From cbc0df73015702a2503f83885ea11355c8f2bcc4 Mon Sep 17 00:00:00 2001 From: Nikola Dipanov Date: Thu, 7 Mar 2013 17:48:54 +0100 Subject: Prevent rescue for volume-backed instances This patch prevents rescuing of volume_backed instances, by checking for it in the API layer and raising an exception if instance on which a rescue was attempted is volume backed. Rescue is supposed to just be a way to log into a wayward instance if something goes wrong with the base image that may have had some data (logfiles etc.) and make it possible to grab that - block devices are assumed to be accessible by re-attaching them, and are considered persistant so no need for rescue there. Fixes bug: #1067744 blueprint: improve-boot-from-volume Change-Id: I8a4b1ccff7406837de3086aa413034e8e647b8fa --- nova/compute/api.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'nova/compute') diff --git a/nova/compute/api.py b/nova/compute/api.py index 83ea98c8f..dc90748a4 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -2142,6 +2142,14 @@ class API(base.Base): @check_instance_state(vm_state=[vm_states.ACTIVE, vm_states.STOPPED]) def rescue(self, context, instance, rescue_password=None): """Rescue the given instance.""" + # TODO(ndipanov): This check can be generalized as a decorator to + # check for valid combinations of src and dests - for now check + # if it's booted from volume only + if self.is_volume_backed_instance(context, instance, None): + reason = _("Cannot rescue a volume-backed instance") + raise exception.InstanceNotRescuable(instance_id=instance['uuid'], + reason=reason) + self.update(context, instance, vm_state=vm_states.ACTIVE, @@ -2414,6 +2422,9 @@ class API(base.Base): instance['uuid']) def is_volume_backed_instance(self, context, instance, bdms): + if not instance['image_ref']: + return True + if bdms is None: bdms = self.get_instance_bdms(context, instance) -- cgit