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
4f1d9ed1
authored
Jun 17, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: destroy disks if save_as operation fails
parent
64405e13
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
3 deletions
+12
-3
circle/vm/operations.py
+12
-3
No files found.
circle/vm/operations.py
View file @
4f1d9ed1
...
...
@@ -343,6 +343,11 @@ class SaveAsTemplateOperation(InstanceOperation):
v
=
1
return
"
%
s v
%
d"
%
(
name
,
v
)
def
on_abort
(
self
,
activity
,
error
):
if
getattr
(
self
,
'disks'
):
for
disk
in
self
.
disks
:
disk
.
destroy
()
def
_operation
(
self
,
activity
,
user
,
system
,
timeout
=
300
,
name
=
None
,
with_shutdown
=
True
,
task
=
None
,
**
kwargs
):
if
with_shutdown
:
...
...
@@ -380,16 +385,20 @@ class SaveAsTemplateOperation(InstanceOperation):
except
Disk
.
WrongDiskTypeError
:
return
disk
self
.
disks
=
[]
with
activity
.
sub_activity
(
'saving_disks'
):
disks
=
[
__try_save_disk
(
disk
)
for
disk
in
self
.
instance
.
disks
.
all
()]
for
disk
in
self
.
instance
.
disks
.
all
():
self
.
disks
.
append
(
__try_save_disk
(
disk
))
for
disk
in
self
.
disks
:
disk
.
set_level
(
user
,
'owner'
)
# create template and do additional setup
tmpl
=
InstanceTemplate
(
**
params
)
tmpl
.
full_clean
()
# Avoiding database errors.
tmpl
.
save
()
try
:
tmpl
.
disks
.
add
(
*
disks
)
tmpl
.
disks
.
add
(
*
self
.
disks
)
# create interface templates
for
i
in
self
.
instance
.
interface_set
.
all
():
i
.
save_as_template
(
tmpl
)
...
...
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