From: lombardof Date: Sun, 3 Jun 2018 14:13:38 +0000 (+0200) Subject: FORCE option when deleting a NS instance X-Git-Tag: BUILD_v4.0.1_1~26 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=7e33ad65244c7babe04cefcaf2a1dc2bc72e278f;p=osm%2FLW-UI.git FORCE option when deleting a NS instance Change-Id: Ic696f687ab7d22af4707428190d78d75c0f43264 Signed-off-by: lombardof --- diff --git a/instancehandler/template/instance_list_ns.html b/instancehandler/template/instance_list_ns.html index d6a8dbe..0e32765 100644 --- a/instancehandler/template/instance_list_ns.html +++ b/instancehandler/template/instance_list_ns.html @@ -79,6 +79,10 @@
  • Active operations
  • +
  • +
  • + + Force delete
  • diff --git a/instancehandler/views.py b/instancehandler/views.py index ea5528d..c9808d6 100644 --- a/instancehandler/views.py +++ b/instancehandler/views.py @@ -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) diff --git a/lib/osm/osmclient/client.py b/lib/osm/osmclient/client.py index a65808f..d91d297 100644 --- a/lib/osm/osmclient/client.py +++ b/lib/osm/osmclient/client.py @@ -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 diff --git a/static/src/instancehandler/instance_list.js b/static/src/instancehandler/instance_list.js index af66f16..47d4957 100644 --- a/static/src/instancehandler/instance_list.js +++ b/static/src/instancehandler/instance_list.js @@ -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 } })