blob: 439390525fc0707149d07b4f8105611c60fb93e6 [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"
26 echo " - Execute both init_customer + distribute"
27 echo " "
28 echo " demo-k8s.sh <namespace> init_customer"
29 echo " - Create demo customer (Demonstration) and services, etc."
30 echo " "
31 echo " demo-k8s.sh <namespace> distribute [<prefix>]"
32 echo " - Distribute demo models (demoVFW and demoVLB)"
33 echo " "
34 echo " demo-k8s.sh <namespace> preload <vnf_name> <module_name>"
35 echo " - Preload data for VNF for the <module_name>"
36 echo " "
37 echo " demo-k8s.sh <namespace> appc <module_name>"
38 echo " - provide APPC with vFW module mount point for closed loop"
39 echo " "
40 echo " demo-k8s.sh <namespace> init_robot [ <etc_hosts_prefix> ]"
41 echo " - Initialize robot after all ONAP VMs have started"
42 echo " "
43 echo " demo-k8s.sh <namespace> instantiateVFW"
44 echo " - Instantiate vFW module for the demo customer (DemoCust<uuid>)"
45 echo " "
46 echo " demo-k8s.sh <namespace> instantiateVFWdirectso csar_filename"
47 echo " - Instantiate vFW module using direct SO interface using previously distributed model "
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +010048 echo " that is in /tmp/csar in robot container"
guillaume.lambert7bf306e2021-09-08 12:03:22 +020049 echo " "
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +010050 echo " demo-k8s.sh <namespace> instantiateVLB_CDS"
51 echo " - Instantiate vLB module using CDS with a preloaded CBA "
52 echo " "
guillaume.lambert7bf306e2021-09-08 12:03:22 +020053 echo " demo-k8s.sh <namespace> deleteVNF <module_name from instantiateVFW>"
54 echo " - Delete the module created by instantiateVFW"
55 echo " "
56 echo " demo-k8s.sh <namespace> vfwclosedloop <pgn-ip-address>"
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +010057 echo " - vFWCL: Sets the packet generator to high and low rates, and checks whether the policy "
58 echo " kicks in to modulate the rates back to medium"
guillaume.lambert7bf306e2021-09-08 12:03:22 +020059 echo " "
60 echo " demo-k8s.sh <namespace> <command> [<parameters>] execscript"
61 echo " - Optional parameter to execute user custom scripts located in scripts/demoscript directory"
62 echo " "
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +010063}
64
65# Check if execscript flag is used and drop it from input arguments
66
Guillaume Lambertba6e50f2021-04-26 21:46:56 +020067if [ "${!#}" = "execscript" ]; then
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +010068 set -- "${@:1:$#-1}"
69 execscript=true
70fi
71
72# Set the defaults
73
74echo "Number of parameters:"
75echo $#
76
77if [ $# -lt 2 ];then
guillaume.lambert7bf306e2021-09-08 12:03:22 +020078 usage
79 exit
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +010080fi
81
82NAMESPACE=$1
83shift
84
85##
86## if more than 1 tag is supplied, the must be provided with -i or -e
87##
88while [ $# -gt 0 ]
89do
guillaume.lambert7bf306e2021-09-08 12:03:22 +020090 key="$1"
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +010091 echo "KEY:"
92 echo $key
93
guillaume.lambert7bf306e2021-09-08 12:03:22 +020094 case $key in
95 init_robot)
96 TAG="UpdateWebPage"
97 echo "WEB Site Password for user 'test': "
98 stty -echo
99 read WEB_PASSWORD
100 stty echo
101 if [ "$WEB_PASSWORD" = "" ]; then
102 echo ""
103 echo "WEB Password is required for user 'test'"
104 exit
105 fi
106 VARIABLES="$VARIABLES -v WEB_PASSWORD:$WEB_PASSWORD"
107 shift
108 if [ $# -eq 2 ];then
109 VARIABLES="$VARIABLES -v HOSTS_PREFIX:$1"
110 fi
111 shift
112 ;;
113 init)
114 TAG="InitDemo"
115 shift
116 ;;
117 vescollector)
118 TAG="vescollector"
119 shift
120 ;;
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +0100121 distribute_vcpe)
guillaume.lambert7bf306e2021-09-08 12:03:22 +0200122 TAG="distributeVCPE"
123 shift
124 ;;
125 init_customer)
126 TAG="InitCustomer"
127 shift
128 ;;
129 distribute)
130 TAG="InitDistribution"
131 shift
132 if [ $# -eq 1 ];then
133 VARIABLES="$VARIABLES -v DEMO_PREFIX:$1"
134 fi
135 shift
136 ;;
137 preload)
138 TAG="PreloadDemo"
139 shift
140 if [ $# -ne 2 ];then
141 echo "Usage: demo-k8s.sh <namespace> preload <vnf_name> <module_name>"
142 exit
143 fi
144 VARIABLES="$VARIABLES -v VNF_NAME:$1"
145 shift
146 VARIABLES="$VARIABLES -v MODULE_NAME:$1"
147 shift
148 ;;
149 appc)
150 TAG="APPCMountPointDemo"
151 shift
152 if [ $# -ne 1 ];then
153 echo "Usage: demo-k8s.sh <namespace> appc <module_name>"
154 exit
155 fi
156 VARIABLES="$VARIABLES -v MODULE_NAME:$1"
157 shift
158 ;;
159 instantiateVFW)
160 TAG="instantiateVFW"
161 VARIABLES="$VARIABLES -v GLOBAL_BUILD_NUMBER:$$"
162 shift
163 ;;
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +0100164 instantiateVFWdirectso)
165 TAG="instantiateVFWdirectso"
166 shift
167 if [ $# -ne 1 ];then
168 echo "Usage: demo-k8s.sh <namespace> instantiateVFWdirectso <csar_filename>"
169 exit
170 fi
171 VARIABLES="$VARIABLES -v CSAR_FILE:$1 -v GLOBAL_BUILD_NUMBER:$$"
172 shift
173 ;;
174 instantiateVLB_CDS)
175 TAG="instantiateVLB_CDS"
176 VARIABLES="$VARIABLES -v GLOBAL_BUILD_NUMBER:$$"
177 shift
178 ;;
guillaume.lambert7bf306e2021-09-08 12:03:22 +0200179 deleteVNF)
180 TAG="deleteVNF"
181 shift
182 if [ $# -ne 1 ];then
183 echo "Usage: demo-k8s.sh <namespace> deleteVNF <module_name from instantiateVFW>"
184 exit
185 fi
186 VARFILE=$1.py
187 VARIABLES="$VARIABLES -V /share/${VARFILE}"
188 shift
189 ;;
190 cds)
191 TAG="cds"
192 shift
193 ;;
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +0100194 distributeVFWNG)
195 TAG="distributeVFWNG"
196 shift
197 ;;
198 distributeDemoVFWDT)
199 TAG="DistributeDemoVFWDT"
200 shift
201 ;;
202 instantiateDemoVFWDT)
203 TAG="instantiateVFWDT"
204 shift
205 ;;
206 vfwclosedloop)
207 TAG="vfwclosedloop"
208 shift
209 VARIABLES="$VARIABLES -v PACKET_GENERATOR_HOST:$1 -v pkg_host:$1"
210 shift
211 ;;
guillaume.lambert7bf306e2021-09-08 12:03:22 +0200212 *)
213 usage
214 exit
215 esac
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +0100216done
217
218set -x
219
220POD=$(kubectl --namespace $NAMESPACE get pods | sed 's/ .*//'| grep robot)
221
222DIR=$(dirname "$0")
223SCRIPTDIR=scripts/demoscript
224
225ETEHOME=/var/opt/ONAP
226
227if [ $execscript ]; then
228 for script in $(ls -1 "$DIR/$SCRIPTDIR"); do
Guillaume Lambertd9017ef2021-03-08 21:38:31 +0100229 [ -f "$DIR/$SCRIPTDIR/$script" ] && [ -x "$DIR/$SCRIPTDIR/$script" ] && . "$DIR/$SCRIPTDIR/$script"
Sylvain Desbureaux16bdf242020-12-07 10:28:24 +0100230 done
231fi
232
233export GLOBAL_BUILD_NUMBER=$(kubectl --namespace $NAMESPACE exec ${POD} -- bash -c "ls -1q /share/logs/ | wc -l")
234OUTPUT_FOLDER=$(printf %04d $GLOBAL_BUILD_NUMBER)_demo_$key
235DISPLAY_NUM=$(($GLOBAL_BUILD_NUMBER + 90))
236
237VARIABLEFILES="-V /share/config/robot_properties.py"
238
239kubectl --namespace $NAMESPACE exec ${POD} -- ${ETEHOME}/runTags.sh ${VARIABLEFILES} ${VARIABLES} -d /share/logs/${OUTPUT_FOLDER} -i ${TAG} --display $DISPLAY_NUM 2> ${TAG}.out