rbd: Remove unnecessary 'encode' calls

The ceph 'rbd' library (librados) now supports Python 3 and, by
extension, unicode strings [1]. There is no need to keep these encode
calls around: if a user is running nova under Python 3, then it is safe
to assume that they are using a Python 3-compatible version of librados.

[1] https://github.com/ceph/ceph/blob/v11.1.0/src/pybind/rados/rados.pyx#L30-L36

Change-Id: Ic1afb3e66bd0991047f97fa74f9d2fbbb837401a
This commit is contained in:
Stephen Finucane 2016-12-19 08:59:59 +00:00
parent 5bcfaf3e8a
commit 1e70cb8d4d
3 changed files with 12 additions and 8 deletions

View File

@ -13,7 +13,6 @@
from eventlet import tpool
import mock
import six
from nova.compute import task_states
from nova import exception
@ -223,7 +222,7 @@ class RbdTestCase(test.NoDBTestCase):
self.driver.clone(location, self.volume_name)
args = [client_stack[0].ioctx, six.b(image), six.b(snap),
args = [client_stack[0].ioctx, image, snap,
client_stack[1].ioctx, str(self.volume_name)]
kwargs = {'features': client.features}
rbd.clone.assert_called_once_with(*args, **kwargs)

View File

@ -66,10 +66,9 @@ class RBDVolumeProxy(object):
read_only=False):
client, ioctx = driver._connect_to_rados(pool)
try:
snap_name = snapshot.encode('utf8') if snapshot else None
self.volume = tpool.Proxy(rbd.Image(ioctx, name.encode('utf8'),
snapshot=snap_name,
read_only=read_only))
self.volume = tpool.Proxy(rbd.Image(ioctx, name,
snapshot=snapshot,
read_only=read_only))
except rbd.ImageNotFound:
with excutils.save_and_reraise_exception():
LOG.debug("rbd image %s does not exist", name)
@ -236,8 +235,8 @@ class RBDDriver(object):
with RADOSClient(self, dest_pool) as dest_client:
try:
RbdProxy().clone(src_client.ioctx,
image.encode('utf-8'),
snapshot.encode('utf-8'),
image,
snapshot,
dest_client.ioctx,
str(dest_name),
features=src_client.features)

View File

@ -0,0 +1,6 @@
---
upgrade:
- |
Nova now requires Ceph/librados >= 11.1.0 if running under Python 3 with
the RBD image backend for the libvirt driver. Requirements for Python 2
users or users using a different backend remain unchanged.