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, or CTRL-C to abort" mainmenuinput
27 echo "This scripts demonstrates the Bronze release Traffic Steering use case, as well as the RIC part of the SMO A1 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 three xApps: Traffic Steering, Quality Predictor, and Quality Predictor Driver."
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"
51 acknowledge "A \"Created\" status indicates on-boarding successful."
53 echo "======> Listing on boarded xApps"
54 curl --location --request GET "http://$(hostname):32080/onboard/api/v1/charts"
55 acknowledge "Verify that the on-boarded xApps indeed are listed."
57 echo "====> Deploy xApps"
58 curl --location --request POST "http://$(hostname):32080/appmgr/ric/v1/xapps" \
59 --header 'Content-Type: application/json' --data-raw '{"xappName": "qp"}'
60 # 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"}
64 curl --location --request POST "http://$(hostname):32080/appmgr/ric/v1/xapps" \
65 --header 'Content-Type: application/json' --data-raw '{"xappName": "trafficxapp"}'
66 # response: {"instances":null,"name":"trafficxapp","status":"deployed","version":"1.0"}
67 acknowledge "A \"deployed\" status indicates that the xApp has been deployed."
70 echo "======> Status of xApps"
71 kubectl get pods -n ricxapp
74 echo -n "Waiting for all newly deployed xApp pod(s) reaching running state."
78 while [ -z $POD_QP ] || [ -z $POD_QPD ] || [ -z $POD_TS ]; do
81 POD_QP=$(kubectl get pods -n ricxapp | grep Running | grep "\-qp\-" | cut -f1 -d ' ')
82 POD_QPD=$(kubectl get pods -n ricxapp | grep Running | grep "\-qpdriver\-" | cut -f1 -d ' ')
83 POD_TS=$(kubectl get pods -n ricxapp | grep Running | grep "\-trafficxapp\-" | cut -f1 -d ' ')
85 echo && echo "Now all newly deployed xApp(s) have reached running state"
88 POD_A1=$(kubectl get pods -n ricplt | grep Running | grep "\-a1mediator\-" | cut -f1 -d ' ')
90 echo "To view the logs of the A1 midiator, run the following "
91 echo "command in a separate terminal window:"
92 echo " kubectl logs -f -n ricplt $POD_A1"
94 echo "To view the logs of the Traffic Steering xapp, run the following "
95 echo "command in a separate terminal window:"
96 echo " kubectl logs -f -n ricxapp $POD_TS"
98 acknowledge "When ready, "
102 echo && echo "===> Inject DBaaS (RNIB) with testing data for Traffic Steering test"
104 git clone http://gerrit.o-ran-sc.org/r/ric-app/ts
107 cd ts/test/populatedb
110 acknowledge "RNIB populated. The Traffic Steering xApp's log should inicate that it is reading RAN data. When ready for the next step, "
113 POLICY_TYPE_ID="20008"
114 echo "====> Creating policy type ${POLICY_TYPE_ID} via A1"
115 cat << EOF > ts-policy-type-${POLICY_TYPE_ID}.json
118 "description": "tsa parameters",
119 "policy_type_id": ${POLICY_TYPE_ID},
121 "\$schema": "http://json-schema.org/draft-07/schema#",
122 "title": "TS Policy",
123 "description": "TS policy type",
131 "additionalProperties": false
135 echo "A policy type definition file ts-policy-type-${POLICY_TYPE_ID}.json has been created."
136 echo && acknowledge "The next command will create a new policy type via A1 Mediator using this definition file. Watch the logs of A1 Mediator for confirmation."
139 curl -v -X PUT "http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}" \
140 -H "accept: application/json" -H "Content-Type: application/json" \
141 -d @./ts-policy-type-${POLICY_TYPE_ID}.json
142 # expect to see a 201
143 acknowledge "A 201 response indicates that the new policy type has been created."
146 echo "======> Listing policy types"
147 curl -X GET --header "Content-Type: application/json" --header "accept: application/json" \
148 http://$(hostname):32080/a1mediator/a1-p/policytypes
149 acknowledge "Verify that the policy type ${POLICY_TYPE_ID} is in the listing."
151 echo && acknowledge "The next steps will be carried out in the SMO cluster by the a1-smo.sh script. After being suggested by the a1-smo.sh script to come back to tis script, "
153 POLICY_ID="tsapolicy145"
154 if [ "${LOCAL_POLICY_INSTANCE}" = "Y" ]; then
155 echo && acknowledge "The next command will create a new policy instance. Watch the logs of A1 Mediator and TS xApp"
157 echo "===> Deploy policy ID of ${POLICY_ID} of policy type ${POLICY_TYPE_ID}"
158 curl -X PUT --header "Content-Type: application/json" \
159 --data "{\"threshold\" : 5}" \
160 http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}/policies/${POLICY_ID}
161 acknowledge "A 202 response indicates that the new policy instance has been created. In additoin, A1 Mediator and HW xApp log would indicate that the new policy instance has been distributed from A1 Mediator to the xApp."
164 # get policy instances
165 echo "======> Listing policy instances"
166 curl -X GET --header "Content-Type: application/json" --header "accept: application/json" \
167 http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}/policies
168 acknowledge "Verify that the new policy instance appears in the policy list. Also watch the A1 Mediator and TS xApp log for policyc distribution, and how TS xApp processes the RNIB data following the new policy instance (with updated treshold)."
173 echo && acknowledge "The above sequence has completed the Hello World xApp on-boarding, deployment, and policy distribution demonstration. The remaining part of the script cleans up the three xApps, and the policy type from the Near RT RIC"
175 if [ "${LOCAL_POLICY_INSTANCE}" = "Y" ]; then
176 echo && echo "===> Deleting policy instance ${POLICY_ID} of type ${POLICY_TYPE_ID}"
177 acknowledge "The next command will delete a policy instance. Watch the logs of A1 Mediator andd TS xApp"
178 curl -X DELETE --header "Content-Type: application/json" --header "accept: application/json" \
179 http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}/policies/${POLICY_ID}
182 echo && echo "======> Listing policy instances"
183 curl -X GET --header "Content-Type: application/json" --header "accept: application/json" \
184 http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}/policies
187 echo && echo "===> Deleting policy type $POLICY_TYPE_ID"
188 acknowledge "The next command will delete a policy type. Watch the logs of A1 Mediator."
189 curl -X DELETE -H "accept: application/json" -H "Content-Type: application/json" \
190 "http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}"
193 echo && echo "======> Listing policy types"
194 curl -X GET --header "Content-Type: application/json" --header "accept: application/json" \
195 http://$(hostname):32080/a1mediator/a1-p/policytypes
197 echo && echo "===> Undeploy the xApps"
198 acknowledge "The next command will delete the TS, QP, and DPQ xApps."
199 curl -H "Content-Type: application/json" -X DELETE \
200 http://$(hostname):32080/appmgr/ric/v1/xapps/trafficxapp
201 curl -H "Content-Type: application/json" -X DELETE \
202 http://$(hostname):32080/appmgr/ric/v1/xapps/qp
203 curl -H "Content-Type: application/json" -X DELETE \
204 http://$(hostname):32080/appmgr/ric/v1/xapps/qpdriver
207 echo && echo "======> Listing xApps"
208 kubectl get pods -n ricxapp
212 echo "That is all folks. Thanks!"