blob: 647f35e1bbe520bc93096f53518f11bb21d8dfe6 [file] [log] [blame]
demx8as620f0c4e2022-09-24 14:01:27 +02001#!/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 raised=$4;
26 domain="stndDefined";
27
28# exception for controller alarms
29if [ "${pnfType^^}" == "SDNR" ]
30 then
31 eventType="ONAP_SDNR_Controller";
32fi
33
34if [ "${raised,,}" != "cleared" ]
35 then
36 raised="new";
37fi
38
39declare -A mapping=(
40 [domain]=$domain
41 [controllerName]=$(hostname --fqdn)
42 [pnfId]=${pnfIdByType[$pnfType]}
43 [eventId]="${pnfIdByType[$pnfType]}_${interfaceByType[$pnfType]}_${alarmType}"
44 [eventType]=${eventType}
45 [type]=${pnfType^^}
46 [interface]=${interfaceByType[$pnfType]}
47 [alarm]=${alarmType}
48 [severity]=${severity}
49 [timestamp]=${timestamp}
50 [eventTime]=${eventTime}
51 [vendor]=${vendorsByType[$pnfType]^^}
52 [model]=${modelByType[$pnfType]}
53)
54
55echo "################################################################################";
56echo "# send NotifyNewAlarm or NotifyClearedAlarm";
57echo;
58for key in "${!mapping[@]}"
59do
60 #label=${${"$spaces$i"}:(-14)};
61 label=$spaces$key;
62 label=${label:(-16)};
63 echo "$label: ${mapping[$key]}";
64 if [ $key = "timestamp" ]; then
65 sequence="$sequence s/\"@$key@\"/${mapping[$key]}/g; "
66 else
67 sequence="$sequence s/@$key@/${mapping[$key]}/g; "
68 fi
69done
70echo;
71
72body="./json/examples/${pnfType^^}-${alarmType}-${severity}-${raised,,}-${domain}.json"
73template="./json/templates/$domain-r16-notify-${raised,,}-alarm.json"
74sed -e "$sequence" $template > $body;
75
76curl -i -k -u $basicAuthVes -X POST -d @${body} --header "Content-Type: application/json" $urlVes
77
78#curl -i -k -u "sample1:sample1" -X POST -d @./json/examples/NSKY-lossOfSignal-CRITICAL-stndDefined.json --header "Content-Type: application/json" https://localhost:8443/eventListener/v7