From f81f39d34bd3fbfbf30f3c3a70fef68c120534e1 Mon Sep 17 00:00:00 2001 From: Abhinav Shrivastava Date: Mon, 20 Aug 2018 03:53:24 -0400 Subject: [PATCH] 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 --- .../tests/virt/powervm/volume/test_iscsi.py | 15 +++++++++++++++ nova_powervm/virt/powervm/volume/iscsi.py | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/nova_powervm/tests/virt/powervm/volume/test_iscsi.py b/nova_powervm/tests/virt/powervm/volume/test_iscsi.py index 4f076cd4..e569e7d3 100644 --- a/nova_powervm/tests/virt/powervm/volume/test_iscsi.py +++ b/nova_powervm/tests/virt/powervm/volume/test_iscsi.py @@ -588,6 +588,21 @@ class TestISCSIAdapter(test_vol.TestVolumeAdapter): self.vol_drv.post_live_migration_at_destination(mig_vol_stor) 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.' 'vios_uuids', new_callable=mock.PropertyMock) def test_is_volume_on_vios(self, mock_vios_uuids): diff --git a/nova_powervm/virt/powervm/volume/iscsi.py b/nova_powervm/virt/powervm/volume/iscsi.py index e889184f..62840d47 100644 --- a/nova_powervm/virt/powervm/volume/iscsi.py +++ b/nova_powervm/virt/powervm/volume/iscsi.py @@ -172,6 +172,21 @@ class IscsiVolumeAdapter(volume.VscsiVolumeAdapter, if volume_key in mig_data: 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): """Returns whether or not the volume is on a VIOS.