blob: c77223d0dc07dc0a0c07d5f740a9ce335145b1e8 [file] [log] [blame]
Test User01ed0642019-07-03 20:17:06 +00001#!/bin/bash
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002# Copyright 2019 Ciena Corporation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
David Bainbridge712afb82019-08-14 19:55:58 +000015TOTAL_START_TIME=$(date +%s)
David K. Bainbridgeb7285432019-07-02 22:05:24 -070016
David Bainbridge38dc1e82019-08-12 15:18:45 +000017FANCY=${FANCY:-1}
18if [ "$TERM X" == " X" ]; then
19 FANCY=0
20fi
21
David K. Bainbridgeb7285432019-07-02 22:05:24 -070022# trap ctrl-c and call ctrl_c()
23trap ctrl_c INT
24
25function ctrl_c() {
David Bainbridge38dc1e82019-08-12 15:18:45 +000026 echo -en $CNORM
David K. Bainbridgeb7285432019-07-02 22:05:24 -070027 echo ""
28 echo "ctrl-c trapped"
David Bainbridgec6a6eb62019-10-18 22:50:07 +000029 echo "Thank you for trying 'voltha up'"
David K. Bainbridgeb7285432019-07-02 22:05:24 -070030 exit
31}
32
David K. Bainbridgeebf38d92020-02-10 10:46:31 -080033VOLTCTL_VERSION=${VOLTCTL_VERSION:-latest}
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -080034KIND_VERSION=${KIND_VERSION:-v0.5.1}
David K. Bainbridgeb3a99372020-01-08 14:39:06 -080035VK_RELEASE=${VK_RELEASE:-master}
Test User08ebbd92019-07-03 17:15:39 +000036
David Bainbridge38dc1e82019-08-12 15:18:45 +000037BLACK=
38RED=
39GREEN=
40YELLOW=
41BLUE=
42MAGENTA=
43CYAN=
44WHITE=
45BOLD=
46NORMAL=
47ERROR=
48CEOL=
49CNORM=
50CIVIS=
51if [ $FANCY -eq 1 ]; then
52 BLACK=$(tput setaf 0)
53 RED=$(tput setaf 1)
54 GREEN=$(tput setaf 2)
55 YELLOW=$(tput setaf 3)
56 BLUE=$(tput setaf 4)
57 MAGENTA=$(tput setaf 5)
58 CYAN=$(tput setaf 6)
59 WHITE=$(tput setaf 7)
60 BOLD=$(tput bold)
61 NORMAL=$(tput sgr0)
62 ERROR="\xe2\x9c\x97\x20"
63 CEOL=$(tput el)
64 CNORM=$(tput cnorm)
65 CIVIS=$(tput civis)
66fi
Test User7d866122019-07-09 17:52:35 +000067
Test User3d7ad8e2019-07-03 06:15:44 +000068TYPE=${TYPE:-minimal}
David Bainbridge0774b232019-08-02 06:37:19 +000069NAME=${NAME:-$TYPE}
David Bainbridgee87067b2019-08-12 22:00:12 +000070WITH_TIMINGS=${WITH_TIMINGS:-no}
Test User7d866122019-07-09 17:52:35 +000071WITH_BBSIM=${WITH_BBSIM:-no}
David Bainbridge5b7b96b2019-07-25 20:29:13 +000072WITH_RADIUS=${WITH_RADIUS:-no}
Matteo Scandolo78dfee02020-02-13 16:18:03 -080073WITH_EAPOL=${WITH_EAPOL:-yes}
74WITH_DHCP=${WITH_DHCP:-yes}
75WITH_IGMP=${WITH_IGMP:-no}
David Bainbridgeb270c202019-07-26 01:44:42 +000076WITH_ONOS=${WITH_ONOS:-yes}
David Bainbridge99ac7a22019-08-31 02:26:43 +000077WITH_CHAOS=${WITH_CHAOS:-no}
David Bainbridge46505fb2019-10-01 21:13:20 +000078WITH_ADAPTERS=${WITH_ADAPTERS:-yes}
79WITH_SIM_ADAPTERS=${WITH_SIM_ADAPTERS:-yes}
80WITH_OPEN_ADAPTERS=${WITH_OPEN_ADAPTERS:-yes}
David Bainbridge05cd8822019-11-19 17:43:53 +000081ONLY_ONE=${ONLY_ONE:-yes}
David Bainbridge2b19e832019-08-16 02:40:53 +000082CONFIG_SADIS=${CONFIG_SADIS:-no}
David Bainbridge27790d62019-08-13 22:43:19 +000083INSTALL_ONOS_APPS=${INSTALL_ONOS_APPS:-no}
Test Userba1e7e72019-07-10 22:27:54 +000084JUST_K8S=${JUST_K8S:-no}
85DEPLOY_K8S=${DEPLOY_K8S:-yes}
David K. Bainbridge0e89cb92019-07-17 11:30:10 -070086INSTALL_KUBECTL=${INSTALL_KUBECTL:-yes}
87INSTALL_HELM=${INSTALL_HELM:-yes}
David Bainbridge46505fb2019-10-01 21:13:20 +000088UPDATE_HELM_REPOS=${UPDATE_HELM_REPOS:-yes}
Matteo Scandolofab98622020-01-28 15:17:20 -080089WAIT_ON_DOWN=${WAIT_ON_DOWN:-yes}
David Bainbridge5b7b96b2019-07-25 20:29:13 +000090VOLTHA_LOG_LEVEL=${VOLTHA_LOG_LEVEL:-WARN}
David Bainbridge90fd8e32019-08-21 23:32:47 +000091VOLTHA_CHART=${VOLTHA_CHART:-onf/voltha}
92VOLTHA_CHART_VERSION=${VOLTHA_CHART_VERSION:-latest}
93VOLTHA_BBSIM_CHART=${VOLTHA_BBSIM_CHART:-onf/bbsim}
Matteo Scandolodcd29f52019-10-07 15:42:42 -070094VOLTHA_BBSIM_CHART_VERSION=${VOLTHA_BBSIM_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +000095VOLTHA_ADAPTER_SIM_CHART=${VOLTHA_ADAPTER_SIM_CHART:-onf/voltha-adapter-simulated}
David Bainbridge90fd8e32019-08-21 23:32:47 +000096VOLTHA_ADAPTER_SIM_CHART_VERSION=${VOLTHA_ADAPTER_SIM_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +000097VOLTHA_ADAPTER_OPEN_OLT_CHART=${VOLTHA_ADAPTER_OPEN_OLT_CHART:-onf/voltha-adapter-openolt}
David Bainbridge90fd8e32019-08-21 23:32:47 +000098VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION=${VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +000099VOLTHA_ADAPTER_OPEN_ONU_CHART=${VOLTHA_ADAPTER_OPEN_ONU_CHART:-onf/voltha-adapter-openonu}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000100VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION=${VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION:-latest}
Andrea Campanella21323292019-12-18 11:44:19 -0800101ONOS_CHART_VERSION=${ONOS_CHART_VERSION:-latest}
David Bainbridge70c0ea82019-11-14 23:25:26 +0000102EXTRA_HELM_INSTALL_ARGS=
Test Userba1e7e72019-07-10 22:27:54 +0000103
104HAVE_GO=$(which go >/dev/null 2>&1 && echo "yes" || echo "no")
105HOSTOS=$(uname -s | tr "[:upper:]" "[:lower:"])
106HOSTARCH=$(uname -m | tr "[:upper:]" "[:lower:"])
107if [ $HOSTARCH == "x86_64" ]; then
108 HOSTARCH="amd64"
109fi
Test User7d866122019-07-09 17:52:35 +0000110
111# Verify TYPE setting
112if [ $(echo ":minimal:full:" | grep -ic ":$TYPE:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700113 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$TYPE value of '$TYPE'. Should be 'minimal' or 'full'${NORMAL}"
Test User7d866122019-07-09 17:52:35 +0000114 exit 1
115fi
116
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000117# Used to verify configuration values are set to "yes" or "no" value or convert
118# equivalents to "yes" or "no"
119function verify_yes_no() {
120 local VAR=$1
121 local VAL=$(eval echo \$$VAR)
122 if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$VAL:") -eq 0 ]; then
123 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid '$VAR' value of '$VAL'. Should be 'yes' or 'no'${NORMAL}"
124 echo "INVALID"
125 return 1
126 fi
127 if [ $(echo ":y:yes:true:1:" | grep -ic ":$VAL:") -eq 1 ]; then
128 echo "yes"
129 else
130 echo "no"
131 fi
132 return 0
133}
Test User7d866122019-07-09 17:52:35 +0000134
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000135ALL_YES_NO="\
136 WITH_TIMINGS \
137 WITH_BBSIM \
138 WITH_RADIUS \
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800139 WITH_EAPOL \
140 WITH_DHCP \
141 WITH_IGMP \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000142 WITH_ONOS \
David Bainbridge99ac7a22019-08-31 02:26:43 +0000143 WITH_CHAOS \
David Bainbridge46505fb2019-10-01 21:13:20 +0000144 WITH_ADAPTERS \
145 WITH_SIM_ADAPTERS \
146 WITH_OPEN_ADAPTERS \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000147 CONFIG_SADIS \
148 JUST_K8S \
149 DEPLOY_K8S \
150 INSTALL_ONOS_APPS \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000151 INSTALL_KUBECTL \
152 INSTALL_HELM \
David Bainbridge46505fb2019-10-01 21:13:20 +0000153 UPDATE_HELM_REPOS \
David Bainbridge4f1b5562019-08-19 04:46:52 +0000154 WAIT_ON_DOWN \
David Bainbridge70c0ea82019-11-14 23:25:26 +0000155 ONLY_ONE \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000156 "
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000157
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000158ALL_OPTIONS="\
159 NAME \
160 TYPE \
161 $ALL_YES_NO \
162 VOLTHA_LOG_LEVEL \
163 VOLTHA_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000164 VOLTHA_CHART_VERSION \
165 VOLTHA_BBSIM_CHART \
166 VOLTHA_BBSIM_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000167 VOLTHA_ADAPTER_SIM_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000168 VOLTHA_ADAPTER_SIM_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000169 VOLTHA_ADAPTER_OPEN_OLT_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000170 VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000171 VOLTHA_ADAPTER_OPEN_ONU_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000172 VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION \
Andrea Campanella21323292019-12-18 11:44:19 -0800173 ONOS_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000174 ONOS_API_PORT \
175 ONOS_SSH_PORT \
176 VOLTHA_API_PORT \
177 VOLTHA_SSH_PORT \
178 VOLTHA_ETCD_PORT \
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800179 VOLTHA_KAFKA_PORT \
David K. Bainbridge8f7f30b2020-01-08 13:06:16 -0800180 VK_RELEASE \
181 KIND_VERSION \
182 VOLTCTL_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000183 "
David Bainbridge01294952019-07-30 19:33:45 +0000184
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000185# Iterate over yes/no configuration options and validate
186for VAR in $ALL_YES_NO; do
187 eval $VAR=$(verify_yes_no $VAR)
188 if [ "$(eval echo \$$VAR)" == "INVALID" ]; then
189 exit 1;
190 fi
191done
David Bainbridgeb270c202019-07-26 01:44:42 +0000192
David Bainbridge0774b232019-08-02 06:37:19 +0000193mkdir -p .voltha
194touch .voltha/ports
195HAVE=$(grep $NAME .voltha/ports)
196if [ "$HAVE X" == " X" ]; then
197 # Find free port prefix
198 START=81
199 while true; do
200 if [ $(grep -c $START .voltha/ports) -eq 0 ]; then
201 break
202 fi
203 START=$(expr $START + 1)
204 done
205 DELTA=$(expr $START - 81)
David Bainbridgea2595422019-10-22 03:54:28 +0000206 ONOS_API_PORT=${ONOS_API_PORT:-${START}81}
207 ONOS_SSH_PORT=${ONOS_SSH_PORT:-${START}01}
208 VOLTHA_API_PORT=${VOLTHA_API_PORT:-5$(expr 55 + $DELTA)55}
209 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$(expr 50 + $DELTA)22}
210 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$(expr 23 + $DELTA)79}
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800211 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(expr 90 + $DELTA)92}
Test User01ed0642019-07-03 20:17:06 +0000212else
David Bainbridge0774b232019-08-02 06:37:19 +0000213 VALUES=$(echo $HAVE | sed -e 's/\s//g' | cut -d= -f2)
David Bainbridgea2595422019-10-22 03:54:28 +0000214 ONOS_API_PORT=${ONOS_API_PORT:-$(echo $VALUES | cut -d, -f1)}
215 ONOS_SSH_PORT=${ONOS_SSH_PORT:-$(echo $VALUES | cut -d, -f2)}
216 VOLTHA_API_PORT=${VOLTHA_API_PORT:-$(echo $VALUES | cut -d, -f3)}
217 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$(echo $VALUES | cut -d, -f4)}
218 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$(echo $VALUES | cut -d, -f5)}
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800219 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(echo $VALUES | cut -d, -f6)}
220
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800221 # A bit of a hueristic required here as the KAFKA port forward was
222 # added after the .voltha/ports files was created. Basically, if
223 # the VOLTHA_KAFKA_PORT isn't in the file then calculate the original
224 # DELTA from the VOLTHA_SSH_PORT and apply it to the VOLTHA_KAFKA_PORT
225 if [ -z "$VOLTHA_KAFKA_PORT" ]; then
226 DELTA=$((VOLTHA_SSH_PORT/100-50))
227 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(expr 90 + $DELTA)92}
228 fi
Test User01ed0642019-07-03 20:17:06 +0000229fi
230
David Bainbridge0774b232019-08-02 06:37:19 +0000231PORTTMP=$(mktemp -u)
232cat .voltha/ports | grep -v $NAME > $PORTTMP
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800233echo "$NAME=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT,$VOLTHA_KAFKA_PORT" >> $PORTTMP
David Bainbridge0774b232019-08-02 06:37:19 +0000234cp $PORTTMP .voltha/ports
235rm -f $PORTTMP
236
David Bainbridge27790d62019-08-13 22:43:19 +0000237export ONOS_API_PORT ONOS_SSH_PORT
David Bainbridge01294952019-07-30 19:33:45 +0000238
Test Userd87942b2019-07-03 07:20:24 +0000239IDX=1
David Bainbridgee87067b2019-08-12 22:00:12 +0000240CLOCK="TIME:"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000241SPIN_PARTS=
242NOT_VERIFIED=
David Bainbridgef858a022019-08-14 21:25:11 +0000243THEX=
244BUILD=
245CROSS=
246ENTER=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000247VERIFIED=
248HELM=
249OLD_KEY=
250BIRD=
251HIGH_VOLTAGE=
252PLUG=
253RESTART=
254FORWARD=
255INSTALL=
256STOP=
257GO=
258DOWNLOAD=
259GEAR=
260NO_ENTRY=
261LOCK=
262
263if [ $FANCY -eq 1 ]; then
264 SPIN_PARTS="\
265 \xe2\xa2\x8e\xe2\xa1\xb0 \
266 \xe2\xa2\x8e\xe2\xa1\xa1 \
267 \xe2\xa2\x8e\xe2\xa1\x91 \
268 \xe2\xa2\x8e\xe2\xa0\xb1 \
269 \xe2\xa0\x8e\xe2\xa1\xb1 \
270 \xe2\xa2\x8a\xe2\xa1\xb1 \
271 \xe2\xa2\x8c\xe2\xa1\xb1 \
272 \xe2\xa2\x86\xe2\xa1\xb1 \
273 "
David Bainbridgee87067b2019-08-12 22:00:12 +0000274 CLOCK="\xe2\x8f\xb1"
David Bainbridgef858a022019-08-14 21:25:11 +0000275 THEX="${RED}${BOLD}\xe2\x9c\x97\x20${NORMAL}"
276 ENTER="${YELLOW}${BOLD}\xe2\x8e\x86${NORMAL}"
277 CROSS="${YELLOW}${BOLD}\xe2\x9c\x9a${NORMAL}"
278 BUILD="${YELLOW}${BOLD}\xf0\x9f\x8f\x97${NORMAL}"
279 NOT_VERIFIED="$BUILD"
280 VERIFIED="${GREEN}${BOLD}\xe2\x9c\x93\x20${NORMAL}"
281 HELM="${BLUE}${BOLD}\xE2\x8E\x88${NORMAL}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000282 OLD_KEY="\xF0\x9F\x97\x9D"
283 BIRD="\xF0\x9F\x90\xA6"
284 HIGH_VOLTAGE="\xE2\x9A\xA1"
285 PLUG="\xF0\x9F\xa7\xa9"
286 RESTART="\xf0\x9f\x94\x84"
287 FORWARD="\xE2\x87\xA8"
288 INSTALL="\xF0\x9F\x8F\x97"
289 STOP="\xf0\x9f\x9b\x91"
290 GO="\xf0\x9f\x9a\x80"
291 DOWNLOAD="\xf0\x9f\x93\xa5"
292 GEAR="\xe2\x9a\x99"
293 NO_ENTRY="\xe2\x9b\x94"
294 LOCK="\xf0\x9f\x94\x92"
295fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700296
David Bainbridge712afb82019-08-14 19:55:58 +0000297duration() {
David Bainbridgee87067b2019-08-12 22:00:12 +0000298 local h=$(expr $1 / 3600)
299 local m=$(expr $1 % 3600 / 60)
300 local s=$(expr $1 % 60)
301 local t=""
302
303 if [ $h -gt 0 ]; then
304 t="$t${h}h"
305 fi
306 if [ $m -gt 0 ]; then
307 t="$t${m}m"
308 fi
David Bainbridge712afb82019-08-14 19:55:58 +0000309 echo "$t${s}s"
310}
311
312printtime() {
313 local INDENT=
314 if [ "$1" == "-" ]; then
315 INDENT=" "
316 shift
317 fi
318 echo -e "$INDENT $CLOCK $(duration $1)"
David Bainbridgee87067b2019-08-12 22:00:12 +0000319}
320
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700321bspin() {
Test Userd87942b2019-07-03 07:20:24 +0000322 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700323 local INDENT=
324 if [ "$1" == "-" ]; then
325 INDENT=" "
326 shift
327 fi
David Bainbridge38dc1e82019-08-12 15:18:45 +0000328 if [ $FANCY -eq 0 ]; then
329 LINE=$(echo $* | sed -e 's/[\s+-]//g')
330 if [ "$LINE X" == " X" ]; then
331 return
332 fi
333 echo -e "$CIVIS$INDENT$*"
334 else
335 echo -en "$CIVIS$INDENT $*"
336 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700337}
338
339sspin() {
340 local INDENT=
341 if [ "$1" == "-" ]; then
342 INDENT=" "
343 shift
344 fi
David Bainbridge38dc1e82019-08-12 15:18:45 +0000345 if [ $FANCY -eq 0 ]; then
346 LINE=$(echo $* | sed -e 's/[\s+-]//g')
347 if [ "$LINE X" == " X" ]; then
348 return
349 fi
350 echo -e "$INDENT$*"
351 else
352 C=$(echo $SPIN_PARTS | cut '-d ' -f $IDX)
353 echo -en "\r$INDENT$C $*"
354 IDX=$(expr $IDX + 1)
355 if [ $IDX -gt 8 ]; then
356 IDX=1
357 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700358 fi
359}
360
361espin() {
362 local INDENT=
363 if [ "$1" == "-" ]; then
364 INDENT=" "
365 shift
366 fi
David Bainbridge38dc1e82019-08-12 15:18:45 +0000367 if [ $FANCY -eq 0 ]; then
368 LINE=$(echo $* | sed -e 's/[\s+-]//g')
369 if [ "$LINE X" == " X" ]; then
370 return
371 fi
372 echo -e "$INDENT$*"
373 else
374 echo -e "\r$INDENT$*$CNORM"
375 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700376}
377
David Bainbridgeac7f8072019-08-01 22:15:33 +0000378if [ "$1" == "get" -a "$2" == "voltconfig" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000379 echo "$HOME/.volt/config-$NAME"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000380 exit
381fi
382
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -0700383if [ $# -ne 1 -o $(echo ":up:down:dump:" | grep -c ":$1:") -ne 1 ]; then
David Bainbridgeac7f8072019-08-01 22:15:33 +0000384 >&2 echo "What wouild you like to do today:"
385 >&2 echo " up - bring up voltha"
386 >&2 echo " down - tear down voltha"
387 >&2 echo " dump - create a debug dump of running system"
388 exit 1
389fi
390
David Bainbridge4f1b5562019-08-19 04:46:52 +0000391push_onos_config() {
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800392 local TYPE=$1
393 local MSG=$2
394 local RESOURCE=$3
395 local DATA=$4
David Bainbridge4f1b5562019-08-19 04:46:52 +0000396
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800397 # Thanks to the latest version of ONOS using the return code 207 this gets a
398 # whole lot nastier. Can't thank them enough for doing this. So in order to
399 # capture the command and the output in the log file as well as capture the
400 # status code to verify it is 200 and not 207 mutltiple files and a bit of
401 # hackery must be used. Thanks again ONOS.
402 local CMD_ECHO=$(mktemp -u)
403 local CMD_OUTPUT=$(mktemp -u)
404 local SC_OUTPUT=$(mktemp -u)
405
David Bainbridge4f1b5562019-08-19 04:46:52 +0000406 bspin - "$MSG $GEAR"
407 while true; do
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800408 if [ $TYPE == "file" ]; then
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800409 (set -x; curl --fail -sSL --user karaf:karaf -w "%{http_code}" -o $CMD_OUTPUT -X POST -H Content-Type:application/json http://127.0.0.1:$ONOS_API_PORT/onos/v1/$RESOURCE --data @$DATA >$SC_OUTPUT 2>/dev/null) >>$CMD_ECHO 2>&1
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800410 fi
411 if [ $TYPE == "json" ]; then
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800412 (set -x; curl --fail -sSL --user karaf:karaf -w "%{http_code}" -o $CMD_OUTPUT -X POST -H Content-Type:application/json http://127.0.0.1:$ONOS_API_PORT/onos/v1/$RESOURCE --data $DATA >$SC_OUTPUT 2>/dev/null) >>$CMD_ECHO 2>&1
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800413 fi
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800414 RESULT=$?
415 # Dump everything to the log
416 cat $CMD_ECHO >> $LOG
417 cat $CMD_OUTPUT >> $LOG
418 SC=$(cat $SC_OUTPUT)
419
420 # clean up temp files
421 rm -f $CMD_ECHO $CMD_OUTPUT $SC_OUTPUT
422 if [ $RESULT -eq 0 -a "$SC" == "200" ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000423 break
424 fi
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800425 sleep 1
David Bainbridge4f1b5562019-08-19 04:46:52 +0000426 sspin -
427 done
428 espin - $VERIFIED
429}
430
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800431check_onos_app_active() {
432 local APP_ID=$1
433
434 bspin - "Checking that $APP_ID is active $CLOCK"
435 while true; do
436 (set -x; curl --fail -sSL --user karaf:karaf -X GET http://127.0.0.1:$ONOS_API_PORT/onos/v1/applications/$APP_ID | grep ACTIVE >>$LOG 2>&1) >>$LOG 2>&1
437 if [ $? -eq 0 ]; then
438 break
439 fi
440 sleep 1
441 sspin -
442 done
443 sleep 5 # OSGI components take a little longer that the app to activate
444 espin - $VERIFIED
445}
446
David Bainbridge4f1b5562019-08-19 04:46:52 +0000447override_onos_app() {
448 local APP=$1
449 local NAME=$(basename $APP | sed -e 's/^[0-9][0-9]*-//g' -e 's/-.*$//g')
450 while true; do
451 sspin -
452 # Attempt to delete old version (if it exists)
453 (set -x; curl --fail -sSL --user karaf:karaf -X DELETE http://127.0.0.1:$ONOS_API_PORT/onos/v1/applications/$NAME >>$LOG 2>&1) >>$LOG 2>&1
454 sspin -
455 if [ $? -ne 0 ]; then
456 continue
457 fi
458 (set -x; curl --fail -sSL --user karaf:karaf -X POST -H Content-Type:application/octet-stream http://127.0.0.1:$ONOS_API_PORT/onos/v1/applications?activate=true --data-binary @$APP >>$LOG 2>&1) >>$LOG 2>&1
459 if [ $? -eq 0 ]; then
460 break
461 fi
462 sleep .2
463 done
464}
465
466activate_onos_app() {
467 local MSG="$1"
468 local APP=$2
469
470 bspin - "$MSG $GO"
471 while true; do
472 sspin -
473 (set -x; curl --fail -sSL --user karaf:karaf -X POST http://127.0.0.1:$ONOS_API_PORT/onos/v1/applications/$APP/active >>$LOG 2>&1) >>$LOG 2>&1
474 if [ $? -eq 0 ]; then
475 break
476 fi
477 sleep .2
478 done
479 espin - "$VERIFIED"
480}
481
482count_pods() {
483 local NAMESPACE=$1; shift
484 if [ "$NAMESPACE" == "all-namespaces" ]; then
485 NAMESPACE="--all-namespaces"
486 else
487 NAMESPACE="-n $NAMESPACE"
488 fi
489 echo "$NAMESPACE" > /tmp/t
490 local STATES=$1; shift
491 echo "$STATES" >> /tmp/t
492 local PODS=$(kubectl get $NAMESPACE pod -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}")
493 local COUNT=0
494 local PATTERNS="$*"
495 for POD in $PODS; do
496 local NAME=$(echo $POD | cut -d/ -f 1)
497 local STATE=$(echo $POD | cut -d/ -f 2)
498 local CONTAINERS=$(echo $POD | cut -d/ -f 3 | sed -e 's/_/ /g')
499 if [ "$STATES" == "*" -o $(echo "$STATES" | grep -c ":$STATE:") -ne 0 ]; then
500 echo "IN WITH $POD" >> /tmp/t
501 local TOTAL=$(echo $CONTAINERS | wc -w)
502 local FOUND=$(echo $CONTAINERS | grep -o true | wc -l)
503 if [ $TOTAL -eq $FOUND ]; then
504 for PATTERN in $PATTERNS; do
505 echo "TEST $PATTERN AGAINST $NAME" >> /tmp/t
506 if [[ $NAME =~ $PATTERN ]]; then
507 echo "COUNT $NAME" >> /tmp/t
508 COUNT=$(expr $COUNT + 1)
509 break
510 fi
511 done
512 fi
513 fi
514 done
515 echo $COUNT >> /tmp/t
516 echo $COUNT
517}
518
519wait_for_pods() {
520 local INDENT=
521 if [ "$1" == "-" ]; then
522 INDENT=$1; shift
523 fi
524 local NAMESPACE=$1; shift
525 local EXPECT=$1; shift
526 local TYPE=$1; shift
527 local RETRY=$1; shift
528 local MESSAGE=$1; shift
529 local PATTERNS=$*
David Bainbridge99ac7a22019-08-31 02:26:43 +0000530 local STATES=":Running:"
531 if [ "$TYPE" == "not" ]; then
532 STATES="*"
533 fi
534 local HAVE=$(count_pods $NAMESPACE "$STATES" $PATTERNS)
David Bainbridge4f1b5562019-08-19 04:46:52 +0000535 local ALL=$HAVE
536 if [ "$TYPE" == "only" ]; then
537 ALL=$(count_pods "all-namespaces" "*" ".*")
538 fi
539 COUNT=$(expr 300 / 15)
540 bspin $INDENT $MESSAGE
541 sspin $INDENT
542 if [ $HAVE -ne $EXPECT -o $ALL -ne $HAVE ]; then
543 while [ $HAVE -ne $EXPECT -o $ALL -ne $HAVE ]; do
544 sspin $INDENT
545 COUNT=$(expr $COUNT - 1)
546 if [ $COUNT -eq 0 ]; then
David Bainbridge99ac7a22019-08-31 02:26:43 +0000547 HAVE=$(count_pods $NAMESPACE "$STATES" $PATTERNS)
David Bainbridge4f1b5562019-08-19 04:46:52 +0000548 ALL=$HAVE
549 if [ "$TYPE" == "only" ]; then
550 ALL=$(count_pods "all-namespaces" "*" ".*")
551 fi
552 COUNT=$(expr 300 / 15)
553 fi
554 sleep .15
555 done
556 fi
557 espin $INDENT $VERIFIED
558 if [ $HAVE -ne $EXPECT ]; then
559 return 1
560 fi
561 return 0
562}
563
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800564port_forward() {
565 local NS=$1
566 local SVC=$2
567 local FROM_PORT=$3
568 local TO_PORT=$4
569 local TAG=$SVC-$NAME
570
571 (set -x; _TAG=$TAG bash -c "while true; do kubectl port-forward -n $NS service/$SVC $FROM_PORT:$TO_PORT; done" >>$LOG 2>&1 &) >>$LOG 2>&1
572}
573
574kill_port_forward() {
575 local TAG=$1-$NAME
David Bainbridgec6871d22019-11-13 17:10:31 +0000576 local P_IDS=$(ps e -ww -A | grep "_TAG=$TAG" | grep -v grep | awk '{print $1}')
David Bainbridgebcf235b2019-11-12 21:33:58 +0000577 local PARENTS=
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800578 local KIDS=
David Bainbridgec6871d22019-11-13 17:10:31 +0000579 local UNKNOWN=
580 if [ ! -z "$P_IDS" ]; then
581 for P_ID in $P_IDS; do
582 local PP_ID=$(ps -o ppid $P_ID | tail -n +2)
583 if [ ! -z "$PP_ID" ]; then
584 if [ $PP_ID -eq 1 ]; then
585 PARENTS="$PARENTS $P_ID"
586 else
587 KIDS="$KIDS $P_ID"
588 fi
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800589 else
David Bainbridgec6871d22019-11-13 17:10:31 +0000590 UNKNOWN="$UNKNOWN $P_ID"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800591 fi
592 done
David Bainbridgec6871d22019-11-13 17:10:31 +0000593 (set -x; kill -9 $PARENTS $KIDS $UNKNOWN >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800594 fi
595}
596
David Bainbridgeac7f8072019-08-01 22:15:33 +0000597if [ "$1" == "down" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000598 echo "Tearing down voltha cluster $NAME"
599 LOG="down-$NAME.log"
600 echo $(date -u +"%Y%m%dT%H%M%SZ") >$LOG
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800601 bspin "Remove port-forwards: onos-ui-$NAME"
602 kill_port_forward onos-ui
603 sspin "Remove port-forwards: onos-ssh-$NAME$CEOL"
604 kill_port_forward onos-ssh
605 sspin "Remove port-forwards: voltha-api-$NAME$CEOL"
606 kill_port_forward voltha-api
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800607 sspin "Remove port-forwards: voltha-etcd-$NAME$CEOL"
608 kill_port_forward voltha-etcd-cluster-client
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800609 sspin "Remove port-forwards: voltha-kafka-$NAME$CEOL"
610 kill_port_forward voltha-kafka
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800611 espin "$VERIFIED Remove port-forwards$CEOL"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000612 if [ $DEPLOY_K8S == "yes" ]; then
613 if [ -x ./bin/kind ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000614 bspin "Delete Kubernetes Kind Cluster"
615 (set -x; ./bin/kind delete cluster --name voltha-$NAME >>$LOG 2>&1) >>$LOG 2>&1
616 espin $VERIFIED
David Bainbridgeac7f8072019-08-01 22:15:33 +0000617 else
David Bainbridge0774b232019-08-02 06:37:19 +0000618 espin "$NO_ENTRY Delete Kubernetes Kind Cluster: kind command not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000619 fi
620 else
621 EXISTS=$(helm list -q)
622 EXPECT="etcd-operator onos open-olt open-onu sim voltha bbsim radius"
David Bainbridge0774b232019-08-02 06:37:19 +0000623 bspin "Remove Helm Deployments"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000624 for i in $EXISTS; do
625 if [ $(echo $EXPECT | grep -c $i) -eq 1 ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000626 sspin "Remove Helm Deployments: $i$CEOL"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800627 (set -x; ./bin/helm delete --no-hooks --purge $i >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000628 fi
629 done
David Bainbridge0774b232019-08-02 06:37:19 +0000630 espin "$VERIFIED Remove Helm Deployments$CEOL"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000631 if [ "$WAIT_ON_DOWN" == "yes" ]; then
632 # There should only be 13 or 15 PODs in the kube-system name
633 # space and no other PODs
David Bainbridge4f1b5562019-08-19 04:46:52 +0000634 PODS="coredns-.* \
635 etcd-voltha-$NAME-control-plane \
636 kindnet-.* \
637 kube-apiserver-voltha-$NAME-control-plane \
638 kube-controller-manager-voltha-$NAME-control-plane \
639 kube-proxy-.* \
640 kube-scheduler-voltha-$NAME-control-plane \
641 tiller-deploy-.*"
642 EXPECT=$(test "$TYPE" == "minimal" && echo "13" || echo "15")
David Bainbridge99ac7a22019-08-31 02:26:43 +0000643 PODS="adapter-.* \
644 bbsim.* \
645 etcd-operator.* \
646 radius.* \
647 voltha-.*"
Matteo Scandolo73442f92020-01-29 09:53:22 -0800648
David Bainbridge99ac7a22019-08-31 02:26:43 +0000649 EXPECT=0
650
Matteo Scandolo73442f92020-01-29 09:53:22 -0800651 if [ "$WITH_ONOS" == "yes" ]; then
652 ONOS_PODS="onos-.*"
653 wait_for_pods "default" $EXPECT "not" -1 "Waiting for ONOS PODs to terminate" $ONOS_PODS
654 fi
David Bainbridge99ac7a22019-08-31 02:26:43 +0000655 wait_for_pods "voltha" $EXPECT "not" -1 "Waiting for VOLTHA PODs to terminate" $PODS
David Bainbridge4f1b5562019-08-19 04:46:52 +0000656 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +0000657 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -0700658 exit
David Bainbridgeac7f8072019-08-01 22:15:33 +0000659fi
660
661if [ "$1" == "dump" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000662 LOG="dump-$NAME.log"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000663 TS=$(date -u +"%Y%m%dT%H%M%SZ")
David Bainbridge76514a02019-10-08 01:50:35 +0000664 if [ ! -z "$DUMP_FROM" ]; then
665 TS=$(echo $DUMP_FROM | sed -e 's/[:-]//g')
666 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +0000667 WORK=$(mktemp -u -d)
David Bainbridge0774b232019-08-02 06:37:19 +0000668 DATA=$WORK/voltha-debug-dump-$NAME-$TS
David Bainbridgeac7f8072019-08-01 22:15:33 +0000669 mkdir -p $DATA
670 echo $TS > $LOG
David Bainbridge0774b232019-08-02 06:37:19 +0000671 echo -e "Capturing debug dump to voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000672 bspin - "Copy install log"
David Bainbridge0774b232019-08-02 06:37:19 +0000673 if [ -f install-$NAME.log ]; then
674 (set -x; cp install-$NAME.log $DATA/install-$NAME.log) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000675 espin - $VERIFIED
676 else
David Bainbridge0774b232019-08-02 06:37:19 +0000677 espin - "$NO_ENTRY Copy install log: install-$NAME.log not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000678 fi
679 bspin - "Dumping Kubernetes PODs"
680 (set -x; kubectl get --all-namespaces pods >> $DATA/all-pods.txt 2>&1) >>$LOG 2>&1
681 espin - $VERIFIED
682 bspin - "Dumping Kubernetes SERVICEs"
683 (set -x; kubectl get --all-namespaces svc >> $DATA/all-services.txt 2>&1) >>$LOG 2>&1
684 espin - $VERIFIED
685 bspin - "Dumping Kubernetes EVENTs"
686 (set -x; kubectl get --all-namespaces events >> $DATA/all-events.txt 2>&1) >>$LOG 2>&1
687 espin - $VERIFIED
688 bspin - "Dumping VOLTHA POD details"
Matteo Scandolodcd29f52019-10-07 15:42:42 -0700689 PODS="$(kubectl -n default get pod -o name | grep onos | sed -e 's/^/default:/g') $(kubectl get -n voltha pod -o name | sed -e 's/^/voltha:/g')"
David Bainbridgecfd7ca12019-10-06 03:31:41 +0000690 SINCE=
691 if [ ! -z "$DUMP_FROM" ]; then
692 SINCE="--since-time=$DUMP_FROM"
693 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +0000694 for POD in $PODS; do
David Bainbridge1f0655a2019-10-01 22:08:48 +0000695 NS=$(echo $POD | cut -d: -f1)
696 POD=$(echo $POD | cut -d: -f2)
David Bainbridgeac7f8072019-08-01 22:15:33 +0000697 sspin - "Dumping VOLTHA POD details: $POD$CEOL"
698 mkdir -p $DATA/$POD
David Bainbridge1f0655a2019-10-01 22:08:48 +0000699 (set -x; kubectl describe -n $NS $POD >> $DATA/$POD/describe.txt 2>&1) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000700 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridgecfd7ca12019-10-06 03:31:41 +0000701 (set -x; kubectl logs -n $NS --all-containers $SINCE --previous $LOG_ARGS $POD >> $DATA/$POD/logs-previous.txt 2>&1) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000702 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridgecfd7ca12019-10-06 03:31:41 +0000703 (set -x; kubectl logs -n $NS --all-containers $SINCE $LOG_ARGS $POD >> $DATA/$POD/logs-current.txt 2>&1) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000704 sspin - "Dumping VOLTHA POD details: $POD"
705 done
706 espin - "$VERIFIED Dumping VOLTHA POD details$CEOL"
707 bspin - "Dumping ETCD"
708 if [ "$(which etcdctl) X" != " X" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000709 (set -x; ETCDCTL_API=3 etcdctl --endpoints localhost:$VOLTHA_ETCD_PORT get --prefix service/voltha | hexdump -C >> $DATA/etcd.hex 2>&1) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000710 espin - $VERIFIED
711 else
712 espin - "$NO_ENTRY Dumping ETCD: etcdctl command not available"
713 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000714 bspin - "Creating compressed TAR: voltha-debug-dump-$NAME-$TS.tgz"
715 (set -x; tar -C $WORK -zcf voltha-debug-dump-$NAME-$TS.tgz ./voltha-debug-dump-$NAME-$TS) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000716 espin - $VERIFIED
717 bspin - "Cleanup"
718 (set -x; rm -rf $WORK) >>$LOG 2>&1
719 espin - $VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +0000720 bspin - "$(ls -l voltha-debug-dump-$NAME-$TS.tgz)"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000721 espin - $VERIFIED
722 exit
723fi
724
David Bainbridge0774b232019-08-02 06:37:19 +0000725LOG="install-$NAME.log"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000726date > $LOG
David Bainbridge0774b232019-08-02 06:37:19 +0000727echo "PORTS=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT" >> $LOG
David Bainbridgeac7f8072019-08-01 22:15:33 +0000728
729# Output install options to log
730echo "OPTIONS" >> $LOG
David Bainbridgeac7f8072019-08-01 22:15:33 +0000731for O in $ALL_OPTIONS; do
732 VAL=$(eval echo \$$O)
David Bainbridgeac7f8072019-08-01 22:15:33 +0000733 if [ ! -z "$VAL" ]; then
734 printf " %-30s = %s\n" $O $VAL >> $LOG
735 fi
736done
737
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -0700738helm_install() {
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700739 local INDENT=
740 if [ "$1" == "-" ]; then
741 INDENT=$1; shift
742 fi
743 local NAMESPACE=$1; shift
David Bainbridge0774b232019-08-02 06:37:19 +0000744 local INAME=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700745 local CHART=$1; shift
David Bainbridge90fd8e32019-08-21 23:32:47 +0000746 local CHART_VERSION=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700747 local MESSAGE=$*
748
David Bainbridge90fd8e32019-08-21 23:32:47 +0000749 if [ "$CHART_VERSION X" != " X" -a "$CHART_VERSION" != "latest" ]; then
750 CHART_VERSION="--version $CHART_VERSION"
751 else
752 CHART_VERSION=
753 fi
754
David Bainbridge99ac7a22019-08-31 02:26:43 +0000755 local CHART_ARGS=
756 if [ -r "${INAME}-values.yaml" ]; then
757 CHART_ARGS="-f ${INAME}-values.yaml"
758 fi
759
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700760 COUNT=$(expr 300 / 15)
761 bspin $INDENT $MESSAGE
David Bainbridge70c0ea82019-11-14 23:25:26 +0000762 (set -x; helm install -f $NAME-values.yaml $CHART_ARGS $EXTRA_HELM_INSTALL_ARGS --set defaults.log_level=$VOLTHA_LOG_LEVEL --namespace $NAMESPACE --name $INAME $CHART_VERSION $EXTRA_HELM_FLAGS $CHART >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700763 SUCCESS=$?
764 while [ $SUCCESS -ne 0 ]; do
765 sspin $INDENT
766 COUNT=$(expr $COUNT - 1)
767 if [ $COUNT -eq 0 ]; then
Andy Baviere22ff252019-12-19 11:40:31 -0700768 (set -x; helm delete --purge $INAME >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridge99ac7a22019-08-31 02:26:43 +0000769 (set -x; helm install -f $NAME-values.yaml $CHART_ARGS --set defaults.log_level=$VOLTHA_LOG_LEVEL --namespace $NAMESPACE --name $INAME $CHART_VERSION $EXTRA_HELM_FLAGS $CHART >>$LOG 2>&1) >>$LOG 2>&1
Andy Baviere22ff252019-12-19 11:40:31 -0700770 SUCCESS=$?
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700771 COUNT=$(expr 300 / 15)
772 fi
773 sleep .15
774 done
775 espin $INDENT $VERIFIED
776}
777
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700778echo "INSTALL TYPE: $TYPE" >> $LOG
779
780bspin "Verify GOPATH"
781export GOPATH=$(pwd)
Test User3d7ad8e2019-07-03 06:15:44 +0000782mkdir -p $GOPATH/bin
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700783espin $VERIFIED
784
David Bainbridgee87067b2019-08-12 22:00:12 +0000785STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700786if [ "$INSTALL_KUBECTL" == "no" ]; then
787 bspin "Skip kubectl install"
788 espin $NO_ENTRY
Test Userc13bdc92019-07-03 20:57:49 +0000789else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700790 bspin "Verify kubectl $HELM"
791 if [ -x $GOPATH/bin/kubectl ]; then
792 espin $VERIFIED
793 else
794 espin $NOT_VERIFIED
795 bspin - "Download and install Kubernetes/kubectl $DOWNLOAD"
796 (set -x; curl -o $GOPATH/bin/kubectl -sSL https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/$HOSTOS/$HOSTARCH/kubectl >>$LOG 2>&1) >>$LOG 2>&1
797 (set -x; chmod 755 $GOPATH/bin/kubectl >>$LOG 2>&1) >>$LOG 2>&1
798 espin - $VERIFIED
799 fi
Test Userc13bdc92019-07-03 20:57:49 +0000800fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000801if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000802 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000803fi
Test Userc13bdc92019-07-03 20:57:49 +0000804
David Bainbridgee87067b2019-08-12 22:00:12 +0000805STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700806if [ "$DEPLOY_K8S" == "no" ]; then
807 bspin "Skip Kubernetes/Kind Deployment"
808 espin $NO_ENTRY
809else
Test Userba1e7e72019-07-10 22:27:54 +0000810 bspin "Verify Kubernetes/Kind $HELM"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800811 IS_INSTALLED=0
812 OP_TYPE="install"
Test Userba1e7e72019-07-10 22:27:54 +0000813 if [ -x $GOPATH/bin/kind ]; then
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800814 OP_TYPE="upgrade"
815 if [ $($GOPATH/bin/kind --version | grep -c $KIND_VERSION) -eq 1 ]; then
816 IS_INSTALLED=1
817 espin $VERIFIED
818 fi
819 fi
820 if [ $IS_INSTALLED -eq 0 ]; then
Test Userba1e7e72019-07-10 22:27:54 +0000821 espin $NOT_VERIFIED
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800822 bspin - "Download and $OP_TYPE Kubernetes/kind $DOWNLOAD"
David Bainbridge9e2a6662019-07-11 17:07:57 +0000823 (set -x; curl -o $GOPATH/bin/kind -sSL https://github.com/kubernetes-sigs/kind/releases/download/$KIND_VERSION/kind-$HOSTOS-$HOSTARCH >>$LOG 2>&1) >>$LOG 2>&1
Test Userba1e7e72019-07-10 22:27:54 +0000824 (set -x; chmod 755 $GOPATH/bin/kind >>$LOG 2>&1) >>$LOG 2>&1
825 espin - $VERIFIED
826 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700827fi
828
David Bainbridgee87067b2019-08-12 22:00:12 +0000829if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000830 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000831fi
832
833STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700834if [ "$INSTALL_HELM" == "no" ]; then
835 bspin "Skip Helm Install"
836 espin $NO_ENTRY
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700837else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700838 bspin "Verify Helm $HELM"
839 if [ -x $GOPATH/bin/helm ]; then
840 espin $VERIFIED
841 else
842 espin $NOT_VERIFIED
843 bspin - "Download and install Helm $DOWNLOAD"
David Bainbridgec6a6eb62019-10-18 22:50:07 +0000844 (set -x; curl -sSL https://git.io/get_helm.sh | DESIRED_VERSION=v2.14.3 USE_SUDO=false HELM_INSTALL_DIR=$GOPATH/bin bash >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700845 espin - $VERIFIED
846 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700847fi
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800848
David Bainbridgee87067b2019-08-12 22:00:12 +0000849if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000850 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000851fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700852
David Bainbridgee87067b2019-08-12 22:00:12 +0000853STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +0000854bspin "Verify voltctl $HIGH_VOLTAGE"
David Bainbridged2811972019-12-14 01:14:09 +0000855VOK=0
856VMESSAGE="install"
David K. Bainbridgeebf38d92020-02-10 10:46:31 -0800857export VC_VERSION="$VOLTCTL_VERSION"
858if [ "$VC_VERSION" == "latest" ]; then
859 export VC_VERSION=$(curl -sSL https://api.github.com/repos/opencord/voltctl/releases/latest | jq -r .tag_name | sed -e 's/^v//g')
860fi
Test User3d7ad8e2019-07-03 06:15:44 +0000861if [ -x $GOPATH/bin/voltctl ]; then
David Bainbridge1ba64f12019-12-18 00:40:13 +0000862 VHAVE=$($GOPATH/bin/voltctl version --clientonly -o json | jq -r .version)
David K. Bainbridgeebf38d92020-02-10 10:46:31 -0800863 if [ $? -eq 0 -a "$VHAVE" == "$VC_VERSION" ]; then
David Bainbridged2811972019-12-14 01:14:09 +0000864 VOK=1
David Bainbridge1ba64f12019-12-18 00:40:13 +0000865 espin $VERIFIED
866 else
David K. Bainbridgeebf38d92020-02-10 10:46:31 -0800867 VCHECK=$(echo -e "$VHAVE\n$VC_VERSION" | sort -V | head -1)
868 if [ "$VCHECK" == "$VHAVE" ]; then
869 VMESSAGE="upgrade"
870 else
871 VMESSAGE="downgrade"
872 fi
David Bainbridged2811972019-12-14 01:14:09 +0000873 fi
874fi
875
David Bainbridge1ba64f12019-12-18 00:40:13 +0000876if [ $VOK -eq 0 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700877 espin $NOT_VERIFIED
David Bainbridged2811972019-12-14 01:14:09 +0000878 bspin - "Download and $VMESSAGE voltctl $DOWNLOAD"
David K. Bainbridgeebf38d92020-02-10 10:46:31 -0800879 (set -x; curl -o $GOPATH/bin/voltctl -sSL https://github.com/opencord/voltctl/releases/download/v$VC_VERSION/voltctl-$VC_VERSION-$HOSTOS-$HOSTARCH >>$LOG 2>&1) >>$LOG 2>&1
Test User08ebbd92019-07-03 17:15:39 +0000880 (set -x; chmod 755 $GOPATH/bin/voltctl >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700881 espin - $VERIFIED
882fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000883if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000884 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000885fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700886
887bspin "Verify command PATH"
Test Userba1e7e72019-07-10 22:27:54 +0000888export PATH=$GOPATH/bin:$PATH
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700889espin $VERIFIED
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700890
David Bainbridgee87067b2019-08-12 22:00:12 +0000891STIME=$(date +%s)
Test Userba1e7e72019-07-10 22:27:54 +0000892if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000893 HAVE=$(kind get clusters | grep -c voltha-$NAME)
Test Userba1e7e72019-07-10 22:27:54 +0000894 bspin "Verify Kubernetes/Kind Cluster"
895 sspin
896 if [ $HAVE -eq 0 ]; then
David Bainbridge491b1bd2019-07-11 17:53:11 +0000897 espin $NOT_VERIFIED
898 bspin - "Verify cluster configuration"
David Bainbridge0774b232019-08-02 06:37:19 +0000899 if [ ! -r ./$NAME-cluster.cfg ]; then
David Bainbridge491b1bd2019-07-11 17:53:11 +0000900 espin - $NOT_VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +0000901 bspin - "Download cluster configuration: $TYPE-cluster.cfg to $NAME-cluster.cfg $DOWNLOAD"
David K. Bainbridgea00736b2020-01-08 14:33:17 -0800902 ERR_OUT=$(mktemp)
903 (set -x; curl --fail -o ./$NAME-cluster.cfg -sSL https://raw.githubusercontent.com/ciena/kind-voltha/$VK_RELEASE/$TYPE-cluster.cfg >>$LOG 2>>$ERR_OUT) >>$LOG 2>&1
904 if [ $? -ne 0 ]; then
905 espin - $THEX
906 echo -e "${RED}${BOLD}${ERROR}ERROR: $NAME-cluster.cfg${NORMAL}${RED} - $(cat $ERR_OUT)${NORMAL}"
907 echo "ERROR: $(cat $ERR_OUT)" >>$LOG
908 rm -rf $ERR_OUT ./$NAME-cluster.cfg
909 exit 1
910 fi
911 rm -rf $ERR_OUT
912 else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700913 espin - $VERIFIED
David K. Bainbridgea00736b2020-01-08 14:33:17 -0800914 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000915 kind create cluster --name voltha-$NAME --config $NAME-cluster.cfg
David Bainbridge491b1bd2019-07-11 17:53:11 +0000916 else
917 espin $VERIFIED
Test Userba1e7e72019-07-10 22:27:54 +0000918 fi
919
David Bainbridge0774b232019-08-02 06:37:19 +0000920 export KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$NAME")"
Test Userba1e7e72019-07-10 22:27:54 +0000921 P="coredns-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000922 etcd-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +0000923 kindnet-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000924 kube-apiserver-voltha-$NAME-control-plane \
925 kube-controller-manager-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +0000926 kube-proxy-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000927 kube-scheduler-voltha-$NAME-control-plane"
Test Userba1e7e72019-07-10 22:27:54 +0000928
929 EXPECT=$(test "$TYPE" == "minimal" && echo "12" || echo "14")
David Bainbridge4f1b5562019-08-19 04:46:52 +0000930 wait_for_pods - "kube-system" $EXPECT "includes" -1 "Waiting for system PODs to start" $P
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700931fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000932if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000933 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000934fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700935
David Bainbridgee87067b2019-08-12 22:00:12 +0000936STIME=$(date +%s)
David Bainbridge4c6289c2019-09-03 21:11:32 +0000937COUNT=$(count_pods "kube-system" ":Running:" "tiller-deploy-.*")
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700938bspin "Verify Helm"
Test Userba1e7e72019-07-10 22:27:54 +0000939if [ $COUNT -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700940 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000941 echo -e "Configuring Helm $GEAR"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700942 if [ "$INSTALL_HELM" == "no" ]; then
943 bspin - "Skip Helm/Tiller Initialization"
944 espin - $NO_ENTRY
945 else
946 bspin - "Initialize Helm"
947 (set -x; helm init --upgrade >>$LOG 2>&1) >>$LOG 2>&1
948 espin - $VERIFIED
David Bainbridge4f1b5562019-08-19 04:46:52 +0000949 wait_for_pods - "kube-system" 1 "includes" -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700950 fi
Test Userb5712372019-07-03 21:52:17 +0000951 bspin - "Add Google Incubator repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700952 (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
953 espin - $VERIFIED
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -0700954
Test Userba1e7e72019-07-10 22:27:54 +0000955 # HACK (sort-of) - the config for tiller is about to be patched, which will
956 # cause the tiller pod to be recreated. This can sometimes cause a timing
957 # issue with the "wait_for_pods" call on tiller as it may incorrectly
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -0700958 # identify the running/ready tiller pod that is soon to be terminated as
Test Userba1e7e72019-07-10 22:27:54 +0000959 # what it is waiting for. To avoid this issue we do a clean scale down and
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -0700960 # scale up of the pod so the script controlls when it should be expecting
Test Userba1e7e72019-07-10 22:27:54 +0000961 # things
962 (set -x; kubectl -n kube-system scale deploy tiller-deploy --replicas=0 >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700963
Test Userb5712372019-07-03 21:52:17 +0000964 bspin - "Add Google Stable repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700965 (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
966 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000967 bspin - "Add ONF repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700968 (set -x; helm repo add onf https://charts.opencord.org >>$LOG 2>&1) >>$LOG 2>&1
969 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000970 bspin - "Update Helm repository cache"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700971 (set -x; helm repo update >>$LOG 2>&1) >>$LOG 2>&1
972 espin - $VERIFIED
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -0700973
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700974 # Create and k8s service account so that Helm can create pods
Test Userb5712372019-07-03 21:52:17 +0000975 bspin - "Create Tiller ServiceAccount"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700976 (set -x; kubectl create serviceaccount --namespace kube-system tiller >>$LOG 2>&1) >>$LOG 2>&1
977 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000978 bspin - "Create Tiller ClusterRoleBinding"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700979 (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>$LOG 2>&1) >>$LOG 2>&1
980 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000981 bspin - "Update Tiller Manifest"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700982 (set -x; kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}' >>$LOG 2>&1) >>$LOG 2>&1
Test Userba1e7e72019-07-10 22:27:54 +0000983
984 # HACK (sort-of) - part to, spin it back up
985 (set -x; kubectl -n kube-system scale deploy tiller-deploy --replicas=1 >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700986 espin - $VERIFIED
987else
988 espin $VERIFIED
David Bainbridge46505fb2019-10-01 21:13:20 +0000989 if [ "$UPDATE_HELM_REPOS" == "yes" ]; then
990 bspin - "Update Helm repository cache"
991 (set -x; helm repo update >>$LOG 2>&1) >>$LOG 2>&1
992 espin - $VERIFIED
993 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700994fi
David Bainbridge4f1b5562019-08-19 04:46:52 +0000995wait_for_pods - "kube-system" 1 "includes" -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +0000996if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000997 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000998fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700999
David Bainbridgee87067b2019-08-12 22:00:12 +00001000STIME=$(date +%s)
David Bainbridge0774b232019-08-02 06:37:19 +00001001bspin "Verify Helm values file: $NAME-values.yaml"
1002if [ ! -r "./$NAME-values.yaml" ]; then
Test Userba1e7e72019-07-10 22:27:54 +00001003 espin $NOT_VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +00001004 bspin - "Download Helm values file: $TYPE-values.yaml to $NAME-values.yaml $DOWNLOAD"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001005 ERR_OUT=$(mktemp)
1006 (set -x; curl --fail -o ./$NAME-values.yaml -sSL https://raw.githubusercontent.com/ciena/kind-voltha/$VK_RELEASE/$TYPE-values.yaml >>$LOG 2>$ERR_OUT) >>$LOG 2>&1
1007 if [ $? -ne 0 ]; then
1008 espin - $THEX
1009 echo -e "${RED}${BOLD}${ERROR}ERROR: $NAME-values.yaml${NORMAL}${RED} - $(cat $ERR_OUT)${NORMAL}"
1010 echo "ERROR: $(cat $ERR_OUT)" >>$LOG
1011 rm -rf $ERR_OUT ./$NAME-values.yaml
1012 exit 1
1013 fi
1014 rm -rf $ERR_OUT
Test Userba1e7e72019-07-10 22:27:54 +00001015 espin - $VERIFIED
1016else
1017 espin $VERIFIED
1018fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001019if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001020 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001021fi
Test Userba1e7e72019-07-10 22:27:54 +00001022
David Bainbridge99ac7a22019-08-31 02:26:43 +00001023STIME=$(date +%s)
1024bspin "Verify or download chart specific values files $DOWNLOAD"
1025VALUES_FILES="monkey-values.yaml"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001026ERR_OUT=$(mktemp)
David Bainbridge99ac7a22019-08-31 02:26:43 +00001027for i in $VALUES_FILES; do
1028 if [ ! -r ./$i ]; then
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001029 (set -x; curl --fail -o ./$i -sSL https://raw.githubusercontent.com/ciena/kind-voltha/$VK_RELEASE/$i >>$LOG 2>$ERR_OUT) >>$LOG 2>&1
1030 if [ $? -ne 0 ]; then
1031 espin $THEX
1032 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat $ERR_OUT)${NORMAL}"
1033 echo "ERROR: $i - $(cat $ERR_OUT)" >>$LOG
1034 rm -rf $ERR_OUT ./$i
1035 exit 1
1036 fi
1037 rm -rf $ERR_OUT
David Bainbridge99ac7a22019-08-31 02:26:43 +00001038 fi
1039done
1040espin $VERIFIED
1041if [ "$WITH_TIMINGS" == "yes" ]; then
1042 printtime $(expr $(date +%s) - $STIME)
1043fi
1044
1045if [ "$WITH_CHAOS" == "yes" ]; then
1046 bspin "Verify or clone kube-monkey helm chart $DOWNLOAD"
1047 if [ -r ./kube-monkey ]; then
1048 espin $VERIFIED
1049 else
1050 espin $NOT_VERIFIED
1051 bspin - "GIT clone kube-monkey"
1052 (set -x; git clone https://github.com/asobti/kube-monkey kube-monkey >>$LOG 2>&1) >>$LOG 2>&1
1053 espin - $VERIFIED
1054 fi
1055fi
1056
Test Userba1e7e72019-07-10 22:27:54 +00001057if [ "$JUST_K8S" == "yes" ]; then
1058 echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye."
1059 echo ""
1060 echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
1061 echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
1062 echo "tools required by VOLTHA in your command path. " | tee -a $LOG
1063 echo "" | tee -a $LOG
1064 echo -en $BOLD
1065 if [ $DEPLOY_K8S == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001066 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +00001067 fi
1068 echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
1069 echo -en $NORMAL
1070 echo "" | tee -a $LOG
1071 echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
1072 exit 0
1073fi
1074
David Bainbridgee87067b2019-08-12 22:00:12 +00001075STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +00001076bspin "Verify ETCD Operator $OLD_KEY"
Test User7d866122019-07-09 17:52:35 +00001077if [ $(helm list --deployed --short --namespace voltha "^etcd-operator\$" | wc -l) -ne 1 ]; then
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001078 espin $NOT_VERIFIED
David Bainbridge90fd8e32019-08-21 23:32:47 +00001079 helm_install - voltha etcd-operator stable/etcd-operator latest "Install ETCD Operator"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001080else
1081 espin $VERIFIED
1082fi
Test User01ed0642019-07-03 20:17:06 +00001083EXPECT=$(test "$TYPE" == "minimal" && echo "1" || echo "3")
David Bainbridge4f1b5562019-08-19 04:46:52 +00001084wait_for_pods - "voltha" $EXPECT "includes" -1 "Waiting for ETCD Operator to start" "etcd-operator-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001085if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001086 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001087fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001088
David Bainbridgee87067b2019-08-12 22:00:12 +00001089STIME=$(date +%s)
David Bainbridgeb270c202019-07-26 01:44:42 +00001090if [ $WITH_ONOS == "yes" ]; then
1091 bspin "Verify ONOS installed $BIRD"
1092 if [ $(helm list --deployed --short --namespace default "^onos\$" | wc -l) -ne 1 ]; then
1093 espin $NOT_VERIFIED
Andrea Campanella6afcb082019-12-18 16:51:30 -08001094 EXTRA_HELM_FLAGS="$SET_TAG $EXTRA_HELM_FLAGS" helm_install - default onos onf/onos $ONOS_CHART_VERSION "Install ONOS"
David Bainbridgeb270c202019-07-26 01:44:42 +00001095 else
1096 espin $VERIFIED
1097 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +00001098 wait_for_pods - "default" 1 "includes" -1 "Waiting for ONOS to start" "onos-.*"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001099
David Bainbridgeb270c202019-07-26 01:44:42 +00001100 bspin - "Forward ONOS API port $FORWARD"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001101 kill_port_forward onos-ui
1102 port_forward default onos-ui $ONOS_API_PORT 8181
David Bainbridgeb270c202019-07-26 01:44:42 +00001103 espin - $VERIFIED
1104 bspin - "Forward ONOS SSH port $FORWARD"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001105 kill_port_forward onos-ssh
1106 port_forward default onos-ssh $ONOS_SSH_PORT 8101
David Bainbridgeb270c202019-07-26 01:44:42 +00001107 espin - $VERIFIED
David Bainbridged31d6122019-08-13 19:37:59 +00001108 bspin - "Verify or download ONOS configuration support files $DOWNLOAD"
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001109 ONOS_FILES="olt-onos-enableExtraneousRules.json onos-aaa.json \
David Bainbridge90fd8e32019-08-21 23:32:47 +00001110 onos-dhcpl2relay.json onos-kafka.json onos-sadis-sample.json"
David Bainbridged31d6122019-08-13 19:37:59 +00001111 (set -x; mkdir -p ./onos-files >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001112 ERR_OUT=$(mktemp)
David Bainbridge2b19e832019-08-16 02:40:53 +00001113 for i in $ONOS_FILES; do
David Bainbridged31d6122019-08-13 19:37:59 +00001114 if [ ! -r ./onos-files/$i ]; then
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001115 (set -x; curl --fail -o ./onos-files/$i -sSL https://raw.githubusercontent.com/ciena/kind-voltha/$VK_RELEASE/onos-files/$i >>$LOG 2>$ERR_OUT) >>$LOG 2>&1
1116 if [ $? -ne 0 ]; then
1117 espin - $THEX
1118 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat $ERR_OUT)${NORMAL}"
1119 echo "ERROR: $(cat $ERR_OUT)" >>$LOG
1120 rm -rf $ERR_OUT ./onos-files/$i
1121 exit 1
1122 fi
1123 rm -rf $ERR_OUT
David Bainbridged31d6122019-08-13 19:37:59 +00001124 fi
1125 done
Test Userba1e7e72019-07-10 22:27:54 +00001126 espin - $VERIFIED
David Bainbridge27790d62019-08-13 22:43:19 +00001127
1128 if [ $INSTALL_ONOS_APPS == "yes" ]; then
1129 bspin - "Installing custom ONOS applications"
1130 if [ -x onos-files/onos-apps -a $(ls -1 onos-files/onos-apps/*.oar 2>/dev/null | wc -l) -gt 0 ]; then
1131 for OAR in $(ls -1 onos-files/onos-apps/*.oar); do
1132 sspin - "Installing custom ONOS applications - $OAR$CEOL"
David Bainbridge2b19e832019-08-16 02:40:53 +00001133 override_onos_app $OAR
David Bainbridge27790d62019-08-13 22:43:19 +00001134 done
1135 espin - "$VERIFIED Installing custom ONOS applications$CEOL"
1136 else
1137 espin - "$NOT_VERIFIED Installing custom ONOS applications - None Found"
1138 fi
1139 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001140
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001141 check_onos_app_active org.opencord.kafka
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001142 push_onos_config "file" "Push ONOS Kafka Configuration" "network/configuration/apps/org.opencord.kafka" "onos-files/onos-kafka.json"
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001143 check_onos_app_active org.opencord.dhcpl2relay
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001144 push_onos_config "file" "Push ONOS DHCP L2 Relay Configuration" "network/configuration/apps/org.opencord.dhcpl2relay" "onos-files/onos-dhcpl2relay.json"
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001145 check_onos_app_active org.opencord.olt
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001146 # FIXME use WITH_DHCP and WITH_EAPOL flags to configre OLT App
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001147 # Default value for "enableEapol" is true in OLT App
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001148 if [ $WITH_EAPOL == "yes" ]; then
1149 push_onos_config "json" "Enable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":true}'
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001150 elif [ $WITH_EAPOL == "no" ]; then
1151 push_onos_config "json" "Disable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001152 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001153 # Default value for "enableDhcpOnProvisioning" is false and for "enableDhcpV4" is true in OLT App
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001154 if [ $WITH_DHCP == "yes" ]; then
1155 push_onos_config "json" "Enable VOLTHA ONOS DHCP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableDhcpOnProvisioning":true,"enableDhcpV4":true}'
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001156 elif [ $WITH_DHCP == "no" ]; then
1157 push_onos_config "json" "Disable VOLTHA ONOS DHCP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableDhcpOnProvisioning":false,"enableDhcpV4":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001158 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001159 # Default value for "enableIgmpOnProvisioning" is false in OLT App
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001160 if [ $WITH_IGMP == "yes" ]; then
1161 push_onos_config "json" "Enable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":true}'
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001162 elif [ $WITH_IGMP == "no" ]; then
1163 push_onos_config "json" "Disable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001164 fi
1165 push_onos_config "file" "Enabling extraneous rules for ONOS" "configuration/org.onosproject.net.flow.impl.FlowRuleManager" "onos-files/olt-onos-enableExtraneousRules.json"
David Bainbridge2b19e832019-08-16 02:40:53 +00001166 if [ -f onos-files/onos-sadis.json ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001167 push_onos_config "file" "[optional] Push ONOS SADIS Configuration" "network/configuration/apps/org.opencord.sadis" "onos-files/onos-sadis.json"
David Bainbridge2b19e832019-08-16 02:40:53 +00001168 elif [ "$CONFIG_SADIS" == "yes" ]; then
David Bainbridge90fd8e32019-08-21 23:32:47 +00001169 SADIS_CFG=onos-files/onos-sadis-sample.json
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001170 check_onos_app_active org.opencord.sadis
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001171 push_onos_config "file" "[optional] Push ONOS SADIS Configuration" "network/configuration/apps/org.opencord.sadis" "$SADIS_CFG"
David Bainbridge2b19e832019-08-16 02:40:53 +00001172 fi
Test Userba1e7e72019-07-10 22:27:54 +00001173fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001174if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001175 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001176fi
Test Userba1e7e72019-07-10 22:27:54 +00001177
David Bainbridgee87067b2019-08-12 22:00:12 +00001178STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +00001179bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
Test User7d866122019-07-09 17:52:35 +00001180if [ $(helm list --deployed --short --namespace voltha "^voltha\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001181 espin $NOT_VERIFIED
David Bainbridge70c0ea82019-11-14 23:25:26 +00001182 if [ "$ONLY_ONE" == "yes" ]; then
1183 EXTRA_HELM_INSTALL_ARGS="--set therecanbeonlyone=true"=
1184 fi
David Bainbridge90fd8e32019-08-21 23:32:47 +00001185 helm_install - voltha voltha $VOLTHA_CHART $VOLTHA_CHART_VERSION "Install VOLTHA Core"
David Bainbridge70c0ea82019-11-14 23:25:26 +00001186 EXTRA_HELM_INSTALL_ARGS=
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001187else
1188 espin $VERIFIED
1189fi
Test Userba1e7e72019-07-10 22:27:54 +00001190
David Bainbridge90fd8e32019-08-21 23:32:47 +00001191VOLTHA="voltha-ofagent-.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001192 ro-core.* \
1193 rw-core.* \
1194 voltha-api-server-.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001195 voltha-etcd-cluster-.* \
1196 voltha-kafka-.* \
1197 voltha-zookeeper-.*"
David Bainbridge70c0ea82019-11-14 23:25:26 +00001198if [ "$ONLY_ONE" == "yes" ]; then
David Bainbridge1ba64f12019-12-18 00:40:13 +00001199 EXPECT=$(test "$TYPE" == "minimal" && echo "5" || echo "7")
David Bainbridge70c0ea82019-11-14 23:25:26 +00001200else
David Bainbridge1ba64f12019-12-18 00:40:13 +00001201 EXPECT=$(test "$TYPE" == "minimal" && echo "8" || echo "10")
David Bainbridge70c0ea82019-11-14 23:25:26 +00001202fi
David Bainbridge4f1b5562019-08-19 04:46:52 +00001203wait_for_pods - "voltha" $EXPECT "includes" -1 "Waiting for VOLTHA Core to start" $VOLTHA
David Bainbridgee87067b2019-08-12 22:00:12 +00001204if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001205 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001206fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001207
David Bainbridge46505fb2019-10-01 21:13:20 +00001208if [ "$WITH_ADAPTERS" == "yes" ]; then
1209 STIME=$(date +%s)
1210 EXPECT=0
1211 echo -e "Verify Adapters $PLUG"
1212 if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then
1213 bspin - "Verify Simulated Adapters installed"
1214 if [ $(helm list --deployed --short --namespace voltha "^sim\$" | wc -l) -ne 1 ]; then
1215 espin - $NOT_VERIFIED
1216 helm_install - voltha sim $VOLTHA_ADAPTER_SIM_CHART $VOLTHA_ADAPTER_SIM_CHART_VERSION "Install Simulated Adapters"
1217 else
1218 espin - $VERIFIED
1219 fi
1220 EXPECT=$(expr $EXPECT + 2)
1221 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001222
David Bainbridge46505fb2019-10-01 21:13:20 +00001223 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
1224 bspin - "Verify OpenOLT Adapter installed"
1225 if [ $(helm list --deployed --short --namespace voltha "^open-olt\$" | wc -l) -ne 1 ]; then
1226 espin - $NOT_VERIFIED
1227 helm_install - voltha open-olt $VOLTHA_ADAPTER_OPEN_OLT_CHART $VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION "Install OpenOLT Adapter"
1228 else
1229 espin - $VERIFIED
1230 fi
1231 bspin - "Verify OpenONU Adapter installed"
1232 if [ $(helm list --deployed --short --namespace voltha "^open-onu\$" | wc -l) -ne 1 ]; then
1233 espin - $NOT_VERIFIED
1234 helm_install - voltha open-onu $VOLTHA_ADAPTER_OPEN_ONU_CHART $VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION "Install OpenONU Adapter"
1235 else
1236 espin - $VERIFIED
1237 fi
1238 EXPECT=$(expr $EXPECT + 2)
1239 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001240
David Bainbridge46505fb2019-10-01 21:13:20 +00001241 ADAPTERS="adapter-.*"
1242 wait_for_pods - "voltha" $EXPECT "includes" -1 "Waiting for adapters to start" $ADAPTERS
1243 if [ "$WITH_TIMINGS" == "yes" ]; then
1244 printtime $(expr $(date +%s) - $STIME)
1245 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001246fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001247
Test User7d866122019-07-09 17:52:35 +00001248if [ $WITH_BBSIM == "yes" ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +00001249 STIME=$(date +%s)
Test User7d866122019-07-09 17:52:35 +00001250 echo -e "Verify BBSIM $PLUG"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001251 bspin - "Verify BBSIM Installed"
Test User7d866122019-07-09 17:52:35 +00001252 if [ $(helm list --deployed --short --namespace voltha "^bbsim\$" | wc -l) -ne 1 ]; then
1253 espin - $NOT_VERIFIED
David Bainbridge90fd8e32019-08-21 23:32:47 +00001254 helm_install - voltha bbsim $VOLTHA_BBSIM_CHART $VOLTHA_BBSIM_CHART_VERSION "Install BBSIM"
Test User7d866122019-07-09 17:52:35 +00001255 else
1256 espin - $VERIFIED
1257 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +00001258 wait_for_pods - "voltha" 1 "includes" -1 "Waiting for BBSIM to start" "bbsim-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001259 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001260 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001261 fi
Test User7d866122019-07-09 17:52:35 +00001262fi
1263
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001264if [ $WITH_RADIUS == "yes" ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +00001265 STIME=$(date +%s)
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001266 echo -e "Verify RADIUS $LOCK"
1267 bspin - "Verify RADIUS Installed"
1268 if [ $(helm list --deployed --short --namespace voltha "^radius\$" | wc -l) -ne 1 ]; then
1269 espin - $NOT_VERIFIED
David Bainbridge90fd8e32019-08-21 23:32:47 +00001270 helm_install - voltha radius onf/freeradius latest "Install RADIUS"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001271 else
1272 espin - $VERIFIED
1273 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +00001274 wait_for_pods - "voltha" 1 "includes" -1 "Waiting for RADIUS to start" "radius-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001275 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001276 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001277 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001278fi
1279
David Bainbridgee87067b2019-08-12 22:00:12 +00001280STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +00001281bspin - "Forward VOLTHA API port $FORWARD"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001282kill_port_forward voltha-api
1283port_forward voltha voltha-api $VOLTHA_API_PORT 55555
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001284espin - $VERIFIED
David Bainbridgeac7f8072019-08-01 22:15:33 +00001285bspin - "Forward VOLTHA ETCD port $FORWARD"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001286kill_port_forward voltha-etcd-cluster-client
1287port_forward voltha voltha-etcd-cluster-client $VOLTHA_ETCD_PORT 2379
David Bainbridgeac7f8072019-08-01 22:15:33 +00001288espin - $VERIFIED
David K. Bainbridge00ecd382020-02-28 12:31:58 -08001289bspin - "Forward VOLTHA Kafka port $FORWARD"
1290kill_port_forward voltha-kafka
1291port_forward voltha voltha-kafka $VOLTHA_KAFKA_PORT 9092
1292espin - $VERIFIED
David Bainbridgee87067b2019-08-12 22:00:12 +00001293if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001294 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001295fi
Test User3d7ad8e2019-07-03 06:15:44 +00001296
David Bainbridgeb270c202019-07-26 01:44:42 +00001297if [ $WITH_ONOS == "yes" -a $WITH_RADIUS == "yes" ]; then
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001298 bspin "Configure ONOS RADIUS Connection $GEAR"
Andy Bavier658ebef2019-11-05 17:22:56 -07001299 (set -x; cat onos-files/onos-aaa.json | sed -e "s/:RADIUS_IP:/$(kubectl -n voltha get service/radius -o jsonpath={.spec.clusterIP})/g" | curl --fail -sSL --user karaf:karaf -X POST http://127.0.0.1:$ONOS_API_PORT/onos/v1/network/configuration/apps/org.opencord.aaa -H Content-type:application/json -d@- >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001300 espin $VERIFIED
1301fi
1302
David Bainbridge99ac7a22019-08-31 02:26:43 +00001303if [ "$WITH_CHAOS" == "yes" ]; then
1304 STIME=$(date +%s)
1305 echo -e "Verify kube-monkey $LOCK"
1306 bspin - "Verify kube-monkey Installed"
1307 if [ $(helm list --deployed --short --namespace kube-monkey "^monkey\$" | wc -l) -ne 1 ]; then
1308 espin - $NOT_VERIFIED
1309 helm_install - kube-monkey monkey ./kube-monkey/helm/kubemonkey latest "Install Chaos Monkey"
1310 else
1311 espin - $VERIFIED
1312 fi
1313 wait_for_pods - "kube-monkey" 1 "includes" -1 "Waiting for Chaos to start" "monkey-.*"
1314 if [ "$WITH_TIMINGS" == "yes" ]; then
1315 printtime $(expr $(date +%s) - $STIME)
1316 fi
1317fi
1318
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001319bspin "Create voltctl configuration file"
Test User3d7ad8e2019-07-03 06:15:44 +00001320(set -x; mkdir -p $HOME/.volt >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridge00ecd382020-02-28 12:31:58 -08001321(set -x; voltctl -a v3 -k localhost:$VOLTHA_KAFKA_PORT -s localhost:$VOLTHA_API_PORT config > $HOME/.volt/config-$NAME 2>>$LOG) >>$LOG 2>&1
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001322espin $VERIFIED
Test User08ebbd92019-07-03 17:15:39 +00001323
David Bainbridge0774b232019-08-02 06:37:19 +00001324if [ ! -f "$NAME-env.sh" ]; then
1325 touch $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001326fi
1327
David Bainbridge596f30d2019-07-30 17:07:59 +00001328for O in $ALL_OPTIONS; do
1329 VAL=$(eval echo \$$O)
David Bainbridge0774b232019-08-02 06:37:19 +00001330 if [ ! -z "$VAL" -a $(grep -c "^export $O=" $NAME-env.sh) -eq 0 ]; then
1331 echo "export $O=\"$(eval echo \$$O)\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001332 fi
1333done
1334
David Bainbridge0774b232019-08-02 06:37:19 +00001335if [ $DEPLOY_K8S == "yes" -a $(grep -c "^export KUBECONFIG=" $NAME-env.sh) -eq 0 ]; then
1336 echo "export KUBECONFIG=\"$(./bin/kind get kubeconfig-path --name=voltha-$NAME)\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001337fi
1338
David Bainbridge0774b232019-08-02 06:37:19 +00001339if [ $(grep -c "^export VOLTCONFIG=" $NAME-env.sh) -eq 0 ]; then
1340 echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001341fi
1342
David Bainbridge0774b232019-08-02 06:37:19 +00001343if [ $(grep -c "^export PATH=" $NAME-env.sh) -eq 0 ]; then
1344 echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001345fi
1346
Test User7d866122019-07-09 17:52:35 +00001347echo ""
Test User08ebbd92019-07-03 17:15:39 +00001348echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
1349echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
1350echo "tools required by VOLTHA in your command path. " | tee -a $LOG
1351echo "" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +00001352echo -en $BOLD
Test Userba1e7e72019-07-10 22:27:54 +00001353if [ $DEPLOY_K8S == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001354 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +00001355fi
David Bainbridge0774b232019-08-02 06:37:19 +00001356echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +00001357echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +00001358echo -en $NORMAL
Test User08ebbd92019-07-03 17:15:39 +00001359echo "" | tee -a $LOG
1360echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
1361
David Bainbridge712afb82019-08-14 19:55:58 +00001362if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridgef858a022019-08-14 21:25:11 +00001363 echo -e "$CLOCK ${BOLD}TOTAL: $(duration $(expr $(date +%s) - $TOTAL_START_TIME))${NORMAL}"
David Bainbridge712afb82019-08-14 19:55:58 +00001364fi