Update documentation
[oam.git] / solution / dev / ves-test-collector / client-scripts-ves-v7 / sendEventList.sh
1 #!/bin/bash
2 ################################################################################
3 #
4 # Copyright 2020 highstreet technologies GmbH and others
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9
10 #     http://www.apache.org/licenses/LICENSE-2.0
11
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17
18 ################################################################################
19 # Script to send a VES Message EventList to DCAE
20
21 . config;
22       pnfType=${1,,};
23     alarmType=$2;
24      severity=$3;
25        domain="fault";
26 echo $pnfType;
27
28 # exception for controller alarms
29 if [ "${pnfType^^}" == "SDNR" ]
30   then
31     eventType="ONAP_SDNR_Controller";
32 fi
33
34 declare -A mapping=(
35     [domain]=$domain
36     [controllerName]=$(hostname --fqdn)
37     [pnfId]=${pnfIdByType[$pnfType]}
38     [eventId]="${pnfIdByType[$pnfType]}_${interfaceByType[$pnfType]}_${alarmType}"
39     [eventType]=${eventType}
40     [type]=${pnfType^^}
41     [interface]=${interfaceByType[$pnfType]}
42     [alarm]=${alarmType}
43     [severity]=${severity}
44     [timestamp]=${timestamp}
45     [eventTime]=${eventTime}
46     [vendor]=${vendorsByType[$pnfType]^^}
47     [model]=${modelByType[$pnfType]}
48 )
49
50 echo "################################################################################";
51 echo "# send EventList wiht heartbeat and fault";
52 echo;
53 for key in "${!mapping[@]}"
54 do
55   #label=${${"$spaces$i"}:(-14)};
56   label=$spaces$key;
57   label=${label:(-16)};
58   echo "$label: ${mapping[$key]}";
59   if [ $key = "timestamp" ]; then
60       sequence="$sequence s/\"@$key@\"/${mapping[$key]}/g; "
61   else
62       sequence="$sequence s/@$key@/${mapping[$key]}/g; "
63   fi  
64 done
65 echo;
66
67 body="./json/examples/${pnfType^^}-${alarmType}-${severity}-event-list.json"
68 sed -e "$sequence" ./json/templates/event-list.json > $body;
69
70 curl -i -k -u $basicAuthVes -X POST -d @${body} --header "Content-Type: application/json" $urlVes