Merge "XtremIO: Implement update_migrated_volume"

This commit is contained in:
Jenkins 2016-08-04 20:55:44 +00:00 committed by Gerrit Code Review
commit cdda1b8fdb
2 changed files with 48 additions and 0 deletions

View File

@ -495,6 +495,33 @@ class EMCXIODriverISCSITestCase(BaseEMCXIODriverTestCase):
self.driver.client.handle_errors,
response, '', '')
def test_update_migrated_volume(self, req):
original = self.data.test_volume
new = self.data.test_volume2
update = (self.driver.
update_migrated_volume({},
original, new, 'available'))
req.assert_called_once_with('volumes', 'PUT',
{'name': original['id']}, new['id'],
None, 'v2')
self.assertEqual({'_name_id': None,
'provider_location': None}, update)
def test_update_migrated_volume_failed_rename(self, req):
req.side_effect = exception.VolumeBackendAPIException(
data='failed rename')
original = self.data.test_volume
new = copy.deepcopy(self.data.test_volume2)
fake_provider = '__provider'
new['provider_location'] = fake_provider
new['_name_id'] = None
update = (self.driver.
update_migrated_volume({},
original, new, 'available'))
self.assertEqual({'_name_id': new['id'],
'provider_location': fake_provider},
update)
# ##### Connection #####
def test_no_portals_configured(self, req):
req.side_effect = xms_request

View File

@ -469,6 +469,27 @@ class XtremIOVolumeDriver(san.SanDriver):
except exception.NotFound:
LOG.info(_LI("snapshot %s doesn't exist"), snapshot.id)
def update_migrated_volume(self, ctxt, volume, new_volume,
original_volume_status):
# as the volume name is used to id the volume we need to rename it
name_id = None
provider_location = None
current_name = new_volume['id']
original_name = volume['id']
try:
data = {'name': original_name}
self.client.req('volumes', 'PUT', data, name=current_name)
except exception.VolumeBackendAPIException:
LOG.error(_LE('Unable to rename the logical volume '
'for volume: %s'), original_name)
# If the rename fails, _name_id should be set to the new
# volume id and provider_location should be set to the
# one from the new volume as well.
name_id = new_volume['_name_id'] or new_volume['id']
provider_location = new_volume['provider_location']
return {'_name_id': name_id, 'provider_location': provider_location}
def _update_volume_stats(self):
sys = self.client.get_cluster()
physical_space = int(sys["ud-ssd-space"]) / units.Mi