]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Port drbdmanagedrv driver to Python 3
authorVictor Stinner <vstinner@redhat.com>
Mon, 29 Jun 2015 13:53:44 +0000 (15:53 +0200)
committerVictor Stinner <vstinner@redhat.com>
Tue, 30 Jun 2015 14:01:54 +0000 (16:01 +0200)
* Replace map() with a list-comprehension where a list is expected
* Replace apply(fn, args) with fn(*args)
* Use str.replace() to remove "{" and "}" characters in _clean_uuid(),
  instead of using str.translate()
* Use literal syntax to create a new dictionary instead of using
  dict() + dict.items()
* tox.ini: add cinder.tests.unit.test_drbdmanagedrv to Python 3.4

Blueprint cinder-python3
Change-Id: I4cb3ae422381442b778de024882e75f31eded5eb

cinder/tests/unit/test_drbdmanagedrv.py
cinder/volume/drivers/drbdmanagedrv.py
tox.ini

index 8f91dc606f1ef61fa0101ad630da4e3800a6a338..14cc24552f446be302fcd766a06add210ac6f0ee 100644 (file)
@@ -200,13 +200,13 @@ class DrbdManageTestCase(test.TestCase):
         return None
 
     def fake_issue_dbus_call(self, fn, *args):
-        return apply(fn, args)
+        return fn(*args)
 
     def fake_issue_dbus_connect(self):
         self.odm = DrbdManageFakeDriver()
 
     def call_or_reconnect(self, method, *params):
-        return apply(method, params)
+        return method(*params)
 
     # Tests per se
 
index 8350c1239ad01c25373d8ddc03a0ad4056ce050b..fcac7901f16aa9c7c187ea82f321d8f564fdd879 100644 (file)
@@ -138,7 +138,9 @@ class DrbdManageDriver(driver.VolumeDriver):
         # Some uuid library versions put braces around the result!?
         # We don't want them, just a plain [0-9a-f-]+ string.
         id = str(uuid.uuid4())
-        return id.translate(None, "{}")
+        id = id.replace("{", "")
+        id = id.replace("}", "")
+        return id
 
     def _check_result(self, res, ignore=None, ret=0):
         seen_success = False
@@ -397,8 +399,7 @@ class DrbdManageDriver(driver.VolumeDriver):
         temp_id = self._clean_uuid()
         snapshot = {'id': temp_id}
 
-        self.create_snapshot(dict(snapshot.items() +
-                                  [('volume_id', src_vref['id'])]))
+        self.create_snapshot({'id': temp_id, 'volume_id': src_vref['id']})
 
         self.create_volume_from_snapshot(volume, snapshot)
 
@@ -468,7 +469,7 @@ class DrbdManageDriver(driver.VolumeDriver):
                                            self.empty_dict)
         self._check_result(res)
 
-        nodes = map(lambda d: d[0], data)
+        nodes = [d[0] for d in data]
         if len(nodes) < 1:
             raise exception.VolumeBackendAPIException(
                 _('Snapshot res "%s" that is not deployed anywhere?') %
diff --git a/tox.ini b/tox.ini
index 144737a4ad56bfb204ac04f18dfb1f7a0770c745..0007c5604a2a0ee020049c1963feb943dd444d76 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -44,6 +44,7 @@ commands =
     cinder.tests.unit.test_dellfc \
     cinder.tests.unit.test_dellsc \
     cinder.tests.unit.test_dellscapi \
+    cinder.tests.unit.test_drbdmanagedrv \
     cinder.tests.unit.test_emc_xtremio \
     cinder.tests.unit.test_eqlx \
     cinder.tests.unit.test_evaluator \