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
1311ddb3
authored
Jul 09, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature-abort-save_as-rebased' into 'master'
Feature: abort save as
parents
00227f21
4cb0af54
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
9 deletions
+18
-9
circle/storage/models.py
+16
-7
circle/vm/operations.py
+2
-2
No files found.
circle/storage/models.py
View file @
1311ddb3
...
@@ -134,6 +134,7 @@ class Disk(AclBase, TimeStampedModel):
...
@@ -134,6 +134,7 @@ class Disk(AclBase, TimeStampedModel):
self
.
disk
=
disk
self
.
disk
=
disk
class
DiskIsNotReady
(
Exception
):
class
DiskIsNotReady
(
Exception
):
""" Exception for operations that need a deployed disk.
""" Exception for operations that need a deployed disk.
"""
"""
...
@@ -394,7 +395,7 @@ class Disk(AclBase, TimeStampedModel):
...
@@ -394,7 +395,7 @@ class Disk(AclBase, TimeStampedModel):
args
=
[
self
.
datastore
.
path
,
self
.
filename
],
args
=
[
self
.
datastore
.
path
,
self
.
filename
],
queue
=
queue_name
)
.
get
(
timeout
=
timeout
)
queue
=
queue_name
)
.
get
(
timeout
=
timeout
)
def
save_as
(
self
,
user
=
None
,
task_uuid
=
None
,
timeout
=
300
):
def
save_as
(
self
,
task
=
None
,
user
=
None
,
task_uuid
=
None
,
timeout
=
300
):
"""Save VM as template.
"""Save VM as template.
Based on disk type:
Based on disk type:
...
@@ -429,10 +430,18 @@ class Disk(AclBase, TimeStampedModel):
...
@@ -429,10 +430,18 @@ class Disk(AclBase, TimeStampedModel):
type
=
new_type
)
type
=
new_type
)
queue_name
=
self
.
get_remote_queue_name
(
"storage"
,
priority
=
"slow"
)
queue_name
=
self
.
get_remote_queue_name
(
"storage"
,
priority
=
"slow"
)
storage_tasks
.
merge
.
apply_async
(
args
=
[
self
.
get_disk_desc
(),
remote
=
storage_tasks
.
merge
.
apply_async
(
kwargs
=
{
disk
.
get_disk_desc
()],
"old_json"
:
self
.
get_disk_desc
(),
queue
=
queue_name
"new_json"
:
disk
.
get_disk_desc
()},
)
.
get
()
# Timeout
queue
=
queue_name
disk
.
is_ready
=
True
)
# Timeout
disk
.
save
()
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
return
disk
circle/vm/operations.py
View file @
1311ddb3
...
@@ -403,7 +403,7 @@ class SaveAsTemplateOperation(InstanceOperation):
...
@@ -403,7 +403,7 @@ class SaveAsTemplateOperation(InstanceOperation):
return
"
%
s v
%
d"
%
(
name
,
v
)
return
"
%
s v
%
d"
%
(
name
,
v
)
def
on_abort
(
self
,
activity
,
error
):
def
on_abort
(
self
,
activity
,
error
):
if
get
attr
(
self
,
'disks'
):
if
has
attr
(
self
,
'disks'
):
for
disk
in
self
.
disks
:
for
disk
in
self
.
disks
:
disk
.
destroy
()
disk
.
destroy
()
...
@@ -445,7 +445,7 @@ class SaveAsTemplateOperation(InstanceOperation):
...
@@ -445,7 +445,7 @@ class SaveAsTemplateOperation(InstanceOperation):
def
__try_save_disk
(
disk
):
def
__try_save_disk
(
disk
):
try
:
try
:
return
disk
.
save_as
()
return
disk
.
save_as
(
task
)
except
Disk
.
WrongDiskTypeError
:
except
Disk
.
WrongDiskTypeError
:
return
disk
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