Merge "Fix a migration issue of Huawei driver"

This commit is contained in:
Jenkins 2017-09-20 02:38:58 +00:00 committed by Gerrit Code Review
commit 6c236bca3d
2 changed files with 17 additions and 12 deletions

View File

@ -4948,11 +4948,11 @@ class HuaweiFCDriverTestCase(HuaweiTestBase):
@mock.patch.object(rest_client.RestClient, 'rename_lun')
def test_update_migrated_volume_success(self, mock_rename_lun):
model_update = self.driver.update_migrated_volume(None,
self.original_volume,
self.current_volume,
'available')
self.assertEqual({'_name_id': None}, model_update)
model_update = self.driver.update_migrated_volume(
None, self.original_volume, self.current_volume, 'available')
self.assertIsNone(model_update['_name_id'])
self.assertDictEqual(json.loads(PROVIDER_LOCATION),
json.loads(model_update['provider_location']))
@mock.patch.object(rest_client.RestClient, 'rename_lun')
def test_update_migrated_volume_fail(self, mock_rename_lun):
@ -4964,6 +4964,8 @@ class HuaweiFCDriverTestCase(HuaweiTestBase):
'available')
self.assertEqual(self.current_volume.name_id,
model_update['_name_id'])
self.assertDictEqual(json.loads(PROVIDER_LOCATION),
json.loads(model_update['provider_location']))
@mock.patch.object(rest_client.RestClient, 'add_lun_to_partition')
def test_retype_volume_success(self, mock_add_lun_to_partition):

View File

@ -590,18 +590,21 @@ class HuaweiBaseDriver(driver.VolumeDriver):
orig_lun_name = huawei_utils.encode_name(volume.id)
new_lun_id, lun_wwn = huawei_utils.get_volume_lun_id(
self.client, new_volume)
new_metadata = huawei_utils.get_lun_metadata(new_volume)
model_update = {
'provider_location': huawei_utils.to_string(**new_metadata),
}
try:
self.client.rename_lun(new_lun_id, orig_lun_name)
except exception.VolumeBackendAPIException:
LOG.error('Unable to rename lun %s on array.', new_lun_id)
return {'_name_id': new_volume.name_id}
LOG.debug("Renamed lun %(id)s to %(name)s successfully.",
{'id': new_lun_id,
'name': orig_lun_name})
model_update = {'_name_id': None}
model_update['_name_id'] = new_volume.name_id
else:
LOG.debug("Renamed lun %(id)s to %(name)s successfully.",
{'id': new_lun_id,
'name': orig_lun_name})
model_update['_name_id'] = None
return model_update