Commit f19b191f by Dudás Ádám

vm: more distinguishing name for async operation task

parent 13d0b9a9
...@@ -11,7 +11,7 @@ from celery.exceptions import TimeLimitExceeded ...@@ -11,7 +11,7 @@ from celery.exceptions import TimeLimitExceeded
from common.models import activity_context from common.models import activity_context
from storage.models import Disk from storage.models import Disk
from .tasks import vm_tasks from .tasks import vm_tasks
from .tasks.local_tasks import async_operation from .tasks.local_tasks import async_instance_operation
from .models import Instance, InstanceActivity, InstanceTemplate from .models import Instance, InstanceActivity, InstanceTemplate
...@@ -71,8 +71,10 @@ class Operation(object): ...@@ -71,8 +71,10 @@ class Operation(object):
For more information, check the synchronous call's documentation. For more information, check the synchronous call's documentation.
""" """
activity = self.__prelude(kwargs) activity = self.__prelude(kwargs)
return async_operation.apply_async(args=(self.id, self.instance.pk, return async_instance_operation.apply_async(args=(self.id,
activity.pk), kwargs=kwargs, self.instance.pk,
activity.pk),
kwargs=kwargs,
queue=self.async_queue) queue=self.async_queue)
def call(self, **kwargs): def call(self, **kwargs):
......
...@@ -2,14 +2,14 @@ from manager.mancelery import celery ...@@ -2,14 +2,14 @@ from manager.mancelery import celery
@celery.task @celery.task
def async_operation(operation_id, instance_pk, activity_pk, **kwargs): def async_instance_operation(operation_id, instance_pk, activity_pk, **kwargs):
from vm.models import Instance, InstanceActivity from vm.models import Instance, InstanceActivity
instance = Instance.objects.get(pk=instance_pk) instance = Instance.objects.get(pk=instance_pk)
operation = getattr(instance, operation_id) operation = getattr(instance, operation_id)
activity = InstanceActivity.objects.get(pk=activity_pk) activity = InstanceActivity.objects.get(pk=activity_pk)
# save async task UUID to activity # save async task UUID to activity
activity.task_uuid = async_operation.request.id activity.task_uuid = async_instance_operation.request.id
activity.save() activity.save()
return operation._exec_op(activity=activity, **kwargs) return operation._exec_op(activity=activity, **kwargs)
......
...@@ -9,7 +9,7 @@ from vm.operations import ( ...@@ -9,7 +9,7 @@ from vm.operations import (
SaveAsTemplateOperation, ShutdownOperation, ShutOffOperation, SaveAsTemplateOperation, ShutdownOperation, ShutOffOperation,
SleepOperation, WakeUpOperation, SleepOperation, WakeUpOperation,
) )
from vm.tasks.local_tasks import async_operation from vm.tasks.local_tasks import async_instance_operation
class OperationTestCase(TestCase): class OperationTestCase(TestCase):
...@@ -20,7 +20,8 @@ class OperationTestCase(TestCase): ...@@ -20,7 +20,8 @@ class OperationTestCase(TestCase):
op = Operation(MagicMock()) op = Operation(MagicMock())
op.activity_code_suffix = 'test' op.activity_code_suffix = 'test'
op.id = 'test' op.id = 'test'
with patch.object(async_operation, 'apply_async', side_effect=AbortEx): with patch.object(async_instance_operation, 'apply_async',
side_effect=AbortEx):
with patch.object(Operation, 'check_precond'): with patch.object(Operation, 'check_precond'):
with patch.object(Operation, 'create_activity') as create_act: with patch.object(Operation, 'create_activity') as create_act:
try: try:
......
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