Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
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
aea984d1
authored
Apr 16, 2014
by
Guba Sándor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
operations: SaveAsTemplateOperation refactor
Saving disks synchronously.
parent
956c4a08
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
circle/vm/operations.py
+7
-4
No files found.
circle/vm/operations.py
View file @
aea984d1
...
...
@@ -8,7 +8,6 @@ from django.utils.translation import ugettext_lazy as _
from
celery.exceptions
import
TimeLimitExceeded
from
common.operations
import
Operation
,
register_operation
from
storage.models
import
Disk
from
.tasks.local_tasks
import
async_instance_operation
,
async_node_operation
from
.models
import
(
Instance
,
InstanceActivity
,
InstanceTemplate
,
Node
,
NodeActivity
,
...
...
@@ -224,20 +223,24 @@ class SaveAsTemplateOperation(InstanceOperation):
}
params
.
update
(
kwargs
)
from
storage.models
import
Disk
def
__try_save_disk
(
disk
):
try
:
return
disk
.
save_as
()
except
Disk
.
WrongDiskTypeError
:
return
disk
with
activity
.
sub_activity
(
'saving_disks'
):
disks
=
[
__try_save_disk
(
disk
)
for
disk
in
self
.
instance
.
disks
.
all
()]
# create template and do additional setup
tmpl
=
InstanceTemplate
(
**
params
)
tmpl
.
full_clean
()
# Avoiding database errors.
tmpl
.
save
()
try
:
with
activity
.
sub_activity
(
'saving_disks'
):
tmpl
.
disks
.
add
(
*
[
__try_save_disk
(
disk
)
for
disk
in
self
.
instance
.
disks
.
all
()])
tmpl
.
disks
.
add
(
*
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