Commit aea984d1 by Guba Sándor

operations: SaveAsTemplateOperation refactor

Saving disks synchronously.
parent 956c4a08
......@@ -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):
from storage.models import Disk
def __try_save_disk(disk):
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.
with activity.sub_activity('saving_disks'):
for disk in self.instance.disks.all()])
# create interface templates
for i in self.instance.interface_set.all():
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment