Merge "Fix python3 compatibility of rbd get_fsid" into stable/stein
This commit is contained in:
commit
176891004b
|
@ -119,6 +119,13 @@ class RbdTestCase(test.NoDBTestCase):
|
|||
self.assertFalse(self.driver.is_cloneable({'url': loc},
|
||||
image_meta))
|
||||
|
||||
@mock.patch.object(rbd_utils, 'RADOSClient')
|
||||
def test_rbddriver(self, mock_client):
|
||||
client = mock_client.return_value
|
||||
client.__enter__.return_value = client
|
||||
client.cluster.get_fsid.side_effect = lambda: b'abc'
|
||||
self.assertEqual('abc', self.driver.get_fsid())
|
||||
|
||||
@mock.patch.object(rbd_utils.RBDDriver, 'get_fsid')
|
||||
def test_cloneable(self, mock_get_fsid):
|
||||
mock_get_fsid.return_value = 'abc'
|
||||
|
|
|
@ -28,6 +28,7 @@ from oslo_concurrency import processutils
|
|||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_service import loopingcall
|
||||
from oslo_utils import encodeutils
|
||||
from oslo_utils import excutils
|
||||
from oslo_utils import units
|
||||
|
||||
|
@ -194,7 +195,7 @@ class RBDDriver(object):
|
|||
|
||||
def get_fsid(self):
|
||||
with RADOSClient(self) as client:
|
||||
return client.cluster.get_fsid()
|
||||
return encodeutils.safe_decode(client.cluster.get_fsid())
|
||||
|
||||
def is_cloneable(self, image_location, image_meta):
|
||||
url = image_location['url']
|
||||
|
@ -204,6 +205,7 @@ class RBDDriver(object):
|
|||
LOG.debug('not cloneable: %s', e)
|
||||
return False
|
||||
|
||||
fsid = encodeutils.safe_decode(fsid)
|
||||
if self.get_fsid() != fsid:
|
||||
reason = '%s is in a different ceph cluster' % url
|
||||
LOG.debug(reason)
|
||||
|
|
Loading…
Reference in New Issue