1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2025-01-12 16:35:17 +00:00

not superuser delete instance causes delete for all corresponding user_instances (not only current user)

This commit is contained in:
Jan Krcmar 2016-03-23 13:47:04 +01:00
parent 8148620025
commit bc0552e12e

View file

@ -229,7 +229,7 @@ def instance(request, compute_id, vname):
usr_inst.instance.compute.type) usr_inst.instance.compute.type)
wvm_instance = conn.get_user_instances(usr_inst.instance.name) wvm_instance = conn.get_user_instances(usr_inst.instance.name)
cpu += int(wvm_instance['vcpu']) cpu += int(wvm_instance['vcpu'])
memory += int(wvm_instance['memory'])/1024 memory += int(wvm_instance['memory'])
ua = request.user.userattributes ua = request.user.userattributes
if ua.max_instances > 0 and instance > ua.max_instances: if ua.max_instances > 0 and instance > ua.max_instances:
@ -325,10 +325,6 @@ def instance(request, compute_id, vname):
instance_name = instance.name instance_name = instance.name
instance.delete() instance.delete()
if not request.user.is_superuser:
del_userinstance = UserInstance.objects.get(id=userinstace.id)
del_userinstance.delete()
else:
try: try:
del_userinstance = UserInstance.objects.filter(instance__compute_id=compute_id, instance__name=vname) del_userinstance = UserInstance.objects.filter(instance__compute_id=compute_id, instance__name=vname)
del_userinstance.delete() del_userinstance.delete()
@ -585,7 +581,7 @@ def instance(request, compute_id, vname):
new_uuid = conn.clone_instance(clone_data) new_uuid = conn.clone_instance(clone_data)
new_instance = Instance(compute_id=compute_id, name=clone_data['name'], uuid=new_uuid) 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) 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)