fixing in vnf/ns-package artifacts 11/9111/3
authortierno <alfonso.tiernosepulveda@telefonica.com>
Thu, 18 Jun 2020 10:52:37 +0000 (10:52 +0000)
committertierno <alfonso.tiernosepulveda@telefonica.com>
Mon, 22 Jun 2020 13:55:17 +0000 (13:55 +0000)
Change-Id: I4c59c88fa380211f07e91016fbdefbbf807117fa
Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
osm_nbi/auth.py
osm_nbi/html_out.py
osm_nbi/nbi.py

index 9098de7..ec6a406 100644 (file)
@@ -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)
index 5fd12ce..82362ec 100644 (file)
@@ -129,6 +129,9 @@ html_nsilcmop_body = """
 </form>
 """
 
+html_vnfpackage_body = """<a href="/osm/vnfpkgm/v1/vnf_packages/{id}/artifacts">Artifacts </a>"""
+html_nspackage_body = """<a href="/osm/nsd/v1/ns_descriptors/{id}/artifacts">Artifacts </a>"""
+
 
 def format(data, request, response, toke_info):
     """
@@ -168,16 +171,21 @@ def format(data, request, response, toke_info):
         if "Location" in response.headers:
             body += '<a href="{}"> show </a>'.format(response.headers["Location"])
         else:
+            _id = request.path_info[request.path_info.rfind("/")+1:]
             body += '<a href="/osm/{}?METHOD=DELETE"> <img src="/osm/static/delete.png" height="25" width="25"> </a>'\
                 .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 += "<pre>" + html_escape(yaml.safe_dump(data, explicit_start=True, indent=4, default_flow_style=False)) + \
                 "</pre>"
     elif data is None:
index 5f822f7..6c63ad8 100644 (file)
@@ -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 "<ID>" in reference:
                 reference = reference["<ID>"]
             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)