blob: 1644eded92178d3e3fea7776c8deb468c0efb221 [file] [log] [blame]
demx8as63dd6f0d2022-11-25 12:18:25 +01001#!/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 domain="stndDefined";
24 collectionEndTime=$(( $timeInS - $(( $timeInS % 900 )) ));
25 collectionStartTime=$(( collectionEndTime - 900 ));
26
27declare -A mapping=(
28 [domain]=$domain
29 [controllerName]=$(hostname --fqdn)
30 [pnfId]=${pnfIdByType[$pnfType]}
31 [eventId]="${pnfIdByType[$pnfType]}_${interfaceByType[$pnfType]}_${alarmType}"
32 [eventType]=${eventType}
33 [type]=${pnfType^^}
34 [timestamp]=${timestamp}
35 [eventTime]=${eventTime}
36 [startTime]=$( date -d @$collectionStartTime -u +%Y%m%d.%H%M+0000 )
37 [endTime]=$( date -d @$collectionEndTime -u +%H%M+0000 )
38)
39
40echo "################################################################################";
41echo "# send VES 3GPP FileReady";
42echo;
43for key in "${!mapping[@]}"
44do
45 #label=${${"$spaces$i"}:(-14)};
46 label=$spaces$key;
47 label=${label:(-16)};
48 echo "$label: ${mapping[$key]}";
49 if [ $key = "timestamp" ]; then
50 sequence="$sequence s/\"@$key@\"/${mapping[$key]}/g; "
51 else
52 sequence="$sequence s/@$key@/${mapping[$key]}/g; "
53 fi
54done
55echo;
56
57body="./json/examples/${pnfType^^}-${domain}-3gpp-file-ready.json"
58template="./json/templates/$domain-r16-notify-file-ready.json"
59sed -e "$sequence" $template > $body;
60
61curl -i -k -u $basicAuthVes -X POST -d @${body} --header "Content-Type: application/json" $urlVes