X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FNBI.git;a=blobdiff_plain;f=osm_nbi%2Fnbi.py;h=d78379f77103b8b70629183333300361acf35944;hp=46fd8cce40c8df20f3409a0dccaa1c16cb9a24bc;hb=HEAD;hpb=536bb568cd1c79d16d36cd13bdd20d167337d30d diff --git a/osm_nbi/nbi.py b/osm_nbi/nbi.py index 46fd8cc..8f87135 100644 --- a/osm_nbi/nbi.py +++ b/osm_nbi/nbi.py @@ -92,7 +92,7 @@ URL: /osm GET POST heal O5 /ns_lcm_op_occs 5 5 / 5 5 5 - TO BE COMPLETED 5 5 + cancel 05 /vnf_instances (also vnfrs for compatibility) O / O /subscriptions 5 5 @@ -475,6 +475,10 @@ valid_url_methods = { "": { "METHODS": ("GET",), "ROLE_PERMISSION": "ns_instances:opps:id:", + "cancel": { + "METHODS": ("POST",), + "ROLE_PERMISSION": "ns_instances:opps:cancel:", + }, }, }, "vnfrs": { @@ -1091,9 +1095,13 @@ class Server(object): # for logging self._format_login(token_info) token_id = token_info["_id"] - token_details = self.engine.db.get_one("tokens", {"_id": token_id}) - current_user = token_details.get("username") - current_project = token_details.get("project_name") + if current_backend != "keystone": + token_details = self.engine.db.get_one("tokens", {"_id": token_id}) + current_user = token_details.get("username") + current_project = token_details.get("project_name") + else: + current_user = "keystone backend" + current_project = "keystone backend" outdata = self.authenticator.del_token(token_id) token_info = None cherrypy.session["Authorization"] = "logout" # pylint: disable=E1101 @@ -1670,6 +1678,13 @@ class Server(object): ) outdata = {"id": _id} cherrypy.response.status = HTTPStatus.ACCEPTED.value + elif topic == "ns_lcm_op_occs" and item == "cancel": + indata["nsLcmOpOccId"] = _id + self.engine.cancel_item( + rollback, engine_session, "nslcmops", indata, None + ) + self._set_location_header(main_topic, version, topic, _id) + cherrypy.response.status = HTTPStatus.ACCEPTED.value else: _id, op_id = self.engine.new_item( rollback, @@ -1928,6 +1943,7 @@ def _start_service(): global nbi_server global subscription_thread global cef_logger + global current_backend cherrypy.log.error("Starting osm_nbi") # update general cherrypy configuration update_dict = {} @@ -2042,6 +2058,7 @@ def _start_service(): # Do not capture except SubscriptionException backend = engine_config["authentication"]["backend"] + current_backend = backend cherrypy.log.error( "Starting OSM NBI Version '{} {}' with '{}' authentication backend".format( nbi_version, nbi_version_date, backend