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
2e78f147
authored
Sep 13, 2013
by
Guba Sándor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor manager
parent
d6b8a8a9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
16 deletions
+18
-16
circle/manager/mancelery.py
+4
-5
circle/manager/storage_manager.py
+2
-0
circle/manager/vm_manager.py
+1
-1
circle/vm/migrations/0003_auto__chg_field_instance_raw_data__chg_field_instancetemplate_raw_data.py
+0
-0
circle/vm/models.py
+11
-10
No files found.
circle/manager/mancelery.py
View file @
2e78f147
from
celery
import
Celery
from
kombu
import
Queue
,
Exchange
from
socket
import
gethostname
from
os
import
getenv
HOSTNAME
=
gethostname
()
HOSTNAME
=
"localhost"
celery
=
Celery
(
'manager'
,
backend
=
'amqp'
,
broker
=
'amqp://cloud:test@10.9.1.31/vmdriver'
,
include
=
[
'
vmdriver_stub
'
])
broker
=
getenv
(
"AMQP_URI"
)
,
include
=
[
'
manager.vm_manager'
,
'manager.storage_manager
'
])
celery
.
conf
.
update
(
CELERY_QUEUES
=
(
...
...
circle/manager/storage.py
→
circle/manager/storage
_manager
.py
View file @
2e78f147
...
...
@@ -8,9 +8,11 @@ def deploy(disk, user):
disk
.
deploy
(
task_uuid
=
deploy
.
rdiskd
,
user
=
user
)
@celery.task
def
delete
():
pass
@celery.task
def
save_as
():
pass
circle/manager/vm.py
→
circle/manager/vm
_manager
.py
View file @
2e78f147
from
mancelery
import
celery
from
.
mancelery
import
celery
@celery.task
...
...
circle/vm/migrations/0003_auto__chg_field_instance_raw_data__chg_field_instancetemplate_raw_data.py
0 → 100644
View file @
2e78f147
This diff is collapsed.
Click to expand it.
circle/vm/models.py
View file @
2e78f147
...
...
@@ -13,7 +13,7 @@ from netaddr import EUI
from
.
import
tasks
from
firewall.models
import
Vlan
,
Host
from
manager
import
vm
,
scheduler
from
manager
import
vm
_manager
,
scheduler
from
storage.models
import
Disk
...
...
@@ -35,7 +35,7 @@ class BaseResourceConfigModel(models.Model):
arch
=
models
.
CharField
(
max_length
=
10
,
verbose_name
=
_
(
'architecture'
))
priority
=
models
.
IntegerField
(
help_text
=
_
(
'instance priority'
))
boot_menu
=
models
.
BooleanField
(
default
=
False
)
raw_data
=
models
.
TextField
(
blank
=
True
,
null
=
True
)
raw_data
=
models
.
TextField
(
blank
=
True
)
class
Meta
:
abstract
=
True
...
...
@@ -242,7 +242,7 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
verbose_name
=
_
(
'active since'
))
node
=
models
.
ForeignKey
(
Node
,
blank
=
True
,
null
=
True
,
related_name
=
'instance_set'
,
verbose_name
=
_
(
'host no
s
e'
))
verbose_name
=
_
(
'host no
d
e'
))
state
=
models
.
CharField
(
choices
=
STATES
,
default
=
'NOSTATE'
,
max_length
=
20
)
disks
=
models
.
ManyToManyField
(
Disk
,
related_name
=
'instance_set'
,
verbose_name
=
_
(
'disks'
))
...
...
@@ -416,15 +416,15 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
'type'
:
'vnc'
,
'listen'
:
'0.0.0.0'
,
'passwd'
:
''
,
'port'
:
self
.
get_vnc_port
()
'port'
:
self
.
vnc_port
},
'raw_data'
:
self
.
raw_data
'raw_data'
:
""
if
not
self
.
raw_data
else
self
.
raw_data
}
def
deploy_async
(
self
,
user
=
None
):
""" Launch celery task to handle the job asynchronously.
"""
vm
.
deploy
.
apply_async
(
self
,
user
)
vm
_manager
.
deploy
.
apply_async
(
self
,
user
,
queue
=
"localhost.man"
)
def
deploy
(
self
,
user
=
None
,
task_uuid
=
None
):
""" Deploy new virtual machine with network
...
...
@@ -437,7 +437,7 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
# Schedule
act
.
update_state
(
"PENDING"
)
self
.
node
=
scheduler
.
get_node
()
self
.
node
=
scheduler
.
get_node
(
self
)
self
.
save
()
# Create virtual images
...
...
@@ -447,8 +447,8 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
# Deploy VM on remote machine
act
.
update_state
(
"DEPLOYING VM"
)
tasks
.
create
.
apply_async
(
self
.
get_vm_desc
,
queue
=
self
.
node
+
".vm"
)
.
get
()
tasks
.
create
.
apply_async
(
args
=
[
self
.
get_vm_desc
()]
,
queue
=
self
.
node
.
host
.
hostname
+
".vm"
)
.
get
()
# Estabilish network connection (vmdriver)
act
.
update_state
(
"DEPLOYING NET"
)
...
...
@@ -457,7 +457,8 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
# Resume vm
act
.
update_state
(
"BOOTING"
)
tasks
.
resume
.
apply_async
(
self
.
vm_name
,
queue
=
self
.
node
+
".vm"
)
.
get
()
tasks
.
resume
.
apply_async
(
args
=
[
self
.
vm_name
],
queue
=
self
.
node
+
".vm"
)
.
get
()
act
.
finish
(
result
=
'SUCCESS'
)
...
...
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