3 # ============LICENSE_START===============================================
4 # Copyright (C) 2023 Nordix Foundation. All rights reserved.
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
10 # http://www.apache.org/licenses/LICENSE-2.0
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 # ============LICENSE_END=================================================
21 echo "script-home: "$SD
39 echo "Usage: kafka-client-send-genfiles-file-ready.sh ves|file-ready <node-count> <num-of-events> <node-name-base> <file-extension> sftp|ftpes|https <num-servers> [hist]"
43 if [ $# -lt 7 ] && [ $# -gt 8 ]; then
47 if [ $TYPE == "sftp" ]; then
48 echo "sftp servers not yet supported"
49 elif [ $TYPE == "ftpes" ]; then
50 echo "ftpes servers not yet supported"
51 elif [ $TYPE == "https" ]; then
57 if [ $FILE_EXT != "xml.gz" ]; then
58 echo "only xml.gz format supported"
63 if [ ! -z "$HIST" ]; then
64 if [ $HIST != "hist" ]; then
70 if [ $VARIANT == "ves" ]; then
71 PUSHMSG="to ves-collector"
72 elif [ $VARIANT == "file-ready" ]; then
73 PUSHMSG="to file-ready topic"
76 # Unix time of 20230515.0700
77 # If the value is changed, make sure to set the same time to the env var GENERATED_FILE_START_TIME in kube-plt.yaml for the https-server
80 # If the value is changed, make sure to set the same value to the env var GENERATED_FILE_TIMEZONE in kube-plt.yaml for the https-server
85 if [ $VARIANT == "ves" ]; then
92 for (( i=0; i<$EVT_COUNT; i++)); do
94 if [ $CNTR -eq 0 ]; then
97 if [ $VARIANT == "ves" ]; then
98 echo '{"eventList": [' > .out.json
102 if [ "$HIST" == "" ]; then
103 echo "EVENT NO: $i for $NODE_COUNT NODES - 1 FILE PER EVENT"
105 echo "EVENT NO: $i for $NODE_COUNT NODES - $HIST_LEN FILES PER EVENT"
107 let STTIMEMS=$CURTIME*1000000
108 ST=$(date -d @$CURTIME +'%Y%m%d.%H%M')
109 let CURTIME=CURTIME+900
110 let CURTIMEMS=$CURTIME*1000000
111 ET=$(date -d @$CURTIME +'%H%M')
113 for (( j=0; j<$NODE_COUNT; j++)); do
115 if [ "$HIST" == "" ]; then
116 NO="$NODE_NAME_BASE-$j"
118 FN="A$ST$TIMEZONE-$ET${TIMEZONE}_$NO.$FILE_EXT"
119 let SRV_ID=$j%$SRV_COUNT
124 if [ $TYPE == "sftp" ]; then
125 SRV="ftp-sftp-$SRV_ID"
126 echo "FTP SERVER "$SRV
127 URL="sftp://onap:pano@$SRV:$SFTP_PORT/$FN"
128 elif [ $TYPE == "ftpes" ]; then
129 SRV="ftp-ftpes-$SRV_ID"
130 echo "FTP SERVER "$SRV
131 URL="ftpes://onap:pano@$SRV:$FTPES_PORT/$FN"
132 elif [ $TYPE == "https" ]; then
133 SRV="pm-https-server-$SRV_ID.pm-https-server.ran"
134 echo "HTTP SERVER "$SRV
135 URL="https://$SRV:$HTTPS_PORT/generatedfiles/$FN"
138 if [ $VARIANT == "ves" ] && [ $CNTR -gt 0 ]; then
139 echo "," >> .out.json
141 if [ $VARIANT == "ves" ]; then
142 EVT='{"commonEventHeader":{"domain":"notification","sequence":0,"eventName":"Noti_RnNode-Ericsson_FileReady","eventId":"FileReady_'$TCNTR'","priority":"Normal","version":"4.0.1","vesEventListenerVersion":"7.0.1","sourceName":"'$NO'","reportingEntityName":"'$NO'","lastEpochMicrosec":'$CURTIMEMS',"startEpochMicrosec":'$STTIMEMS',"timeZoneOffset":"UTC'$TIMEZONE'"},"notificationFields":{"notificationFieldsVersion":"2.0","changeType":"FileReady","changeIdentifier":"PM_MEAS_FILES","arrayOfNamedHashMap":[{"name":"'$FN'","hashMap":{"fileFormatType":"org.3GPP.32.435#measCollec","location":"'$URL'","fileFormatVersion":"V10","compression":"gzip"}}]}}'
144 EVT='{"event":{"commonEventHeader":{"sequence":0,"eventName":"Noti_RnNode-Ericsson_FileReady","sourceName":"'$NO'","lastEpochMicrosec":'$CURTIMEMS',"startEpochMicrosec":'$STTIMEMS',"timeZoneOffset":"UTC'$TIMEZONE'","changeIdentifier":"PM_MEAS_FILES"},"notificationFields":{"notificationFieldsVersion":"notificationFieldsVersion","changeType":"FileReady","changeIdentifier":"PM_MEAS_FILES","arrayOfNamedHashMap":[{"name":"'$FN'","hashMap":{"fileFormatType":"org.3GPP.32.435#measCollec","location":"'$URL'","fileFormatVersion":"V10","compression":"gzip"}}]}}}'
146 echo $EVT >> .out.json
148 NO="$NODE_NAME_BASE-$j"
150 let SRV_ID=$j%$SRV_COUNT
154 for(( k=95; k>=0; k-- )); do
157 CURTIME=$(($BEGINTIME+$FID*900))
158 let STTIMEMS=$CURTIME*1000000
159 ST=$(date -d @$CURTIME +'%Y%m%d.%H%M')
160 let CURTIME=CURTIME+900
161 let CURTIMEMS=$CURTIME*1000000
162 ET=$(date -d @$CURTIME +'%H%M')
163 if [ $FID -lt 0 ]; then
164 FN="NONEXISTING_$NO.$FILE_EXT"
166 FN="A$ST$TIMEZONE-$ET${TIMEZONE}_$NO.$FILE_EXT"
169 SRV="pm-https-server-$SRV_ID.pm-https-server.ran"
170 URL="https://$SRV:$HTTPS_PORT/files/$FN"
171 if [ "$EVT_FRAG" != "" ]; then
172 EVT_FRAG=$EVT_FRAG","
174 EVT_FRAG=$EVT_FRAG'{"name":"'$FN'","hashMap":{"fileFormatType":"org.3GPP.32.435#measCollec","location":"'$URL'","fileFormatVersion":"V10","compression":"gzip"}}'
177 if [ $VARIANT == "ves" ] && [ $CNTR -gt 0 ]; then
178 echo "," >> .out.json
180 if [ $VARIANT == "ves" ]; then
181 EVT='{"commonEventHeader":{"domain":"notification","sequence":0,"eventName":"Noti_RnNode-Ericsson_FileReady","eventId":"FileReady_'$TCNTR'","priority":"Normal","version":"4.0.1","vesEventListenerVersion":"7.0.1","sourceName":"'$NO'","reportingEntityName":"'$NO'","lastEpochMicrosec":'$CURTIMEMS',"startEpochMicrosec":'$STTIMEMS',"timeZoneOffset":"UTC'$TIMEZONE'"},"notificationFields":{"notificationFieldsVersion":"2.0","changeType":"FileReady","changeIdentifier":"PM_MEAS_FILES","arrayOfNamedHashMap":[{"name":"'$FN'","hashMap":{"fileFormatType":"org.3GPP.32.435#measCollec","location":"'$URL'","fileFormatVersion":"V10","compression":"gzip"}}]}}'
183 EVT='{"event":{"commonEventHeader":{"sequence":0,"eventName":"Noti_RnNode-Ericsson_FileReady","sourceName":"'$NO'","lastEpochMicrosec":'$CURTIMEMS',"startEpochMicrosec":'$STTIMEMS',"timeZoneOffset":"UTC'$TIMEZONE'","changeIdentifier":"PM_MEAS_FILES"},"notificationFields":{"notificationFieldsVersion":"notificationFieldsVersion","changeType":"FileReady","changeIdentifier":"PM_MEAS_FILES","arrayOfNamedHashMap":[{"name":"'$FN'","hashMap":{"fileFormatType":"org.3GPP.32.435#measCollec","location":"'$URL'","fileFormatVersion":"V10","compression":"gzip"}}]}}}'
185 echo $EVT >> .out.json
190 if [ $CNTR -ge $BATCHSIZE ]; then
191 echo "Pushing batch of $CNTR events $PUSHMSG"
192 if [ $VARIANT == "ves" ]; then
193 echo ']}' >> .out.json
194 curl -s -X POST http://ves-collector.nonrtric:8080/eventListener/v7/eventBatch --header 'Content-Type: application/json' --data-binary @.out.json
196 cat .out.json | kafka-console-producer --topic file-ready --broker-list kafka-1-kafka-bootstrap.nonrtric:9092
200 if [ $VARIANT == "ves" ]; then
201 echo '{"eventList": [' > .out.json
207 if [ $CNTR -ne 0 ]; then
208 echo "Pushing batch of $CNTR events $PUSHMSG"
209 if [ $VARIANT == "ves" ]; then
210 echo ']}' >> .out.json
211 curl -s -X POST http://ves-collector.nonrtric:8080/eventListener/v7/eventBatch --header 'Content-Type: application/json' --data-binary @.out.json
213 cat .out.json | kafka-console-producer --topic file-ready --broker-list kafka-1-kafka-bootstrap.nonrtric:9092
217 echo "Pushed $TCNTR events"