expected = []
mock_client.assert_has_calls(expected)
+ def test_update_migrated_volume(self):
+ mock_client = self.setup_driver()
+ fake_old_volume = {'id': self.VOLUME_ID}
+ provider_location = 'foo'
+ fake_new_volume = {'id': self.CLONE_ID,
+ '_name_id': self.CLONE_ID,
+ 'provider_location': provider_location}
+ original_volume_status = 'available'
+ with mock.patch.object(hpcommon.HP3PARCommon,
+ '_create_client') as mock_create_client:
+ mock_create_client.return_value = mock_client
+ actual_update = self.driver.update_migrated_volume(
+ context.get_admin_context(), fake_old_volume,
+ fake_new_volume, original_volume_status)
+
+ expected_update = {'_name_id': None,
+ 'provider_location': None}
+ self.assertEqual(expected_update, actual_update)
+
+ def test_update_migrated_volume_attached(self):
+ mock_client = self.setup_driver()
+ fake_old_volume = {'id': self.VOLUME_ID}
+ provider_location = 'foo'
+ fake_new_volume = {'id': self.CLONE_ID,
+ '_name_id': self.CLONE_ID,
+ 'provider_location': provider_location}
+ original_volume_status = 'in-use'
+
+ with mock.patch.object(hpcommon.HP3PARCommon,
+ '_create_client') as mock_create_client:
+ mock_create_client.return_value = mock_client
+ actual_update = self.driver.update_migrated_volume(
+ context.get_admin_context(), fake_old_volume,
+ fake_new_volume, original_volume_status)
+
+ expected_update = {'_name_id': fake_new_volume['_name_id'],
+ 'provider_location': provider_location}
+ self.assertEqual(expected_update, actual_update)
+
def test_attach_volume(self):
# setup_mock_client drive with default configuration
# and return the mock HTTP 3PAR client
2.0.49 - Added client CPG stats to driver volume stats. bug #1482741
2.0.50 - Add over subscription support
2.0.51 - Adds consistency group support
+ 2.0.52 - Added update_migrated_volume. bug # 1492023
"""
- VERSION = "2.0.51"
+ VERSION = "2.0.52"
stats = {}
dbg_ret)
return ret
+ def update_migrated_volume(self, context, volume, new_volume,
+ original_volume_status):
+ """Rename the new (temp) volume to it's original name.
+
+
+ This method tries to rename the new volume to it's original
+ name after the migration has completed.
+
+ """
+ LOG.debug("Update volume name for %(id)s", {'id': new_volume['id']})
+ name_id = None
+ provider_location = None
+ if original_volume_status == 'available':
+ # volume isn't attached and can be updated
+ original_name = self._get_3par_vol_name(volume['id'])
+ current_name = self._get_3par_vol_name(new_volume['id'])
+ try:
+ volumeMods = {'newName': original_name}
+ self.client.modifyVolume(current_name, volumeMods)
+ LOG.info(_LI("Volume name changed from %(tmp)s to %(orig)s"),
+ {'tmp': current_name, 'orig': original_name})
+ except Exception as e:
+ LOG.error(_LE("Changing the volume name from %(tmp)s to "
+ "%(orig)s failed because %(reason)s"),
+ {'tmp': current_name, 'orig': original_name,
+ 'reason': e})
+ name_id = new_volume['_name_id'] or new_volume['id']
+ provider_location = new_volume['provider_location']
+ else:
+ # the backend can't change the name.
+ 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 _convert_to_base_volume(self, volume, new_cpg=None):
try:
type_info = self.get_volume_settings_from_type(volume)
2.0.18 - Changed initialize_connection to use getHostVLUNs. #1475064
2.0.19 - Adds consistency group support
2.0.20 - Update driver to use ABC metaclasses
+ 2.0.21 - Added update_migrated_volume. bug # 1492023
"""
- VERSION = "2.0.20"
+ VERSION = "2.0.21"
def __init__(self, *args, **kwargs):
super(HP3PARFCDriver, self).__init__(*args, **kwargs)
finally:
self._logout(common)
+ def update_migrated_volume(self, context, volume, new_volume,
+ original_volume_status):
+ """Update the name of the migrated volume to it's new ID."""
+ common = self._login()
+ try:
+ return common.update_migrated_volume(context, volume, new_volume,
+ original_volume_status)
+ finally:
+ self._logout(common)
+
def get_pool(self, volume):
common = self._login()
try:
2.0.20 - Adding changes to support 3PAR iSCSI multipath.
2.0.21 - Adds consistency group support
2.0.22 - Update driver to use ABC metaclasses
+ 2.0.23 - Added update_migrated_volume. bug # 1492023
"""
- VERSION = "2.0.22"
+ VERSION = "2.0.23"
def __init__(self, *args, **kwargs):
super(HP3PARISCSIDriver, self).__init__(*args, **kwargs)
finally:
self._logout(common)
+ def update_migrated_volume(self, context, volume, new_volume,
+ original_volume_status):
+ """Update the name of the migrated volume to it's new ID."""
+ common = self._login()
+ try:
+ return common.update_migrated_volume(context, volume, new_volume,
+ original_volume_status)
+ finally:
+ self._logout(common)
+
def get_pool(self, volume):
common = self._login()
try: