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