Skip to content

Commit

Permalink
Sync cinder: Stable generation of strings from dicts at 01/27
Browse files Browse the repository at this point in the history
Infortrend: Stable generation of strings from dicts
openstack/cinder@9e44060
  • Loading branch information
billsung committed Mar 22, 2017
1 parent 69c0d3a commit 3e5cdfb
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 36 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,10 @@ It manages storage by Infortrend CLI tool.
- Clone a volume.
- Extend a volume
- Retype a volume.
- Manage and unmanage a volume.
- Migrate a volume with back-end assistance.
- Live migrate an instance with volumes hosted on an Infortrend backend.
- List volumes.
- Manage and unmanage a snapshot.
- List, manage and unmanage a volume.
- List, manage and unmanage a snapshot.

## How to setup and use

Expand Down
7 changes: 4 additions & 3 deletions infortrend/raidcmd_cli/common_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class InfortrendCommon(object):
2.0.2 - Remove timeout for replication
2.0.3 - Use full ID for volume name
2.1.0 - Support for list manageable volume
- Support for manage/unmanage snapshot
- Support for list/manage/unmanage snapshot
- Remove unnecessary check in snapshot
"""

Expand Down Expand Up @@ -690,7 +690,7 @@ def _create_part_parameters_str(self, extraspecs_dict):
'tiering': 'tier=%s',
'init': 'init=%s',
}
for extraspec in extraspecs_dict.keys():
for extraspec in sorted(extraspecs_dict.keys()):
value = parameters[extraspec] % (extraspecs_dict[extraspec])
parameters_list.append(value)

Expand Down Expand Up @@ -1190,7 +1190,8 @@ def _get_mcs_id(self, channel_id, controller):
return mcs_id

def _concat_provider_location(self, model_dict):
return '@'.join([i + '^' + str(model_dict[i]) for i in model_dict])
keys = sorted(model_dict.keys())
return '@'.join([i + '^' + str(model_dict[i]) for i in keys])

def delete_volume(self, volume):
"""Delete the specific volume."""
Expand Down
65 changes: 35 additions & 30 deletions test/test_infortrend_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,9 +869,10 @@ def test_create_volume(self, log_info):

test_volume = self.cli_data.test_volume
test_model_update = {
'provider_location': 'system_id^%s@partition_id^%s' % (
int(self.cli_data.fake_system_id[0], 16),
self.cli_data.fake_partition_id[0]),
'provider_location': 'partition_id^%s@system_id^%s' % (
self.cli_data.fake_partition_id[0],
int(self.cli_data.fake_system_id[0], 16)
)
}

mock_commands = {
Expand Down Expand Up @@ -994,8 +995,8 @@ def test_delete_volume_without_provider(self, log_info):

test_system_id = self.cli_data.fake_system_id[0]
test_volume = copy.deepcopy(self.cli_data.test_volume)
test_volume['provider_location'] = 'system_id^%s@partition_id^%s' % (
int(test_system_id, 16), 'None')
test_volume['provider_location'] = 'partition_id^%s@system_id^%s' % (
'None', int(test_system_id, 16))
test_partition_id = self.cli_data.fake_partition_id[0]

mock_commands = {
Expand Down Expand Up @@ -1027,9 +1028,10 @@ def test_create_cloned_volume(self, log_info):
test_src_volume = self.cli_data.test_volume
test_dst_part_id = self.cli_data.fake_partition_id[1]
test_model_update = {
'provider_location': 'system_id^%s@partition_id^%s' % (
int(self.cli_data.fake_system_id[0], 16),
self.cli_data.fake_partition_id[1]),
'provider_location': 'partition_id^%s@system_id^%s' % (
self.cli_data.fake_partition_id[1],
int(self.cli_data.fake_system_id[0], 16)
)
}

mock_commands = {
Expand Down Expand Up @@ -1264,9 +1266,10 @@ def test_create_volume_from_snapshot(self, log_info):
test_dst_volume_id = test_dst_volume['id']
test_dst_part_id = self.cli_data.fake_partition_id[1]
test_model_update = {
'provider_location': 'system_id^%s@partition_id^%s' % (
int(self.cli_data.fake_system_id[0], 16),
self.cli_data.fake_partition_id[1]),
'provider_location': 'partition_id^%s@system_id^%s' % (
self.cli_data.fake_partition_id[1],
int(self.cli_data.fake_system_id[0], 16)
)
}
mock_commands = {
'CreatePartition': SUCCEED,
Expand Down Expand Up @@ -1631,9 +1634,10 @@ def test_migrate_volume(self):
test_dst_part_id = self.cli_data.fake_partition_id[2]
test_pair_id = self.cli_data.fake_pair_id[0]
test_model_update = {
'provider_location': 'system_id^%s@partition_id^%s' % (
int(self.cli_data.fake_system_id[0], 16),
test_dst_part_id),
'provider_location': 'partition_id^%s@system_id^%s' % (
test_dst_part_id,
int(self.cli_data.fake_system_id[0], 16)
)
}

mock_commands = {
Expand Down Expand Up @@ -1855,9 +1859,10 @@ def test_manage_existing(self, log_info):
test_partition_id = self.cli_data.test_dst_volume['id']
test_ref_volume_id = test_ref_volume['source-id']
test_model_update = {
'provider_location': 'system_id^%s@partition_id^%s' % (
int(self.cli_data.fake_system_id[0], 16),
test_partition_id),
'provider_location': 'partition_id^%s@system_id^%s' % (
test_partition_id,
int(self.cli_data.fake_system_id[0], 16)
)
}

mock_commands = {
Expand Down Expand Up @@ -1927,9 +1932,10 @@ def test_manage_existing_with_import(self, log_info):
test_pool = self.cli_data.fake_lv_id[0]
test_partition_id = self.cli_data.fake_partition_id[2]
test_model_update = {
'provider_location': 'system_id^%s@partition_id^%s' % (
int(self.cli_data.fake_system_id[0], 16),
test_partition_id),
'provider_location': 'partition_id^%s@system_id^%s' % (
test_partition_id,
int(self.cli_data.fake_system_id[0], 16)
)
}

mock_commands = {
Expand Down Expand Up @@ -2278,9 +2284,10 @@ def test_retype_with_migrate(self):
test_dst_part_id = self.cli_data.fake_partition_id[2]
test_pair_id = self.cli_data.fake_pair_id[0]
test_model_update = {
'provider_location': 'system_id^%s@partition_id^%s' % (
int(self.cli_data.fake_system_id[0], 16),
test_dst_part_id),
'provider_location': 'partition_id^%s@system_id^%s' % (
test_dst_part_id,
int(self.cli_data.fake_system_id[0], 16)
)
}

mock_commands = {
Expand All @@ -2303,9 +2310,7 @@ def test_retype_with_migrate(self):
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())
create_params = 'init=disable min=%sMB' % min_size
expect_cli_cmd = [
mock.call('ShowSnapshot', 'part=%s' % test_src_part_id),
mock.call(
Expand Down Expand Up @@ -2338,8 +2343,8 @@ def test_update_migrated_volume(self):
src_volume = self.cli_data.test_volume
dst_volume = copy.deepcopy(self.cli_data.test_dst_volume)
test_dst_part_id = self.cli_data.fake_partition_id[1]
dst_volume['provider_location'] = 'system_id^%s@partition_id^%s' % (
int(self.cli_data.fake_system_id[0], 16), test_dst_part_id)
dst_volume['provider_location'] = 'partition_id^%s@system_id^%s' % (
test_dst_part_id, int(self.cli_data.fake_system_id[0], 16))
test_model_update = {
'_name_id': None,
'provider_location': dst_volume['provider_location'],
Expand All @@ -2366,8 +2371,8 @@ def test_update_migrated_volume_rename_fail(self):
dst_volume = self.cli_data.test_dst_volume
dst_volume['_name_id'] = 'fake_name_id'
test_dst_part_id = self.cli_data.fake_partition_id[1]
dst_volume['provider_location'] = 'system_id^%s@partition_id^%s' % (
int(self.cli_data.fake_system_id[0], 16), test_dst_part_id)
dst_volume['provider_location'] = 'partition_id^%s@system_id^%s' % (
test_dst_part_id, int(self.cli_data.fake_system_id[0], 16))

mock_commands = {
'SetPartition': FAKE_ERROR_RETURN
Expand Down

0 comments on commit 3e5cdfb

Please sign in to comment.