Update documentation
[oam.git] / solution / dev / ves-test-collector / client-scripts-ves-v7 / pnfRegister.sh
1 #!/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
10 #     http://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="pnfRegistration";
24
25 declare -A mapping=(
26     [controllerName]=$(hostname --fqdn)
27     [domain]=$domain
28     [eventId]="${pnfIdByType[$pnfType]}_${modelByType[$pnfType]}"
29     [eventTime]=${eventTime}
30     [eventType]=EventType5G
31     [pnfId]=${pnfIdByType[$pnfType]}
32     [type]=${pnfType^^}
33     [model]=${modelByType[$pnfType]}
34     [oamIp]=${oamIpByType[$pnfType]}
35     [macAddress]=02:42:f7:d4:62:ce
36     [oamIpV6]=0:0:0:0:0:ffff:a0a:0${oamIpByType[$pnfType]:(-2)}
37     [vendor]=${vendorsByType[$pnfType]^^}
38     [timestamp]=${timestamp}
39     [eventId]="${pnfIdByType[$pnfType]}_${modelByType[$pnfType]}"
40     [eventTime]=${eventTime}
41     [eventType]=EventType5G
42 )
43
44 echo "################################################################################";
45 echo "# send PNF registration";
46 echo;
47 for key in "${!mapping[@]}"
48 do
49   #label=${${"$spaces$i"}:(-14)};
50   label=$spaces$key;
51   label=${label:(-16)};
52   echo "$label: ${mapping[$key]}";
53   if [ $key = "timestamp" ]; then
54       sequence="$sequence s/\"@$key@\"/${mapping[$key]}/g; "
55   else
56       sequence="$sequence s/@$key@/${mapping[$key]}/g; "
57   fi  
58 done
59 echo;
60
61 body="./json/examples/${pnfType^^}-${domain}.json"
62 sed -e "$sequence" ./json/templates/$domain.json > $body;
63
64 curl -i -k -u $basicAuthVes -X POST -d @${body} --header "Content-Type: application/json" $urlVes