blob: 5b540b2b1e5e640145c67b325bd0ae43cb5745f6 [file] [log] [blame]
Gary Wu57ceeeb2018-11-02 13:48:21 -07001#!/bin/bash
2# Copyright (C) 2018 Amdocs, Bell Canada
kaihlavi33771f42019-04-16 14:53:04 +03003# Modifications Copyright (C) 2019 Samsung
deen19854a50a3b2020-05-12 15:28:49 +02004# Modifications Copyright (C) 2020 Nokia
vaibhavjayas002fb992018-08-31 06:22:26 +00005#
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.
Mandeep Khindaba48b012017-10-26 17:46:43 +000017#
kaihlavi33771f42019-04-16 14:53:04 +030018# Execute tags built to support the hands-on demo
Mandeep Khindaba48b012017-10-26 17:46:43 +000019#
20function usage
21{
marekpl1b6baa42019-08-02 18:11:42 +020022 echo "Usage: demo-k8s.sh <namespace> <command> [<parameters>] [execscript]"
Mandeep Khindaba48b012017-10-26 17:46:43 +000023 echo " "
kaihlavi33771f42019-04-16 14:53:04 +030024 echo " demo-k8s.sh <namespace> init"
Mandeep Khindaba48b012017-10-26 17:46:43 +000025 echo " - Execute both init_customer + distribute"
26 echo " "
kaihlavi33771f42019-04-16 14:53:04 +030027 echo " demo-k8s.sh <namespace> init_customer"
Mandeep Khindaba48b012017-10-26 17:46:43 +000028 echo " - Create demo customer (Demonstration) and services, etc."
29 echo " "
kaihlavi33771f42019-04-16 14:53:04 +030030 echo " demo-k8s.sh <namespace> distribute [<prefix>]"
Mandeep Khindaba48b012017-10-26 17:46:43 +000031 echo " - Distribute demo models (demoVFW and demoVLB)"
32 echo " "
kaihlavi33771f42019-04-16 14:53:04 +030033 echo " demo-k8s.sh <namespace> preload <vnf_name> <module_name>"
Mandeep Khindaba48b012017-10-26 17:46:43 +000034 echo " - Preload data for VNF for the <module_name>"
35 echo " "
kaihlavi33771f42019-04-16 14:53:04 +030036 echo " demo-k8s.sh <namespace> appc <module_name>"
37 echo " - provide APPC with vFW module mount point for closed loop"
Mandeep Khindaba48b012017-10-26 17:46:43 +000038 echo " "
kaihlavi33771f42019-04-16 14:53:04 +030039 echo " demo-k8s.sh <namespace> init_robot [ <etc_hosts_prefix> ]"
40 echo " - Initialize robot after all ONAP VMs have started"
Mandeep Khindaba48b012017-10-26 17:46:43 +000041 echo " "
kaihlavi33771f42019-04-16 14:53:04 +030042 echo " demo-k8s.sh <namespace> instantiateVFW"
43 echo " - Instantiate vFW module for the demo customer (DemoCust<uuid>)"
Mandeep Khindaba48b012017-10-26 17:46:43 +000044 echo " "
Brian Freeman98e80ad2019-05-06 12:12:36 -050045 echo " demo-k8s.sh <namespace> instantiateVFWdirectso csar_filename"
46 echo " - Instantiate vFW module using direct SO interface using previously distributed model "
47 echo " that is in /tmp/csar in robot container"
48 echo " "
Abdelmuhaimen Seaudi1d36d592019-09-18 08:44:00 +000049 echo " demo-k8s.sh <namespace> instantiateVLB_CDS"
50 echo " - Instantiate vLB module using CDS with a preloaded CBA "
51 echo " "
kaihlavi33771f42019-04-16 14:53:04 +030052 echo " demo-k8s.sh <namespace> deleteVNF <module_name from instantiateVFW>"
53 echo " - Delete the module created by instantiateVFW"
Alexis de Talhouëtda89d732017-12-07 16:23:15 -050054 echo " "
deen19854a50a3b2020-05-12 15:28:49 +020055 echo " demo-k8s.sh <namespace> heatbridge <stack_name> <vnf_type> <service_type> <oam-ip-address_env_parameter>"
56 echo " - Run heatbridge against the stack for the given vnf type and service type"
Gary Wu57ceeeb2018-11-02 13:48:21 -070057 echo " "
kaihlavi33771f42019-04-16 14:53:04 +030058 echo " demo-k8s.sh <namespace> vfwclosedloop <pgn-ip-address>"
marekpl1b6baa42019-08-02 18:11:42 +020059 echo " - vFWCL: Sets the packet generator to high and low rates, and checks whether the policy "
60 echo " kicks in to modulate the rates back to medium"
61 echo " "
marekpl580d9332019-08-13 10:41:34 +020062 echo " demo-k8s.sh <namespace> <command> [<parameters>] execscript"
marekpl1b6baa42019-08-02 18:11:42 +020063 echo " - Optional parameter to execute user custom scripts located in scripts/demoscript directory"
Gary Wu57ceeeb2018-11-02 13:48:21 -070064 echo " "
Mandeep Khindaba48b012017-10-26 17:46:43 +000065}
66
marekpl1b6baa42019-08-02 18:11:42 +020067# Check if execscript flag is used and drop it from input arguments
68
69if [[ "${!#}" == "execscript" ]]; then
70 set -- "${@:1:$#-1}"
71 execscript=true
72fi
73
Mandeep Khindaba48b012017-10-26 17:46:43 +000074# Set the defaults
Brian Freemandf2baf02018-04-23 17:24:35 -050075
Gary Wuab5a0b62019-06-25 09:32:28 -070076echo "Number of parameters:"
Brian Freemandf2baf02018-04-23 17:24:35 -050077echo $#
78
79if [ $# -lt 2 ];then
Mandeep Khindaba48b012017-10-26 17:46:43 +000080 usage
81 exit
82fi
BorislavG4e8014a2018-02-27 15:04:26 +000083
84NAMESPACE=$1
85shift
86
Mandeep Khindaba48b012017-10-26 17:46:43 +000087##
88## if more than 1 tag is supplied, the must be provided with -i or -e
89##
Brian Freemandf2baf02018-04-23 17:24:35 -050090while [ $# -gt 0 ]
Mandeep Khindaba48b012017-10-26 17:46:43 +000091do
Brian Freemandf2baf02018-04-23 17:24:35 -050092 key="$1"
93 echo "KEY:"
94 echo $key
Mandeep Khindaba48b012017-10-26 17:46:43 +000095
96 case $key in
97 init_robot)
98 TAG="UpdateWebPage"
99 read -s -p "WEB Site Password for user 'test': " WEB_PASSWORD
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
Mandeep Khinda15b8fc52018-04-17 03:26:26 +0000107 if [ $# -eq 2 ];then
Brian Freemanbe7845b2018-05-15 17:49:50 -0500108 VARIABLES="$VARIABLES -v HOSTS_PREFIX:$1"
Mandeep Khinda15b8fc52018-04-17 03:26:26 +0000109 fi
110 shift
Mandeep Khindaba48b012017-10-26 17:46:43 +0000111 ;;
112 init)
113 TAG="InitDemo"
114 shift
115 ;;
Brian Freeman53949ab2019-12-06 11:39:05 -0500116 distribute_vcpe)
117 TAG="distributeVCPE"
118 shift
119 ;;
Mandeep Khindaba48b012017-10-26 17:46:43 +0000120 init_customer)
121 TAG="InitCustomer"
122 shift
123 ;;
124 distribute)
125 TAG="InitDistribution"
126 shift
127 if [ $# -eq 1 ];then
Brian Freemanbe7845b2018-05-15 17:49:50 -0500128 VARIABLES="$VARIABLES -v DEMO_PREFIX:$1"
Mandeep Khindaba48b012017-10-26 17:46:43 +0000129 fi
130 shift
131 ;;
132 preload)
133 TAG="PreloadDemo"
134 shift
135 if [ $# -ne 2 ];then
kaihlavi33771f42019-04-16 14:53:04 +0300136 echo "Usage: demo-k8s.sh <namespace> preload <vnf_name> <module_name>"
Mandeep Khindaba48b012017-10-26 17:46:43 +0000137 exit
138 fi
Brian Freemanbe7845b2018-05-15 17:49:50 -0500139 VARIABLES="$VARIABLES -v VNF_NAME:$1"
Mandeep Khindaba48b012017-10-26 17:46:43 +0000140 shift
Brian Freemanbe7845b2018-05-15 17:49:50 -0500141 VARIABLES="$VARIABLES -v MODULE_NAME:$1"
Mandeep Khindaba48b012017-10-26 17:46:43 +0000142 shift
143 ;;
144 appc)
Brian Freemanbe7845b2018-05-15 17:49:50 -0500145 TAG="APPCMountPointDemo"
146 shift
147 if [ $# -ne 1 ];then
kaihlavi33771f42019-04-16 14:53:04 +0300148 echo "Usage: demo-k8s.sh <namespace> appc <module_name>"
Brian Freemanbe7845b2018-05-15 17:49:50 -0500149 exit
150 fi
151 VARIABLES="$VARIABLES -v MODULE_NAME:$1"
152 shift
153 ;;
Mandeep Khindaba48b012017-10-26 17:46:43 +0000154 instantiateVFW)
155 TAG="instantiateVFW"
156 VARIABLES="$VARIABLES -v GLOBAL_BUILD_NUMBER:$$"
157 shift
158 ;;
Brian Freeman98e80ad2019-05-06 12:12:36 -0500159 instantiateVFWdirectso)
160 TAG="instantiateVFWdirectso"
161 shift
162 if [ $# -ne 1 ];then
163 echo "Usage: demo-k8s.sh <namespace> instantiateVFWdirectso <csar_filename>"
164 exit
165 fi
166 VARIABLES="$VARIABLES -v CSAR_FILE:$1 -v GLOBAL_BUILD_NUMBER:$$"
167 shift
168 ;;
Abdelmuhaimen Seaudi1d36d592019-09-18 08:44:00 +0000169 instantiateVLB_CDS)
170 TAG="instantiateVLB_CDS"
171 VARIABLES="$VARIABLES -v GLOBAL_BUILD_NUMBER:$$"
172 shift
173 ;;
Mandeep Khindaba48b012017-10-26 17:46:43 +0000174 deleteVNF)
175 TAG="deleteVNF"
176 shift
177 if [ $# -ne 1 ];then
kaihlavi33771f42019-04-16 14:53:04 +0300178 echo "Usage: demo-k8s.sh <namespace> deleteVNF <module_name from instantiateVFW>"
Mandeep Khindaba48b012017-10-26 17:46:43 +0000179 exit
180 fi
Brian Freemanbe7845b2018-05-15 17:49:50 -0500181 VARFILE=$1.py
Mandeep Khindaba48b012017-10-26 17:46:43 +0000182 if [ -e /opt/eteshare/${VARFILE} ]; then
183 VARIABLES="$VARIABLES -V /share/${VARFILE}"
184 else
185 echo "Cache file ${VARFILE} is not found"
186 exit
187 fi
Mandeep Khinda15b8fc52018-04-17 03:26:26 +0000188 shift
Alexis de Talhouëtda89d732017-12-07 16:23:15 -0500189 ;;
190 heatbridge)
191 TAG="heatbridge"
192 shift
Marco Platania5b796782018-10-29 17:27:15 -0400193 if [ $# -ne 4 ];then
deen19854a50a3b2020-05-12 15:28:49 +0200194 echo "Usage: demo-k8s.sh <namespace> heatbridge <stack_name> <vnf_type> <service_type> <oam-ip-address_env_parameter>"
Alexis de Talhouëtda89d732017-12-07 16:23:15 -0500195 exit
196 fi
Brian Freemanbe7845b2018-05-15 17:49:50 -0500197 VARIABLES="$VARIABLES -v HB_STACK:$1"
Alexis de Talhouëtda89d732017-12-07 16:23:15 -0500198 shift
deen19854a50a3b2020-05-12 15:28:49 +0200199 VARIABLES="$VARIABLES -v HB_VNF:$1"
Alexis de Talhouëtda89d732017-12-07 16:23:15 -0500200 shift
Brian Freemanbe7845b2018-05-15 17:49:50 -0500201 VARIABLES="$VARIABLES -v HB_SERVICE:$1"
Mandeep Khindaba48b012017-10-26 17:46:43 +0000202 shift
Marco Platania5b796782018-10-29 17:27:15 -0400203 VARIABLES="$VARIABLES -v HB_IPV4_OAM_ADDRESS:$1"
204 shift
Mandeep Khindaba48b012017-10-26 17:46:43 +0000205 ;;
Yang Xu930daeb2018-10-28 11:47:13 -0400206 cds)
207 TAG="cds"
208 shift
209 ;;
Yang Xub39937b2018-11-01 12:56:55 -0400210 distributeVFWNG)
211 TAG="distributeVFWNG"
212 shift
213 ;;
Brian Freeman7bc755c2019-02-13 18:05:02 -0500214 distributeDemoVFWDT)
215 TAG="DistributeDemoVFWDT"
216 shift
217 ;;
218 instantiateDemoVFWDT)
219 TAG="instantiateVFWDT"
220 shift
221 ;;
Gary Wu57ceeeb2018-11-02 13:48:21 -0700222 vfwclosedloop)
223 TAG="vfwclosedloop"
224 shift
Gary Wuab5a0b62019-06-25 09:32:28 -0700225 VARIABLES="$VARIABLES -v PACKET_GENERATOR_HOST:$1 -v pkg_host:$1"
Gary Wu57ceeeb2018-11-02 13:48:21 -0700226 shift
227 ;;
Mandeep Khindaba48b012017-10-26 17:46:43 +0000228 *)
229 usage
230 exit
231 esac
232done
233
Gary Wu9b5fa0a2018-09-14 10:29:27 -0700234set -x
235
BorislavG4e8014a2018-02-27 15:04:26 +0000236POD=$(kubectl --namespace $NAMESPACE get pods | sed 's/ .*//'| grep robot)
Gary Wu42c42922018-11-01 11:57:27 -0700237
marekpl1b6baa42019-08-02 18:11:42 +0200238DIR=$(dirname "$0")
239SCRIPTDIR=scripts/demoscript
240
Brian Freeman7bc755c2019-02-13 18:05:02 -0500241ETEHOME=/var/opt/ONAP
Gary Wu42c42922018-11-01 11:57:27 -0700242
marekpl1b6baa42019-08-02 18:11:42 +0200243if [ $execscript ]; then
244 for script in $(ls -1 "$DIR/$SCRIPTDIR"); do
245 [ -f "$DIR/$SCRIPTDIR/$script" ] && [ -x "$DIR/$SCRIPTDIR/$script" ] && source "$DIR/$SCRIPTDIR/$script"
246 done
247fi
248
Gary Wu42c42922018-11-01 11:57:27 -0700249export GLOBAL_BUILD_NUMBER=$(kubectl --namespace $NAMESPACE exec ${POD} -- bash -c "ls -1q /share/logs/ | wc -l")
250OUTPUT_FOLDER=$(printf %04d $GLOBAL_BUILD_NUMBER)_demo_$key
251DISPLAY_NUM=$(($GLOBAL_BUILD_NUMBER + 90))
252
DR695H1f1bf372019-08-02 15:42:32 -0400253VARIABLEFILES="-V /share/config/robot_properties.py"
Gary Wu42c42922018-11-01 11:57:27 -0700254
255kubectl --namespace $NAMESPACE exec ${POD} -- ${ETEHOME}/runTags.sh ${VARIABLEFILES} ${VARIABLES} -d /share/logs/${OUTPUT_FOLDER} -i ${TAG} --display $DISPLAY_NUM 2> ${TAG}.out