Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
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
0988e858
authored
Sep 11, 2013
by
Guba Sándor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding async functions
parent
f79946dd
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
4 deletions
+64
-4
circle/manager/storage.py
+16
-0
circle/manager/vm.py
+36
-0
circle/storage/models.py
+10
-2
circle/vm/models.py
+2
-2
No files found.
circle/manager/storage.py
0 → 100644
View file @
0988e858
from
.mancelery
import
celery
@celery.task
def
deploy
(
disk
,
user
):
'''Create new virtual machine from VM class.
'''
disk
.
deploy
(
task_uuid
=
deploy
.
rdiskd
,
user
=
user
)
def
delete
():
pass
def
save_as
():
pass
circle/manager/vm.py
0 → 100644
View file @
0988e858
from
mancelery
import
celery
@celery.task
def
deploy
(
instance
,
user
):
'''Create new virtual machine from VM class.
'''
instance
.
deploy
(
task_uuid
=
deploy
.
request
.
id
,
user
=
user
)
def
delete
():
pass
def
save_as
():
pass
def
suspend
():
pass
def
resume
():
pass
def
restart
():
pass
def
reset
():
pass
def
migrate
():
pass
circle/storage/models.py
View file @
0988e858
...
...
@@ -6,12 +6,15 @@ from django.utils.translation import ugettext_lazy as _
from
django.db.models.signals
import
post_delete
from
model_utils.models
import
TimeStampedModel
from
.tasks
import
StorageDriver
from
manager
import
storage
from
.
import
tasks
logger
=
logging
.
getLogger
(
__name__
)
class
DataStore
(
models
.
Model
):
"""Collection of virtual disks.
"""
name
=
models
.
CharField
(
max_length
=
100
,
unique
=
True
,
...
...
@@ -20,6 +23,7 @@ class DataStore(models.Model):
verbose_name
=
_
(
'path'
))
hostname
=
models
.
CharField
(
max_length
=
40
,
unique
=
True
,
verbose_name
=
_
(
'hostname'
))
class
Meta
:
ordering
=
[
'name'
]
verbose_name
=
_
(
'datastore'
)
...
...
@@ -30,6 +34,7 @@ class DataStore(models.Model):
class
Disk
(
TimeStampedModel
):
"""A virtual disk.
"""
TYPES
=
[(
'qcow2-norm'
,
'qcow2 normal'
),
(
'qcow2-snap'
,
'qcow2 snapshot'
),
...
...
@@ -93,6 +98,9 @@ class Disk(TimeStampedModel):
def
__unicode__
(
self
):
return
u"
%
s (#
%
d)"
%
(
self
.
name
,
self
.
id
)
def
deploy_async
(
self
):
storage
.
deploy
.
apply_async
(
self
)
def
deploy
(
self
):
if
self
.
ready
:
return
...
...
@@ -105,7 +113,7 @@ class Disk(TimeStampedModel):
'base_name'
:
self
.
base
.
name
if
self
.
base
else
None
,
'type'
:
self
.
type
}
StorageDriver
.
create_disk
.
delay
(
disk_desc
)
.
get
()
tasks
.
create_disk
.
delay
(
disk_desc
)
.
get
()
self
.
ready
=
True
self
.
save
()
...
...
circle/vm/models.py
View file @
0988e858
...
...
@@ -13,7 +13,7 @@ from netaddr import EUI
from
.
import
tasks
from
firewall.models
import
Vlan
,
Host
from
manager
import
manager
,
scheduler
from
manager
import
vm
,
scheduler
from
storage.models
import
Disk
...
...
@@ -424,7 +424,7 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
def
deploy_async
(
self
,
user
=
None
):
""" Launch celery task to handle the job asynchronously.
"""
manager
.
deploy
.
apply_async
(
self
,
user
)
vm
.
deploy
.
apply_async
(
self
,
user
)
def
deploy
(
self
,
user
=
None
,
task_uuid
=
None
):
""" Deploy new virtual machine with network
...
...
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