4cd5e4475bc7d39d3fd738fa6bb14d0093302a56
[integration/csit.git] / scripts / dcaegen2-services-slice-analysis-ms / slice-analysis-ms / cps-aai / cps-aai-setup.sh
1 #!/bin/bash
2
3 #Building cps-tbdmt image
4 git clone "https://gerrit.onap.org/r/cps/cps-tbdmt"
5 mvn -f cps-tbdmt/ -Dmaven.test.skip clean install --settings settings.xml
6 sudo rm -r cps-tbdmt/
7
8 #Creating containers for cps, cps-tbdmt & aai-resources
9 docker-compose up -d
10
11 sleep 50
12
13 # uploading data to cps & cps-tbdmt
14 CPS_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' cps-and-ncmp )
15 echo $CPS_IP
16 CPS_TBDMT_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' cps-tbdmt )
17 echo $CPS_TBDMT_IP
18
19 echo "Creating dataspace: "
20 curl --location --user cpsuser:cpsr0cks! -H "Accept: application/json" -H "Content-Type: application/json" \
21 --request POST \
22 http://$CPS_IP:8080/cps/api/v1/dataspaces?dataspace-name=E2EDemo
23
24 echo "\nCreating schema set: "
25 curl --location --user cpsuser:cpsr0cks! \
26 --request POST \
27 http://$CPS_IP:8080/cps/api/v1/dataspaces/E2EDemo/schema-sets --form 'file=@"ran-network.zip"' --form 'schema-set-name="ran-network"'
28
29 echo "\nCreating anchor: "
30 curl --location --user cpsuser:cpsr0cks!  --request POST \
31 http://$CPS_IP:8080/cps/api/v1/dataspaces/E2EDemo/anchors?schema-set-name=ran-network \
32 -d anchor-name=ran-network-anchor
33
34 echo "\nUploading cps payload "
35 curl --location --user cpsuser:cpsr0cks! --request POST \
36 http://$CPS_IP:8080/cps/api/v1/dataspaces/E2EDemo/anchors/ran-network-anchor/nodes \
37 --header 'Content-Type: application/json' \
38 -d @sim-data/payload-ran-network.json
39
40
41 echo "\nuploading tbdmt-templates"
42 curl --location --request POST \
43 http://$CPS_TBDMT_IP:8080/templates \
44 --header 'Content-Type: application/json' \
45 --data-raw '{"templateId": "get-nearrtric-config","model": "ran-network","requestType": "query-cps-path","xpathTemplate": "//sNSSAIList[@sNssai='\''{{sNssai}}'\'']/ancestor::NearRTRIC","includeDescendants": true}'
46
47 curl --location --request POST \
48 http://$CPS_TBDMT_IP:8080/templates \
49 --header 'Content-Type: application/json' \
50 --data-raw '{"templateId": "get-gnbdufunction-by-snssai","model": "ran-network","requestType": "query-cps-path","xpathTemplate": "//sNSSAIList[@sNssai='\''{{sNssai}}'\'']/ancestor::GNBDUFunction","includeDescendants": true}'
51
52 curl --location --request POST \
53 http://$CPS_TBDMT_IP:8080/templates \
54 --header 'Content-Type: application/json' \
55 --data-raw '{"templateId": "get-nrcelldu-by-snssai","model": "ran-network","requestType": "query-cps-path","xpathTemplate": "//sNSSAIList[@sNssai='\''{{sNssai}}'\'']/ancestor::NearRTRIC","includeDescendants": true}'
56
57
58 ##Uploading aai data
59 AAI_RESOURCES_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' aai-resources )
60
61 echo "\nUploading data to aai-resources"
62 curl --request PUT -H "X-FromAppId:AAI " -H  "X-TransactionId:get_aai_subscr" -H "Accept:application/json" -H "Content-Type:application/json" -k \
63 https://$AAI_RESOURCES_IP:8447/aai/v21/business/customers/customer/5GCustomer \
64 -d @sim-data/customers.json
65
66 curl --request PUT -H "X-FromAppId:AAI " -H  "X-TransactionId:get_aai_subscr" -H "Accept:application/json" -H "Content-Type:application/json" -k \
67 https://$AAI_RESOURCES_IP:8447/aai/v21/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G \
68 -d @sim-data/service_subscriptions.json
69
70 curl --request PUT -H "X-FromAppId:AAI " -H  "X-TransactionId:get_aai_subscr" -H "Accept:application/json" -H "Content-Type:application/json" -k \
71 https://$AAI_RESOURCES_IP:8447/aai/v21/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/3f2f23fa-c567-4dd8-8f15-f95ae3e6fd84 \
72 -d @sim-data/service_instances.json
73
74 curl --request PUT -H "X-FromAppId:AAI " -H  "X-TransactionId:get_aai_subscr" -H "Accept:application/json" -H "Content-Type:application/json" -k \
75 https://$AAI_RESOURCES_IP:8447/aai/v24/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/3f2f23fa-c567-4dd8-8f15-f95ae3e6fd84/slice-profiles/slice-profile/684hf846f-863b-4901-b202-0ab86a638555 \
76 -d @sim-data/slice_profile.json
77