fix 1059. Provide rights parameters to ns_terminate for a nsi service
[osm/NBI.git] / osm_nbi / html_out.py
index 9adf6f5..5fd12ce 100644 (file)
@@ -46,6 +46,8 @@ html_start = """
       <a href="/osm/admin/v1/vim_accounts">VIMs </a>
       <a href="/osm/admin/v1/wim_accounts">WIMs </a>
       <a href="/osm/admin/v1/sdns">SDNs </a>
+      <a href="/osm/admin/v1/k8sclusters">K8s_clusters </a>
+      <a href="/osm/admin/v1/k8srepos">K8s_repos </a>
       <a href="/osm/admin/v1/tokens?METHOD=DELETE">logout </a>
     </div>
   </div>
@@ -128,7 +130,7 @@ html_nsilcmop_body = """
 """
 
 
-def format(data, request, response, session):
+def format(data, request, response, toke_info):
     """
     Format a nice html response, depending on the data
     :param data:
@@ -143,12 +145,14 @@ def format(data, request, response, session):
             return
         else:
             return html_auth2.format(error=data)
+    if request.path_info in ("/version", "/system"):
+        return "<pre>" + yaml.safe_dump(data, explicit_start=False, indent=4, default_flow_style=False) + "</pre>"
     body = html_body.format(item=request.path_info)
     if response.status and response.status > 202:
         body += html_body_error.format(yaml.safe_dump(data, explicit_start=True, indent=4, default_flow_style=False))
     elif isinstance(data, (list, tuple)):
         if request.path_info == "/vnfpkgm/v1/vnf_packages":
-            body += html_upload_body.format(request.path_info, "VNFD")
+            body += html_upload_body.format(request.path_info + "_content", "VNFD")
         elif request.path_info == "/nsd/v1/ns_descriptors":
             body += html_upload_body.format(request.path_info + "_content", "NSD")
         elif request.path_info == "/nst/v1/nst_templates":
@@ -182,11 +186,11 @@ def format(data, request, response, session):
     else:
         body = html_escape(str(data))
     user_text = "    "
-    if session:
-        if session.get("username"):
-            user_text += "user: {}".format(session.get("username"))
-        if session.get("project_id"):
-            user_text += ", project: {}".format(session.get("project_id"))
+    if toke_info:
+        if toke_info.get("username"):
+            user_text += "user: {}".format(toke_info.get("username"))
+        if toke_info.get("project_id"):
+            user_text += ", project: {}".format(toke_info.get("project_name"))
     return html_start.format(user_text) + body + html_end
     # yaml.safe_dump(data, explicit_start=True, indent=4, default_flow_style=False)
     # tags=False,