FORCE option when deleting a NS instance 47/6247/4
authorlombardof <flombardo@cnit.it>
Sun, 3 Jun 2018 14:13:38 +0000 (16:13 +0200)
committerlombardof <flombardo@cnit.it>
Tue, 12 Jun 2018 15:38:18 +0000 (17:38 +0200)
Change-Id: Ic696f687ab7d22af4707428190d78d75c0f43264
Signed-off-by: lombardof <flombardo@cnit.it>
instancehandler/template/instance_list_ns.html
instancehandler/views.py
lib/osm/osmclient/client.py
static/src/instancehandler/instance_list.js

index d6a8dbe..0e32765 100644 (file)
                                 <li>
                                     <a href="{% url 'projects:instances:ns_operations' project_id=project_id type=type instance_id=i|get:'_id' %}">
                                         <i class="fa fa-list"></i>Active operations</a></li>
+                                <li class="divider"></li>
+                                <li>
+                                    <a href="javascript:deleteNs('{% url 'projects:instances:delete' instance_id=i|get:'_id' project_id=project_id type=type %}', true)">
+                                        <i class="fa fa-trash" style="color:red" ></i>Force delete</a></li>
                             </ul>
 
 
index ea5528d..c9808d6 100644 (file)
@@ -104,9 +104,10 @@ def action(request, project_id=None, instance_id=None, type=None):
 
 @login_required
 def delete(request, project_id=None, instance_id=None, type=None):
+    force = bool(request.GET.get('force', False))
     result = {}
     client = Client()
-    result = client.ns_delete(instance_id)
+    result = client.ns_delete(instance_id, force)
     print result
     return __response_handler(request, result, 'projects:instances:list', to_redirect=True, type='ns', project_id=project_id)
 
index a65808f..d91d297 100644 (file)
@@ -252,13 +252,16 @@ class Client(object):
             return self._send_get(_url, headers=self._headers)
         return None
 
-    def ns_delete(self, id):
+    def ns_delete(self, id, force=None):
         token = self.get_token()
         if token:
             self._headers['Authorization'] = 'Bearer {}'.format(token)
-            #self._headers['Content-Type'] = 'application/yaml'
             self._headers['accept'] = 'application/json'
-            _url = "{0}/nslcm/v1/ns_instances_content/{1}".format(self._base_path, id)
+            query_path = ''
+            if force:
+                query_path = '?FORCE=true'
+            _url = "{0}/nslcm/v1/ns_instances_content/{1}{2}".format(self._base_path, id, query_path)
+
             return self._send_delete(_url, headers=self._headers)
         return None
 
index af66f16..47d4957 100644 (file)
@@ -19,9 +19,11 @@ function performAction(url) {
     $('#modal_instance_new_action').modal('show');
 }
 
-function deleteNs(url) {
+function deleteNs(url, force) {
     bootbox.confirm("Are you sure want to delete?", function (result) {
         if (result) {
+            if(force)
+                url = url + '?force=true';
             location.href = url
         }
     })