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):
disk = self.get_object()
app = disk.get_appliance()
app.disks.remove(disk)
app.remove_disk(disk=disk, user=request.user)
Please register or sign in to reply
disk.destroy()
next_url = request.POST.get("next")
......
......@@ -197,6 +197,26 @@ class RebootOperation(InstanceOperation):
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):
activity_code_suffix = '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