Guillaume Lambert | 85b1492 | 2021-03-12 13:53:18 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
Sylvain Desbureaux | 16bdf24 | 2020-12-07 10:28:24 +0100 | [diff] [blame] | 3 | # 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 Lambert | 785bc38 | 2021-03-09 21:41:30 +0100 | [diff] [blame] | 21 | usage () |
Sylvain Desbureaux | 16bdf24 | 2020-12-07 10:28:24 +0100 | [diff] [blame] | 22 | { |
guillaume.lambert | 7bf306e | 2021-09-08 12:03:22 +0200 | [diff] [blame] | 23 | 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 Desbureaux | 16bdf24 | 2020-12-07 10:28:24 +0100 | [diff] [blame] | 48 | echo " that is in /tmp/csar in robot container" |
guillaume.lambert | 7bf306e | 2021-09-08 12:03:22 +0200 | [diff] [blame] | 49 | echo " " |
Sylvain Desbureaux | 16bdf24 | 2020-12-07 10:28:24 +0100 | [diff] [blame] | 50 | echo " demo-k8s.sh <namespace> instantiateVLB_CDS" |
| 51 | echo " - Instantiate vLB module using CDS with a preloaded CBA " |
| 52 | echo " " |
guillaume.lambert | 7bf306e | 2021-09-08 12:03:22 +0200 | [diff] [blame] | 53 | 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 Desbureaux | 16bdf24 | 2020-12-07 10:28:24 +0100 | [diff] [blame] | 57 | 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.lambert | 7bf306e | 2021-09-08 12:03:22 +0200 | [diff] [blame] | 59 | 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 Desbureaux | 16bdf24 | 2020-12-07 10:28:24 +0100 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | # Check if execscript flag is used and drop it from input arguments |
| 66 | |
Guillaume Lambert | ba6e50f | 2021-04-26 21:46:56 +0200 | [diff] [blame] | 67 | if [ "${!#}" = "execscript" ]; then |
Sylvain Desbureaux | 16bdf24 | 2020-12-07 10:28:24 +0100 | [diff] [blame] | 68 | set -- "${@:1:$#-1}" |
| 69 | execscript=true |
| 70 | fi |
| 71 | |
| 72 | # Set the defaults |
| 73 | |
| 74 | echo "Number of parameters:" |
| 75 | echo $# |
| 76 | |
| 77 | if [ $# -lt 2 ];then |
guillaume.lambert | 7bf306e | 2021-09-08 12:03:22 +0200 | [diff] [blame] | 78 | usage |
| 79 | exit |
Sylvain Desbureaux | 16bdf24 | 2020-12-07 10:28:24 +0100 | [diff] [blame] | 80 | fi |
| 81 | |
| 82 | NAMESPACE=$1 |
| 83 | shift |
| 84 | |
| 85 | ## |
| 86 | ## if more than 1 tag is supplied, the must be provided with -i or -e |
| 87 | ## |
| 88 | while [ $# -gt 0 ] |
| 89 | do |
guillaume.lambert | 7bf306e | 2021-09-08 12:03:22 +0200 | [diff] [blame] | 90 | key="$1" |
Sylvain Desbureaux | 16bdf24 | 2020-12-07 10:28:24 +0100 | [diff] [blame] | 91 | echo "KEY:" |
| 92 | echo $key |
| 93 | |
guillaume.lambert | 7bf306e | 2021-09-08 12:03:22 +0200 | [diff] [blame] | 94 | 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 Desbureaux | 16bdf24 | 2020-12-07 10:28:24 +0100 | [diff] [blame] | 121 | distribute_vcpe) |
guillaume.lambert | 7bf306e | 2021-09-08 12:03:22 +0200 | [diff] [blame] | 122 | 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 Desbureaux | 16bdf24 | 2020-12-07 10:28:24 +0100 | [diff] [blame] | 164 | 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.lambert | 7bf306e | 2021-09-08 12:03:22 +0200 | [diff] [blame] | 179 | 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 Desbureaux | 16bdf24 | 2020-12-07 10:28:24 +0100 | [diff] [blame] | 194 | 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.lambert | 7bf306e | 2021-09-08 12:03:22 +0200 | [diff] [blame] | 212 | *) |
| 213 | usage |
| 214 | exit |
| 215 | esac |
Sylvain Desbureaux | 16bdf24 | 2020-12-07 10:28:24 +0100 | [diff] [blame] | 216 | done |
| 217 | |
| 218 | set -x |
| 219 | |
| 220 | POD=$(kubectl --namespace $NAMESPACE get pods | sed 's/ .*//'| grep robot) |
| 221 | |
| 222 | DIR=$(dirname "$0") |
| 223 | SCRIPTDIR=scripts/demoscript |
| 224 | |
| 225 | ETEHOME=/var/opt/ONAP |
| 226 | |
| 227 | if [ $execscript ]; then |
| 228 | for script in $(ls -1 "$DIR/$SCRIPTDIR"); do |
Guillaume Lambert | d9017ef | 2021-03-08 21:38:31 +0100 | [diff] [blame] | 229 | [ -f "$DIR/$SCRIPTDIR/$script" ] && [ -x "$DIR/$SCRIPTDIR/$script" ] && . "$DIR/$SCRIPTDIR/$script" |
Sylvain Desbureaux | 16bdf24 | 2020-12-07 10:28:24 +0100 | [diff] [blame] | 230 | done |
| 231 | fi |
| 232 | |
| 233 | export GLOBAL_BUILD_NUMBER=$(kubectl --namespace $NAMESPACE exec ${POD} -- bash -c "ls -1q /share/logs/ | wc -l") |
| 234 | OUTPUT_FOLDER=$(printf %04d $GLOBAL_BUILD_NUMBER)_demo_$key |
| 235 | DISPLAY_NUM=$(($GLOBAL_BUILD_NUMBER + 90)) |
| 236 | |
| 237 | VARIABLEFILES="-V /share/config/robot_properties.py" |
| 238 | |
| 239 | kubectl --namespace $NAMESPACE exec ${POD} -- ${ETEHOME}/runTags.sh ${VARIABLEFILES} ${VARIABLES} -d /share/logs/${OUTPUT_FOLDER} -i ${TAG} --display $DISPLAY_NUM 2> ${TAG}.out |