X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=test%2Fmrstub%2Fapp%2Fmain.py;h=90924b1ca56d214011eb5f8a47897312ae8fe71e;hb=20da522bf441015f55cb35f3b904ef3d9b388154;hp=db13fc02c48cdbd89b30f8f9a4dc8bc1ab4d604c;hpb=f0019c8168b9d59f132ba47e939e8aa3ef324b7d;p=nonrtric.git diff --git a/test/mrstub/app/main.py b/test/mrstub/app/main.py index db13fc02..90924b1c 100644 --- a/test/mrstub/app/main.py +++ b/test/mrstub/app/main.py @@ -54,6 +54,8 @@ cntr_msg_responses_submitted=0 cntr_msg_responses_fetched=0 # Request and response constants +ORU_WRITE_URL="/events/unauthenticated.SEC_FAULT_OUTPUT" +ORU_READ_URL="/events/unauthenticated.SEC_FAULT_OUTPUT/users/test/" AGENT_WRITE_URL="/events/A1-POLICY-AGENT-WRITE" AGENT_READ_URL="/events/A1-POLICY-AGENT-READ/users/policy-agent" APP_WRITE_URL="/send-request" @@ -168,7 +170,7 @@ def create_message(operation, correlation_id, payload, url): ### MR-stub interface, for MR control # Send a message to MR -# URI and parameters (GET): /send-request?operation=&url= +# URI and parameters (PUT or POST): /send-request?operation=&url= # response: (http 200) o4 400 for parameter error or 500 for other errors @app.route(APP_WRITE_URL, methods=['PUT','POST']) @@ -344,6 +346,24 @@ def events_write(): return Response('{}', status=200, mimetype=MIME_JSON) +@app.route(ORU_WRITE_URL, + methods=['PUT','POST']) +def oru_write(): + global msg_requests + msg=json.dumps(request.json) + msg_requests.append(msg) + return Response('{}', status=200, mimetype=MIME_JSON) + +@app.route(ORU_READ_URL, + methods=['GET']) +def oru_read(): + global msg_requests + if(len(msg_requests)>0): + rsp=msg_requests.pop(0) + res=[] + res.append(rsp) + return Response(json.dumps(res), status=200, mimetype=MIME_JSON) + return Response("[]", status=200, mimetype=MIME_JSON) ### Functions for metrics read out ### @@ -421,4 +441,4 @@ else: print("No env variables - OK") if __name__ == "__main__": - app.run(port=HOST_PORT, host=HOST_IP) \ No newline at end of file + app.run(port=HOST_PORT, host=HOST_IP)