From ad821f2864cd860d1d198587a441846db4b81e81 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Sun, 8 Nov 2015 22:36:01 +0100 Subject: [PATCH] Port IBM storewize_svc driver to Python 3 Change default preferred node in StorwizeSVCDriver.initialize_connection(). For fiber channel without multipath, pick the first node from the list of sorted nodes, to have a determinist preferred node. The list of nodes is created indirectly using list(set(nodes)) which doesn't have a determinist order. On Python 3, the hash function is randomized, and so list(set()) has an unknown order. A similar change was done for volume throttling in the change Icf7141f772397c7ac08f0f1e21ad74cb86a06351 to port the code to Python 3. Other changes: * Use assertSetEqual() in test_storwize_svc to compare initiator_target_map, because conn_wwpns has a random order on Python 3. * StorwizeSVCDriver._check_volume_copy_ops(): replace dict.items() with list(dict.items()) to iterate on items. On Python 3, dict.items() now returns a view instead of a copy. The loop modifies the dictionary and a dict must not be modified while iterating on it, we really need a copy of items. * StorwizeHelpers: replace a/b with a//b to use integer division on Python 3. * tests-py3.txt: add cinder.tests.unit.test_storwize_svc Partial-Implements: blueprint cinder-python3 Change-Id: I534a85928816d6cce921545e1820311aedd1b884 --- cinder/volume/drivers/ibm/storwize_svc/__init__.py | 2 +- cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py | 2 +- tests-py3.txt | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cinder/volume/drivers/ibm/storwize_svc/__init__.py b/cinder/volume/drivers/ibm/storwize_svc/__init__.py index f41a7d87b..e341ff72c 100644 --- a/cinder/volume/drivers/ibm/storwize_svc/__init__.py +++ b/cinder/volume/drivers/ibm/storwize_svc/__init__.py @@ -749,7 +749,7 @@ class StorwizeSVCDriver(san.SanDriver, def _check_volume_copy_ops(self): LOG.debug("Enter: update volume copy status.") ctxt = context.get_admin_context() - copy_items = self._vdiskcopyops.items() + copy_items = list(self._vdiskcopyops.items()) for vol_id, copy_ops in copy_items: try: volume = self.db.volume_get(ctxt, vol_id) diff --git a/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py b/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py index c4370d0a8..bbc426d45 100644 --- a/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py +++ b/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py @@ -1014,7 +1014,7 @@ class StorwizeHelpers(object): self.ssh.prestartfcmap(fc_map_id) mapping_ready = False wait_time = 5 - max_retries = (timeout / wait_time) + 1 + max_retries = (timeout // wait_time) + 1 for try_number in range(1, max_retries): mapping_attrs = self._get_flashcopy_mapping_attributes(fc_map_id) if (mapping_attrs is None or diff --git a/tests-py3.txt b/tests-py3.txt index 18edc1ea2..3305ce77f 100644 --- a/tests-py3.txt +++ b/tests-py3.txt @@ -105,6 +105,7 @@ cinder.tests.unit.test_smbfs cinder.tests.unit.test_srb cinder.tests.unit.test_solidfire cinder.tests.unit.test_ssh_utils +cinder.tests.unit.test_storwize_svc cinder.tests.unit.test_test cinder.tests.unit.test_test_utils cinder.tests.unit.test_tintri -- 2.45.2