Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
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
66b0952f
authored
Jul 08, 2014
by
Guba Sándor
Committed by
Bach Dániel
Jul 08, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storage: make save_as abortable task
parent
0bb9d185
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
7 deletions
+16
-7
circle/storage/models.py
+16
-7
No files found.
circle/storage/models.py
View file @
66b0952f
...
...
@@ -134,6 +134,7 @@ class Disk(AclBase, TimeStampedModel):
self
.
disk
=
disk
class
DiskIsNotReady
(
Exception
):
""" Exception for operations that need a deployed disk.
"""
...
...
@@ -394,7 +395,7 @@ class Disk(AclBase, TimeStampedModel):
args
=
[
self
.
datastore
.
path
,
self
.
filename
],
queue
=
queue_name
)
.
get
(
timeout
=
timeout
)
def
save_as
(
self
,
user
=
None
,
task_uuid
=
None
,
timeout
=
300
):
def
save_as
(
self
,
task
,
user
=
None
,
task_uuid
=
None
,
timeout
=
300
):
"""Save VM as template.
Based on disk type:
...
...
@@ -429,10 +430,18 @@ class Disk(AclBase, TimeStampedModel):
type
=
new_type
)
queue_name
=
self
.
get_remote_queue_name
(
"storage"
,
priority
=
"slow"
)
storage_tasks
.
merge
.
apply_async
(
args
=
[
self
.
get_disk_desc
(),
disk
.
get_disk_desc
()],
queue
=
queue_name
)
.
get
()
# Timeout
disk
.
is_ready
=
True
disk
.
save
()
remote
=
storage_tasks
.
merge
.
apply_async
(
kwargs
=
{
"old_json"
:
self
.
get_disk_desc
(),
"new_json"
:
disk
.
get_disk_desc
()},
queue
=
queue_name
)
# Timeout
while
True
:
try
:
remote
.
get
(
timeout
=
5
)
break
except
TimeoutError
:
if
task
is
not
None
and
task
.
is_aborted
():
AbortableAsyncResult
(
remote
.
id
)
.
abort
()
disk
.
destroy
()
raise
Exception
(
"Save as aborted by use."
)
return
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