From: tierno Date: Thu, 18 Jun 2020 10:52:37 +0000 (+0000) Subject: fixing in vnf/ns-package artifacts X-Git-Tag: release-v8.0-start~4 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F11%2F9111%2F3;p=osm%2FNBI.git fixing in vnf/ns-package artifacts Change-Id: I4c59c88fa380211f07e91016fbdefbbf807117fa Signed-off-by: tierno --- diff --git a/osm_nbi/auth.py b/osm_nbi/auth.py index 9098de7..ec6a406 100644 --- a/osm_nbi/auth.py +++ b/osm_nbi/auth.py @@ -147,7 +147,7 @@ class Authenticator: self.role_permissions.append(permission) elif k in ("TODO", "METHODS"): continue - else: + elif method_dict[k]: load_role_permissions(method_dict[k]) load_role_permissions(self.valid_methods) diff --git a/osm_nbi/html_out.py b/osm_nbi/html_out.py index 5fd12ce..82362ec 100644 --- a/osm_nbi/html_out.py +++ b/osm_nbi/html_out.py @@ -129,6 +129,9 @@ html_nsilcmop_body = """ """ +html_vnfpackage_body = """Artifacts """ +html_nspackage_body = """Artifacts """ + def format(data, request, response, toke_info): """ @@ -168,16 +171,21 @@ def format(data, request, response, toke_info): if "Location" in response.headers: body += ' show '.format(response.headers["Location"]) else: + _id = request.path_info[request.path_info.rfind("/")+1:] body += ' '\ .format(request.path_info) if request.path_info.startswith("/nslcm/v1/ns_instances_content/") or \ request.path_info.startswith("/nslcm/v1/ns_instances/"): - _id = request.path_info[request.path_info.rfind("/")+1:] body += html_nslcmop_body.format(id=_id) elif request.path_info.startswith("/nsilcm/v1/netslice_instances_content/") or \ request.path_info.startswith("/nsilcm/v1/netslice_instances/"): - _id = request.path_info[request.path_info.rfind("/")+1:] body += html_nsilcmop_body.format(id=_id) + elif request.path_info.startswith("/vnfpkgm/v1/vnf_packages/") or \ + request.path_info.startswith("/vnfpkgm/v1/vnf_packages_content/"): + body += html_vnfpackage_body.format(id=_id) + elif request.path_info.startswith("/nsd/v1/ns_descriptors/") or \ + request.path_info.startswith("/nsd/v1/ns_descriptors_content/"): + body += html_nspackage_body.format(id=_id) body += "
" + html_escape(yaml.safe_dump(data, explicit_start=True, indent=4, default_flow_style=False)) + \
                 "
" elif data is None: diff --git a/osm_nbi/nbi.py b/osm_nbi/nbi.py index 5f822f7..6c63ad8 100644 --- a/osm_nbi/nbi.py +++ b/osm_nbi/nbi.py @@ -307,9 +307,9 @@ valid_url_methods = { "nsd": {"METHODS": ("GET",), # descriptor inside package "ROLE_PERMISSION": "nsds:id:content:" }, - "artifacts": {"*": {"METHODS": ("GET",), - "ROLE_PERMISSION": "nsds:id:nsd_artifact:" - } + "artifacts": {"METHODS": ("GET",), + "ROLE_PERMISSION": "nsds:id:nsd_artifact:", + "*": None, } } }, @@ -344,9 +344,9 @@ valid_url_methods = { "vnfd": {"METHODS": ("GET", ), # descriptor inside package "ROLE_PERMISSION": "vnfds:id:content:" }, - "artifacts": {"*": {"METHODS": ("GET", ), - "ROLE_PERMISSION": "vnfds:id:vnfd_artifact:" - } + "artifacts": {"METHODS": ("GET", ), + "ROLE_PERMISSION": "vnfds:id:vnfd_artifact:", + "*": None, }, "action": {"METHODS": ("POST", ), "ROLE_PERMISSION": "vnfds:id:action:" @@ -434,9 +434,9 @@ valid_url_methods = { "nst": {"METHODS": ("GET",), # descriptor inside package "ROLE_PERMISSION": "slice_templates:id:content:" }, - "artifacts": {"*": {"METHODS": ("GET",), - "ROLE_PERMISSION": "slice_templates:id:content:" - } + "artifacts": {"METHODS": ("GET",), + "ROLE_PERMISSION": "slice_templates:id:content:", + "*": None } } }, @@ -867,7 +867,9 @@ class Server(object): elif "" in reference: reference = reference[""] elif "*" in reference: - reference = reference["*"] + # if there is content + if reference["*"]: + reference = reference["*"] break else: raise NbiException("Unexpected URL item {}".format(arg), HTTPStatus.METHOD_NOT_ALLOWED)