provide version in json format 88/7888/4
authortierno <alfonso.tiernosepulveda@telefonica.com>
Fri, 30 Aug 2019 15:37:12 +0000 (15:37 +0000)
committertierno <alfonso.tiernosepulveda@telefonica.com>
Mon, 2 Sep 2019 07:24:29 +0000 (07:24 +0000)
Change-Id: I69140a3655a0cf95212eae1022d6d34eec30a198
Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
osm_nbi/__init__.py
osm_nbi/html_out.py
osm_nbi/nbi.py

index 2569c9e..1e02f66 100644 (file)
@@ -12,5 +12,5 @@
 # under the License.
 ##
 
 # under the License.
 ##
 
-version = '6.0.2.post0'
+version = '6.0.2.post1'
 version_date = '2018-08-30'
 version_date = '2018-08-30'
index a8823bd..871d502 100644 (file)
@@ -143,6 +143,8 @@ def format(data, request, response, toke_info):
             return
         else:
             return html_auth2.format(error=data)
             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))
     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))
index 1085ebc..03e8727 100644 (file)
@@ -557,7 +557,7 @@ class Server(object):
         return string of dictionary data according to requested json, yaml, xml. By default json
         :param data: response to be sent. Can be a dict, text or file
         :param token_info: Contains among other username and project
         return string of dictionary data according to requested json, yaml, xml. By default json
         :param data: response to be sent. Can be a dict, text or file
         :param token_info: Contains among other username and project
-        :param _format: The format to be set as Content-Type ir data is a file
+        :param _format: The format to be set as Content-Type if data is a file
         :return: None
         """
         accept = cherrypy.request.headers.get("Accept")
         :return: None
         """
         accept = cherrypy.request.headers.get("Accept")
@@ -621,7 +621,8 @@ class Server(object):
             elif args or kwargs:
                 raise NbiException("Invalid URL or query string for version", HTTPStatus.METHOD_NOT_ALLOWED)
             # TODO include version of other modules, pick up from some kafka admin message
             elif args or kwargs:
                 raise NbiException("Invalid URL or query string for version", HTTPStatus.METHOD_NOT_ALLOWED)
             # TODO include version of other modules, pick up from some kafka admin message
-            return "<pre>NBI:\n    version: {}\n    date: {}\n".format(nbi_version, nbi_version_date)
+            osm_nbi_version = {"version": nbi_version, "date": nbi_version_date}
+            return self._format_out(osm_nbi_version)
         except NbiException as e:
             cherrypy.response.status = e.http_code.value
             problem_details = {
         except NbiException as e:
             cherrypy.response.status = e.http_code.value
             problem_details = {