Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
25356007
authored
Mar 23, 2014
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: helper function for registering operations
parent
9ef83cbc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
0 deletions
+11
-0
circle/vm/models/instance.py
+1
-0
circle/vm/models/operation.py
+10
-0
No files found.
circle/vm/models/instance.py
View file @
25356007
...
...
@@ -218,6 +218,7 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel,
"destruction."
))
objects
=
Manager
()
active
=
InstanceActiveManager
()
_ops
=
{}
# operation factory registry
class
Meta
:
app_label
=
'vm'
...
...
circle/vm/models/operation.py
View file @
25356007
...
...
@@ -3,6 +3,7 @@ from __future__ import absolute_import, unicode_literals
from
common.models
import
activity_context
from
..tasks.local_tasks
import
async_operation
from
.activity
import
InstanceActivity
from
.instance
import
Instance
class
Operation
:
...
...
@@ -77,3 +78,12 @@ class Operation:
"""This method is called when the operation executes successfully.
"""
pass
def
register_operation
(
op_cls
,
op_id
=
None
):
"""Register the specified operation with Instance.
"""
if
op_id
is
None
:
op_id
=
op_cls
.
id
Instance
.
_ops
[
op_id
]
=
lambda
inst
:
op_cls
(
inst
)
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