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
65c96698
authored
9 years ago
by
Czémán Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: data store selector for download disk operation
parent
3b446530
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
4 deletions
+28
-4
circle/dashboard/forms.py
+12
-0
circle/dashboard/views/vm.py
+5
-0
circle/storage/models.py
+2
-1
circle/vm/operations.py
+9
-3
No files found.
circle/dashboard/forms.py
View file @
65c96698
...
...
@@ -910,6 +910,18 @@ class VmDownloadDiskForm(OperationForm):
name
=
forms
.
CharField
(
max_length
=
100
,
label
=
_
(
"Name"
),
required
=
False
)
url
=
forms
.
CharField
(
label
=
_
(
'URL'
),
validators
=
[
URLValidator
(),
])
def
__init__
(
self
,
*
args
,
**
kwargs
):
datastore_choices
=
kwargs
.
pop
(
'datastore_choices'
)
super
(
VmDownloadDiskForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
datastore_field
=
forms
.
ModelChoiceField
(
queryset
=
datastore_choices
,
required
=
False
,
initial
=
None
,
label
=
_
(
'Data store'
))
if
not
datastore_choices
:
datastore_field
.
widget
.
attrs
[
'disabled'
]
=
'disabled'
datastore_field
.
empty_label
=
_
(
'No more data stores.'
)
self
.
fields
[
'datastore'
]
=
datastore_field
def
clean
(
self
):
cleaned_data
=
super
(
VmDownloadDiskForm
,
self
)
.
clean
()
if
not
cleaned_data
[
'name'
]:
...
...
This diff is collapsed.
Click to expand it.
circle/dashboard/views/vm.py
View file @
65c96698
...
...
@@ -430,6 +430,11 @@ class VmDownloadDiskView(FormOperationMixin, VmOperationView):
is_disk_operation
=
True
with_reload
=
True
def
get_form_kwargs
(
self
):
val
=
super
(
VmDownloadDiskView
,
self
)
.
get_form_kwargs
()
val
[
'datastore_choices'
]
=
DataStore
.
get_all
()
return
val
class
VmMigrateView
(
FormOperationMixin
,
VmOperationView
):
...
...
This diff is collapsed.
Click to expand it.
circle/storage/models.py
View file @
65c96698
...
...
@@ -542,7 +542,7 @@ class Disk(TimeStampedModel):
return
disk
@classmethod
def
download
(
cls
,
url
,
task
,
user
=
None
,
**
params
):
def
download
(
cls
,
url
,
datastore
,
task
,
user
=
None
,
**
params
):
"""Create disk object and download data from url synchronusly.
:param url: image url to download.
...
...
@@ -560,6 +560,7 @@ class Disk(TimeStampedModel):
params
.
setdefault
(
'name'
,
url
.
split
(
'/'
)[
-
1
])
params
.
setdefault
(
'type'
,
'iso'
)
params
.
setdefault
(
'size'
,
None
)
params
.
setdefault
(
'datastore'
,
datastore
)
disk
=
cls
.
__create
(
params
=
params
,
user
=
user
)
queue_name
=
disk
.
get_remote_queue_name
(
'storage'
,
priority
=
'slow'
)
remote
=
storage_tasks
.
download
.
apply_async
(
...
...
This diff is collapsed.
Click to expand it.
circle/vm/operations.py
View file @
65c96698
...
...
@@ -333,10 +333,16 @@ class DownloadDiskOperation(InstanceOperation):
accept_states
=
(
'STOPPED'
,
'PENDING'
,
'RUNNING'
)
async_queue
=
"localhost.man.slow"
def
_operation
(
self
,
user
,
url
,
task
,
activity
,
name
=
None
):
from
storage.models
import
Disk
def
_operation
(
self
,
user
,
url
,
datastore
,
task
,
activity
,
name
=
None
):
from
storage.models
import
Disk
,
DataStore
if
not
datastore
:
datastore
=
self
.
instance
.
get_most_used_datastore
()
if
not
datastore
:
datastore
=
DataStore
.
get_default_datastore
()
disk
=
Disk
.
download
(
url
=
url
,
name
=
name
,
task
=
task
)
disk
=
Disk
.
download
(
url
=
url
,
name
=
name
,
task
=
task
,
datastore
=
datastore
)
devnums
=
list
(
ascii_lowercase
)
for
d
in
self
.
instance
.
disks
.
all
():
devnums
.
remove
(
d
.
dev_num
)
...
...
This diff is collapsed.
Click to expand it.
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