Describe the usage of this docker-compose
[oam.git] / solution / dev / client-scripts-ves-v7 / sendStndDefinedNotifyNewAlarm.sh
1 #!/bin/bash
2 ################################################################################
3 #
4 # Copyright 2022 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 #     https://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 an VES Message Event to DCAE
20
21 . config;
22       pnfType=${1,,};
23     alarmType=$2;
24      severity=$3;
25        domain="stndDefined";
26
27 # exception for controller alarms
28 if [ "${pnfType^^}" == "SDNR" ]
29   then
30     eventType="ONAP_SDNR_Controller";
31 fi
32
33 declare -A mapping=(
34     [domain]=$domain
35     [controllerName]=$(hostname --fqdn)
36     [pnfId]=${pnfIdByType[$pnfType]}
37     [eventId]="${pnfIdByType[$pnfType]}_${interfaceByType[$pnfType]}_${alarmType}"
38     [eventType]=${eventType}
39     [type]=${pnfType^^}
40     [interface]=${interfaceByType[$pnfType]}
41     [alarm]=${alarmType}
42     [severity]=${severity}
43     [timestamp]=${timestamp}
44     [eventTime]=${eventTime}
45     [vendor]=${vendorsByType[$pnfType]^^}
46     [model]=${modelByType[$pnfType]}
47 )
48
49 echo "################################################################################";
50 echo "# send NotifyNewAlarm";
51 echo;
52 for key in "${!mapping[@]}"
53 do
54   #label=${${"$spaces$i"}:(-14)};
55   label=$spaces$key;
56   label=${label:(-16)};
57   echo "$label: ${mapping[$key]}";
58   if [ $key = "timestamp" ]; then
59       sequence="$sequence s/\"@$key@\"/${mapping[$key]}/g; "
60   else
61       sequence="$sequence s/@$key@/${mapping[$key]}/g; "
62   fi
63 done
64 echo;
65
66 body="./json/examples/${pnfType^^}-${alarmType}-${severity}-${domain}.json"
67 sed -e "$sequence" ./json/templates/$domain-notifyNewAlarm.json > $body;
68
69 curl -i -k -u $basicAuthVes -X POST -d @${body} --header "Content-Type: application/json" $urlVes