Commit 3d0afb21 by Bach Dániel

Merge branch 'fix-operations' into 'master'

Fix operations

![szia (1)](https://git.ik.bme.hu/uploads/circle/cloud/a3c7ade2b8/szia__1_.png)

Closes #322

See merge request !240
parents 709eec33 b7bebad6
...@@ -490,6 +490,9 @@ class Disk(TimeStampedModel): ...@@ -490,6 +490,9 @@ class Disk(TimeStampedModel):
disk.destroy() disk.destroy()
raise humanize_exception(ugettext_noop( raise humanize_exception(ugettext_noop(
"Operation aborted by user."), e) "Operation aborted by user."), e)
except:
disk.destroy()
raise
disk.is_ready = True disk.is_ready = True
disk.save() disk.save()
return disk return disk
...@@ -324,7 +324,7 @@ class DeployOperation(InstanceOperation): ...@@ -324,7 +324,7 @@ class DeployOperation(InstanceOperation):
"deployed to node: %(node)s"), "deployed to node: %(node)s"),
node=self.instance.node) node=self.instance.node)
def _operation(self, activity, timeout=15): def _operation(self, activity):
# Allocate VNC port and host node # Allocate VNC port and host node
self.instance.allocate_vnc_port() self.instance.allocate_vnc_port()
self.instance.allocate_node() self.instance.allocate_node()
...@@ -405,7 +405,7 @@ class DestroyOperation(InstanceOperation): ...@@ -405,7 +405,7 @@ class DestroyOperation(InstanceOperation):
required_perms = () required_perms = ()
resultant_state = 'DESTROYED' resultant_state = 'DESTROYED'
def _operation(self, activity): def _operation(self, activity, system):
# Destroy networks # Destroy networks
with activity.sub_activity( with activity.sub_activity(
'destroying_net', 'destroying_net',
...@@ -415,7 +415,7 @@ class DestroyOperation(InstanceOperation): ...@@ -415,7 +415,7 @@ class DestroyOperation(InstanceOperation):
self.instance.destroy_net() self.instance.destroy_net()
if self.instance.node: if self.instance.node:
self.instance._delete_vm(parent_activity=activity) self.instance._delete_vm(parent_activity=activity, system=system)
# Destroy disks # Destroy disks
with activity.sub_activity( with activity.sub_activity(
...@@ -425,7 +425,8 @@ class DestroyOperation(InstanceOperation): ...@@ -425,7 +425,8 @@ class DestroyOperation(InstanceOperation):
# Delete mem. dump if exists # Delete mem. dump if exists
try: try:
self.instance._delete_mem_dump(parent_activity=activity) self.instance._delete_mem_dump(parent_activity=activity,
system=system)
except: except:
pass pass
...@@ -470,7 +471,7 @@ class MigrateOperation(RemoteInstanceOperation): ...@@ -470,7 +471,7 @@ class MigrateOperation(RemoteInstanceOperation):
async_queue = "localhost.man.slow" async_queue = "localhost.man.slow"
task = vm_tasks.migrate task = vm_tasks.migrate
remote_queue = ("vm", "slow") remote_queue = ("vm", "slow")
timeout = 600 remote_timeout = 1000
def _get_remote_args(self, to_node, **kwargs): def _get_remote_args(self, to_node, **kwargs):
return (super(MigrateOperation, self)._get_remote_args(**kwargs) return (super(MigrateOperation, self)._get_remote_args(**kwargs)
...@@ -632,7 +633,7 @@ class SaveAsTemplateOperation(InstanceOperation): ...@@ -632,7 +633,7 @@ class SaveAsTemplateOperation(InstanceOperation):
for disk in self.disks: for disk in self.disks:
disk.destroy() disk.destroy()
def _operation(self, activity, user, system, timeout=300, name=None, def _operation(self, activity, user, system, name=None,
with_shutdown=True, task=None, **kwargs): with_shutdown=True, task=None, **kwargs):
if with_shutdown: if with_shutdown:
try: try:
...@@ -710,7 +711,7 @@ class ShutdownOperation(AbortableRemoteOperationMixin, ...@@ -710,7 +711,7 @@ class ShutdownOperation(AbortableRemoteOperationMixin,
resultant_state = 'STOPPED' resultant_state = 'STOPPED'
task = vm_tasks.shutdown task = vm_tasks.shutdown
remote_queue = ("vm", "slow") remote_queue = ("vm", "slow")
timeout = 120 remote_timeout = 120
def _operation(self, task): def _operation(self, task):
super(ShutdownOperation, self)._operation(task=task) super(ShutdownOperation, self)._operation(task=task)
...@@ -779,12 +780,12 @@ class SleepOperation(InstanceOperation): ...@@ -779,12 +780,12 @@ class SleepOperation(InstanceOperation):
else: else:
activity.resultant_state = 'ERROR' activity.resultant_state = 'ERROR'
def _operation(self, activity): def _operation(self, activity, system):
with activity.sub_activity('shutdown_net', with activity.sub_activity('shutdown_net',
readable_name=ugettext_noop( readable_name=ugettext_noop(
"shutdown network")): "shutdown network")):
self.instance.shutdown_net() self.instance.shutdown_net()
self.instance._suspend_vm(parent_activity=activity) self.instance._suspend_vm(parent_activity=activity, system=system)
self.instance.yield_node() self.instance.yield_node()
@register_operation @register_operation
...@@ -793,7 +794,7 @@ class SleepOperation(InstanceOperation): ...@@ -793,7 +794,7 @@ class SleepOperation(InstanceOperation):
name = _("suspend virtual machine") name = _("suspend virtual machine")
task = vm_tasks.sleep task = vm_tasks.sleep
remote_queue = ("vm", "slow") remote_queue = ("vm", "slow")
timeout = 600 remote_timeout = 1000
def _get_remote_args(self, **kwargs): def _get_remote_args(self, **kwargs):
return (super(SleepOperation.SuspendVmOperation, self) return (super(SleepOperation.SuspendVmOperation, self)
...@@ -846,7 +847,7 @@ class WakeUpOperation(InstanceOperation): ...@@ -846,7 +847,7 @@ class WakeUpOperation(InstanceOperation):
name = _("resume virtual machine") name = _("resume virtual machine")
task = vm_tasks.wake_up task = vm_tasks.wake_up
remote_queue = ("vm", "slow") remote_queue = ("vm", "slow")
timeout = 600 remote_timeout = 1000
def _get_remote_args(self, **kwargs): def _get_remote_args(self, **kwargs):
return (super(WakeUpOperation.WakeUpVmOperation, self) return (super(WakeUpOperation.WakeUpVmOperation, self)
......
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