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
23717a39
authored
Sep 23, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
common: make register_operation a class-decorator
parent
d6f8ae38
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
64 deletions
+24
-64
circle/common/operations.py
+1
-0
circle/vm/operations.py
+23
-64
No files found.
circle/common/operations.py
View file @
23717a39
...
@@ -273,3 +273,4 @@ def register_operation(op_cls, op_id=None, target_cls=None):
...
@@ -273,3 +273,4 @@ def register_operation(op_cls, op_id=None, target_cls=None):
setattr
(
target_cls
,
operation_registry_name
,
dict
())
setattr
(
target_cls
,
operation_registry_name
,
dict
())
getattr
(
target_cls
,
operation_registry_name
)[
op_id
]
=
op_cls
getattr
(
target_cls
,
operation_registry_name
)[
op_id
]
=
op_cls
return
op_cls
circle/vm/operations.py
View file @
23717a39
...
@@ -116,6 +116,7 @@ class InstanceOperation(Operation):
...
@@ -116,6 +116,7 @@ class InstanceOperation(Operation):
return
False
return
False
@register_operation
class
AddInterfaceOperation
(
InstanceOperation
):
class
AddInterfaceOperation
(
InstanceOperation
):
activity_code_suffix
=
'add_interface'
activity_code_suffix
=
'add_interface'
id
=
'add_interface'
id
=
'add_interface'
...
@@ -161,9 +162,7 @@ class AddInterfaceOperation(InstanceOperation):
...
@@ -161,9 +162,7 @@ class AddInterfaceOperation(InstanceOperation):
vlan
=
kwargs
[
'vlan'
])
vlan
=
kwargs
[
'vlan'
])
register_operation
(
AddInterfaceOperation
)
@register_operation
class
CreateDiskOperation
(
InstanceOperation
):
class
CreateDiskOperation
(
InstanceOperation
):
activity_code_suffix
=
'create_disk'
activity_code_suffix
=
'create_disk'
...
@@ -205,9 +204,7 @@ class CreateDiskOperation(InstanceOperation):
...
@@ -205,9 +204,7 @@ class CreateDiskOperation(InstanceOperation):
size
=
filesizeformat
(
kwargs
[
'size'
]),
name
=
kwargs
[
'name'
])
size
=
filesizeformat
(
kwargs
[
'size'
]),
name
=
kwargs
[
'name'
])
register_operation
(
CreateDiskOperation
)
@register_operation
class
DownloadDiskOperation
(
InstanceOperation
):
class
DownloadDiskOperation
(
InstanceOperation
):
activity_code_suffix
=
'download_disk'
activity_code_suffix
=
'download_disk'
id
=
'download_disk'
id
=
'download_disk'
...
@@ -245,9 +242,8 @@ class DownloadDiskOperation(InstanceOperation):
...
@@ -245,9 +242,8 @@ class DownloadDiskOperation(InstanceOperation):
):
):
self
.
instance
.
attach_disk
(
disk
)
self
.
instance
.
attach_disk
(
disk
)
register_operation
(
DownloadDiskOperation
)
@register_operation
class
DeployOperation
(
InstanceOperation
):
class
DeployOperation
(
InstanceOperation
):
activity_code_suffix
=
'deploy'
activity_code_suffix
=
'deploy'
id
=
'deploy'
id
=
'deploy'
...
@@ -315,9 +311,7 @@ class DeployOperation(InstanceOperation):
...
@@ -315,9 +311,7 @@ class DeployOperation(InstanceOperation):
"wait operating system loading"
),
interruptible
=
True
)
"wait operating system loading"
),
interruptible
=
True
)
register_operation
(
DeployOperation
)
@register_operation
class
DestroyOperation
(
InstanceOperation
):
class
DestroyOperation
(
InstanceOperation
):
activity_code_suffix
=
'destroy'
activity_code_suffix
=
'destroy'
id
=
'destroy'
id
=
'destroy'
...
@@ -363,9 +357,7 @@ class DestroyOperation(InstanceOperation):
...
@@ -363,9 +357,7 @@ class DestroyOperation(InstanceOperation):
self
.
instance
.
save
()
self
.
instance
.
save
()
register_operation
(
DestroyOperation
)
@register_operation
class
MigrateOperation
(
InstanceOperation
):
class
MigrateOperation
(
InstanceOperation
):
activity_code_suffix
=
'migrate'
activity_code_suffix
=
'migrate'
id
=
'migrate'
id
=
'migrate'
...
@@ -417,9 +409,7 @@ class MigrateOperation(InstanceOperation):
...
@@ -417,9 +409,7 @@ class MigrateOperation(InstanceOperation):
self
.
instance
.
deploy_net
()
self
.
instance
.
deploy_net
()
register_operation
(
MigrateOperation
)
@register_operation
class
RebootOperation
(
InstanceOperation
):
class
RebootOperation
(
InstanceOperation
):
activity_code_suffix
=
'reboot'
activity_code_suffix
=
'reboot'
id
=
'reboot'
id
=
'reboot'
...
@@ -436,9 +426,7 @@ class RebootOperation(InstanceOperation):
...
@@ -436,9 +426,7 @@ class RebootOperation(InstanceOperation):
"wait operating system loading"
),
interruptible
=
True
)
"wait operating system loading"
),
interruptible
=
True
)
register_operation
(
RebootOperation
)
@register_operation
class
RemoveInterfaceOperation
(
InstanceOperation
):
class
RemoveInterfaceOperation
(
InstanceOperation
):
activity_code_suffix
=
'remove_interface'
activity_code_suffix
=
'remove_interface'
id
=
'remove_interface'
id
=
'remove_interface'
...
@@ -466,9 +454,7 @@ class RemoveInterfaceOperation(InstanceOperation):
...
@@ -466,9 +454,7 @@ class RemoveInterfaceOperation(InstanceOperation):
vlan
=
kwargs
[
'interface'
]
.
vlan
)
vlan
=
kwargs
[
'interface'
]
.
vlan
)
register_operation
(
RemoveInterfaceOperation
)
@register_operation
class
RemoveDiskOperation
(
InstanceOperation
):
class
RemoveDiskOperation
(
InstanceOperation
):
activity_code_suffix
=
'remove_disk'
activity_code_suffix
=
'remove_disk'
id
=
'remove_disk'
id
=
'remove_disk'
...
@@ -495,9 +481,8 @@ class RemoveDiskOperation(InstanceOperation):
...
@@ -495,9 +481,8 @@ class RemoveDiskOperation(InstanceOperation):
return
create_readable
(
ugettext_noop
(
'remove disk
%(name)
s'
),
return
create_readable
(
ugettext_noop
(
'remove disk
%(name)
s'
),
name
=
kwargs
[
"disk"
]
.
name
)
name
=
kwargs
[
"disk"
]
.
name
)
register_operation
(
RemoveDiskOperation
)
@register_operation
class
ResetOperation
(
InstanceOperation
):
class
ResetOperation
(
InstanceOperation
):
activity_code_suffix
=
'reset'
activity_code_suffix
=
'reset'
id
=
'reset'
id
=
'reset'
...
@@ -512,9 +497,8 @@ class ResetOperation(InstanceOperation):
...
@@ -512,9 +497,8 @@ class ResetOperation(InstanceOperation):
activity
.
sub_activity
(
'os_boot'
,
readable_name
=
ugettext_noop
(
activity
.
sub_activity
(
'os_boot'
,
readable_name
=
ugettext_noop
(
"wait operating system loading"
),
interruptible
=
True
)
"wait operating system loading"
),
interruptible
=
True
)
register_operation
(
ResetOperation
)
@register_operation
class
SaveAsTemplateOperation
(
InstanceOperation
):
class
SaveAsTemplateOperation
(
InstanceOperation
):
activity_code_suffix
=
'save_as_template'
activity_code_suffix
=
'save_as_template'
id
=
'save_as_template'
id
=
'save_as_template'
...
@@ -610,9 +594,7 @@ class SaveAsTemplateOperation(InstanceOperation):
...
@@ -610,9 +594,7 @@ class SaveAsTemplateOperation(InstanceOperation):
return
tmpl
return
tmpl
register_operation
(
SaveAsTemplateOperation
)
@register_operation
class
ShutdownOperation
(
InstanceOperation
):
class
ShutdownOperation
(
InstanceOperation
):
activity_code_suffix
=
'shutdown'
activity_code_suffix
=
'shutdown'
id
=
'shutdown'
id
=
'shutdown'
...
@@ -642,9 +624,7 @@ class ShutdownOperation(InstanceOperation):
...
@@ -642,9 +624,7 @@ class ShutdownOperation(InstanceOperation):
super
(
ShutdownOperation
,
self
)
.
on_abort
(
activity
,
error
)
super
(
ShutdownOperation
,
self
)
.
on_abort
(
activity
,
error
)
register_operation
(
ShutdownOperation
)
@register_operation
class
ShutOffOperation
(
InstanceOperation
):
class
ShutOffOperation
(
InstanceOperation
):
activity_code_suffix
=
'shut_off'
activity_code_suffix
=
'shut_off'
id
=
'shut_off'
id
=
'shut_off'
...
@@ -672,9 +652,7 @@ class ShutOffOperation(InstanceOperation):
...
@@ -672,9 +652,7 @@ class ShutOffOperation(InstanceOperation):
self
.
instance
.
yield_node
()
self
.
instance
.
yield_node
()
register_operation
(
ShutOffOperation
)
@register_operation
class
SleepOperation
(
InstanceOperation
):
class
SleepOperation
(
InstanceOperation
):
activity_code_suffix
=
'sleep'
activity_code_suffix
=
'sleep'
id
=
'sleep'
id
=
'sleep'
...
@@ -718,9 +696,7 @@ class SleepOperation(InstanceOperation):
...
@@ -718,9 +696,7 @@ class SleepOperation(InstanceOperation):
# VNC port needs to be kept
# VNC port needs to be kept
register_operation
(
SleepOperation
)
@register_operation
class
WakeUpOperation
(
InstanceOperation
):
class
WakeUpOperation
(
InstanceOperation
):
activity_code_suffix
=
'wake_up'
activity_code_suffix
=
'wake_up'
id
=
'wake_up'
id
=
'wake_up'
...
@@ -764,9 +740,7 @@ class WakeUpOperation(InstanceOperation):
...
@@ -764,9 +740,7 @@ class WakeUpOperation(InstanceOperation):
pass
pass
register_operation
(
WakeUpOperation
)
@register_operation
class
RenewOperation
(
InstanceOperation
):
class
RenewOperation
(
InstanceOperation
):
activity_code_suffix
=
'renew'
activity_code_suffix
=
'renew'
id
=
'renew'
id
=
'renew'
...
@@ -801,9 +775,7 @@ class RenewOperation(InstanceOperation):
...
@@ -801,9 +775,7 @@ class RenewOperation(InstanceOperation):
suspend
=
suspend
,
delete
=
delete
)
suspend
=
suspend
,
delete
=
delete
)
register_operation
(
RenewOperation
)
@register_operation
class
ChangeStateOperation
(
InstanceOperation
):
class
ChangeStateOperation
(
InstanceOperation
):
activity_code_suffix
=
'emergency_change_state'
activity_code_suffix
=
'emergency_change_state'
id
=
'emergency_change_state'
id
=
'emergency_change_state'
...
@@ -828,9 +800,6 @@ class ChangeStateOperation(InstanceOperation):
...
@@ -828,9 +800,6 @@ class ChangeStateOperation(InstanceOperation):
logger
.
error
(
'Forced finishing activity
%
s'
,
i
)
logger
.
error
(
'Forced finishing activity
%
s'
,
i
)
register_operation
(
ChangeStateOperation
)
class
NodeOperation
(
Operation
):
class
NodeOperation
(
Operation
):
async_operation
=
abortable_async_node_operation
async_operation
=
abortable_async_node_operation
host_cls
=
Node
host_cls
=
Node
...
@@ -859,6 +828,7 @@ class NodeOperation(Operation):
...
@@ -859,6 +828,7 @@ class NodeOperation(Operation):
readable_name
=
name
)
readable_name
=
name
)
@register_operation
class
FlushOperation
(
NodeOperation
):
class
FlushOperation
(
NodeOperation
):
activity_code_suffix
=
'flush'
activity_code_suffix
=
'flush'
id
=
'flush'
id
=
'flush'
...
@@ -885,9 +855,9 @@ class FlushOperation(NodeOperation):
...
@@ -885,9 +855,9 @@ class FlushOperation(NodeOperation):
i
.
migrate
(
user
=
user
)
i
.
migrate
(
user
=
user
)
register_operation
(
FlushOperation
)
@register_operation
class
ScreenshotOperation
(
InstanceOperation
):
class
ScreenshotOperation
(
InstanceOperation
):
activity_code_suffix
=
'screenshot'
activity_code_suffix
=
'screenshot'
id
=
'screenshot'
id
=
'screenshot'
...
@@ -903,9 +873,7 @@ class ScreenshotOperation(InstanceOperation):
...
@@ -903,9 +873,7 @@ class ScreenshotOperation(InstanceOperation):
return
self
.
instance
.
get_screenshot
(
timeout
=
20
)
return
self
.
instance
.
get_screenshot
(
timeout
=
20
)
register_operation
(
ScreenshotOperation
)
@register_operation
class
RecoverOperation
(
InstanceOperation
):
class
RecoverOperation
(
InstanceOperation
):
activity_code_suffix
=
'recover'
activity_code_suffix
=
'recover'
id
=
'recover'
id
=
'recover'
...
@@ -933,9 +901,7 @@ class RecoverOperation(InstanceOperation):
...
@@ -933,9 +901,7 @@ class RecoverOperation(InstanceOperation):
self
.
instance
.
save
()
self
.
instance
.
save
()
register_operation
(
RecoverOperation
)
@register_operation
class
ResourcesOperation
(
InstanceOperation
):
class
ResourcesOperation
(
InstanceOperation
):
activity_code_suffix
=
'Resources change'
activity_code_suffix
=
'Resources change'
id
=
'resources_change'
id
=
'resources_change'
...
@@ -963,9 +929,6 @@ class ResourcesOperation(InstanceOperation):
...
@@ -963,9 +929,6 @@ class ResourcesOperation(InstanceOperation):
)
)
register_operation
(
ResourcesOperation
)
class
EnsureAgentMixin
(
object
):
class
EnsureAgentMixin
(
object
):
accept_states
=
(
'RUNNING'
,
)
accept_states
=
(
'RUNNING'
,
)
...
@@ -985,6 +948,7 @@ class EnsureAgentMixin(object):
...
@@ -985,6 +948,7 @@ class EnsureAgentMixin(object):
raise
self
.
instance
.
NoAgentError
(
self
.
instance
)
raise
self
.
instance
.
NoAgentError
(
self
.
instance
)
@register_operation
class
PasswordResetOperation
(
EnsureAgentMixin
,
InstanceOperation
):
class
PasswordResetOperation
(
EnsureAgentMixin
,
InstanceOperation
):
activity_code_suffix
=
'password_reset'
activity_code_suffix
=
'password_reset'
id
=
'password_reset'
id
=
'password_reset'
...
@@ -1005,9 +969,7 @@ class PasswordResetOperation(EnsureAgentMixin, InstanceOperation):
...
@@ -1005,9 +969,7 @@ class PasswordResetOperation(EnsureAgentMixin, InstanceOperation):
self
.
instance
.
save
()
self
.
instance
.
save
()
register_operation
(
PasswordResetOperation
)
@register_operation
class
MountStoreOperation
(
EnsureAgentMixin
,
InstanceOperation
):
class
MountStoreOperation
(
EnsureAgentMixin
,
InstanceOperation
):
activity_code_suffix
=
'mount_store'
activity_code_suffix
=
'mount_store'
id
=
'mount_store'
id
=
'mount_store'
...
@@ -1034,6 +996,3 @@ class MountStoreOperation(EnsureAgentMixin, InstanceOperation):
...
@@ -1034,6 +996,3 @@ class MountStoreOperation(EnsureAgentMixin, InstanceOperation):
password
=
user
.
profile
.
smb_password
password
=
user
.
profile
.
smb_password
agent_tasks
.
mount_store
.
apply_async
(
agent_tasks
.
mount_store
.
apply_async
(
queue
=
queue
,
args
=
(
inst
.
vm_name
,
host
,
username
,
password
))
queue
=
queue
,
args
=
(
inst
.
vm_name
,
host
,
username
,
password
))
register_operation
(
MountStoreOperation
)
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