Merge "VNX: Fix metadata get overriden issue"

This commit is contained in:
Jenkins 2015-11-20 05:32:37 +00:00 committed by Gerrit Code Review
commit ad5bb097d1
2 changed files with 9 additions and 6 deletions

View File

@ -130,7 +130,7 @@ class EMCVNXCLIDriverTestData(object):
'display_description': 'test volume', 'display_description': 'test volume',
'volume_type_id': None, 'volume_type_id': None,
'provider_location': 'system^FNM11111|type^lun|id^1|version^05.03.00', 'provider_location': 'system^FNM11111|type^lun|id^1|version^05.03.00',
'volume_metadata': [{'key': 'lun_type', 'value': 'lun'}]} 'metadata': {'key': 'lun_type', 'value': 'lun'}}
volume_in_cg = { volume_in_cg = {
'name': 'vol2', 'name': 'vol2',
@ -279,7 +279,7 @@ class EMCVNXCLIDriverTestData(object):
'volume_attachment': [], 'volume_attachment': [],
'provider_location': 'provider_location':
'system^FNM11111|type^lun|id^1|version^05.03.00', 'system^FNM11111|type^lun|id^1|version^05.03.00',
'_name_id': None, 'volume_metadata': []} '_name_id': None, 'metadata': {}}
test_new_type = {'name': 'voltype0', 'qos_specs_id': None, test_new_type = {'name': 'voltype0', 'qos_specs_id': None,
'deleted': False, 'deleted': False,
@ -312,7 +312,7 @@ class EMCVNXCLIDriverTestData(object):
'volume_attachment': [], 'volume_attachment': [],
'attach_status': 'detached', 'attach_status': 'detached',
'volume_type': [], 'volume_type': [],
'_name_id': None, 'volume_metadata': []} '_name_id': None, 'metadata': {}}
test_volume5 = {'migration_status': None, 'availability_zone': 'nova', test_volume5 = {'migration_status': None, 'availability_zone': 'nova',
'id': '1181d1b2-cea3-4f55-8fa8-3360d026ce25', 'id': '1181d1b2-cea3-4f55-8fa8-3360d026ce25',
@ -330,7 +330,7 @@ class EMCVNXCLIDriverTestData(object):
'volume_attachment': [], 'volume_attachment': [],
'attach_status': 'detached', 'attach_status': 'detached',
'volume_type': [], 'volume_type': [],
'_name_id': None, 'volume_metadata': []} '_name_id': None, 'metadata': {}}
test_new_type2 = {'name': 'voltype0', 'qos_specs_id': None, test_new_type2 = {'name': 'voltype0', 'qos_specs_id': None,
'deleted': False, 'deleted': False,
@ -3182,7 +3182,6 @@ Time Remaining: 0 second(s)
'-FAST'] '-FAST']
emc_vnx_cli.CommandLineHelper.get_array_serial = mock.Mock( emc_vnx_cli.CommandLineHelper.get_array_serial = mock.Mock(
return_value={'array_serial': "FNM00124500890"}) return_value={'array_serial': "FNM00124500890"})
self.driver.retype(None, self.testData.test_volume3, self.driver.retype(None, self.testData.test_volume3,
new_type_data, new_type_data,
diff_data, diff_data,

View File

@ -2967,11 +2967,15 @@ class EMCVnxCliBase(object):
return model_update return model_update
def _get_volume_metadata(self, volume): def _get_volume_metadata(self, volume):
# Since versionedobjects is partially merged, metadata
# may come from 'volume_metadata' or 'metadata', here
# we need to take care both of them.
volume_metadata = {} volume_metadata = {}
if 'volume_metadata' in volume: if 'volume_metadata' in volume:
for metadata in volume['volume_metadata']: for metadata in volume['volume_metadata']:
volume_metadata[metadata['key']] = metadata['value'] volume_metadata[metadata['key']] = metadata['value']
return volume_metadata return volume_metadata
return volume['metadata'] if 'metadata' in volume else {}
def dumps_provider_location(self, pl_dict): def dumps_provider_location(self, pl_dict):
return '|'.join([k + '^' + pl_dict[k] for k in pl_dict]) return '|'.join([k + '^' + pl_dict[k] for k in pl_dict])