mirror of
https://github.com/retspen/webvirtcloud
synced 2024-12-25 15:45:23 +00:00
clone instance: create db record first, then run clone process. delete db record if exception while cloning
This commit is contained in:
parent
9d07c2d7b6
commit
b5f38afbca
1 changed files with 9 additions and 4 deletions
|
@ -741,11 +741,16 @@ def instance(request, compute_id, vname):
|
||||||
msg = _("Instance mac '%s' invalid format!" % clone_data['clone-net-mac-0'])
|
msg = _("Instance mac '%s' invalid format!" % clone_data['clone-net-mac-0'])
|
||||||
error_messages.append(msg)
|
error_messages.append(msg)
|
||||||
else:
|
else:
|
||||||
new_uuid = conn.clone_instance(clone_data)
|
new_instance = Instance(compute_id=compute_id, name=clone_data['name'])
|
||||||
new_instance = Instance(compute_id=compute_id, name=clone_data['name'], uuid=new_uuid)
|
|
||||||
new_instance.save()
|
new_instance.save()
|
||||||
userinstance = UserInstance(instance_id=new_instance.id, user_id=request.user.id,
|
try:
|
||||||
is_delete=True)
|
new_uuid = conn.clone_instance(clone_data)
|
||||||
|
new_instance.uuid = new_uuid
|
||||||
|
new_instance.save()
|
||||||
|
except Exception as e:
|
||||||
|
new_instance.delete()
|
||||||
|
raise e
|
||||||
|
userinstance = UserInstance(instance_id=new_instance.id, user_id=request.user.id, is_delete=True)
|
||||||
userinstance.save()
|
userinstance.save()
|
||||||
|
|
||||||
msg = _("Clone of '%s'" % instance.name)
|
msg = _("Clone of '%s'" % instance.name)
|
||||||
|
|
Loading…
Reference in a new issue