blob: 0e8f11afcc30a341b5f0fda1ad50afd5ab752e04 [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 " "
guillaume.lambert7bf306e2021-09-08 12:03:22 +020058 echo " demo-k8s.sh <namespace> init_robot [ <etc_hosts_prefix> ]"
59 echo " - Initialize robot after all ONAP VMs have started"
60 echo " "
61 echo " demo-k8s.sh <namespace> instantiateVFW"
62 echo " - Instantiate vFW module for the demo customer (DemoCust<uuid>)"
63 echo " "
64 echo " demo-k8s.sh <namespace> instantiateVFWdirectso csar_filename"
65 echo " - Instantiate vFW module using direct SO interface using previously distributed model "
Krzysztof Kuzmicki0b06cdd2021-09-30 14:13:39 +020066 echo " that is in /tmp/csar in robot container"
guillaume.lambert7bf306e2021-09-08 12:03:22 +020067 echo " "
Krzysztof Kuzmicki0b06cdd2021-09-30 14:13:39 +020068 echo " demo-k8s.sh <namespace> instantiateVLB_CDS"
69 echo " - Instantiate vLB module using CDS with a preloaded CBA "
70 echo " "
guillaume.lambert7bf306e2021-09-08 12:03:22 +020071 echo " demo-k8s.sh <namespace> deleteVNF <module_name from instantiateVFW>"
72 echo " - Delete the module created by instantiateVFW"
73 echo " "
74 echo " demo-k8s.sh <namespace> vfwclosedloop <pgn-ip-address>"
Krzysztof Kuzmicki0b06cdd2021-09-30 14:13:39 +020075 echo " - vFWCL: Sets the packet generator to high and low rates, and checks whether the policy "
76 echo " kicks in to modulate the rates back to medium"
guillaume.lambert7bf306e2021-09-08 12:03:22 +020077 echo " "
78 echo " demo-k8s.sh <namespace> <command> [<parameters>] execscript"
79 echo " - Optional parameter to execute user custom scripts located in scripts/demoscript directory"
80 echo " "
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +010081}
82
83# Check if execscript flag is used and drop it from input arguments
84
Guillaume Lambertba6e50f2021-04-26 21:46:56 +020085if [ "${!#}" = "execscript" ]; then
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +010086 set -- "${@:1:$#-1}"
87 execscript=true
88fi
89
90# Set the defaults
91
92echo "Number of parameters:"
93echo $#
94
Krzysztof Kuzmicki0b06cdd2021-09-30 14:13:39 +020095if [ $# -lt 2 ]; then
guillaume.lambert7bf306e2021-09-08 12:03:22 +020096 usage
97 exit
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +010098fi
99
100NAMESPACE=$1
101shift
102
103##
104## if more than 1 tag is supplied, the must be provided with -i or -e
105##
106while [ $# -gt 0 ]
107do
guillaume.lambert7bf306e2021-09-08 12:03:22 +0200108 key="$1"
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +0100109 echo "KEY:"
110 echo $key
111
guillaume.lambert7bf306e2021-09-08 12:03:22 +0200112 case $key in
113 init_robot)
114 TAG="UpdateWebPage"
115 echo "WEB Site Password for user 'test': "
116 stty -echo
117 read WEB_PASSWORD
118 stty echo
119 if [ "$WEB_PASSWORD" = "" ]; then
120 echo ""
121 echo "WEB Password is required for user 'test'"
122 exit
123 fi
124 VARIABLES="$VARIABLES -v WEB_PASSWORD:$WEB_PASSWORD"
125 shift
126 if [ $# -eq 2 ];then
127 VARIABLES="$VARIABLES -v HOSTS_PREFIX:$1"
128 fi
129 shift
130 ;;
131 init)
132 TAG="InitDemo"
Krzysztof Kuzmicki0b06cdd2021-09-30 14:13:39 +0200133 dcaeRegistrySynch=true
guillaume.lambert7bf306e2021-09-08 12:03:22 +0200134 shift
135 ;;
136 vescollector)
137 TAG="vescollector"
138 shift
139 ;;
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +0100140 distribute_vcpe)
guillaume.lambert7bf306e2021-09-08 12:03:22 +0200141 TAG="distributeVCPE"
142 shift
143 ;;
144 init_customer)
145 TAG="InitCustomer"
146 shift
147 ;;
148 distribute)
149 TAG="InitDistribution"
150 shift
151 if [ $# -eq 1 ];then
152 VARIABLES="$VARIABLES -v DEMO_PREFIX:$1"
153 fi
154 shift
155 ;;
156 preload)
157 TAG="PreloadDemo"
158 shift
159 if [ $# -ne 2 ];then
160 echo "Usage: demo-k8s.sh <namespace> preload <vnf_name> <module_name>"
161 exit
162 fi
163 VARIABLES="$VARIABLES -v VNF_NAME:$1"
164 shift
165 VARIABLES="$VARIABLES -v MODULE_NAME:$1"
166 shift
167 ;;
guillaume.lambert7bf306e2021-09-08 12:03:22 +0200168 instantiateVFW)
169 TAG="instantiateVFW"
170 VARIABLES="$VARIABLES -v GLOBAL_BUILD_NUMBER:$$"
171 shift
172 ;;
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +0100173 instantiateVFWdirectso)
174 TAG="instantiateVFWdirectso"
175 shift
176 if [ $# -ne 1 ];then
177 echo "Usage: demo-k8s.sh <namespace> instantiateVFWdirectso <csar_filename>"
178 exit
179 fi
180 VARIABLES="$VARIABLES -v CSAR_FILE:$1 -v GLOBAL_BUILD_NUMBER:$$"
181 shift
182 ;;
183 instantiateVLB_CDS)
184 TAG="instantiateVLB_CDS"
185 VARIABLES="$VARIABLES -v GLOBAL_BUILD_NUMBER:$$"
186 shift
187 ;;
guillaume.lambert7bf306e2021-09-08 12:03:22 +0200188 deleteVNF)
189 TAG="deleteVNF"
190 shift
191 if [ $# -ne 1 ];then
192 echo "Usage: demo-k8s.sh <namespace> deleteVNF <module_name from instantiateVFW>"
193 exit
194 fi
195 VARFILE=$1.py
196 VARIABLES="$VARIABLES -V /share/${VARFILE}"
197 shift
198 ;;
199 cds)
200 TAG="cds"
201 shift
202 ;;
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +0100203 distributeVFWNG)
204 TAG="distributeVFWNG"
205 shift
206 ;;
207 distributeDemoVFWDT)
208 TAG="DistributeDemoVFWDT"
209 shift
210 ;;
211 instantiateDemoVFWDT)
212 TAG="instantiateVFWDT"
213 shift
214 ;;
215 vfwclosedloop)
216 TAG="vfwclosedloop"
217 shift
218 VARIABLES="$VARIABLES -v PACKET_GENERATOR_HOST:$1 -v pkg_host:$1"
219 shift
220 ;;
Krzysztof Kuzmicki0b06cdd2021-09-30 14:13:39 +0200221 registrySynch)
222 dcaeRegistrySynch=true
223 echo $dcaeRegistrySynch
224 shift
225 echo $1
226 if [ "$1" = "path" ]; then
227 shift
228 customHelmChartsPath=$1
229 shift
230 customHelmChartsPref=$1
231 shift
232 elif [ "$1" = "repo" ]; then
233 shift
234 customHelmChartFromLocalRepo=$1
235 echo $customHelmChartFromLocalRepo
236 shift
237 else
238 echo "demo-k8s.sh <namespace> registrySynch { repo <chart name> | path [ <path to helm charts> ] [ <chart prefix> ] }"
239 fi
240 ;;
guillaume.lambert7bf306e2021-09-08 12:03:22 +0200241 *)
242 usage
243 exit
244 esac
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +0100245done
246
247set -x
248
249POD=$(kubectl --namespace $NAMESPACE get pods | sed 's/ .*//'| grep robot)
Krzysztof Kuzmicki0b06cdd2021-09-30 14:13:39 +0200250HELM_RELEASE=$(kubectl --namespace onap get pods | sed 's/ .*//' | grep robot | sed 's/-.*//')
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +0100251
252DIR=$(dirname "$0")
253SCRIPTDIR=scripts/demoscript
254
255ETEHOME=/var/opt/ONAP
256
257if [ $execscript ]; then
258 for script in $(ls -1 "$DIR/$SCRIPTDIR"); do
Guillaume Lambertd9017ef2021-03-08 21:38:31 +0100259 [ -f "$DIR/$SCRIPTDIR/$script" ] && [ -x "$DIR/$SCRIPTDIR/$script" ] && . "$DIR/$SCRIPTDIR/$script"
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +0100260 done
261fi
262
guillaume.lambertab71c572022-05-28 21:12:47 +0200263export GLOBAL_BUILD_NUMBER=$(kubectl --namespace $NAMESPACE exec ${POD} -- sh -c "ls -1q /share/logs/ | wc -l")
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +0100264OUTPUT_FOLDER=$(printf %04d $GLOBAL_BUILD_NUMBER)_demo_$key
265DISPLAY_NUM=$(($GLOBAL_BUILD_NUMBER + 90))
266
Krzysztof Kuzmicki0b06cdd2021-09-30 14:13:39 +0200267if [ $dcaeRegistrySynch ]; then
268 CURRENT_DIR=$PWD
269 PARENT_PATH=${0%/*}
270 cd $PARENT_PATH
271 cd ../contrib/tools
272 if [ -n "$customHelmChartsPath" ]; then
273 ./registry-initialize.sh -d $customHelmChartsPath -n $NAMESPACE -r $HELM_RELEASE -p customHelmChartsPref
274 elif [ -n "$customHelmChartFromLocalRepo" ]; then
275 ./registry-initialize.sh -h $customHelmChartFromLocalRepo -n $NAMESPACE -r $HELM_RELEASE
276 else
277 ./registry-initialize.sh -d ../../dcaegen2-services/charts/ -n $NAMESPACE -r $HELM_RELEASE
278 ./registry-initialize.sh -d ../../dcaegen2-services/charts/ -n $NAMESPACE -r $HELM_RELEASE -p common
279 ./registry-initialize.sh -h certInitializer -n $NAMESPACE -r $HELM_RELEASE
280 ./registry-initialize.sh -h repositoryGenerator -n $NAMESPACE -r $HELM_RELEASE
281 ./registry-initialize.sh -h readinessCheck -n $NAMESPACE -r $HELM_RELEASE
282 ./registry-initialize.sh -h dcaegen2-services-common -n $NAMESPACE -r $HELM_RELEASE
283 ./registry-initialize.sh -h postgres -n $NAMESPACE -r $HELM_RELEASE
284 ./registry-initialize.sh -h serviceAccount -n $NAMESPACE -r $HELM_RELEASE
Krzysztof Kuzmicki6c6269d2022-03-25 11:51:18 +0100285 ./registry-initialize.sh -h mongo -n $NAMESPACE -r $HELM_RELEASE
286 ./registry-initialize.sh -h common -n $NAMESPACE -r $HELM_RELEASE
Krzysztof Kuzmicki0b06cdd2021-09-30 14:13:39 +0200287 fi
288 cd $CURRENT_DIR
289fi
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +0100290
Krzysztof Kuzmicki0b06cdd2021-09-30 14:13:39 +0200291if [ -n "$TAG" ]; then
292 VARIABLEFILES="-V /share/config/robot_properties.py"
293 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 +0200294fi