Port infortrend driver to Python 3
* InfortrendCommon: sort dictionary items to get a reliable behaviour. On Python 3, the hash function is randomized by default. - _get_minimun_mapping_channel_id(): sort LUN mapping by keys - _do_fc_connection(): sort initiator_target_map keys * InfortrendCommon._create_partition_with_pool(): cast gi_to_mi() result to int. On Python 3, gi_to_mi() returns a float (a/b always return a float, even for int/int). * test_retype_with_migrate(): build create_params using a dictionary to create parameter in the same order than the driver. * tests-py3.txt: cinder.tests.unit.test_infortrend_common Change-Id: Idd849a9cd5dc0ad17c5d8d54da489346c018e778
This commit is contained in:
parent
f0ef5e50e4
commit
071ee18240
@ -1997,6 +1997,10 @@ class InfortrendiSCSICommonTestCase(InfortrendTestCass):
|
|||||||
rc, model_update = self.driver.retype(
|
rc, model_update = self.driver.retype(
|
||||||
None, test_volume, test_new_type, test_diff, test_host)
|
None, test_volume, test_new_type, test_diff, test_host)
|
||||||
|
|
||||||
|
min_size = int(test_volume['size'] * 1024 * 0.2)
|
||||||
|
create_params = {'init': 'disable', 'min': '%sMB' % min_size}
|
||||||
|
create_params = ' '.join('%s=%s' % (key, value)
|
||||||
|
for key, value in create_params.items())
|
||||||
expect_cli_cmd = [
|
expect_cli_cmd = [
|
||||||
mock.call('ShowSnapshot', 'part=%s' % test_src_part_id),
|
mock.call('ShowSnapshot', 'part=%s' % test_src_part_id),
|
||||||
mock.call(
|
mock.call(
|
||||||
@ -2004,8 +2008,7 @@ class InfortrendiSCSICommonTestCase(InfortrendTestCass):
|
|||||||
fake_pool['pool_id'],
|
fake_pool['pool_id'],
|
||||||
test_volume['id'].replace('-', ''),
|
test_volume['id'].replace('-', ''),
|
||||||
'size=%s' % (test_volume['size'] * 1024),
|
'size=%s' % (test_volume['size'] * 1024),
|
||||||
'init=disable min=%sMB' % (
|
create_params,
|
||||||
int(test_volume['size'] * 1024 * 0.2))
|
|
||||||
),
|
),
|
||||||
mock.call('ShowPartition'),
|
mock.call('ShowPartition'),
|
||||||
mock.call(
|
mock.call(
|
||||||
|
@ -522,7 +522,7 @@ class InfortrendCommon(object):
|
|||||||
if extraspecs_dict:
|
if extraspecs_dict:
|
||||||
cmd = self._create_part_parameters_str(extraspecs_dict)
|
cmd = self._create_part_parameters_str(extraspecs_dict)
|
||||||
|
|
||||||
commands = (pool_id, volume_id, 'size=%s' % volume_size, cmd)
|
commands = (pool_id, volume_id, 'size=%s' % int(volume_size), cmd)
|
||||||
self._execute('CreatePartition', *commands)
|
self._execute('CreatePartition', *commands)
|
||||||
|
|
||||||
def _create_part_parameters_str(self, extraspecs_dict):
|
def _create_part_parameters_str(self, extraspecs_dict):
|
||||||
@ -776,7 +776,9 @@ class InfortrendCommon(object):
|
|||||||
empty_lun_num = 0
|
empty_lun_num = 0
|
||||||
min_map_chl = -1
|
min_map_chl = -1
|
||||||
|
|
||||||
for key, value in self.map_dict[controller].items():
|
# Sort items to get a reliable behaviour. Dictionary items
|
||||||
|
# are iterated in a random order because of hash randomization.
|
||||||
|
for key, value in sorted(self.map_dict[controller].items()):
|
||||||
if empty_lun_num < len(value):
|
if empty_lun_num < len(value):
|
||||||
min_map_chl = key
|
min_map_chl = key
|
||||||
empty_lun_num = len(value)
|
empty_lun_num = len(value)
|
||||||
@ -1303,7 +1305,9 @@ class InfortrendCommon(object):
|
|||||||
|
|
||||||
map_lun = self._get_common_lun_map_id(wwpn_channel_info)
|
map_lun = self._get_common_lun_map_id(wwpn_channel_info)
|
||||||
|
|
||||||
for initiator_wwpn in initiator_target_map:
|
# Sort items to get a reliable behaviour. Dictionary items
|
||||||
|
# are iterated in a random order because of hash randomization.
|
||||||
|
for initiator_wwpn in sorted(initiator_target_map):
|
||||||
for target_wwpn in initiator_target_map[initiator_wwpn]:
|
for target_wwpn in initiator_target_map[initiator_wwpn]:
|
||||||
channel_id = wwpn_channel_info[target_wwpn.upper()]['channel']
|
channel_id = wwpn_channel_info[target_wwpn.upper()]['channel']
|
||||||
controller = wwpn_channel_info[target_wwpn.upper()]['slot']
|
controller = wwpn_channel_info[target_wwpn.upper()]['slot']
|
||||||
|
@ -116,6 +116,7 @@ cinder.tests.unit.test_ibm_xiv_ds8k
|
|||||||
cinder.tests.unit.test_ibmnas
|
cinder.tests.unit.test_ibmnas
|
||||||
cinder.tests.unit.test_image_utils
|
cinder.tests.unit.test_image_utils
|
||||||
cinder.tests.unit.test_infortrend_cli
|
cinder.tests.unit.test_infortrend_cli
|
||||||
|
cinder.tests.unit.test_infortrend_common
|
||||||
cinder.tests.unit.test_migrations
|
cinder.tests.unit.test_migrations
|
||||||
cinder.tests.unit.test_misc
|
cinder.tests.unit.test_misc
|
||||||
cinder.tests.unit.test_netapp
|
cinder.tests.unit.test_netapp
|
||||||
|
Loading…
Reference in New Issue
Block a user