Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
d1bee728
authored
8 years ago
by
Czémán Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
common, vm: make operations help() friendly
parent
5ea451a2
Pipeline
#103
passed with stage
in 0 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
58 deletions
+88
-58
circle/common/operations.py
+31
-4
circle/dashboard/tests/test_views.py
+2
-1
circle/vm/operations.py
+55
-53
No files found.
circle/common/operations.py
View file @
d1bee728
...
@@ -38,15 +38,23 @@ class SubOperationMixin(object):
...
@@ -38,15 +38,23 @@ class SubOperationMixin(object):
parent
,
user
,
kwargs
)
parent
,
user
,
kwargs
)
class
WritableDocMeta
(
type
):
pass
class
Operation
(
object
):
class
Operation
(
object
):
"""Base class for VM operations.
"""Base class for VM operations.
"""
"""
__metaclass__
=
WritableDocMeta
async_queue
=
'localhost.man'
async_queue
=
'localhost.man'
required_perms
=
None
required_perms
=
None
superuser_required
=
False
superuser_required
=
False
do_not_call_in_templates
=
True
do_not_call_in_templates
=
True
abortable
=
False
abortable
=
False
has_percentage
=
False
has_percentage
=
False
description
=
None
@classmethod
@classmethod
def
get_activity_code_suffix
(
cls
):
def
get_activity_code_suffix
(
cls
):
...
@@ -219,10 +227,12 @@ operation_registry_name = '_ops'
...
@@ -219,10 +227,12 @@ operation_registry_name = '_ops'
class
OperatedMixin
(
object
):
class
OperatedMixin
(
object
):
def
__getattr__
(
self
,
name
):
# NOTE: __getattr__ is only called if the attribute doesn't already
def
__getattribute__
(
self
,
name
):
# exist in your __dict__
ops
=
getattr
(
type
(
self
),
operation_registry_name
,
{})
return
self
.
get_operation_class
(
name
)(
self
)
if
name
in
ops
:
return
type
(
self
)
.
get_operation_class
(
name
)(
self
)
return
object
.
__getattribute__
(
self
,
name
)
@classmethod
@classmethod
def
get_operation_class
(
cls
,
name
):
def
get_operation_class
(
cls
,
name
):
...
@@ -261,6 +271,19 @@ class OperatedMixin(object):
...
@@ -261,6 +271,19 @@ class OperatedMixin(object):
return
None
return
None
def
generate_op_doc
(
op
,
op_id
):
doc
=
"""
Usage:
%
s(<args>) |
%
s.async(<args>)
Args:
%
s
%
s
"""
%
(
op_id
,
op_id
,
", "
.
join
(
getargspec
(
op
.
_operation
)[
0
]),
op
.
__doc__
)
op
.
__doc__
=
doc
def
register_operation
(
op_cls
,
op_id
=
None
,
target_cls
=
None
):
def
register_operation
(
op_cls
,
op_id
=
None
,
target_cls
=
None
):
"""Register the specified operation with the target class.
"""Register the specified operation with the target class.
...
@@ -297,5 +320,9 @@ def register_operation(op_cls, op_id=None, target_cls=None):
...
@@ -297,5 +320,9 @@ def register_operation(op_cls, op_id=None, target_cls=None):
if
not
hasattr
(
target_cls
,
operation_registry_name
):
if
not
hasattr
(
target_cls
,
operation_registry_name
):
setattr
(
target_cls
,
operation_registry_name
,
dict
())
setattr
(
target_cls
,
operation_registry_name
,
dict
())
op_cls
.
__doc__
=
op_cls
.
description
or
"It has no documentation. :("
op
=
op_cls
(
None
)
generate_op_doc
(
op
,
op_id
)
setattr
(
target_cls
,
op_id
,
op
)
getattr
(
target_cls
,
operation_registry_name
)[
op_id
]
=
op_cls
getattr
(
target_cls
,
operation_registry_name
)[
op_id
]
=
op_cls
return
op_cls
return
op_cls
This diff is collapsed.
Click to expand it.
circle/dashboard/tests/test_views.py
View file @
d1bee728
...
@@ -24,6 +24,7 @@ from django.contrib.auth.models import User, Group, Permission
...
@@ -24,6 +24,7 @@ from django.contrib.auth.models import User, Group, Permission
from
django.contrib.auth
import
authenticate
from
django.contrib.auth
import
authenticate
from
common.tests.celery_mock
import
MockCeleryMixin
from
common.tests.celery_mock
import
MockCeleryMixin
from
common.operations
import
operation_registry_name
from
dashboard.views
import
VmAddInterfaceView
from
dashboard.views
import
VmAddInterfaceView
from
vm.models
import
Instance
,
InstanceTemplate
,
Lease
,
Node
,
Trait
from
vm.models
import
Instance
,
InstanceTemplate
,
Lease
,
Node
,
Trait
from
vm.operations
import
(
WakeUpOperation
,
AddInterfaceOperation
,
from
vm.operations
import
(
WakeUpOperation
,
AddInterfaceOperation
,
...
@@ -482,7 +483,7 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase):
...
@@ -482,7 +483,7 @@ class VmDetailTest(LoginMixin, MockCeleryMixin, TestCase):
patch
.
object
(
Instance
.
WrongStateError
,
'send_message'
)
as
wro
:
patch
.
object
(
Instance
.
WrongStateError
,
'send_message'
)
as
wro
:
inst
=
Instance
.
objects
.
get
(
pk
=
1
)
inst
=
Instance
.
objects
.
get
(
pk
=
1
)
new_wake_up
.
side_effect
=
inst
.
wake_up
new_wake_up
.
side_effect
=
inst
.
wake_up
inst
.
_wake_up_vm
=
Mock
()
getattr
(
inst
,
operation_registry_name
)[
"_wake_up_vm"
]
=
Mock
()
inst
.
get_remote_queue_name
=
Mock
(
return_value
=
'test'
)
inst
.
get_remote_queue_name
=
Mock
(
return_value
=
'test'
)
inst
.
status
=
'SUSPENDED'
inst
.
status
=
'SUSPENDED'
inst
.
set_level
(
self
.
u2
,
'owner'
)
inst
.
set_level
(
self
.
u2
,
'owner'
)
...
...
This diff is collapsed.
Click to expand it.
circle/vm/operations.py
View file @
d1bee728
...
@@ -30,7 +30,9 @@ from urlparse import urlsplit
...
@@ -30,7 +30,9 @@ from urlparse import urlsplit
from
django.core.exceptions
import
PermissionDenied
,
SuspiciousOperation
from
django.core.exceptions
import
PermissionDenied
,
SuspiciousOperation
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
from
django.utils
import
timezone
from
django.utils
import
timezone
from
django.utils.translation
import
ugettext_lazy
as
_
,
ugettext_noop
from
django.utils.translation
import
(
ugettext_noop
,
ugettext_noop
as
_
,
ugettext_lazy
)
from
django.conf
import
settings
from
django.conf
import
settings
from
django.db.models
import
Q
from
django.db.models
import
Q
...
@@ -205,7 +207,7 @@ class RemoteAgentOperation(EnsureAgentMixin, RemoteInstanceOperation):
...
@@ -205,7 +207,7 @@ class RemoteAgentOperation(EnsureAgentMixin, RemoteInstanceOperation):
@register_operation
@register_operation
class
AddInterfaceOperation
(
InstanceOperation
):
class
AddInterfaceOperation
(
InstanceOperation
):
id
=
'add_interface'
id
=
'add_interface'
name
=
_
(
"add interface"
)
name
=
ugettext_lazy
(
"add interface"
)
description
=
_
(
"Add a new network interface for the specified VLAN to "
description
=
_
(
"Add a new network interface for the specified VLAN to "
"the VM."
)
"the VM."
)
required_perms
=
()
required_perms
=
()
...
@@ -250,7 +252,7 @@ class AddInterfaceOperation(InstanceOperation):
...
@@ -250,7 +252,7 @@ class AddInterfaceOperation(InstanceOperation):
class
CreateDiskOperation
(
InstanceOperation
):
class
CreateDiskOperation
(
InstanceOperation
):
id
=
'create_disk'
id
=
'create_disk'
name
=
_
(
"create disk"
)
name
=
ugettext_lazy
(
"create disk"
)
description
=
_
(
"Create and attach empty disk to the virtual machine."
)
description
=
_
(
"Create and attach empty disk to the virtual machine."
)
required_perms
=
(
'storage.create_empty_disk'
,
)
required_perms
=
(
'storage.create_empty_disk'
,
)
accept_states
=
(
'STOPPED'
,
'PENDING'
,
'RUNNING'
)
accept_states
=
(
'STOPPED'
,
'PENDING'
,
'RUNNING'
)
...
@@ -287,7 +289,7 @@ class CreateDiskOperation(InstanceOperation):
...
@@ -287,7 +289,7 @@ class CreateDiskOperation(InstanceOperation):
class
ResizeDiskOperation
(
RemoteInstanceOperation
):
class
ResizeDiskOperation
(
RemoteInstanceOperation
):
id
=
'resize_disk'
id
=
'resize_disk'
name
=
_
(
"resize disk"
)
name
=
ugettext_lazy
(
"resize disk"
)
description
=
_
(
"Resize the virtual disk image. "
description
=
_
(
"Resize the virtual disk image. "
"Size must be greater value than the actual size."
)
"Size must be greater value than the actual size."
)
required_perms
=
(
'storage.resize_disk'
,
)
required_perms
=
(
'storage.resize_disk'
,
)
...
@@ -317,7 +319,7 @@ class ResizeDiskOperation(RemoteInstanceOperation):
...
@@ -317,7 +319,7 @@ class ResizeDiskOperation(RemoteInstanceOperation):
@register_operation
@register_operation
class
DownloadDiskOperation
(
InstanceOperation
):
class
DownloadDiskOperation
(
InstanceOperation
):
id
=
'download_disk'
id
=
'download_disk'
name
=
_
(
"download disk"
)
name
=
ugettext_lazy
(
"download disk"
)
description
=
_
(
"Download and attach disk image (ISO file) for the "
description
=
_
(
"Download and attach disk image (ISO file) for the "
"virtual machine. Most operating systems do not detect a "
"virtual machine. Most operating systems do not detect a "
"new optical drive, so you may have to reboot the "
"new optical drive, so you may have to reboot the "
...
@@ -354,7 +356,7 @@ class DownloadDiskOperation(InstanceOperation):
...
@@ -354,7 +356,7 @@ class DownloadDiskOperation(InstanceOperation):
@register_operation
@register_operation
class
DeployOperation
(
InstanceOperation
):
class
DeployOperation
(
InstanceOperation
):
id
=
'deploy'
id
=
'deploy'
name
=
_
(
"deploy"
)
name
=
ugettext_lazy
(
"deploy"
)
description
=
_
(
"Deploy and start the virtual machine (including storage "
description
=
_
(
"Deploy and start the virtual machine (including storage "
"and network configuration)."
)
"and network configuration)."
)
required_perms
=
()
required_perms
=
()
...
@@ -417,7 +419,7 @@ class DeployOperation(InstanceOperation):
...
@@ -417,7 +419,7 @@ class DeployOperation(InstanceOperation):
@register_operation
@register_operation
class
DeployVmOperation
(
SubOperationMixin
,
RemoteInstanceOperation
):
class
DeployVmOperation
(
SubOperationMixin
,
RemoteInstanceOperation
):
id
=
"_deploy_vm"
id
=
"_deploy_vm"
name
=
_
(
"deploy vm"
)
name
=
ugettext_lazy
(
"deploy vm"
)
description
=
_
(
"Deploy virtual machine."
)
description
=
_
(
"Deploy virtual machine."
)
remote_queue
=
(
"vm"
,
"slow"
)
remote_queue
=
(
"vm"
,
"slow"
)
task
=
vm_tasks
.
deploy
task
=
vm_tasks
.
deploy
...
@@ -434,7 +436,7 @@ class DeployOperation(InstanceOperation):
...
@@ -434,7 +436,7 @@ class DeployOperation(InstanceOperation):
@register_operation
@register_operation
class
DeployDisksOperation
(
SubOperationMixin
,
InstanceOperation
):
class
DeployDisksOperation
(
SubOperationMixin
,
InstanceOperation
):
id
=
"_deploy_disks"
id
=
"_deploy_disks"
name
=
_
(
"deploy disks"
)
name
=
ugettext_lazy
(
"deploy disks"
)
description
=
_
(
"Deploy all associated disks."
)
description
=
_
(
"Deploy all associated disks."
)
def
_operation
(
self
):
def
_operation
(
self
):
...
@@ -452,7 +454,7 @@ class DeployOperation(InstanceOperation):
...
@@ -452,7 +454,7 @@ class DeployOperation(InstanceOperation):
@register_operation
@register_operation
class
ResumeVmOperation
(
SubOperationMixin
,
RemoteInstanceOperation
):
class
ResumeVmOperation
(
SubOperationMixin
,
RemoteInstanceOperation
):
id
=
"_resume_vm"
id
=
"_resume_vm"
name
=
_
(
"boot virtual machine"
)
name
=
ugettext_lazy
(
"boot virtual machine"
)
remote_queue
=
(
"vm"
,
"slow"
)
remote_queue
=
(
"vm"
,
"slow"
)
task
=
vm_tasks
.
resume
task
=
vm_tasks
.
resume
...
@@ -460,7 +462,7 @@ class DeployOperation(InstanceOperation):
...
@@ -460,7 +462,7 @@ class DeployOperation(InstanceOperation):
@register_operation
@register_operation
class
DestroyOperation
(
InstanceOperation
):
class
DestroyOperation
(
InstanceOperation
):
id
=
'destroy'
id
=
'destroy'
name
=
_
(
"destroy"
)
name
=
ugettext_lazy
(
"destroy"
)
description
=
_
(
"Permanently destroy virtual machine, its network "
description
=
_
(
"Permanently destroy virtual machine, its network "
"settings and disks."
)
"settings and disks."
)
required_perms
=
()
required_perms
=
()
...
@@ -503,7 +505,7 @@ class DestroyOperation(InstanceOperation):
...
@@ -503,7 +505,7 @@ class DestroyOperation(InstanceOperation):
@register_operation
@register_operation
class
DeleteVmOperation
(
SubOperationMixin
,
RemoteInstanceOperation
):
class
DeleteVmOperation
(
SubOperationMixin
,
RemoteInstanceOperation
):
id
=
"_delete_vm"
id
=
"_delete_vm"
name
=
_
(
"destroy virtual machine"
)
name
=
ugettext_lazy
(
"destroy virtual machine"
)
task
=
vm_tasks
.
destroy
task
=
vm_tasks
.
destroy
# if e.libvirtError and "Domain not found" in str(e):
# if e.libvirtError and "Domain not found" in str(e):
...
@@ -511,7 +513,7 @@ class DestroyOperation(InstanceOperation):
...
@@ -511,7 +513,7 @@ class DestroyOperation(InstanceOperation):
class
DeleteMemDumpOperation
(
RemoteOperationMixin
,
SubOperationMixin
,
class
DeleteMemDumpOperation
(
RemoteOperationMixin
,
SubOperationMixin
,
InstanceOperation
):
InstanceOperation
):
id
=
"_delete_mem_dump"
id
=
"_delete_mem_dump"
name
=
_
(
"removing memory dump"
)
name
=
ugettext_lazy
(
"removing memory dump"
)
task
=
storage_tasks
.
delete_dump
task
=
storage_tasks
.
delete_dump
def
_get_remote_queue
(
self
):
def
_get_remote_queue
(
self
):
...
@@ -525,7 +527,7 @@ class DestroyOperation(InstanceOperation):
...
@@ -525,7 +527,7 @@ class DestroyOperation(InstanceOperation):
@register_operation
@register_operation
class
MigrateOperation
(
RemoteInstanceOperation
):
class
MigrateOperation
(
RemoteInstanceOperation
):
id
=
'migrate'
id
=
'migrate'
name
=
_
(
"migrate"
)
name
=
ugettext_lazy
(
"migrate"
)
description
=
_
(
"Move a running virtual machine to an other worker node "
description
=
_
(
"Move a running virtual machine to an other worker node "
"keeping its full state."
)
"keeping its full state."
)
required_perms
=
()
required_perms
=
()
...
@@ -585,7 +587,7 @@ class MigrateOperation(RemoteInstanceOperation):
...
@@ -585,7 +587,7 @@ class MigrateOperation(RemoteInstanceOperation):
@register_operation
@register_operation
class
RebootOperation
(
RemoteInstanceOperation
):
class
RebootOperation
(
RemoteInstanceOperation
):
id
=
'reboot'
id
=
'reboot'
name
=
_
(
"reboot"
)
name
=
ugettext_lazy
(
"reboot"
)
description
=
_
(
"Warm reboot virtual machine by sending Ctrl+Alt+Del "
description
=
_
(
"Warm reboot virtual machine by sending Ctrl+Alt+Del "
"signal to its console."
)
"signal to its console."
)
required_perms
=
()
required_perms
=
()
...
@@ -602,7 +604,7 @@ class RebootOperation(RemoteInstanceOperation):
...
@@ -602,7 +604,7 @@ class RebootOperation(RemoteInstanceOperation):
@register_operation
@register_operation
class
RemoveInterfaceOperation
(
InstanceOperation
):
class
RemoveInterfaceOperation
(
InstanceOperation
):
id
=
'remove_interface'
id
=
'remove_interface'
name
=
_
(
"remove interface"
)
name
=
ugettext_lazy
(
"remove interface"
)
description
=
_
(
"Remove the specified network interface and erase IP "
description
=
_
(
"Remove the specified network interface and erase IP "
"address allocations, related firewall rules and "
"address allocations, related firewall rules and "
"hostnames."
)
"hostnames."
)
...
@@ -626,7 +628,7 @@ class RemoveInterfaceOperation(InstanceOperation):
...
@@ -626,7 +628,7 @@ class RemoveInterfaceOperation(InstanceOperation):
@register_operation
@register_operation
class
RemovePortOperation
(
InstanceOperation
):
class
RemovePortOperation
(
InstanceOperation
):
id
=
'remove_port'
id
=
'remove_port'
name
=
_
(
"close port"
)
name
=
ugettext_lazy
(
"close port"
)
description
=
_
(
"Close the specified port."
)
description
=
_
(
"Close the specified port."
)
concurrency_check
=
False
concurrency_check
=
False
acl_level
=
"operator"
acl_level
=
"operator"
...
@@ -645,7 +647,7 @@ class RemovePortOperation(InstanceOperation):
...
@@ -645,7 +647,7 @@ class RemovePortOperation(InstanceOperation):
@register_operation
@register_operation
class
AddPortOperation
(
InstanceOperation
):
class
AddPortOperation
(
InstanceOperation
):
id
=
'add_port'
id
=
'add_port'
name
=
_
(
"open port"
)
name
=
ugettext_lazy
(
"open port"
)
description
=
_
(
"Open the specified port."
)
description
=
_
(
"Open the specified port."
)
concurrency_check
=
False
concurrency_check
=
False
acl_level
=
"operator"
acl_level
=
"operator"
...
@@ -663,7 +665,7 @@ class AddPortOperation(InstanceOperation):
...
@@ -663,7 +665,7 @@ class AddPortOperation(InstanceOperation):
@register_operation
@register_operation
class
RemoveDiskOperation
(
InstanceOperation
):
class
RemoveDiskOperation
(
InstanceOperation
):
id
=
'remove_disk'
id
=
'remove_disk'
name
=
_
(
"remove disk"
)
name
=
ugettext_lazy
(
"remove disk"
)
description
=
_
(
"Remove the specified disk from the virtual machine, and "
description
=
_
(
"Remove the specified disk from the virtual machine, and "
"destroy the data."
)
"destroy the data."
)
required_perms
=
()
required_perms
=
()
...
@@ -687,7 +689,7 @@ class RemoveDiskOperation(InstanceOperation):
...
@@ -687,7 +689,7 @@ class RemoveDiskOperation(InstanceOperation):
@register_operation
@register_operation
class
ResetOperation
(
RemoteInstanceOperation
):
class
ResetOperation
(
RemoteInstanceOperation
):
id
=
'reset'
id
=
'reset'
name
=
_
(
"reset"
)
name
=
ugettext_lazy
(
"reset"
)
description
=
_
(
"Cold reboot virtual machine (power cycle)."
)
description
=
_
(
"Cold reboot virtual machine (power cycle)."
)
required_perms
=
()
required_perms
=
()
accept_states
=
(
'RUNNING'
,
)
accept_states
=
(
'RUNNING'
,
)
...
@@ -703,7 +705,7 @@ class ResetOperation(RemoteInstanceOperation):
...
@@ -703,7 +705,7 @@ class ResetOperation(RemoteInstanceOperation):
@register_operation
@register_operation
class
SaveAsTemplateOperation
(
InstanceOperation
):
class
SaveAsTemplateOperation
(
InstanceOperation
):
id
=
'save_as_template'
id
=
'save_as_template'
name
=
_
(
"save as template"
)
name
=
ugettext_lazy
(
"save as template"
)
description
=
_
(
"Save virtual machine as a template so they can be shared "
description
=
_
(
"Save virtual machine as a template so they can be shared "
"with users and groups. Anyone who has access to a "
"with users and groups. Anyone who has access to a "
"template (and to the networks it uses) will be able to "
"template (and to the networks it uses) will be able to "
...
@@ -815,7 +817,7 @@ class SaveAsTemplateOperation(InstanceOperation):
...
@@ -815,7 +817,7 @@ class SaveAsTemplateOperation(InstanceOperation):
class
ShutdownOperation
(
AbortableRemoteOperationMixin
,
class
ShutdownOperation
(
AbortableRemoteOperationMixin
,
RemoteInstanceOperation
):
RemoteInstanceOperation
):
id
=
'shutdown'
id
=
'shutdown'
name
=
_
(
"shutdown"
)
name
=
ugettext_lazy
(
"shutdown"
)
description
=
_
(
"Try to halt virtual machine by a standard ACPI signal, "
description
=
_
(
"Try to halt virtual machine by a standard ACPI signal, "
"allowing the operating system to keep a consistent "
"allowing the operating system to keep a consistent "
"state. The operation will fail if the machine does not "
"state. The operation will fail if the machine does not "
...
@@ -847,7 +849,7 @@ class ShutdownOperation(AbortableRemoteOperationMixin,
...
@@ -847,7 +849,7 @@ class ShutdownOperation(AbortableRemoteOperationMixin,
@register_operation
@register_operation
class
ShutOffOperation
(
InstanceOperation
):
class
ShutOffOperation
(
InstanceOperation
):
id
=
'shut_off'
id
=
'shut_off'
name
=
_
(
"shut off"
)
name
=
ugettext_lazy
(
"shut off"
)
description
=
_
(
"Forcibly halt a virtual machine without notifying the "
description
=
_
(
"Forcibly halt a virtual machine without notifying the "
"operating system. This operation will even work in cases "
"operating system. This operation will even work in cases "
"when shutdown does not, but the operating system and the "
"when shutdown does not, but the operating system and the "
...
@@ -873,7 +875,7 @@ class ShutOffOperation(InstanceOperation):
...
@@ -873,7 +875,7 @@ class ShutOffOperation(InstanceOperation):
@register_operation
@register_operation
class
SleepOperation
(
InstanceOperation
):
class
SleepOperation
(
InstanceOperation
):
id
=
'sleep'
id
=
'sleep'
name
=
_
(
"sleep"
)
name
=
ugettext_lazy
(
"sleep"
)
description
=
_
(
"Suspend virtual machine. This means the machine is "
description
=
_
(
"Suspend virtual machine. This means the machine is "
"stopped and its memory is saved to disk, so if the "
"stopped and its memory is saved to disk, so if the "
"machine is waked up, all the applications will keep "
"machine is waked up, all the applications will keep "
...
@@ -908,7 +910,7 @@ class SleepOperation(InstanceOperation):
...
@@ -908,7 +910,7 @@ class SleepOperation(InstanceOperation):
@register_operation
@register_operation
class
SuspendVmOperation
(
SubOperationMixin
,
RemoteInstanceOperation
):
class
SuspendVmOperation
(
SubOperationMixin
,
RemoteInstanceOperation
):
id
=
"_suspend_vm"
id
=
"_suspend_vm"
name
=
_
(
"suspend virtual machine"
)
name
=
ugettext_lazy
(
"suspend virtual machine"
)
task
=
vm_tasks
.
sleep
task
=
vm_tasks
.
sleep
remote_queue
=
(
"vm"
,
"slow"
)
remote_queue
=
(
"vm"
,
"slow"
)
remote_timeout
=
1000
remote_timeout
=
1000
...
@@ -922,7 +924,7 @@ class SleepOperation(InstanceOperation):
...
@@ -922,7 +924,7 @@ class SleepOperation(InstanceOperation):
@register_operation
@register_operation
class
WakeUpOperation
(
InstanceOperation
):
class
WakeUpOperation
(
InstanceOperation
):
id
=
'wake_up'
id
=
'wake_up'
name
=
_
(
"wake up"
)
name
=
ugettext_lazy
(
"wake up"
)
description
=
_
(
"Wake up sleeping (suspended) virtual machine. This will "
description
=
_
(
"Wake up sleeping (suspended) virtual machine. This will "
"load the saved memory of the system and start the "
"load the saved memory of the system and start the "
"virtual machine from this state."
)
"virtual machine from this state."
)
...
@@ -962,7 +964,7 @@ class WakeUpOperation(InstanceOperation):
...
@@ -962,7 +964,7 @@ class WakeUpOperation(InstanceOperation):
@register_operation
@register_operation
class
WakeUpVmOperation
(
SubOperationMixin
,
RemoteInstanceOperation
):
class
WakeUpVmOperation
(
SubOperationMixin
,
RemoteInstanceOperation
):
id
=
"_wake_up_vm"
id
=
"_wake_up_vm"
name
=
_
(
"resume virtual machine"
)
name
=
ugettext_lazy
(
"resume virtual machine"
)
task
=
vm_tasks
.
wake_up
task
=
vm_tasks
.
wake_up
remote_queue
=
(
"vm"
,
"slow"
)
remote_queue
=
(
"vm"
,
"slow"
)
remote_timeout
=
1000
remote_timeout
=
1000
...
@@ -976,7 +978,7 @@ class WakeUpOperation(InstanceOperation):
...
@@ -976,7 +978,7 @@ class WakeUpOperation(InstanceOperation):
@register_operation
@register_operation
class
RenewOperation
(
InstanceOperation
):
class
RenewOperation
(
InstanceOperation
):
id
=
'renew'
id
=
'renew'
name
=
_
(
"renew"
)
name
=
ugettext_lazy
(
"renew"
)
description
=
_
(
"Virtual machines are suspended and destroyed after they "
description
=
_
(
"Virtual machines are suspended and destroyed after they "
"expire. This operation renews expiration times according "
"expire. This operation renews expiration times according "
"to the lease type. If the machine is close to the "
"to the lease type. If the machine is close to the "
...
@@ -1032,7 +1034,7 @@ class RenewOperation(InstanceOperation):
...
@@ -1032,7 +1034,7 @@ class RenewOperation(InstanceOperation):
@register_operation
@register_operation
class
ChangeStateOperation
(
InstanceOperation
):
class
ChangeStateOperation
(
InstanceOperation
):
id
=
'emergency_change_state'
id
=
'emergency_change_state'
name
=
_
(
"emergency state change"
)
name
=
ugettext_lazy
(
"emergency state change"
)
description
=
_
(
"Change the virtual machine state to NOSTATE. This "
description
=
_
(
"Change the virtual machine state to NOSTATE. This "
"should only be used if manual intervention was needed in "
"should only be used if manual intervention was needed in "
"the virtualization layer, and the machine has to be "
"the virtualization layer, and the machine has to be "
...
@@ -1061,7 +1063,7 @@ class ChangeStateOperation(InstanceOperation):
...
@@ -1061,7 +1063,7 @@ class ChangeStateOperation(InstanceOperation):
@register_operation
@register_operation
class
RedeployOperation
(
InstanceOperation
):
class
RedeployOperation
(
InstanceOperation
):
id
=
'redeploy'
id
=
'redeploy'
name
=
_
(
"redeploy"
)
name
=
ugettext_lazy
(
"redeploy"
)
description
=
_
(
"Change the virtual machine state to NOSTATE "
description
=
_
(
"Change the virtual machine state to NOSTATE "
"and redeploy the VM. This operation allows starting "
"and redeploy the VM. This operation allows starting "
"machines formerly running on a failed node."
)
"machines formerly running on a failed node."
)
...
@@ -1125,7 +1127,7 @@ class NodeOperation(Operation):
...
@@ -1125,7 +1127,7 @@ class NodeOperation(Operation):
@register_operation
@register_operation
class
ResetNodeOperation
(
NodeOperation
):
class
ResetNodeOperation
(
NodeOperation
):
id
=
'reset'
id
=
'reset'
name
=
_
(
"reset"
)
name
=
ugettext_lazy
(
"reset"
)
description
=
_
(
"Disable missing node and redeploy all instances "
description
=
_
(
"Disable missing node and redeploy all instances "
"on other ones."
)
"on other ones."
)
required_perms
=
()
required_perms
=
()
...
@@ -1154,7 +1156,7 @@ class ResetNodeOperation(NodeOperation):
...
@@ -1154,7 +1156,7 @@ class ResetNodeOperation(NodeOperation):
@register_operation
@register_operation
class
FlushOperation
(
NodeOperation
):
class
FlushOperation
(
NodeOperation
):
id
=
'flush'
id
=
'flush'
name
=
_
(
"flush"
)
name
=
ugettext_lazy
(
"flush"
)
description
=
_
(
"Passivate node and move all instances to other ones."
)
description
=
_
(
"Passivate node and move all instances to other ones."
)
required_perms
=
()
required_perms
=
()
async_queue
=
"localhost.man.slow"
async_queue
=
"localhost.man.slow"
...
@@ -1174,7 +1176,7 @@ class FlushOperation(NodeOperation):
...
@@ -1174,7 +1176,7 @@ class FlushOperation(NodeOperation):
@register_operation
@register_operation
class
ActivateOperation
(
NodeOperation
):
class
ActivateOperation
(
NodeOperation
):
id
=
'activate'
id
=
'activate'
name
=
_
(
"activate"
)
name
=
ugettext_lazy
(
"activate"
)
description
=
_
(
"Make node active, i.e. scheduler is allowed to deploy "
description
=
_
(
"Make node active, i.e. scheduler is allowed to deploy "
"virtual machines to it."
)
"virtual machines to it."
)
required_perms
=
()
required_perms
=
()
...
@@ -1195,7 +1197,7 @@ class ActivateOperation(NodeOperation):
...
@@ -1195,7 +1197,7 @@ class ActivateOperation(NodeOperation):
@register_operation
@register_operation
class
PassivateOperation
(
NodeOperation
):
class
PassivateOperation
(
NodeOperation
):
id
=
'passivate'
id
=
'passivate'
name
=
_
(
"passivate"
)
name
=
ugettext_lazy
(
"passivate"
)
description
=
_
(
"Make node passive, i.e. scheduler is denied to deploy "
description
=
_
(
"Make node passive, i.e. scheduler is denied to deploy "
"virtual machines to it, but remaining instances and "
"virtual machines to it, but remaining instances and "
"the ones manually migrated will continue running."
)
"the ones manually migrated will continue running."
)
...
@@ -1217,7 +1219,7 @@ class PassivateOperation(NodeOperation):
...
@@ -1217,7 +1219,7 @@ class PassivateOperation(NodeOperation):
@register_operation
@register_operation
class
DisableOperation
(
NodeOperation
):
class
DisableOperation
(
NodeOperation
):
id
=
'disable'
id
=
'disable'
name
=
_
(
"disable"
)
name
=
ugettext_lazy
(
"disable"
)
description
=
_
(
"Disable node."
)
description
=
_
(
"Disable node."
)
required_perms
=
()
required_perms
=
()
online_required
=
False
online_required
=
False
...
@@ -1241,7 +1243,7 @@ class DisableOperation(NodeOperation):
...
@@ -1241,7 +1243,7 @@ class DisableOperation(NodeOperation):
@register_operation
@register_operation
class
UpdateNodeOperation
(
NodeOperation
):
class
UpdateNodeOperation
(
NodeOperation
):
id
=
'update_node'
id
=
'update_node'
name
=
_
(
"update node"
)
name
=
ugettext_lazy
(
"update node"
)
description
=
_
(
"Upgrade or install node software (vmdriver, agentdriver, "
description
=
_
(
"Upgrade or install node software (vmdriver, agentdriver, "
"monitor-client) with Salt."
)
"monitor-client) with Salt."
)
required_perms
=
()
required_perms
=
()
...
@@ -1314,7 +1316,7 @@ class UpdateNodeOperation(NodeOperation):
...
@@ -1314,7 +1316,7 @@ class UpdateNodeOperation(NodeOperation):
@register_operation
@register_operation
class
ScreenshotOperation
(
RemoteInstanceOperation
):
class
ScreenshotOperation
(
RemoteInstanceOperation
):
id
=
'screenshot'
id
=
'screenshot'
name
=
_
(
"screenshot"
)
name
=
ugettext_lazy
(
"screenshot"
)
description
=
_
(
"Get a screenshot about the virtual machine's console. A "
description
=
_
(
"Get a screenshot about the virtual machine's console. A "
"key will be pressed on the keyboard to stop "
"key will be pressed on the keyboard to stop "
"screensaver."
)
"screensaver."
)
...
@@ -1327,7 +1329,7 @@ class ScreenshotOperation(RemoteInstanceOperation):
...
@@ -1327,7 +1329,7 @@ class ScreenshotOperation(RemoteInstanceOperation):
@register_operation
@register_operation
class
RecoverOperation
(
InstanceOperation
):
class
RecoverOperation
(
InstanceOperation
):
id
=
'recover'
id
=
'recover'
name
=
_
(
"recover"
)
name
=
ugettext_lazy
(
"recover"
)
description
=
_
(
"Try to recover virtual machine disks from destroyed "
description
=
_
(
"Try to recover virtual machine disks from destroyed "
"state. Network resources (allocations) are already lost, "
"state. Network resources (allocations) are already lost, "
"so you will have to manually add interfaces afterwards."
)
"so you will have to manually add interfaces afterwards."
)
...
@@ -1368,7 +1370,7 @@ class RecoverOperation(InstanceOperation):
...
@@ -1368,7 +1370,7 @@ class RecoverOperation(InstanceOperation):
@register_operation
@register_operation
class
ResourcesOperation
(
InstanceOperation
):
class
ResourcesOperation
(
InstanceOperation
):
id
=
'resources_change'
id
=
'resources_change'
name
=
_
(
"resources change"
)
name
=
ugettext_lazy
(
"resources change"
)
description
=
_
(
"Change resources of a stopped virtual machine."
)
description
=
_
(
"Change resources of a stopped virtual machine."
)
acl_level
=
"owner"
acl_level
=
"owner"
required_perms
=
(
'vm.change_resources'
,
)
required_perms
=
(
'vm.change_resources'
,
)
...
@@ -1405,7 +1407,7 @@ class ResourcesOperation(InstanceOperation):
...
@@ -1405,7 +1407,7 @@ class ResourcesOperation(InstanceOperation):
@register_operation
@register_operation
class
PasswordResetOperation
(
RemoteAgentOperation
):
class
PasswordResetOperation
(
RemoteAgentOperation
):
id
=
'password_reset'
id
=
'password_reset'
name
=
_
(
"password reset"
)
name
=
ugettext_lazy
(
"password reset"
)
description
=
_
(
"Generate and set a new login password on the virtual "
description
=
_
(
"Generate and set a new login password on the virtual "
"machine. This operation requires the agent running. "
"machine. This operation requires the agent running. "
"Resetting the password is not warranted to allow you "
"Resetting the password is not warranted to allow you "
...
@@ -1430,7 +1432,7 @@ class PasswordResetOperation(RemoteAgentOperation):
...
@@ -1430,7 +1432,7 @@ class PasswordResetOperation(RemoteAgentOperation):
@register_operation
@register_operation
class
InstallKeysOperation
(
RemoteAgentOperation
):
class
InstallKeysOperation
(
RemoteAgentOperation
):
id
=
'install_keys'
id
=
'install_keys'
name
=
_
(
"install SSH keys"
)
name
=
ugettext_lazy
(
"install SSH keys"
)
description
=
_
(
"Copy your public keys to the virtual machines. "
description
=
_
(
"Copy your public keys to the virtual machines. "
"Only works on UNIX-like operating systems."
)
"Only works on UNIX-like operating systems."
)
acl_level
=
"user"
acl_level
=
"user"
...
@@ -1447,7 +1449,7 @@ class InstallKeysOperation(RemoteAgentOperation):
...
@@ -1447,7 +1449,7 @@ class InstallKeysOperation(RemoteAgentOperation):
@register_operation
@register_operation
class
RemoveKeysOperation
(
RemoteAgentOperation
):
class
RemoveKeysOperation
(
RemoteAgentOperation
):
id
=
'remove_keys'
id
=
'remove_keys'
name
=
_
(
"remove SSH keys"
)
name
=
ugettext_lazy
(
"remove SSH keys"
)
acl_level
=
"user"
acl_level
=
"user"
task
=
agent_tasks
.
del_keys
task
=
agent_tasks
.
del_keys
required_perms
=
()
required_perms
=
()
...
@@ -1460,7 +1462,7 @@ class RemoveKeysOperation(RemoteAgentOperation):
...
@@ -1460,7 +1462,7 @@ class RemoveKeysOperation(RemoteAgentOperation):
@register_operation
@register_operation
class
AgentStartedOperation
(
InstanceOperation
):
class
AgentStartedOperation
(
InstanceOperation
):
id
=
'agent_started'
id
=
'agent_started'
name
=
_
(
"agent"
)
name
=
ugettext_lazy
(
"agent"
)
acl_level
=
"owner"
acl_level
=
"owner"
required_perms
=
()
required_perms
=
()
concurrency_check
=
False
concurrency_check
=
False
...
@@ -1537,13 +1539,13 @@ class AgentStartedOperation(InstanceOperation):
...
@@ -1537,13 +1539,13 @@ class AgentStartedOperation(InstanceOperation):
@register_operation
@register_operation
class
CleanupOperation
(
SubOperationMixin
,
RemoteAgentOperation
):
class
CleanupOperation
(
SubOperationMixin
,
RemoteAgentOperation
):
id
=
'_cleanup'
id
=
'_cleanup'
name
=
_
(
"cleanup"
)
name
=
ugettext_lazy
(
"cleanup"
)
task
=
agent_tasks
.
cleanup
task
=
agent_tasks
.
cleanup
@register_operation
@register_operation
class
SetTimeOperation
(
SubOperationMixin
,
RemoteAgentOperation
):
class
SetTimeOperation
(
SubOperationMixin
,
RemoteAgentOperation
):
id
=
'_set_time'
id
=
'_set_time'
name
=
_
(
"set time"
)
name
=
ugettext_lazy
(
"set time"
)
task
=
agent_tasks
.
set_time
task
=
agent_tasks
.
set_time
def
_get_remote_args
(
self
,
**
kwargs
):
def
_get_remote_args
(
self
,
**
kwargs
):
...
@@ -1554,7 +1556,7 @@ class AgentStartedOperation(InstanceOperation):
...
@@ -1554,7 +1556,7 @@ class AgentStartedOperation(InstanceOperation):
@register_operation
@register_operation
class
SetHostnameOperation
(
SubOperationMixin
,
RemoteAgentOperation
):
class
SetHostnameOperation
(
SubOperationMixin
,
RemoteAgentOperation
):
id
=
'_set_hostname'
id
=
'_set_hostname'
name
=
_
(
"set hostname"
)
name
=
ugettext_lazy
(
"set hostname"
)
task
=
agent_tasks
.
set_hostname
task
=
agent_tasks
.
set_hostname
def
_get_remote_args
(
self
,
**
kwargs
):
def
_get_remote_args
(
self
,
**
kwargs
):
...
@@ -1565,13 +1567,13 @@ class AgentStartedOperation(InstanceOperation):
...
@@ -1565,13 +1567,13 @@ class AgentStartedOperation(InstanceOperation):
@register_operation
@register_operation
class
RestartNetworkingOperation
(
SubOperationMixin
,
RemoteAgentOperation
):
class
RestartNetworkingOperation
(
SubOperationMixin
,
RemoteAgentOperation
):
id
=
'_restart_networking'
id
=
'_restart_networking'
name
=
_
(
"restart networking"
)
name
=
ugettext_lazy
(
"restart networking"
)
task
=
agent_tasks
.
restart_networking
task
=
agent_tasks
.
restart_networking
@register_operation
@register_operation
class
ChangeIpOperation
(
SubOperationMixin
,
RemoteAgentOperation
):
class
ChangeIpOperation
(
SubOperationMixin
,
RemoteAgentOperation
):
id
=
'_change_ip'
id
=
'_change_ip'
name
=
_
(
"change ip"
)
name
=
ugettext_lazy
(
"change ip"
)
task
=
agent_tasks
.
change_ip
task
=
agent_tasks
.
change_ip
def
_get_remote_args
(
self
,
**
kwargs
):
def
_get_remote_args
(
self
,
**
kwargs
):
...
@@ -1586,7 +1588,7 @@ class AgentStartedOperation(InstanceOperation):
...
@@ -1586,7 +1588,7 @@ class AgentStartedOperation(InstanceOperation):
@register_operation
@register_operation
class
UpdateAgentOperation
(
RemoteAgentOperation
):
class
UpdateAgentOperation
(
RemoteAgentOperation
):
id
=
'update_agent'
id
=
'update_agent'
name
=
_
(
"update agent"
)
name
=
ugettext_lazy
(
"update agent"
)
acl_level
=
"owner"
acl_level
=
"owner"
required_perms
=
()
required_perms
=
()
...
@@ -1675,7 +1677,7 @@ class UpdateAgentOperation(RemoteAgentOperation):
...
@@ -1675,7 +1677,7 @@ class UpdateAgentOperation(RemoteAgentOperation):
@register_operation
@register_operation
class
MountStoreOperation
(
EnsureAgentMixin
,
InstanceOperation
):
class
MountStoreOperation
(
EnsureAgentMixin
,
InstanceOperation
):
id
=
'mount_store'
id
=
'mount_store'
name
=
_
(
"mount store"
)
name
=
ugettext_lazy
(
"mount store"
)
description
=
_
(
description
=
_
(
"This operation attaches your personal file store. Other users who "
"This operation attaches your personal file store. Other users who "
"have access to this machine can see these files as well."
"have access to this machine can see these files as well."
...
@@ -1711,7 +1713,7 @@ class AbstractDiskOperation(SubOperationMixin, RemoteInstanceOperation):
...
@@ -1711,7 +1713,7 @@ class AbstractDiskOperation(SubOperationMixin, RemoteInstanceOperation):
@register_operation
@register_operation
class
AttachDisk
(
AbstractDiskOperation
):
class
AttachDisk
(
AbstractDiskOperation
):
id
=
"_attach_disk"
id
=
"_attach_disk"
name
=
_
(
"attach disk"
)
name
=
ugettext_lazy
(
"attach disk"
)
task
=
vm_tasks
.
attach_disk
task
=
vm_tasks
.
attach_disk
...
@@ -1732,7 +1734,7 @@ class DetachMixin(object):
...
@@ -1732,7 +1734,7 @@ class DetachMixin(object):
@register_operation
@register_operation
class
DetachDisk
(
DetachMixin
,
AbstractDiskOperation
):
class
DetachDisk
(
DetachMixin
,
AbstractDiskOperation
):
id
=
"_detach_disk"
id
=
"_detach_disk"
name
=
_
(
"detach disk"
)
name
=
ugettext_lazy
(
"detach disk"
)
task
=
vm_tasks
.
detach_disk
task
=
vm_tasks
.
detach_disk
...
@@ -1747,12 +1749,12 @@ class AbstractNetworkOperation(SubOperationMixin, RemoteInstanceOperation):
...
@@ -1747,12 +1749,12 @@ class AbstractNetworkOperation(SubOperationMixin, RemoteInstanceOperation):
@register_operation
@register_operation
class
AttachNetwork
(
AbstractNetworkOperation
):
class
AttachNetwork
(
AbstractNetworkOperation
):
id
=
"_attach_network"
id
=
"_attach_network"
name
=
_
(
"attach network"
)
name
=
ugettext_lazy
(
"attach network"
)
task
=
vm_tasks
.
attach_network
task
=
vm_tasks
.
attach_network
@register_operation
@register_operation
class
DetachNetwork
(
DetachMixin
,
AbstractNetworkOperation
):
class
DetachNetwork
(
DetachMixin
,
AbstractNetworkOperation
):
id
=
"_detach_network"
id
=
"_detach_network"
name
=
_
(
"detach network"
)
name
=
ugettext_lazy
(
"detach network"
)
task
=
vm_tasks
.
detach_network
task
=
vm_tasks
.
detach_network
This diff is collapsed.
Click to expand it.
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