Commit 4b185b09 by Kálmán Viktor

occi: delete storage

parent 4d56b18f
...@@ -402,6 +402,7 @@ class Storage(Resource): ...@@ -402,6 +402,7 @@ class Storage(Resource):
self.attrs['occi.storage.size'] /= 1024*1024*1024.0 self.attrs['occi.storage.size'] /= 1024*1024*1024.0
def trigger_action(self, data): def trigger_action(self, data):
# TODO, this is copypaste ATM
method = None method = None
action_term = None action_term = None
for d in data: for d in data:
...@@ -428,6 +429,15 @@ class Storage(Resource): ...@@ -428,6 +429,15 @@ class Storage(Resource):
user = User.objects.get(username="test") user = User.objects.get(username="test")
getattr(self.instance, operation).async(user=user) getattr(self.instance, operation).async(user=user)
def delete(self):
# TODO
user = User.objects.get(username="test")
if self.disk.instance_set.count() > 0:
for i in self.disk.instance_set.all():
i.detach_disk(user=user, disk=self.disk)
self.disk.destroy()
class StorageLink(Link): class StorageLink(Link):
def __init__(self, instance=None, disk=None, data=None): def __init__(self, instance=None, disk=None, data=None):
......
...@@ -193,6 +193,10 @@ class DiskInterface(DetailView): ...@@ -193,6 +193,10 @@ class DiskInterface(DetailView):
Storage(disk=disk).trigger_action(data) Storage(disk=disk).trigger_action(data)
return HttpResponse() return HttpResponse()
def delete(self, request, *args, **kwargs):
Storage(disk=self.get_object()).delete()
return HttpResponse("")
@method_decorator(csrf_exempt) @method_decorator(csrf_exempt)
def dispatch(self, *args, **kwargs): def dispatch(self, *args, **kwargs):
return super(DiskInterface, self).dispatch(*args, **kwargs) return super(DiskInterface, self).dispatch(*args, **kwargs)
......
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