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
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
41 additions
and
39 deletions
+41
-39
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
+32
-26
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"
...
@@ -6,11 +6,11 @@ HOSTNAME = "localhost"
celery
=
Celery
(
'manager'
,
backend
=
'amqp'
,
celery
=
Celery
(
'manager'
,
backend
=
'amqp'
,
broker
=
getenv
(
"AMQP_URI"
),
broker
=
getenv
(
"AMQP_URI"
),
include
=
[
'
manager.vm_manager'
,
'manager.storage_manager
'
])
include
=
[
'
vm.tasks.local_tasks'
,
'storage.tasks.local_tasks
'
])
celery
.
conf
.
update
(
celery
.
conf
.
update
(
CELERY_QUEUES
=
(
CELERY_QUEUES
=
(
Queue
(
HOSTNAME
+
'.man'
,
Exchange
(
Queue
(
HOSTNAME
+
'.man'
,
Exchange
(
'manager'
,
type
=
'direct'
),
'manager'
,
type
=
'direct'
),
routing_key
=
"manager"
),
routing_key
=
"manager"
),
)
)
)
)
circle/storage/models.py
View file @
e59f2b72
...
@@ -8,8 +8,7 @@ from django.utils.translation import ugettext_lazy as _
...
@@ -8,8 +8,7 @@ from django.utils.translation import ugettext_lazy as _
from
model_utils.models
import
TimeStampedModel
from
model_utils.models
import
TimeStampedModel
from
sizefield.models
import
FileSizeField
from
sizefield.models
import
FileSizeField
from
manager
import
storage_manager
from
.tasks
import
local_tasks
,
remote_tasks
import
tasks
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
@@ -115,7 +114,7 @@ class Disk(TimeStampedModel):
...
@@ -115,7 +114,7 @@ class Disk(TimeStampedModel):
return
u"
%
s (#
%
d)"
%
(
self
.
name
,
self
.
id
)
return
u"
%
s (#
%
d)"
%
(
self
.
name
,
self
.
id
)
def
deploy_async
(
self
):
def
deploy_async
(
self
):
storage_manager
.
deploy
.
apply_async
(
self
)
local_tasks
.
deploy
.
apply_async
(
self
)
def
deploy
(
self
):
def
deploy
(
self
):
"""Reify the disk model on the associated data store.
"""Reify the disk model on the associated data store.
...
@@ -138,7 +137,7 @@ class Disk(TimeStampedModel):
...
@@ -138,7 +137,7 @@ class Disk(TimeStampedModel):
'base_name'
:
self
.
base
.
name
if
self
.
base
else
None
,
'base_name'
:
self
.
base
.
name
if
self
.
base
else
None
,
'type'
:
'snapshot'
if
self
.
type
==
'qcow2-snap'
else
'normal'
'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
()
args
=
[
disk_desc
],
queue
=
self
.
datastore
.
hostname
+
".storage"
)
.
get
()
self
.
ready
=
True
self
.
ready
=
True
self
.
save
()
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
@celery.task
...
...
circle/storage/tasks.py
→
circle/storage/tasks
/remote_tasks
.py
View file @
e59f2b72
import
celery
from
manager.mancelery
import
celery
import
logging
logger
=
logging
.
getLogger
(
__name__
)
@celery.task
(
name
=
'storagedriver.list_disks'
)
@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 _
...
@@ -14,9 +14,8 @@ from django.utils.translation import ugettext_lazy as _
from
model_utils.models
import
TimeStampedModel
from
model_utils.models
import
TimeStampedModel
from
netaddr
import
EUI
from
netaddr
import
EUI
from
.
import
tasks
from
.
tasks
import
local_tasks
,
remote_
tasks
from
firewall.models
import
Vlan
,
Host
from
firewall.models
import
Vlan
,
Host
from
manager
import
vm_manager
from
storage.models
import
Disk
from
storage.models
import
Disk
...
@@ -482,7 +481,8 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
...
@@ -482,7 +481,8 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
def
deploy_async
(
self
,
user
=
None
):
def
deploy_async
(
self
,
user
=
None
):
""" Launch celery task to handle the job asynchronously.
""" 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
):
def
deploy
(
self
,
user
=
None
,
task_uuid
=
None
):
""" Deploy new virtual machine with network
""" Deploy new virtual machine with network
...
@@ -507,8 +507,9 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
...
@@ -507,8 +507,9 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
# Deploy VM on remote machine
# Deploy VM on remote machine
act
.
update_state
(
"DEPLOYING VM"
)
act
.
update_state
(
"DEPLOYING VM"
)
tasks
.
create
.
apply_async
(
args
=
[
self
.
get_vm_desc
()],
queue_name
=
self
.
node
.
host
.
hostname
+
".vm"
queue
=
self
.
node
.
host
.
hostname
+
".vm"
)
.
get
()
remote_tasks
.
create
.
apply_async
(
args
=
[
self
.
get_vm_desc
()],
queue
=
queue_name
)
.
get
()
# Estabilish network connection (vmdriver)
# Estabilish network connection (vmdriver)
act
.
update_state
(
"DEPLOYING NET"
)
act
.
update_state
(
"DEPLOYING NET"
)
...
@@ -517,13 +518,13 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
...
@@ -517,13 +518,13 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
# Resume vm
# Resume vm
act
.
update_state
(
"BOOTING"
)
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
()
queue
=
self
.
node
+
".vm"
)
.
get
()
act
.
finish
(
result
=
'SUCCESS'
)
act
.
finish
(
result
=
'SUCCESS'
)
def
stop_async
(
self
,
user
=
None
):
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
):
def
stop
(
self
,
user
=
None
,
task_uuid
=
None
):
act
=
InstanceActivity
(
activity_code
=
'vm.Instance.stop'
)
act
=
InstanceActivity
(
activity_code
=
'vm.Instance.stop'
)
...
@@ -532,11 +533,13 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
...
@@ -532,11 +533,13 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
act
.
started
=
timezone
.
now
()
act
.
started
=
timezone
.
now
()
act
.
task_uuid
=
task_uuid
act
.
task_uuid
=
task_uuid
act
.
save
()
act
.
save
()
tasks
.
stop
.
apply_async
(
args
=
[
self
.
get_vm_desc
()],
queue_name
=
self
.
node
.
host
.
hostname
+
".vm"
queue
=
self
.
node
.
host
.
hostname
+
".vm"
)
.
get
()
remote_tasks
.
stop
.
apply_async
(
args
=
[
self
.
get_vm_desc
()],
queue
=
queue_name
)
.
get
()
def
resume_async
(
self
,
user
=
None
):
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
):
def
resume
(
self
,
user
=
None
,
task_uuid
=
None
):
act
=
InstanceActivity
(
activity_code
=
'vm.Instance.resume'
)
act
=
InstanceActivity
(
activity_code
=
'vm.Instance.resume'
)
...
@@ -545,12 +548,13 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
...
@@ -545,12 +548,13 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
act
.
started
=
timezone
.
now
()
act
.
started
=
timezone
.
now
()
act
.
task_uuid
=
task_uuid
act
.
task_uuid
=
task_uuid
act
.
save
()
act
.
save
()
tasks
.
resume
.
apply_async
(
args
=
[
self
.
get_vm_desc
()],
queue_name
=
self
.
node
.
host
.
hostname
+
".vm"
queue
=
self
.
node
.
host
.
hostname
+
".vm"
)
.
get
()
remote_tasks
.
resume
.
apply_async
(
args
=
[
self
.
get_vm_desc
()],
queue
=
queue_name
)
.
get
()
def
poweroff_async
(
self
,
user
=
None
):
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"
)
queue
=
"localhost.man"
)
def
poweroff
(
self
,
user
=
None
,
task_uuid
=
None
):
def
poweroff
(
self
,
user
=
None
,
task_uuid
=
None
):
act
=
InstanceActivity
(
activity_code
=
'vm.Instance.power_off'
)
act
=
InstanceActivity
(
activity_code
=
'vm.Instance.power_off'
)
...
@@ -559,13 +563,13 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
...
@@ -559,13 +563,13 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
act
.
started
=
timezone
.
now
()
act
.
started
=
timezone
.
now
()
act
.
task_uuid
=
task_uuid
act
.
task_uuid
=
task_uuid
act
.
save
()
act
.
save
()
tasks
.
power_off
.
apply_async
(
args
=
[
self
.
get_vm_desc
()],
queue_name
=
self
.
node
.
host
.
hostname
+
".vm"
queue
=
self
.
node
.
host
.
hostname
+
".vm"
remote_tasks
.
power_off
.
apply_async
(
args
=
[
self
.
get_vm_desc
()],
)
.
get
()
queue
=
queue_name
)
.
get
()
def
restart_async
(
self
,
user
=
None
):
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"
)
queue
=
"localhost.man"
)
def
restart
(
self
,
user
=
None
,
task_uuid
=
None
):
def
restart
(
self
,
user
=
None
,
task_uuid
=
None
):
act
=
InstanceActivity
(
activity_code
=
'vm.Instance.restart'
)
act
=
InstanceActivity
(
activity_code
=
'vm.Instance.restart'
)
...
@@ -574,12 +578,13 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
...
@@ -574,12 +578,13 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
act
.
started
=
timezone
.
now
()
act
.
started
=
timezone
.
now
()
act
.
task_uuid
=
task_uuid
act
.
task_uuid
=
task_uuid
act
.
save
()
act
.
save
()
tasks
.
restart
.
apply_async
(
args
=
[
self
.
get_vm_desc
()],
queue_name
=
self
.
node
.
host
.
hostname
+
".vm"
queue
=
self
.
node
.
host
.
hostname
+
".vm"
)
.
get
()
remote_tasks
.
restart
.
apply_async
(
args
=
[
self
.
get_vm_desc
()],
queue
=
queue_name
)
.
get
()
def
save_as_async
(
self
,
user
=
None
):
def
save_as_async
(
self
,
user
=
None
):
vm_manager
.
save_as
.
apply_async
(
local_tasks
.
save_as
.
apply_async
(
args
=
[
self
,
user
],
args
=
[
self
,
user
],
queue
=
"localhost.man"
)
queue
=
"localhost.man"
)
def
save_as
(
self
,
user
=
None
,
task_uuid
=
None
):
def
save_as
(
self
,
user
=
None
,
task_uuid
=
None
):
act
=
InstanceActivity
(
activity_code
=
'vm.Instance.restart'
)
act
=
InstanceActivity
(
activity_code
=
'vm.Instance.restart'
)
...
@@ -588,8 +593,9 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
...
@@ -588,8 +593,9 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
act
.
started
=
timezone
.
now
()
act
.
started
=
timezone
.
now
()
act
.
task_uuid
=
task_uuid
act
.
task_uuid
=
task_uuid
act
.
save
()
act
.
save
()
tasks
.
save_as
.
apply_async
(
args
=
[
self
.
get_vm_desc
()],
queue_name
=
self
.
node
.
host
.
hostname
+
".vm"
queue
=
self
.
node
.
host
.
hostname
+
".vm"
)
.
get
()
remote_tasks
.
save_as
.
apply_async
(
args
=
[
self
.
get_vm_desc
()],
queue
=
queue_name
)
.
get
()
def
renew
(
self
,
which
=
'both'
):
def
renew
(
self
,
which
=
'both'
):
"""Renew virtual machine instance leases.
"""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
@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