diff options
| -rw-r--r-- | nova/compute/api.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py index 7c8b3cbfe..6ff8d96a1 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -92,6 +92,18 @@ def _is_able_to_shutdown(instance, instance_id): return True +def _is_delete_queued(instance, instance_id): + vm_state = instance["vm_state"] + task_state = instance["task_state"] + + if vm_state != vm_states.DELETED: + LOG.warn(_("Instance %(instance_id)s is not in a 'deleted' state. It " + "is currently %(vm_state)s. Action aborted.") % locals()) + return False + + return True + + class API(base.Base): """API for interacting with the compute manager.""" @@ -786,6 +798,9 @@ class API(base.Base): """Restore a previously deleted (but not reclaimed) instance.""" instance = self._get_instance(context, instance_id, 'restore') + if not _is_delete_queued(instance, instance_id): + return + self.update(context, instance_id, vm_state=vm_states.ACTIVE, @@ -803,6 +818,9 @@ class API(base.Base): """Force delete a previously deleted (but not reclaimed) instance.""" instance = self._get_instance(context, instance_id, 'force delete') + if not _is_delete_queued(instance, instance_id): + return + self.update(context, instance_id, task_state=task_states.DELETING) |
