Commit eb9b746f by Őry Máté

vm: move Instance.deploy_vm to DeployVmOperation

parent 95199687
......@@ -761,12 +761,6 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
for net in self.interface_set.all():
net.shutdown()
def deploy_vm(self, timeout=15):
queue_name = self.get_remote_queue_name('vm', 'slow')
return vm_tasks.deploy.apply_async(args=[self.get_vm_desc()],
queue=queue_name
).get(timeout=timeout)
def migrate_vm(self, to_node, timeout=120):
queue_name = self.get_remote_queue_name('vm', 'slow')
return vm_tasks.migrate.apply_async(args=[self.vm_name,
......
......@@ -28,7 +28,8 @@ from django.conf import settings
from sizefield.utils import filesizeformat
from celery.exceptions import TimeLimitExceeded
from celery.contrib.abortable import AbortableAsyncResult
from celery.exceptions import TimeLimitExceeded, TimeoutError
from common.models import (
create_readable, humanize_exception, HumanReadableException
......@@ -318,12 +319,7 @@ class DeployOperation(InstanceOperation):
# Deploy VM on remote machine
if self.instance.state not in ['PAUSED']:
rn = create_readable(ugettext_noop("deploy virtual machine"),
ugettext_noop("deploy vm to %(node)s"),
node=self.instance.node)
with activity.sub_activity(
'deploying_vm', readable_name=rn) as deploy_act:
deploy_act.result = self.instance.deploy_vm(timeout=timeout)
self.instance._deploy_vm(parent_activity=activity)
# Establish network connection (vmdriver)
with activity.sub_activity(
......@@ -343,6 +339,23 @@ class DeployOperation(InstanceOperation):
"wait operating system loading"), interruptible=True)
@register_operation
class DeployVmOperation(SubOperationMixin, InstanceOperation):
id = "_deploy_vm"
name = _("deploy vm")
description = _("Deploy all associated disks.")
remote_queue = ("vm", "slow")
task = vm_tasks.deploy
def _get_remote_args(self):
return [self.instance.get_vm_desc()]
# intentionally not calling super
def get_activity_name(self, kwargs):
return create_readable(ugettext_noop("deploy virtual machine"),
ugettext_noop("deploy vm to %(node)s"),
node=self.instance.node)
@register_operation
class DeployDisksOperation(SubOperationMixin, InstanceOperation):
id = "_deploy_disks"
name = _("deploy disks")
......
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