Commit cceea9b2 by Bach Dániel

vm: destroy disks on template delete

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