From 99c51e34230394cadf0b82e364ea10c38e193979 Mon Sep 17 00:00:00 2001 From: Phil Day Date: Fri, 7 Jun 2013 15:18:03 +0100 Subject: Allow reboot or rebuild from vm_state=Error In general most operations are only valid on an instance that has booted successfully at least once so this change extends the instance state check logic to include evidence that the instance has been successfully started at least once. This enables more operations to be allowed in against instances in an Error state. For example reboot and rebuild are useful recover options for an instance which has reached an error state, but not if the instance failed during its initial build. With this change the only actions allowed on an instance which has never booted successfully are delete and force_delete. Soft delete is not allowed, as the restore is in effect a start unless there is specific virt driver support. In addition the following actions are now allowed against instances in an Error state providing the instance has booted at least once: Reboot, Rebuild, and Rescue. Fixes bug: 1183946 Change-Id: I63fd8d2a182df5cf12754892e8076933b3b1e79f --- nova/api/openstack/common.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'nova/api') diff --git a/nova/api/openstack/common.py b/nova/api/openstack/common.py index bec919f4b..dd746e23d 100644 --- a/nova/api/openstack/common.py +++ b/nova/api/openstack/common.py @@ -358,9 +358,12 @@ def raise_http_conflict_for_instance_invalid_state(exc, action): """ attr = exc.kwargs.get('attr') state = exc.kwargs.get('state') + not_launched = exc.kwargs.get('not_launched') if attr and state: msg = _("Cannot '%(action)s' while instance is in %(attr)s " "%(state)s") % {'action': action, 'attr': attr, 'state': state} + elif not_launched: + msg = _("Cannot '%s' an instance which has never been active") % action else: # At least give some meaningful message msg = _("Instance is in an invalid state for '%s'") % action -- cgit