Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gutyán Gábor
/
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
2c82e657
authored
Feb 26, 2014
by
Guba Sándor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storage: add new disks to instance, and docstrings
parent
ae3fd15c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
3 deletions
+39
-3
circle/storage/models.py
+39
-3
No files found.
circle/storage/models.py
View file @
2c82e657
...
@@ -274,20 +274,56 @@ class Disk(AclBase, TimeStampedModel):
...
@@ -274,20 +274,56 @@ class Disk(AclBase, TimeStampedModel):
if
instance
:
if
instance
:
instance
.
disks
.
add
(
disk
)
instance
.
disks
.
add
(
disk
)
return
disk
return
disk
@classmethod
def
create_from_url_async
(
cls
,
url
,
instance
=
None
,
params
=
None
,
user
=
None
):
"""Create disk object and download data from url asynchronusly.
:param url: image url to download.
:type url: url
:param instance: instnace object to connect disk
:type instane: vm.models.Instance
:param params: disk custom parameters
:type params: dict
:param user: owner of the disk
:type user: django.contrib.auth.User
:return: Task
:rtype: AsyncResult
"""
return
local_tasks
.
create_from_url
.
apply_async
(
kwargs
=
{
return
local_tasks
.
create_from_url
.
apply_async
(
kwargs
=
{
'cls'
:
cls
,
'url'
:
url
,
'params'
:
params
,
'user'
:
user
},
'cls'
:
cls
,
'url'
:
url
,
'instance'
:
instance
,
'params'
:
params
,
'user'
:
user
},
queue
=
'localhost.man'
)
queue
=
'localhost.man'
)
def
create_from_url
(
cls
,
url
,
params
=
{},
user
=
None
,
task_uuid
=
None
,
@classmethod
abortable_task
=
None
):
def
create_from_url
(
cls
,
url
,
instance
=
None
,
params
=
None
,
user
=
None
,
task_uuid
=
None
,
abortable_task
=
None
):
"""Create disk object and download data from url synchronusly.
:param url: image url to download.
:type url: url
:param instance: instnace object to connect disk
:type instane: vm.models.Instance
:param params: disk custom parameters
:type params: dict
:param user: owner of the disk
:type user: django.contrib.auth.User
:return: Task
:rtype: AsyncResult
"""
disk
=
cls
()
disk
=
cls
()
disk
.
filename
=
str
(
uuid
.
uuid4
())
disk
.
filename
=
str
(
uuid
.
uuid4
())
disk
.
type
=
"iso"
disk
.
type
=
"iso"
disk
.
size
=
1
disk
.
size
=
1
# TODO get proper datastore
disk
.
datastore
=
DataStore
.
objects
.
all
()[
0
]
disk
.
datastore
=
DataStore
.
objects
.
all
()[
0
]
if
params
:
if
params
:
disk
.
__dict__
.
update
(
params
)
disk
.
__dict__
.
update
(
params
)
disk
.
save
()
disk
.
save
()
if
instance
:
instance
.
disks
.
add
(
disk
)
queue_name
=
disk
.
get_remote_queue_name
(
'storage'
)
queue_name
=
disk
.
get_remote_queue_name
(
'storage'
)
def
__on_abort
(
activity
,
error
):
def
__on_abort
(
activity
,
error
):
...
...
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