Sylvain Desbureaux | 16bdf24 | 2020-12-07 10:28:24 +0100 | [diff] [blame] | 1 | #!/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 Lambert | 785bc38 | 2021-03-09 21:41:30 +0100 | [diff] [blame] | 20 | usage () |
Sylvain Desbureaux | 16bdf24 | 2020-12-07 10:28:24 +0100 | [diff] [blame] | 21 | { |
| 22 | 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 " |
| 47 | echo " that is in /tmp/csar in robot container" |
| 48 | echo " " |
| 49 | echo " demo-k8s.sh <namespace> instantiateVLB_CDS" |
| 50 | echo " - Instantiate vLB module using CDS with a preloaded CBA " |
| 51 | echo " " |
| 52 | 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>" |
| 56 | 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" |
| 58 | 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 " " |
| 62 | } |
| 63 | |
| 64 | # Check if execscript flag is used and drop it from input arguments |
| 65 | |
Guillaume Lambert | ba6e50f | 2021-04-26 21:46:56 +0200 | [diff] [blame] | 66 | if [ "${!#}" = "execscript" ]; then |
Sylvain Desbureaux | 16bdf24 | 2020-12-07 10:28:24 +0100 | [diff] [blame] | 67 | set -- "${@:1:$#-1}" |
| 68 | execscript=true |
| 69 | fi |
| 70 | |
| 71 | # Set the defaults |
| 72 | |
| 73 | echo "Number of parameters:" |
| 74 | echo $# |
| 75 | |
| 76 | if [ $# -lt 2 ];then |
| 77 | usage |
| 78 | exit |
| 79 | fi |
| 80 | |
| 81 | NAMESPACE=$1 |
| 82 | shift |
| 83 | |
| 84 | ## |
| 85 | ## if more than 1 tag is supplied, the must be provided with -i or -e |
| 86 | ## |
| 87 | while [ $# -gt 0 ] |
| 88 | do |
| 89 | key="$1" |
| 90 | echo "KEY:" |
| 91 | echo $key |
| 92 | |
| 93 | case $key in |
| 94 | init_robot) |
| 95 | TAG="UpdateWebPage" |
| 96 | read -s -p "WEB Site Password for user 'test': " WEB_PASSWORD |
| 97 | if [ "$WEB_PASSWORD" = "" ]; then |
| 98 | echo "" |
| 99 | echo "WEB Password is required for user 'test'" |
| 100 | exit |
| 101 | fi |
| 102 | VARIABLES="$VARIABLES -v WEB_PASSWORD:$WEB_PASSWORD" |
| 103 | shift |
| 104 | if [ $# -eq 2 ];then |
| 105 | VARIABLES="$VARIABLES -v HOSTS_PREFIX:$1" |
| 106 | fi |
| 107 | shift |
| 108 | ;; |
| 109 | init) |
| 110 | TAG="InitDemo" |
| 111 | shift |
| 112 | ;; |
| 113 | vescollector) |
| 114 | TAG="vescollector" |
| 115 | shift |
| 116 | ;; |
| 117 | distribute_vcpe) |
| 118 | TAG="distributeVCPE" |
| 119 | shift |
| 120 | ;; |
| 121 | init_customer) |
| 122 | TAG="InitCustomer" |
| 123 | shift |
| 124 | ;; |
| 125 | distribute) |
| 126 | TAG="InitDistribution" |
| 127 | shift |
| 128 | if [ $# -eq 1 ];then |
| 129 | VARIABLES="$VARIABLES -v DEMO_PREFIX:$1" |
| 130 | fi |
| 131 | shift |
| 132 | ;; |
| 133 | preload) |
| 134 | TAG="PreloadDemo" |
| 135 | shift |
| 136 | if [ $# -ne 2 ];then |
| 137 | echo "Usage: demo-k8s.sh <namespace> preload <vnf_name> <module_name>" |
| 138 | exit |
| 139 | fi |
| 140 | VARIABLES="$VARIABLES -v VNF_NAME:$1" |
| 141 | shift |
| 142 | VARIABLES="$VARIABLES -v MODULE_NAME:$1" |
| 143 | shift |
| 144 | ;; |
| 145 | appc) |
| 146 | TAG="APPCMountPointDemo" |
| 147 | shift |
| 148 | if [ $# -ne 1 ];then |
| 149 | echo "Usage: demo-k8s.sh <namespace> appc <module_name>" |
| 150 | exit |
| 151 | fi |
| 152 | VARIABLES="$VARIABLES -v MODULE_NAME:$1" |
| 153 | shift |
| 154 | ;; |
| 155 | instantiateVFW) |
| 156 | TAG="instantiateVFW" |
| 157 | VARIABLES="$VARIABLES -v GLOBAL_BUILD_NUMBER:$$" |
| 158 | shift |
| 159 | ;; |
| 160 | instantiateVFWdirectso) |
| 161 | TAG="instantiateVFWdirectso" |
| 162 | shift |
| 163 | if [ $# -ne 1 ];then |
| 164 | echo "Usage: demo-k8s.sh <namespace> instantiateVFWdirectso <csar_filename>" |
| 165 | exit |
| 166 | fi |
| 167 | VARIABLES="$VARIABLES -v CSAR_FILE:$1 -v GLOBAL_BUILD_NUMBER:$$" |
| 168 | shift |
| 169 | ;; |
| 170 | instantiateVLB_CDS) |
| 171 | TAG="instantiateVLB_CDS" |
| 172 | VARIABLES="$VARIABLES -v GLOBAL_BUILD_NUMBER:$$" |
| 173 | shift |
| 174 | ;; |
| 175 | deleteVNF) |
| 176 | TAG="deleteVNF" |
| 177 | shift |
| 178 | if [ $# -ne 1 ];then |
| 179 | echo "Usage: demo-k8s.sh <namespace> deleteVNF <module_name from instantiateVFW>" |
| 180 | exit |
| 181 | fi |
| 182 | VARFILE=$1.py |
| 183 | VARIABLES="$VARIABLES -V /share/${VARFILE}" |
| 184 | shift |
| 185 | ;; |
| 186 | cds) |
| 187 | TAG="cds" |
| 188 | shift |
| 189 | ;; |
| 190 | distributeVFWNG) |
| 191 | TAG="distributeVFWNG" |
| 192 | shift |
| 193 | ;; |
| 194 | distributeDemoVFWDT) |
| 195 | TAG="DistributeDemoVFWDT" |
| 196 | shift |
| 197 | ;; |
| 198 | instantiateDemoVFWDT) |
| 199 | TAG="instantiateVFWDT" |
| 200 | shift |
| 201 | ;; |
| 202 | vfwclosedloop) |
| 203 | TAG="vfwclosedloop" |
| 204 | shift |
| 205 | VARIABLES="$VARIABLES -v PACKET_GENERATOR_HOST:$1 -v pkg_host:$1" |
| 206 | shift |
| 207 | ;; |
| 208 | *) |
| 209 | usage |
| 210 | exit |
| 211 | esac |
| 212 | done |
| 213 | |
| 214 | set -x |
| 215 | |
| 216 | POD=$(kubectl --namespace $NAMESPACE get pods | sed 's/ .*//'| grep robot) |
| 217 | |
| 218 | DIR=$(dirname "$0") |
| 219 | SCRIPTDIR=scripts/demoscript |
| 220 | |
| 221 | ETEHOME=/var/opt/ONAP |
| 222 | |
| 223 | if [ $execscript ]; then |
| 224 | for script in $(ls -1 "$DIR/$SCRIPTDIR"); do |
Guillaume Lambert | 62178a4 | 2021-03-08 21:38:31 +0100 | [diff] [blame^] | 225 | [ -f "$DIR/$SCRIPTDIR/$script" ] && [ -x "$DIR/$SCRIPTDIR/$script" ] && . "$DIR/$SCRIPTDIR/$script" |
Sylvain Desbureaux | 16bdf24 | 2020-12-07 10:28:24 +0100 | [diff] [blame] | 226 | done |
| 227 | fi |
| 228 | |
| 229 | export GLOBAL_BUILD_NUMBER=$(kubectl --namespace $NAMESPACE exec ${POD} -- bash -c "ls -1q /share/logs/ | wc -l") |
| 230 | OUTPUT_FOLDER=$(printf %04d $GLOBAL_BUILD_NUMBER)_demo_$key |
| 231 | DISPLAY_NUM=$(($GLOBAL_BUILD_NUMBER + 90)) |
| 232 | |
| 233 | VARIABLEFILES="-V /share/config/robot_properties.py" |
| 234 | |
| 235 | kubectl --namespace $NAMESPACE exec ${POD} -- ${ETEHOME}/runTags.sh ${VARIABLEFILES} ${VARIABLES} -d /share/logs/${OUTPUT_FOLDER} -i ${TAG} --display $DISPLAY_NUM 2> ${TAG}.out |