Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gyuricska Milán
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e59f2b72
authored
Sep 20, 2013
by
Dudás Ádám
Committed by
Your Name
Sep 20, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move local celery tasks beside remote tasks in vm and storage
parent
809d0cbb
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
38 additions
and
36 deletions
+38
-36
circle/manager/mancelery.py
+3
-3
circle/storage/models.py
+3
-4
circle/storage/tasks/__init__.py
+0
-0
circle/storage/tasks/local_tasks.py
+1
-1
circle/storage/tasks/remote_tasks.py
+1
-4
circle/vm/models.py
+29
-23
circle/vm/tasks/__init__.py
+0
-0
circle/vm/tasks/local_tasks.py
+1
-1
circle/vm/tasks/remote_tasks.py
+0
-0
No files found.
circle/manager/mancelery.py
View file @
e59f2b72
...
...
@@ -6,11 +6,11 @@ HOSTNAME = "localhost"
celery
=
Celery
(
'manager'
,
backend
=
'amqp'
,
broker
=
getenv
(
"AMQP_URI"
),
include
=
[
'
manager.vm_manager'
,
'manager.storage_manager
'
])
include
=
[
'
vm.tasks.local_tasks'
,
'storage.tasks.local_tasks
'
])
celery
.
conf
.
update
(
CELERY_QUEUES
=
(
Queue
(
HOSTNAME
+
'.man'
,
Exchange
(
'manager'
,
type
=
'direct'
),
routing_key
=
"manager"
),
Queue
(
HOSTNAME
+
'.man'
,
Exchange
(
'manager'
,
type
=
'direct'
),
routing_key
=
"manager"
),
)
)
circle/storage/models.py
View file @
e59f2b72
...
...
@@ -8,8 +8,7 @@ from django.utils.translation import ugettext_lazy as _
from
model_utils.models
import
TimeStampedModel
from
sizefield.models
import
FileSizeField
from
manager
import
storage_manager
import
tasks
from
.tasks
import
local_tasks
,
remote_tasks
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -115,7 +114,7 @@ class Disk(TimeStampedModel):
return
u"
%
s (#
%
d)"
%
(
self
.
name
,
self
.
id
)
def
deploy_async
(
self
):
storage_manager
.
deploy
.
apply_async
(
self
)
local_tasks
.
deploy
.
apply_async
(
self
)
def
deploy
(
self
):
"""Reify the disk model on the associated data store.
...
...
@@ -138,7 +137,7 @@ class Disk(TimeStampedModel):
'base_name'
:
self
.
base
.
name
if
self
.
base
else
None
,
'type'
:
'snapshot'
if
self
.
type
==
'qcow2-snap'
else
'normal'
}
tasks
.
create_disk
.
apply_async
(
remote_
tasks
.
create_disk
.
apply_async
(
args
=
[
disk_desc
],
queue
=
self
.
datastore
.
hostname
+
".storage"
)
.
get
()
self
.
ready
=
True
self
.
save
()
...
...
circle/storage/tasks/__init__.py
0 → 100644
View file @
e59f2b72
circle/
manager/storage_manager
.py
→
circle/
storage/tasks/local_tasks
.py
View file @
e59f2b72
from
.mancelery
import
celery
from
manager
.mancelery
import
celery
@celery.task
...
...
circle/storage/tasks.py
→
circle/storage/tasks
/remote_tasks
.py
View file @
e59f2b72
import
celery
import
logging
logger
=
logging
.
getLogger
(
__name__
)
from
manager.mancelery
import
celery
@celery.task
(
name
=
'storagedriver.list_disks'
)
...
...
circle/vm/models.py
View file @
e59f2b72
...
...
@@ -14,9 +14,8 @@ from django.utils.translation import ugettext_lazy as _
from
model_utils.models
import
TimeStampedModel
from
netaddr
import
EUI
from
.
import
tasks
from
.
tasks
import
local_tasks
,
remote_
tasks
from
firewall.models
import
Vlan
,
Host
from
manager
import
vm_manager
from
storage.models
import
Disk
...
...
@@ -482,7 +481,8 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
def
deploy_async
(
self
,
user
=
None
):
""" Launch celery task to handle the job asynchronously.
"""
vm_manager
.
deploy
.
apply_async
(
args
=
[
self
,
user
],
queue
=
"localhost.man"
)
local_tasks
.
deploy
.
apply_async
(
args
=
[
self
,
user
],
queue
=
"localhost.man"
)
def
deploy
(
self
,
user
=
None
,
task_uuid
=
None
):
""" Deploy new virtual machine with network
...
...
@@ -507,8 +507,9 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
# Deploy VM on remote machine
act
.
update_state
(
"DEPLOYING VM"
)
tasks
.
create
.
apply_async
(
args
=
[
self
.
get_vm_desc
()],
queue
=
self
.
node
.
host
.
hostname
+
".vm"
)
.
get
()
queue_name
=
self
.
node
.
host
.
hostname
+
".vm"
remote_tasks
.
create
.
apply_async
(
args
=
[
self
.
get_vm_desc
()],
queue
=
queue_name
)
.
get
()
# Estabilish network connection (vmdriver)
act
.
update_state
(
"DEPLOYING NET"
)
...
...
@@ -517,13 +518,13 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
# Resume vm
act
.
update_state
(
"BOOTING"
)
tasks
.
resume
.
apply_async
(
args
=
[
self
.
vm_name
],
remote_
tasks
.
resume
.
apply_async
(
args
=
[
self
.
vm_name
],
queue
=
self
.
node
+
".vm"
)
.
get
()
act
.
finish
(
result
=
'SUCCESS'
)
def
stop_async
(
self
,
user
=
None
):
vm_manager
.
stop
.
apply_async
(
args
=
[
self
,
user
],
queue
=
"localhost.man"
)
local_tasks
.
stop
.
apply_async
(
args
=
[
self
,
user
],
queue
=
"localhost.man"
)
def
stop
(
self
,
user
=
None
,
task_uuid
=
None
):
act
=
InstanceActivity
(
activity_code
=
'vm.Instance.stop'
)
...
...
@@ -532,11 +533,13 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
act
.
started
=
timezone
.
now
()
act
.
task_uuid
=
task_uuid
act
.
save
()
tasks
.
stop
.
apply_async
(
args
=
[
self
.
get_vm_desc
()],
queue
=
self
.
node
.
host
.
hostname
+
".vm"
)
.
get
()
queue_name
=
self
.
node
.
host
.
hostname
+
".vm"
remote_tasks
.
stop
.
apply_async
(
args
=
[
self
.
get_vm_desc
()],
queue
=
queue_name
)
.
get
()
def
resume_async
(
self
,
user
=
None
):
vm_manager
.
resume
.
apply_async
(
args
=
[
self
,
user
],
queue
=
"localhost.man"
)
local_tasks
.
resume
.
apply_async
(
args
=
[
self
,
user
],
queue
=
"localhost.man"
)
def
resume
(
self
,
user
=
None
,
task_uuid
=
None
):
act
=
InstanceActivity
(
activity_code
=
'vm.Instance.resume'
)
...
...
@@ -545,11 +548,12 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
act
.
started
=
timezone
.
now
()
act
.
task_uuid
=
task_uuid
act
.
save
()
tasks
.
resume
.
apply_async
(
args
=
[
self
.
get_vm_desc
()],
queue
=
self
.
node
.
host
.
hostname
+
".vm"
)
.
get
()
queue_name
=
self
.
node
.
host
.
hostname
+
".vm"
remote_tasks
.
resume
.
apply_async
(
args
=
[
self
.
get_vm_desc
()],
queue
=
queue_name
)
.
get
()
def
poweroff_async
(
self
,
user
=
None
):
vm_manager
.
power_off
.
apply_async
(
args
=
[
self
,
user
],
local_tasks
.
power_off
.
apply_async
(
args
=
[
self
,
user
],
queue
=
"localhost.man"
)
def
poweroff
(
self
,
user
=
None
,
task_uuid
=
None
):
...
...
@@ -559,12 +563,12 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
act
.
started
=
timezone
.
now
()
act
.
task_uuid
=
task_uuid
act
.
save
()
tasks
.
power_off
.
apply_async
(
args
=
[
self
.
get_vm_desc
()],
queue
=
self
.
node
.
host
.
hostname
+
".vm"
)
.
get
()
queue_name
=
self
.
node
.
host
.
hostname
+
".vm"
remote_tasks
.
power_off
.
apply_async
(
args
=
[
self
.
get_vm_desc
()],
queue
=
queue_name
)
.
get
()
def
restart_async
(
self
,
user
=
None
):
vm_manager
.
restart
.
apply_async
(
args
=
[
self
,
user
],
local_tasks
.
restart
.
apply_async
(
args
=
[
self
,
user
],
queue
=
"localhost.man"
)
def
restart
(
self
,
user
=
None
,
task_uuid
=
None
):
...
...
@@ -574,12 +578,13 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
act
.
started
=
timezone
.
now
()
act
.
task_uuid
=
task_uuid
act
.
save
()
tasks
.
restart
.
apply_async
(
args
=
[
self
.
get_vm_desc
()],
queue
=
self
.
node
.
host
.
hostname
+
".vm"
)
.
get
()
queue_name
=
self
.
node
.
host
.
hostname
+
".vm"
remote_tasks
.
restart
.
apply_async
(
args
=
[
self
.
get_vm_desc
()],
queue
=
queue_name
)
.
get
()
def
save_as_async
(
self
,
user
=
None
):
vm_manager
.
save_as
.
apply_async
(
args
=
[
self
,
user
],
queue
=
"localhost.man"
)
local_tasks
.
save_as
.
apply_async
(
args
=
[
self
,
user
],
queue
=
"localhost.man"
)
def
save_as
(
self
,
user
=
None
,
task_uuid
=
None
):
act
=
InstanceActivity
(
activity_code
=
'vm.Instance.restart'
)
...
...
@@ -588,8 +593,9 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
act
.
started
=
timezone
.
now
()
act
.
task_uuid
=
task_uuid
act
.
save
()
tasks
.
save_as
.
apply_async
(
args
=
[
self
.
get_vm_desc
()],
queue
=
self
.
node
.
host
.
hostname
+
".vm"
)
.
get
()
queue_name
=
self
.
node
.
host
.
hostname
+
".vm"
remote_tasks
.
save_as
.
apply_async
(
args
=
[
self
.
get_vm_desc
()],
queue
=
queue_name
)
.
get
()
def
renew
(
self
,
which
=
'both'
):
"""Renew virtual machine instance leases.
...
...
circle/vm/tasks/__init__.py
0 → 100644
View file @
e59f2b72
circle/
manager/vm_manager
.py
→
circle/
vm/tasks/local_tasks
.py
View file @
e59f2b72
from
.mancelery
import
celery
from
manager
.mancelery
import
celery
@celery.task
...
...
circle/vm/tasks.py
→
circle/vm/tasks
/remote_tasks
.py
View file @
e59f2b72
File moved
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