3 from flask import request
8 app = flask.Flask(__name__)
9 app.config["DEBUG"] = True
12 def get_neighbour_cell_list_for_cell_id():
13 with open('cell_list.json') as cell_list:
14 data = json.load(cell_list)
16 return {"Error": "Unable to read file"}, 503
19 def get_pci_for_cell_id():
20 with open('pci_value.json') as pci_value:
21 data = json.load(pci_value)
23 return {"Error": "Unable to read file"}, 503
26 def get_cell_data_for_cell_id():
27 with open('cell_data.json') as cell_data:
28 data = json.load(cell_data)
30 return {"Error": "Unable to read file"}, 503
33 def get_oof_sync_response():
34 with open('oof_syn_response.json') as syncRes:
35 data = json.load(syncRes)
37 return {"Error": "Unale to read file"}, 503
40 def get_oof_async_response(callback_url, transaction_id):
42 with open('oof_async_response.json') as asyncRes:
43 data = json.load(asyncRes)
44 data['transactionId'] = transaction_id
46 return {"Error": "Unable to read file"}, 503
47 res = requests.post(callback_url, json=data)
48 print('response from server:',res.text)
51 @app.route("/api/sdnc-config-db/v3/getNbrList/<cell_id>/<ts>", methods=["GET"])
52 def get_neighbour_list(cell_id, ts):
53 data, status = get_neighbour_cell_list_for_cell_id()
58 @app.route("/api/sdnc-config-db/v3/getPCI/<cell_id>/<ts>", methods=["GET"])
59 def get_pci(cell_id, ts):
60 data, status = get_pci_for_cell_id()
64 @app.route("/api/sdnc-config-db/v3/getPnfId/<cell_id>/<ts>", methods=["GET"])
65 def get_pnf_id(cell_id, ts):
66 data, status = get_pci_for_cell_id()
67 data['value'] = 'ncserver5'
72 @app.route("/api/sdnc-config-db/v3/getCell/<cell_id>", methods=["GET"])
73 def get_cell_data(cell_id):
74 data, status = get_cell_data_for_cell_id()
79 @app.route("/api/oof/v1/pci",methods=["POST"])
80 def oof_optimizatio_result():
81 content = request.get_json()
82 callback_url = content['requestInfo']['callbackUrl']
83 transaction_id = content['requestInfo']['transactionId']
85 task = threading.Thread(target=get_oof_async_response, args=(callback_url,transaction_id,))
89 print("Error: Unable to start thread")
91 data, status = get_oof_sync_response()
98 app.run(host='0.0.0.0')