Port violin driver to Python 3
* Replace dict.items()[0] with list(dict.items())[0], same for dict.values() * Replace dict.iteritems() with dict.items() * Replace dict.itervalues() with dict.values() * Replace a/b with a//b to get integer on Python 3. * test_get_active_fc_targets(): ignore order when comparing active FC targets. On Python 3, the hash function is randomized and so dictionaries values are returned in a random order. Partial-Implements: blueprint cinder-python3 Change-Id: If2c50606ae68b7f645bfdbe5aaf7510a512e709a
This commit is contained in:
parent
a37618f55b
commit
1874f7cfae
@ -385,9 +385,9 @@ class V7000FCPDriverTestCase(test.TestCase):
|
||||
|
||||
result = self.driver._get_active_fc_targets()
|
||||
|
||||
self.assertEqual(['2100001b9745e230', '2100001b9745e25f',
|
||||
'2100001b9745e231', '2100001b9745e25e'],
|
||||
result)
|
||||
self.assertEqual({'2100001b9745e230', '2100001b9745e25f',
|
||||
'2100001b9745e231', '2100001b9745e25e'},
|
||||
set(result))
|
||||
|
||||
def test_initialize_connection(self):
|
||||
lun_id = 1
|
||||
|
@ -115,7 +115,7 @@ class V6000Common(object):
|
||||
ret_dict = self.vip.basic.get_node_values(
|
||||
"/vshare/state/local/container/*")
|
||||
if ret_dict:
|
||||
self.container = ret_dict.items()[0][1]
|
||||
self.container = list(ret_dict.items())[0][1]
|
||||
|
||||
def check_for_setup_error(self):
|
||||
"""Returns an error if prerequisites aren't met."""
|
||||
|
@ -430,8 +430,8 @@ class V6000FCDriver(driver.FibreChannelDriver):
|
||||
free_gb = 0
|
||||
v = self.common.vip
|
||||
|
||||
master_cluster_id = v.basic.get_node_values(
|
||||
'/cluster/state/master_id').values()[0]
|
||||
master_cluster_id = list(v.basic.get_node_values(
|
||||
'/cluster/state/master_id').values())[0]
|
||||
|
||||
bn1 = "/vshare/state/global/%s/container/%s/total_bytes" \
|
||||
% (master_cluster_id, self.common.container)
|
||||
@ -440,14 +440,14 @@ class V6000FCDriver(driver.FibreChannelDriver):
|
||||
resp = v.basic.get_node_values([bn1, bn2])
|
||||
|
||||
if bn1 in resp:
|
||||
total_gb = resp[bn1] / units.Gi
|
||||
total_gb = resp[bn1] // units.Gi
|
||||
else:
|
||||
LOG.warning(_LW("Failed to receive update for total_gb stat!"))
|
||||
if 'total_capacity_gb' in self.stats:
|
||||
total_gb = self.stats['total_capacity_gb']
|
||||
|
||||
if bn2 in resp:
|
||||
free_gb = resp[bn2] / units.Gi
|
||||
free_gb = resp[bn2] // units.Gi
|
||||
else:
|
||||
LOG.warning(_LW("Failed to receive update for free_gb stat!"))
|
||||
if 'free_capacity_gb' in self.stats:
|
||||
|
@ -449,8 +449,8 @@ class V6000ISCSIDriver(driver.ISCSIDriver):
|
||||
free_gb = 0
|
||||
v = self.common.vip
|
||||
|
||||
master_cluster_id = v.basic.get_node_values(
|
||||
'/cluster/state/master_id').values()[0]
|
||||
master_cluster_id = list(v.basic.get_node_values(
|
||||
'/cluster/state/master_id').values())[0]
|
||||
|
||||
bn1 = "/vshare/state/global/%s/container/%s/total_bytes" \
|
||||
% (master_cluster_id, self.common.container)
|
||||
@ -459,14 +459,14 @@ class V6000ISCSIDriver(driver.ISCSIDriver):
|
||||
resp = v.basic.get_node_values([bn1, bn2])
|
||||
|
||||
if bn1 in resp:
|
||||
total_gb = resp[bn1] / units.Gi
|
||||
total_gb = resp[bn1] // units.Gi
|
||||
else:
|
||||
LOG.warning(_LW("Failed to receive update for total_gb stat!"))
|
||||
if 'total_capacity_gb' in self.stats:
|
||||
total_gb = self.stats['total_capacity_gb']
|
||||
|
||||
if bn2 in resp:
|
||||
free_gb = resp[bn2] / units.Gi
|
||||
free_gb = resp[bn2] // units.Gi
|
||||
else:
|
||||
LOG.warning(_LW("Failed to receive update for free_gb stat!"))
|
||||
if 'free_capacity_gb' in self.stats:
|
||||
@ -554,7 +554,7 @@ class V6000ISCSIDriver(driver.ISCSIDriver):
|
||||
|
||||
ret_dict = conn.basic.get_node_values("/system/hostname")
|
||||
if ret_dict:
|
||||
hostname = ret_dict.items()[0][1]
|
||||
hostname = list(ret_dict.items())[0][1]
|
||||
else:
|
||||
LOG.debug("Unable to fetch gateway hostname for %s.", mg_to_query)
|
||||
|
||||
|
@ -133,7 +133,7 @@ class V7000Common(object):
|
||||
thin_lun = True
|
||||
# Set the actual allocation size for thin lun
|
||||
# default here is 10%
|
||||
size_mb = size_mb / 10
|
||||
size_mb = size_mb // 10
|
||||
|
||||
typeid = volume['volume_type_id']
|
||||
if typeid:
|
||||
@ -143,7 +143,7 @@ class V7000Common(object):
|
||||
thin_lun = True
|
||||
# Set the actual allocation size for thin lun
|
||||
# default here is 10%
|
||||
size_mb = size_mb / 10
|
||||
size_mb = size_mb // 10
|
||||
|
||||
spec_value = self._get_volume_type_extra_spec(volume, "dedup")
|
||||
if spec_value and spec_value.lower() == "true":
|
||||
@ -153,7 +153,7 @@ class V7000Common(object):
|
||||
# Set the actual allocation size for thin lun
|
||||
# default here is 10%. The actual allocation may
|
||||
# different, depending on other factors
|
||||
size_mb = full_size_mb / 10
|
||||
size_mb = full_size_mb // 10
|
||||
|
||||
# Extract the storage_pool name if one is specified
|
||||
pool = self._get_violin_extra_spec(volume, "storage_pool")
|
||||
@ -817,7 +817,7 @@ class V7000Common(object):
|
||||
if typeid:
|
||||
volume_type = volume_types.get_volume_type(ctxt, typeid)
|
||||
volume_specs = volume_type.get('extra_specs')
|
||||
for key, val in volume_specs.iteritems():
|
||||
for key, val in volume_specs.items():
|
||||
|
||||
# Strip the prefix "capabilities"
|
||||
if ':' in key:
|
||||
@ -842,7 +842,7 @@ class V7000Common(object):
|
||||
if typeid:
|
||||
volume_type = volume_types.get_volume_type(ctxt, typeid)
|
||||
volume_specs = volume_type.get('extra_specs')
|
||||
for key, val in volume_specs.iteritems():
|
||||
for key, val in volume_specs.items():
|
||||
|
||||
# Strip the prefix "violin"
|
||||
if ':' in key:
|
||||
|
@ -269,8 +269,8 @@ class V7000FCPDriver(driver.FibreChannelDriver):
|
||||
|
||||
for x in all_devices:
|
||||
if socket.getfqdn(x['owner']) == array_name:
|
||||
total_gb += x['size_mb'] / 1024
|
||||
free_gb += x['availsize_mb'] / 1024
|
||||
total_gb += x['size_mb'] // 1024
|
||||
free_gb += x['availsize_mb'] // 1024
|
||||
|
||||
backend_name = self.configuration.volume_backend_name
|
||||
data['volume_backend_name'] = backend_name or self.__class__.__name__
|
||||
@ -297,7 +297,7 @@ class V7000FCPDriver(driver.FibreChannelDriver):
|
||||
active_gw_fcp_wwns = []
|
||||
|
||||
fc_info = v.adapter.get_fc_info()
|
||||
for x in fc_info.itervalues():
|
||||
for x in fc_info.values():
|
||||
active_gw_fcp_wwns.append(x[0])
|
||||
|
||||
return active_gw_fcp_wwns
|
||||
|
@ -80,6 +80,10 @@ cinder.tests.unit.test_solidfire
|
||||
cinder.tests.unit.test_test
|
||||
cinder.tests.unit.test_test_utils
|
||||
cinder.tests.unit.test_v6000_common
|
||||
cinder.tests.unit.test_v6000_fcp
|
||||
cinder.tests.unit.test_v6000_iscsi
|
||||
cinder.tests.unit.test_v7000_common
|
||||
cinder.tests.unit.test_v7000_fcp
|
||||
cinder.tests.unit.test_vmware_vmdk
|
||||
cinder.tests.unit.test_vmware_volumeops
|
||||
cinder.tests.unit.test_volume
|
||||
|
Loading…
x
Reference in New Issue
Block a user