2 ################################################################################
3 # Copyright (c) 2020 AT&T Intellectual Property. #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
22 read -n 1 -p "Press any key to continue" mainmenuinput
27 echo "This script demonstrates the phase one of the Bronze release Traffic Steering use case."
28 DIRNAME="/tmp/tsflow-$(date +%Y%m%d%H%M)"
32 echo "===> Generating xApp on-boarding file"
34 "config-file.json_url": "https://gerrit.o-ran-sc.org/r/gitweb?p=ric-app/qp.git;a=blob_plain;f=xapp-descriptor/config.json;hb=HEAD"
37 "config-file.json_url": "https://gerrit.o-ran-sc.org/r/gitweb?p=ric-app/qp-driver.git;a=blob_plain;f=xapp-descriptor/config.json;hb=HEAD"
40 "config-file.json_url": "https://gerrit.o-ran-sc.org/r/gitweb?p=ric-app/ts.git;a=blob_plain;f=xapp-descriptor/config.json;hb=HEAD"
44 echo "===> On-boarding xApps"
45 curl --location --request POST "http://$(hostname):32080/onboard/api/v1/onboard/download" \
46 --header 'Content-Type: application/json' --data-binary "@./onboard.ts.url"
47 curl --location --request POST "http://$(hostname):32080/onboard/api/v1/onboard/download" \
48 --header 'Content-Type: application/json' --data-binary "@./onboard.qp.url"
49 curl --location --request POST "http://$(hostname):32080/onboard/api/v1/onboard/download" \
50 --header 'Content-Type: application/json' --data-binary "@./onboard.qpd.url"
52 echo "======> Listing on boarded xApps"
53 curl --location --request GET "http://$(hostname):32080/onboard/api/v1/charts"
56 echo "====> Deploy xApps"
57 curl --location --request POST "http://$(hostname):32080/appmgr/ric/v1/xapps" \
58 --header 'Content-Type: application/json' --data-raw '{"xappName": "qp"}'
59 # response: {"instances":null,"name":"qp","status":"deployed","version":"1.0"}
61 curl --location --request POST "http://$(hostname):32080/appmgr/ric/v1/xapps" \
62 --header 'Content-Type: application/json' --data-raw '{"xappName": "qpdriver"}'
63 # response: {"instances":null,"name":"qpdriver","status":"deployed","version":"1.0"}
65 curl --location --request POST "http://$(hostname):32080/appmgr/ric/v1/xapps" \
66 --header 'Content-Type: application/json' --data-raw '{"xappName": "trafficxapp"}'
67 # response: {"instances":null,"name":"trafficxapp","status":"deployed","version":"1.0"}
69 echo "======> Status of xApps"
70 kubectl get pods -n ricxapp
75 while [ -z $POD_QP ] || [ -z $POD_QPD ] || [ -z $POD_TS ]; do
76 echo "Not all new xApp pods are in running state."
78 POD_QP=$(kubectl get pods -n ricxapp | grep Running | grep "\-qp\-" | cut -f1 -d ' ')
79 POD_QPD=$(kubectl get pods -n ricxapp | grep Running | grep "\-qpdriver\-" | cut -f1 -d ' ')
80 POD_TS=$(kubectl get pods -n ricxapp | grep Running | grep "\-trafficxapp\-" | cut -f1 -d ' ')
84 POD_A1=$(kubectl get pods -n ricplt | grep Running | grep "\-a1mediator\-" | cut -f1 -d ' ')
85 echo "To view the logs of the A1 midiator, run the following "
86 echo "command in a separate terminal window:"
87 echo " kubectl logs -f -n ricplt $POD_A1"
89 echo "To view the logs of the traffic steering xapp, run the following "
90 echo "command in a separate terminal window:"
91 echo " kubectl logs -f -n ricplt $POD_TS"
97 echo "===> Inject DBaas with testing data for Traffic Steering test"
99 git clone http://gerrit.o-ran-sc.org/r/ric-xapp/ts
102 cd ts/test/populatedb
107 echo "====> Pushing policy type to A1"
108 POLICY_TYPE_ID="20008"
109 cat << EOF > ts-policy-type-${POLICY_TYPE_ID}.json
112 "description": "tsa parameters",
113 "policy_type_id": ${POLICY_TYPE_ID},
115 "\$schema": "http://json-schema.org/draft-07/schema#",
116 "title": "TS Policy",
117 "description": "TS policy type",
125 "additionalProperties": false
130 acknowledge "The next command will create a new policy type. Watch the logs of A1 Mediator"
132 curl -v -X PUT "http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}" \
133 -H "accept: application/json" -H "Content-Type: application/json" \
134 -d @./ts-policy-type-${POLICY_TYPE_ID}.json
135 # expect to see a 201
137 echo "======> Listing policy types"
138 curl -X GET --header "Content-Type: application/json" --header "accept: application/json" \
139 http://$(hostname):32080/a1mediator/a1-p/policytypes
141 acknowledge "The next command will create a new policy instance. Watch the logs of A1 Mediator and TS xApp"
143 POLICY_ID="tsapolicy145"
144 echo "===> Deploy policy ID of ${POLICY_ID}" of policy type ${POLICY_TYPE_ID}"
145 curl -X PUT --header "Content-Type: application/json" \
146 --data "{\"threshold\" : 5}" \
147 http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}/policies/${POLICY_ID}
149 # get policy instances
150 echo "======> Listing policy instances"
151 curl -X GET --header "Content-Type: application/json" --header "accept: application/json" \
152 http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}/policies
154 echo "Watch how TS processes the data retrieved from RNIB in TS logs"
155 acknowledge "After done we will start the removal process"
158 echo "===> Deleting policy instance"
159 acknowledge "The next command will delete a policy instance. Watch the logs of A1 Mediator andd TS xApp"
160 curl -X DELETE --header "Content-Type: application/json" --header "accept: application/json" \
161 http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}/policies/${POLICY_ID}
163 echo "======> Listing policy instances"
164 curl -X GET --header "Content-Type: application/json" --header "accept: application/json" \
165 http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}/policies
167 echo "===> Deleting policy type $POLICY_TYPE_ID"
168 acknowledge "The next command will delete a policy type. Watch the logs of TS xApp"
169 curl -X DELETE -H "accept: application/json" -H "Content-Type: application/json" \
170 "http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}"
172 echo "======> Listing policy types"
173 curl -X GET --header "Content-Type: application/json" --header "accept: application/json" \
174 http://$(hostname):32080/a1mediator/a1-p/policytypes
177 echo "===> Unddeploy the xApps"
178 acknowledge "The next command will delete the TS, QP, and DPQ xApps."
179 curl -H "Content-Type: application/json" -X DELETE \
180 http://$(hostname):32080/appmgr/ric/v1/xapps/trafficxapp
181 curl -H "Content-Type: application/json" -X DELETE \
182 http://$(hostname):32080/appmgr/ric/v1/xapps/qp
183 curl -H "Content-Type: application/json" -X DELETE \
184 http://$(hostname):32080/appmgr/ric/v1/xapps/qpdriver
186 echo "======> Listing xApps"
187 kubectl get pods -n ricxapp