X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=near-rt-ric-simulator%2Fsrc%2FSTD_2.0.0%2Fmain.py;h=16e4a31a505947c8766e7419c085a7a0508cdcfe;hb=595506e290356d26b8eebfab32ef8d3f625cbb0a;hp=dcf835e5aa4ad497195fcfa3b76a18c5552ac028;hpb=967079bda24e7a0f5268728f1474ce0ddc9e52d0;p=sim%2Fa1-interface.git diff --git a/near-rt-ric-simulator/src/STD_2.0.0/main.py b/near-rt-ric-simulator/src/STD_2.0.0/main.py index dcf835e..16e4a31 100644 --- a/near-rt-ric-simulator/src/STD_2.0.0/main.py +++ b/near-rt-ric-simulator/src/STD_2.0.0/main.py @@ -1,5 +1,5 @@ # ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. All rights reserved. +# Copyright (C) 2021 Nordix Foundation. All rights reserved. # ======================================================================== # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -25,7 +25,7 @@ import requests from pathlib import Path from flask import Flask, escape, request, Response from jsonschema import validate -from var_declaration import policy_instances, policy_types, policy_status, callbacks, forced_settings, policy_fingerprint, hosts_set, data_delivery_counter +from var_declaration import policy_instances, policy_types, policy_status, callbacks, forced_settings, policy_fingerprint, hosts_set, data_delivery_counter, app from maincommon import check_apipath, apipath, get_supported_interfaces_response, extract_host_name #Constants @@ -33,7 +33,9 @@ TEXT_PLAIN='text/plain' check_apipath() -app = connexion.App(__name__, specification_dir=apipath) +# app is created in var_declarations + +import payload_logging # app var need to be initialized #Check alive function @app.route('/', methods=['GET']) @@ -61,9 +63,9 @@ def delete_instances(): return Response("All policy instances deleted", 200, mimetype=TEXT_PLAIN) #Delete all - all reset -#(same as delete_instances but kept to in order to use the same interface as other version of the simulator) @app.route('/deleteall', methods=['POST']) def delete_all(): + global data_delivery_counter policy_instances.clear() policy_types.clear() @@ -72,6 +74,7 @@ def delete_all(): forced_settings['code']=None forced_settings['delay']=None policy_fingerprint.clear() + data_delivery_counter=0 return Response("All policy instances and types deleted", 200, mimetype=TEXT_PLAIN) #Load a policy type @@ -188,9 +191,8 @@ def sendstatus(): ps=policy_status[policyid] cb=callbacks[policyid] try: - print("Callback url: " + str(cb)) resp=requests.post(cb,json=json.dumps(ps), verify=False) # NOSONAR - except: + except Exception: return Response('Post status failed, could not send to: '+str(cb), status=500, mimetype=TEXT_PLAIN) if (resp.status_code<199 & resp.status_code > 299): return Response('Post status failed with code: '+resp.status_code, status=500, mimetype=TEXT_PLAIN)