blob: 3f8ac9deec33935c730612aba0a8a10793d74637 [file] [log] [blame]
Guillaume Lambert85b14922021-03-12 13:53:18 +01001#!/bin/sh
2
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +01003# Copyright (C) 2018 Amdocs, Bell Canada
4# Modifications Copyright (C) 2019 Samsung
5# Modifications Copyright (C) 2020 Nokia
6#
7# Licensed under the Apache License, Version 2.0 (the "License");
8# you may not use this file except in compliance with the License.
9# You may obtain a copy of the License at
10#
11# http://www.apache.org/licenses/LICENSE-2.0
12#
13# Unless required by applicable law or agreed to in writing, software
14# distributed under the License is distributed on an "AS IS" BASIS,
15# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16# See the License for the specific language governing permissions and
17# limitations under the License.
18#
19# Execute tags built to support the hands-on demo
20#
Guillaume Lambert785bc382021-03-09 21:41:30 +010021usage ()
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +010022{
guillaume.lambert7bf306e2021-09-08 12:03:22 +020023 echo "Usage: demo-k8s.sh <namespace> <command> [<parameters>] [execscript]"
24 echo " "
25 echo " demo-k8s.sh <namespace> init"
Krzysztof Kuzmicki0b06cdd2021-09-30 14:13:39 +020026 echo " - Execute both init_customer + distribute + registrySynch"
guillaume.lambert7bf306e2021-09-08 12:03:22 +020027 echo " "
28 echo " demo-k8s.sh <namespace> init_customer"
29 echo " - Create demo customer (Demonstration) and services, etc."
30 echo " "
Krzysztof Kuzmicki0b06cdd2021-09-30 14:13:39 +020031 echo " demo-k8s.sh <namespace> registrySynch [ repo <chart name> | path [ <path to helm charts> ]"
32 echo " [ <chart prefix> ] ]"
33 echo " - Synchronize chart museum inside of onap k8s cluster with"
34 echo " onap helm charts git repository (OOM)"
35 echo " By default following charts are synchronized:"
36 echo " - oom/kubernetes/dcaegen2-services/charts/,"
37 echo " - oom/kubernetes/common/common/charts,"
38 echo " - oom/kubernetes/common/postgres/charts/,"
39 echo " - oom/kubernetes/common/repositoryGenerator/charts/,"
40 echo " - oom/kubernetes/common/readinessCheck/charts/,"
41 echo " User is able also to synchronize custom helm charts by providing"
42 echo " flag 'path' and path to charts into command and chart name/s prefix for example:"
43 echo " demo-k8s.sh onap registrySynch /home/ubuntu/oom/kubernetes/common/postgres/charts/ postgres"
44 echo " - Synchronize chart museum inside of onap k8s cluster with"
45 echo " onap installation server 'local' helm charts repository"
46 echo " By default following charts are synchronized:"
47 echo " - local/certInitializer"
48 echo " User is able also to synchronize custom helm charts by providing"
49 echo " flag 'repo' and chart name in 'local' repo into command for example:"
50 echo " demo-k8s.sh onap registrySynch repo certInitializer"
51 echo " "
guillaume.lambert7bf306e2021-09-08 12:03:22 +020052 echo " demo-k8s.sh <namespace> distribute [<prefix>]"
53 echo " - Distribute demo models (demoVFW and demoVLB)"
54 echo " "
55 echo " demo-k8s.sh <namespace> preload <vnf_name> <module_name>"
56 echo " - Preload data for VNF for the <module_name>"
57 echo " "
58 echo " demo-k8s.sh <namespace> appc <module_name>"
59 echo " - provide APPC with vFW module mount point for closed loop"
60 echo " "
61 echo " demo-k8s.sh <namespace> init_robot [ <etc_hosts_prefix> ]"
62 echo " - Initialize robot after all ONAP VMs have started"
63 echo " "
64 echo " demo-k8s.sh <namespace> instantiateVFW"
65 echo " - Instantiate vFW module for the demo customer (DemoCust<uuid>)"
66 echo " "
67 echo " demo-k8s.sh <namespace> instantiateVFWdirectso csar_filename"
68 echo " - Instantiate vFW module using direct SO interface using previously distributed model "
Krzysztof Kuzmicki0b06cdd2021-09-30 14:13:39 +020069 echo " that is in /tmp/csar in robot container"
guillaume.lambert7bf306e2021-09-08 12:03:22 +020070 echo " "
Krzysztof Kuzmicki0b06cdd2021-09-30 14:13:39 +020071 echo " demo-k8s.sh <namespace> instantiateVLB_CDS"
72 echo " - Instantiate vLB module using CDS with a preloaded CBA "
73 echo " "
guillaume.lambert7bf306e2021-09-08 12:03:22 +020074 echo " demo-k8s.sh <namespace> deleteVNF <module_name from instantiateVFW>"
75 echo " - Delete the module created by instantiateVFW"
76 echo " "
77 echo " demo-k8s.sh <namespace> vfwclosedloop <pgn-ip-address>"
Krzysztof Kuzmicki0b06cdd2021-09-30 14:13:39 +020078 echo " - vFWCL: Sets the packet generator to high and low rates, and checks whether the policy "
79 echo " kicks in to modulate the rates back to medium"
guillaume.lambert7bf306e2021-09-08 12:03:22 +020080 echo " "
81 echo " demo-k8s.sh <namespace> <command> [<parameters>] execscript"
82 echo " - Optional parameter to execute user custom scripts located in scripts/demoscript directory"
83 echo " "
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +010084}
85
86# Check if execscript flag is used and drop it from input arguments
87
Guillaume Lambertba6e50f2021-04-26 21:46:56 +020088if [ "${!#}" = "execscript" ]; then
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +010089 set -- "${@:1:$#-1}"
90 execscript=true
91fi
92
93# Set the defaults
94
95echo "Number of parameters:"
96echo $#
97
Krzysztof Kuzmicki0b06cdd2021-09-30 14:13:39 +020098if [ $# -lt 2 ]; then
guillaume.lambert7bf306e2021-09-08 12:03:22 +020099 usage
100 exit
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +0100101fi
102
103NAMESPACE=$1
104shift
105
106##
107## if more than 1 tag is supplied, the must be provided with -i or -e
108##
109while [ $# -gt 0 ]
110do
guillaume.lambert7bf306e2021-09-08 12:03:22 +0200111 key="$1"
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +0100112 echo "KEY:"
113 echo $key
114
guillaume.lambert7bf306e2021-09-08 12:03:22 +0200115 case $key in
116 init_robot)
117 TAG="UpdateWebPage"
118 echo "WEB Site Password for user 'test': "
119 stty -echo
120 read WEB_PASSWORD
121 stty echo
122 if [ "$WEB_PASSWORD" = "" ]; then
123 echo ""
124 echo "WEB Password is required for user 'test'"
125 exit
126 fi
127 VARIABLES="$VARIABLES -v WEB_PASSWORD:$WEB_PASSWORD"
128 shift
129 if [ $# -eq 2 ];then
130 VARIABLES="$VARIABLES -v HOSTS_PREFIX:$1"
131 fi
132 shift
133 ;;
134 init)
135 TAG="InitDemo"
Krzysztof Kuzmicki0b06cdd2021-09-30 14:13:39 +0200136 dcaeRegistrySynch=true
guillaume.lambert7bf306e2021-09-08 12:03:22 +0200137 shift
138 ;;
139 vescollector)
140 TAG="vescollector"
141 shift
142 ;;
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +0100143 distribute_vcpe)
guillaume.lambert7bf306e2021-09-08 12:03:22 +0200144 TAG="distributeVCPE"
145 shift
146 ;;
147 init_customer)
148 TAG="InitCustomer"
149 shift
150 ;;
151 distribute)
152 TAG="InitDistribution"
153 shift
154 if [ $# -eq 1 ];then
155 VARIABLES="$VARIABLES -v DEMO_PREFIX:$1"
156 fi
157 shift
158 ;;
159 preload)
160 TAG="PreloadDemo"
161 shift
162 if [ $# -ne 2 ];then
163 echo "Usage: demo-k8s.sh <namespace> preload <vnf_name> <module_name>"
164 exit
165 fi
166 VARIABLES="$VARIABLES -v VNF_NAME:$1"
167 shift
168 VARIABLES="$VARIABLES -v MODULE_NAME:$1"
169 shift
170 ;;
171 appc)
172 TAG="APPCMountPointDemo"
173 shift
174 if [ $# -ne 1 ];then
175 echo "Usage: demo-k8s.sh <namespace> appc <module_name>"
176 exit
177 fi
178 VARIABLES="$VARIABLES -v MODULE_NAME:$1"
179 shift
180 ;;
181 instantiateVFW)
182 TAG="instantiateVFW"
183 VARIABLES="$VARIABLES -v GLOBAL_BUILD_NUMBER:$$"
184 shift
185 ;;
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +0100186 instantiateVFWdirectso)
187 TAG="instantiateVFWdirectso"
188 shift
189 if [ $# -ne 1 ];then
190 echo "Usage: demo-k8s.sh <namespace> instantiateVFWdirectso <csar_filename>"
191 exit
192 fi
193 VARIABLES="$VARIABLES -v CSAR_FILE:$1 -v GLOBAL_BUILD_NUMBER:$$"
194 shift
195 ;;
196 instantiateVLB_CDS)
197 TAG="instantiateVLB_CDS"
198 VARIABLES="$VARIABLES -v GLOBAL_BUILD_NUMBER:$$"
199 shift
200 ;;
guillaume.lambert7bf306e2021-09-08 12:03:22 +0200201 deleteVNF)
202 TAG="deleteVNF"
203 shift
204 if [ $# -ne 1 ];then
205 echo "Usage: demo-k8s.sh <namespace> deleteVNF <module_name from instantiateVFW>"
206 exit
207 fi
208 VARFILE=$1.py
209 VARIABLES="$VARIABLES -V /share/${VARFILE}"
210 shift
211 ;;
212 cds)
213 TAG="cds"
214 shift
215 ;;
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +0100216 distributeVFWNG)
217 TAG="distributeVFWNG"
218 shift
219 ;;
220 distributeDemoVFWDT)
221 TAG="DistributeDemoVFWDT"
222 shift
223 ;;
224 instantiateDemoVFWDT)
225 TAG="instantiateVFWDT"
226 shift
227 ;;
228 vfwclosedloop)
229 TAG="vfwclosedloop"
230 shift
231 VARIABLES="$VARIABLES -v PACKET_GENERATOR_HOST:$1 -v pkg_host:$1"
232 shift
233 ;;
Krzysztof Kuzmicki0b06cdd2021-09-30 14:13:39 +0200234 registrySynch)
235 dcaeRegistrySynch=true
236 echo $dcaeRegistrySynch
237 shift
238 echo $1
239 if [ "$1" = "path" ]; then
240 shift
241 customHelmChartsPath=$1
242 shift
243 customHelmChartsPref=$1
244 shift
245 elif [ "$1" = "repo" ]; then
246 shift
247 customHelmChartFromLocalRepo=$1
248 echo $customHelmChartFromLocalRepo
249 shift
250 else
251 echo "demo-k8s.sh <namespace> registrySynch { repo <chart name> | path [ <path to helm charts> ] [ <chart prefix> ] }"
252 fi
253 ;;
guillaume.lambert7bf306e2021-09-08 12:03:22 +0200254 *)
255 usage
256 exit
257 esac
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +0100258done
259
260set -x
261
262POD=$(kubectl --namespace $NAMESPACE get pods | sed 's/ .*//'| grep robot)
Krzysztof Kuzmicki0b06cdd2021-09-30 14:13:39 +0200263HELM_RELEASE=$(kubectl --namespace onap get pods | sed 's/ .*//' | grep robot | sed 's/-.*//')
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +0100264
265DIR=$(dirname "$0")
266SCRIPTDIR=scripts/demoscript
267
268ETEHOME=/var/opt/ONAP
269
270if [ $execscript ]; then
271 for script in $(ls -1 "$DIR/$SCRIPTDIR"); do
Guillaume Lambertd9017ef2021-03-08 21:38:31 +0100272 [ -f "$DIR/$SCRIPTDIR/$script" ] && [ -x "$DIR/$SCRIPTDIR/$script" ] && . "$DIR/$SCRIPTDIR/$script"
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +0100273 done
274fi
275
guillaume.lambertab71c572022-05-28 21:12:47 +0200276export GLOBAL_BUILD_NUMBER=$(kubectl --namespace $NAMESPACE exec ${POD} -- sh -c "ls -1q /share/logs/ | wc -l")
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +0100277OUTPUT_FOLDER=$(printf %04d $GLOBAL_BUILD_NUMBER)_demo_$key
278DISPLAY_NUM=$(($GLOBAL_BUILD_NUMBER + 90))
279
Krzysztof Kuzmicki0b06cdd2021-09-30 14:13:39 +0200280if [ $dcaeRegistrySynch ]; then
281 CURRENT_DIR=$PWD
282 PARENT_PATH=${0%/*}
283 cd $PARENT_PATH
284 cd ../contrib/tools
285 if [ -n "$customHelmChartsPath" ]; then
286 ./registry-initialize.sh -d $customHelmChartsPath -n $NAMESPACE -r $HELM_RELEASE -p customHelmChartsPref
287 elif [ -n "$customHelmChartFromLocalRepo" ]; then
288 ./registry-initialize.sh -h $customHelmChartFromLocalRepo -n $NAMESPACE -r $HELM_RELEASE
289 else
290 ./registry-initialize.sh -d ../../dcaegen2-services/charts/ -n $NAMESPACE -r $HELM_RELEASE
291 ./registry-initialize.sh -d ../../dcaegen2-services/charts/ -n $NAMESPACE -r $HELM_RELEASE -p common
292 ./registry-initialize.sh -h certInitializer -n $NAMESPACE -r $HELM_RELEASE
293 ./registry-initialize.sh -h repositoryGenerator -n $NAMESPACE -r $HELM_RELEASE
294 ./registry-initialize.sh -h readinessCheck -n $NAMESPACE -r $HELM_RELEASE
295 ./registry-initialize.sh -h dcaegen2-services-common -n $NAMESPACE -r $HELM_RELEASE
296 ./registry-initialize.sh -h postgres -n $NAMESPACE -r $HELM_RELEASE
297 ./registry-initialize.sh -h serviceAccount -n $NAMESPACE -r $HELM_RELEASE
Krzysztof Kuzmicki6c6269d2022-03-25 11:51:18 +0100298 ./registry-initialize.sh -h mongo -n $NAMESPACE -r $HELM_RELEASE
299 ./registry-initialize.sh -h common -n $NAMESPACE -r $HELM_RELEASE
Krzysztof Kuzmicki0b06cdd2021-09-30 14:13:39 +0200300 fi
301 cd $CURRENT_DIR
302fi
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +0100303
Krzysztof Kuzmicki0b06cdd2021-09-30 14:13:39 +0200304if [ -n "$TAG" ]; then
305 VARIABLEFILES="-V /share/config/robot_properties.py"
306 kubectl --namespace $NAMESPACE exec ${POD} -- ${ETEHOME}/runTags.sh ${VARIABLEFILES} ${VARIABLES} -d /share/logs/${OUTPUT_FOLDER} -i ${TAG} --display $DISPLAY_NUM 2> ${TAG}.out
guillaume.lambertab71c572022-05-28 21:12:47 +0200307fi