aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrishnaa96 <krishna.moorthy6@wipro.com>2021-10-05 15:10:49 +0000
committerkrishnaa96 <krishna.moorthy6@wipro.com>2021-10-11 14:38:50 +0530
commit0792564e8e30aa1c3efc21e8f92fb6be7be167a1 (patch)
tree34f6cb5891e0e9d39cfa18b0d449cf325724af66
parentb2e2c6688737230608c3dd8e14e1c09d2b54c86d (diff)
Add scripts to preload templates
Issue-ID: CPS-708 Signed-off-by: krishnaa96 <krishna.moorthy6@wipro.com> Change-Id: Id8f48c061b9556c47953c78e9c86c6a3dc9ec79c
-rw-r--r--docker-compose/docker-compose.yml11
-rw-r--r--docker-compose/preload-templates/Dockerfile7
-rw-r--r--docker-compose/preload-templates/cpspreload.py26
-rw-r--r--docker-compose/preload-templates/samplepreload.json16
4 files changed, 59 insertions, 1 deletions
diff --git a/docker-compose/docker-compose.yml b/docker-compose/docker-compose.yml
index 961cec6..1868c89 100644
--- a/docker-compose/docker-compose.yml
+++ b/docker-compose/docker-compose.yml
@@ -50,4 +50,13 @@ services:
depends_on:
- postgres
networks:
- - cps-tbdmt-default \ No newline at end of file
+ - cps-tbdmt-default
+ preload-templates:
+ build: ../preload-templates
+ depends_on:
+ - cps-tbdmt
+ networks:
+ - cps-tbdmt-default
+ volumes:
+ - ../preload-templates/$FILENAME:/usr/src/app/samplepreload.json
+
diff --git a/docker-compose/preload-templates/Dockerfile b/docker-compose/preload-templates/Dockerfile
new file mode 100644
index 0000000..c668ed9
--- /dev/null
+++ b/docker-compose/preload-templates/Dockerfile
@@ -0,0 +1,7 @@
+FROM python:3
+WORKDIR /usr/src/app
+COPY cpspreload.py .
+COPY samplepreload.json .
+RUN pip install requests
+CMD ["cpspreload.py"]
+ENTRYPOINT ["python3"]
diff --git a/docker-compose/preload-templates/cpspreload.py b/docker-compose/preload-templates/cpspreload.py
new file mode 100644
index 0000000..25fd568
--- /dev/null
+++ b/docker-compose/preload-templates/cpspreload.py
@@ -0,0 +1,26 @@
+import json
+import time
+import requests
+
+CPS_HEADERS = {
+ "Accept": "application/json",
+ "Content-Type": "application/json",
+ }
+tbdmt_url="http://cps-tbdmt:8080/templates"
+
+
+
+with open('samplepreload.json') as template_file:
+ templates_json = template_file.read()
+templates=json.loads(templates_json)
+
+
+for template in templates:
+ print(type(template))
+ print("send rest req")
+ print("waiting before sent req")
+ time.sleep(2)
+ response=requests.post(tbdmt_url, json=template, headers=CPS_HEADERS)
+ print("res",response.reason)
+
+
diff --git a/docker-compose/preload-templates/samplepreload.json b/docker-compose/preload-templates/samplepreload.json
new file mode 100644
index 0000000..d96488d
--- /dev/null
+++ b/docker-compose/preload-templates/samplepreload.json
@@ -0,0 +1,16 @@
+[
+ {
+ "includeDescendants": true,
+ "model": "ran-network",
+ "requestType": "get",
+ "templateId": "dummy-template-7",
+ "xpathTemplate": "/ran-network/NearRTRIC[@idNearRTRIC='{{idNearRTRIC}}']/GNBCUUPFunction[@idGNBCUUPFunction='{{idGNBCUUPFunction}}']/attributes/pLMNInfoList[@mcc='{{mcc}}' and @mnc='{{mnc}}']/sNSSAIList[@sNssai='{{sNSSAIList}}']"
+ },
+ {
+ "includeDescendants": true,
+ "model": "ran-network",
+ "requestType": "get",
+ "templateId": "dummy-template-8",
+ "xpathTemplate": "/ran-network/NearRTRIC[@idNearRTRIC='{{idNearRTRIC}}']/GNBCUUPFunction[@idGNBCUUPFunction='{{idGNBCUUPFunction}}']/attributes/RRMPolicyRatio[@id='{{id}}']/attributes/rRMPolicyMemberList[@idx='{{idx}}']"
+ }
+]