X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_nbi%2Fnbi.py;h=1cd13b799af624bd63085018526885fe11e3b019;hb=refs%2Fchanges%2F51%2F13451%2F1;hp=fa414f053384983fa4b1c786697f9f1bd27c8846;hpb=f2af4a100d308e07f355d61b94fb27d1ccc97aa2;p=osm%2FNBI.git diff --git a/osm_nbi/nbi.py b/osm_nbi/nbi.py index fa414f05..1cd13b79 100644 --- a/osm_nbi/nbi.py +++ b/osm_nbi/nbi.py @@ -32,6 +32,7 @@ from osm_nbi.validation import ValidationError from osm_common.dbbase import DbException from osm_common.fsbase import FsException from osm_common.msgbase import MsgException +from osm_common.wftemporal import WFTemporal from http import HTTPStatus from codecs import getreader from os import environ, path @@ -672,9 +673,7 @@ class Server(object): cherrypy.request.headers.pop("Content-File-MD5", None) elif "application/yaml" in cherrypy.request.headers["Content-Type"]: error_text = "Invalid yaml format " - indata = yaml.load( - cherrypy.request.body, Loader=yaml.SafeLoader - ) + indata = yaml.safe_load(cherrypy.request.body) cherrypy.request.headers.pop("Content-File-MD5", None) elif ( "application/binary" in cherrypy.request.headers["Content-Type"] @@ -704,13 +703,11 @@ class Server(object): # "Only 'Content-Type' of type 'application/json' or # 'application/yaml' for input format are available") error_text = "Invalid yaml format " - indata = yaml.load( - cherrypy.request.body, Loader=yaml.SafeLoader - ) + indata = yaml.safe_load(cherrypy.request.body) cherrypy.request.headers.pop("Content-File-MD5", None) else: error_text = "Invalid yaml format " - indata = yaml.load(cherrypy.request.body, Loader=yaml.SafeLoader) + indata = yaml.safe_load(cherrypy.request.body) cherrypy.request.headers.pop("Content-File-MD5", None) if not indata: indata = {} @@ -725,7 +722,7 @@ class Server(object): kwargs[k] = None elif format_yaml: try: - kwargs[k] = yaml.load(v, Loader=yaml.SafeLoader) + kwargs[k] = yaml.safe_load(v) except Exception: pass elif ( @@ -749,7 +746,7 @@ class Server(object): v[index] = None elif format_yaml: try: - v[index] = yaml.load(v[index], Loader=yaml.SafeLoader) + v[index] = yaml.safe_load(v[index]) except Exception: pass @@ -904,7 +901,7 @@ class Server(object): project_name=None, ns_id=None, *args, - **kwargs + **kwargs, ): if topic == "alarms": try: @@ -977,7 +974,7 @@ class Server(object): return self._format_out(str(alarm_list)) # to handle patch request for alarm update elif cherrypy.request.method == "PATCH": - data = yaml.load(cherrypy.request.body, Loader=yaml.SafeLoader) + data = yaml.safe_load(cherrypy.request.body) try: # check if uuid is valid self.engine.db.get_one("alarms", {"uuid": data.get("uuid")}) @@ -1171,13 +1168,13 @@ class Server(object): return_text = "
{} ->\n".format(main_topic)
             try:
                 if cherrypy.request.method == "POST":
-                    to_send = yaml.load(cherrypy.request.body, Loader=yaml.SafeLoader)
+                    to_send = yaml.safe_load(cherrypy.request.body)
                     for k, v in to_send.items():
                         self.engine.msg.write(main_topic, k, v)
                         return_text += "  {}: {}\n".format(k, v)
                 elif cherrypy.request.method == "GET":
                     for k, v in kwargs.items():
-                        v_dict = yaml.load(v, Loader=yaml.SafeLoader)
+                        v_dict = yaml.safe_load(v)
                         self.engine.msg.write(main_topic, k, v_dict)
                         return_text += "  {}: {}\n".format(k, v_dict)
             except Exception as e:
@@ -1385,7 +1382,7 @@ class Server(object):
         _id=None,
         item=None,
         *args,
-        **kwargs
+        **kwargs,
     ):
         token_info = None
         outdata = None
@@ -1854,7 +1851,7 @@ def _start_service():
                 update_dict["server.socket_host"] = v
             elif k1 in ("server", "test", "auth", "log"):
                 update_dict[k1 + "." + k2] = v
-            elif k1 in ("message", "database", "storage", "authentication"):
+            elif k1 in ("message", "database", "storage", "authentication", "temporal"):
                 # k2 = k2.replace('_', '.')
                 if k2 in ("port", "db_port"):
                     engine_config[k1][k2] = int(v)
@@ -1940,6 +1937,10 @@ def _start_service():
     subscription_thread.start()
     # Do not capture except SubscriptionException
 
+    WFTemporal.temporal_api = (
+        f'{engine_config["temporal"]["host"]}:{engine_config["temporal"]["port"]}'
+    )
+
     backend = engine_config["authentication"]["backend"]
     cherrypy.log.error(
         "Starting OSM NBI Version '{} {}' with '{}' authentication backend".format(