Commit 73c6938b by Guba Sándor

Merge branch 'issue-153'

parents 4fcd632b 1e35578f
...@@ -2240,7 +2240,7 @@ class DiskRemoveView(DeleteView): ...@@ -2240,7 +2240,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")
......
...@@ -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):
......
...@@ -80,6 +80,26 @@ class AddInterfaceOperation(InstanceOperation): ...@@ -80,6 +80,26 @@ class AddInterfaceOperation(InstanceOperation):
register_operation(AddInterfaceOperation) register_operation(AddInterfaceOperation)
class AddDiskOperation(InstanceOperation):
activity_code_suffix = 'add_disk'
id = 'add_disk'
name = _("add disk")
description = _("Add the specified disk to the VM.")
def check_precond(self):
super(AddDiskOperation, self).check_precond()
# TODO remove check when hot-attach 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-attach when it'll be available
return self.instance.disks.add(disk)
register_operation(AddDiskOperation)
class DeployOperation(InstanceOperation): class DeployOperation(InstanceOperation):
activity_code_suffix = 'deploy' activity_code_suffix = 'deploy'
id = 'deploy' id = 'deploy'
...@@ -217,6 +237,26 @@ class RemoveInterfaceOperation(InstanceOperation): ...@@ -217,6 +237,26 @@ class RemoveInterfaceOperation(InstanceOperation):
register_operation(RemoveInterfaceOperation) register_operation(RemoveInterfaceOperation)
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_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