Add Bronze Get Started demo scripts 98/4498/2
authorLusheng Ji <lji@research.att.com>
Mon, 3 Aug 2020 01:25:26 +0000 (21:25 -0400)
committerLusheng Ji <lji@research.att.com>
Mon, 3 Aug 2020 01:29:43 +0000 (21:29 -0400)
Change-Id: I52341d2a1dfabf8f9f1808fa713181a787f1fb3a
Signed-off-by: Lusheng Ji <lji@research.att.com>
demos/bronze/README.txt [new file with mode: 0644]
demos/bronze/__config-ip.sh [new file with mode: 0755]
demos/bronze/a1-ric.sh [new file with mode: 0755]
demos/bronze/a1-smo.sh [new file with mode: 0755]
demos/bronze/o1-ric.sh [new file with mode: 0755]
demos/bronze/o1-smo.sh [new file with mode: 0755]
demos/bronze/odu-high.sh [new file with mode: 0755]
demos/bronze/test-raise-alarm.sh [new file with mode: 0755]
demos/bronze/xapp-hw.sh [new file with mode: 0755]
demos/bronze/xapp-ts.sh [new file with mode: 0755]
docs/release-notes.rst

diff --git a/demos/bronze/README.txt b/demos/bronze/README.txt
new file mode 100644 (file)
index 0000000..624fb97
--- /dev/null
@@ -0,0 +1,60 @@
+################################################################################
+#   Copyright (c)  2020 AT&T                                                   #
+#                                                                              #
+#   Licensed under the Creative Commons License, Attribution 4.0 Intl. (the    #
+#   "License"); you may not use this file except in compliance with the        #
+#   License.  You may obtain a copy of the License at                          #
+#                                                                              #
+#   https://creativecommons.org/licenses/by/4.0/                               #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, documentation   #
+#   distributed under the Documentation License is distributed on an "AS IS"   #
+#   BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or     #
+#   implied. See the Documentation License for the specific language governing #
+#   permissions and limitations under the Documentation License.               #
+#                                                                              #
+################################################################################ 
+
+
+This directory contains a set of scripts used in the Bronze Release "Getting
+Started" series of demonstrations.  The video recordings of these demonstrations
+are available at https://wiki.o-ran-sc.org/display/GS/Getting+Started.
+
+To run these demonstration scripts, it is assumed that two Kubernetes clusters 
+have been set up, and the SMO and (Near Realtime) RIC have been deployed into 
+these two clusters following the instructions at 
+https://wiki.o-ran-sc.org/display/GS/SMO+Installation and 
+https://wiki.o-ran-sc.org/display/GS/Near+Realtime+RIC+Installation respectively.
+
+
+__config-ip.sh
+       This script configures the IP addresses of the RIC and SMO clusters into the
+       Helm charts and scripts in the cloned it/dep repository.  Prior to the running
+       of this script, the IP addresses of the SMO and RIC clusters can be configured 
+       as environment variables, or the script will prompt the user to input them.  
+       This script must be run in both the RIC and SMO clusters before starting any 
+       of the demonstrations.
+
+xapp-hw.sh, xapp-ts.sh
+       These two scripts demonstrate the Hello World and the Traffic Steering xApps
+       respectively.  They are to be run in a shell with sufficient privilege (e.g. 
+       kubectl) to operate the RIC cluster.
+
+a1-ric.sh, a1-smo.sh
+       These two scripts demonstrate the A1 Bronze use case.  The *-ric.sh script is to
+       be run in the RIC cluster and the *-smo.sh script is to be run in the SMO cluster.
+       The scripts are interactive and will prompt the user to perform actions in sequence
+       in these two clusters.
+
+odu-high.sh
+       The odu-high.sh script is to be run in a server outside of the (Near Realtime) RIC
+       cluster.  It completes the steps of cloning, compiling, and running the O-DU High 
+       to interact with the (Near Realtime) RIC to complete the E2 Setup handshake.
+
+
+o1-ric.sh, o1-smo.sh, test-raise-alarm.sh
+       These three scripts demonstrate the O1 Bronze use case.  The *-ric.sh script is to
+        be run in the RIC cluster and the *-smo.sh script is to be run in the SMO cluster.
+        The scripts are interactive and will prompt the user to perform actions in sequence 
+        in these two clusters.  The test-raise-alarm.sh script shows how to raise artificial
+       alarms in the RIC cluster.
diff --git a/demos/bronze/__config-ip.sh b/demos/bronze/__config-ip.sh
new file mode 100755 (executable)
index 0000000..6ae6447
--- /dev/null
@@ -0,0 +1,83 @@
+#!/bin/bash
+################################################################################
+#   Copyright (c) 2020 AT&T Intellectual Property.                             #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+
+#set -x
+
+acknowledge() {
+  if [ ! -z "$1" ]; then echo "$1"; fi
+  read  -n 1 -p "Press any key to continue, or CTRL-C to abort" mainmenuinput
+  echo
+}
+
+
+echo "This script sets up the IP address references for RIC and SMO clusters."
+echo
+echo "Reading RIC cluster IP address from envirronment variable \$RIC_IP."
+if [ -z $(echo ${RIC_IP} | grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}") ]; then
+  read -p "Not found or not in right format.  Enter the external IP address of the RIC cluster: " RIC_IP
+  echo
+else
+  echo "  Got ${RIC_IP}"
+fi
+
+echo "Reading SMO cluster IP address from envirronment variable \$SMO_IP."
+if [ -z $(echo ${SMO_IP} | grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}") ]; then
+  read -p "Not found or not in right format.  Enter the external IP address of the SMO cluster: " SMO_IP
+  echo
+else
+  echo "  Got ${SMO_IP}"
+fi
+
+echo
+echo "Ready to configure demo scripts and Helm charts using RIC cluster at ${RIC_IP} and SMO cluster at ${SMO_IP}."
+echo "If not correct, abort from this script, then export the correct values for the RIC_IP and SMO_IP environment variables."
+acknowledge
+
+export RIC_IP="$RIC_IP"
+export SMO_IP="$SMO_IP"
+
+# run fixes from git clone's root directory
+PREVDIR="$PWD"
+cd $(git rev-parse --show-toplevel)
+
+if [ ! "$(ls -A ./ric-dep)" ]; then
+  echo "ric-dep directory empty, running submodule command to fetch"
+  git submodule update --init --recursive
+  echo
+fi
+
+echo "Inject the RIC cluster IP address (${RIC_IP}) into NONRTRIC recipe..."
+#./nonrtric/RECIPE_EXAMPLE/example_recipe.yaml:137:192.168.130.80
+sed -i -e 's/"baseUrl":"http:\/\/192.168.130.80:32080\/a1mediator"/"baseUrl":"http:\/\/'"${RIC_IP}"':32080\/a1mediator"/g' ./nonrtric/RECIPE_EXAMPLE/example_recipe.yaml
+
+
+echo "Inject the RIC and SMO cluster IP addresses (${RIC_IP} and ${SMO_IP}) into RICAUX recipe..."
+#./ric-aux/RECIPE_EXAMPLE/example_recipe.yaml:40:ricip: "10.0.0.1"
+#./ric-aux/RECIPE_EXAMPLE/example_recipe.yaml:40:auxip: "10.0.0.1"
+sed -i -e 's/ricip: "10.0.0.1"/ricip: "'"${RIC_IP}"'"/g' ./ric-aux/RECIPE_EXAMPLE/example_recipe.yaml
+sed -i -e 's/auxip: "10.0.0.1"/auxip: "'"${SMO_IP}"'"/g' ./ric-aux/RECIPE_EXAMPLE/example_recipe.yaml
+
+echo "Inject the RIC and SMO cluster IP addresses (${RIC_IP} and ${SMO_IP}) into RIC recipe..."
+#ric-dep/RECIPE_EXAMPLE/example_recipe.yaml:39:  ricip: "10.0.0.1"
+#ric-dep/RECIPE_EXAMPLE/example_recipe.yaml:40:  auxip: "10.0.0.1"
+sed -i -e 's/ricip: "10.0.0.1"/ricip: "'"${RIC_IP}"'"/g' ./ric-dep/RECIPE_EXAMPLE/example_recipe.yaml
+sed -i -e 's/auxip: "10.0.0.1"/auxip: "'"${SMO_IP}"'"/g' ./ric-dep/RECIPE_EXAMPLE/example_recipe.yaml
+
+
+echo
+echo "Completed."
+cd "$PREVDIR"
diff --git a/demos/bronze/a1-ric.sh b/demos/bronze/a1-ric.sh
new file mode 100755 (executable)
index 0000000..7fd728c
--- /dev/null
@@ -0,0 +1,212 @@
+#!/bin/bash
+################################################################################
+#   Copyright (c) 2020 AT&T Intellectual Property.                             #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+
+#set -x
+
+acknowledge() {
+  echo "$1"
+  read  -n 1 -p "Press any key to continue, or CTRL-C to abort" mainmenuinput
+  echo
+}
+
+
+echo "This scripts demonstrates the Bronze release Traffic Steering use case, as well as the RIC part of the SMO A1 use case."
+DIRNAME="/tmp/tsflow-$(date +%Y%m%d%H%M)"
+mkdir $DIRNAME
+cd $DIRNAME
+
+echo "===>  Generating xApp on-boarding file"
+echo '{
+  "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" 
+}' > onboard.qp.url
+echo '{
+  "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"
+}' > onboard.qpd.url
+echo '{
+  "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"
+}' > onboard.ts.url
+
+
+echo "===>  On-boarding three xApps: Traffic Steering, Quality Predictor, and Quality Predictor Driver."
+curl --location --request POST "http://$(hostname):32080/onboard/api/v1/onboard/download" \
+     --header 'Content-Type: application/json' --data-binary "@./onboard.ts.url"
+curl --location --request POST "http://$(hostname):32080/onboard/api/v1/onboard/download" \
+     --header 'Content-Type: application/json' --data-binary "@./onboard.qp.url"
+curl --location --request POST "http://$(hostname):32080/onboard/api/v1/onboard/download" \
+     --header 'Content-Type: application/json' --data-binary "@./onboard.qpd.url"
+acknowledge "A \"Created\" status indicates on-boarding successful."
+
+echo "======> Listing on boarded xApps"
+curl --location --request GET "http://$(hostname):32080/onboard/api/v1/charts"
+acknowledge "Verify that the on-boarded xApps indeed are listed."
+
+echo "====>  Deploy xApps"
+curl --location --request POST "http://$(hostname):32080/appmgr/ric/v1/xapps" \
+     --header 'Content-Type: application/json' --data-raw '{"xappName": "qp"}'
+# response: {"instances":null,"name":"qp","status":"deployed","version":"1.0"}
+curl --location --request POST "http://$(hostname):32080/appmgr/ric/v1/xapps" \
+     --header 'Content-Type: application/json' --data-raw '{"xappName": "qpdriver"}'
+# response: {"instances":null,"name":"qpdriver","status":"deployed","version":"1.0"}
+curl --location --request POST "http://$(hostname):32080/appmgr/ric/v1/xapps" \
+     --header 'Content-Type: application/json' --data-raw '{"xappName": "trafficxapp"}'
+# response: {"instances":null,"name":"trafficxapp","status":"deployed","version":"1.0"}
+acknowledge "A \"deployed\" status indicates that the xApp has been deployed."
+
+
+echo "======> Status of xApps"
+kubectl get pods -n ricxapp
+
+
+echo -n "Waiting for all newly deployed xApp pod(s) reaching running state."
+POD_QP=""
+POD_QPD=""
+POD_TS=""
+while [ -z $POD_QP ] || [ -z $POD_QPD ] || [ -z $POD_TS ]; do
+  echo -n "."
+  sleep 5
+  POD_QP=$(kubectl get pods -n ricxapp | grep Running | grep "\-qp\-" | cut -f1 -d ' ')
+  POD_QPD=$(kubectl get pods -n ricxapp | grep Running | grep "\-qpdriver\-" | cut -f1 -d ' ')
+  POD_TS=$(kubectl get pods -n ricxapp | grep Running | grep "\-trafficxapp\-" | cut -f1 -d ' ')
+done
+echo && echo "Now all newly deployed xApp(s) have reached running state"
+
+
+POD_A1=$(kubectl get pods -n ricplt | grep Running | grep "\-a1mediator\-" | cut -f1 -d ' ')
+echo
+echo "To view the logs of the A1 midiator, run the following "
+echo "command in a separate terminal window:"
+echo "  kubectl logs -f -n ricplt $POD_A1"
+
+echo "To view the logs of the Traffic Steering xapp, run the following "
+echo "command in a separate terminal window:"
+echo "  kubectl logs -f -n ricxapp $POD_TS"
+
+acknowledge "When ready, "
+
+
+# populate DB
+echo && echo "===> Inject DBaaS (RNIB) with testing data for Traffic Steering test"
+if [ ! -e ts ]; then
+  git clone http://gerrit.o-ran-sc.org/r/ric-app/ts
+fi
+pushd "$(pwd)"
+cd ts/test/populatedb
+./populate_db.sh
+popd
+acknowledge "RNIB populated.  The Traffic Steering xApp's log should inicate that it is reading RAN data.  When ready for the next step, "
+
+
+POLICY_TYPE_ID="20008"
+echo "====>  Creating policy type ${POLICY_TYPE_ID} via A1"
+cat << EOF > ts-policy-type-${POLICY_TYPE_ID}.json
+{
+  "name": "tsapolicy",
+  "description": "tsa parameters",
+  "policy_type_id": ${POLICY_TYPE_ID},
+  "create_schema": {
+    "\$schema": "http://json-schema.org/draft-07/schema#",
+    "title": "TS Policy",
+    "description": "TS policy type",
+    "type": "object",
+    "properties": {
+      "threshold": {
+        "type": "integer",
+        "default": 0
+      }
+    },
+    "additionalProperties": false
+  }
+}
+EOF
+echo "A policy type definition file ts-policy-type-${POLICY_TYPE_ID}.json has been created."
+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."
+
+
+curl -v -X PUT "http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}" \
+  -H "accept: application/json" -H "Content-Type: application/json" \
+  -d @./ts-policy-type-${POLICY_TYPE_ID}.json
+# expect to see a 201
+acknowledge "A 201 response indicates that the new policy type has been created."
+
+
+echo "======> Listing policy types"
+curl -X GET --header "Content-Type: application/json" --header "accept: application/json" \
+  http://$(hostname):32080/a1mediator/a1-p/policytypes
+acknowledge "Verify that the policy type ${POLICY_TYPE_ID} is in the listing."
+
+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, " 
+
+POLICY_ID="tsapolicy145"
+if [ "${LOCAL_POLICY_INSTANCE}" = "Y" ]; then
+  echo && acknowledge "The next command will create a new policy instance.  Watch the logs of A1 Mediator and TS xApp"
+
+  echo "===> Deploy policy ID of ${POLICY_ID} of policy type ${POLICY_TYPE_ID}"
+  curl -X PUT --header "Content-Type: application/json" \
+    --data "{\"threshold\" : 5}" \
+    http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}/policies/${POLICY_ID}
+  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."
+
+
+  # get policy instances
+  echo "======> Listing policy instances"
+  curl -X GET --header "Content-Type: application/json" --header "accept: application/json" \
+    http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}/policies
+  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)."
+
+fi
+
+
+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"
+
+if [ "${LOCAL_POLICY_INSTANCE}" = "Y" ]; then
+  echo && echo "===> Deleting policy instance ${POLICY_ID} of type ${POLICY_TYPE_ID}"
+  acknowledge "The next command will delete a policy instance.  Watch the logs of A1 Mediator andd TS xApp"
+  curl -X DELETE --header "Content-Type: application/json" --header "accept: application/json" \
+  http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}/policies/${POLICY_ID}
+  sleep 5
+
+  echo && echo "======> Listing policy instances"
+  curl -X GET --header "Content-Type: application/json" --header "accept: application/json" \
+    http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}/policies
+fi
+
+echo && echo "===> Deleting policy type $POLICY_TYPE_ID"
+acknowledge "The next command will delete a policy type.  Watch the logs of A1 Mediator."
+curl -X DELETE -H "accept: application/json" -H "Content-Type: application/json" \
+  "http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}"
+sleep 5
+
+echo && echo "======> Listing policy types"
+curl -X GET --header "Content-Type: application/json" --header "accept: application/json" \
+  http://$(hostname):32080/a1mediator/a1-p/policytypes
+
+echo && echo "===> Undeploy the xApps"
+acknowledge "The next command will delete the TS, QP, and DPQ xApps."
+curl -H "Content-Type: application/json" -X DELETE \
+  http://$(hostname):32080/appmgr/ric/v1/xapps/trafficxapp
+curl -H "Content-Type: application/json" -X DELETE \
+  http://$(hostname):32080/appmgr/ric/v1/xapps/qp
+curl -H "Content-Type: application/json" -X DELETE \
+  http://$(hostname):32080/appmgr/ric/v1/xapps/qpdriver
+sleep 5
+
+echo && echo "======> Listing xApps"
+kubectl get pods -n ricxapp
+
+
+echo
+echo "That is all folks.  Thanks!"
diff --git a/demos/bronze/a1-smo.sh b/demos/bronze/a1-smo.sh
new file mode 100755 (executable)
index 0000000..98b4788
--- /dev/null
@@ -0,0 +1,71 @@
+#!/bin/bash
+################################################################################
+#   Copyright (c) 2020 AT&T Intellectual Property.                             #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+
+#set -x
+
+acknowledge() {
+  echo "$1"
+  read  -n 1 -p "Press any key to continue, or CTRL-C to abort" mainmenuinput
+  echo
+}
+
+curl -k -X POST -H 'Content-Type: application/json' -d '{ "serverTimeMs": 0, "count": 1 }' \
+  https://$(hostname):30226/events/A1-POLICY-AGENT-READ
+
+curl -X "POST" "http://$(hostname):30093/actuator/loggers/org.oransc.policyagent.clients.AsyncRestClient" -H "Content-Type: application/json; charset=utf-8"   -d $'{ "configuredLevel": "TRACE" }'
+sleep 2
+
+
+RIC_NAME="ric1"
+POLICY_TYPE_ID="20008"
+
+echo && acknowledge "Listing the RICs that the NonRTRIC manages:"
+curl -s http://$(hostname):30093/rics | jq .
+
+
+echo && acknowledge "Now we have finished all prep work, switch the demo sequence to the RIC side."
+
+echo "Back to SMO"
+echo -n "Waiting for policy type ${POLICY_TYPE_ID} to show up in policy type list of ${RIC_NAME}"
+PP=""
+while [ -z "$PP" ]; do
+  PP=$(curl -s http://$(hostname):30093/rics | jq '.[] | select(.ricName == "ric1") | .policyTypes | .[] ' | grep "${POLICY_TYPE_ID}")
+  echo -n '.'
+  sleep 1
+done
+echo
+curl -s http://$(hostname):30093/rics | jq .
+
+echo && acknowledge "The policy type is visiable, time to create policy instance.  After hitting any key to continue, look into the logs of the Traffic Steering xApp, it will receive the new policy and execute based on the new thhreshold value in the new policy instance."
+# add a policy instance
+POLICY_ID="tspolicy001"
+curl -v -X PUT --header "Content-Type: application/json" -d '{"threshold" : 5}' \
+  "http://$(hostname):30093/policy?id=${POLICY_ID}&ric=ric1&service=dummyService&type=${POLICY_TYPE_ID}"
+
+acknowledge "Check for policy instances of type $POLICY_TYPE_ID on $RIC_NAME"
+curl -s -X GET --header "Content-Type: application/json"  \
+  "http://$(hostname):30093/policy_ids?ric=ric1&type=$POLICY_TYPE_ID" | jq .
+
+
+echo && acknowledge "Now the SMO A1 flow is completed, we will start the cleaning"
+
+echo && acknowledge "Delete the policy instance.  Pay attention to the Traffic Steering xApp's log to see its processing of the policy deletion."
+curl -v -X DELETE --header "Content-Type: application/json"  "http://$(hostname):30093/policy?id=$POLICY_ID"
+
+
+echo "The SMO part of the A1 flow is complete.  Go back to the RIC part of the demo sequence to complete.  Thank you."
+
diff --git a/demos/bronze/o1-ric.sh b/demos/bronze/o1-ric.sh
new file mode 100755 (executable)
index 0000000..6a74389
--- /dev/null
@@ -0,0 +1,95 @@
+#!/bin/bash
+################################################################################
+#   Copyright (c) 2020 AT&T Intellectual Property.                             #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+
+#set -x
+
+acknowledge() {
+  echo "$1"
+  read  -n 1 -p "Press any key to continue, or CTRL to abort." mainmenuinput
+  echo
+}
+
+
+echo "This script demonstrates how to raise alarm in Nearr RT RIC using API call."
+
+DIRNAME="/tmp/o1-$(date +%Y%m%d%H%M)"
+mkdir $DIRNAME
+cd $DIRNAME
+
+
+aa_ipaddr="$(kubectl get svc --all-namespaces | grep alarmadapter-http | awk '{print $4}')"
+aa_port="$(kubectl get svc --all-namespaces | grep alarmadapter-http | awk '{print $6}' | cut -f1 -d'/')"
+
+echo && acknowledge "Next step: raising an alarm 8005 (network down CRITICAL) by calling AlarmAdapter API"
+cmd="POST"
+problem="8005"
+severity="CRITICAL"
+additionialinfo="network-down"
+identityinfo="abcd-123"
+# alarm-cli raise 8005 CRITICAL network-down abdc-123
+APICALL="curl -v -X $cmd http://$aa_ipaddr:$aa_port/ric/v1/alarms -d '{\"SpecificProblem\": $problem, \"PerceivedSeverity\": \"$severity\", \"AdditionalInfo\": \"$additionialinfo\", \"IdentifyingInfo\": \"$identityinfo\"}'"
+echo "running [$APICALL]"
+eval $APICALL
+sleep 5 
+echo "A 200 response means that the API call was successful."
+
+echo && acknowledge "Next step: raising an alarm 8006 (ethernet eth12 MAJOR) by calling AlarmAdapter API"
+cmd="POST"
+problem="8006"
+severity="MAJOR"
+additionialinfo="ethernet"
+identityinfo="eth12"
+# alarm-cli raise 8006 MAJOR ethernet eth12
+APICALL="curl -v -X $cmd http://$aa_ipaddr:$aa_port/ric/v1/alarms -d '{\"SpecificProblem\": $problem, \"PerceivedSeverity\": \"$severity\", \"AdditionalInfo\": \"$additionialinfo\", \"IdentifyingInfo\": \"$identityinfo\"}'"
+echo "running [$APICALL]"
+eval $APICALL
+sleep 5
+echo "A 200 response means that the API call was successful."
+
+
+echo && acknowledge "Take the next step in SMO terminal to see the alarm list that SMO receives from Near RT RIC.  After seeing the alarm list, come back and proceed with the next step in RIC." 
+
+#o1-cli.go --host 10.103.67.128 --action get --namespace urn:o-ran:ric:alarm:1.0
+echo && acknowledge "The next step: delete the alarm 8006 by calling AlarmAdapter API"
+cmd="DELETE"
+problem="8006"
+severity="MAJOR"
+additionialinfo="ethernet"
+identityinfo="eth12"
+# alarm-cli delete 8006 MAJOR ethernet eth12
+APICALL="curl -v -X $cmd http://$aa_ipaddr:$aa_port/ric/v1/alarms -d '{\"SpecificProblem\": $problem, \"PerceivedSeverity\": \"$severity\", \"AdditionalInfo\": \"$additionialinfo\", \"IdentifyingInfo\": \"$identityinfo\"}'"
+echo "running [$APICALL]"
+eval $APICALL
+sleep 10
+echo "A 200 response means that the API call was successful."
+
+echo && acknowledge "Take the next step in SMO terminal to see the alarm list that SMO receives from Near RT RIC.  After seeing the alarm list, come back and proceed with the next step in RIC."
+
+
+echo && acknowledge "Clearing all remaining alarms."
+cmd="DELETE"
+problem="8005"
+severity="CRITICAL"
+additionialinfo="network-down"
+identityinfo="abcd-123"
+# alarm-cli delete 8005 CRITICAL network-down abdc-123
+APICALL="curl -v -X $cmd http://$aa_ipaddr:$aa_port/ric/v1/alarms -d '{\"SpecificProblem\": $problem, \"PerceivedSeverity\": \"$severity\", \"AdditionalInfo\": \"$additionialinfo\", \"IdentifyingInfo\": \"$identityinfo\"}'"
+echo "running [$APICALL]"
+eval $APICALL
+sleep 5
+
+echo "That is all.  Thanks."
diff --git a/demos/bronze/o1-smo.sh b/demos/bronze/o1-smo.sh
new file mode 100755 (executable)
index 0000000..059335f
--- /dev/null
@@ -0,0 +1,123 @@
+#!/bin/bash
+################################################################################
+#   Copyright (c) 2020 AT&T Intellectual Property.                             #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+
+#set -x
+
+acknowledge() {
+  echo "$1"
+  read  -n 1 -p "Press any key to continue" mainmenuinput
+  echo
+}
+
+
+echo "This script demonstrates alarm communication between SMO (ONAP SDNC-SDNR) and"
+echo "Near RT RIC O1 Mediator over netconf interface"
+
+DIRNAME="/tmp/o1flow-$(date +%Y%m%d%H%M)"
+mkdir $DIRNAME
+cd $DIRNAME
+
+echo && echo "===> Add network topology node for Near RT RIC in SDNC-SDNR."
+
+# parameters used in API call into SDNC-SDNR
+controller="192.168.130.182"
+port="30267"
+protocol=http
+nodeId="near-rt-ric-01"
+basicAuth="admin:Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U"
+accept="Accept:application/json"
+content="Content-Type:application/json"
+
+echo && acknowledge "Next step: check initial list of nodes configured"
+echo "======> Check list of nodes"
+path="restconf/config/network-topology:network-topology/topology/topology-netconf"
+uri="$protocol://$controller:$port/$path"
+echo "curl -u $basicAuth $uri"
+curl -s -u $basicAuth $uri | jq .
+echo "You should see that pretty an empty list under the \"topology\" array."
+
+
+echo && echo "======> Prepare config file for the new node"
+cat << EOF > oam-connect-${nodeId}.json
+{
+  "node": [
+    {
+      "node-id": "near-rt-ric-01",
+      "netconf-node-topology:host": "192.168.130.80",
+      "netconf-node-topology:port": 30830,
+      "netconf-node-topology:username": "netconf",
+      "netconf-node-topology:password": "netconf",
+      "netconf-node-topology:reconnect-on-changed-schema": false,
+      "netconf-node-topology:sleep-factor": 1.5,
+      "netconf-node-topology:tcp-only": false,
+      "netconf-node-topology:connection-timeout-millis": 20000,
+      "netconf-node-topology:max-connection-attempts": 100,
+      "netconf-node-topology:between-attempts-timeout-millis": 2000,
+      "netconf-node-topology:keepalive-delay": 120
+    }
+  ]
+}
+EOF
+echo "The configuration file is created at: $(pwd)/oam-connect-${nodeId}.json"
+
+echo && echo "======> Create the node"
+acknowledge "Next step: create the topology node for near real time RIC"
+path="restconf/config/network-topology:network-topology/topology/topology-netconf"
+uri="$protocol://$controller:$port/$path/node/$nodeId"
+echo "curl $basicAuth -H $content -H $accept -X PUT -d @./oam-connect-${nodeId}.json $uri" 
+curl -i -u $basicAuth -H $content -H $accept -X PUT -d @./oam-connect-${nodeId}.json $uri
+echo "As the tradition, a 200 response means that the API call was successful."
+
+echo && acknowledge "Next step: check list of nodes configured"
+echo "======> Check list of nodes"
+path="restconf/config/network-topology:network-topology/topology/topology-netconf"
+uri="$protocol://$controller:$port/$path"
+echo "curl -u $basicAuth $uri"
+curl -s -u $basicAuth $uri | jq .
+echo "You should see that under the \"topology\" array, a node called \"neat-rt-ric-01\"."
+
+echo && acknowledge "Next step: check capabilities and supported models of the Near RT RIC node"
+echo "======> Querying capabilities and supported models of the Near RT RIC node"
+path="restconf/operational/network-topology:network-topology/topology/topology-netconf"
+uri="$protocol://$controller:$port/$path"
+echo "curl -u $basicAuth $uri"
+curl -s -u $basicAuth $uri | jq .
+echo "You should see bunch of capabilities advertiised by the near-rt-ric-01 node.  Among which the \"(urn:o-ran:ric:alarm:1.0?revision=2020-01-29)o-ran-sc-ric-alarm-v1\" is what we will use in the demo."
+
+echo && acknowledge "Next step: retrieving outstanding alarms at the Near RT RIC node"
+echo "======> Retrieving outstanding alarms at the Near RT RIC node"
+path="restconf/operational/network-topology:network-topology/topology/topology-netconf/node/$nodeId/yang-ext:mount/o-ran-sc-ric-alarm-v1:ric/alarms"
+uri="$protocol://$controller:$port/$path"
+echo "curl -u $basicAuth $uri"
+curl -u $basicAuth $uri | jq .
+acknowledge  "We should see two alarms, one MAJOR, the other CRITICAL.  Next step: move demo sequence to Near RT RIC for the next step, which will delete one alarm.  If you see a \"data-missing\" error, donot panic, it may mean that the near-rt-ric-01 node has nothing to report."
+
+
+echo && echo "======> Retrieving outstanding alarms at the Near RT RIC node, the second time"
+path="restconf/operational/network-topology:network-topology/topology/topology-netconf/node/$nodeId/yang-ext:mount/o-ran-sc-ric-alarm-v1:ric/alarms"
+uri="$protocol://$controller:$port/$path"
+echo "curl -u $basicAuth $uri"
+curl -u $basicAuth $uri | jq .
+acknowledge "We should see one alarm now, the MAJOR as the CRITICAL has been deleted. When ready to proceed,"
+
+
+echo && acknowledge "The O1 alarm demonstration is complete.  We now remove the Near RT RIC node to stop the netconf interface between OAM and Near RT RIC"
+
+echo "===> Remove network topology nodee for Near RT RIC"
+path="restconf/config/network-topology:network-topology/topology/topology-netconf/node/$nodeId"
+uri="$protocol://$controller:$port/$path"
+curl -u $basicAuth -X DELETE $uri | jq .
diff --git a/demos/bronze/odu-high.sh b/demos/bronze/odu-high.sh
new file mode 100755 (executable)
index 0000000..57359a8
--- /dev/null
@@ -0,0 +1,51 @@
+#!/bin/bash
+################################################################################
+#   Copyright (c) 2020 AT&T Intellectual Property.                             #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+
+acknowledge() {
+  echo "$1"
+  read  -n 1 -p "Press any key to continue, or CTRL-C to abort" mainmenuinput
+  echo
+}
+
+
+acknowledge "Make sure the env veriables __RIC_HOST__ and __ODU_HOST__ are populated with the hostname/IP address of the RIC cluster and ODU server."
+if [[ -z "$__RIC_HOST__" ]] || [[ -z "$__ODU_HOST__" ]]; then
+  echo 'Cannot proceed, must have the Hostname/IP of the RIC and ODU as env variables $__RIC_HOST__ and $__ODU_HOST__'
+  echo 'Use the address of the local NIC that the ODU binds for SCTP communication for $__ODU_HOST__'
+  exit
+fi
+
+acknowledge "O-DU HIGH code needs to be recompiled with the RIC and ODU server addresses."
+apt-get install libpcap-dev gcc-multilib g++-multilib libsctp-dev
+git clone http://gerrit.o-ran-sc.org/r/o-du/l2
+cd l2
+# Edit src/du_app/du_cfg.h for the IP addresses, both ODU and RIC (because ODU binds
+# to specific local port for SCTP, it needs the ODU IP address as well to decide which 
+# interface to bind.  use ifconfig to identify.)
+sed -i "s/^#define RIC_IP_V4_ADDR.*/#define RIC_IP_V4_ADDR \"${__RIC_HOST__}\"/g" src/du_app/du_cfg.h 
+sed -i "s/^#define DU_IP_V4_ADDR.*/#define DU_IP_V4_ADDR \"${__ODU_HOST__}\"/g" src/du_app/du_cfg.h 
+# RIC Bronze E2T's SCTP is at 36422, but exposed as nodeport on 36422
+sed -i "s/^#define RIC_PORT.*/#define RIC_PORT 32222/g" src/du_app/du_cfg.h 
+
+cd build/odu/
+make clean_odu odu MACHINE=BIT64 MODE=FDD
+
+acknowledge "The compilation has completed.  The next step is to run the O-DU HIGH executable.  We will see the ODU HIGH establishes SCTP connection to E2Termination, then sending E2 Setup Request and receiving E2 Setup Response.  It will be good to also start following the logs of the E2 Termination."
+cd ../../bin/odu
+./odu
+# we should see odu dumps communication parameters
+
diff --git a/demos/bronze/test-raise-alarm.sh b/demos/bronze/test-raise-alarm.sh
new file mode 100755 (executable)
index 0000000..aefc55b
--- /dev/null
@@ -0,0 +1,47 @@
+#!/bin/bash
+
+#set -x
+
+acknowledge() {
+  echo "$1"
+  read  -n 1 -p "Press any key to continue" mainmenuinput
+  echo
+}
+
+
+echo "This script demonstrates raising alarm within Near RT RIC"
+
+DIRNAME="/tmp/tsflow-$(date +%Y%m%d%H%M)"
+mkdir $DIRNAME
+cd $DIRNAME
+
+echo "===> Add network topology node for Near RT RIC"
+
+ipaddr="$(kubectl get svc --all-namespaces | grep alarmadapter-http | awk '{print $4}')"
+port="$(kubectl get svc --all-namespaces | grep alarmadapter-http | awk '{print $6}' | cut -f1 -d'/')"
+
+
+OP="POST"
+SpecificProblem="8006"
+PerceivedSeverity="MAJOR"
+AdditionalInfo="ethernet"
+IdentifyingInfo="eth1"
+curl -v -X $OP http://"$ipaddr":"$port"/ric/v1/alarms -d '{"SpecificProblem": "${SpecificProblem}", "PerceivedSeverity": "${PerceivedSeverity}", "AdditionalInfo": "${AdditionalInfo}", "IdentifyingInfo": "${IdentifyingInfo}"}'
+
+
+OP="POST"
+SpecificProblem="8005"
+PerceivedSeverity="CRITICAL"
+AdditionalInfo="network-down"
+IdentifyingInfo="switch 1"
+curl -v -X $OP http://"$ipaddr":"$port"/ric/v1/alarms -d '{"SpecificProblem": "${SpecificProblem}", "PerceivedSeverity": "${PerceivedSeverity}", "AdditionalInfo": "${AdditionalInfo}", "IdentifyingInfo": "${IdentifyingInfo}"}'
+
+
+
+
+OP="DELETE"
+SpecificProblem="8005"
+PerceivedSeverity="CRITICAL"
+AdditionalInfo="network-down"
+IdentifyingInfo="switch 1"
+curl -v -X $OP http://"$ipaddr":"$port"/ric/v1/alarms -d '{"SpecificProblem": "${SpecificProblem}", "PerceivedSeverity": "${PerceivedSeverity}", "AdditionalInfo": "${AdditionalInfo}", "IdentifyingInfo": "${IdentifyingInfo}"}'
diff --git a/demos/bronze/xapp-hw.sh b/demos/bronze/xapp-hw.sh
new file mode 100755 (executable)
index 0000000..31604fd
--- /dev/null
@@ -0,0 +1,163 @@
+#!/bin/bash
+################################################################################
+#   Copyright (c) 2020 AT&T Intellectual Property.                             #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+
+#set -x
+
+acknowledge() {
+  echo "$1"
+  read  -n 1 -p "Press any key to continue, or CTRL-C to abort" mainmenuinput
+  echo
+}
+
+
+acknowledge "This script demonstrates the deployment of HelloWorld xApp."
+DIRNAME="/tmp/tsflow-$(date +%Y%m%d%H%M)"
+mkdir $DIRNAME
+cd $DIRNAME
+
+echo "===>  Generating xApp on-boarding file"
+echo '{
+  "config-file.json_url": "https://gerrit.o-ran-sc.org/r/gitweb?p=ric-app/hw.git;a=blob_plain;f=init/config-file.json;hb=HEAD"
+}' > onboard.hw.url
+
+
+echo "===>  On-boarding xApps"
+curl --location --request POST "http://$(hostname):32080/onboard/api/v1/onboard/download" \
+     --header 'Content-Type: application/json' --data-binary "@./onboard.hw.url"
+acknowledge "A \"Created\" status indicates on-boarding successful."
+
+echo "======> Listing on boarded xApps"
+curl --location --request GET "http://$(hostname):32080/onboard/api/v1/charts"
+acknowledge "Verify that the on-boarded xApp indeed is listed."
+
+echo "===>  Deploy xApps"
+curl --location --request POST "http://$(hostname):32080/appmgr/ric/v1/xapps" \
+     --header 'Content-Type: application/json' --data-raw '{"xappName": "hwxapp"}'
+acknowledge "A \"deployed\" status indicates that the xApp has been deployed."
+# response: {"instances":null,"name":"trafficxapp","status":"deployed","version":"1.0"}
+
+POD_HW=""
+echo -n "Waiting for all newly deployed xApp pod(s) reaching running state."
+while [ -z $POD_HW ]; do
+  echo -n "."
+  sleep 5
+  POD_HW=$(kubectl get pods -n ricxapp | grep Running | grep "\-hwxapp\-" | cut -f1 -d ' ')
+done
+echo && echo "Now all newly deployed xApp(s) have reached running state"
+
+echo && echo "======> Status of xApps"
+kubectl get pods -n ricxapp
+
+POD_A1=$(kubectl get pods -n ricplt | grep Running | grep "\-a1mediator\-" | cut -f1 -d ' ')
+echo
+echo "To view the logs of the A1 midiator, run the following "
+echo "command in a separate terminal window:"
+echo "  kubectl logs -f -n ricplt $POD_A1"
+
+echo "To view the logs of the Hello World xapp, run the following "
+echo "command in a separate terminal window:"
+echo "  kubectl logs -f -n ricxapp $POD_HW"
+
+acknowledge "When ready, "
+
+
+
+echo "====>  Pushing policy type to A1"
+POLICY_TYPE_ID="1"
+cat << EOF > hw-policy-type-${POLICY_TYPE_ID}.json
+{
+  "name": "hwpolicy",
+  "description": "Hellow World policy type",
+  "policy_type_id": ${POLICY_TYPE_ID},
+  "create_schema": {
+    "\$schema": "http://json-schema.org/draft-07/schema#",
+    "title": "HW Policy",
+    "description": "HW policy type",
+    "type": "object",
+    "properties": {
+      "threshold": {
+        "type": "integer",
+        "default": 0
+      }
+    },
+    "additionalProperties": false
+  }
+}
+EOF
+echo "A policy type definition file hw-policy-type-${POLICY_TYPE_ID}.json has been created."
+echo && acknowledge "The next command will create a new policy type via A1 Mediator using this definition file.  Watch the logs of A1 Mediator."
+curl -v -X PUT "http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}" \
+  -H "accept: application/json" -H "Content-Type: application/json" \
+  -d @./hw-policy-type-${POLICY_TYPE_ID}.json
+# expect to see a 201
+acknowledge "A 201 response indicates that the new policy type has been created."
+
+echo && echo "======> Listing policy types"
+curl -X GET --header "Content-Type: application/json" --header "accept: application/json" \
+  http://$(hostname):32080/a1mediator/a1-p/policytypes
+acknowledge "Verify that the policy type ${POLICY_TYPE_ID} is in the listing."
+
+
+echo && acknowledge "The next command will create a new policy instance of the newly created policy type.  Watch the logs of A1 Mediator and HW xApp."
+POLICY_ID="hwpolicy321"
+echo && echo "===> Deploy policy ID of ${POLICY_ID} of policy type ${POLICY_TYPE_ID}"
+curl -v -X PUT --header "Content-Type: application/json" \
+  --data "{\"threshold\" : 9}" \
+  http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}/policies/${POLICY_ID}
+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."
+
+# get policy instances
+echo && echo "======> Listing policy instances of policy type ${POLICY_TYPE_ID}"
+curl -X GET --header "Content-Type: application/json" --header "accept: application/json" \
+  http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}/policies
+acknowledge "Verify that the new policy instance appears in the policy list"
+
+
+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 HW xApp, policy type, and policy instance from the Near RT RIC"
+
+echo && echo "===> Deleting policy instance ${POLICY_ID} of type ${POLICY_TYPE_ID}"
+acknowledge "The next command will delete a policy instance.  Watch the logs of A1 Mediator andd HW xApp"
+curl -X DELETE --header "Content-Type: application/json" --header "accept: application/json" \
+  http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}/policies/${POLICY_ID}
+sleep 5
+
+echo && echo "======> Listing policy instances"
+curl -X GET --header "Content-Type: application/json" --header "accept: application/json" \
+  http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}/policies
+
+echo && echo "===> Deleting policy type $POLICY_TYPE_ID"
+acknowledge "The next command will delete a policy type.  Watch the logs of TS xApp"
+curl -X DELETE -H "accept: application/json" -H "Content-Type: application/json" \
+  "http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}"
+sleep 5
+
+echo && echo "======> Listing policy types"
+curl -X GET --header "Content-Type: application/json" --header "accept: application/json" \
+  http://$(hostname):32080/a1mediator/a1-p/policytypes
+
+
+echo && echo "===> Undeploy the xApps"
+acknowledge "The next command will delete the HW xApp."
+curl -H "Content-Type: application/json" -X DELETE \
+  http://$(hostname):32080/appmgr/ric/v1/xapps/hwxapp
+sleep 5
+
+echo && echo "======> Listing xApps"
+kubectl get pods -n ricxapp
+
+echo
+echo "That is all folks.  Thanks!"
diff --git a/demos/bronze/xapp-ts.sh b/demos/bronze/xapp-ts.sh
new file mode 100755 (executable)
index 0000000..bd4dfb6
--- /dev/null
@@ -0,0 +1,188 @@
+#!/bin/bash
+################################################################################
+#   Copyright (c) 2020 AT&T Intellectual Property.                             #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+
+#set -x
+
+acknowledge() {
+  echo "$1"
+  read  -n 1 -p "Press any key to continue" mainmenuinput
+  echo
+}
+
+
+echo "This script demonstrates the phase one of the Bronze release Traffic Steering use case."
+DIRNAME="/tmp/tsflow-$(date +%Y%m%d%H%M)"
+mkdir $DIRNAME
+cd $DIRNAME
+
+echo "===>  Generating xApp on-boarding file"
+echo '{
+  "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" 
+}' > onboard.qp.url
+echo '{
+  "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"
+}' > onboard.qpd.url
+echo '{
+  "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"
+}' > onboard.ts.url
+
+
+echo "===>  On-boarding xApps"
+curl --location --request POST "http://$(hostname):32080/onboard/api/v1/onboard/download" \
+     --header 'Content-Type: application/json' --data-binary "@./onboard.ts.url"
+curl --location --request POST "http://$(hostname):32080/onboard/api/v1/onboard/download" \
+     --header 'Content-Type: application/json' --data-binary "@./onboard.qp.url"
+curl --location --request POST "http://$(hostname):32080/onboard/api/v1/onboard/download" \
+     --header 'Content-Type: application/json' --data-binary "@./onboard.qpd.url"
+
+echo "======> Listing on boarded xApps"
+curl --location --request GET "http://$(hostname):32080/onboard/api/v1/charts"
+
+
+echo "====>  Deploy xApps"
+curl --location --request POST "http://$(hostname):32080/appmgr/ric/v1/xapps" \
+     --header 'Content-Type: application/json' --data-raw '{"xappName": "qp"}'
+# response: {"instances":null,"name":"qp","status":"deployed","version":"1.0"}
+
+curl --location --request POST "http://$(hostname):32080/appmgr/ric/v1/xapps" \
+     --header 'Content-Type: application/json' --data-raw '{"xappName": "qpdriver"}'
+# response: {"instances":null,"name":"qpdriver","status":"deployed","version":"1.0"}
+
+curl --location --request POST "http://$(hostname):32080/appmgr/ric/v1/xapps" \
+     --header 'Content-Type: application/json' --data-raw '{"xappName": "trafficxapp"}'
+# response: {"instances":null,"name":"trafficxapp","status":"deployed","version":"1.0"}
+
+echo "======> Status of xApps"
+kubectl get pods -n ricxapp
+
+POD_QP=""
+POD_QPD=""
+POD_TS=""
+while [ -z $POD_QP ] || [ -z $POD_QPD ] || [ -z $POD_TS ]; do
+  echo "Not all new xApp pods are in running state."
+  sleep 5
+  POD_QP=$(kubectl get pods -n ricxapp | grep Running | grep "\-qp\-" | cut -f1 -d ' ')
+  POD_QPD=$(kubectl get pods -n ricxapp | grep Running | grep "\-qpdriver\-" | cut -f1 -d ' ')
+  POD_TS=$(kubectl get pods -n ricxapp | grep Running | grep "\-trafficxapp\-" | cut -f1 -d ' ')
+done
+
+
+POD_A1=$(kubectl get pods -n ricplt | grep Running | grep "\-a1mediator\-" | cut -f1 -d ' ')
+echo "To view the logs of the A1 midiator, run the following "
+echo "command in a separate terminal window:"
+echo "  kubectl logs -f -n ricplt $POD_A1"
+
+echo "To view the logs of the traffic steering xapp, run the following "
+echo "command in a separate terminal window:"
+echo "  kubectl logs -f -n ricplt $POD_TS"
+
+acknowledge ""
+
+
+# populate DB
+echo "===> Inject DBaas with testing data for Traffic Steering test"
+if [ ! -e ts ]; then
+  git clone http://gerrit.o-ran-sc.org/r/ric-xapp/ts
+fi
+pushd "$(pwd)"
+cd ts/test/populatedb
+./populate_db.sh
+popd
+
+
+echo "====>  Pushing policy type to A1"
+POLICY_TYPE_ID="20008"
+cat << EOF > ts-policy-type-${POLICY_TYPE_ID}.json
+{
+  "name": "tsapolicy",
+  "description": "tsa parameters",
+  "policy_type_id": ${POLICY_TYPE_ID},
+  "create_schema": {
+    "\$schema": "http://json-schema.org/draft-07/schema#",
+    "title": "TS Policy",
+    "description": "TS policy type",
+    "type": "object",
+    "properties": {
+      "threshold": {
+        "type": "integer",
+        "default": 0
+      }
+    },
+    "additionalProperties": false
+  }
+}
+EOF
+
+acknowledge "The next command will create a new policy type.  Watch the logs of A1 Mediator"
+
+curl -v -X PUT "http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}" \
+  -H "accept: application/json" -H "Content-Type: application/json" \
+  -d @./ts-policy-type-${POLICY_TYPE_ID}.json
+# expect to see a 201
+
+echo "======> Listing policy types"
+curl -X GET --header "Content-Type: application/json" --header "accept: application/json" \
+  http://$(hostname):32080/a1mediator/a1-p/policytypes
+
+acknowledge "The next command will create a new policy instance.  Watch the logs of A1 Mediator and TS xApp"
+
+POLICY_ID="tsapolicy145"
+echo "===> Deploy policy ID of ${POLICY_ID}" of policy type ${POLICY_TYPE_ID}"
+curl -X PUT --header "Content-Type: application/json" \
+  --data "{\"threshold\" : 5}" \
+  http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}/policies/${POLICY_ID}
+
+# get policy instances
+echo "======> Listing policy instances"
+curl -X GET --header "Content-Type: application/json" --header "accept: application/json" \
+  http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}/policies
+
+echo "Watch how TS processes the data retrieved from RNIB in TS logs"
+acknowledge "After done we will start the removal process"
+
+
+echo "===> Deleting policy instance"
+acknowledge "The next command will delete a policy instance.  Watch the logs of A1 Mediator andd TS xApp"
+curl -X DELETE --header "Content-Type: application/json" --header "accept: application/json" \
+  http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}/policies/${POLICY_ID}
+
+echo "======> Listing policy instances"
+curl -X GET --header "Content-Type: application/json" --header "accept: application/json" \
+  http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}/policies
+
+echo "===> Deleting policy type $POLICY_TYPE_ID"
+acknowledge "The next command will delete a policy type.  Watch the logs of TS xApp"
+curl -X DELETE -H "accept: application/json" -H "Content-Type: application/json" \
+  "http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}"
+
+echo "======> Listing policy types"
+curl -X GET --header "Content-Type: application/json" --header "accept: application/json" \
+  http://$(hostname):32080/a1mediator/a1-p/policytypes
+
+
+echo "===> Unddeploy the xApps"
+acknowledge "The next command will delete the TS, QP, and DPQ xApps."
+curl -H "Content-Type: application/json" -X DELETE \
+  http://$(hostname):32080/appmgr/ric/v1/xapps/trafficxapp
+curl -H "Content-Type: application/json" -X DELETE \
+  http://$(hostname):32080/appmgr/ric/v1/xapps/qp
+curl -H "Content-Type: application/json" -X DELETE \
+  http://$(hostname):32080/appmgr/ric/v1/xapps/qpdriver
+
+echo "======> Listing xApps"
+kubectl get pods -n ricxapp
+
index 4242ada..f259202 100644 (file)
@@ -33,6 +33,9 @@ Version history
 | **Date**           | **Ver.**           | **Author**         | **Comment**        |
 |                    |                    |                    |                    |
 +--------------------+--------------------+--------------------+--------------------+
+| 2020-08-01         | 0.2.1              | Lusheng Ji         |                    |
+|                    |                    |                    |                    |
++--------------------+--------------------+--------------------+--------------------+
 | 2020-06-20         | 0.2.0              | Lusheng Ji         |                    |
 |                    |                    |                    |                    |
 +--------------------+--------------------+--------------------+--------------------+
@@ -44,6 +47,14 @@ Version history
 Releases
 --------
 
+0.2.1
+^^^^^
+**Release designation**: Bronze Maintenance Release
+
+**Release Date**: 2020-08-01
+
+- Added demo scripts for Bronze "Get Started" demontsrations.
+
 0.2.0
 ^^^^^