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
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 _
...
@@ -8,7 +8,6 @@ from django.utils.translation import ugettext_lazy as _
from
celery.exceptions
import
TimeLimitExceeded
from
celery.exceptions
import
TimeLimitExceeded
from
common.operations
import
Operation
,
register_operation
from
common.operations
import
Operation
,
register_operation
from
storage.models
import
Disk
from
.tasks.local_tasks
import
async_instance_operation
,
async_node_operation
from
.tasks.local_tasks
import
async_instance_operation
,
async_node_operation
from
.models
import
(
from
.models
import
(
Instance
,
InstanceActivity
,
InstanceTemplate
,
Node
,
NodeActivity
,
Instance
,
InstanceActivity
,
InstanceTemplate
,
Node
,
NodeActivity
,
...
@@ -224,20 +223,24 @@ class SaveAsTemplateOperation(InstanceOperation):
...
@@ -224,20 +223,24 @@ class SaveAsTemplateOperation(InstanceOperation):
}
}
params
.
update
(
kwargs
)
params
.
update
(
kwargs
)
from
storage.models
import
Disk
def
__try_save_disk
(
disk
):
def
__try_save_disk
(
disk
):
try
:
try
:
return
disk
.
save_as
()
return
disk
.
save_as
()
except
Disk
.
WrongDiskTypeError
:
except
Disk
.
WrongDiskTypeError
:
return
disk
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
# create template and do additional setup
tmpl
=
InstanceTemplate
(
**
params
)
tmpl
=
InstanceTemplate
(
**
params
)
tmpl
.
full_clean
()
# Avoiding database errors.
tmpl
.
full_clean
()
# Avoiding database errors.
tmpl
.
save
()
tmpl
.
save
()
try
:
try
:
with
activity
.
sub_activity
(
'saving_disks'
):
tmpl
.
disks
.
add
(
*
disks
)
tmpl
.
disks
.
add
(
*
[
__try_save_disk
(
disk
)
for
disk
in
self
.
instance
.
disks
.
all
()])
# create interface templates
# create interface templates
for
i
in
self
.
instance
.
interface_set
.
all
():
for
i
in
self
.
instance
.
interface_set
.
all
():
i
.
save_as_template
(
tmpl
)
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