Add Bronze Get Started demo scripts
[it/dep.git] / demos / bronze / o1-ric.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 to abort." mainmenuinput
23   echo
24 }
25
26
27 echo "This script demonstrates how to raise alarm in Nearr RT RIC using API call."
28
29 DIRNAME="/tmp/o1-$(date +%Y%m%d%H%M)"
30 mkdir $DIRNAME
31 cd $DIRNAME
32
33
34 aa_ipaddr="$(kubectl get svc --all-namespaces | grep alarmadapter-http | awk '{print $4}')"
35 aa_port="$(kubectl get svc --all-namespaces | grep alarmadapter-http | awk '{print $6}' | cut -f1 -d'/')"
36
37 echo && acknowledge "Next step: raising an alarm 8005 (network down CRITICAL) by calling AlarmAdapter API"
38 cmd="POST"
39 problem="8005"
40 severity="CRITICAL"
41 additionialinfo="network-down"
42 identityinfo="abcd-123"
43 # alarm-cli raise 8005 CRITICAL network-down abdc-123
44 APICALL="curl -v -X $cmd http://$aa_ipaddr:$aa_port/ric/v1/alarms -d '{\"SpecificProblem\": $problem, \"PerceivedSeverity\": \"$severity\", \"AdditionalInfo\": \"$additionialinfo\", \"IdentifyingInfo\": \"$identityinfo\"}'"
45 echo "running [$APICALL]"
46 eval $APICALL
47 sleep 5 
48 echo "A 200 response means that the API call was successful."
49
50 echo && acknowledge "Next step: raising an alarm 8006 (ethernet eth12 MAJOR) by calling AlarmAdapter API"
51 cmd="POST"
52 problem="8006"
53 severity="MAJOR"
54 additionialinfo="ethernet"
55 identityinfo="eth12"
56 # alarm-cli raise 8006 MAJOR ethernet eth12
57 APICALL="curl -v -X $cmd http://$aa_ipaddr:$aa_port/ric/v1/alarms -d '{\"SpecificProblem\": $problem, \"PerceivedSeverity\": \"$severity\", \"AdditionalInfo\": \"$additionialinfo\", \"IdentifyingInfo\": \"$identityinfo\"}'"
58 echo "running [$APICALL]"
59 eval $APICALL
60 sleep 5
61 echo "A 200 response means that the API call was successful."
62
63
64 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." 
65
66 #o1-cli.go --host 10.103.67.128 --action get --namespace urn:o-ran:ric:alarm:1.0
67 echo && acknowledge "The next step: delete the alarm 8006 by calling AlarmAdapter API"
68 cmd="DELETE"
69 problem="8006"
70 severity="MAJOR"
71 additionialinfo="ethernet"
72 identityinfo="eth12"
73 # alarm-cli delete 8006 MAJOR ethernet eth12
74 APICALL="curl -v -X $cmd http://$aa_ipaddr:$aa_port/ric/v1/alarms -d '{\"SpecificProblem\": $problem, \"PerceivedSeverity\": \"$severity\", \"AdditionalInfo\": \"$additionialinfo\", \"IdentifyingInfo\": \"$identityinfo\"}'"
75 echo "running [$APICALL]"
76 eval $APICALL
77 sleep 10
78 echo "A 200 response means that the API call was successful."
79
80 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."
81
82
83 echo && acknowledge "Clearing all remaining alarms."
84 cmd="DELETE"
85 problem="8005"
86 severity="CRITICAL"
87 additionialinfo="network-down"
88 identityinfo="abcd-123"
89 # alarm-cli delete 8005 CRITICAL network-down abdc-123
90 APICALL="curl -v -X $cmd http://$aa_ipaddr:$aa_port/ric/v1/alarms -d '{\"SpecificProblem\": $problem, \"PerceivedSeverity\": \"$severity\", \"AdditionalInfo\": \"$additionialinfo\", \"IdentifyingInfo\": \"$identityinfo\"}'"
91 echo "running [$APICALL]"
92 eval $APICALL
93 sleep 5
94
95 echo "That is all.  Thanks."