iSCSI: Clean up source VIOS on migration

Whenever a VM migrated from one host to another
the source VIOS had hdisk remaining after LPM.
The current change makes sure that VIOS hdisks
get cleaned up after migration.

Change-Id: I3c085a872abbaf6e6e91b2496314a06ce8e7ba58
This commit is contained in:
Abhinav Shrivastava 2018-08-20 03:53:24 -04:00
parent dcc2bfa1c1
commit f81f39d34b
2 changed files with 30 additions and 0 deletions

View File

@ -588,6 +588,21 @@ class TestISCSIAdapter(test_vol.TestVolumeAdapter):
self.vol_drv.post_live_migration_at_destination(mig_vol_stor) self.vol_drv.post_live_migration_at_destination(mig_vol_stor)
mock_set_udid.assert_called_with(mock.ANY, 'udid') mock_set_udid.assert_called_with(mock.ANY, 'udid')
def test_post_live_migr_source(self):
# Bad path. volume id not found
bad_data = {'vscsi-BAD': 'udid1'}
# good path.
good_data = {'vscsi-' + self.serial: 'udid1'}
with mock.patch.object(self.vol_drv, '_cleanup_volume') as mock_cln:
self.vol_drv.post_live_migration_at_source(bad_data)
mock_cln.assert_called_once_with(None)
mock_cln.reset_mock()
self.vol_drv.post_live_migration_at_source(good_data)
mock_cln.assert_called_once_with('udid1')
@mock.patch('nova_powervm.virt.powervm.volume.driver.PowerVMVolumeAdapter.' @mock.patch('nova_powervm.virt.powervm.volume.driver.PowerVMVolumeAdapter.'
'vios_uuids', new_callable=mock.PropertyMock) 'vios_uuids', new_callable=mock.PropertyMock)
def test_is_volume_on_vios(self, mock_vios_uuids): def test_is_volume_on_vios(self, mock_vios_uuids):

View File

@ -172,6 +172,21 @@ class IscsiVolumeAdapter(volume.VscsiVolumeAdapter,
if volume_key in mig_data: if volume_key in mig_data:
self._set_udid(mig_data[volume_key]) self._set_udid(mig_data[volume_key])
def post_live_migration_at_source(self, migrate_data):
"""Performs post live migration for the volume on the source host.
This method can be used to handle any steps that need to taken on
the source host after the VM is on the destination.
:param migrate_data: volume migration data
"""
# Get the udid of the volume to remove the hdisk for. We can't
# use the connection information because LPM 'refreshes' it, which
# wipes out our data, so we use the data from the destination host
# to avoid having to discover the hdisk to get the udid.
udid = migrate_data.get('vscsi-' + self.volume_id)
self._cleanup_volume(udid)
def is_volume_on_vios(self, vios_w): def is_volume_on_vios(self, vios_w):
"""Returns whether or not the volume is on a VIOS. """Returns whether or not the volume is on a VIOS.