Commit 0ede81f1 by Dudás Ádám

vm: operation for removing a disk from the VM

parent 32809cd7
...@@ -2160,7 +2160,7 @@ class DiskRemoveView(DeleteView): ...@@ -2160,7 +2160,7 @@ class DiskRemoveView(DeleteView):
disk = self.get_object() disk = self.get_object()
app = disk.get_appliance() app = disk.get_appliance()
app.disks.remove(disk) app.remove_disk(disk=disk, user=request.user)
disk.destroy() disk.destroy()
next_url = request.POST.get("next") next_url = request.POST.get("next")
......
...@@ -197,6 +197,26 @@ class RebootOperation(InstanceOperation): ...@@ -197,6 +197,26 @@ class RebootOperation(InstanceOperation):
register_instance_operation(RebootOperation) register_instance_operation(RebootOperation)
class RemoveDiskOperation(InstanceOperation):
activity_code_suffix = 'remove_disk'
id = 'remove_disk'
name = _("remove disk")
description = _("Remove the specified disk from the VM.")
def check_precond(self):
super(RemoveDiskOperation, self).check_precond()
# TODO remove check when hot-detach is implemented
if self.instance.status not in ['STOPPED']:
raise self.instance.WrongStateError(self.instance)
def _operation(self, activity, user, system, disk):
# TODO implement with hot-detach when it'll be available
return self.instance.disks.remove(disk)
register_instance_operation(RemoveDiskOperation)
class ResetOperation(InstanceOperation): class ResetOperation(InstanceOperation):
activity_code_suffix = 'reset' activity_code_suffix = 'reset'
id = 'reset' id = 'reset'
......
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