Gary Wu | 57ceeeb | 2018-11-02 13:48:21 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Copyright (C) 2018 Amdocs, Bell Canada |
kaihlavi | 33771f4 | 2019-04-16 14:53:04 +0300 | [diff] [blame] | 3 | # Modifications Copyright (C) 2019 Samsung |
deen1985 | 4a50a3b | 2020-05-12 15:28:49 +0200 | [diff] [blame] | 4 | # Modifications Copyright (C) 2020 Nokia |
vaibhavjayas | 002fb99 | 2018-08-31 06:22:26 +0000 | [diff] [blame] | 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. |
Mandeep Khinda | ba48b01 | 2017-10-26 17:46:43 +0000 | [diff] [blame] | 17 | # |
kaihlavi | 33771f4 | 2019-04-16 14:53:04 +0300 | [diff] [blame] | 18 | # Execute tags built to support the hands-on demo |
Mandeep Khinda | ba48b01 | 2017-10-26 17:46:43 +0000 | [diff] [blame] | 19 | # |
| 20 | function usage |
| 21 | { |
marekpl | 1b6baa4 | 2019-08-02 18:11:42 +0200 | [diff] [blame] | 22 | echo "Usage: demo-k8s.sh <namespace> <command> [<parameters>] [execscript]" |
Mandeep Khinda | ba48b01 | 2017-10-26 17:46:43 +0000 | [diff] [blame] | 23 | echo " " |
kaihlavi | 33771f4 | 2019-04-16 14:53:04 +0300 | [diff] [blame] | 24 | echo " demo-k8s.sh <namespace> init" |
Mandeep Khinda | ba48b01 | 2017-10-26 17:46:43 +0000 | [diff] [blame] | 25 | echo " - Execute both init_customer + distribute" |
| 26 | echo " " |
kaihlavi | 33771f4 | 2019-04-16 14:53:04 +0300 | [diff] [blame] | 27 | echo " demo-k8s.sh <namespace> init_customer" |
Mandeep Khinda | ba48b01 | 2017-10-26 17:46:43 +0000 | [diff] [blame] | 28 | echo " - Create demo customer (Demonstration) and services, etc." |
| 29 | echo " " |
kaihlavi | 33771f4 | 2019-04-16 14:53:04 +0300 | [diff] [blame] | 30 | echo " demo-k8s.sh <namespace> distribute [<prefix>]" |
Mandeep Khinda | ba48b01 | 2017-10-26 17:46:43 +0000 | [diff] [blame] | 31 | echo " - Distribute demo models (demoVFW and demoVLB)" |
| 32 | echo " " |
kaihlavi | 33771f4 | 2019-04-16 14:53:04 +0300 | [diff] [blame] | 33 | echo " demo-k8s.sh <namespace> preload <vnf_name> <module_name>" |
Mandeep Khinda | ba48b01 | 2017-10-26 17:46:43 +0000 | [diff] [blame] | 34 | echo " - Preload data for VNF for the <module_name>" |
| 35 | echo " " |
kaihlavi | 33771f4 | 2019-04-16 14:53:04 +0300 | [diff] [blame] | 36 | echo " demo-k8s.sh <namespace> appc <module_name>" |
| 37 | echo " - provide APPC with vFW module mount point for closed loop" |
Mandeep Khinda | ba48b01 | 2017-10-26 17:46:43 +0000 | [diff] [blame] | 38 | echo " " |
kaihlavi | 33771f4 | 2019-04-16 14:53:04 +0300 | [diff] [blame] | 39 | echo " demo-k8s.sh <namespace> init_robot [ <etc_hosts_prefix> ]" |
| 40 | echo " - Initialize robot after all ONAP VMs have started" |
Mandeep Khinda | ba48b01 | 2017-10-26 17:46:43 +0000 | [diff] [blame] | 41 | echo " " |
kaihlavi | 33771f4 | 2019-04-16 14:53:04 +0300 | [diff] [blame] | 42 | echo " demo-k8s.sh <namespace> instantiateVFW" |
| 43 | echo " - Instantiate vFW module for the demo customer (DemoCust<uuid>)" |
Mandeep Khinda | ba48b01 | 2017-10-26 17:46:43 +0000 | [diff] [blame] | 44 | echo " " |
Brian Freeman | 98e80ad | 2019-05-06 12:12:36 -0500 | [diff] [blame] | 45 | 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 Seaudi | 1d36d59 | 2019-09-18 08:44:00 +0000 | [diff] [blame] | 49 | echo " demo-k8s.sh <namespace> instantiateVLB_CDS" |
| 50 | echo " - Instantiate vLB module using CDS with a preloaded CBA " |
| 51 | echo " " |
kaihlavi | 33771f4 | 2019-04-16 14:53:04 +0300 | [diff] [blame] | 52 | echo " demo-k8s.sh <namespace> deleteVNF <module_name from instantiateVFW>" |
| 53 | echo " - Delete the module created by instantiateVFW" |
Alexis de Talhouët | da89d73 | 2017-12-07 16:23:15 -0500 | [diff] [blame] | 54 | echo " " |
deen1985 | 4a50a3b | 2020-05-12 15:28:49 +0200 | [diff] [blame] | 55 | 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 Wu | 57ceeeb | 2018-11-02 13:48:21 -0700 | [diff] [blame] | 57 | echo " " |
kaihlavi | 33771f4 | 2019-04-16 14:53:04 +0300 | [diff] [blame] | 58 | echo " demo-k8s.sh <namespace> vfwclosedloop <pgn-ip-address>" |
marekpl | 1b6baa4 | 2019-08-02 18:11:42 +0200 | [diff] [blame] | 59 | 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 " " |
marekpl | 580d933 | 2019-08-13 10:41:34 +0200 | [diff] [blame] | 62 | echo " demo-k8s.sh <namespace> <command> [<parameters>] execscript" |
marekpl | 1b6baa4 | 2019-08-02 18:11:42 +0200 | [diff] [blame] | 63 | echo " - Optional parameter to execute user custom scripts located in scripts/demoscript directory" |
Gary Wu | 57ceeeb | 2018-11-02 13:48:21 -0700 | [diff] [blame] | 64 | echo " " |
Mandeep Khinda | ba48b01 | 2017-10-26 17:46:43 +0000 | [diff] [blame] | 65 | } |
| 66 | |
marekpl | 1b6baa4 | 2019-08-02 18:11:42 +0200 | [diff] [blame] | 67 | # Check if execscript flag is used and drop it from input arguments |
| 68 | |
| 69 | if [[ "${!#}" == "execscript" ]]; then |
| 70 | set -- "${@:1:$#-1}" |
| 71 | execscript=true |
| 72 | fi |
| 73 | |
Mandeep Khinda | ba48b01 | 2017-10-26 17:46:43 +0000 | [diff] [blame] | 74 | # Set the defaults |
Brian Freeman | df2baf0 | 2018-04-23 17:24:35 -0500 | [diff] [blame] | 75 | |
Gary Wu | ab5a0b6 | 2019-06-25 09:32:28 -0700 | [diff] [blame] | 76 | echo "Number of parameters:" |
Brian Freeman | df2baf0 | 2018-04-23 17:24:35 -0500 | [diff] [blame] | 77 | echo $# |
| 78 | |
| 79 | if [ $# -lt 2 ];then |
Mandeep Khinda | ba48b01 | 2017-10-26 17:46:43 +0000 | [diff] [blame] | 80 | usage |
| 81 | exit |
| 82 | fi |
BorislavG | 4e8014a | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 83 | |
| 84 | NAMESPACE=$1 |
| 85 | shift |
| 86 | |
Mandeep Khinda | ba48b01 | 2017-10-26 17:46:43 +0000 | [diff] [blame] | 87 | ## |
| 88 | ## if more than 1 tag is supplied, the must be provided with -i or -e |
| 89 | ## |
Brian Freeman | df2baf0 | 2018-04-23 17:24:35 -0500 | [diff] [blame] | 90 | while [ $# -gt 0 ] |
Mandeep Khinda | ba48b01 | 2017-10-26 17:46:43 +0000 | [diff] [blame] | 91 | do |
Brian Freeman | df2baf0 | 2018-04-23 17:24:35 -0500 | [diff] [blame] | 92 | key="$1" |
| 93 | echo "KEY:" |
| 94 | echo $key |
Mandeep Khinda | ba48b01 | 2017-10-26 17:46:43 +0000 | [diff] [blame] | 95 | |
| 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 Khinda | 15b8fc5 | 2018-04-17 03:26:26 +0000 | [diff] [blame] | 107 | if [ $# -eq 2 ];then |
Brian Freeman | be7845b | 2018-05-15 17:49:50 -0500 | [diff] [blame] | 108 | VARIABLES="$VARIABLES -v HOSTS_PREFIX:$1" |
Mandeep Khinda | 15b8fc5 | 2018-04-17 03:26:26 +0000 | [diff] [blame] | 109 | fi |
| 110 | shift |
Mandeep Khinda | ba48b01 | 2017-10-26 17:46:43 +0000 | [diff] [blame] | 111 | ;; |
| 112 | init) |
| 113 | TAG="InitDemo" |
| 114 | shift |
| 115 | ;; |
Brian Freeman | 53949ab | 2019-12-06 11:39:05 -0500 | [diff] [blame] | 116 | distribute_vcpe) |
| 117 | TAG="distributeVCPE" |
| 118 | shift |
| 119 | ;; |
Mandeep Khinda | ba48b01 | 2017-10-26 17:46:43 +0000 | [diff] [blame] | 120 | init_customer) |
| 121 | TAG="InitCustomer" |
| 122 | shift |
| 123 | ;; |
| 124 | distribute) |
| 125 | TAG="InitDistribution" |
| 126 | shift |
| 127 | if [ $# -eq 1 ];then |
Brian Freeman | be7845b | 2018-05-15 17:49:50 -0500 | [diff] [blame] | 128 | VARIABLES="$VARIABLES -v DEMO_PREFIX:$1" |
Mandeep Khinda | ba48b01 | 2017-10-26 17:46:43 +0000 | [diff] [blame] | 129 | fi |
| 130 | shift |
| 131 | ;; |
| 132 | preload) |
| 133 | TAG="PreloadDemo" |
| 134 | shift |
| 135 | if [ $# -ne 2 ];then |
kaihlavi | 33771f4 | 2019-04-16 14:53:04 +0300 | [diff] [blame] | 136 | echo "Usage: demo-k8s.sh <namespace> preload <vnf_name> <module_name>" |
Mandeep Khinda | ba48b01 | 2017-10-26 17:46:43 +0000 | [diff] [blame] | 137 | exit |
| 138 | fi |
Brian Freeman | be7845b | 2018-05-15 17:49:50 -0500 | [diff] [blame] | 139 | VARIABLES="$VARIABLES -v VNF_NAME:$1" |
Mandeep Khinda | ba48b01 | 2017-10-26 17:46:43 +0000 | [diff] [blame] | 140 | shift |
Brian Freeman | be7845b | 2018-05-15 17:49:50 -0500 | [diff] [blame] | 141 | VARIABLES="$VARIABLES -v MODULE_NAME:$1" |
Mandeep Khinda | ba48b01 | 2017-10-26 17:46:43 +0000 | [diff] [blame] | 142 | shift |
| 143 | ;; |
| 144 | appc) |
Brian Freeman | be7845b | 2018-05-15 17:49:50 -0500 | [diff] [blame] | 145 | TAG="APPCMountPointDemo" |
| 146 | shift |
| 147 | if [ $# -ne 1 ];then |
kaihlavi | 33771f4 | 2019-04-16 14:53:04 +0300 | [diff] [blame] | 148 | echo "Usage: demo-k8s.sh <namespace> appc <module_name>" |
Brian Freeman | be7845b | 2018-05-15 17:49:50 -0500 | [diff] [blame] | 149 | exit |
| 150 | fi |
| 151 | VARIABLES="$VARIABLES -v MODULE_NAME:$1" |
| 152 | shift |
| 153 | ;; |
Mandeep Khinda | ba48b01 | 2017-10-26 17:46:43 +0000 | [diff] [blame] | 154 | instantiateVFW) |
| 155 | TAG="instantiateVFW" |
| 156 | VARIABLES="$VARIABLES -v GLOBAL_BUILD_NUMBER:$$" |
| 157 | shift |
| 158 | ;; |
Brian Freeman | 98e80ad | 2019-05-06 12:12:36 -0500 | [diff] [blame] | 159 | 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 Seaudi | 1d36d59 | 2019-09-18 08:44:00 +0000 | [diff] [blame] | 169 | instantiateVLB_CDS) |
| 170 | TAG="instantiateVLB_CDS" |
| 171 | VARIABLES="$VARIABLES -v GLOBAL_BUILD_NUMBER:$$" |
| 172 | shift |
| 173 | ;; |
Mandeep Khinda | ba48b01 | 2017-10-26 17:46:43 +0000 | [diff] [blame] | 174 | deleteVNF) |
| 175 | TAG="deleteVNF" |
| 176 | shift |
| 177 | if [ $# -ne 1 ];then |
kaihlavi | 33771f4 | 2019-04-16 14:53:04 +0300 | [diff] [blame] | 178 | echo "Usage: demo-k8s.sh <namespace> deleteVNF <module_name from instantiateVFW>" |
Mandeep Khinda | ba48b01 | 2017-10-26 17:46:43 +0000 | [diff] [blame] | 179 | exit |
| 180 | fi |
Brian Freeman | be7845b | 2018-05-15 17:49:50 -0500 | [diff] [blame] | 181 | VARFILE=$1.py |
Mandeep Khinda | ba48b01 | 2017-10-26 17:46:43 +0000 | [diff] [blame] | 182 | 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 Khinda | 15b8fc5 | 2018-04-17 03:26:26 +0000 | [diff] [blame] | 188 | shift |
Alexis de Talhouët | da89d73 | 2017-12-07 16:23:15 -0500 | [diff] [blame] | 189 | ;; |
| 190 | heatbridge) |
| 191 | TAG="heatbridge" |
| 192 | shift |
Marco Platania | 5b79678 | 2018-10-29 17:27:15 -0400 | [diff] [blame] | 193 | if [ $# -ne 4 ];then |
deen1985 | 4a50a3b | 2020-05-12 15:28:49 +0200 | [diff] [blame] | 194 | echo "Usage: demo-k8s.sh <namespace> heatbridge <stack_name> <vnf_type> <service_type> <oam-ip-address_env_parameter>" |
Alexis de Talhouët | da89d73 | 2017-12-07 16:23:15 -0500 | [diff] [blame] | 195 | exit |
| 196 | fi |
Brian Freeman | be7845b | 2018-05-15 17:49:50 -0500 | [diff] [blame] | 197 | VARIABLES="$VARIABLES -v HB_STACK:$1" |
Alexis de Talhouët | da89d73 | 2017-12-07 16:23:15 -0500 | [diff] [blame] | 198 | shift |
deen1985 | 4a50a3b | 2020-05-12 15:28:49 +0200 | [diff] [blame] | 199 | VARIABLES="$VARIABLES -v HB_VNF:$1" |
Alexis de Talhouët | da89d73 | 2017-12-07 16:23:15 -0500 | [diff] [blame] | 200 | shift |
Brian Freeman | be7845b | 2018-05-15 17:49:50 -0500 | [diff] [blame] | 201 | VARIABLES="$VARIABLES -v HB_SERVICE:$1" |
Mandeep Khinda | ba48b01 | 2017-10-26 17:46:43 +0000 | [diff] [blame] | 202 | shift |
Marco Platania | 5b79678 | 2018-10-29 17:27:15 -0400 | [diff] [blame] | 203 | VARIABLES="$VARIABLES -v HB_IPV4_OAM_ADDRESS:$1" |
| 204 | shift |
Mandeep Khinda | ba48b01 | 2017-10-26 17:46:43 +0000 | [diff] [blame] | 205 | ;; |
Yang Xu | 930daeb | 2018-10-28 11:47:13 -0400 | [diff] [blame] | 206 | cds) |
| 207 | TAG="cds" |
| 208 | shift |
| 209 | ;; |
Yang Xu | b39937b | 2018-11-01 12:56:55 -0400 | [diff] [blame] | 210 | distributeVFWNG) |
| 211 | TAG="distributeVFWNG" |
| 212 | shift |
| 213 | ;; |
Brian Freeman | 7bc755c | 2019-02-13 18:05:02 -0500 | [diff] [blame] | 214 | distributeDemoVFWDT) |
| 215 | TAG="DistributeDemoVFWDT" |
| 216 | shift |
| 217 | ;; |
| 218 | instantiateDemoVFWDT) |
| 219 | TAG="instantiateVFWDT" |
| 220 | shift |
| 221 | ;; |
Gary Wu | 57ceeeb | 2018-11-02 13:48:21 -0700 | [diff] [blame] | 222 | vfwclosedloop) |
| 223 | TAG="vfwclosedloop" |
| 224 | shift |
Gary Wu | ab5a0b6 | 2019-06-25 09:32:28 -0700 | [diff] [blame] | 225 | VARIABLES="$VARIABLES -v PACKET_GENERATOR_HOST:$1 -v pkg_host:$1" |
Gary Wu | 57ceeeb | 2018-11-02 13:48:21 -0700 | [diff] [blame] | 226 | shift |
| 227 | ;; |
Mandeep Khinda | ba48b01 | 2017-10-26 17:46:43 +0000 | [diff] [blame] | 228 | *) |
| 229 | usage |
| 230 | exit |
| 231 | esac |
| 232 | done |
| 233 | |
Gary Wu | 9b5fa0a | 2018-09-14 10:29:27 -0700 | [diff] [blame] | 234 | set -x |
| 235 | |
BorislavG | 4e8014a | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 236 | POD=$(kubectl --namespace $NAMESPACE get pods | sed 's/ .*//'| grep robot) |
Gary Wu | 42c4292 | 2018-11-01 11:57:27 -0700 | [diff] [blame] | 237 | |
marekpl | 1b6baa4 | 2019-08-02 18:11:42 +0200 | [diff] [blame] | 238 | DIR=$(dirname "$0") |
| 239 | SCRIPTDIR=scripts/demoscript |
| 240 | |
Brian Freeman | 7bc755c | 2019-02-13 18:05:02 -0500 | [diff] [blame] | 241 | ETEHOME=/var/opt/ONAP |
Gary Wu | 42c4292 | 2018-11-01 11:57:27 -0700 | [diff] [blame] | 242 | |
marekpl | 1b6baa4 | 2019-08-02 18:11:42 +0200 | [diff] [blame] | 243 | if [ $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 |
| 247 | fi |
| 248 | |
Gary Wu | 42c4292 | 2018-11-01 11:57:27 -0700 | [diff] [blame] | 249 | export GLOBAL_BUILD_NUMBER=$(kubectl --namespace $NAMESPACE exec ${POD} -- bash -c "ls -1q /share/logs/ | wc -l") |
| 250 | OUTPUT_FOLDER=$(printf %04d $GLOBAL_BUILD_NUMBER)_demo_$key |
| 251 | DISPLAY_NUM=$(($GLOBAL_BUILD_NUMBER + 90)) |
| 252 | |
DR695H | 1f1bf37 | 2019-08-02 15:42:32 -0400 | [diff] [blame] | 253 | VARIABLEFILES="-V /share/config/robot_properties.py" |
Gary Wu | 42c4292 | 2018-11-01 11:57:27 -0700 | [diff] [blame] | 254 | |
| 255 | kubectl --namespace $NAMESPACE exec ${POD} -- ${ETEHOME}/runTags.sh ${VARIABLEFILES} ${VARIABLES} -d /share/logs/${OUTPUT_FOLDER} -i ${TAG} --display $DISPLAY_NUM 2> ${TAG}.out |