Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
circlestack
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
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
Show 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
celery
import
Celery
from
kombu
import
Queue
,
Exchange
from
kombu
import
Queue
,
Exchange
from
socket
import
gethostname
from
os
import
getenv
HOSTNAME
=
"localhost"
HOSTNAME
=
gethostname
()
celery
=
Celery
(
'manager'
,
backend
=
'amqp'
,
celery
=
Celery
(
'manager'
,
backend
=
'amqp'
,
broker
=
'amqp://cloud:test@10.9.1.31/vmdriver'
,
broker
=
getenv
(
"AMQP_URI"
)
,
include
=
[
'
vmdriver_stub
'
])
include
=
[
'
manager.vm_manager'
,
'manager.storage_manager
'
])
celery
.
conf
.
update
(
celery
.
conf
.
update
(
CELERY_QUEUES
=
(
CELERY_QUEUES
=
(
...
...
circle/manager/storage.py
→
circle/manager/storage
_manager
.py
View file @
2e78f147
...
@@ -8,9 +8,11 @@ def deploy(disk, user):
...
@@ -8,9 +8,11 @@ def deploy(disk, user):
disk
.
deploy
(
task_uuid
=
deploy
.
rdiskd
,
user
=
user
)
disk
.
deploy
(
task_uuid
=
deploy
.
rdiskd
,
user
=
user
)
@celery.task
def
delete
():
def
delete
():
pass
pass
@celery.task
def
save_as
():
def
save_as
():
pass
pass
circle/manager/vm.py
→
circle/manager/vm
_manager
.py
View file @
2e78f147
from
mancelery
import
celery
from
.
mancelery
import
celery
@celery.task
@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
...
@@ -13,7 +13,7 @@ from netaddr import EUI
from
.
import
tasks
from
.
import
tasks
from
firewall.models
import
Vlan
,
Host
from
firewall.models
import
Vlan
,
Host
from
manager
import
vm
,
scheduler
from
manager
import
vm
_manager
,
scheduler
from
storage.models
import
Disk
from
storage.models
import
Disk
...
@@ -35,7 +35,7 @@ class BaseResourceConfigModel(models.Model):
...
@@ -35,7 +35,7 @@ class BaseResourceConfigModel(models.Model):
arch
=
models
.
CharField
(
max_length
=
10
,
verbose_name
=
_
(
'architecture'
))
arch
=
models
.
CharField
(
max_length
=
10
,
verbose_name
=
_
(
'architecture'
))
priority
=
models
.
IntegerField
(
help_text
=
_
(
'instance priority'
))
priority
=
models
.
IntegerField
(
help_text
=
_
(
'instance priority'
))
boot_menu
=
models
.
BooleanField
(
default
=
False
)
boot_menu
=
models
.
BooleanField
(
default
=
False
)
raw_data
=
models
.
TextField
(
blank
=
True
,
null
=
True
)
raw_data
=
models
.
TextField
(
blank
=
True
)
class
Meta
:
class
Meta
:
abstract
=
True
abstract
=
True
...
@@ -242,7 +242,7 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
...
@@ -242,7 +242,7 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
verbose_name
=
_
(
'active since'
))
verbose_name
=
_
(
'active since'
))
node
=
models
.
ForeignKey
(
Node
,
blank
=
True
,
null
=
True
,
node
=
models
.
ForeignKey
(
Node
,
blank
=
True
,
null
=
True
,
related_name
=
'instance_set'
,
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
)
state
=
models
.
CharField
(
choices
=
STATES
,
default
=
'NOSTATE'
,
max_length
=
20
)
disks
=
models
.
ManyToManyField
(
Disk
,
related_name
=
'instance_set'
,
disks
=
models
.
ManyToManyField
(
Disk
,
related_name
=
'instance_set'
,
verbose_name
=
_
(
'disks'
))
verbose_name
=
_
(
'disks'
))
...
@@ -416,15 +416,15 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
...
@@ -416,15 +416,15 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
'type'
:
'vnc'
,
'type'
:
'vnc'
,
'listen'
:
'0.0.0.0'
,
'listen'
:
'0.0.0.0'
,
'passwd'
:
''
,
'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
):
def
deploy_async
(
self
,
user
=
None
):
""" Launch celery task to handle the job asynchronously.
""" 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
):
def
deploy
(
self
,
user
=
None
,
task_uuid
=
None
):
""" Deploy new virtual machine with network
""" Deploy new virtual machine with network
...
@@ -437,7 +437,7 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
...
@@ -437,7 +437,7 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
# Schedule
# Schedule
act
.
update_state
(
"PENDING"
)
act
.
update_state
(
"PENDING"
)
self
.
node
=
scheduler
.
get_node
()
self
.
node
=
scheduler
.
get_node
(
self
)
self
.
save
()
self
.
save
()
# Create virtual images
# Create virtual images
...
@@ -447,8 +447,8 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
...
@@ -447,8 +447,8 @@ 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
(
self
.
get_vm_desc
,
tasks
.
create
.
apply_async
(
args
=
[
self
.
get_vm_desc
()]
,
queue
=
self
.
node
+
".vm"
)
.
get
()
queue
=
self
.
node
.
host
.
hostname
+
".vm"
)
.
get
()
# Estabilish network connection (vmdriver)
# Estabilish network connection (vmdriver)
act
.
update_state
(
"DEPLOYING NET"
)
act
.
update_state
(
"DEPLOYING NET"
)
...
@@ -457,7 +457,8 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
...
@@ -457,7 +457,8 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
# Resume vm
# Resume vm
act
.
update_state
(
"BOOTING"
)
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'
)
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