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
6786c800
authored
Mar 31, 2014
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: add 'system' parameter to operations
parent
0dd197ec
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
12 deletions
+14
-12
circle/vm/models/operation.py
+14
-12
No files found.
circle/vm/models/operation.py
View file @
6786c800
...
@@ -40,7 +40,9 @@ class Operation:
...
@@ -40,7 +40,9 @@ class Operation:
def
__prelude
(
self
,
kwargs
):
def
__prelude
(
self
,
kwargs
):
"""This method contains the shared prelude of __call__ and async.
"""This method contains the shared prelude of __call__ and async.
"""
"""
skip_checks
=
kwargs
.
setdefault
(
'system'
,
False
)
user
=
kwargs
.
setdefault
(
'user'
,
None
)
user
=
kwargs
.
setdefault
(
'user'
,
None
)
if
not
skip_checks
:
self
.
check_auth
(
user
)
self
.
check_auth
(
user
)
self
.
check_precond
()
self
.
check_precond
()
return
self
.
create_activity
(
user
=
user
)
return
self
.
create_activity
(
user
=
user
)
...
@@ -52,7 +54,7 @@ class Operation:
...
@@ -52,7 +54,7 @@ class Operation:
on_commit
=
self
.
on_commit
):
on_commit
=
self
.
on_commit
):
return
self
.
_operation
(
activity
,
user
,
**
kwargs
)
return
self
.
_operation
(
activity
,
user
,
**
kwargs
)
def
_operation
(
self
,
activity
,
user
,
**
kwargs
):
def
_operation
(
self
,
activity
,
user
,
system
,
**
kwargs
):
"""This method is the operation's particular implementation.
"""This method is the operation's particular implementation.
Deriving classes should implement this method.
Deriving classes should implement this method.
...
@@ -133,7 +135,7 @@ class DeployOperation(Operation):
...
@@ -133,7 +135,7 @@ class DeployOperation(Operation):
def
on_commit
(
self
,
activity
):
def
on_commit
(
self
,
activity
):
activity
.
resultant_state
=
'RUNNING'
activity
.
resultant_state
=
'RUNNING'
def
_operation
(
self
,
activity
,
user
):
def
_operation
(
self
,
activity
,
user
,
system
):
if
self
.
instance
.
destroyed_at
:
if
self
.
instance
.
destroyed_at
:
raise
self
.
instance
.
InstanceDestroyedError
(
self
.
instance
)
raise
self
.
instance
.
InstanceDestroyedError
(
self
.
instance
)
...
@@ -182,7 +184,7 @@ class DestroyOperation(Operation):
...
@@ -182,7 +184,7 @@ class DestroyOperation(Operation):
def
on_commit
(
self
,
activity
):
def
on_commit
(
self
,
activity
):
activity
.
resultant_state
=
'DESTROYED'
activity
.
resultant_state
=
'DESTROYED'
def
_operation
(
self
,
activity
,
user
):
def
_operation
(
self
,
activity
,
user
,
system
):
if
self
.
instance
.
node
:
if
self
.
instance
.
node
:
self
.
instance
.
_destroy_vm
(
activity
)
self
.
instance
.
_destroy_vm
(
activity
)
...
@@ -206,7 +208,7 @@ class MigrateOperation(Operation):
...
@@ -206,7 +208,7 @@ class MigrateOperation(Operation):
name
=
_
(
"migrate"
)
name
=
_
(
"migrate"
)
description
=
_
(
"""Live migrate running vm to another node."""
)
description
=
_
(
"""Live migrate running vm to another node."""
)
def
_operation
(
self
,
activity
,
user
,
to_node
=
None
,
timeout
=
120
):
def
_operation
(
self
,
activity
,
user
,
system
,
to_node
=
None
,
timeout
=
120
):
if
not
to_node
:
if
not
to_node
:
with
activity
.
sub_activity
(
'scheduling'
)
as
sa
:
with
activity
.
sub_activity
(
'scheduling'
)
as
sa
:
to_node
=
self
.
instance
.
select_node
()
to_node
=
self
.
instance
.
select_node
()
...
@@ -240,7 +242,7 @@ class RebootOperation(Operation):
...
@@ -240,7 +242,7 @@ class RebootOperation(Operation):
name
=
_
(
"reboot"
)
name
=
_
(
"reboot"
)
description
=
_
(
"""Reboot virtual machine with Ctrl+Alt+Del signal."""
)
description
=
_
(
"""Reboot virtual machine with Ctrl+Alt+Del signal."""
)
def
_operation
(
self
,
activity
,
user
,
timeout
=
5
):
def
_operation
(
self
,
activity
,
user
,
system
,
timeout
=
5
):
queue_name
=
self
.
instance
.
get_remote_queue_name
(
'vm'
)
queue_name
=
self
.
instance
.
get_remote_queue_name
(
'vm'
)
vm_tasks
.
reboot
.
apply_async
(
args
=
[
self
.
instance
.
vm_name
],
vm_tasks
.
reboot
.
apply_async
(
args
=
[
self
.
instance
.
vm_name
],
queue
=
queue_name
)
.
get
(
timeout
=
timeout
)
queue
=
queue_name
)
.
get
(
timeout
=
timeout
)
...
@@ -265,7 +267,7 @@ class RedeployOperation(Operation):
...
@@ -265,7 +267,7 @@ class RedeployOperation(Operation):
:type task_uuid: str
:type task_uuid: str
"""
)
"""
)
def
_operation
(
self
,
activity
,
user
):
def
_operation
(
self
,
activity
,
user
,
system
):
# Destroy VM
# Destroy VM
if
self
.
instance
.
node
:
if
self
.
instance
.
node
:
self
.
instance
.
_destroy_vm
(
activity
)
self
.
instance
.
_destroy_vm
(
activity
)
...
@@ -287,7 +289,7 @@ class ResetOperation(Operation):
...
@@ -287,7 +289,7 @@ class ResetOperation(Operation):
name
=
_
(
"reset"
)
name
=
_
(
"reset"
)
description
=
_
(
"""Reset virtual machine (reset button)"""
)
description
=
_
(
"""Reset virtual machine (reset button)"""
)
def
_operation
(
self
,
activity
,
user
,
timeout
=
5
):
def
_operation
(
self
,
activity
,
user
,
system
,
timeout
=
5
):
queue_name
=
self
.
instance
.
get_remote_queue_name
(
'vm'
)
queue_name
=
self
.
instance
.
get_remote_queue_name
(
'vm'
)
vm_tasks
.
reset
.
apply_async
(
args
=
[
self
.
instance
.
vm_name
],
vm_tasks
.
reset
.
apply_async
(
args
=
[
self
.
instance
.
vm_name
],
queue
=
queue_name
)
.
get
(
timeout
=
timeout
)
queue
=
queue_name
)
.
get
(
timeout
=
timeout
)
...
@@ -306,7 +308,7 @@ class SaveAsTemplateOperation(Operation):
...
@@ -306,7 +308,7 @@ class SaveAsTemplateOperation(Operation):
Users can instantiate Virtual Machines from Templates.
Users can instantiate Virtual Machines from Templates.
"""
)
"""
)
def
_operation
(
self
,
activity
,
name
,
user
,
timeout
=
300
,
**
kwargs
):
def
_operation
(
self
,
activity
,
name
,
user
,
system
,
timeout
=
300
,
**
kwargs
):
# prepare parameters
# prepare parameters
params
=
{
params
=
{
'access_method'
:
self
.
instance
.
access_method
,
'access_method'
:
self
.
instance
.
access_method
,
...
@@ -368,7 +370,7 @@ class ShutdownOperation(Operation):
...
@@ -368,7 +370,7 @@ class ShutdownOperation(Operation):
def
on_commit
(
self
,
activity
):
def
on_commit
(
self
,
activity
):
activity
.
resultant_state
=
'STOPPED'
activity
.
resultant_state
=
'STOPPED'
def
_operation
(
self
,
activity
,
user
,
timeout
=
120
):
def
_operation
(
self
,
activity
,
user
,
system
,
timeout
=
120
):
queue_name
=
self
.
instance
.
get_remote_queue_name
(
'vm'
)
queue_name
=
self
.
instance
.
get_remote_queue_name
(
'vm'
)
logger
.
debug
(
"RPC Shutdown at queue:
%
s, for vm:
%
s."
,
logger
.
debug
(
"RPC Shutdown at queue:
%
s, for vm:
%
s."
,
self
.
instance
.
vm_name
,
queue_name
)
# TODO param order ok?
self
.
instance
.
vm_name
,
queue_name
)
# TODO param order ok?
...
@@ -391,7 +393,7 @@ class ShutOffOperation(Operation):
...
@@ -391,7 +393,7 @@ class ShutOffOperation(Operation):
def
on_commit
(
activity
):
def
on_commit
(
activity
):
activity
.
resultant_state
=
'STOPPED'
activity
.
resultant_state
=
'STOPPED'
def
_operation
(
self
,
activity
,
user
):
def
_operation
(
self
,
activity
,
user
,
system
):
# Destroy VM
# Destroy VM
if
self
.
instance
.
node
:
if
self
.
instance
.
node
:
self
.
instance
.
_destroy_vm
(
activity
)
self
.
instance
.
_destroy_vm
(
activity
)
...
@@ -422,7 +424,7 @@ class SleepOperation(Operation):
...
@@ -422,7 +424,7 @@ class SleepOperation(Operation):
def
on_commit
(
self
,
activity
):
def
on_commit
(
self
,
activity
):
activity
.
resultant_state
=
'SUSPENDED'
activity
.
resultant_state
=
'SUSPENDED'
def
_operation
(
self
,
activity
,
user
,
timeout
=
60
):
def
_operation
(
self
,
activity
,
user
,
system
,
timeout
=
60
):
# Destroy networks
# Destroy networks
with
activity
.
sub_activity
(
'destroying_net'
):
with
activity
.
sub_activity
(
'destroying_net'
):
for
net
in
self
.
instance
.
interface_set
.
all
():
for
net
in
self
.
instance
.
interface_set
.
all
():
...
@@ -460,7 +462,7 @@ class WakeUpOperation(Operation):
...
@@ -460,7 +462,7 @@ class WakeUpOperation(Operation):
def
on_commit
(
self
,
activity
):
def
on_commit
(
self
,
activity
):
activity
.
resultant_state
=
'RUNNING'
activity
.
resultant_state
=
'RUNNING'
def
_operation
(
self
,
activity
,
user
,
timeout
=
60
):
def
_operation
(
self
,
activity
,
user
,
system
,
timeout
=
60
):
# Schedule vm
# Schedule vm
self
.
instance
.
_schedule_vm
(
activity
)
self
.
instance
.
_schedule_vm
(
activity
)
queue_name
=
self
.
instance
.
get_remote_queue_name
(
'vm'
)
queue_name
=
self
.
instance
.
get_remote_queue_name
(
'vm'
)
...
...
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