3 from flask import request
8 app = flask.Flask(__name__)
9 app.config["DEBUG"] = True
11 def get_neighbour_cell_list_for_cell_id():
12 with open('cell_list.json') as cell_list:
13 data = json.load(cell_list)
15 return {"Error": "Unable to read file"}, 503
18 def get_pci_for_cell_id():
19 with open('pci_value.json') as pci_value:
20 data = json.load(pci_value)
22 return {"Error": "Unable to read file"}, 503
25 def get_cell_data_for_cell_id():
26 with open('cell_data.json') as cell_data:
27 data = json.load(cell_data)
29 return {"Error": "Unable to read file"}, 503
32 def get_oof_sync_response():
33 with open('oof_syn_response.json') as syncRes:
34 data = json.load(syncRes)
36 return {"Error": "Unale to read file"}, 503
39 def get_oof_async_response(callback_url, transaction_id):
41 with open('oof_async_response.json') as asyncRes:
42 data = json.load(asyncRes)
43 data['transactionId'] = transaction_id
45 return {"Error": "Unable to read file"}, 503
46 res = requests.post(callback_url, json=data)
47 print('response from server:',res.text)
50 @app.route("/api/sdnc-config-db/v3/getNbrList/<cell_id>/<ts>", methods=["GET"])
51 def get_neighbour_list(cell_id, ts):
52 data, status = get_neighbour_cell_list_for_cell_id()
57 @app.route("/api/sdnc-config-db/v3/getPCI/<cell_id>/<ts>", methods=["GET"])
58 def get_pci(cell_id, ts):
59 data, status = get_pci_for_cell_id()
63 @app.route("/api/sdnc-config-db/v3/getPnfId/<cell_id>/<ts>", methods=["GET"])
64 def get_pnf_id(cell_id, ts):
65 data, status = get_pci_for_cell_id()
66 data['value'] = 'ncserver5'
71 @app.route("/api/sdnc-config-db/v3/getCell/<cell_id>", methods=["GET"])
72 def get_cell_data(cell_id):
73 data, status = get_cell_data_for_cell_id()
78 @app.route("/api/oof/v1/pci",methods=["POST"])
79 def oof_optimizatio_result():
80 content = request.get_json()
81 callback_url = content['requestInfo']['callbackUrl']
82 transaction_id = content['requestInfo']['transactionId']
84 task = threading.Thread(target=get_oof_async_response, args=(callback_url,transaction_id,))
88 print("Error: Unable to start thread")
90 data, status = get_oof_sync_response()
97 app.run(host='0.0.0.0')