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
b560c0d5
authored
Nov 12, 2019
by
Bálint Máhonfai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Formatting fixes
parent
5179872f
Pipeline
#950
passed with stage
in 0 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
27 deletions
+23
-27
circle/vm/operations.py
+23
-27
No files found.
circle/vm/operations.py
View file @
b560c0d5
...
@@ -62,7 +62,6 @@ logger = getLogger(__name__)
...
@@ -62,7 +62,6 @@ logger = getLogger(__name__)
class
RemoteOperationMixin
(
object
):
class
RemoteOperationMixin
(
object
):
remote_timeout
=
30
remote_timeout
=
30
def
_operation
(
self
,
**
kwargs
):
def
_operation
(
self
,
**
kwargs
):
...
@@ -167,7 +166,6 @@ class InstanceOperation(Operation):
...
@@ -167,7 +166,6 @@ class InstanceOperation(Operation):
class
RemoteInstanceOperation
(
RemoteOperationMixin
,
InstanceOperation
):
class
RemoteInstanceOperation
(
RemoteOperationMixin
,
InstanceOperation
):
remote_queue
=
(
'vm'
,
'fast'
)
remote_queue
=
(
'vm'
,
'fast'
)
def
_get_remote_queue
(
self
):
def
_get_remote_queue
(
self
):
...
@@ -178,7 +176,7 @@ class RemoteInstanceOperation(RemoteOperationMixin, InstanceOperation):
...
@@ -178,7 +176,7 @@ class RemoteInstanceOperation(RemoteOperationMixin, InstanceOperation):
class
EnsureAgentMixin
(
object
):
class
EnsureAgentMixin
(
object
):
accept_states
=
(
'RUNNING'
,
)
accept_states
=
(
'RUNNING'
,)
def
check_precond
(
self
):
def
check_precond
(
self
):
super
(
EnsureAgentMixin
,
self
)
.
check_precond
()
super
(
EnsureAgentMixin
,
self
)
.
check_precond
()
...
@@ -198,7 +196,7 @@ class EnsureAgentMixin(object):
...
@@ -198,7 +196,7 @@ class EnsureAgentMixin(object):
class
RemoteAgentOperation
(
EnsureAgentMixin
,
RemoteInstanceOperation
):
class
RemoteAgentOperation
(
EnsureAgentMixin
,
RemoteInstanceOperation
):
remote_queue
=
(
'agent'
,
)
remote_queue
=
(
'agent'
,)
concurrency_check
=
False
concurrency_check
=
False
...
@@ -248,11 +246,10 @@ class AddInterfaceOperation(InstanceOperation):
...
@@ -248,11 +246,10 @@ class AddInterfaceOperation(InstanceOperation):
@register_operation
@register_operation
class
CreateDiskOperation
(
InstanceOperation
):
class
CreateDiskOperation
(
InstanceOperation
):
id
=
'create_disk'
id
=
'create_disk'
name
=
_
(
"create disk"
)
name
=
_
(
"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'
)
def
_operation
(
self
,
user
,
size
,
activity
,
name
=
None
):
def
_operation
(
self
,
user
,
size
,
activity
,
name
=
None
):
...
@@ -285,13 +282,12 @@ class CreateDiskOperation(InstanceOperation):
...
@@ -285,13 +282,12 @@ class CreateDiskOperation(InstanceOperation):
@register_operation
@register_operation
class
ResizeDiskOperation
(
RemoteInstanceOperation
):
class
ResizeDiskOperation
(
RemoteInstanceOperation
):
id
=
'resize_disk'
id
=
'resize_disk'
name
=
_
(
"resize disk"
)
name
=
_
(
"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'
,)
accept_states
=
(
'RUNNING'
,
)
accept_states
=
(
'RUNNING'
,)
async_queue
=
"localhost.man.slow"
async_queue
=
"localhost.man.slow"
remote_queue
=
(
'vm'
,
'slow'
)
remote_queue
=
(
'vm'
,
'slow'
)
task
=
vm_tasks
.
resize_disk
task
=
vm_tasks
.
resize_disk
...
@@ -324,7 +320,7 @@ class DownloadDiskOperation(InstanceOperation):
...
@@ -324,7 +320,7 @@ class DownloadDiskOperation(InstanceOperation):
"machine."
)
"machine."
)
abortable
=
True
abortable
=
True
has_percentage
=
True
has_percentage
=
True
required_perms
=
(
'storage.download_disk'
,
)
required_perms
=
(
'storage.download_disk'
,)
accept_states
=
(
'STOPPED'
,
'PENDING'
,
'RUNNING'
)
accept_states
=
(
'STOPPED'
,
'PENDING'
,
'RUNNING'
)
async_queue
=
"localhost.man.slow"
async_queue
=
"localhost.man.slow"
...
@@ -376,7 +372,6 @@ class ExportDiskOperation(InstanceOperation):
...
@@ -376,7 +372,6 @@ class ExportDiskOperation(InstanceOperation):
@register_operation
@register_operation
class
ImportDiskOperation
(
InstanceOperation
):
class
ImportDiskOperation
(
InstanceOperation
):
id
=
'import_disk'
id
=
'import_disk'
name
=
_
(
'import disk'
)
name
=
_
(
'import disk'
)
description
=
_
(
'Import and attach a disk image to the virtual machine.'
)
description
=
_
(
'Import and attach a disk image to the virtual machine.'
)
...
@@ -461,6 +456,7 @@ class DeployOperation(InstanceOperation):
...
@@ -461,6 +456,7 @@ class DeployOperation(InstanceOperation):
remote_queue
=
(
"vm"
,
"slow"
)
remote_queue
=
(
"vm"
,
"slow"
)
task
=
vm_tasks
.
deploy
task
=
vm_tasks
.
deploy
remote_timeout
=
120
remote_timeout
=
120
def
_get_remote_args
(
self
,
**
kwargs
):
def
_get_remote_args
(
self
,
**
kwargs
):
return
[
self
.
instance
.
get_vm_desc
()]
return
[
self
.
instance
.
get_vm_desc
()]
# intentionally not calling super
# intentionally not calling super
...
@@ -569,7 +565,7 @@ class MigrateOperation(RemoteInstanceOperation):
...
@@ -569,7 +565,7 @@ class MigrateOperation(RemoteInstanceOperation):
"keeping its full state."
)
"keeping its full state."
)
required_perms
=
()
required_perms
=
()
superuser_required
=
True
superuser_required
=
True
accept_states
=
(
'RUNNING'
,
)
accept_states
=
(
'RUNNING'
,)
async_queue
=
"localhost.man.slow"
async_queue
=
"localhost.man.slow"
task
=
vm_tasks
.
migrate
task
=
vm_tasks
.
migrate
remote_queue
=
(
"vm"
,
"slow"
)
remote_queue
=
(
"vm"
,
"slow"
)
...
@@ -628,7 +624,7 @@ class RebootOperation(RemoteInstanceOperation):
...
@@ -628,7 +624,7 @@ class RebootOperation(RemoteInstanceOperation):
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
=
()
accept_states
=
(
'RUNNING'
,
)
accept_states
=
(
'RUNNING'
,)
task
=
vm_tasks
.
reboot
task
=
vm_tasks
.
reboot
def
_operation
(
self
,
activity
):
def
_operation
(
self
,
activity
):
...
@@ -669,7 +665,7 @@ class RemovePortOperation(InstanceOperation):
...
@@ -669,7 +665,7 @@ class RemovePortOperation(InstanceOperation):
description
=
_
(
"Close the specified port."
)
description
=
_
(
"Close the specified port."
)
concurrency_check
=
False
concurrency_check
=
False
acl_level
=
"operator"
acl_level
=
"operator"
required_perms
=
(
'vm.config_ports'
,
)
required_perms
=
(
'vm.config_ports'
,)
def
_operation
(
self
,
activity
,
rule
):
def
_operation
(
self
,
activity
,
rule
):
interface
=
rule
.
host
.
interface_set
.
get
()
interface
=
rule
.
host
.
interface_set
.
get
()
...
@@ -688,7 +684,7 @@ class AddPortOperation(InstanceOperation):
...
@@ -688,7 +684,7 @@ class AddPortOperation(InstanceOperation):
description
=
_
(
"Open the specified port."
)
description
=
_
(
"Open the specified port."
)
concurrency_check
=
False
concurrency_check
=
False
acl_level
=
"operator"
acl_level
=
"operator"
required_perms
=
(
'vm.config_ports'
,
)
required_perms
=
(
'vm.config_ports'
,)
def
_operation
(
self
,
activity
,
host
,
proto
,
port
):
def
_operation
(
self
,
activity
,
host
,
proto
,
port
):
if
host
.
interface_set
.
get
()
.
instance
!=
self
.
instance
:
if
host
.
interface_set
.
get
()
.
instance
!=
self
.
instance
:
...
@@ -729,7 +725,7 @@ class ResetOperation(RemoteInstanceOperation):
...
@@ -729,7 +725,7 @@ class ResetOperation(RemoteInstanceOperation):
name
=
_
(
"reset"
)
name
=
_
(
"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'
,)
task
=
vm_tasks
.
reset
task
=
vm_tasks
.
reset
def
_operation
(
self
,
activity
):
def
_operation
(
self
,
activity
):
...
@@ -749,7 +745,7 @@ class SaveAsTemplateOperation(InstanceOperation):
...
@@ -749,7 +745,7 @@ class SaveAsTemplateOperation(InstanceOperation):
"start an instance of it."
)
"start an instance of it."
)
has_percentage
=
True
has_percentage
=
True
abortable
=
True
abortable
=
True
required_perms
=
(
'vm.create_template'
,
)
required_perms
=
(
'vm.create_template'
,)
accept_states
=
(
'RUNNING'
,
'STOPPED'
)
accept_states
=
(
'RUNNING'
,
'STOPPED'
)
async_queue
=
"localhost.man.slow"
async_queue
=
"localhost.man.slow"
...
@@ -861,7 +857,7 @@ class ShutdownOperation(AbortableRemoteOperationMixin,
...
@@ -861,7 +857,7 @@ class ShutdownOperation(AbortableRemoteOperationMixin,
"turn itself off in a period."
)
"turn itself off in a period."
)
abortable
=
True
abortable
=
True
required_perms
=
()
required_perms
=
()
accept_states
=
(
'RUNNING'
,
)
accept_states
=
(
'RUNNING'
,)
resultant_state
=
'STOPPED'
resultant_state
=
'STOPPED'
task
=
vm_tasks
.
shutdown
task
=
vm_tasks
.
shutdown
remote_queue
=
(
"vm"
,
"slow"
)
remote_queue
=
(
"vm"
,
"slow"
)
...
@@ -922,7 +918,7 @@ class SleepOperation(InstanceOperation):
...
@@ -922,7 +918,7 @@ class SleepOperation(InstanceOperation):
"resumed. In the meantime, the machine will only use "
"resumed. In the meantime, the machine will only use "
"storage resources, and keep network resources allocated."
)
"storage resources, and keep network resources allocated."
)
required_perms
=
()
required_perms
=
()
accept_states
=
(
'RUNNING'
,
)
accept_states
=
(
'RUNNING'
,)
resultant_state
=
'SUSPENDED'
resultant_state
=
'SUSPENDED'
async_queue
=
"localhost.man.slow"
async_queue
=
"localhost.man.slow"
...
@@ -966,7 +962,7 @@ class WakeUpOperation(InstanceOperation):
...
@@ -966,7 +962,7 @@ class WakeUpOperation(InstanceOperation):
"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."
)
required_perms
=
()
required_perms
=
()
accept_states
=
(
'SUSPENDED'
,
)
accept_states
=
(
'SUSPENDED'
,)
resultant_state
=
'RUNNING'
resultant_state
=
'RUNNING'
async_queue
=
"localhost.man.slow"
async_queue
=
"localhost.man.slow"
...
@@ -1078,7 +1074,7 @@ class ChangeStateOperation(InstanceOperation):
...
@@ -1078,7 +1074,7 @@ class ChangeStateOperation(InstanceOperation):
"redeployed without losing its storage and network "
"redeployed without losing its storage and network "
"resources."
)
"resources."
)
acl_level
=
"owner"
acl_level
=
"owner"
required_perms
=
(
'vm.emergency_change_state'
,
)
required_perms
=
(
'vm.emergency_change_state'
,)
concurrency_check
=
False
concurrency_check
=
False
def
_operation
(
self
,
user
,
activity
,
new_state
=
"NOSTATE"
,
interrupt
=
False
,
def
_operation
(
self
,
user
,
activity
,
new_state
=
"NOSTATE"
,
interrupt
=
False
,
...
@@ -1105,7 +1101,7 @@ class RedeployOperation(InstanceOperation):
...
@@ -1105,7 +1101,7 @@ class RedeployOperation(InstanceOperation):
"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."
)
acl_level
=
"owner"
acl_level
=
"owner"
required_perms
=
(
'vm.redeploy'
,
)
required_perms
=
(
'vm.redeploy'
,)
concurrency_check
=
False
concurrency_check
=
False
def
_operation
(
self
,
user
,
activity
,
with_emergency_change_state
=
True
):
def
_operation
(
self
,
user
,
activity
,
with_emergency_change_state
=
True
):
...
@@ -1359,7 +1355,7 @@ class ScreenshotOperation(RemoteInstanceOperation):
...
@@ -1359,7 +1355,7 @@ class ScreenshotOperation(RemoteInstanceOperation):
"screensaver."
)
"screensaver."
)
acl_level
=
"owner"
acl_level
=
"owner"
required_perms
=
()
required_perms
=
()
accept_states
=
(
'RUNNING'
,
)
accept_states
=
(
'RUNNING'
,)
task
=
vm_tasks
.
screenshot
task
=
vm_tasks
.
screenshot
...
@@ -1371,8 +1367,8 @@ class RecoverOperation(InstanceOperation):
...
@@ -1371,8 +1367,8 @@ class RecoverOperation(InstanceOperation):
"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."
)
acl_level
=
"owner"
acl_level
=
"owner"
required_perms
=
(
'vm.recover'
,
)
required_perms
=
(
'vm.recover'
,)
accept_states
=
(
'DESTROYED'
,
)
accept_states
=
(
'DESTROYED'
,)
resultant_state
=
'PENDING'
resultant_state
=
'PENDING'
def
check_precond
(
self
):
def
check_precond
(
self
):
...
@@ -1410,7 +1406,7 @@ class ResourcesOperation(InstanceOperation):
...
@@ -1410,7 +1406,7 @@ class ResourcesOperation(InstanceOperation):
name
=
_
(
"resources change"
)
name
=
_
(
"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'
,)
accept_states
=
(
'STOPPED'
,
'PENDING'
,
'RUNNING'
)
accept_states
=
(
'STOPPED'
,
'PENDING'
,
'RUNNING'
)
def
_operation
(
self
,
user
,
activity
,
def
_operation
(
self
,
user
,
activity
,
...
@@ -1716,7 +1712,7 @@ class UpdateAgentOperation(RemoteAgentOperation):
...
@@ -1716,7 +1712,7 @@ class UpdateAgentOperation(RemoteAgentOperation):
index
=
0
index
=
0
filename
=
settings
.
AGENT_VERSION
+
".tar"
filename
=
settings
.
AGENT_VERSION
+
".tar"
while
True
:
while
True
:
chunk
=
data
[
index
:
index
+
chunk_size
]
chunk
=
data
[
index
:
index
+
chunk_size
]
if
chunk
:
if
chunk
:
agent_tasks
.
append
.
apply_async
(
agent_tasks
.
append
.
apply_async
(
queue
=
queue
,
queue
=
queue
,
...
...
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