Commit c342b6da by Guba Sándor

vm: rewrite manual_state_change

parent dc0fd302
...@@ -270,6 +270,7 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin, ...@@ -270,6 +270,7 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
('create_vm', _('Can create a new VM.')), ('create_vm', _('Can create a new VM.')),
('config_ports', _('Can configure port forwards.')), ('config_ports', _('Can configure port forwards.')),
('recover', _('Can recover a destroyed VM.')), ('recover', _('Can recover a destroyed VM.')),
('change_state', _('Can change VM state to NOSTATE.')),
) )
verbose_name = _('instance') verbose_name = _('instance')
verbose_name_plural = _('instances') verbose_name_plural = _('instances')
...@@ -442,19 +443,13 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin, ...@@ -442,19 +443,13 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
self.time_of_suspend, self.time_of_delete = self.get_renew_times() self.time_of_suspend, self.time_of_delete = self.get_renew_times()
super(Instance, self).clean(*args, **kwargs) super(Instance, self).clean(*args, **kwargs)
def manual_state_change(self, new_state="NOSTATE", reason=None, user=None): def manual_state_change(self, activity, new_state="NOSTATE",
reason=None, user=None):
""" Manually change state of an Instance. """ Manually change state of an Instance.
Can be used to recover VM after administrator fixed problems. Can be used to recover VM after administrator fixed problems.
""" """
# TODO cancel concurrent activity (if exists) activity.resultant_state = new_state
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):
# log state change # log state change
......
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