aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorNiranjana <niranjana.y60@wipro.com>2020-08-12 13:33:22 +0530
committerNiranjana <niranjana.y60@wipro.com>2020-08-18 15:11:27 +0530
commit3d457a05e0d180faec09285561bca1023654332f (patch)
tree0224166482cf388a73b4e239628ace17e44f8b8d /scripts
parent7ee6e129f29262b3c7828299bf457004abf28614 (diff)
Add CSIT for son-handler
Issue-ID: DCAEGEN2-1433 Signed-off-by: Niranjana <niranjana.y60@wipro.com> Change-Id: Id7ea296ebef70964f5e8b751969595320b49d00a
Diffstat (limited to 'scripts')
-rw-r--r--scripts/dcaegen2-services-son-handler/sonhandler/Dockerfile15
-rw-r--r--scripts/dcaegen2-services-son-handler/sonhandler/configdb-oof-sim.py98
-rw-r--r--scripts/dcaegen2-services-son-handler/sonhandler/sim-data/cell_data.json13
-rw-r--r--scripts/dcaegen2-services-son-handler/sonhandler/sim-data/cell_list.json60
-rw-r--r--scripts/dcaegen2-services-son-handler/sonhandler/sim-data/oof_async_response.json14
-rw-r--r--scripts/dcaegen2-services-son-handler/sonhandler/sim-data/oof_syn_response.json6
-rw-r--r--scripts/dcaegen2-services-son-handler/sonhandler/sim-data/pci_value.json4
7 files changed, 210 insertions, 0 deletions
diff --git a/scripts/dcaegen2-services-son-handler/sonhandler/Dockerfile b/scripts/dcaegen2-services-son-handler/sonhandler/Dockerfile
new file mode 100644
index 00000000..688a2fe0
--- /dev/null
+++ b/scripts/dcaegen2-services-son-handler/sonhandler/Dockerfile
@@ -0,0 +1,15 @@
+FROM python:alpine3.7
+
+ADD configdb-oof-sim.py /
+
+ADD ./sim-data /
+
+RUN pip install Flask
+
+RUN pip install requests
+
+EXPOSE 5000
+
+CMD ["flask", "run", "--host", "0.0.0.0"]
+
+CMD [ "python", "./configdb-oof-sim.py" ]
diff --git a/scripts/dcaegen2-services-son-handler/sonhandler/configdb-oof-sim.py b/scripts/dcaegen2-services-son-handler/sonhandler/configdb-oof-sim.py
new file mode 100644
index 00000000..7a51c951
--- /dev/null
+++ b/scripts/dcaegen2-services-son-handler/sonhandler/configdb-oof-sim.py
@@ -0,0 +1,98 @@
+import flask
+import json
+from flask import request
+import requests
+import threading
+import time
+
+app = flask.Flask(__name__)
+app.config["DEBUG"] = True
+
+
+def get_neighbour_cell_list_for_cell_id():
+ with open('cell_list.json') as cell_list:
+ data = json.load(cell_list)
+ if not data:
+ return {"Error": "Unable to read file"}, 503
+ return data, None
+
+def get_pci_for_cell_id():
+ with open('pci_value.json') as pci_value:
+ data = json.load(pci_value)
+ if not data:
+ return {"Error": "Unable to read file"}, 503
+ return data, None
+
+def get_cell_data_for_cell_id():
+ with open('cell_data.json') as cell_data:
+ data = json.load(cell_data)
+ if not data:
+ return {"Error": "Unable to read file"}, 503
+ return data, None
+
+def get_oof_sync_response():
+ with open('oof_syn_response.json') as syncRes:
+ data = json.load(syncRes)
+ if not data:
+ return {"Error": "Unale to read file"}, 503
+ return data, None
+
+def get_oof_async_response(callback_url, transaction_id):
+ time.sleep(10)
+ with open('oof_async_response.json') as asyncRes:
+ data = json.load(asyncRes)
+ data['transactionId'] = transaction_id
+ if not data:
+ return {"Error": "Unable to read file"}, 503
+ res = requests.post(callback_url, json=data)
+ print('response from server:',res.text)
+ return res
+
+@app.route("/api/sdnc-config-db/v3/getNbrList/<cell_id>/<ts>", methods=["GET"])
+def get_neighbour_list(cell_id, ts):
+ data, status = get_neighbour_cell_list_for_cell_id()
+ if not status:
+ return data
+ return data, 503
+
+@app.route("/api/sdnc-config-db/v3/getPCI/<cell_id>/<ts>", methods=["GET"])
+def get_pci(cell_id, ts):
+ data, status = get_pci_for_cell_id()
+ if not status:
+ return data
+ return data, 503
+@app.route("/api/sdnc-config-db/v3/getPnfId/<cell_id>/<ts>", methods=["GET"])
+def get_pnf_id(cell_id, ts):
+ data, status = get_pci_for_cell_id()
+ data['value'] = 'ncserver5'
+ if not status:
+ return data
+ return data, 503
+
+@app.route("/api/sdnc-config-db/v3/getCell/<cell_id>", methods=["GET"])
+def get_cell_data(cell_id):
+ data, status = get_cell_data_for_cell_id()
+ if not status:
+ return data
+ return data, 503
+
+@app.route("/api/oof/v1/pci",methods=["POST"])
+def oof_optimizatio_result():
+ content = request.get_json()
+ callback_url = content['requestInfo']['callbackUrl']
+ transaction_id = content['requestInfo']['transactionId']
+ try:
+ task = threading.Thread(target=get_oof_async_response, args=(callback_url,transaction_id,))
+ task.daemon = True
+ task.start()
+ except:
+ print("Error: Unable to start thread")
+
+ data, status = get_oof_sync_response()
+
+ if not status:
+ return data, 202
+ return data, 503
+
+
+app.run(host='0.0.0.0')
diff --git a/scripts/dcaegen2-services-son-handler/sonhandler/sim-data/cell_data.json b/scripts/dcaegen2-services-son-handler/sonhandler/sim-data/cell_data.json
new file mode 100644
index 00000000..0e4e73f4
--- /dev/null
+++ b/scripts/dcaegen2-services-son-handler/sonhandler/sim-data/cell_data.json
@@ -0,0 +1,13 @@
+{
+ "neighbor": ["Chn0066", "Chn0067", "Chn0068", "Chn0069", "Chn0070", "Chn0072", "Chn0073", "Chn0074", "Chn0075", "Chn0076", "Chn0077", "Chn0078", "Chn0079", "Chn0080"],
+ "Cell": {
+ "networkId": "ran-1",
+ "nodeId": "Chn0071",
+ "physicalCellId": 1,
+ "pnfId": "ncserver5",
+ "sectorNumber": null,
+ "latitude": "27.55626304907802",
+ "longitude": "-58.48690415723466",
+ "notes": "NA"
+ }
+} \ No newline at end of file
diff --git a/scripts/dcaegen2-services-son-handler/sonhandler/sim-data/cell_list.json b/scripts/dcaegen2-services-son-handler/sonhandler/sim-data/cell_list.json
new file mode 100644
index 00000000..4f961ae2
--- /dev/null
+++ b/scripts/dcaegen2-services-son-handler/sonhandler/sim-data/cell_list.json
@@ -0,0 +1,60 @@
+{
+ "cellId": "Chn0071",
+ "nbrList": [{
+ "targetCellId": "Chn0066",
+ "pciValue": 0,
+ "ho": true
+ }, {
+ "targetCellId": "Chn0067",
+ "pciValue": 1,
+ "ho": true
+ }, {
+ "targetCellId": "Chn0068",
+ "pciValue": 2,
+ "ho": true
+ }, {
+ "targetCellId": "Chn0069",
+ "pciValue": 3,
+ "ho": true
+ }, {
+ "targetCellId": "Chn0070",
+ "pciValue": 4,
+ "ho": true
+ }, {
+ "targetCellId": "Chn0072",
+ "pciValue": 6,
+ "ho": true
+ }, {
+ "targetCellId": "Chn0073",
+ "pciValue": 7,
+ "ho": true
+ }, {
+ "targetCellId": "Chn0074",
+ "pciValue": 8,
+ "ho": true
+ }, {
+ "targetCellId": "Chn0075",
+ "pciValue": 9,
+ "ho": true
+ }, {
+ "targetCellId": "Chn0076",
+ "pciValue": 10,
+ "ho": true
+ }, {
+ "targetCellId": "Chn0077",
+ "pciValue": 11,
+ "ho": true
+ }, {
+ "targetCellId": "Chn0078",
+ "pciValue": 12,
+ "ho": true
+ }, {
+ "targetCellId": "Chn0079",
+ "pciValue": 13,
+ "ho": true
+ }, {
+ "targetCellId": "Chn0080",
+ "pciValue": 14,
+ "ho": true
+ }]
+} \ No newline at end of file
diff --git a/scripts/dcaegen2-services-son-handler/sonhandler/sim-data/oof_async_response.json b/scripts/dcaegen2-services-son-handler/sonhandler/sim-data/oof_async_response.json
new file mode 100644
index 00000000..99f54cb4
--- /dev/null
+++ b/scripts/dcaegen2-services-son-handler/sonhandler/sim-data/oof_async_response.json
@@ -0,0 +1,14 @@
+{
+ "transactionId": "fff33db3-8fc9-4e29-89ff-7419c85900bd",
+ "requestId": "742b9e6a-aa55-487e-9d71-a4a5e05b3981",
+ "requestStatus": "completed",
+ "statusMessage": "success",
+ "solutions": {
+ "networkId": "ran-1",
+ "pciSolutions": [{
+ "cellId": "Chn0071",
+ "pci": "5"
+ }],
+ "anrSolutions": []
+ }
+} \ No newline at end of file
diff --git a/scripts/dcaegen2-services-son-handler/sonhandler/sim-data/oof_syn_response.json b/scripts/dcaegen2-services-son-handler/sonhandler/sim-data/oof_syn_response.json
new file mode 100644
index 00000000..c9260bbc
--- /dev/null
+++ b/scripts/dcaegen2-services-son-handler/sonhandler/sim-data/oof_syn_response.json
@@ -0,0 +1,6 @@
+{
+ "requestId": "742b9e6a-aa55-487e-9d71-a4a5e05b3981",
+ "transactionId": "fff33db3-8fc9-4e29-89ff-7419c85900bd",
+ "requestStatus": "accepted",
+ "statusMessage": ""
+} \ No newline at end of file
diff --git a/scripts/dcaegen2-services-son-handler/sonhandler/sim-data/pci_value.json b/scripts/dcaegen2-services-son-handler/sonhandler/sim-data/pci_value.json
new file mode 100644
index 00000000..6b6d4475
--- /dev/null
+++ b/scripts/dcaegen2-services-son-handler/sonhandler/sim-data/pci_value.json
@@ -0,0 +1,4 @@
+{
+ "attributeName": "PCIvalue",
+ "value": "5"
+} \ No newline at end of file