blob: c855c1fea3b390bba10cdc38a593a75ecf332a73 [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}
David Bainbridge4f1b5562019-08-19 04:46:52 +000083WAIT_ON_DOWN=${WAIT_ON_DOWN:-no}
David Bainbridge5b7b96b2019-07-25 20:29:13 +000084VOLTHA_LOG_LEVEL=${VOLTHA_LOG_LEVEL:-WARN}
David Bainbridgee10f6d52019-07-25 00:28:13 +000085VOLTHA_CHART=${VOLTHA_CHART:=onf/voltha}
86VOLTHA_ADAPTER_SIM_CHART=${VOLTHA_ADAPTER_SIM_CHART:-onf/voltha-adapter-simulated}
87VOLTHA_ADAPTER_OPEN_OLT_CHART=${VOLTHA_ADAPTER_OPEN_OLT_CHART:-onf/voltha-adapter-openolt}
88VOLTHA_ADAPTER_OPEN_ONU_CHART=${VOLTHA_ADAPTER_OPEN_ONU_CHART:-onf/voltha-adapter-openonu}
Test Userba1e7e72019-07-10 22:27:54 +000089
90HAVE_GO=$(which go >/dev/null 2>&1 && echo "yes" || echo "no")
91HOSTOS=$(uname -s | tr "[:upper:]" "[:lower:"])
92HOSTARCH=$(uname -m | tr "[:upper:]" "[:lower:"])
93if [ $HOSTARCH == "x86_64" ]; then
94 HOSTARCH="amd64"
95fi
Test User7d866122019-07-09 17:52:35 +000096
97# Verify TYPE setting
98if [ $(echo ":minimal:full:" | grep -ic ":$TYPE:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -070099 >&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 +0000100 exit 1
101fi
102
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000103# Used to verify configuration values are set to "yes" or "no" value or convert
104# equivalents to "yes" or "no"
105function verify_yes_no() {
106 local VAR=$1
107 local VAL=$(eval echo \$$VAR)
108 if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$VAL:") -eq 0 ]; then
109 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid '$VAR' value of '$VAL'. Should be 'yes' or 'no'${NORMAL}"
110 echo "INVALID"
111 return 1
112 fi
113 if [ $(echo ":y:yes:true:1:" | grep -ic ":$VAL:") -eq 1 ]; then
114 echo "yes"
115 else
116 echo "no"
117 fi
118 return 0
119}
Test User7d866122019-07-09 17:52:35 +0000120
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000121ALL_YES_NO="\
122 WITH_TIMINGS \
123 WITH_BBSIM \
124 WITH_RADIUS \
125 WITH_ONOS \
126 WITH_TP \
127 CONFIG_SADIS \
128 JUST_K8S \
129 DEPLOY_K8S \
130 INSTALL_ONOS_APPS \
131 SKIP_RESTART_API \
132 INSTALL_KUBECTL \
133 INSTALL_HELM \
134 USE_GO \
David Bainbridge4f1b5562019-08-19 04:46:52 +0000135 WAIT_ON_DOWN \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000136 "
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000137
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000138ALL_OPTIONS="\
139 NAME \
140 TYPE \
141 $ALL_YES_NO \
142 VOLTHA_LOG_LEVEL \
143 VOLTHA_CHART \
144 VOLTHA_ADAPTER_SIM_CHART \
145 VOLTHA_ADAPTER_OPEN_OLT_CHART \
146 VOLTHA_ADAPTER_OPEN_ONU_CHART \
147 ONOS_TAG \
148 ONOS_API_PORT \
149 ONOS_SSH_PORT \
150 VOLTHA_API_PORT \
151 VOLTHA_SSH_PORT \
152 VOLTHA_ETCD_PORT \
153 "
David Bainbridge01294952019-07-30 19:33:45 +0000154
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000155# Iterate over yes/no configuration options and validate
156for VAR in $ALL_YES_NO; do
157 eval $VAR=$(verify_yes_no $VAR)
158 if [ "$(eval echo \$$VAR)" == "INVALID" ]; then
159 exit 1;
160 fi
161done
David Bainbridgeb270c202019-07-26 01:44:42 +0000162
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000163# Convert USE_GO from yes/no to true/false for helm chart usage
164if [ "$USE_GO" == "yes" ]; then
David Bainbridge1ceabc12019-07-25 17:21:05 +0000165 USE_GO=true
166else
167 USE_GO=false
168fi
169
David Bainbridge0774b232019-08-02 06:37:19 +0000170mkdir -p .voltha
171touch .voltha/ports
172HAVE=$(grep $NAME .voltha/ports)
173if [ "$HAVE X" == " X" ]; then
174 # Find free port prefix
175 START=81
176 while true; do
177 if [ $(grep -c $START .voltha/ports) -eq 0 ]; then
178 break
179 fi
180 START=$(expr $START + 1)
181 done
182 DELTA=$(expr $START - 81)
183 ONOS_API_PORT=${START}81
184 ONOS_SSH_PORT=${START}01
185 VOLTHA_API_PORT=5$(expr 55 + $DELTA)55
186 VOLTHA_SSH_PORT=$(expr 50 + $DELTA)22
187 VOLTHA_ETCD_PORT=$(expr 23 + $DELTA)79
Test User01ed0642019-07-03 20:17:06 +0000188else
David Bainbridge0774b232019-08-02 06:37:19 +0000189 VALUES=$(echo $HAVE | sed -e 's/\s//g' | cut -d= -f2)
190 ONOS_API_PORT=$(echo $VALUES | cut -d, -f1)
191 ONOS_SSH_PORT=$(echo $VALUES | cut -d, -f2)
192 VOLTHA_API_PORT=$(echo $VALUES | cut -d, -f3)
193 VOLTHA_SSH_PORT=$(echo $VALUES | cut -d, -f4)
194 VOLTHA_ETCD_PORT=$(echo $VALUES | cut -d, -f5)
Test User01ed0642019-07-03 20:17:06 +0000195fi
196
David Bainbridge0774b232019-08-02 06:37:19 +0000197PORTTMP=$(mktemp -u)
198cat .voltha/ports | grep -v $NAME > $PORTTMP
199echo "$NAME=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT" >> $PORTTMP
200cp $PORTTMP .voltha/ports
201rm -f $PORTTMP
202
David Bainbridge27790d62019-08-13 22:43:19 +0000203ONOS_TAG=${ONOS_TAG:-}
204if [ "$WITH_TP" == "yes" -a "$ONOS_TAG X" == " X" ]; then
205 ONOS_TAG="voltha-1.7"
David Bainbridge01294952019-07-30 19:33:45 +0000206fi
David Bainbridge27790d62019-08-13 22:43:19 +0000207export ONOS_API_PORT ONOS_SSH_PORT
David Bainbridge01294952019-07-30 19:33:45 +0000208
Test Userd87942b2019-07-03 07:20:24 +0000209IDX=1
David Bainbridgee87067b2019-08-12 22:00:12 +0000210CLOCK="TIME:"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000211SPIN_PARTS=
212NOT_VERIFIED=
David Bainbridgef858a022019-08-14 21:25:11 +0000213THEX=
214BUILD=
215CROSS=
216ENTER=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000217VERIFIED=
218HELM=
219OLD_KEY=
220BIRD=
221HIGH_VOLTAGE=
222PLUG=
223RESTART=
224FORWARD=
225INSTALL=
226STOP=
227GO=
228DOWNLOAD=
229GEAR=
230NO_ENTRY=
231LOCK=
232
233if [ $FANCY -eq 1 ]; then
234 SPIN_PARTS="\
235 \xe2\xa2\x8e\xe2\xa1\xb0 \
236 \xe2\xa2\x8e\xe2\xa1\xa1 \
237 \xe2\xa2\x8e\xe2\xa1\x91 \
238 \xe2\xa2\x8e\xe2\xa0\xb1 \
239 \xe2\xa0\x8e\xe2\xa1\xb1 \
240 \xe2\xa2\x8a\xe2\xa1\xb1 \
241 \xe2\xa2\x8c\xe2\xa1\xb1 \
242 \xe2\xa2\x86\xe2\xa1\xb1 \
243 "
David Bainbridgee87067b2019-08-12 22:00:12 +0000244 CLOCK="\xe2\x8f\xb1"
David Bainbridgef858a022019-08-14 21:25:11 +0000245 THEX="${RED}${BOLD}\xe2\x9c\x97\x20${NORMAL}"
246 ENTER="${YELLOW}${BOLD}\xe2\x8e\x86${NORMAL}"
247 CROSS="${YELLOW}${BOLD}\xe2\x9c\x9a${NORMAL}"
248 BUILD="${YELLOW}${BOLD}\xf0\x9f\x8f\x97${NORMAL}"
249 NOT_VERIFIED="$BUILD"
250 VERIFIED="${GREEN}${BOLD}\xe2\x9c\x93\x20${NORMAL}"
251 HELM="${BLUE}${BOLD}\xE2\x8E\x88${NORMAL}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000252 OLD_KEY="\xF0\x9F\x97\x9D"
253 BIRD="\xF0\x9F\x90\xA6"
254 HIGH_VOLTAGE="\xE2\x9A\xA1"
255 PLUG="\xF0\x9F\xa7\xa9"
256 RESTART="\xf0\x9f\x94\x84"
257 FORWARD="\xE2\x87\xA8"
258 INSTALL="\xF0\x9F\x8F\x97"
259 STOP="\xf0\x9f\x9b\x91"
260 GO="\xf0\x9f\x9a\x80"
261 DOWNLOAD="\xf0\x9f\x93\xa5"
262 GEAR="\xe2\x9a\x99"
263 NO_ENTRY="\xe2\x9b\x94"
264 LOCK="\xf0\x9f\x94\x92"
265fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700266
David Bainbridge712afb82019-08-14 19:55:58 +0000267duration() {
David Bainbridgee87067b2019-08-12 22:00:12 +0000268 local h=$(expr $1 / 3600)
269 local m=$(expr $1 % 3600 / 60)
270 local s=$(expr $1 % 60)
271 local t=""
272
273 if [ $h -gt 0 ]; then
274 t="$t${h}h"
275 fi
276 if [ $m -gt 0 ]; then
277 t="$t${m}m"
278 fi
David Bainbridge712afb82019-08-14 19:55:58 +0000279 echo "$t${s}s"
280}
281
282printtime() {
283 local INDENT=
284 if [ "$1" == "-" ]; then
285 INDENT=" "
286 shift
287 fi
288 echo -e "$INDENT $CLOCK $(duration $1)"
David Bainbridgee87067b2019-08-12 22:00:12 +0000289}
290
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700291bspin() {
Test Userd87942b2019-07-03 07:20:24 +0000292 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700293 local INDENT=
294 if [ "$1" == "-" ]; then
295 INDENT=" "
296 shift
297 fi
David Bainbridge38dc1e82019-08-12 15:18:45 +0000298 if [ $FANCY -eq 0 ]; then
299 LINE=$(echo $* | sed -e 's/[\s+-]//g')
300 if [ "$LINE X" == " X" ]; then
301 return
302 fi
303 echo -e "$CIVIS$INDENT$*"
304 else
305 echo -en "$CIVIS$INDENT $*"
306 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700307}
308
309sspin() {
310 local INDENT=
311 if [ "$1" == "-" ]; then
312 INDENT=" "
313 shift
314 fi
David Bainbridge38dc1e82019-08-12 15:18:45 +0000315 if [ $FANCY -eq 0 ]; then
316 LINE=$(echo $* | sed -e 's/[\s+-]//g')
317 if [ "$LINE X" == " X" ]; then
318 return
319 fi
320 echo -e "$INDENT$*"
321 else
322 C=$(echo $SPIN_PARTS | cut '-d ' -f $IDX)
323 echo -en "\r$INDENT$C $*"
324 IDX=$(expr $IDX + 1)
325 if [ $IDX -gt 8 ]; then
326 IDX=1
327 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700328 fi
329}
330
331espin() {
332 local INDENT=
333 if [ "$1" == "-" ]; then
334 INDENT=" "
335 shift
336 fi
David Bainbridge38dc1e82019-08-12 15:18:45 +0000337 if [ $FANCY -eq 0 ]; then
338 LINE=$(echo $* | sed -e 's/[\s+-]//g')
339 if [ "$LINE X" == " X" ]; then
340 return
341 fi
342 echo -e "$INDENT$*"
343 else
344 echo -e "\r$INDENT$*$CNORM"
345 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700346}
347
David Bainbridgeac7f8072019-08-01 22:15:33 +0000348if [ "$1" == "get" -a "$2" == "voltconfig" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000349 echo "$HOME/.volt/config-$NAME"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000350 exit
351fi
352
353if [ $# -ne 1 -o $(echo ":up:down:dump:" | grep -c ":$1:") -ne 1 ]; then
354 >&2 echo "What wouild you like to do today:"
355 >&2 echo " up - bring up voltha"
356 >&2 echo " down - tear down voltha"
357 >&2 echo " dump - create a debug dump of running system"
358 exit 1
359fi
360
David Bainbridge4f1b5562019-08-19 04:46:52 +0000361push_onos_config() {
362 local MSG=$1
363 local RESOURCE=$2
364 local DATA=$3
365
366 bspin - "$MSG $GEAR"
367 while true; do
368 (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
369 if [ $? -eq 0 ]; then
370 break
371 fi
372 sleep .2
373 sspin -
374 done
375 espin - $VERIFIED
376}
377
378override_onos_app() {
379 local APP=$1
380 local NAME=$(basename $APP | sed -e 's/^[0-9][0-9]*-//g' -e 's/-.*$//g')
381 while true; do
382 sspin -
383 # Attempt to delete old version (if it exists)
384 (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
385 sspin -
386 if [ $? -ne 0 ]; then
387 continue
388 fi
389 (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
390 if [ $? -eq 0 ]; then
391 break
392 fi
393 sleep .2
394 done
395}
396
397activate_onos_app() {
398 local MSG="$1"
399 local APP=$2
400
401 bspin - "$MSG $GO"
402 while true; do
403 sspin -
404 (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
405 if [ $? -eq 0 ]; then
406 break
407 fi
408 sleep .2
409 done
410 espin - "$VERIFIED"
411}
412
413count_pods() {
414 local NAMESPACE=$1; shift
415 if [ "$NAMESPACE" == "all-namespaces" ]; then
416 NAMESPACE="--all-namespaces"
417 else
418 NAMESPACE="-n $NAMESPACE"
419 fi
420 echo "$NAMESPACE" > /tmp/t
421 local STATES=$1; shift
422 echo "$STATES" >> /tmp/t
423 local PODS=$(kubectl get $NAMESPACE pod -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}")
424 local COUNT=0
425 local PATTERNS="$*"
426 for POD in $PODS; do
427 local NAME=$(echo $POD | cut -d/ -f 1)
428 local STATE=$(echo $POD | cut -d/ -f 2)
429 local CONTAINERS=$(echo $POD | cut -d/ -f 3 | sed -e 's/_/ /g')
430 if [ "$STATES" == "*" -o $(echo "$STATES" | grep -c ":$STATE:") -ne 0 ]; then
431 echo "IN WITH $POD" >> /tmp/t
432 local TOTAL=$(echo $CONTAINERS | wc -w)
433 local FOUND=$(echo $CONTAINERS | grep -o true | wc -l)
434 if [ $TOTAL -eq $FOUND ]; then
435 for PATTERN in $PATTERNS; do
436 echo "TEST $PATTERN AGAINST $NAME" >> /tmp/t
437 if [[ $NAME =~ $PATTERN ]]; then
438 echo "COUNT $NAME" >> /tmp/t
439 COUNT=$(expr $COUNT + 1)
440 break
441 fi
442 done
443 fi
444 fi
445 done
446 echo $COUNT >> /tmp/t
447 echo $COUNT
448}
449
450wait_for_pods() {
451 local INDENT=
452 if [ "$1" == "-" ]; then
453 INDENT=$1; shift
454 fi
455 local NAMESPACE=$1; shift
456 local EXPECT=$1; shift
457 local TYPE=$1; shift
458 local RETRY=$1; shift
459 local MESSAGE=$1; shift
460 local PATTERNS=$*
461 local HAVE=$(count_pods $NAMESPACE ":Running:" $PATTERNS)
462 local ALL=$HAVE
463 if [ "$TYPE" == "only" ]; then
464 ALL=$(count_pods "all-namespaces" "*" ".*")
465 fi
466 COUNT=$(expr 300 / 15)
467 bspin $INDENT $MESSAGE
468 sspin $INDENT
469 if [ $HAVE -ne $EXPECT -o $ALL -ne $HAVE ]; then
470 while [ $HAVE -ne $EXPECT -o $ALL -ne $HAVE ]; do
471 sspin $INDENT
472 COUNT=$(expr $COUNT - 1)
473 if [ $COUNT -eq 0 ]; then
474 HAVE=$(count_pods $NAMESPACE ":Running:" $PATTERNS)
475 ALL=$HAVE
476 if [ "$TYPE" == "only" ]; then
477 ALL=$(count_pods "all-namespaces" "*" ".*")
478 fi
479 COUNT=$(expr 300 / 15)
480 fi
481 sleep .15
482 done
483 fi
484 espin $INDENT $VERIFIED
485 if [ $HAVE -ne $EXPECT ]; then
486 return 1
487 fi
488 return 0
489}
490
David Bainbridgeac7f8072019-08-01 22:15:33 +0000491if [ "$1" == "down" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000492 echo "Tearing down voltha cluster $NAME"
493 LOG="down-$NAME.log"
494 echo $(date -u +"%Y%m%dT%H%M%SZ") >$LOG
David Bainbridgeac7f8072019-08-01 22:15:33 +0000495 if [ $DEPLOY_K8S == "yes" ]; then
496 if [ -x ./bin/kind ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000497 bspin "Delete Kubernetes Kind Cluster"
498 (set -x; ./bin/kind delete cluster --name voltha-$NAME >>$LOG 2>&1) >>$LOG 2>&1
499 espin $VERIFIED
David Bainbridgeac7f8072019-08-01 22:15:33 +0000500 else
David Bainbridge0774b232019-08-02 06:37:19 +0000501 espin "$NO_ENTRY Delete Kubernetes Kind Cluster: kind command not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000502 fi
503 else
504 EXISTS=$(helm list -q)
505 EXPECT="etcd-operator onos open-olt open-onu sim voltha bbsim radius"
David Bainbridge0774b232019-08-02 06:37:19 +0000506 bspin "Remove Helm Deployments"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000507 for i in $EXISTS; do
508 if [ $(echo $EXPECT | grep -c $i) -eq 1 ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000509 sspin "Remove Helm Deployments: $i$CEOL"
510 (set -x; ./bin/helm delete --purge $i >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000511 fi
512 done
David Bainbridge0774b232019-08-02 06:37:19 +0000513 espin "$VERIFIED Remove Helm Deployments$CEOL"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000514 if [ "$WAIT_ON_DOWN" == "yes" ]; then
515 # There should only be 13 or 15 PODs in the kube-system name
516 # space and no other PODs
517
518 PODS="coredns-.* \
519 etcd-voltha-$NAME-control-plane \
520 kindnet-.* \
521 kube-apiserver-voltha-$NAME-control-plane \
522 kube-controller-manager-voltha-$NAME-control-plane \
523 kube-proxy-.* \
524 kube-scheduler-voltha-$NAME-control-plane \
525 tiller-deploy-.*"
526 EXPECT=$(test "$TYPE" == "minimal" && echo "13" || echo "15")
527 wait_for_pods "all-namespaces" $EXPECT "only" -1 "Waiting for only system PODs to be running" $PODS
528 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +0000529 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000530 bspin "Remove port-forwards: onos-ui-$NAME"
531 for i in $(screen -ls | grep onos-ui-$NAME | awk '{print $1}'); do
532 sspin
533 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
534 done
535 sspin "Remove port-forwards: onos-ssh-$NAME$CEOL"
536 for i in $(screen -ls | grep onos-ssh-$NAME | awk '{print $1}'); do
537 sspin
538 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
539 done
540 sspin "Remove port-forwards: voltha-api-$NAME$CEOL"
541 for i in $(screen -ls | grep voltha-api-$NAME | awk '{print $1}'); do
542 sspin
543 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
544 done
545 sspin "Remove port-forwards: voltha-ssh-$NAME$CEOL"
546 for i in $(screen -ls | grep voltha-ssh-$NAME | awk '{print $1}'); do
547 sspin
548 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
549 done
550 sspin "Remove port-forwards: voltha-etcd-$NAME$CEOL"
551 for i in $(screen -ls | grep voltha-etcd-$NAME | awk '{print $1}'); do
552 sspin
553 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
554 done
555 espin "$VERIFIED Remove port-forwards$CEOL"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000556 exit
557fi
558
559if [ "$1" == "dump" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000560 LOG="dump-$NAME.log"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000561 TS=$(date -u +"%Y%m%dT%H%M%SZ")
562 WORK=$(mktemp -u -d)
David Bainbridge0774b232019-08-02 06:37:19 +0000563 DATA=$WORK/voltha-debug-dump-$NAME-$TS
David Bainbridgeac7f8072019-08-01 22:15:33 +0000564 mkdir -p $DATA
565 echo $TS > $LOG
David Bainbridge0774b232019-08-02 06:37:19 +0000566 echo -e "Capturing debug dump to voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000567 bspin - "Copy install log"
David Bainbridge0774b232019-08-02 06:37:19 +0000568 if [ -f install-$NAME.log ]; then
569 (set -x; cp install-$NAME.log $DATA/install-$NAME.log) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000570 espin - $VERIFIED
571 else
David Bainbridge0774b232019-08-02 06:37:19 +0000572 espin - "$NO_ENTRY Copy install log: install-$NAME.log not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000573 fi
574 bspin - "Dumping Kubernetes PODs"
575 (set -x; kubectl get --all-namespaces pods >> $DATA/all-pods.txt 2>&1) >>$LOG 2>&1
576 espin - $VERIFIED
577 bspin - "Dumping Kubernetes SERVICEs"
578 (set -x; kubectl get --all-namespaces svc >> $DATA/all-services.txt 2>&1) >>$LOG 2>&1
579 espin - $VERIFIED
580 bspin - "Dumping Kubernetes EVENTs"
581 (set -x; kubectl get --all-namespaces events >> $DATA/all-events.txt 2>&1) >>$LOG 2>&1
582 espin - $VERIFIED
583 bspin - "Dumping VOLTHA POD details"
584 PODS=$(kubectl get -n voltha pod -o name)
585 for POD in $PODS; do
586 sspin - "Dumping VOLTHA POD details: $POD$CEOL"
587 mkdir -p $DATA/$POD
588 (set -x; kubectl describe -n voltha $POD >> $DATA/$POD/describe.txt 2>&1) >>$LOG 2>&1
589 sspin - "Dumping VOLTHA POD details: $POD"
590 (set -x; kubectl logs -n voltha --all-containers --previous $LOG_ARGS $POD >> $DATA/$POD/logs-previous.txt 2>&1) >>$LOG 2>&1
591 sspin - "Dumping VOLTHA POD details: $POD"
592 (set -x; kubectl logs -n voltha --all-containers $LOG_ARGS $POD >> $DATA/$POD/logs-current.txt 2>&1) >>$LOG 2>&1
593 sspin - "Dumping VOLTHA POD details: $POD"
594 done
595 espin - "$VERIFIED Dumping VOLTHA POD details$CEOL"
596 bspin - "Dumping ETCD"
597 if [ "$(which etcdctl) X" != " X" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000598 (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 +0000599 espin - $VERIFIED
600 else
601 espin - "$NO_ENTRY Dumping ETCD: etcdctl command not available"
602 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000603 bspin - "Creating compressed TAR: voltha-debug-dump-$NAME-$TS.tgz"
604 (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 +0000605 espin - $VERIFIED
606 bspin - "Cleanup"
607 (set -x; rm -rf $WORK) >>$LOG 2>&1
608 espin - $VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +0000609 bspin - "$(ls -l voltha-debug-dump-$NAME-$TS.tgz)"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000610 espin - $VERIFIED
611 exit
612fi
613
David Bainbridge0774b232019-08-02 06:37:19 +0000614LOG="install-$NAME.log"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000615date > $LOG
David Bainbridge0774b232019-08-02 06:37:19 +0000616echo "PORTS=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT" >> $LOG
David Bainbridgeac7f8072019-08-01 22:15:33 +0000617
618# Output install options to log
619echo "OPTIONS" >> $LOG
David Bainbridgeac7f8072019-08-01 22:15:33 +0000620for O in $ALL_OPTIONS; do
621 VAL=$(eval echo \$$O)
622 if [ $O == "USE_GO" ]; then
623 VAL="$(echo $VAL| test $(grep -c true) -eq 1 && echo yes || echo no)"
624 fi
625 if [ ! -z "$VAL" ]; then
626 printf " %-30s = %s\n" $O $VAL >> $LOG
627 fi
628done
629
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700630helm_install() {
631 local INDENT=
632 if [ "$1" == "-" ]; then
633 INDENT=$1; shift
634 fi
635 local NAMESPACE=$1; shift
David Bainbridge0774b232019-08-02 06:37:19 +0000636 local INAME=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700637 local CHART=$1; shift
638 local MESSAGE=$*
639
640 COUNT=$(expr 300 / 15)
641 bspin $INDENT $MESSAGE
David Bainbridge458bb662019-08-02 20:04:23 +0000642 (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 -0700643 SUCCESS=$?
644 while [ $SUCCESS -ne 0 ]; do
645 sspin $INDENT
646 COUNT=$(expr $COUNT - 1)
647 if [ $COUNT -eq 0 ]; then
David Bainbridge458bb662019-08-02 20:04:23 +0000648 (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 -0700649 COUNT=$(expr 300 / 15)
650 fi
651 sleep .15
652 done
653 espin $INDENT $VERIFIED
654}
655
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700656echo "INSTALL TYPE: $TYPE" >> $LOG
657
658bspin "Verify GOPATH"
659export GOPATH=$(pwd)
Test User3d7ad8e2019-07-03 06:15:44 +0000660mkdir -p $GOPATH/bin
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700661espin $VERIFIED
662
David Bainbridgee87067b2019-08-12 22:00:12 +0000663STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700664if [ "$INSTALL_KUBECTL" == "no" ]; then
665 bspin "Skip kubectl install"
666 espin $NO_ENTRY
Test Userc13bdc92019-07-03 20:57:49 +0000667else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700668 bspin "Verify kubectl $HELM"
669 if [ -x $GOPATH/bin/kubectl ]; then
670 espin $VERIFIED
671 else
672 espin $NOT_VERIFIED
673 bspin - "Download and install Kubernetes/kubectl $DOWNLOAD"
674 (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
675 (set -x; chmod 755 $GOPATH/bin/kubectl >>$LOG 2>&1) >>$LOG 2>&1
676 espin - $VERIFIED
677 fi
Test Userc13bdc92019-07-03 20:57:49 +0000678fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000679if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000680 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000681fi
Test Userc13bdc92019-07-03 20:57:49 +0000682
David Bainbridgee87067b2019-08-12 22:00:12 +0000683STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700684if [ "$DEPLOY_K8S" == "no" ]; then
685 bspin "Skip Kubernetes/Kind Deployment"
686 espin $NO_ENTRY
687else
Test Userba1e7e72019-07-10 22:27:54 +0000688 bspin "Verify Kubernetes/Kind $HELM"
689 if [ -x $GOPATH/bin/kind ]; then
690 espin $VERIFIED
691 else
692 espin $NOT_VERIFIED
693 bspin - "Download and install Kubernetes/kind $DOWNLOAD"
David Bainbridge9e2a6662019-07-11 17:07:57 +0000694 (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 +0000695 (set -x; chmod 755 $GOPATH/bin/kind >>$LOG 2>&1) >>$LOG 2>&1
696 espin - $VERIFIED
697 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700698fi
699
David Bainbridgee87067b2019-08-12 22:00:12 +0000700if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000701 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000702fi
703
704STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700705if [ "$INSTALL_HELM" == "no" ]; then
706 bspin "Skip Helm Install"
707 espin $NO_ENTRY
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700708else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700709 bspin "Verify Helm $HELM"
710 if [ -x $GOPATH/bin/helm ]; then
711 espin $VERIFIED
712 else
713 espin $NOT_VERIFIED
714 bspin - "Download and install Helm $DOWNLOAD"
715 (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
716 espin - $VERIFIED
717 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700718fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000719if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000720 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000721fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700722
David Bainbridgee87067b2019-08-12 22:00:12 +0000723STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +0000724bspin "Verify voltctl $HIGH_VOLTAGE"
Test User3d7ad8e2019-07-03 06:15:44 +0000725if [ -x $GOPATH/bin/voltctl ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700726 espin $VERIFIED
727else
728 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000729 bspin - "Download and build voltctl $DOWNLOAD"
Test Userba1e7e72019-07-10 22:27:54 +0000730 (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 +0000731 (set -x; chmod 755 $GOPATH/bin/voltctl >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700732 espin - $VERIFIED
733fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000734if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000735 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000736fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700737
738bspin "Verify command PATH"
Test Userba1e7e72019-07-10 22:27:54 +0000739export PATH=$GOPATH/bin:$PATH
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700740espin $VERIFIED
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700741
David Bainbridgee87067b2019-08-12 22:00:12 +0000742STIME=$(date +%s)
Test Userba1e7e72019-07-10 22:27:54 +0000743if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000744 HAVE=$(kind get clusters | grep -c voltha-$NAME)
Test Userba1e7e72019-07-10 22:27:54 +0000745 bspin "Verify Kubernetes/Kind Cluster"
746 sspin
747 if [ $HAVE -eq 0 ]; then
David Bainbridge491b1bd2019-07-11 17:53:11 +0000748 espin $NOT_VERIFIED
749 bspin - "Verify cluster configuration"
David Bainbridge0774b232019-08-02 06:37:19 +0000750 if [ ! -r ./$NAME-cluster.cfg ]; then
David Bainbridge491b1bd2019-07-11 17:53:11 +0000751 espin - $NOT_VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +0000752 bspin - "Download cluster configuration: $TYPE-cluster.cfg to $NAME-cluster.cfg $DOWNLOAD"
753 (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 -0700754 espin - $VERIFIED
755 else
756 espin - $VERIFIED
757 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000758 kind create cluster --name voltha-$NAME --config $NAME-cluster.cfg
David Bainbridge491b1bd2019-07-11 17:53:11 +0000759 else
760 espin $VERIFIED
Test Userba1e7e72019-07-10 22:27:54 +0000761 fi
762
David Bainbridge0774b232019-08-02 06:37:19 +0000763 export KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$NAME")"
Test Userba1e7e72019-07-10 22:27:54 +0000764 P="coredns-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000765 etcd-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +0000766 kindnet-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000767 kube-apiserver-voltha-$NAME-control-plane \
768 kube-controller-manager-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +0000769 kube-proxy-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000770 kube-scheduler-voltha-$NAME-control-plane"
Test Userba1e7e72019-07-10 22:27:54 +0000771
772 EXPECT=$(test "$TYPE" == "minimal" && echo "12" || echo "14")
David Bainbridge4f1b5562019-08-19 04:46:52 +0000773 wait_for_pods - "kube-system" $EXPECT "includes" -1 "Waiting for system PODs to start" $P
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700774fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000775if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000776 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000777fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700778
David Bainbridgee87067b2019-08-12 22:00:12 +0000779STIME=$(date +%s)
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700780COUNT=$(count_pods "kube-system" "tiller-deploy-.*")
781bspin "Verify Helm"
Test Userba1e7e72019-07-10 22:27:54 +0000782if [ $COUNT -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700783 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000784 echo -e "Configuring Helm $GEAR"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700785 if [ "$INSTALL_HELM" == "no" ]; then
786 bspin - "Skip Helm/Tiller Initialization"
787 espin - $NO_ENTRY
788 else
789 bspin - "Initialize Helm"
790 (set -x; helm init --upgrade >>$LOG 2>&1) >>$LOG 2>&1
791 espin - $VERIFIED
David Bainbridge4f1b5562019-08-19 04:46:52 +0000792 wait_for_pods - "kube-system" 1 "includes" -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700793 fi
Test Userb5712372019-07-03 21:52:17 +0000794 bspin - "Add Google Incubator repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700795 (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
796 espin - $VERIFIED
Test Userba1e7e72019-07-10 22:27:54 +0000797
798 # HACK (sort-of) - the config for tiller is about to be patched, which will
799 # cause the tiller pod to be recreated. This can sometimes cause a timing
800 # issue with the "wait_for_pods" call on tiller as it may incorrectly
801 # identify the running/ready tiller pod that is soon to be terminated as
802 # what it is waiting for. To avoid this issue we do a clean scale down and
803 # scale up of the pod so the script controlls when it should be expecting
804 # things
805 (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 -0700806
Test Userb5712372019-07-03 21:52:17 +0000807 bspin - "Add Google Stable repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700808 (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
809 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000810 bspin - "Add ONF repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700811 (set -x; helm repo add onf https://charts.opencord.org >>$LOG 2>&1) >>$LOG 2>&1
812 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000813 bspin - "Update Helm repository cache"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700814 (set -x; helm repo update >>$LOG 2>&1) >>$LOG 2>&1
815 espin - $VERIFIED
816
817 # Create and k8s service account so that Helm can create pods
Test Userb5712372019-07-03 21:52:17 +0000818 bspin - "Create Tiller ServiceAccount"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700819 (set -x; kubectl create serviceaccount --namespace kube-system tiller >>$LOG 2>&1) >>$LOG 2>&1
820 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000821 bspin - "Create Tiller ClusterRoleBinding"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700822 (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>$LOG 2>&1) >>$LOG 2>&1
823 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000824 bspin - "Update Tiller Manifest"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700825 (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 +0000826
827 # HACK (sort-of) - part to, spin it back up
828 (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 -0700829 espin - $VERIFIED
830else
831 espin $VERIFIED
832fi
David Bainbridge4f1b5562019-08-19 04:46:52 +0000833wait_for_pods - "kube-system" 1 "includes" -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +0000834if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000835 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000836fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700837
David Bainbridgee87067b2019-08-12 22:00:12 +0000838STIME=$(date +%s)
David Bainbridge0774b232019-08-02 06:37:19 +0000839bspin "Verify Helm values file: $NAME-values.yaml"
840if [ ! -r "./$NAME-values.yaml" ]; then
Test Userba1e7e72019-07-10 22:27:54 +0000841 espin $NOT_VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +0000842 bspin - "Download Helm values file: $TYPE-values.yaml to $NAME-values.yaml $DOWNLOAD"
843 (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 +0000844 espin - $VERIFIED
845else
846 espin $VERIFIED
847fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000848if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000849 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000850fi
Test Userba1e7e72019-07-10 22:27:54 +0000851
852if [ "$JUST_K8S" == "yes" ]; then
853 echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye."
854 echo ""
855 echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
856 echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
857 echo "tools required by VOLTHA in your command path. " | tee -a $LOG
858 echo "" | tee -a $LOG
859 echo -en $BOLD
860 if [ $DEPLOY_K8S == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000861 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +0000862 fi
863 echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
864 echo -en $NORMAL
865 echo "" | tee -a $LOG
866 echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
867 exit 0
868fi
869
David Bainbridgee87067b2019-08-12 22:00:12 +0000870STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +0000871bspin "Verify ETCD Operator $OLD_KEY"
Test User7d866122019-07-09 17:52:35 +0000872if [ $(helm list --deployed --short --namespace voltha "^etcd-operator\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700873 espin $NOT_VERIFIED
874 helm_install - voltha etcd-operator stable/etcd-operator "Install ETCD Operator"
875else
876 espin $VERIFIED
877fi
Test User01ed0642019-07-03 20:17:06 +0000878EXPECT=$(test "$TYPE" == "minimal" && echo "1" || echo "3")
David Bainbridge4f1b5562019-08-19 04:46:52 +0000879wait_for_pods - "voltha" $EXPECT "includes" -1 "Waiting for ETCD Operator to start" "etcd-operator-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +0000880if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000881 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000882fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700883
David Bainbridgee87067b2019-08-12 22:00:12 +0000884STIME=$(date +%s)
David Bainbridgeb270c202019-07-26 01:44:42 +0000885if [ $WITH_ONOS == "yes" ]; then
886 bspin "Verify ONOS installed $BIRD"
887 if [ $(helm list --deployed --short --namespace default "^onos\$" | wc -l) -ne 1 ]; then
888 espin $NOT_VERIFIED
David Bainbridge27790d62019-08-13 22:43:19 +0000889 SET_TAG=
890 if [ "$ONOS_TAG X" != " X" ]; then
891 SET_TAG="--set images.onos.tag=$ONOS_TAG"
892 fi
893 EXTRA_HELM_FLAGS="$SET_TAG $EXTRA_HELM_FLAGS" helm_install - default onos onf/onos "Install ONOS"
David Bainbridgeb270c202019-07-26 01:44:42 +0000894 else
895 espin $VERIFIED
896 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +0000897 wait_for_pods - "default" 1 "includes" -1 "Waiting for ONOS to start" "onos-.*"
David Bainbridgeb270c202019-07-26 01:44:42 +0000898
899 bspin - "Forward ONOS API port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +0000900 for i in $(screen -ls | grep onos-ui-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +0000901 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
902 done
David Bainbridge0774b232019-08-02 06:37:19 +0000903 (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 +0000904 espin - $VERIFIED
905 bspin - "Forward ONOS SSH port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +0000906 for i in $(screen -ls | grep onos-ssh-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +0000907 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
908 done
David Bainbridge2b19e832019-08-16 02:40:53 +0000909
910
David Bainbridge0774b232019-08-02 06:37:19 +0000911 (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 +0000912 espin - $VERIFIED
David Bainbridged31d6122019-08-13 19:37:59 +0000913 bspin - "Verify or download ONOS configuration support files $DOWNLOAD"
David Bainbridge2b19e832019-08-16 02:40:53 +0000914 ONOS_FILES="olt-onos-enableExtraneousRules.json olt-onos-olt-settings.json onos-aaa.json \
915 onos-dhcpl2relay.json onos-kafka.json onos-sadis-no-tp.json onos-sadis-tp.json"
David Bainbridged31d6122019-08-13 19:37:59 +0000916 (set -x; mkdir -p ./onos-files >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridge2b19e832019-08-16 02:40:53 +0000917 for i in $ONOS_FILES; do
David Bainbridged31d6122019-08-13 19:37:59 +0000918 if [ ! -r ./onos-files/$i ]; then
919 (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
920 fi
921 done
Test Userba1e7e72019-07-10 22:27:54 +0000922 espin - $VERIFIED
David Bainbridge27790d62019-08-13 22:43:19 +0000923
924 if [ $INSTALL_ONOS_APPS == "yes" ]; then
925 bspin - "Installing custom ONOS applications"
926 if [ -x onos-files/onos-apps -a $(ls -1 onos-files/onos-apps/*.oar 2>/dev/null | wc -l) -gt 0 ]; then
927 for OAR in $(ls -1 onos-files/onos-apps/*.oar); do
928 sspin - "Installing custom ONOS applications - $OAR$CEOL"
David Bainbridge2b19e832019-08-16 02:40:53 +0000929 override_onos_app $OAR
David Bainbridge27790d62019-08-13 22:43:19 +0000930 done
931 espin - "$VERIFIED Installing custom ONOS applications$CEOL"
932 else
933 espin - "$NOT_VERIFIED Installing custom ONOS applications - None Found"
934 fi
935 fi
David Bainbridge2b19e832019-08-16 02:40:53 +0000936
937 push_onos_config "Push ONOS Kafka Configuration" "network/configuration/apps/org.opencord.kafka" "onos-files/onos-kafka.json"
938 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 +0000939 push_onos_config "Enable VOLTHA ONOS DHCP provisioning" "configuration/org.opencord.olt.impl.Olt" "onos-files/olt-onos-olt-settings.json"
940 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 +0000941 if [ -f onos-files/onos-sadis.json ]; then
942 push_onos_config "[optional] Push ONOS SADIS Configuration" "network/configuration/apps/org.opencord.sadis" "onos-files/onos-sadis.json"
943 elif [ "$CONFIG_SADIS" == "yes" ]; then
944 SADIS_CFG=onos-files/onos-sadis-no-tp.json
945 if [ "$WITH_TP" == "yes" ]; then
946 SADIS_CFG=onos-files/onos-sadis-tp.json
947 fi
948 push_onos_config "[optional] Push ONOS SADIS Configuration" "network/configuration/apps/org.opencord.sadis" "$SADIS_CFG"
949 fi
Test Userba1e7e72019-07-10 22:27:54 +0000950fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000951if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000952 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000953fi
Test Userba1e7e72019-07-10 22:27:54 +0000954
David Bainbridgee87067b2019-08-12 22:00:12 +0000955STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +0000956bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
Test User7d866122019-07-09 17:52:35 +0000957if [ $(helm list --deployed --short --namespace voltha "^voltha\$" | 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 voltha $VOLTHA_CHART "Install VOLTHA Core"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700960else
961 espin $VERIFIED
962fi
Test Userba1e7e72019-07-10 22:27:54 +0000963
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700964VOLTHA="ofagent-.* \
965 ro-core.* \
966 rw-core.* \
967 voltha-api-server-.* \
968 voltha-cli-server-.* \
969 voltha-etcd-cluster-.* \
970 voltha-kafka-.* \
971 voltha-zookeeper-.*"
Test User01ed0642019-07-03 20:17:06 +0000972EXPECT=$(test "$TYPE" == "minimal" && echo "9" || echo "11")
David Bainbridge4f1b5562019-08-19 04:46:52 +0000973wait_for_pods - "voltha" $EXPECT "includes" -1 "Waiting for VOLTHA Core to start" $VOLTHA
David Bainbridgee87067b2019-08-12 22:00:12 +0000974if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000975 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000976fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700977
David Bainbridgee87067b2019-08-12 22:00:12 +0000978STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +0000979echo -e "Verify Adapters $PLUG"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700980bspin - "Verify Simulated Adapters installed"
Test User7d866122019-07-09 17:52:35 +0000981if [ $(helm list --deployed --short --namespace voltha "^sim\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700982 espin - $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +0000983 helm_install - voltha sim $VOLTHA_ADAPTER_SIM_CHART "Install Simulated Adapters"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700984else
985 espin - $VERIFIED
986fi
987
988bspin - "Verify OpenOLT Adapter installed"
Test User7d866122019-07-09 17:52:35 +0000989if [ $(helm list --deployed --short --namespace voltha "^open-olt\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700990 espin - $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +0000991 helm_install - voltha open-olt $VOLTHA_ADAPTER_OPEN_OLT_CHART "Install OpenOLT Adapter"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700992else
993 espin - $VERIFIED
994fi
995bspin - "Verify OpenONU Adapter installed"
Test User7d866122019-07-09 17:52:35 +0000996if [ $(helm list --deployed --short --namespace voltha "^open-onu\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700997 espin - $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +0000998 helm_install - voltha open-onu $VOLTHA_ADAPTER_OPEN_ONU_CHART "Install OpenONU Adapter"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700999else
1000 espin - $VERIFIED
1001fi
1002
1003ADAPTERS="adapter-.*"
David Bainbridge4f1b5562019-08-19 04:46:52 +00001004wait_for_pods - "voltha" 4 "includes" -1 "Waiting for adapters to start" $ADAPTERS
David Bainbridgee87067b2019-08-12 22:00:12 +00001005if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001006 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001007fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001008
Test User7d866122019-07-09 17:52:35 +00001009if [ $WITH_BBSIM == "yes" ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +00001010 STIME=$(date +%s)
Test User7d866122019-07-09 17:52:35 +00001011 echo -e "Verify BBSIM $PLUG"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001012 bspin - "Verify BBSIM Installed"
Test User7d866122019-07-09 17:52:35 +00001013 if [ $(helm list --deployed --short --namespace voltha "^bbsim\$" | wc -l) -ne 1 ]; then
1014 espin - $NOT_VERIFIED
1015 helm_install - voltha bbsim onf/bbsim "Install BBSIM"
1016 else
1017 espin - $VERIFIED
1018 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +00001019 wait_for_pods - "voltha" 1 "includes" -1 "Waiting for BBSIM to start" "bbsim-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001020 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001021 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001022 fi
Test User7d866122019-07-09 17:52:35 +00001023fi
1024
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001025if [ $WITH_RADIUS == "yes" ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +00001026 STIME=$(date +%s)
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001027 echo -e "Verify RADIUS $LOCK"
1028 bspin - "Verify RADIUS Installed"
1029 if [ $(helm list --deployed --short --namespace voltha "^radius\$" | wc -l) -ne 1 ]; then
1030 espin - $NOT_VERIFIED
1031 helm_install - voltha radius onf/freeradius "Install RADIUS"
1032 else
1033 espin - $VERIFIED
1034 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +00001035 wait_for_pods - "voltha" 1 "includes" -1 "Waiting for RADIUS to start" "radius-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001036 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001037 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001038 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001039fi
1040
David Bainbridgee87067b2019-08-12 22:00:12 +00001041STIME=$(date +%s)
David Bainbridgee10f6d52019-07-25 00:28:13 +00001042if [ $SKIP_RESTART_API == "no" ]; then
1043 echo -e "Restart VOLTHA API $RESTART"
1044 API="voltha-api-server-.* ofagent-.*"
1045 (set -x; kubectl scale --replicas=0 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridge4f1b5562019-08-19 04:46:52 +00001046 wait_for_pods - "voltha" 0 "includes" -1 "Wait for API to stop $STOP" $API
David Bainbridgee10f6d52019-07-25 00:28:13 +00001047 (set -x; kubectl scale --replicas=1 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridge4f1b5562019-08-19 04:46:52 +00001048 wait_for_pods - "voltha" 2 "includes" -1 "Wait for API to re-start $GO" $API
David Bainbridgee10f6d52019-07-25 00:28:13 +00001049else
1050 bspin "Skip VOLTHA API Restart"
1051 espin $NO_ENTRY
1052fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001053
Test Userb5712372019-07-03 21:52:17 +00001054bspin - "Forward VOLTHA API port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +00001055for i in $(screen -ls | grep voltha-api-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +00001056 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
1057done
David Bainbridge0774b232019-08-02 06:37:19 +00001058(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 -07001059espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +00001060bspin - "Forward VOLTHA SSH port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +00001061for i in $(screen -ls | grep voltha-ssh-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +00001062 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
1063done
David Bainbridge0774b232019-08-02 06:37:19 +00001064(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 -07001065espin - $VERIFIED
David Bainbridgeac7f8072019-08-01 22:15:33 +00001066bspin - "Forward VOLTHA ETCD port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +00001067for i in $(screen -ls | grep voltha-etcd-$NAME | awk '{print $1}'); do
David Bainbridgeac7f8072019-08-01 22:15:33 +00001068 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
1069done
David Bainbridge0774b232019-08-02 06:37:19 +00001070(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 +00001071espin - $VERIFIED
David Bainbridgee87067b2019-08-12 22:00:12 +00001072if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001073 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001074fi
Test User3d7ad8e2019-07-03 06:15:44 +00001075
David Bainbridgeb270c202019-07-26 01:44:42 +00001076if [ $WITH_ONOS == "yes" -a $WITH_RADIUS == "yes" ]; then
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001077 bspin "Configure ONOS RADIUS Connection $GEAR"
David Bainbridge2b19e832019-08-16 02:40:53 +00001078 (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 +00001079 espin $VERIFIED
1080fi
1081
1082bspin "Create voltctl configuration file"
Test User3d7ad8e2019-07-03 06:15:44 +00001083(set -x; mkdir -p $HOME/.volt >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridge0774b232019-08-02 06:37:19 +00001084(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 +00001085espin $VERIFIED
Test User08ebbd92019-07-03 17:15:39 +00001086
David Bainbridge0774b232019-08-02 06:37:19 +00001087if [ ! -f "$NAME-env.sh" ]; then
1088 touch $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001089fi
1090
David Bainbridge596f30d2019-07-30 17:07:59 +00001091for O in $ALL_OPTIONS; do
1092 VAL=$(eval echo \$$O)
1093 if [ $O == "USE_GO" ]; then
1094 VAL="$(echo $VAL| test $(grep -c true) -eq 1 && echo yes || echo no)"
1095 fi
David Bainbridge0774b232019-08-02 06:37:19 +00001096 if [ ! -z "$VAL" -a $(grep -c "^export $O=" $NAME-env.sh) -eq 0 ]; then
1097 echo "export $O=\"$(eval echo \$$O)\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001098 fi
1099done
1100
David Bainbridge0774b232019-08-02 06:37:19 +00001101if [ $DEPLOY_K8S == "yes" -a $(grep -c "^export KUBECONFIG=" $NAME-env.sh) -eq 0 ]; then
1102 echo "export KUBECONFIG=\"$(./bin/kind get kubeconfig-path --name=voltha-$NAME)\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001103fi
1104
David Bainbridge0774b232019-08-02 06:37:19 +00001105if [ $(grep -c "^export VOLTCONFIG=" $NAME-env.sh) -eq 0 ]; then
1106 echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001107fi
1108
David Bainbridge0774b232019-08-02 06:37:19 +00001109if [ $(grep -c "^export PATH=" $NAME-env.sh) -eq 0 ]; then
1110 echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001111fi
1112
Test User7d866122019-07-09 17:52:35 +00001113echo ""
Test User08ebbd92019-07-03 17:15:39 +00001114echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
1115echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
1116echo "tools required by VOLTHA in your command path. " | tee -a $LOG
1117echo "" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +00001118echo -en $BOLD
Test Userba1e7e72019-07-10 22:27:54 +00001119if [ $DEPLOY_K8S == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001120 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +00001121fi
David Bainbridge0774b232019-08-02 06:37:19 +00001122echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +00001123echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +00001124echo -en $NORMAL
Test User08ebbd92019-07-03 17:15:39 +00001125echo "" | tee -a $LOG
1126echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
1127
David Bainbridge712afb82019-08-14 19:55:58 +00001128if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridgef858a022019-08-14 21:25:11 +00001129 echo -e "$CLOCK ${BOLD}TOTAL: $(duration $(expr $(date +%s) - $TOTAL_START_TIME))${NORMAL}"
David Bainbridge712afb82019-08-14 19:55:58 +00001130fi
1131