Commit cceea9b2 by Bach Dániel

vm: destroy disks on template delete

parent 3886665c
...@@ -1142,6 +1142,7 @@ class TemplateDelete(LoginRequiredMixin, DeleteView): ...@@ -1142,6 +1142,7 @@ class TemplateDelete(LoginRequiredMixin, DeleteView):
if not object.has_level(request.user, 'owner'): if not object.has_level(request.user, 'owner'):
raise PermissionDenied() raise PermissionDenied()
object.destroy_disks()
object.delete() object.delete()
success_url = self.get_success_url() success_url = self.get_success_url()
success_message = _("Template successfully deleted.") success_message = _("Template successfully deleted.")
...@@ -1262,6 +1263,8 @@ class NodeList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView): ...@@ -1262,6 +1263,8 @@ class NodeList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
content_type="application/json", content_type="application/json",
) )
else: else:
for node in Node.objects.all():
print node.byte_ram_usage
return super(NodeList, self).get(*args, **kwargs) return super(NodeList, self).get(*args, **kwargs)
def get_queryset(self): def get_queryset(self):
......
...@@ -190,6 +190,12 @@ class InstanceTemplate(AclBase, VirtualMachineDescModel, TimeStampedModel): ...@@ -190,6 +190,12 @@ class InstanceTemplate(AclBase, VirtualMachineDescModel, TimeStampedModel):
def remove_disk(self, disk, **kwargs): def remove_disk(self, disk, **kwargs):
self.disks.remove(disk) self.disks.remove(disk)
def destroy_disks(self):
"""Destroy all associated disks.
"""
for disk in self.disks.all():
disk.destroy()
class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin, class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
TimeStampedModel): TimeStampedModel):
......
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