Add Bronze Get Started demo scripts
[it/dep.git] / demos / bronze / a1-smo.sh
1 #!/bin/bash
2 ################################################################################
3 #   Copyright (c) 2020 AT&T Intellectual Property.                             #
4 #                                                                              #
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                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
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 ################################################################################
17
18 #set -x
19
20 acknowledge() {
21   echo "$1"
22   read  -n 1 -p "Press any key to continue, or CTRL-C to abort" mainmenuinput
23   echo
24 }
25
26 curl -k -X POST -H 'Content-Type: application/json' -d '{ "serverTimeMs": 0, "count": 1 }' \
27   https://$(hostname):30226/events/A1-POLICY-AGENT-READ
28
29 curl -X "POST" "http://$(hostname):30093/actuator/loggers/org.oransc.policyagent.clients.AsyncRestClient" -H "Content-Type: application/json; charset=utf-8"   -d $'{ "configuredLevel": "TRACE" }'
30 sleep 2
31
32
33 RIC_NAME="ric1"
34 POLICY_TYPE_ID="20008"
35
36 echo && acknowledge "Listing the RICs that the NonRTRIC manages:"
37 curl -s http://$(hostname):30093/rics | jq .
38
39
40 echo && acknowledge "Now we have finished all prep work, switch the demo sequence to the RIC side."
41
42 echo "Back to SMO"
43 echo -n "Waiting for policy type ${POLICY_TYPE_ID} to show up in policy type list of ${RIC_NAME}"
44 PP=""
45 while [ -z "$PP" ]; do
46   PP=$(curl -s http://$(hostname):30093/rics | jq '.[] | select(.ricName == "ric1") | .policyTypes | .[] ' | grep "${POLICY_TYPE_ID}")
47   echo -n '.'
48   sleep 1
49 done
50 echo
51 curl -s http://$(hostname):30093/rics | jq .
52
53 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."
54 # add a policy instance
55 POLICY_ID="tspolicy001"
56 curl -v -X PUT --header "Content-Type: application/json" -d '{"threshold" : 5}' \
57   "http://$(hostname):30093/policy?id=${POLICY_ID}&ric=ric1&service=dummyService&type=${POLICY_TYPE_ID}"
58
59 acknowledge "Check for policy instances of type $POLICY_TYPE_ID on $RIC_NAME"
60 curl -s -X GET --header "Content-Type: application/json"  \
61   "http://$(hostname):30093/policy_ids?ric=ric1&type=$POLICY_TYPE_ID" | jq .
62
63
64 echo && acknowledge "Now the SMO A1 flow is completed, we will start the cleaning"
65
66 echo && acknowledge "Delete the policy instance.  Pay attention to the Traffic Steering xApp's log to see its processing of the policy deletion."
67 curl -v -X DELETE --header "Content-Type: application/json"  "http://$(hostname):30093/policy?id=$POLICY_ID"
68
69
70 echo "The SMO part of the A1 flow is complete.  Go back to the RIC part of the demo sequence to complete.  Thank you."
71