blob: 9ab3abb544be2fcd3012a2b6efa27eb00bfe76d9 [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"
29 echo "Thank you for trying 'votlha up'"
30 exit
31}
32
Test User08ebbd92019-07-03 17:15:39 +000033VOLTCTL_VERSION=${VOLTCTL_VERSION:-0.0.5-dev}
34KIND_VERSION=${KIND_VERSION:-v0.4.0}
35_VOLTCTL_VERSION=$(echo $VOLTCTL_VERSION | sed -e 's/-/_/g')
36
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}
David Bainbridgeb270c202019-07-26 01:44:42 +000073WITH_ONOS=${WITH_ONOS:-yes}
David Bainbridge2b19e832019-08-16 02:40:53 +000074CONFIG_SADIS=${CONFIG_SADIS:-no}
David Bainbridge27790d62019-08-13 22:43:19 +000075INSTALL_ONOS_APPS=${INSTALL_ONOS_APPS:-no}
David Bainbridge01294952019-07-30 19:33:45 +000076WITH_TP=${WITH_TP:-yes}
Test Userba1e7e72019-07-10 22:27:54 +000077JUST_K8S=${JUST_K8S:-no}
78DEPLOY_K8S=${DEPLOY_K8S:-yes}
David Bainbridgee10f6d52019-07-25 00:28:13 +000079SKIP_RESTART_API=${SKIP_RESTART_API:-no}
David K. Bainbridge0e89cb92019-07-17 11:30:10 -070080INSTALL_KUBECTL=${INSTALL_KUBECTL:-yes}
81INSTALL_HELM=${INSTALL_HELM:-yes}
David Bainbridge5b7b96b2019-07-25 20:29:13 +000082USE_GO=${USE_GO:-yes}
83VOLTHA_LOG_LEVEL=${VOLTHA_LOG_LEVEL:-WARN}
David Bainbridgee10f6d52019-07-25 00:28:13 +000084VOLTHA_CHART=${VOLTHA_CHART:=onf/voltha}
85VOLTHA_ADAPTER_SIM_CHART=${VOLTHA_ADAPTER_SIM_CHART:-onf/voltha-adapter-simulated}
86VOLTHA_ADAPTER_OPEN_OLT_CHART=${VOLTHA_ADAPTER_OPEN_OLT_CHART:-onf/voltha-adapter-openolt}
87VOLTHA_ADAPTER_OPEN_ONU_CHART=${VOLTHA_ADAPTER_OPEN_ONU_CHART:-onf/voltha-adapter-openonu}
Test Userba1e7e72019-07-10 22:27:54 +000088
89HAVE_GO=$(which go >/dev/null 2>&1 && echo "yes" || echo "no")
90HOSTOS=$(uname -s | tr "[:upper:]" "[:lower:"])
91HOSTARCH=$(uname -m | tr "[:upper:]" "[:lower:"])
92if [ $HOSTARCH == "x86_64" ]; then
93 HOSTARCH="amd64"
94fi
Test User7d866122019-07-09 17:52:35 +000095
96# Verify TYPE setting
97if [ $(echo ":minimal:full:" | grep -ic ":$TYPE:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -070098 >&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 +000099 exit 1
100fi
101
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000102# Used to verify configuration values are set to "yes" or "no" value or convert
103# equivalents to "yes" or "no"
104function verify_yes_no() {
105 local VAR=$1
106 local VAL=$(eval echo \$$VAR)
107 if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$VAL:") -eq 0 ]; then
108 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid '$VAR' value of '$VAL'. Should be 'yes' or 'no'${NORMAL}"
109 echo "INVALID"
110 return 1
111 fi
112 if [ $(echo ":y:yes:true:1:" | grep -ic ":$VAL:") -eq 1 ]; then
113 echo "yes"
114 else
115 echo "no"
116 fi
117 return 0
118}
Test User7d866122019-07-09 17:52:35 +0000119
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000120ALL_YES_NO="\
121 WITH_TIMINGS \
122 WITH_BBSIM \
123 WITH_RADIUS \
124 WITH_ONOS \
125 WITH_TP \
126 CONFIG_SADIS \
127 JUST_K8S \
128 DEPLOY_K8S \
129 INSTALL_ONOS_APPS \
130 SKIP_RESTART_API \
131 INSTALL_KUBECTL \
132 INSTALL_HELM \
133 USE_GO \
134 "
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000135
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000136ALL_OPTIONS="\
137 NAME \
138 TYPE \
139 $ALL_YES_NO \
140 VOLTHA_LOG_LEVEL \
141 VOLTHA_CHART \
142 VOLTHA_ADAPTER_SIM_CHART \
143 VOLTHA_ADAPTER_OPEN_OLT_CHART \
144 VOLTHA_ADAPTER_OPEN_ONU_CHART \
145 ONOS_TAG \
146 ONOS_API_PORT \
147 ONOS_SSH_PORT \
148 VOLTHA_API_PORT \
149 VOLTHA_SSH_PORT \
150 VOLTHA_ETCD_PORT \
151 "
David Bainbridge01294952019-07-30 19:33:45 +0000152
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000153# Iterate over yes/no configuration options and validate
154for VAR in $ALL_YES_NO; do
155 eval $VAR=$(verify_yes_no $VAR)
156 if [ "$(eval echo \$$VAR)" == "INVALID" ]; then
157 exit 1;
158 fi
159done
David Bainbridgeb270c202019-07-26 01:44:42 +0000160
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000161# Convert USE_GO from yes/no to true/false for helm chart usage
162if [ "$USE_GO" == "yes" ]; then
David Bainbridge1ceabc12019-07-25 17:21:05 +0000163 USE_GO=true
164else
165 USE_GO=false
166fi
167
David Bainbridge0774b232019-08-02 06:37:19 +0000168mkdir -p .voltha
169touch .voltha/ports
170HAVE=$(grep $NAME .voltha/ports)
171if [ "$HAVE X" == " X" ]; then
172 # Find free port prefix
173 START=81
174 while true; do
175 if [ $(grep -c $START .voltha/ports) -eq 0 ]; then
176 break
177 fi
178 START=$(expr $START + 1)
179 done
180 DELTA=$(expr $START - 81)
181 ONOS_API_PORT=${START}81
182 ONOS_SSH_PORT=${START}01
183 VOLTHA_API_PORT=5$(expr 55 + $DELTA)55
184 VOLTHA_SSH_PORT=$(expr 50 + $DELTA)22
185 VOLTHA_ETCD_PORT=$(expr 23 + $DELTA)79
Test User01ed0642019-07-03 20:17:06 +0000186else
David Bainbridge0774b232019-08-02 06:37:19 +0000187 VALUES=$(echo $HAVE | sed -e 's/\s//g' | cut -d= -f2)
188 ONOS_API_PORT=$(echo $VALUES | cut -d, -f1)
189 ONOS_SSH_PORT=$(echo $VALUES | cut -d, -f2)
190 VOLTHA_API_PORT=$(echo $VALUES | cut -d, -f3)
191 VOLTHA_SSH_PORT=$(echo $VALUES | cut -d, -f4)
192 VOLTHA_ETCD_PORT=$(echo $VALUES | cut -d, -f5)
Test User01ed0642019-07-03 20:17:06 +0000193fi
194
David Bainbridge0774b232019-08-02 06:37:19 +0000195PORTTMP=$(mktemp -u)
196cat .voltha/ports | grep -v $NAME > $PORTTMP
197echo "$NAME=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT" >> $PORTTMP
198cp $PORTTMP .voltha/ports
199rm -f $PORTTMP
200
David Bainbridge27790d62019-08-13 22:43:19 +0000201ONOS_TAG=${ONOS_TAG:-}
202if [ "$WITH_TP" == "yes" -a "$ONOS_TAG X" == " X" ]; then
203 ONOS_TAG="voltha-1.7"
David Bainbridge01294952019-07-30 19:33:45 +0000204fi
David Bainbridge27790d62019-08-13 22:43:19 +0000205export ONOS_API_PORT ONOS_SSH_PORT
David Bainbridge01294952019-07-30 19:33:45 +0000206
Test Userd87942b2019-07-03 07:20:24 +0000207IDX=1
David Bainbridgee87067b2019-08-12 22:00:12 +0000208CLOCK="TIME:"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000209SPIN_PARTS=
210NOT_VERIFIED=
David Bainbridgef858a022019-08-14 21:25:11 +0000211THEX=
212BUILD=
213CROSS=
214ENTER=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000215VERIFIED=
216HELM=
217OLD_KEY=
218BIRD=
219HIGH_VOLTAGE=
220PLUG=
221RESTART=
222FORWARD=
223INSTALL=
224STOP=
225GO=
226DOWNLOAD=
227GEAR=
228NO_ENTRY=
229LOCK=
230
231if [ $FANCY -eq 1 ]; then
232 SPIN_PARTS="\
233 \xe2\xa2\x8e\xe2\xa1\xb0 \
234 \xe2\xa2\x8e\xe2\xa1\xa1 \
235 \xe2\xa2\x8e\xe2\xa1\x91 \
236 \xe2\xa2\x8e\xe2\xa0\xb1 \
237 \xe2\xa0\x8e\xe2\xa1\xb1 \
238 \xe2\xa2\x8a\xe2\xa1\xb1 \
239 \xe2\xa2\x8c\xe2\xa1\xb1 \
240 \xe2\xa2\x86\xe2\xa1\xb1 \
241 "
David Bainbridgee87067b2019-08-12 22:00:12 +0000242 CLOCK="\xe2\x8f\xb1"
David Bainbridgef858a022019-08-14 21:25:11 +0000243 THEX="${RED}${BOLD}\xe2\x9c\x97\x20${NORMAL}"
244 ENTER="${YELLOW}${BOLD}\xe2\x8e\x86${NORMAL}"
245 CROSS="${YELLOW}${BOLD}\xe2\x9c\x9a${NORMAL}"
246 BUILD="${YELLOW}${BOLD}\xf0\x9f\x8f\x97${NORMAL}"
247 NOT_VERIFIED="$BUILD"
248 VERIFIED="${GREEN}${BOLD}\xe2\x9c\x93\x20${NORMAL}"
249 HELM="${BLUE}${BOLD}\xE2\x8E\x88${NORMAL}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000250 OLD_KEY="\xF0\x9F\x97\x9D"
251 BIRD="\xF0\x9F\x90\xA6"
252 HIGH_VOLTAGE="\xE2\x9A\xA1"
253 PLUG="\xF0\x9F\xa7\xa9"
254 RESTART="\xf0\x9f\x94\x84"
255 FORWARD="\xE2\x87\xA8"
256 INSTALL="\xF0\x9F\x8F\x97"
257 STOP="\xf0\x9f\x9b\x91"
258 GO="\xf0\x9f\x9a\x80"
259 DOWNLOAD="\xf0\x9f\x93\xa5"
260 GEAR="\xe2\x9a\x99"
261 NO_ENTRY="\xe2\x9b\x94"
262 LOCK="\xf0\x9f\x94\x92"
263fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700264
David Bainbridge712afb82019-08-14 19:55:58 +0000265duration() {
David Bainbridgee87067b2019-08-12 22:00:12 +0000266 local h=$(expr $1 / 3600)
267 local m=$(expr $1 % 3600 / 60)
268 local s=$(expr $1 % 60)
269 local t=""
270
271 if [ $h -gt 0 ]; then
272 t="$t${h}h"
273 fi
274 if [ $m -gt 0 ]; then
275 t="$t${m}m"
276 fi
David Bainbridge712afb82019-08-14 19:55:58 +0000277 echo "$t${s}s"
278}
279
280printtime() {
281 local INDENT=
282 if [ "$1" == "-" ]; then
283 INDENT=" "
284 shift
285 fi
286 echo -e "$INDENT $CLOCK $(duration $1)"
David Bainbridgee87067b2019-08-12 22:00:12 +0000287}
288
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700289bspin() {
Test Userd87942b2019-07-03 07:20:24 +0000290 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700291 local INDENT=
292 if [ "$1" == "-" ]; then
293 INDENT=" "
294 shift
295 fi
David Bainbridge38dc1e82019-08-12 15:18:45 +0000296 if [ $FANCY -eq 0 ]; then
297 LINE=$(echo $* | sed -e 's/[\s+-]//g')
298 if [ "$LINE X" == " X" ]; then
299 return
300 fi
301 echo -e "$CIVIS$INDENT$*"
302 else
303 echo -en "$CIVIS$INDENT $*"
304 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700305}
306
307sspin() {
308 local INDENT=
309 if [ "$1" == "-" ]; then
310 INDENT=" "
311 shift
312 fi
David Bainbridge38dc1e82019-08-12 15:18:45 +0000313 if [ $FANCY -eq 0 ]; then
314 LINE=$(echo $* | sed -e 's/[\s+-]//g')
315 if [ "$LINE X" == " X" ]; then
316 return
317 fi
318 echo -e "$INDENT$*"
319 else
320 C=$(echo $SPIN_PARTS | cut '-d ' -f $IDX)
321 echo -en "\r$INDENT$C $*"
322 IDX=$(expr $IDX + 1)
323 if [ $IDX -gt 8 ]; then
324 IDX=1
325 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700326 fi
327}
328
329espin() {
330 local INDENT=
331 if [ "$1" == "-" ]; then
332 INDENT=" "
333 shift
334 fi
David Bainbridge38dc1e82019-08-12 15:18:45 +0000335 if [ $FANCY -eq 0 ]; then
336 LINE=$(echo $* | sed -e 's/[\s+-]//g')
337 if [ "$LINE X" == " X" ]; then
338 return
339 fi
340 echo -e "$INDENT$*"
341 else
342 echo -e "\r$INDENT$*$CNORM"
343 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700344}
345
David Bainbridgeac7f8072019-08-01 22:15:33 +0000346if [ "$1" == "get" -a "$2" == "voltconfig" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000347 echo "$HOME/.volt/config-$NAME"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000348 exit
349fi
350
351if [ $# -ne 1 -o $(echo ":up:down:dump:" | grep -c ":$1:") -ne 1 ]; then
352 >&2 echo "What wouild you like to do today:"
353 >&2 echo " up - bring up voltha"
354 >&2 echo " down - tear down voltha"
355 >&2 echo " dump - create a debug dump of running system"
356 exit 1
357fi
358
359if [ "$1" == "down" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000360 echo "Tearing down voltha cluster $NAME"
361 LOG="down-$NAME.log"
362 echo $(date -u +"%Y%m%dT%H%M%SZ") >$LOG
David Bainbridgeac7f8072019-08-01 22:15:33 +0000363 if [ $DEPLOY_K8S == "yes" ]; then
364 if [ -x ./bin/kind ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000365 bspin "Delete Kubernetes Kind Cluster"
366 (set -x; ./bin/kind delete cluster --name voltha-$NAME >>$LOG 2>&1) >>$LOG 2>&1
367 espin $VERIFIED
David Bainbridgeac7f8072019-08-01 22:15:33 +0000368 else
David Bainbridge0774b232019-08-02 06:37:19 +0000369 espin "$NO_ENTRY Delete Kubernetes Kind Cluster: kind command not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000370 fi
371 else
372 EXISTS=$(helm list -q)
373 EXPECT="etcd-operator onos open-olt open-onu sim voltha bbsim radius"
David Bainbridge0774b232019-08-02 06:37:19 +0000374 bspin "Remove Helm Deployments"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000375 for i in $EXISTS; do
376 if [ $(echo $EXPECT | grep -c $i) -eq 1 ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000377 sspin "Remove Helm Deployments: $i$CEOL"
378 (set -x; ./bin/helm delete --purge $i >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000379 fi
380 done
David Bainbridge0774b232019-08-02 06:37:19 +0000381 espin "$VERIFIED Remove Helm Deployments$CEOL"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000382 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000383 bspin "Remove port-forwards: onos-ui-$NAME"
384 for i in $(screen -ls | grep onos-ui-$NAME | awk '{print $1}'); do
385 sspin
386 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
387 done
388 sspin "Remove port-forwards: onos-ssh-$NAME$CEOL"
389 for i in $(screen -ls | grep onos-ssh-$NAME | awk '{print $1}'); do
390 sspin
391 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
392 done
393 sspin "Remove port-forwards: voltha-api-$NAME$CEOL"
394 for i in $(screen -ls | grep voltha-api-$NAME | awk '{print $1}'); do
395 sspin
396 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
397 done
398 sspin "Remove port-forwards: voltha-ssh-$NAME$CEOL"
399 for i in $(screen -ls | grep voltha-ssh-$NAME | awk '{print $1}'); do
400 sspin
401 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
402 done
403 sspin "Remove port-forwards: voltha-etcd-$NAME$CEOL"
404 for i in $(screen -ls | grep voltha-etcd-$NAME | awk '{print $1}'); do
405 sspin
406 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
407 done
408 espin "$VERIFIED Remove port-forwards$CEOL"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000409 exit
410fi
411
412if [ "$1" == "dump" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000413 LOG="dump-$NAME.log"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000414 TS=$(date -u +"%Y%m%dT%H%M%SZ")
415 WORK=$(mktemp -u -d)
David Bainbridge0774b232019-08-02 06:37:19 +0000416 DATA=$WORK/voltha-debug-dump-$NAME-$TS
David Bainbridgeac7f8072019-08-01 22:15:33 +0000417 mkdir -p $DATA
418 echo $TS > $LOG
David Bainbridge0774b232019-08-02 06:37:19 +0000419 echo -e "Capturing debug dump to voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000420 bspin - "Copy install log"
David Bainbridge0774b232019-08-02 06:37:19 +0000421 if [ -f install-$NAME.log ]; then
422 (set -x; cp install-$NAME.log $DATA/install-$NAME.log) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000423 espin - $VERIFIED
424 else
David Bainbridge0774b232019-08-02 06:37:19 +0000425 espin - "$NO_ENTRY Copy install log: install-$NAME.log not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000426 fi
427 bspin - "Dumping Kubernetes PODs"
428 (set -x; kubectl get --all-namespaces pods >> $DATA/all-pods.txt 2>&1) >>$LOG 2>&1
429 espin - $VERIFIED
430 bspin - "Dumping Kubernetes SERVICEs"
431 (set -x; kubectl get --all-namespaces svc >> $DATA/all-services.txt 2>&1) >>$LOG 2>&1
432 espin - $VERIFIED
433 bspin - "Dumping Kubernetes EVENTs"
434 (set -x; kubectl get --all-namespaces events >> $DATA/all-events.txt 2>&1) >>$LOG 2>&1
435 espin - $VERIFIED
436 bspin - "Dumping VOLTHA POD details"
437 PODS=$(kubectl get -n voltha pod -o name)
438 for POD in $PODS; do
439 sspin - "Dumping VOLTHA POD details: $POD$CEOL"
440 mkdir -p $DATA/$POD
441 (set -x; kubectl describe -n voltha $POD >> $DATA/$POD/describe.txt 2>&1) >>$LOG 2>&1
442 sspin - "Dumping VOLTHA POD details: $POD"
443 (set -x; kubectl logs -n voltha --all-containers --previous $LOG_ARGS $POD >> $DATA/$POD/logs-previous.txt 2>&1) >>$LOG 2>&1
444 sspin - "Dumping VOLTHA POD details: $POD"
445 (set -x; kubectl logs -n voltha --all-containers $LOG_ARGS $POD >> $DATA/$POD/logs-current.txt 2>&1) >>$LOG 2>&1
446 sspin - "Dumping VOLTHA POD details: $POD"
447 done
448 espin - "$VERIFIED Dumping VOLTHA POD details$CEOL"
449 bspin - "Dumping ETCD"
450 if [ "$(which etcdctl) X" != " X" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000451 (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 +0000452 espin - $VERIFIED
453 else
454 espin - "$NO_ENTRY Dumping ETCD: etcdctl command not available"
455 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000456 bspin - "Creating compressed TAR: voltha-debug-dump-$NAME-$TS.tgz"
457 (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 +0000458 espin - $VERIFIED
459 bspin - "Cleanup"
460 (set -x; rm -rf $WORK) >>$LOG 2>&1
461 espin - $VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +0000462 bspin - "$(ls -l voltha-debug-dump-$NAME-$TS.tgz)"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000463 espin - $VERIFIED
464 exit
465fi
466
David Bainbridge0774b232019-08-02 06:37:19 +0000467LOG="install-$NAME.log"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000468date > $LOG
David Bainbridge0774b232019-08-02 06:37:19 +0000469echo "PORTS=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT" >> $LOG
David Bainbridgeac7f8072019-08-01 22:15:33 +0000470
471# Output install options to log
472echo "OPTIONS" >> $LOG
David Bainbridgeac7f8072019-08-01 22:15:33 +0000473for O in $ALL_OPTIONS; do
474 VAL=$(eval echo \$$O)
475 if [ $O == "USE_GO" ]; then
476 VAL="$(echo $VAL| test $(grep -c true) -eq 1 && echo yes || echo no)"
477 fi
478 if [ ! -z "$VAL" ]; then
479 printf " %-30s = %s\n" $O $VAL >> $LOG
480 fi
481done
482
David Bainbridged31d6122019-08-13 19:37:59 +0000483push_onos_config() {
484 local MSG=$1
485 local RESOURCE=$2
486 local DATA=$3
487
488 bspin - "$MSG $GEAR"
David Bainbridge2b19e832019-08-16 02:40:53 +0000489 while true; do
David Bainbridged31d6122019-08-13 19:37:59 +0000490 (set -x; curl --fail -sSL --user karaf:karaf -X POST -H Content-Type:application/json http://127.0.0.1:$ONOS_API_PORT/onos/v1/$RESOURCE --data @$DATA >>$LOG 2>&1) >>$LOG 2>&1
491 if [ $? -eq 0 ]; then
492 break
493 fi
494 sleep .2
495 sspin -
496 done
497 espin - $VERIFIED
498}
David Bainbridgeac7f8072019-08-01 22:15:33 +0000499
David Bainbridge27790d62019-08-13 22:43:19 +0000500override_onos_app() {
501 local APP=$1
David Bainbridge2b19e832019-08-16 02:40:53 +0000502 local NAME=$(basename $APP | sed -e 's/^[0-9][0-9]*-//g' -e 's/-.*$//g')
503 while true; do
David Bainbridge27790d62019-08-13 22:43:19 +0000504 sspin -
505 # Attempt to delete old version (if it exists)
506 (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
507 sspin -
David Bainbridge2b19e832019-08-16 02:40:53 +0000508 if [ $? -ne 0 ]; then
509 continue
510 fi
David Bainbridge27790d62019-08-13 22:43:19 +0000511 (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
512 if [ $? -eq 0 ]; then
513 break
514 fi
515 sleep .2
516 done
517}
518
David Bainbridge2b19e832019-08-16 02:40:53 +0000519activate_onos_app() {
520 local MSG="$1"
521 local APP=$2
522
523 bspin - "$MSG $GO"
524 while true; do
525 sspin -
526 (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
527 if [ $? -eq 0 ]; then
528 break
529 fi
530 sleep .2
531 done
532 espin - "$VERIFIED"
533}
534
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700535count_pods() {
536 local NAMESPACE=$1; shift
537 local PODS=$(kubectl -n $NAMESPACE get pod -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}")
538 local COUNT=0
539 local PATTERNS=$*
540 for POD in $PODS; do
541 local NAME=$(echo $POD | cut -d/ -f 1)
542 local STATE=$(echo $POD | cut -d/ -f 2)
543 local CONTAINERS=$(echo $POD | cut -d/ -f 3 | sed -e 's/_/ /g')
544 if [ "$STATE" == "Running" ]; then
545 local TOTAL=$(echo $CONTAINERS | wc -w)
546 local FOUND=$(echo $CONTAINERS | grep -o true | wc -l)
547 if [ $TOTAL -eq $FOUND ]; then
548 for PATTERN in $PATTERNS; do
549 if [[ $NAME =~ $PATTERN ]]; then
550 COUNT=$(expr $COUNT + 1)
551 fi
552 done
553 fi
554 fi
555 done
556 echo $COUNT
557}
558
559wait_for_pods() {
560 local INDENT=
561 if [ "$1" == "-" ]; then
562 INDENT=$1; shift
563 fi
564 local NAMESPACE=$1; shift
565 local EXPECT=$1; shift
566 local RETRY=$1; shift
567 local MESSAGE=$1; shift
568 local PATTERNS=$*
569 local HAVE=$(count_pods $NAMESPACE $PATTERNS)
570 COUNT=$(expr 300 / 15)
571 bspin $INDENT $MESSAGE
572 sspin $INDENT
573 if [ $HAVE -ne $EXPECT ]; then
574 while [ $HAVE -ne $EXPECT ]; do
575 sspin $INDENT
576 COUNT=$(expr $COUNT - 1)
577 if [ $COUNT -eq 0 ]; then
578 HAVE=$(count_pods $NAMESPACE $PATTERNS)
579 COUNT=$(expr 300 / 15)
580 fi
581 sleep .15
582 done
583 fi
584 espin $INDENT $VERIFIED
585 if [ $HAVE -ne $EXPECT ]; then
586 return 1
587 fi
588 return 0
589}
590
591helm_install() {
592 local INDENT=
593 if [ "$1" == "-" ]; then
594 INDENT=$1; shift
595 fi
596 local NAMESPACE=$1; shift
David Bainbridge0774b232019-08-02 06:37:19 +0000597 local INAME=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700598 local CHART=$1; shift
599 local MESSAGE=$*
600
601 COUNT=$(expr 300 / 15)
602 bspin $INDENT $MESSAGE
David Bainbridge458bb662019-08-02 20:04:23 +0000603 (set -x; helm install -f $NAME-values.yaml --set use_go=$USE_GO --set defaults.log_level=$VOLTHA_LOG_LEVEL --namespace $NAMESPACE --name $INAME $EXTRA_HELM_FLAGS $CHART >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700604 SUCCESS=$?
605 while [ $SUCCESS -ne 0 ]; do
606 sspin $INDENT
607 COUNT=$(expr $COUNT - 1)
608 if [ $COUNT -eq 0 ]; then
David Bainbridge458bb662019-08-02 20:04:23 +0000609 (set -x; helm install -f $NAME-values.yaml --set use_go=$USE_GO --set defaults.log_level=$VOLTHA_LOG_LEVEL --namespace $NAMESPACE --name $INAME $EXTRA_HELM_FLAGS $CHART >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700610 COUNT=$(expr 300 / 15)
611 fi
612 sleep .15
613 done
614 espin $INDENT $VERIFIED
615}
616
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700617echo "INSTALL TYPE: $TYPE" >> $LOG
618
619bspin "Verify GOPATH"
620export GOPATH=$(pwd)
Test User3d7ad8e2019-07-03 06:15:44 +0000621mkdir -p $GOPATH/bin
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700622espin $VERIFIED
623
David Bainbridgee87067b2019-08-12 22:00:12 +0000624STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700625if [ "$INSTALL_KUBECTL" == "no" ]; then
626 bspin "Skip kubectl install"
627 espin $NO_ENTRY
Test Userc13bdc92019-07-03 20:57:49 +0000628else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700629 bspin "Verify kubectl $HELM"
630 if [ -x $GOPATH/bin/kubectl ]; then
631 espin $VERIFIED
632 else
633 espin $NOT_VERIFIED
634 bspin - "Download and install Kubernetes/kubectl $DOWNLOAD"
635 (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
636 (set -x; chmod 755 $GOPATH/bin/kubectl >>$LOG 2>&1) >>$LOG 2>&1
637 espin - $VERIFIED
638 fi
Test Userc13bdc92019-07-03 20:57:49 +0000639fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000640if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000641 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000642fi
Test Userc13bdc92019-07-03 20:57:49 +0000643
David Bainbridgee87067b2019-08-12 22:00:12 +0000644STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700645if [ "$DEPLOY_K8S" == "no" ]; then
646 bspin "Skip Kubernetes/Kind Deployment"
647 espin $NO_ENTRY
648else
Test Userba1e7e72019-07-10 22:27:54 +0000649 bspin "Verify Kubernetes/Kind $HELM"
650 if [ -x $GOPATH/bin/kind ]; then
651 espin $VERIFIED
652 else
653 espin $NOT_VERIFIED
654 bspin - "Download and install Kubernetes/kind $DOWNLOAD"
David Bainbridge9e2a6662019-07-11 17:07:57 +0000655 (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 +0000656 (set -x; chmod 755 $GOPATH/bin/kind >>$LOG 2>&1) >>$LOG 2>&1
657 espin - $VERIFIED
658 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700659fi
660
David Bainbridgee87067b2019-08-12 22:00:12 +0000661if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000662 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000663fi
664
665STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700666if [ "$INSTALL_HELM" == "no" ]; then
667 bspin "Skip Helm Install"
668 espin $NO_ENTRY
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700669else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700670 bspin "Verify Helm $HELM"
671 if [ -x $GOPATH/bin/helm ]; then
672 espin $VERIFIED
673 else
674 espin $NOT_VERIFIED
675 bspin - "Download and install Helm $DOWNLOAD"
676 (set -x; curl -sSL https://git.io/get_helm.sh | USE_SUDO=false HELM_INSTALL_DIR=$GOPATH/bin bash >>$LOG 2>&1) >>$LOG 2>&1
677 espin - $VERIFIED
678 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700679fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000680if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000681 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000682fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700683
David Bainbridgee87067b2019-08-12 22:00:12 +0000684STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +0000685bspin "Verify voltctl $HIGH_VOLTAGE"
Test User3d7ad8e2019-07-03 06:15:44 +0000686if [ -x $GOPATH/bin/voltctl ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700687 espin $VERIFIED
688else
689 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000690 bspin - "Download and build voltctl $DOWNLOAD"
Test Userba1e7e72019-07-10 22:27:54 +0000691 (set -x; curl -o $GOPATH/bin/voltctl -sSL https://github.com/ciena/voltctl/releases/download/$VOLTCTL_VERSION/voltctl-$_VOLTCTL_VERSION-$HOSTOS-$HOSTARCH >>$LOG 2>&1) >>$LOG 2>&1
Test User08ebbd92019-07-03 17:15:39 +0000692 (set -x; chmod 755 $GOPATH/bin/voltctl >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700693 espin - $VERIFIED
694fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000695if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000696 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000697fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700698
699bspin "Verify command PATH"
Test Userba1e7e72019-07-10 22:27:54 +0000700export PATH=$GOPATH/bin:$PATH
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700701espin $VERIFIED
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700702
David Bainbridgee87067b2019-08-12 22:00:12 +0000703STIME=$(date +%s)
Test Userba1e7e72019-07-10 22:27:54 +0000704if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000705 HAVE=$(kind get clusters | grep -c voltha-$NAME)
Test Userba1e7e72019-07-10 22:27:54 +0000706 bspin "Verify Kubernetes/Kind Cluster"
707 sspin
708 if [ $HAVE -eq 0 ]; then
David Bainbridge491b1bd2019-07-11 17:53:11 +0000709 espin $NOT_VERIFIED
710 bspin - "Verify cluster configuration"
David Bainbridge0774b232019-08-02 06:37:19 +0000711 if [ ! -r ./$NAME-cluster.cfg ]; then
David Bainbridge491b1bd2019-07-11 17:53:11 +0000712 espin - $NOT_VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +0000713 bspin - "Download cluster configuration: $TYPE-cluster.cfg to $NAME-cluster.cfg $DOWNLOAD"
714 (set -x; curl -o ./$NAME-cluster.cfg -sSL https://raw.githubusercontent.com/ciena/kind-voltha/master/$TYPE-cluster.cfg >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700715 espin - $VERIFIED
716 else
717 espin - $VERIFIED
718 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000719 kind create cluster --name voltha-$NAME --config $NAME-cluster.cfg
David Bainbridge491b1bd2019-07-11 17:53:11 +0000720 else
721 espin $VERIFIED
Test Userba1e7e72019-07-10 22:27:54 +0000722 fi
723
David Bainbridge0774b232019-08-02 06:37:19 +0000724 export KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$NAME")"
Test Userba1e7e72019-07-10 22:27:54 +0000725 P="coredns-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000726 etcd-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +0000727 kindnet-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000728 kube-apiserver-voltha-$NAME-control-plane \
729 kube-controller-manager-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +0000730 kube-proxy-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000731 kube-scheduler-voltha-$NAME-control-plane"
Test Userba1e7e72019-07-10 22:27:54 +0000732
733 EXPECT=$(test "$TYPE" == "minimal" && echo "12" || echo "14")
734 wait_for_pods - "kube-system" $EXPECT -1 "Waiting for system PODs to start" $P
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700735fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000736if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000737 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000738fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700739
David Bainbridgee87067b2019-08-12 22:00:12 +0000740STIME=$(date +%s)
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700741COUNT=$(count_pods "kube-system" "tiller-deploy-.*")
742bspin "Verify Helm"
Test Userba1e7e72019-07-10 22:27:54 +0000743if [ $COUNT -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700744 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000745 echo -e "Configuring Helm $GEAR"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700746 if [ "$INSTALL_HELM" == "no" ]; then
747 bspin - "Skip Helm/Tiller Initialization"
748 espin - $NO_ENTRY
749 else
750 bspin - "Initialize Helm"
751 (set -x; helm init --upgrade >>$LOG 2>&1) >>$LOG 2>&1
752 espin - $VERIFIED
753 wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
754 fi
Test Userb5712372019-07-03 21:52:17 +0000755 bspin - "Add Google Incubator repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700756 (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
757 espin - $VERIFIED
Test Userba1e7e72019-07-10 22:27:54 +0000758
759 # HACK (sort-of) - the config for tiller is about to be patched, which will
760 # cause the tiller pod to be recreated. This can sometimes cause a timing
761 # issue with the "wait_for_pods" call on tiller as it may incorrectly
762 # identify the running/ready tiller pod that is soon to be terminated as
763 # what it is waiting for. To avoid this issue we do a clean scale down and
764 # scale up of the pod so the script controlls when it should be expecting
765 # things
766 (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 -0700767
Test Userb5712372019-07-03 21:52:17 +0000768 bspin - "Add Google Stable repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700769 (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
770 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000771 bspin - "Add ONF repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700772 (set -x; helm repo add onf https://charts.opencord.org >>$LOG 2>&1) >>$LOG 2>&1
773 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000774 bspin - "Update Helm repository cache"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700775 (set -x; helm repo update >>$LOG 2>&1) >>$LOG 2>&1
776 espin - $VERIFIED
777
778 # Create and k8s service account so that Helm can create pods
Test Userb5712372019-07-03 21:52:17 +0000779 bspin - "Create Tiller ServiceAccount"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700780 (set -x; kubectl create serviceaccount --namespace kube-system tiller >>$LOG 2>&1) >>$LOG 2>&1
781 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000782 bspin - "Create Tiller ClusterRoleBinding"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700783 (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>$LOG 2>&1) >>$LOG 2>&1
784 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000785 bspin - "Update Tiller Manifest"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700786 (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 +0000787
788 # HACK (sort-of) - part to, spin it back up
789 (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 -0700790 espin - $VERIFIED
791else
792 espin $VERIFIED
793fi
Test Userb5712372019-07-03 21:52:17 +0000794wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +0000795if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000796 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000797fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700798
David Bainbridgee87067b2019-08-12 22:00:12 +0000799STIME=$(date +%s)
David Bainbridge0774b232019-08-02 06:37:19 +0000800bspin "Verify Helm values file: $NAME-values.yaml"
801if [ ! -r "./$NAME-values.yaml" ]; then
Test Userba1e7e72019-07-10 22:27:54 +0000802 espin $NOT_VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +0000803 bspin - "Download Helm values file: $TYPE-values.yaml to $NAME-values.yaml $DOWNLOAD"
804 (set -x; curl -o ./$NAME-values.yaml -sSL https://raw.githubusercontent.com/ciena/kind-voltha/master/$TYPE-values.yaml >>$LOG 2>&1) >>$LOG 2>&1
Test Userba1e7e72019-07-10 22:27:54 +0000805 espin - $VERIFIED
806else
807 espin $VERIFIED
808fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000809if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000810 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000811fi
Test Userba1e7e72019-07-10 22:27:54 +0000812
813if [ "$JUST_K8S" == "yes" ]; then
814 echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye."
815 echo ""
816 echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
817 echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
818 echo "tools required by VOLTHA in your command path. " | tee -a $LOG
819 echo "" | tee -a $LOG
820 echo -en $BOLD
821 if [ $DEPLOY_K8S == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000822 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +0000823 fi
824 echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
825 echo -en $NORMAL
826 echo "" | tee -a $LOG
827 echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
828 exit 0
829fi
830
David Bainbridgee87067b2019-08-12 22:00:12 +0000831STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +0000832bspin "Verify ETCD Operator $OLD_KEY"
Test User7d866122019-07-09 17:52:35 +0000833if [ $(helm list --deployed --short --namespace voltha "^etcd-operator\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700834 espin $NOT_VERIFIED
835 helm_install - voltha etcd-operator stable/etcd-operator "Install ETCD Operator"
836else
837 espin $VERIFIED
838fi
Test User01ed0642019-07-03 20:17:06 +0000839EXPECT=$(test "$TYPE" == "minimal" && echo "1" || echo "3")
Test Userb5712372019-07-03 21:52:17 +0000840wait_for_pods - "voltha" $EXPECT -1 "Waiting for ETCD Operator to start" "etcd-operator-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +0000841if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000842 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000843fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700844
David Bainbridgee87067b2019-08-12 22:00:12 +0000845STIME=$(date +%s)
David Bainbridgeb270c202019-07-26 01:44:42 +0000846if [ $WITH_ONOS == "yes" ]; then
847 bspin "Verify ONOS installed $BIRD"
848 if [ $(helm list --deployed --short --namespace default "^onos\$" | wc -l) -ne 1 ]; then
849 espin $NOT_VERIFIED
David Bainbridge27790d62019-08-13 22:43:19 +0000850 SET_TAG=
851 if [ "$ONOS_TAG X" != " X" ]; then
852 SET_TAG="--set images.onos.tag=$ONOS_TAG"
853 fi
854 EXTRA_HELM_FLAGS="$SET_TAG $EXTRA_HELM_FLAGS" helm_install - default onos onf/onos "Install ONOS"
David Bainbridgeb270c202019-07-26 01:44:42 +0000855 else
856 espin $VERIFIED
857 fi
858 wait_for_pods - "default" 1 -1 "Waiting for ONOS to start" "onos-.*"
859
860 bspin - "Forward ONOS API port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +0000861 for i in $(screen -ls | grep onos-ui-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +0000862 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
863 done
David Bainbridge0774b232019-08-02 06:37:19 +0000864 (set -x; screen -dmS onos-ui-$NAME bash -c "while true; do kubectl port-forward service/onos-ui $ONOS_API_PORT:8181; done" >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridgeb270c202019-07-26 01:44:42 +0000865 espin - $VERIFIED
866 bspin - "Forward ONOS SSH port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +0000867 for i in $(screen -ls | grep onos-ssh-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +0000868 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
869 done
David Bainbridge2b19e832019-08-16 02:40:53 +0000870
871
David Bainbridge0774b232019-08-02 06:37:19 +0000872 (set -x; screen -dmS onos-ssh-$NAME bash -c "while true; do kubectl port-forward service/onos-ssh $ONOS_SSH_PORT:8101; done" >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridgeb270c202019-07-26 01:44:42 +0000873 espin - $VERIFIED
David Bainbridged31d6122019-08-13 19:37:59 +0000874 bspin - "Verify or download ONOS configuration support files $DOWNLOAD"
David Bainbridge2b19e832019-08-16 02:40:53 +0000875 ONOS_FILES="olt-onos-enableExtraneousRules.json olt-onos-olt-settings.json onos-aaa.json \
876 onos-dhcpl2relay.json onos-kafka.json onos-sadis-no-tp.json onos-sadis-tp.json"
David Bainbridged31d6122019-08-13 19:37:59 +0000877 (set -x; mkdir -p ./onos-files >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridge2b19e832019-08-16 02:40:53 +0000878 for i in $ONOS_FILES; do
David Bainbridged31d6122019-08-13 19:37:59 +0000879 if [ ! -r ./onos-files/$i ]; then
880 (set -x; curl -o ./onos-files/$i -sSL https://raw.githubusercontent.com/ciena/kind-voltha/master/onos-files/$i >>$LOG 2>&1) >>$LOG 2>&1
881 fi
882 done
Test Userba1e7e72019-07-10 22:27:54 +0000883 espin - $VERIFIED
David Bainbridge27790d62019-08-13 22:43:19 +0000884
885 if [ $INSTALL_ONOS_APPS == "yes" ]; then
886 bspin - "Installing custom ONOS applications"
887 if [ -x onos-files/onos-apps -a $(ls -1 onos-files/onos-apps/*.oar 2>/dev/null | wc -l) -gt 0 ]; then
888 for OAR in $(ls -1 onos-files/onos-apps/*.oar); do
889 sspin - "Installing custom ONOS applications - $OAR$CEOL"
David Bainbridge2b19e832019-08-16 02:40:53 +0000890 override_onos_app $OAR
David Bainbridge27790d62019-08-13 22:43:19 +0000891 done
892 espin - "$VERIFIED Installing custom ONOS applications$CEOL"
893 else
894 espin - "$NOT_VERIFIED Installing custom ONOS applications - None Found"
895 fi
896 fi
David Bainbridge2b19e832019-08-16 02:40:53 +0000897
898 push_onos_config "Push ONOS Kafka Configuration" "network/configuration/apps/org.opencord.kafka" "onos-files/onos-kafka.json"
899 push_onos_config "Push ONOS DHCP L2 Relay Configuration" "network/configuration/apps/org.opencord.dhcpl2relay" "onos-files/onos-dhcpl2relay.json"
David Bainbridged31d6122019-08-13 19:37:59 +0000900 push_onos_config "Enable VOLTHA ONOS DHCP provisioning" "configuration/org.opencord.olt.impl.Olt" "onos-files/olt-onos-olt-settings.json"
901 push_onos_config "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 +0000902 if [ -f onos-files/onos-sadis.json ]; then
903 push_onos_config "[optional] Push ONOS SADIS Configuration" "network/configuration/apps/org.opencord.sadis" "onos-files/onos-sadis.json"
904 elif [ "$CONFIG_SADIS" == "yes" ]; then
905 SADIS_CFG=onos-files/onos-sadis-no-tp.json
906 if [ "$WITH_TP" == "yes" ]; then
907 SADIS_CFG=onos-files/onos-sadis-tp.json
908 fi
909 push_onos_config "[optional] Push ONOS SADIS Configuration" "network/configuration/apps/org.opencord.sadis" "$SADIS_CFG"
910 fi
Test Userba1e7e72019-07-10 22:27:54 +0000911fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000912if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000913 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000914fi
Test Userba1e7e72019-07-10 22:27:54 +0000915
David Bainbridgee87067b2019-08-12 22:00:12 +0000916STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +0000917bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
Test User7d866122019-07-09 17:52:35 +0000918if [ $(helm list --deployed --short --namespace voltha "^voltha\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700919 espin $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +0000920 helm_install - voltha voltha $VOLTHA_CHART "Install VOLTHA Core"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700921else
922 espin $VERIFIED
923fi
Test Userba1e7e72019-07-10 22:27:54 +0000924
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700925VOLTHA="ofagent-.* \
926 ro-core.* \
927 rw-core.* \
928 voltha-api-server-.* \
929 voltha-cli-server-.* \
930 voltha-etcd-cluster-.* \
931 voltha-kafka-.* \
932 voltha-zookeeper-.*"
Test User01ed0642019-07-03 20:17:06 +0000933EXPECT=$(test "$TYPE" == "minimal" && echo "9" || echo "11")
Test Userb5712372019-07-03 21:52:17 +0000934wait_for_pods - "voltha" $EXPECT -1 "Waiting for VOLTHA Core to start" $VOLTHA
David Bainbridgee87067b2019-08-12 22:00:12 +0000935if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000936 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000937fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700938
David Bainbridgee87067b2019-08-12 22:00:12 +0000939STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +0000940echo -e "Verify Adapters $PLUG"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700941bspin - "Verify Simulated Adapters installed"
Test User7d866122019-07-09 17:52:35 +0000942if [ $(helm list --deployed --short --namespace voltha "^sim\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700943 espin - $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +0000944 helm_install - voltha sim $VOLTHA_ADAPTER_SIM_CHART "Install Simulated Adapters"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700945else
946 espin - $VERIFIED
947fi
948
949bspin - "Verify OpenOLT Adapter installed"
Test User7d866122019-07-09 17:52:35 +0000950if [ $(helm list --deployed --short --namespace voltha "^open-olt\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700951 espin - $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +0000952 helm_install - voltha open-olt $VOLTHA_ADAPTER_OPEN_OLT_CHART "Install OpenOLT Adapter"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700953else
954 espin - $VERIFIED
955fi
956bspin - "Verify OpenONU Adapter installed"
Test User7d866122019-07-09 17:52:35 +0000957if [ $(helm list --deployed --short --namespace voltha "^open-onu\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700958 espin - $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +0000959 helm_install - voltha open-onu $VOLTHA_ADAPTER_OPEN_ONU_CHART "Install OpenONU Adapter"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700960else
961 espin - $VERIFIED
962fi
963
964ADAPTERS="adapter-.*"
Test Userb5712372019-07-03 21:52:17 +0000965wait_for_pods - "voltha" 4 -1 "Waiting for adapters to start" $ADAPTERS
David Bainbridgee87067b2019-08-12 22:00:12 +0000966if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000967 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000968fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700969
Test User7d866122019-07-09 17:52:35 +0000970if [ $WITH_BBSIM == "yes" ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +0000971 STIME=$(date +%s)
Test User7d866122019-07-09 17:52:35 +0000972 echo -e "Verify BBSIM $PLUG"
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000973 bspin - "Verify BBSIM Installed"
Test User7d866122019-07-09 17:52:35 +0000974 if [ $(helm list --deployed --short --namespace voltha "^bbsim\$" | wc -l) -ne 1 ]; then
975 espin - $NOT_VERIFIED
976 helm_install - voltha bbsim onf/bbsim "Install BBSIM"
977 else
978 espin - $VERIFIED
979 fi
980 wait_for_pods - "voltha" 1 -1 "Waiting for BBSIM to start" "bbsim-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +0000981 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000982 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000983 fi
Test User7d866122019-07-09 17:52:35 +0000984fi
985
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000986if [ $WITH_RADIUS == "yes" ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +0000987 STIME=$(date +%s)
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000988 echo -e "Verify RADIUS $LOCK"
989 bspin - "Verify RADIUS Installed"
990 if [ $(helm list --deployed --short --namespace voltha "^radius\$" | wc -l) -ne 1 ]; then
991 espin - $NOT_VERIFIED
992 helm_install - voltha radius onf/freeradius "Install RADIUS"
993 else
994 espin - $VERIFIED
995 fi
996 wait_for_pods - "voltha" 1 -1 "Waiting for RADIUS to start" "radius-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +0000997 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000998 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000999 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001000fi
1001
David Bainbridgee87067b2019-08-12 22:00:12 +00001002STIME=$(date +%s)
David Bainbridgee10f6d52019-07-25 00:28:13 +00001003if [ $SKIP_RESTART_API == "no" ]; then
1004 echo -e "Restart VOLTHA API $RESTART"
1005 API="voltha-api-server-.* ofagent-.*"
1006 (set -x; kubectl scale --replicas=0 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1
1007 wait_for_pods - "voltha" 0 -1 "Wait for API to stop $STOP" $API
1008 (set -x; kubectl scale --replicas=1 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1
1009 wait_for_pods - "voltha" 2 -1 "Wait for API to re-start $GO" $API
1010else
1011 bspin "Skip VOLTHA API Restart"
1012 espin $NO_ENTRY
1013fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001014
Test Userb5712372019-07-03 21:52:17 +00001015bspin - "Forward VOLTHA API port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +00001016for i in $(screen -ls | grep voltha-api-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +00001017 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
1018done
David Bainbridge0774b232019-08-02 06:37:19 +00001019(set -x; screen -dmS voltha-api-$NAME bash -c "while true; do kubectl port-forward -n voltha service/voltha-api $VOLTHA_API_PORT:55555; done" >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001020espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +00001021bspin - "Forward VOLTHA SSH port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +00001022for i in $(screen -ls | grep voltha-ssh-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +00001023 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
1024done
David Bainbridge0774b232019-08-02 06:37:19 +00001025(set -x; screen -dmS voltha-ssh-$NAME bash -c "while true; do kubectl port-forward -n voltha service/voltha-cli $VOLTHA_SSH_PORT:5022; done" >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001026espin - $VERIFIED
David Bainbridgeac7f8072019-08-01 22:15:33 +00001027bspin - "Forward VOLTHA ETCD port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +00001028for i in $(screen -ls | grep voltha-etcd-$NAME | awk '{print $1}'); do
David Bainbridgeac7f8072019-08-01 22:15:33 +00001029 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
1030done
David Bainbridge0774b232019-08-02 06:37:19 +00001031(set -x; screen -dmS voltha-etcd-$NAME bash -c "while true; do kubectl port-forward -n voltha service/voltha-etcd-cluster-client $VOLTHA_ETCD_PORT:2379; done" >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +00001032espin - $VERIFIED
David Bainbridgee87067b2019-08-12 22:00:12 +00001033if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001034 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001035fi
Test User3d7ad8e2019-07-03 06:15:44 +00001036
David Bainbridgeb270c202019-07-26 01:44:42 +00001037if [ $WITH_ONOS == "yes" -a $WITH_RADIUS == "yes" ]; then
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001038 bspin "Configure ONOS RADIUS Connection $GEAR"
David Bainbridge2b19e832019-08-16 02:40:53 +00001039 (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 -XPOST -sSL http://karaf:karaf@localhost:8181/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 +00001040 espin $VERIFIED
1041fi
1042
1043bspin "Create voltctl configuration file"
Test User3d7ad8e2019-07-03 06:15:44 +00001044(set -x; mkdir -p $HOME/.volt >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridge0774b232019-08-02 06:37:19 +00001045(set -x; voltctl -a v2 -s localhost:$VOLTHA_API_PORT config > $HOME/.volt/config-$NAME 2>>$LOG) >>$LOG 2>&1
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001046espin $VERIFIED
Test User08ebbd92019-07-03 17:15:39 +00001047
David Bainbridge0774b232019-08-02 06:37:19 +00001048if [ ! -f "$NAME-env.sh" ]; then
1049 touch $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001050fi
1051
David Bainbridge596f30d2019-07-30 17:07:59 +00001052for O in $ALL_OPTIONS; do
1053 VAL=$(eval echo \$$O)
1054 if [ $O == "USE_GO" ]; then
1055 VAL="$(echo $VAL| test $(grep -c true) -eq 1 && echo yes || echo no)"
1056 fi
David Bainbridge0774b232019-08-02 06:37:19 +00001057 if [ ! -z "$VAL" -a $(grep -c "^export $O=" $NAME-env.sh) -eq 0 ]; then
1058 echo "export $O=\"$(eval echo \$$O)\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001059 fi
1060done
1061
David Bainbridge0774b232019-08-02 06:37:19 +00001062if [ $DEPLOY_K8S == "yes" -a $(grep -c "^export KUBECONFIG=" $NAME-env.sh) -eq 0 ]; then
1063 echo "export KUBECONFIG=\"$(./bin/kind get kubeconfig-path --name=voltha-$NAME)\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001064fi
1065
David Bainbridge0774b232019-08-02 06:37:19 +00001066if [ $(grep -c "^export VOLTCONFIG=" $NAME-env.sh) -eq 0 ]; then
1067 echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001068fi
1069
David Bainbridge0774b232019-08-02 06:37:19 +00001070if [ $(grep -c "^export PATH=" $NAME-env.sh) -eq 0 ]; then
1071 echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001072fi
1073
Test User7d866122019-07-09 17:52:35 +00001074echo ""
Test User08ebbd92019-07-03 17:15:39 +00001075echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
1076echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
1077echo "tools required by VOLTHA in your command path. " | tee -a $LOG
1078echo "" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +00001079echo -en $BOLD
Test Userba1e7e72019-07-10 22:27:54 +00001080if [ $DEPLOY_K8S == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001081 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +00001082fi
David Bainbridge0774b232019-08-02 06:37:19 +00001083echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +00001084echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +00001085echo -en $NORMAL
Test User08ebbd92019-07-03 17:15:39 +00001086echo "" | tee -a $LOG
1087echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
1088
David Bainbridge712afb82019-08-14 19:55:58 +00001089if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridgef858a022019-08-14 21:25:11 +00001090 echo -e "$CLOCK ${BOLD}TOTAL: $(duration $(expr $(date +%s) - $TOTAL_START_TIME))${NORMAL}"
David Bainbridge712afb82019-08-14 19:55:58 +00001091fi
1092