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
0dce6c0d
authored
Feb 28, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storage: clean up Disk.create_from_url
parent
c0770d4a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
20 deletions
+15
-20
circle/storage/models.py
+15
-20
No files found.
circle/storage/models.py
View file @
0dce6c0d
...
@@ -280,8 +280,8 @@ class Disk(AclBase, TimeStampedModel):
...
@@ -280,8 +280,8 @@ class Disk(AclBase, TimeStampedModel):
def
create_empty
(
cls
,
instance
=
None
,
user
=
None
,
**
kwargs
):
def
create_empty
(
cls
,
instance
=
None
,
user
=
None
,
**
kwargs
):
"""Create empty Disk object.
"""Create empty Disk object.
:param instance: Instance attach the Disk to.
:param instance: Instance
or template
attach the Disk to.
:type instan
e: vm.models.Instanc
e or NoneType
:type instan
ce: vm.models.Instance or InstanceTemplat
e or NoneType
:param user: Creator of the disk.
:param user: Creator of the disk.
:type user: django.contrib.auth.User
:type user: django.contrib.auth.User
...
@@ -299,37 +299,33 @@ class Disk(AclBase, TimeStampedModel):
...
@@ -299,37 +299,33 @@ class Disk(AclBase, TimeStampedModel):
return
disk
return
disk
@classmethod
@classmethod
def
create_from_url_async
(
cls
,
url
,
instance
=
None
,
params
=
None
,
user
=
None
):
def
create_from_url_async
(
cls
,
url
,
instance
=
None
,
user
=
None
,
**
kwargs
):
"""Create disk object and download data from url asynchrnously.
"""Create disk object and download data from url asynchrnously.
:param url: URL of image to download.
:param url: URL of image to download.
:type url: string
:type url: string
:param instance: instance object to connect disk
:param instance: Instance or template attach the Disk to.
:type instane: vm.models.Instance
:type instance: vm.models.Instance or InstanceTemplate or NoneType
:param params: disk custom parameters
:type params: dict
:param user: owner of the disk
:param user: owner of the disk
:type user: django.contrib.auth.User
:type user: django.contrib.auth.User
:return: Task
:return: Task
:rtype: AsyncResult
:rtype: AsyncResult
"""
"""
return
local_tasks
.
create_from_url
.
apply_async
(
kwargs
=
{
kwargs
.
update
({
'cls'
:
cls
,
'url'
:
url
,
'cls'
:
cls
,
'url'
:
url
,
'instance'
:
instance
,
'instance'
:
instance
,
'user'
:
user
})
'params'
:
params
,
'user'
:
user
}
,
return
local_tasks
.
create_from_url
.
apply_async
(
kwargs
=
kwargs
,
queue
=
'localhost.man'
)
queue
=
'localhost.man'
)
@classmethod
@classmethod
def
create_from_url
(
cls
,
url
,
instance
=
None
,
params
=
None
,
user
=
None
,
def
create_from_url
(
cls
,
url
,
instance
=
None
,
user
=
None
,
task_uuid
=
None
,
abortable_task
=
None
):
task_uuid
=
None
,
abortable_task
=
None
,
**
kwargs
):
"""Create disk object and download data from url synchronusly.
"""Create disk object and download data from url synchronusly.
:param url: image url to download.
:param url: image url to download.
:type url: url
:type url: url
:param instance: instnace object to connect disk
:param instance: Instance or template attach the Disk to.
:type instane: vm.models.Instance
:type instance: vm.models.Instance or InstanceTemplate or NoneType
:param params: disk custom parameters
:type params: dict
:param user: owner of the disk
:param user: owner of the disk
:type user: django.contrib.auth.User
:type user: django.contrib.auth.User
:param task_uuid: TODO
:param task_uuid: TODO
...
@@ -338,14 +334,13 @@ class Disk(AclBase, TimeStampedModel):
...
@@ -338,14 +334,13 @@ class Disk(AclBase, TimeStampedModel):
:return: The created Disk object
:return: The created Disk object
:rtype: Disk
:rtype: Disk
"""
"""
disk
=
cls
()
kwargs
.
setdefault
(
'name'
,
url
.
split
(
'/'
)[
-
1
])
disk
=
cls
(
**
kwargs
)
disk
.
generate_filename
()
disk
.
generate_filename
()
disk
.
type
=
"iso"
disk
.
type
=
"iso"
disk
.
size
=
1
disk
.
size
=
1
# TODO get proper datastore
# TODO get proper datastore
disk
.
datastore
=
DataStore
.
objects
.
get
()
disk
.
datastore
=
DataStore
.
objects
.
get
()
if
params
:
disk
.
__dict__
.
update
(
params
)
disk
.
save
()
disk
.
save
()
if
instance
:
if
instance
:
instance
.
disks
.
add
(
disk
)
instance
.
disks
.
add
(
disk
)
...
...
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