]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Port zonemanager to Python 3
authorVictor Stinner <vstinner@redhat.com>
Tue, 24 Nov 2015 16:33:37 +0000 (17:33 +0100)
committerVictor Stinner <vstinner@redhat.com>
Tue, 24 Nov 2015 20:00:09 +0000 (21:00 +0100)
* Replace xrange() with six.moves.range()
* Replace filter() with list-comprehension to get a list on Python 3.
* get_formatted_wwn(): join byte strings with b':' instead of ':'
* ZoneManager: don't pass arguments to object.__new__()
* tests-py3.txt: add zonemanager tests

Partial-Implements: blueprint cinder-python3
Change-Id: Ia3fcd816c5afd7a08b8769fbc9d2839b70c8c3fb

cinder/tests/unit/zonemanager/test_cisco_fc_zone_client_cli.py
cinder/zonemanager/drivers/brocade/brcd_fc_san_lookup_service.py
cinder/zonemanager/drivers/brocade/brcd_fc_zone_driver.py
cinder/zonemanager/drivers/cisco/cisco_fc_san_lookup_service.py
cinder/zonemanager/fc_zone_manager.py
tests-py3.txt

index 9e63a9c2b2def31dd5faab790f349ee843692920..c5c057c3253069ad95da79cf7f6ecc69c24060a2 100644 (file)
@@ -19,6 +19,7 @@
 
 import mock
 from oslo_concurrency import processutils
+from six.moves import range
 
 from cinder import exception
 from cinder import test
@@ -219,7 +220,7 @@ class TestCiscoFCZoneClientCLI(cli.CiscoFCZoneClientCLI, test.TestCase):
 
         expected_num_calls = 5
         expected_calls = []
-        for i in xrange(expected_num_calls):
+        for i in range(expected_num_calls):
             expected_calls.append(mock.call(cmd_list, True))
 
         self.assertEqual(expected_num_calls, run_ssh_mock.call_count)
index 3e405996383310b8520eff4330c8889a8dc05c20..fd79de3f5f270299452eed77e6b7ec4654bec4f8 100644 (file)
@@ -139,10 +139,10 @@ class BrcdFCSanLookupService(fc_service.FCSanLookupService):
                           "caller-%s", formatted_initiator_list)
                 LOG.debug("Lookup service:target list from "
                           "caller-%s", formatted_target_list)
-                visible_targets = filter(lambda x: x in formatted_target_list,
-                                         nsinfo)
-                visible_initiators = filter(lambda x: x in
-                                            formatted_initiator_list, nsinfo)
+                visible_targets = [x for x in nsinfo
+                                   if x in formatted_target_list]
+                visible_initiators = [x for x in nsinfo
+                                      if x in formatted_initiator_list]
 
                 if visible_targets:
                     LOG.debug("Filtered targets is: %s", visible_targets)
index 8b8fe227b1656c50ac86aacf7b13e7f5deb125e7..e865ea0b833692f43217184c7c6e8c1c47c8461a 100644 (file)
@@ -105,7 +105,7 @@ class BrcdFCZoneDriver(fc_zone_driver.FCZoneDriver):
         if len(wwn_str) != 16:
             return wwn_str
         else:
-            return ':'.join(
+            return b':'.join(
                 [wwn_str[i:i + 2] for i in range(0, len(wwn_str), 2)])
 
     @lockutils.synchronized('brcd', 'fcfabric-', True)
index 8db7743d2e8ddc5bd5479e470ea2a7735ca1c5ba..5edc9ef16ad72665b73a7a3fd5fa2493e0fb6219 100644 (file)
@@ -137,10 +137,10 @@ class CiscoFCSanLookupService(fc_service.FCSanLookupService):
                           formatted_initiator_list)
                 LOG.debug("Lookup service:target list from caller-%s",
                           formatted_target_list)
-                visible_targets = filter(lambda x: x in formatted_target_list,
-                                         nsinfo)
-                visible_initiators = filter(lambda x: x in
-                                            formatted_initiator_list, nsinfo)
+                visible_targets = [x for x in nsinfo
+                                   if x in formatted_target_list]
+                visible_initiators = [x for x in nsinfo
+                                      if x in formatted_initiator_list]
 
                 if visible_targets:
                     LOG.debug("Filtered targets is: %s", visible_targets)
index c19565a853858e17820b321ed7dc187f7295f89d..2d598b5fc6d4430750f6a87dbd6ecc0cec86d85c 100644 (file)
@@ -81,7 +81,7 @@ class ZoneManager(fc_common.FCCommon):
 
     def __new__(class_, *args, **kwargs):
         if not hasattr(class_, "_instance"):
-            class_._instance = object.__new__(class_, *args, **kwargs)
+            class_._instance = object.__new__(class_)
         return class_._instance
 
     def __init__(self, **kwargs):
index 3305ce77f45929016c904883909c4c7b9d4485e2..a4b71b02d0a88e189134cbdcd5e7e7c4231ed0e5 100644 (file)
@@ -137,3 +137,13 @@ cinder.tests.unit.windows.test_windows
 cinder.tests.unit.windows.test_windows_remotefs
 cinder.tests.unit.windows.test_windows_utils
 cinder.tests.unit.wsgi
+cinder.tests.unit.zonemanager.test_brcd_fc_san_lookup_service
+cinder.tests.unit.zonemanager.test_brcd_fc_zone_client_cli
+cinder.tests.unit.zonemanager.test_brcd_fc_zone_driver
+cinder.tests.unit.zonemanager.test_brcd_lookup_service
+cinder.tests.unit.zonemanager.test_cisco_fc_san_lookup_service
+cinder.tests.unit.zonemanager.test_cisco_fc_zone_client_cli
+cinder.tests.unit.zonemanager.test_cisco_fc_zone_driver
+cinder.tests.unit.zonemanager.test_cisco_lookup_service
+cinder.tests.unit.zonemanager.test_fc_zone_manager
+cinder.tests.unit.zonemanager.test_volume_driver