Commit 054e4941 by Dudás Ádám

vm: method for manually changing instance state

closes #68
parent 9daef8ff
...@@ -22,7 +22,7 @@ from taggit.managers import TaggableManager ...@@ -22,7 +22,7 @@ from taggit.managers import TaggableManager
from acl.models import AclBase from acl.models import AclBase
from storage.models import Disk from storage.models import Disk
from ..tasks import local_tasks, vm_tasks, agent_tasks from ..tasks import local_tasks, vm_tasks, agent_tasks
from .activity import instance_activity from .activity import instance_activity, InstanceActivity
from .common import BaseResourceConfigModel, Lease from .common import BaseResourceConfigModel, Lease
from .network import Interface from .network import Interface
from .node import Node, Trait from .node import Node, Trait
...@@ -273,6 +273,15 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel): ...@@ -273,6 +273,15 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
act = None act = None
return 'NOSTATE' if act is None else act.resultant_state return 'NOSTATE' if act is None else act.resultant_state
def manual_state_change(self, new_state, reason=None, user=None):
act = InstanceActivity.create(code_suffix='manual_state_change',
instance=self, user=user)
act.finished = act.started
act.result = reason
act.resultant_state = new_state
act.succeeded = True
act.save()
def vm_state_changed(self, new_state): def vm_state_changed(self, new_state):
pass pass
......
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