Commit 1e35578f by Dudás Ádám

dashboard, vm: implement remove_disk on InstanceTemplate and use it instead of…

dashboard, vm: implement remove_disk on InstanceTemplate and use it instead of dispatching on appliance type
parent 07190c6d
...@@ -2160,10 +2160,7 @@ class DiskRemoveView(DeleteView): ...@@ -2160,10 +2160,7 @@ class DiskRemoveView(DeleteView):
disk = self.get_object() disk = self.get_object()
app = disk.get_appliance() app = disk.get_appliance()
if isinstance(app, Instance): app.remove_disk(disk=disk, user=request.user)
app.remove_disk(disk=disk, user=request.user)
else: # isinstance(app, InstanceTemplate)
app.disks.remove(disk)
disk.destroy() disk.destroy()
next_url = request.POST.get("next") next_url = request.POST.get("next")
......
...@@ -165,6 +165,9 @@ class InstanceTemplate(AclBase, VirtualMachineDescModel, TimeStampedModel): ...@@ -165,6 +165,9 @@ class InstanceTemplate(AclBase, VirtualMachineDescModel, TimeStampedModel):
def get_absolute_url(self): def get_absolute_url(self):
return ('dashboard.views.template-detail', None, {'pk': self.pk}) return ('dashboard.views.template-detail', None, {'pk': self.pk})
def remove_disk(self, disk, **kwargs):
self.disks.remove(disk)
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