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" |
Krzysztof Kuzmicki | 0b06cdd | 2021-09-30 14:13:39 +0200 | [diff] [blame] | 26 | echo " - Execute both init_customer + distribute + registrySynch" |
guillaume.lambert | 7bf306e | 2021-09-08 12:03:22 +0200 | [diff] [blame] | 27 | echo " " |
| 28 | echo " demo-k8s.sh <namespace> init_customer" |
| 29 | echo " - Create demo customer (Demonstration) and services, etc." |
| 30 | echo " " |
Krzysztof Kuzmicki | 0b06cdd | 2021-09-30 14:13:39 +0200 | [diff] [blame] | 31 | echo " demo-k8s.sh <namespace> registrySynch [ repo <chart name> | path [ <path to helm charts> ]" |
| 32 | echo " [ <chart prefix> ] ]" |
| 33 | echo " - Synchronize chart museum inside of onap k8s cluster with" |
| 34 | echo " onap helm charts git repository (OOM)" |
| 35 | echo " By default following charts are synchronized:" |
| 36 | echo " - oom/kubernetes/dcaegen2-services/charts/," |
| 37 | echo " - oom/kubernetes/common/common/charts," |
| 38 | echo " - oom/kubernetes/common/postgres/charts/," |
| 39 | echo " - oom/kubernetes/common/repositoryGenerator/charts/," |
| 40 | echo " - oom/kubernetes/common/readinessCheck/charts/," |
| 41 | echo " User is able also to synchronize custom helm charts by providing" |
| 42 | echo " flag 'path' and path to charts into command and chart name/s prefix for example:" |
| 43 | echo " demo-k8s.sh onap registrySynch /home/ubuntu/oom/kubernetes/common/postgres/charts/ postgres" |
| 44 | echo " - Synchronize chart museum inside of onap k8s cluster with" |
| 45 | echo " onap installation server 'local' helm charts repository" |
| 46 | echo " By default following charts are synchronized:" |
| 47 | echo " - local/certInitializer" |
| 48 | echo " User is able also to synchronize custom helm charts by providing" |
| 49 | echo " flag 'repo' and chart name in 'local' repo into command for example:" |
| 50 | echo " demo-k8s.sh onap registrySynch repo certInitializer" |
| 51 | echo " " |
guillaume.lambert | 7bf306e | 2021-09-08 12:03:22 +0200 | [diff] [blame] | 52 | echo " demo-k8s.sh <namespace> distribute [<prefix>]" |
| 53 | echo " - Distribute demo models (demoVFW and demoVLB)" |
| 54 | echo " " |
| 55 | echo " demo-k8s.sh <namespace> preload <vnf_name> <module_name>" |
| 56 | echo " - Preload data for VNF for the <module_name>" |
| 57 | echo " " |
| 58 | echo " demo-k8s.sh <namespace> appc <module_name>" |
| 59 | echo " - provide APPC with vFW module mount point for closed loop" |
| 60 | echo " " |
| 61 | echo " demo-k8s.sh <namespace> init_robot [ <etc_hosts_prefix> ]" |
| 62 | echo " - Initialize robot after all ONAP VMs have started" |
| 63 | echo " " |
| 64 | echo " demo-k8s.sh <namespace> instantiateVFW" |
| 65 | echo " - Instantiate vFW module for the demo customer (DemoCust<uuid>)" |
| 66 | echo " " |
| 67 | echo " demo-k8s.sh <namespace> instantiateVFWdirectso csar_filename" |
| 68 | echo " - Instantiate vFW module using direct SO interface using previously distributed model " |
Krzysztof Kuzmicki | 0b06cdd | 2021-09-30 14:13:39 +0200 | [diff] [blame] | 69 | echo " that is in /tmp/csar in robot container" |
guillaume.lambert | 7bf306e | 2021-09-08 12:03:22 +0200 | [diff] [blame] | 70 | echo " " |
Krzysztof Kuzmicki | 0b06cdd | 2021-09-30 14:13:39 +0200 | [diff] [blame] | 71 | echo " demo-k8s.sh <namespace> instantiateVLB_CDS" |
| 72 | echo " - Instantiate vLB module using CDS with a preloaded CBA " |
| 73 | echo " " |
guillaume.lambert | 7bf306e | 2021-09-08 12:03:22 +0200 | [diff] [blame] | 74 | echo " demo-k8s.sh <namespace> deleteVNF <module_name from instantiateVFW>" |
| 75 | echo " - Delete the module created by instantiateVFW" |
| 76 | echo " " |
| 77 | echo " demo-k8s.sh <namespace> vfwclosedloop <pgn-ip-address>" |
Krzysztof Kuzmicki | 0b06cdd | 2021-09-30 14:13:39 +0200 | [diff] [blame] | 78 | echo " - vFWCL: Sets the packet generator to high and low rates, and checks whether the policy " |
| 79 | echo " kicks in to modulate the rates back to medium" |
guillaume.lambert | 7bf306e | 2021-09-08 12:03:22 +0200 | [diff] [blame] | 80 | echo " " |
| 81 | echo " demo-k8s.sh <namespace> <command> [<parameters>] execscript" |
| 82 | echo " - Optional parameter to execute user custom scripts located in scripts/demoscript directory" |
| 83 | echo " " |
Sylvain Desbureaux | 16bdf24 | 2020-12-07 10:28:24 +0100 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | # Check if execscript flag is used and drop it from input arguments |
| 87 | |
Guillaume Lambert | ba6e50f | 2021-04-26 21:46:56 +0200 | [diff] [blame] | 88 | if [ "${!#}" = "execscript" ]; then |
Sylvain Desbureaux | 16bdf24 | 2020-12-07 10:28:24 +0100 | [diff] [blame] | 89 | set -- "${@:1:$#-1}" |
| 90 | execscript=true |
| 91 | fi |
| 92 | |
| 93 | # Set the defaults |
| 94 | |
| 95 | echo "Number of parameters:" |
| 96 | echo $# |
| 97 | |
Krzysztof Kuzmicki | 0b06cdd | 2021-09-30 14:13:39 +0200 | [diff] [blame] | 98 | if [ $# -lt 2 ]; then |
guillaume.lambert | 7bf306e | 2021-09-08 12:03:22 +0200 | [diff] [blame] | 99 | usage |
| 100 | exit |
Sylvain Desbureaux | 16bdf24 | 2020-12-07 10:28:24 +0100 | [diff] [blame] | 101 | fi |
| 102 | |
| 103 | NAMESPACE=$1 |
| 104 | shift |
| 105 | |
| 106 | ## |
| 107 | ## if more than 1 tag is supplied, the must be provided with -i or -e |
| 108 | ## |
| 109 | while [ $# -gt 0 ] |
| 110 | do |
guillaume.lambert | 7bf306e | 2021-09-08 12:03:22 +0200 | [diff] [blame] | 111 | key="$1" |
Sylvain Desbureaux | 16bdf24 | 2020-12-07 10:28:24 +0100 | [diff] [blame] | 112 | echo "KEY:" |
| 113 | echo $key |
| 114 | |
guillaume.lambert | 7bf306e | 2021-09-08 12:03:22 +0200 | [diff] [blame] | 115 | case $key in |
| 116 | init_robot) |
| 117 | TAG="UpdateWebPage" |
| 118 | echo "WEB Site Password for user 'test': " |
| 119 | stty -echo |
| 120 | read WEB_PASSWORD |
| 121 | stty echo |
| 122 | if [ "$WEB_PASSWORD" = "" ]; then |
| 123 | echo "" |
| 124 | echo "WEB Password is required for user 'test'" |
| 125 | exit |
| 126 | fi |
| 127 | VARIABLES="$VARIABLES -v WEB_PASSWORD:$WEB_PASSWORD" |
| 128 | shift |
| 129 | if [ $# -eq 2 ];then |
| 130 | VARIABLES="$VARIABLES -v HOSTS_PREFIX:$1" |
| 131 | fi |
| 132 | shift |
| 133 | ;; |
| 134 | init) |
| 135 | TAG="InitDemo" |
Krzysztof Kuzmicki | 0b06cdd | 2021-09-30 14:13:39 +0200 | [diff] [blame] | 136 | dcaeRegistrySynch=true |
guillaume.lambert | 7bf306e | 2021-09-08 12:03:22 +0200 | [diff] [blame] | 137 | shift |
| 138 | ;; |
| 139 | vescollector) |
| 140 | TAG="vescollector" |
| 141 | shift |
| 142 | ;; |
Sylvain Desbureaux | 16bdf24 | 2020-12-07 10:28:24 +0100 | [diff] [blame] | 143 | distribute_vcpe) |
guillaume.lambert | 7bf306e | 2021-09-08 12:03:22 +0200 | [diff] [blame] | 144 | TAG="distributeVCPE" |
| 145 | shift |
| 146 | ;; |
| 147 | init_customer) |
| 148 | TAG="InitCustomer" |
| 149 | shift |
| 150 | ;; |
| 151 | distribute) |
| 152 | TAG="InitDistribution" |
| 153 | shift |
| 154 | if [ $# -eq 1 ];then |
| 155 | VARIABLES="$VARIABLES -v DEMO_PREFIX:$1" |
| 156 | fi |
| 157 | shift |
| 158 | ;; |
| 159 | preload) |
| 160 | TAG="PreloadDemo" |
| 161 | shift |
| 162 | if [ $# -ne 2 ];then |
| 163 | echo "Usage: demo-k8s.sh <namespace> preload <vnf_name> <module_name>" |
| 164 | exit |
| 165 | fi |
| 166 | VARIABLES="$VARIABLES -v VNF_NAME:$1" |
| 167 | shift |
| 168 | VARIABLES="$VARIABLES -v MODULE_NAME:$1" |
| 169 | shift |
| 170 | ;; |
| 171 | appc) |
| 172 | TAG="APPCMountPointDemo" |
| 173 | shift |
| 174 | if [ $# -ne 1 ];then |
| 175 | echo "Usage: demo-k8s.sh <namespace> appc <module_name>" |
| 176 | exit |
| 177 | fi |
| 178 | VARIABLES="$VARIABLES -v MODULE_NAME:$1" |
| 179 | shift |
| 180 | ;; |
| 181 | instantiateVFW) |
| 182 | TAG="instantiateVFW" |
| 183 | VARIABLES="$VARIABLES -v GLOBAL_BUILD_NUMBER:$$" |
| 184 | shift |
| 185 | ;; |
Sylvain Desbureaux | 16bdf24 | 2020-12-07 10:28:24 +0100 | [diff] [blame] | 186 | instantiateVFWdirectso) |
| 187 | TAG="instantiateVFWdirectso" |
| 188 | shift |
| 189 | if [ $# -ne 1 ];then |
| 190 | echo "Usage: demo-k8s.sh <namespace> instantiateVFWdirectso <csar_filename>" |
| 191 | exit |
| 192 | fi |
| 193 | VARIABLES="$VARIABLES -v CSAR_FILE:$1 -v GLOBAL_BUILD_NUMBER:$$" |
| 194 | shift |
| 195 | ;; |
| 196 | instantiateVLB_CDS) |
| 197 | TAG="instantiateVLB_CDS" |
| 198 | VARIABLES="$VARIABLES -v GLOBAL_BUILD_NUMBER:$$" |
| 199 | shift |
| 200 | ;; |
guillaume.lambert | 7bf306e | 2021-09-08 12:03:22 +0200 | [diff] [blame] | 201 | deleteVNF) |
| 202 | TAG="deleteVNF" |
| 203 | shift |
| 204 | if [ $# -ne 1 ];then |
| 205 | echo "Usage: demo-k8s.sh <namespace> deleteVNF <module_name from instantiateVFW>" |
| 206 | exit |
| 207 | fi |
| 208 | VARFILE=$1.py |
| 209 | VARIABLES="$VARIABLES -V /share/${VARFILE}" |
| 210 | shift |
| 211 | ;; |
| 212 | cds) |
| 213 | TAG="cds" |
| 214 | shift |
| 215 | ;; |
Sylvain Desbureaux | 16bdf24 | 2020-12-07 10:28:24 +0100 | [diff] [blame] | 216 | distributeVFWNG) |
| 217 | TAG="distributeVFWNG" |
| 218 | shift |
| 219 | ;; |
| 220 | distributeDemoVFWDT) |
| 221 | TAG="DistributeDemoVFWDT" |
| 222 | shift |
| 223 | ;; |
| 224 | instantiateDemoVFWDT) |
| 225 | TAG="instantiateVFWDT" |
| 226 | shift |
| 227 | ;; |
| 228 | vfwclosedloop) |
| 229 | TAG="vfwclosedloop" |
| 230 | shift |
| 231 | VARIABLES="$VARIABLES -v PACKET_GENERATOR_HOST:$1 -v pkg_host:$1" |
| 232 | shift |
| 233 | ;; |
Krzysztof Kuzmicki | 0b06cdd | 2021-09-30 14:13:39 +0200 | [diff] [blame] | 234 | registrySynch) |
| 235 | dcaeRegistrySynch=true |
| 236 | echo $dcaeRegistrySynch |
| 237 | shift |
| 238 | echo $1 |
| 239 | if [ "$1" = "path" ]; then |
| 240 | shift |
| 241 | customHelmChartsPath=$1 |
| 242 | shift |
| 243 | customHelmChartsPref=$1 |
| 244 | shift |
| 245 | elif [ "$1" = "repo" ]; then |
| 246 | shift |
| 247 | customHelmChartFromLocalRepo=$1 |
| 248 | echo $customHelmChartFromLocalRepo |
| 249 | shift |
| 250 | else |
| 251 | echo "demo-k8s.sh <namespace> registrySynch { repo <chart name> | path [ <path to helm charts> ] [ <chart prefix> ] }" |
| 252 | fi |
| 253 | ;; |
guillaume.lambert | 7bf306e | 2021-09-08 12:03:22 +0200 | [diff] [blame] | 254 | *) |
| 255 | usage |
| 256 | exit |
| 257 | esac |
Sylvain Desbureaux | 16bdf24 | 2020-12-07 10:28:24 +0100 | [diff] [blame] | 258 | done |
| 259 | |
| 260 | set -x |
| 261 | |
| 262 | POD=$(kubectl --namespace $NAMESPACE get pods | sed 's/ .*//'| grep robot) |
Krzysztof Kuzmicki | 0b06cdd | 2021-09-30 14:13:39 +0200 | [diff] [blame] | 263 | HELM_RELEASE=$(kubectl --namespace onap get pods | sed 's/ .*//' | grep robot | sed 's/-.*//') |
Sylvain Desbureaux | 16bdf24 | 2020-12-07 10:28:24 +0100 | [diff] [blame] | 264 | |
| 265 | DIR=$(dirname "$0") |
| 266 | SCRIPTDIR=scripts/demoscript |
| 267 | |
| 268 | ETEHOME=/var/opt/ONAP |
| 269 | |
| 270 | if [ $execscript ]; then |
| 271 | for script in $(ls -1 "$DIR/$SCRIPTDIR"); do |
Guillaume Lambert | d9017ef | 2021-03-08 21:38:31 +0100 | [diff] [blame] | 272 | [ -f "$DIR/$SCRIPTDIR/$script" ] && [ -x "$DIR/$SCRIPTDIR/$script" ] && . "$DIR/$SCRIPTDIR/$script" |
Sylvain Desbureaux | 16bdf24 | 2020-12-07 10:28:24 +0100 | [diff] [blame] | 273 | done |
| 274 | fi |
| 275 | |
| 276 | export GLOBAL_BUILD_NUMBER=$(kubectl --namespace $NAMESPACE exec ${POD} -- bash -c "ls -1q /share/logs/ | wc -l") |
| 277 | OUTPUT_FOLDER=$(printf %04d $GLOBAL_BUILD_NUMBER)_demo_$key |
| 278 | DISPLAY_NUM=$(($GLOBAL_BUILD_NUMBER + 90)) |
| 279 | |
Krzysztof Kuzmicki | 0b06cdd | 2021-09-30 14:13:39 +0200 | [diff] [blame] | 280 | if [ $dcaeRegistrySynch ]; then |
| 281 | CURRENT_DIR=$PWD |
| 282 | PARENT_PATH=${0%/*} |
| 283 | cd $PARENT_PATH |
| 284 | cd ../contrib/tools |
| 285 | if [ -n "$customHelmChartsPath" ]; then |
| 286 | ./registry-initialize.sh -d $customHelmChartsPath -n $NAMESPACE -r $HELM_RELEASE -p customHelmChartsPref |
| 287 | elif [ -n "$customHelmChartFromLocalRepo" ]; then |
| 288 | ./registry-initialize.sh -h $customHelmChartFromLocalRepo -n $NAMESPACE -r $HELM_RELEASE |
| 289 | else |
| 290 | ./registry-initialize.sh -d ../../dcaegen2-services/charts/ -n $NAMESPACE -r $HELM_RELEASE |
| 291 | ./registry-initialize.sh -d ../../dcaegen2-services/charts/ -n $NAMESPACE -r $HELM_RELEASE -p common |
| 292 | ./registry-initialize.sh -h certInitializer -n $NAMESPACE -r $HELM_RELEASE |
| 293 | ./registry-initialize.sh -h repositoryGenerator -n $NAMESPACE -r $HELM_RELEASE |
| 294 | ./registry-initialize.sh -h readinessCheck -n $NAMESPACE -r $HELM_RELEASE |
| 295 | ./registry-initialize.sh -h dcaegen2-services-common -n $NAMESPACE -r $HELM_RELEASE |
| 296 | ./registry-initialize.sh -h postgres -n $NAMESPACE -r $HELM_RELEASE |
| 297 | ./registry-initialize.sh -h serviceAccount -n $NAMESPACE -r $HELM_RELEASE |
Krzysztof Kuzmicki | 6c6269d | 2022-03-25 11:51:18 +0100 | [diff] [blame] | 298 | ./registry-initialize.sh -h mongo -n $NAMESPACE -r $HELM_RELEASE |
| 299 | ./registry-initialize.sh -h common -n $NAMESPACE -r $HELM_RELEASE |
Krzysztof Kuzmicki | 0b06cdd | 2021-09-30 14:13:39 +0200 | [diff] [blame] | 300 | fi |
| 301 | cd $CURRENT_DIR |
| 302 | fi |
Sylvain Desbureaux | 16bdf24 | 2020-12-07 10:28:24 +0100 | [diff] [blame] | 303 | |
Krzysztof Kuzmicki | 0b06cdd | 2021-09-30 14:13:39 +0200 | [diff] [blame] | 304 | if [ -n "$TAG" ]; then |
| 305 | VARIABLEFILES="-V /share/config/robot_properties.py" |
| 306 | kubectl --namespace $NAMESPACE exec ${POD} -- ${ETEHOME}/runTags.sh ${VARIABLEFILES} ${VARIABLES} -d /share/logs/${OUTPUT_FOLDER} -i ${TAG} --display $DISPLAY_NUM 2> ${TAG}.out |
| 307 | fi |