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