Browse Source

Merge "Fix python3 compatibility of rbd get_fsid" into stable/rocky

tags/18.2.2
Zuul 1 month ago
parent
commit
fa12df80fd

+ 7
- 0
nova/tests/unit/virt/libvirt/storage/test_rbd.py View File

@@ -119,6 +119,13 @@ class RbdTestCase(test.NoDBTestCase):
119 119
             self.assertFalse(self.driver.is_cloneable({'url': loc},
120 120
                                                       image_meta))
121 121
 
122
+    @mock.patch.object(rbd_utils, 'RADOSClient')
123
+    def test_rbddriver(self, mock_client):
124
+        client = mock_client.return_value
125
+        client.__enter__.return_value = client
126
+        client.cluster.get_fsid.side_effect = lambda: b'abc'
127
+        self.assertEqual('abc', self.driver.get_fsid())
128
+
122 129
     @mock.patch.object(rbd_utils.RBDDriver, 'get_fsid')
123 130
     def test_cloneable(self, mock_get_fsid):
124 131
         mock_get_fsid.return_value = 'abc'

+ 3
- 1
nova/virt/libvirt/storage/rbd_utils.py View File

@@ -28,6 +28,7 @@ from oslo_concurrency import processutils
28 28
 from oslo_log import log as logging
29 29
 from oslo_serialization import jsonutils
30 30
 from oslo_service import loopingcall
31
+from oslo_utils import encodeutils
31 32
 from oslo_utils import excutils
32 33
 from oslo_utils import units
33 34
 
@@ -194,7 +195,7 @@ class RBDDriver(object):
194 195
 
195 196
     def get_fsid(self):
196 197
         with RADOSClient(self) as client:
197
-            return client.cluster.get_fsid()
198
+            return encodeutils.safe_decode(client.cluster.get_fsid())
198 199
 
199 200
     def is_cloneable(self, image_location, image_meta):
200 201
         url = image_location['url']
@@ -204,6 +205,7 @@ class RBDDriver(object):
204 205
             LOG.debug('not cloneable: %s', e)
205 206
             return False
206 207
 
208
+        fsid = encodeutils.safe_decode(fsid)
207 209
         if self.get_fsid() != fsid:
208 210
             reason = '%s is in a different ceph cluster' % url
209 211
             LOG.debug(reason)

Loading…
Cancel
Save