Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gutyán Gábor
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f19b191f
authored
Apr 01, 2014
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: more distinguishing name for async operation task
parent
13d0b9a9
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
7 deletions
+10
-7
circle/vm/operations.py
+5
-3
circle/vm/tasks/local_tasks.py
+2
-2
circle/vm/tests/test_operations.py
+3
-2
No files found.
circle/vm/operations.py
View file @
f19b191f
...
@@ -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
):
...
...
circle/vm/tasks/local_tasks.py
View file @
f19b191f
...
@@ -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
)
...
...
circle/vm/tests/test_operations.py
View file @
f19b191f
...
@@ -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
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment