Commit 1fd46fee by Dudás Ádám

vm: check by default whether instance is destroyed

parent 106096b6
...@@ -90,7 +90,8 @@ class Operation(object): ...@@ -90,7 +90,8 @@ class Operation(object):
return self._exec_op(activity=activity, **kwargs) return self._exec_op(activity=activity, **kwargs)
def check_precond(self): def check_precond(self):
pass if self.instance.destroyed_at:
raise self.instance.InstanceDestroyedError(self.instance)
def check_auth(self, user): def check_auth(self, user):
if not self.instance.has_level(user, self.acl_level): if not self.instance.has_level(user, self.acl_level):
...@@ -147,9 +148,6 @@ class DeployOperation(Operation): ...@@ -147,9 +148,6 @@ class DeployOperation(Operation):
activity.resultant_state = 'RUNNING' activity.resultant_state = 'RUNNING'
def _operation(self, activity, user, system): def _operation(self, activity, user, system):
if self.instance.destroyed_at:
raise self.instance.InstanceDestroyedError(self.instance)
self.instance._schedule_vm(activity) self.instance._schedule_vm(activity)
# Deploy virtual images # Deploy virtual images
...@@ -188,10 +186,6 @@ class DestroyOperation(Operation): ...@@ -188,10 +186,6 @@ class DestroyOperation(Operation):
:type task_uuid: str :type task_uuid: str
""") """)
def check_precond(self):
if self.instance.destroyed_at:
raise self.instance.InstanceDestroyedError(self.instance)
def on_commit(self, activity): def on_commit(self, activity):
activity.resultant_state = 'DESTROYED' activity.resultant_state = 'DESTROYED'
...@@ -423,6 +417,7 @@ class SleepOperation(Operation): ...@@ -423,6 +417,7 @@ class SleepOperation(Operation):
description = _("""Suspend virtual machine with memory dump.""") description = _("""Suspend virtual machine with memory dump.""")
def check_precond(self): def check_precond(self):
super(SleepOperation, self).check_precond()
if self.instance.status not in ['RUNNING']: if self.instance.status not in ['RUNNING']:
raise self.instance.WrongStateError(self.instance) raise self.instance.WrongStateError(self.instance)
...@@ -464,6 +459,7 @@ class WakeUpOperation(Operation): ...@@ -464,6 +459,7 @@ class WakeUpOperation(Operation):
""") """)
def check_precond(self): def check_precond(self):
super(WakeUpOperation, self).check_precond()
if self.instance.status not in ['SUSPENDED']: if self.instance.status not in ['SUSPENDED']:
raise self.instance.WrongStateError(self.instance) raise self.instance.WrongStateError(self.instance)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment