Commit 24872266 by Guba Sándor

instance: fixed save_as rollback on failure

parent 586d86e0
...@@ -1155,12 +1155,10 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, ...@@ -1155,12 +1155,10 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel,
tmpl = InstanceTemplate(**params) tmpl = InstanceTemplate(**params)
tmpl.full_clean() # Avoiding database errors. tmpl.full_clean() # Avoiding database errors.
tmpl.save() tmpl.save()
try:
with act.sub_activity('saving_disks'): with act.sub_activity('saving_disks'):
tmpl.disks.add(*[__try_save_disk(disk) tmpl.disks.add(*[__try_save_disk(disk)
for disk in self.disks.all()]) for disk in self.disks.all()])
# save template
tmpl.save()
try:
# create interface templates # create interface templates
for i in self.interface_set.all(): for i in self.interface_set.all():
i.save_as_template(tmpl) i.save_as_template(tmpl)
......
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