Commit faa40f86 by Őry Máté

vm: move Instance.suspend_vm to SuspendVmOperation

parent 71c7bedb
......@@ -785,13 +785,6 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
raise humanize_exception(ugettext_noop(
"Operation aborted by user."), e)
def suspend_vm(self, timeout=230):
queue_name = self.get_remote_queue_name('vm', 'slow')
return vm_tasks.sleep.apply_async(args=[self.vm_name,
self.mem_dump['path']],
queue=queue_name
).get(timeout=timeout)
def delete_mem_dump(self, timeout=15):
queue_name = self.mem_dump['datastore'].get_remote_queue_name(
'storage', 'fast')
......
......@@ -735,20 +735,26 @@ class SleepOperation(InstanceOperation):
else:
activity.resultant_state = 'ERROR'
def _operation(self, activity, timeout=240):
# Destroy networks
with activity.sub_activity('shutdown_net', readable_name=ugettext_noop(
def _operation(self, activity):
with activity.sub_activity('shutdown_net',
readable_name=ugettext_noop(
"shutdown network")):
self.instance.shutdown_net()
self.instance._suspend_vm(parent_activity=activity)
self.instance.yield_node()
# Suspend vm
with activity.sub_activity('suspending',
readable_name=ugettext_noop(
"suspend virtual machine")):
self.instance.suspend_vm(timeout=timeout)
@register_operation
class SuspendVmOperation(SubOperationMixin, RemoteInstanceOperation):
id = "_suspend_vm"
name = _("suspend virtual machine")
task = vm_tasks.suspend
remote_queue = ("vm", "slow")
timeout = 600
self.instance.yield_node()
# VNC port needs to be kept
def _get_remote_args(self, **kwargs):
return (super(SleepOperation.SuspendVmOperation, self)
._get_remote_args(**kwargs)
+ [self.instance.mem_dump['path']])
@register_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