From 8705f49a4ad9c6f3a93f33e333475285a8f70a30 Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Tue, 29 Jan 2013 07:26:48 +0000 Subject: Fix rebuild with volumes attached This patch assumes that the correct behavior for instance rebuild is to maintain attached volumes across a rebuild operation. Two important changes are: 1) Detaching all volumes during a rebuild so that they won't be 'in-use' when prep_block_devices is called to reattach them. 2) xenapi: Allowing additional volumes, not just root volumes, to be attached before boot. To handle this, we cycle through all block-device-mappings, not just the root-device, create the VDI, and later, create the VBD. Small changes include: * Using `connection_data` instead of `dev_params` (to match other parts of the code base) * Renaming `get_vdis_for_boot_from_vol` to `get_vdi_uuid_for_volume` to reflect its more general and simpler semantics. Fixes bug 1071547 Change-Id: Ie54a16be4bae2a718ed7d506f32777d0847b9089 --- nova/tests/xenapi/test_vm_utils.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'nova/tests') diff --git a/nova/tests/xenapi/test_vm_utils.py b/nova/tests/xenapi/test_vm_utils.py index 6d7f9a624..a701efdd9 100644 --- a/nova/tests/xenapi/test_vm_utils.py +++ b/nova/tests/xenapi/test_vm_utils.py @@ -14,7 +14,7 @@ XENSM_TYPE = 'xensm' ISCSI_TYPE = 'iscsi' -def get_fake_dev_params(sr_type): +def get_fake_connection_data(sr_type): fakes = {XENSM_TYPE: {'sr_uuid': 'falseSR', 'name_label': 'fake_storage', 'name_description': 'test purposes', @@ -73,16 +73,16 @@ class GetInstanceForVdisForSrTestCase(stubs.XenAPITestBase): self.assertEquals([], result) - def test_get_vdis_for_boot_from_vol_with_sr_uuid(self): - dev_params = get_fake_dev_params(XENSM_TYPE) + def test_get_vdi_uuid_for_volume_with_sr_uuid(self): + connection_data = get_fake_connection_data(XENSM_TYPE) stubs.stubout_session(self.stubs, fake.SessionBase) driver = xenapi_conn.XenAPIDriver(False) - result = vm_utils.get_vdis_for_boot_from_vol(driver._session, - dev_params) - self.assertEquals(result['root']['uuid'], 'falseVDI') + vdi_uuid = vm_utils.get_vdi_uuid_for_volume( + driver._session, connection_data) + self.assertEquals(vdi_uuid, 'falseVDI') - def test_get_vdis_for_boot_from_vol_failure(self): + def test_get_vdi_uuid_for_volume_failure(self): stubs.stubout_session(self.stubs, fake.SessionBase) driver = xenapi_conn.XenAPIDriver(False) @@ -90,19 +90,19 @@ class GetInstanceForVdisForSrTestCase(stubs.XenAPITestBase): return None self.stubs.Set(volume_utils, 'introduce_sr', bad_introduce_sr) - dev_params = get_fake_dev_params(XENSM_TYPE) + connection_data = get_fake_connection_data(XENSM_TYPE) self.assertRaises(exception.NovaException, - vm_utils.get_vdis_for_boot_from_vol, - driver._session, dev_params) + vm_utils.get_vdi_uuid_for_volume, + driver._session, connection_data) - def test_get_vdis_for_boot_from_iscsi_vol_missing_sr_uuid(self): - dev_params = get_fake_dev_params(ISCSI_TYPE) + def test_get_vdi_uuid_for_volume_from_iscsi_vol_missing_sr_uuid(self): + connection_data = get_fake_connection_data(ISCSI_TYPE) stubs.stubout_session(self.stubs, fake.SessionBase) driver = xenapi_conn.XenAPIDriver(False) - result = vm_utils.get_vdis_for_boot_from_vol(driver._session, - dev_params) - self.assertNotEquals(result['root']['uuid'], None) + vdi_uuid = vm_utils.get_vdi_uuid_for_volume( + driver._session, connection_data) + self.assertNotEquals(vdi_uuid, None) class VMRefOrRaiseVMFoundTestCase(test.TestCase): -- cgit