Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
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
9c7ba32e
authored
Oct 03, 2013
by
Guba Sándor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: refactoring tasks names
parent
ba62e349
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
80 deletions
+79
-80
circle/vm/models.py
+58
-50
circle/vm/tasks/local_tasks.py
+3
-2
circle/vm/tasks/net_tasks.py
+1
-1
circle/vm/tasks/vm_tasks.py
+17
-27
No files found.
circle/vm/models.py
View file @
9c7ba32e
...
@@ -530,84 +530,96 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
...
@@ -530,84 +530,96 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
act
.
finish
(
result
=
'SUCCESS'
)
act
.
finish
(
result
=
'SUCCESS'
)
def
de
ploy_async
(
self
,
user
=
None
):
def
de
stroy
(
self
,
user
=
None
,
task_uuid
=
None
):
"""
Execute deploy asynchronously
.
"""
Remove Instance with its networks
.
"""
"""
local_tasks
.
deploy
.
apply_async
(
args
=
[
self
,
user
],
act
=
InstanceActivity
(
activity_code
=
'vm.Instance.destroy'
)
queue
=
"localhost.man"
)
def
stop
(
self
,
user
=
None
,
task_uuid
=
None
):
act
=
InstanceActivity
(
activity_code
=
'vm.Instance.stop'
)
act
.
instance
=
self
act
.
instance
=
self
act
.
user
=
user
act
.
user
=
user
act
.
started
=
timezone
.
now
()
act
.
started
=
timezone
.
now
()
act
.
task_uuid
=
task_uuid
act
.
task_uuid
=
task_uuid
act
.
save
()
act
.
save
()
queue_name
=
self
.
node
.
host
.
hostname
+
".vm"
queue_name
=
self
.
node
.
host
.
hostname
+
".vm"
vm_tasks
.
stop
.
apply_async
(
args
=
[
self
.
vm_name
],
# Delete instance
vm_tasks
.
destroy
.
apply_async
(
args
=
[
self
.
vm_name
],
queue
=
queue_name
)
.
get
()
queue
=
queue_name
)
.
get
()
act
.
finish
(
result
=
'SUCCESS'
)
# Delete networks
for
net
in
self
.
interface_set
.
all
():
net
.
remove
()
act
.
finish
(
result
=
"DONE"
)
def
stop
_async
(
self
,
user
=
None
):
def
destroy
_async
(
self
,
user
=
None
):
"""Execute
stop asynchrono
usly.
"""Execute
destroy() asyncrhon
usly.
"""
"""
local_tasks
.
stop
.
apply_async
(
args
=
[
self
,
user
],
queue
=
"localhost.man"
)
local_tasks
.
destroy
.
apply_async
(
args
=
[
self
,
user
],
queue
=
"localhost.man"
)
def
resume
(
self
,
user
=
None
,
task_uuid
=
None
):
def
deploy_async
(
self
,
user
=
None
):
act
=
InstanceActivity
(
activity_code
=
'vm.Instance.resume'
)
"""Execute deploy() asynchronously.
"""
local_tasks
.
deploy
.
apply_async
(
args
=
[
self
,
user
],
queue
=
"localhost.man"
)
def
sleep
(
self
,
user
=
None
,
task_uuid
=
None
):
"""Suspend virtual machine with memory dump.
"""
act
=
InstanceActivity
(
activity_code
=
'vm.Instance.sleep'
)
act
.
instance
=
self
act
.
instance
=
self
act
.
user
=
user
act
.
user
=
user
act
.
started
=
timezone
.
now
()
act
.
started
=
timezone
.
now
()
act
.
task_uuid
=
task_uuid
act
.
task_uuid
=
task_uuid
act
.
save
()
act
.
save
()
queue_name
=
self
.
node
.
host
.
hostname
+
".vm"
queue_name
=
self
.
node
.
host
.
hostname
+
".vm"
vm_tasks
.
resume
.
apply_async
(
args
=
[
self
.
vm_name
],
vm_tasks
.
sleep
.
apply_async
(
args
=
[
self
.
vm_name
],
queue
=
queue_name
)
.
get
()
queue
=
queue_name
)
.
get
()
act
.
finish
(
result
=
'SUCCESS'
)
act
.
finish
(
result
=
'SUCCESS'
)
def
resume
_async
(
self
,
user
=
None
):
def
sleep
_async
(
self
,
user
=
None
):
"""Execute
resume
asynchronously.
"""Execute
suspend()
asynchronously.
"""
"""
local_tasks
.
resume
.
apply_async
(
args
=
[
self
,
user
],
local_tasks
.
sleep
.
apply_async
(
args
=
[
self
,
user
],
queue
=
"localhost.man"
)
queue
=
"localhost.man"
)
def
poweroff
(
self
,
user
=
None
,
task_uuid
=
None
):
def
wake_up
(
self
,
user
=
None
,
task_uuid
=
None
):
act
=
InstanceActivity
(
activity_code
=
'vm.Instance.
power_off
'
)
act
=
InstanceActivity
(
activity_code
=
'vm.Instance.
resume
'
)
act
.
instance
=
self
act
.
instance
=
self
act
.
user
=
user
act
.
user
=
user
act
.
started
=
timezone
.
now
()
act
.
started
=
timezone
.
now
()
act
.
task_uuid
=
task_uuid
act
.
task_uuid
=
task_uuid
act
.
save
()
act
.
save
()
queue_name
=
self
.
node
.
host
.
hostname
+
".vm"
queue_name
=
self
.
node
.
host
.
hostname
+
".vm"
vm_tasks
.
power_off
.
apply_async
(
args
=
[
self
.
vm_name
],
vm_tasks
.
resume
.
apply_async
(
args
=
[
self
.
vm_name
],
queue
=
queue_name
)
.
get
()
queue
=
queue_name
)
.
get
()
act
.
finish
(
result
=
'SUCCESS'
)
act
.
finish
(
result
=
'SUCCESS'
)
def
poweroff
_async
(
self
,
user
=
None
):
def
wake_up
_async
(
self
,
user
=
None
):
"""Execute
poweroff
asynchronously.
"""Execute
resume()
asynchronously.
"""
"""
local_tasks
.
power_off
.
apply_async
(
args
=
[
self
,
user
],
local_tasks
.
resume
.
apply_async
(
args
=
[
self
,
user
],
queue
=
"localhost.man"
)
queue
=
"localhost.man"
)
def
restart
(
self
,
user
=
None
,
task_uuid
=
None
):
def
shutdown
(
self
,
user
=
None
,
task_uuid
=
None
):
act
=
InstanceActivity
(
activity_code
=
'vm.Instance.restart'
)
"""Shutdown virtual machine with ACPI signal.
"""
act
=
InstanceActivity
(
activity_code
=
'vm.Instance.power_off'
)
act
.
instance
=
self
act
.
instance
=
self
act
.
user
=
user
act
.
user
=
user
act
.
started
=
timezone
.
now
()
act
.
started
=
timezone
.
now
()
act
.
task_uuid
=
task_uuid
act
.
task_uuid
=
task_uuid
act
.
save
()
act
.
save
()
queue_name
=
self
.
node
.
host
.
hostname
+
".vm"
queue_name
=
self
.
node
.
host
.
hostname
+
".vm"
vm_tasks
.
restart
.
apply_async
(
args
=
[
self
.
vm_name
],
vm_tasks
.
shutdown
.
apply_async
(
args
=
[
self
.
vm_name
],
queue
=
queue_name
)
.
get
()
queue
=
queue_name
)
.
get
()
act
.
finish
(
result
=
'SUCCESS'
)
act
.
finish
(
result
=
'SUCCESS'
)
def
restart
_async
(
self
,
user
=
None
):
def
shutdown
_async
(
self
,
user
=
None
):
"""Execute
restart
asynchronously.
"""Execute
shutdown
asynchronously.
"""
"""
local_tasks
.
restart
.
apply_async
(
args
=
[
self
,
user
],
local_tasks
.
shutdown
.
apply_async
(
args
=
[
self
,
user
],
queue
=
"localhost.man"
)
queue
=
"localhost.man"
)
def
save_as
(
self
,
user
=
None
,
task_uuid
=
None
):
def
reset
(
self
,
user
=
None
,
task_uuid
=
None
):
"""Reset virtual machine (reset button)
"""
act
=
InstanceActivity
(
activity_code
=
'vm.Instance.restart'
)
act
=
InstanceActivity
(
activity_code
=
'vm.Instance.restart'
)
act
.
instance
=
self
act
.
instance
=
self
act
.
user
=
user
act
.
user
=
user
...
@@ -615,38 +627,34 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
...
@@ -615,38 +627,34 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
act
.
task_uuid
=
task_uuid
act
.
task_uuid
=
task_uuid
act
.
save
()
act
.
save
()
queue_name
=
self
.
node
.
host
.
hostname
+
".vm"
queue_name
=
self
.
node
.
host
.
hostname
+
".vm"
vm_tasks
.
save_as
.
apply_async
(
args
=
[
self
.
vm_name
],
vm_tasks
.
restart
.
apply_async
(
args
=
[
self
.
vm_name
],
queue
=
queue_name
)
.
get
()
queue
=
queue_name
)
.
get
()
act
.
finish
(
result
=
'SUCCESS'
)
act
.
finish
(
result
=
'SUCCESS'
)
def
save_as_async
(
self
,
user
=
None
,
task_uuid
=
None
):
def
reset_async
(
self
,
user
=
None
):
"""Execute
save_as
asynchronously.
"""Execute
reset
asynchronously.
"""
"""
local_tasks
.
save_as
.
apply_async
(
args
=
[
self
,
user
],
local_tasks
.
restart
.
apply_async
(
args
=
[
self
,
user
],
queue
=
"localhost.man"
)
queue
=
"localhost.man"
)
def
re
move
(
self
,
user
=
None
,
task_uuid
=
None
):
def
re
boot
(
self
,
user
=
None
,
task_uuid
=
None
):
"""
Remove Instance with its networks
.
"""
Reboot virtual machin with ctr+alt+del signal
.
"""
"""
act
=
InstanceActivity
(
activity_code
=
'vm.Instance.re
move
'
)
act
=
InstanceActivity
(
activity_code
=
'vm.Instance.re
boot
'
)
act
.
instance
=
self
act
.
instance
=
self
act
.
user
=
user
act
.
user
=
user
act
.
started
=
timezone
.
now
()
act
.
started
=
timezone
.
now
()
act
.
task_uuid
=
task_uuid
act
.
task_uuid
=
task_uuid
act
.
save
()
act
.
save
()
queue_name
=
self
.
node
.
host
.
hostname
+
".vm"
queue_name
=
self
.
node
.
host
.
hostname
+
".vm"
# Delete instance
vm_tasks
.
reboot
.
apply_async
(
args
=
[
self
.
vm_name
],
vm_tasks
.
delete
.
apply_async
(
args
=
[
self
.
vm_name
],
queue
=
queue_name
)
.
get
()
queue
=
queue_name
)
.
get
()
# Delete networks
act
.
finish
(
result
=
'SUCCESS'
)
for
net
in
self
.
interface_set
.
all
():
net
.
remove
()
act
.
finish
(
result
=
"DONE"
)
def
re
move
_async
(
self
,
user
=
None
):
def
re
boot
_async
(
self
,
user
=
None
):
"""
Asyncron remove()
"""
Execute reboot asynchronously.
"""
"""
local_tasks
.
delete
.
apply_async
(
args
=
[
self
,
user
],
local_tasks
.
reboot
.
apply_async
(
args
=
[
self
,
user
],
queue
=
"localhost.man"
)
queue
=
"localhost.man"
)
def
renew
(
self
,
which
=
'both'
):
def
renew
(
self
,
which
=
'both'
):
...
@@ -735,8 +743,8 @@ class Interface(Model):
...
@@ -735,8 +743,8 @@ class Interface(Model):
args
=
[
self
.
get_vmnetwork_desc
()],
args
=
[
self
.
get_vmnetwork_desc
()],
queue
=
self
.
instance
.
node
.
host
.
hostname
+
'.net'
)
queue
=
self
.
instance
.
node
.
host
.
hostname
+
'.net'
)
def
remove
(
self
,
user
=
None
,
task_uuid
=
None
):
def
destroy
(
self
,
user
=
None
,
task_uuid
=
None
):
net_tasks
.
de
lete
.
apply_async
(
net_tasks
.
de
stroy
.
apply_async
(
args
=
[
self
.
get_vmnetwork_desc
()],
args
=
[
self
.
get_vmnetwork_desc
()],
queue
=
self
.
instance
.
node
.
host
.
hostname
+
'.net'
)
queue
=
self
.
instance
.
node
.
host
.
hostname
+
'.net'
)
...
...
circle/vm/tasks/local_tasks.py
View file @
9c7ba32e
from
manager.mancelery
import
celery
from
manager.mancelery
import
celery
# TODO: Keep syncronhised with Instance funcs
@celery.task
@celery.task
def
deploy
(
instance
,
user
):
def
deploy
(
instance
,
user
):
'''
Create new virtual machine from VM class
.
'''
Call Insance.deploy() from celery task
.
'''
'''
instance
.
deploy
(
task_uuid
=
deploy
.
request
.
id
,
user
=
user
)
instance
.
deploy
(
task_uuid
=
deploy
.
request
.
id
,
user
=
user
)
def
de
lete
():
def
de
stroy
():
pass
pass
...
...
circle/vm/tasks/net_tasks.py
View file @
9c7ba32e
...
@@ -7,5 +7,5 @@ def create(params):
...
@@ -7,5 +7,5 @@ def create(params):
@celery.task
(
name
=
'netdriver.delete'
)
@celery.task
(
name
=
'netdriver.delete'
)
def
de
lete
(
params
):
def
de
stroy
(
params
):
pass
pass
circle/vm/tasks/vm_tasks.py
View file @
9c7ba32e
...
@@ -2,52 +2,47 @@ from manager.mancelery import celery
...
@@ -2,52 +2,47 @@ from manager.mancelery import celery
@celery.task
(
name
=
'vmdriver.create'
)
@celery.task
(
name
=
'vmdriver.create'
)
def
create
(
params
):
def
deploy
(
params
):
pass
pass
@celery.task
(
name
=
'vmdriver.suspend'
)
@celery.task
(
name
=
'vmdriver.delete'
)
def
stop
(
params
):
def
destroy
(
params
):
pass
@celery.task
(
name
=
'vmdriver.resume'
)
def
resume
(
params
):
pass
pass
@celery.task
(
name
=
'vmdriver.
delet
e'
)
@celery.task
(
name
=
'vmdriver.
sav
e'
)
def
poweroff
(
params
):
def
sleep
(
params
):
pass
pass
@celery.task
(
name
=
'vmdriver.
shutdown
'
)
@celery.task
(
name
=
'vmdriver.
restore
'
)
def
shutdown
(
params
):
def
wake_up
(
params
):
pass
pass
@celery.task
(
name
=
'vmdriver.
reset
'
)
@celery.task
(
name
=
'vmdriver.
suspend
'
)
def
reset
(
params
):
def
suspend
(
params
):
pass
pass
@celery.task
(
name
=
'vmdriver.
start
'
)
@celery.task
(
name
=
'vmdriver.
resume
'
)
def
res
tart
(
params
):
def
res
ume
(
params
):
pass
pass
@celery.task
(
name
=
'vmdriver.
reboot
'
)
@celery.task
(
name
=
'vmdriver.
shutdown
'
)
def
reboot
(
params
):
def
shutdown
(
params
):
pass
pass
@celery.task
(
name
=
'vmdriver.
save
'
)
@celery.task
(
name
=
'vmdriver.
reset
'
)
def
save
(
params
):
def
reset
(
params
):
pass
pass
@celery.task
(
name
=
'vmdriver.re
store
'
)
@celery.task
(
name
=
'vmdriver.re
boot
'
)
def
re
store
(
params
):
def
re
boot
(
params
):
pass
pass
...
@@ -64,8 +59,3 @@ def domain_info(params):
...
@@ -64,8 +59,3 @@ def domain_info(params):
@celery.task
(
name
=
'vmdriver.list_domains'
)
@celery.task
(
name
=
'vmdriver.list_domains'
)
def
list_domains
(
params
):
def
list_domains
(
params
):
pass
pass
@celery.task
(
name
=
'vmdriver.delete'
)
def
delete
(
params
):
pass
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