Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9daef8ff
authored
Feb 14, 2014
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: discard incomplete template on error
fixes #67
parent
6ab9e981
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
9 deletions
+17
-9
circle/vm/models/instance.py
+17
-9
No files found.
circle/vm/models/instance.py
View file @
9daef8ff
...
@@ -935,22 +935,30 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
...
@@ -935,22 +935,30 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
kwargs
.
setdefault
(
'access_method'
,
self
.
access_method
)
kwargs
.
setdefault
(
'access_method'
,
self
.
access_method
)
kwargs
.
setdefault
(
'system'
,
self
.
template
.
system
kwargs
.
setdefault
(
'system'
,
self
.
template
.
system
if
self
.
template
else
None
)
if
self
.
template
else
None
)
def
__try_save_disk
(
disk
):
try
:
return
disk
.
save_as
()
except
Disk
.
WrongDiskTypeError
:
return
disk
# copy disks
disks
=
[
__try_save_disk
(
disk
)
for
disk
in
self
.
disks
.
all
()]
kwargs
.
setdefault
(
'disks'
,
disks
)
# create template and do additional setup
# create template and do additional setup
tmpl
=
InstanceTemplate
(
**
kwargs
)
tmpl
=
InstanceTemplate
(
**
kwargs
)
# save template
# save template
tmpl
.
save
()
tmpl
.
save
()
# create related entities
for
disk
in
self
.
disks
.
all
():
try
:
try
:
d
=
disk
.
save_as
()
# create interface templates
except
Disk
.
WrongDiskTypeError
:
d
=
disk
tmpl
.
disks
.
add
(
d
)
for
i
in
self
.
interface_set
.
all
():
for
i
in
self
.
interface_set
.
all
():
i
.
save_as_template
(
tmpl
)
i
.
save_as_template
(
tmpl
)
except
:
tmpl
.
delete
()
raise
else
:
return
tmpl
return
tmpl
def
shutdown_and_save_as_template
(
self
,
name
,
user
=
None
,
task_uuid
=
None
,
def
shutdown_and_save_as_template
(
self
,
name
,
user
=
None
,
task_uuid
=
None
,
...
...
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