Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
abd0f554
authored
Dec 23, 2020
by
Máhonfai Bálint
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add percentage progress and abort to export disk operation
parent
35fec9da
Pipeline
#1388
passed with stage
in 0 seconds
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
10 deletions
+19
-10
circle/dashboard/forms.py
+2
-2
circle/storage/models.py
+11
-4
circle/storage/tasks/storage_tasks.py
+2
-2
circle/vm/operations.py
+4
-2
No files found.
circle/dashboard/forms.py
View file @
abd0f554
...
@@ -824,7 +824,7 @@ class VmCreateDiskForm(OperationForm):
...
@@ -824,7 +824,7 @@ class VmCreateDiskForm(OperationForm):
class
VmDiskExportForm
(
OperationForm
):
class
VmDiskExportForm
(
OperationForm
):
format
=
forms
.
ChoiceField
(
disk_
format
=
forms
.
ChoiceField
(
choices
=
Disk
.
EXPORT_FORMATS
,
choices
=
Disk
.
EXPORT_FORMATS
,
label
=
_
(
'Format'
))
label
=
_
(
'Format'
))
...
@@ -850,7 +850,7 @@ class VmDiskExportForm(OperationForm):
...
@@ -850,7 +850,7 @@ class VmDiskExportForm(OperationForm):
HTML
(
_
(
"<label>Disk:</label>
%
s"
)
%
escape
(
self
.
disk
)),
HTML
(
_
(
"<label>Disk:</label>
%
s"
)
%
escape
(
self
.
disk
)),
css_class
=
"form-group"
,
css_class
=
"form-group"
,
),
),
Field
(
'disk'
),
Field
(
'format'
)
Field
(
'disk'
),
Field
(
'
disk_
format'
)
)
)
return
helper
return
helper
...
...
circle/storage/models.py
View file @
abd0f554
...
@@ -497,13 +497,20 @@ class Disk(TimeStampedModel):
...
@@ -497,13 +497,20 @@ class Disk(TimeStampedModel):
disk
.
save
()
disk
.
save
()
return
disk
return
disk
def
export
(
self
,
format
,
upload_link
,
timeout
=
3600
):
def
export
(
self
,
disk_format
,
upload_link
,
task
):
exported_name
=
self
.
name
if
self
.
name
!=
''
else
self
.
filename
exported_name
=
self
.
name
if
self
.
name
!=
''
else
self
.
filename
queue_name
=
self
.
get_remote_queue_name
(
'storage'
,
priority
=
'slow'
)
queue_name
=
self
.
get_remote_queue_name
(
'storage'
,
priority
=
'slow'
)
storage_tasks
.
export
.
apply_async
(
remote
=
storage_tasks
.
export_disk
.
apply_async
(
args
=
[
self
.
get_disk_desc
(),
format
,
exported_name
,
upload_link
],
kwargs
=
{
queue
=
queue_name
)
.
get
(
timeout
=
timeout
)
"disk_desc"
:
self
.
get_disk_desc
(),
"disk_format"
:
disk_format
,
"exported_name"
:
exported_name
,
"upload_link"
:
upload_link
,
"task"
:
task
.
request
.
id
},
queue
=
queue_name
)
self
.
_run_abortable_task
(
remote
,
task
)
def
destroy
(
self
,
user
=
None
,
task_uuid
=
None
):
def
destroy
(
self
,
user
=
None
,
task_uuid
=
None
):
if
self
.
destroyed
:
if
self
.
destroyed
:
...
...
circle/storage/tasks/storage_tasks.py
View file @
abd0f554
...
@@ -43,8 +43,8 @@ def import_disk(disk_desc, url):
...
@@ -43,8 +43,8 @@ def import_disk(disk_desc, url):
pass
pass
@celery.task
(
name
=
'storagedriver.export'
)
@celery.task
(
name
=
'storagedriver.export
_disk
'
)
def
export
(
disk_desc
,
format
):
def
export
_disk
(
disk_desc
,
format
):
pass
pass
...
...
circle/vm/operations.py
View file @
abd0f554
...
@@ -376,6 +376,8 @@ class ExportDiskOperation(InstanceOperation):
...
@@ -376,6 +376,8 @@ class ExportDiskOperation(InstanceOperation):
id
=
'export_disk'
id
=
'export_disk'
name
=
_
(
'export disk'
)
name
=
_
(
'export disk'
)
description
=
_
(
'Export disk to the selected format.'
)
description
=
_
(
'Export disk to the selected format.'
)
abortable
=
True
has_percentage
=
True
required_perms
=
(
'storage.export_disk'
,)
required_perms
=
(
'storage.export_disk'
,)
accept_states
=
(
'STOPPED'
,)
accept_states
=
(
'STOPPED'
,)
async_queue
=
'localhost.man.slow'
async_queue
=
'localhost.man.slow'
...
@@ -387,10 +389,10 @@ class ExportDiskOperation(InstanceOperation):
...
@@ -387,10 +389,10 @@ class ExportDiskOperation(InstanceOperation):
except
NoStoreException
:
except
NoStoreException
:
raise
PermissionDenied
raise
PermissionDenied
def
_operation
(
self
,
user
,
disk
,
format
):
def
_operation
(
self
,
user
,
disk
,
disk_format
,
task
):
store
=
Store
(
user
)
store
=
Store
(
user
)
upload_link
=
store
.
request_upload
(
'/'
)
upload_link
=
store
.
request_upload
(
'/'
)
disk
.
export
(
format
,
upload_lin
k
)
disk
.
export
(
disk_format
,
upload_link
,
tas
k
)
@register_operation
@register_operation
...
...
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