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
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
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):
def
create_empty
(
cls
,
instance
=
None
,
user
=
None
,
**
kwargs
):
"""Create empty Disk object.
:param instance: Instance attach the Disk to.
:type instan
e: vm.models.Instanc
e or NoneType
:param instance: Instance
or template
attach the Disk to.
:type instan
ce: vm.models.Instance or InstanceTemplat
e or NoneType
:param user: Creator of the disk.
:type user: django.contrib.auth.User
...
...
@@ -299,37 +299,33 @@ class Disk(AclBase, TimeStampedModel):
return
disk
@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.
:param url: URL of image to download.
:type url: string
:param instance: instance object to connect disk
:type instane: vm.models.Instance
:param params: disk custom parameters
:type params: dict
:param instance: Instance or template attach the Disk to.
:type instance: vm.models.Instance or InstanceTemplate or NoneType
: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
=
{
'cls'
:
cls
,
'url'
:
url
,
'instance'
:
instance
,
'params'
:
params
,
'user'
:
user
}
,
queue
=
'localhost.man'
)
kwargs
.
update
({
'cls'
:
cls
,
'url'
:
url
,
'instance'
:
instance
,
'user'
:
user
})
return
local_tasks
.
create_from_url
.
apply_async
(
kwargs
=
kwargs
,
queue
=
'localhost.man'
)
@classmethod
def
create_from_url
(
cls
,
url
,
instance
=
None
,
params
=
None
,
user
=
None
,
task_uuid
=
None
,
abortable_task
=
None
):
def
create_from_url
(
cls
,
url
,
instance
=
None
,
user
=
None
,
task_uuid
=
None
,
abortable_task
=
None
,
**
kwargs
):
"""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 instance: Instance or template attach the Disk to.
:type instance: vm.models.Instance or InstanceTemplate or NoneType
:param user: owner of the disk
:type user: django.contrib.auth.User
:param task_uuid: TODO
...
...
@@ -338,14 +334,13 @@ class Disk(AclBase, TimeStampedModel):
:return: The created Disk object
:rtype: Disk
"""
disk
=
cls
()
kwargs
.
setdefault
(
'name'
,
url
.
split
(
'/'
)[
-
1
])
disk
=
cls
(
**
kwargs
)
disk
.
generate_filename
()
disk
.
type
=
"iso"
disk
.
size
=
1
# TODO get proper datastore
disk
.
datastore
=
DataStore
.
objects
.
get
()
if
params
:
disk
.
__dict__
.
update
(
params
)
disk
.
save
()
if
instance
:
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