Add to_directory method to relevant object classes
[oam.git] / code / client-scripts-ves-v7 / sendStndDefinedNotifyFileReady.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    domain="stndDefined";
24    collectionEndTime=$(( $timeInS - $(( $timeInS % 900 )) ));
25    collectionStartTime=$(( collectionEndTime - 900 ));
26
27 declare -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
40 echo "################################################################################";
41 echo "# send VES 3GPP FileReady";
42 echo;
43 for key in "${!mapping[@]}"
44 do
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
54 done
55 echo;
56
57 body="./json/examples/${pnfType^^}-${domain}-3gpp-file-ready.json"
58 template="./json/templates/$domain-r16-notify-file-ready.json"
59 sed -e "$sequence" $template > $body;
60
61 curl -i -k -u $basicAuthVes -X POST -d @${body} --header "Content-Type: application/json" $urlVes