diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-11-13 05:14:30 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-11-13 05:14:30 +0000 |
| commit | aa7f3eacf72bd9c070ddd0118835d76b1ebc2bc1 (patch) | |
| tree | bcf7a6979042b1e45de9a80682d652a8671cb2ad /nova/compute | |
| parent | 1756ec29fa5d81aa6e3de90b2612093460deecaa (diff) | |
| parent | 9f59d4af0dd06f8a70e2a647c5932472e0bf0f3a (diff) | |
Merge "Use base image for rescue instance."
Diffstat (limited to 'nova/compute')
| -rw-r--r-- | nova/compute/manager.py | 31 |
1 files changed, 28 insertions, 3 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, |
