diff --git a/cinder/tests/unit/volume/drivers/hpe/test_hpe3par.py b/cinder/tests/unit/volume/drivers/hpe/test_hpe3par.py index 468e95a46c6..6b605bf85ac 100644 --- a/cinder/tests/unit/volume/drivers/hpe/test_hpe3par.py +++ b/cinder/tests/unit/volume/drivers/hpe/test_hpe3par.py @@ -2917,6 +2917,23 @@ class HPE3PARBaseDriver(object): 'provider_location': None} self.assertEqual(expected_update, actual_update) + expected = [ + mock.call.modifyVolume( + 'osv-0DM4qZEVSKON-DXN-NwVpw', + {'newName': u'tsv-0DM4qZEVSKON-DXN-NwVpw'}), + mock.call.modifyVolume( + 'osv-0DM4qZEVSKON-AAAAAAAAA', + {'newName': u'osv-0DM4qZEVSKON-DXN-NwVpw'}), + mock.call.modifyVolume( + 'tsv-0DM4qZEVSKON-DXN-NwVpw', + {'newName': u'osv-0DM4qZEVSKON-AAAAAAAAA'}) + ] + + mock_client.assert_has_calls( + self.standard_login + + expected + + self.standard_logout) + def test_update_migrated_volume_attached(self): mock_client = self.setup_driver() fake_old_volume = {'id': self.VOLUME_ID} diff --git a/cinder/volume/drivers/hpe/hpe_3par_common.py b/cinder/volume/drivers/hpe/hpe_3par_common.py index 015a92d444d..259911d2fc6 100644 --- a/cinder/volume/drivers/hpe/hpe_3par_common.py +++ b/cinder/volume/drivers/hpe/hpe_3par_common.py @@ -260,10 +260,11 @@ class HPE3PARCommon(object): 3.0.33 - Added replication feature in retype flow. bug #1680313 3.0.34 - Add cloned volume to vvset in online copy. bug #1664464 3.0.35 - Add volume to consistency group if flag enabled. bug #1702317 + 3.0.36 - Swap volume name in migration. bug #1699733 """ - VERSION = "3.0.35" + VERSION = "3.0.36" stats = {} @@ -1096,7 +1097,7 @@ class HPE3PARCommon(object): {'vol': volume_name, 'ex': ex}) return model_update - def _get_3par_vol_name(self, volume_id): + def _get_3par_vol_name(self, volume_id, temp_vol=False): """Get converted 3PAR volume name. Converts the openstack volume id from @@ -1112,7 +1113,13 @@ class HPE3PARCommon(object): and / with - """ volume_name = self._encode_name(volume_id) - return "osv-%s" % volume_name + if temp_vol: + # is this a temporary volume + # this is done during migration + prefix = "tsv-%s" + else: + prefix = "osv-%s" + return prefix % volume_name def _get_3par_snap_name(self, snapshot_id, temp_snap=False): snapshot_name = self._encode_name(snapshot_id) @@ -2523,10 +2530,16 @@ class HPE3PARCommon(object): if original_volume_status == 'available': # volume isn't attached and can be updated original_name = self._get_3par_vol_name(volume['id']) + temp_name = self._get_3par_vol_name(volume['id'], temp_vol=True) current_name = self._get_3par_vol_name(new_volume['id']) try: volumeMods = {'newName': original_name} + volumeTempMods = {'newName': temp_name} + volumeCurrentMods = {'newName': current_name} + # swap volume name in backend + self.client.modifyVolume(original_name, volumeTempMods) self.client.modifyVolume(current_name, volumeMods) + self.client.modifyVolume(temp_name, volumeCurrentMods) LOG.info("Volume name changed from %(tmp)s to %(orig)s", {'tmp': current_name, 'orig': original_name}) except Exception as e: