blob: 8d4863b32f8b474ae1e0c6ef976a1969ad4f2be3 [file] [log] [blame]
demx8as6f58b3e12019-09-18 08:53:26 +02001#!/bin/bash
2################################################################################
3#
4# Copyright 2019 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#
demx8as686b92e82021-05-08 15:58:54 +020010# https://www.apache.org/licenses/LICENSE-2.0
demx8as6f58b3e12019-09-18 08:53:26 +020011#
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="fault";
26echo $pnfType;
27
28# exception for controller alarms
29if [ "${pnfType^^}" == "SDNR" ]
30 then
31 eventType="ONAP_SDNR_Controller";
32fi
33
34declare -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
50echo "################################################################################";
51echo "# send fault";
52echo;
53for key in "${!mapping[@]}"
54do
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
64done
65echo;
66
67body="./json/examples/${pnfType^^}-${alarmType}-${severity}-${domain}.json"
68sed -e "$sequence" ./json/templates/$domain.json > $body;
69
70curl -i -k -u $basicAuthVes -X POST -d @${body} --header "Content-Type: application/json" $urlVes