]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Port hitachi driver to Python 3
authorVictor Stinner <vstinner@redhat.com>
Mon, 29 Jun 2015 20:20:16 +0000 (22:20 +0200)
committerVictor Stinner <vstinner@redhat.com>
Tue, 30 Jun 2015 12:53:11 +0000 (14:53 +0200)
* On Python 3, shlex expects Unicode, not bytes: don't encode
* Replace map() with list-comprehension where a list is expected.
* tox.ini: add cinder.tests.unit.test_hitachi_hbsd_horcm_fc to Python 3.4

Blueprint cinder-python3
Change-Id: Id0db0dabef98f7dd8331a5149e88dee0622917b3

cinder/volume/drivers/hitachi/hbsd_basiclib.py
cinder/volume/drivers/hitachi/hbsd_horcm.py
tox.ini

index 8fc59912f544e3b1d0c3801aa638d12f0538e14b..f4bc7577937a67894721b3c14a1db996ea6beba6 100644 (file)
@@ -244,7 +244,7 @@ class HBSDBasicLib(object):
         cmd = [cmd]
 
         if args:
-            if isinstance(args, six.text_type):
+            if six.PY2 and isinstance(args, six.text_type):
                 cmd += shlex.split(args.encode())
             else:
                 cmd += shlex.split(args)
index 0ebe8f00d289d4fec6b26f475bd3191117e0e5cf..c551f624ca2677774fcb240179f02b971e3ad718 100644 (file)
@@ -167,7 +167,7 @@ class HBSDHORCM(basic_lib.HBSDBasicLib):
             if not i.isdigit():
                 msg = basic_lib.output_err(601, param='hitachi_horcm_numbers')
                 raise exception.HBSDError(message=msg)
-        self.conf.hitachi_horcm_numbers = map(int, numbers)
+        self.conf.hitachi_horcm_numbers = [int(num) for num in numbers]
         inst = self.conf.hitachi_horcm_numbers[0]
         pair_inst = self.conf.hitachi_horcm_numbers[1]
         if inst == pair_inst:
diff --git a/tox.ini b/tox.ini
index 144737a4ad56bfb204ac04f18dfb1f7a0770c745..4ab49a9cda8f9a8867e5831e3ed9fb8010afa078 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -49,6 +49,7 @@ commands =
     cinder.tests.unit.test_evaluator \
     cinder.tests.unit.test_exception \
     cinder.tests.unit.test_gpfs \
+    cinder.tests.unit.test_hitachi_hbsd_horcm_fc \
     cinder.tests.unit.test_hitachi_hbsd_snm2_fc \
     cinder.tests.unit.test_hitachi_hbsd_snm2_iscsi \
     cinder.tests.unit.test_hp_xp_fc \