diff options
| author | Nikola Dipanov <ndipanov@redhat.com> | 2013-03-07 17:48:54 +0100 |
|---|---|---|
| committer | Nikola Dipanov <ndipanov@redhat.com> | 2013-03-09 11:24:08 +0100 |
| commit | cbc0df73015702a2503f83885ea11355c8f2bcc4 (patch) | |
| tree | 7d77ad773476b541895c6fa7f8e77b6b8ad37450 /nova/compute | |
| parent | 7477bbfdad9cfa6383a1ef1824f630a2c9938212 (diff) | |
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
Diffstat (limited to 'nova/compute')
| -rw-r--r-- | nova/compute/api.py | 11 |
1 files changed, 11 insertions, 0 deletions
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) |
