Commit 0caef6e0 by Őry Máté

vm: add remote operation classes

parent 613c590c
......@@ -42,13 +42,28 @@ from .models import (
Instance, InstanceActivity, InstanceTemplate, Interface, Node,
NodeActivity, pwgen
from .tasks import agent_tasks, local_agent_tasks
from .tasks import agent_tasks, local_agent_tasks, vm_tasks
from dashboard.store_api import Store, NoStoreException
logger = getLogger(__name__)
class RemoteOperationMixin(object):
remote_timeout = 30
def _operation(self, **kwargs):
args = self._get_remote_args(**kwargs),
return self.task.apply_async(
args=args, queue=self._get_remote_queue()
def check_precond(self):
super(RemoteOperationMixin, self).check_precond()
class InstanceOperation(Operation):
acl_level = 'owner'
async_operation = abortable_async_instance_operation
......@@ -116,6 +131,18 @@ class InstanceOperation(Operation):
return False
class RemoteInstanceOperation(RemoteOperationMixin, InstanceOperation):
remote_queue = ('vm', 'fast')
# activity_code_suffix = property(lambda self: or
def _get_remote_queue(self):
return self.instance.get_remote_queue_name(*self.remote_queue)
def _get_remote_args(self, **kwargs):
return [self.instance.vm_name]
class AddInterfaceOperation(InstanceOperation):
activity_code_suffix = 'add_interface'
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