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/compute/manager.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'nova/compute') diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 831e825fe..eb2ce2c54 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -1366,18 +1366,18 @@ class ComputeManager(manager.SchedulerDependentManager): block_device_mapping_get_all_by_instance( context, instance) - if recreate: - for bdm in self._get_volume_bdms(bdms): - volume = self.volume_api.get(context, bdm['volume_id']) + # NOTE(sirp): this detach is necessary b/c we will reattach the + # volumes in _prep_block_devices below. + for bdm in self._get_volume_bdms(bdms): + volume = self.volume_api.get(context, bdm['volume_id']) + self.volume_api.detach(context, volume) - # We can't run volume disconnect on source because - # the host is down. Just marking volume as detached - # in db, anyway the zombie instance going to be deleted - # from source during init_host when host comes back - self.volume_api.detach(context.elevated(), volume) - else: + if not recreate: + block_device_info = self._get_volume_block_device_info( + self._get_volume_bdms(bdms)) self.driver.destroy(instance, - self._legacy_nw_info(network_info)) + self._legacy_nw_info(network_info), + block_device_info=block_device_info) instance = self._instance_update( context, instance['uuid'], -- cgit