summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-11-13 05:14:30 +0000
committerGerrit Code Review <review@openstack.org>2012-11-13 05:14:30 +0000
commitaa7f3eacf72bd9c070ddd0118835d76b1ebc2bc1 (patch)
treebcf7a6979042b1e45de9a80682d652a8671cb2ad
parent1756ec29fa5d81aa6e3de90b2612093460deecaa (diff)
parent9f59d4af0dd06f8a70e2a647c5932472e0bf0f3a (diff)
downloadnova-aa7f3eacf72bd9c070ddd0118835d76b1ebc2bc1.tar.gz
nova-aa7f3eacf72bd9c070ddd0118835d76b1ebc2bc1.tar.xz
nova-aa7f3eacf72bd9c070ddd0118835d76b1ebc2bc1.zip
Merge "Use base image for rescue instance."
-rw-r--r--nova/compute/manager.py31
-rw-r--r--nova/virt/xenapi/vmops.py11
2 files changed, 34 insertions, 8 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index fed8b32d3..9011196b2 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -1484,6 +1484,27 @@ class ComputeManager(manager.SchedulerDependentManager):
instance=instance)
self.driver.inject_file(instance, path, file_contents)
+ def _get_rescue_image_ref(self, context, instance):
+ """Determine what image should be used to boot the rescue VM. """
+ system_meta = self.db.instance_system_metadata_get(
+ context, instance['uuid'])
+
+ rescue_image_ref = system_meta.get('image_base_image_ref')
+
+ # 1. First try to use base image associated with instance's current
+ # image.
+ #
+ # The idea here is to provide the customer with a rescue environment
+ # which they are familiar with. So, if they built their instance off of
+ # a Debian image, their rescue VM wil also be Debian.
+ if rescue_image_ref:
+ return rescue_image_ref
+
+ # 2. As a last resort, use instance's current image
+ LOG.warn(_('Unable to find a different image to use for rescue VM,'
+ ' using instance\'s current image'))
+ return instance['image_ref']
+
@exception.wrap_exception(notifier=notifier, publisher_id=publisher_id())
@reverts_task_state
@wrap_instance_fault
@@ -1499,12 +1520,16 @@ class ComputeManager(manager.SchedulerDependentManager):
utils.generate_password(CONF.password_length))
network_info = self._get_instance_nw_info(context, instance)
- image_meta = _get_image_meta(context, instance['image_ref'])
+
+ # Boot the instance using the 'base' image instead of the user's
+ # current (possibly broken) image
+ rescue_image_ref = self._get_rescue_image_ref(context, instance)
+ rescue_image_meta = _get_image_meta(context, rescue_image_ref)
with self._error_out_instance_on_exception(context, instance['uuid']):
self.driver.rescue(context, instance,
- self._legacy_nw_info(network_info), image_meta,
- admin_password)
+ self._legacy_nw_info(network_info),
+ rescue_image_meta, admin_password)
current_power_state = self._get_power_state(context, instance)
self._instance_update(context,
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py
index cc0d48d22..df25b9992 100644
--- a/nova/virt/xenapi/vmops.py
+++ b/nova/virt/xenapi/vmops.py
@@ -238,10 +238,10 @@ class VMOps(object):
False, False)
def _create_disks(self, context, instance, name_label, disk_image_type,
- block_device_info=None):
+ image_meta, block_device_info=None):
vdis = vm_utils.get_vdis_for_instance(context, self._session,
instance, name_label,
- instance['image_ref'],
+ image_meta['id'],
disk_image_type,
block_device_info=block_device_info)
# Just get the VDI ref once
@@ -269,9 +269,10 @@ class VMOps(object):
return vm_utils.determine_disk_image_type(image_meta)
@step
- def create_disks_step(undo_mgr, disk_image_type):
+ def create_disks_step(undo_mgr, disk_image_type, image_meta):
vdis = self._create_disks(context, instance, name_label,
- disk_image_type, block_device_info)
+ disk_image_type, image_meta,
+ block_device_info)
def undo_create_disks():
vdi_refs = [vdi['ref'] for vdi in vdis.values()
@@ -387,7 +388,7 @@ class VMOps(object):
bdev_set_default_root(undo_mgr)
disk_image_type = determine_disk_image_type_step(undo_mgr)
- vdis = create_disks_step(undo_mgr, disk_image_type)
+ vdis = create_disks_step(undo_mgr, disk_image_type, image_meta)
kernel_file, ramdisk_file = create_kernel_ramdisk_step(undo_mgr)
vm_ref = create_vm_record_step(undo_mgr, vdis, disk_image_type,
kernel_file, ramdisk_file)