Commit 1e4c94ea by Bach Dániel

dashboard: add reset_node option to VmStateChangeForm

parent 8f6b93ba
...@@ -752,6 +752,7 @@ class VmStateChangeForm(forms.Form): ...@@ -752,6 +752,7 @@ class VmStateChangeForm(forms.Form):
"but don't interrupt any tasks.")) "but don't interrupt any tasks."))
new_state = forms.ChoiceField(Instance.STATUS, label=_( new_state = forms.ChoiceField(Instance.STATUS, label=_(
"New status")) "New status"))
reset_node = forms.BooleanField(required=False, label=_("Reset node"))
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
show_interrupt = kwargs.pop('show_interrupt') show_interrupt = kwargs.pop('show_interrupt')
......
...@@ -811,7 +811,8 @@ class ChangeStateOperation(InstanceOperation): ...@@ -811,7 +811,8 @@ class ChangeStateOperation(InstanceOperation):
required_perms = ('vm.emergency_change_state', ) required_perms = ('vm.emergency_change_state', )
concurrency_check = False concurrency_check = False
def _operation(self, user, activity, new_state="NOSTATE", interrupt=False): def _operation(self, user, activity, new_state="NOSTATE", interrupt=False,
reset_node=False):
activity.resultant_state = new_state activity.resultant_state = new_state
if interrupt: if interrupt:
msg_txt = ugettext_noop("Activity is forcibly interrupted.") msg_txt = ugettext_noop("Activity is forcibly interrupted.")
...@@ -821,6 +822,10 @@ class ChangeStateOperation(InstanceOperation): ...@@ -821,6 +822,10 @@ class ChangeStateOperation(InstanceOperation):
i.finish(False, result=message) i.finish(False, result=message)
logger.error('Forced finishing activity %s', i) logger.error('Forced finishing activity %s', i)
if reset_node:
self.instance.node = None
self.instance.save()
class NodeOperation(Operation): class NodeOperation(Operation):
async_operation = abortable_async_node_operation async_operation = abortable_async_node_operation
......
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