blob: f5adc4d8b36cd8971494a093e67a543cd21e31a4 [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.
15
David Bainbridge38dc1e82019-08-12 15:18:45 +000016FANCY=${FANCY:-1}
17if [ "$TERM X" == " X" ]; then
18 FANCY=0
19fi
20
David K. Bainbridgeb7285432019-07-02 22:05:24 -070021# trap ctrl-c and call ctrl_c()
22trap ctrl_c INT
23
24function ctrl_c() {
David Bainbridge38dc1e82019-08-12 15:18:45 +000025 echo -en $CNORM
David K. Bainbridgeb7285432019-07-02 22:05:24 -070026 echo ""
27 echo "ctrl-c trapped"
28 echo "Thank you for trying 'votlha up'"
29 exit
30}
31
Test User08ebbd92019-07-03 17:15:39 +000032VOLTCTL_VERSION=${VOLTCTL_VERSION:-0.0.5-dev}
33KIND_VERSION=${KIND_VERSION:-v0.4.0}
34_VOLTCTL_VERSION=$(echo $VOLTCTL_VERSION | sed -e 's/-/_/g')
35
David Bainbridge38dc1e82019-08-12 15:18:45 +000036BLACK=
37RED=
38GREEN=
39YELLOW=
40BLUE=
41MAGENTA=
42CYAN=
43WHITE=
44BOLD=
45NORMAL=
46ERROR=
47CEOL=
48CNORM=
49CIVIS=
50if [ $FANCY -eq 1 ]; then
51 BLACK=$(tput setaf 0)
52 RED=$(tput setaf 1)
53 GREEN=$(tput setaf 2)
54 YELLOW=$(tput setaf 3)
55 BLUE=$(tput setaf 4)
56 MAGENTA=$(tput setaf 5)
57 CYAN=$(tput setaf 6)
58 WHITE=$(tput setaf 7)
59 BOLD=$(tput bold)
60 NORMAL=$(tput sgr0)
61 ERROR="\xe2\x9c\x97\x20"
62 CEOL=$(tput el)
63 CNORM=$(tput cnorm)
64 CIVIS=$(tput civis)
65fi
Test User7d866122019-07-09 17:52:35 +000066
Test User3d7ad8e2019-07-03 06:15:44 +000067TYPE=${TYPE:-minimal}
David Bainbridge0774b232019-08-02 06:37:19 +000068NAME=${NAME:-$TYPE}
David Bainbridgee87067b2019-08-12 22:00:12 +000069WITH_TIMINGS=${WITH_TIMINGS:-no}
Test User7d866122019-07-09 17:52:35 +000070WITH_BBSIM=${WITH_BBSIM:-no}
David Bainbridge5b7b96b2019-07-25 20:29:13 +000071WITH_RADIUS=${WITH_RADIUS:-no}
David Bainbridgeb270c202019-07-26 01:44:42 +000072WITH_ONOS=${WITH_ONOS:-yes}
David Bainbridge01294952019-07-30 19:33:45 +000073WITH_TP=${WITH_TP:-yes}
Test Userba1e7e72019-07-10 22:27:54 +000074JUST_K8S=${JUST_K8S:-no}
75DEPLOY_K8S=${DEPLOY_K8S:-yes}
David Bainbridgee10f6d52019-07-25 00:28:13 +000076SKIP_RESTART_API=${SKIP_RESTART_API:-no}
David K. Bainbridge0e89cb92019-07-17 11:30:10 -070077INSTALL_KUBECTL=${INSTALL_KUBECTL:-yes}
78INSTALL_HELM=${INSTALL_HELM:-yes}
David Bainbridge5b7b96b2019-07-25 20:29:13 +000079USE_GO=${USE_GO:-yes}
80VOLTHA_LOG_LEVEL=${VOLTHA_LOG_LEVEL:-WARN}
David Bainbridgee10f6d52019-07-25 00:28:13 +000081VOLTHA_CHART=${VOLTHA_CHART:=onf/voltha}
82VOLTHA_ADAPTER_SIM_CHART=${VOLTHA_ADAPTER_SIM_CHART:-onf/voltha-adapter-simulated}
83VOLTHA_ADAPTER_OPEN_OLT_CHART=${VOLTHA_ADAPTER_OPEN_OLT_CHART:-onf/voltha-adapter-openolt}
84VOLTHA_ADAPTER_OPEN_ONU_CHART=${VOLTHA_ADAPTER_OPEN_ONU_CHART:-onf/voltha-adapter-openonu}
Test Userba1e7e72019-07-10 22:27:54 +000085
86HAVE_GO=$(which go >/dev/null 2>&1 && echo "yes" || echo "no")
87HOSTOS=$(uname -s | tr "[:upper:]" "[:lower:"])
88HOSTARCH=$(uname -m | tr "[:upper:]" "[:lower:"])
89if [ $HOSTARCH == "x86_64" ]; then
90 HOSTARCH="amd64"
91fi
Test User7d866122019-07-09 17:52:35 +000092
93# Verify TYPE setting
94if [ $(echo ":minimal:full:" | grep -ic ":$TYPE:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -070095 >&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 +000096 exit 1
97fi
98
99# Verify WITH_BBSIM settting and convert uniform value of yes or no
100if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_BBSIM:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700101 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_BBSIM value of '$WITH_BBSIM'. Should be 'yes' or 'no'${NORMAL}"
Test User7d866122019-07-09 17:52:35 +0000102 exit 1
103fi
104if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_BBSIM:") -eq 1 ]; then
105 WITH_BBSIM=yes
106else
107 WITH_BBSIM=no
108fi
109
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000110# Verify WITH_RADIUS settting and convert uniform value of yes or no
111if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_RADIUS:") -eq 0 ]; then
112 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_RADIUS value of '$WITH_RADIUS'. Should be 'yes' or 'no'${NORMAL}"
113 exit 1
114fi
115if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_RADIUS:") -eq 1 ]; then
116 WITH_RADIUS=yes
117else
118 WITH_RADIUS=no
119fi
120
David Bainbridge01294952019-07-30 19:33:45 +0000121# Verify WITH_TP settting and convert uniform value of yes or no
122if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_TP:") -eq 0 ]; then
123 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_TP value of '$WITH_TP'. Should be 'yes' or 'no'${NORMAL}"
124 exit 1
125fi
126if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_TP:") -eq 1 ]; then
127 WITH_TP=yes
128else
129 WITH_TP=no
130fi
131
David Bainbridgeb270c202019-07-26 01:44:42 +0000132# Verify WITH_ONOS settting and convert uniform value of yes or no
133if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_ONOS:") -eq 0 ]; then
134 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_ONOS value of '$WITH_ONOS'. Should be 'yes' or 'no'${NORMAL}"
135 exit 1
136fi
137if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_ONOS:") -eq 1 ]; then
138 WITH_ONOS=yes
139else
140 WITH_ONOS=no
141fi
142
Test Userba1e7e72019-07-10 22:27:54 +0000143# Verify JUST_K8S settting and convert uniform value of yes or no
144if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$JUST_K8S:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700145 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$JUST_K8S value of '$JUST_K8S'. Should be 'yes' or 'no'${NORMAL}"
Test Userba1e7e72019-07-10 22:27:54 +0000146 exit 1
147fi
148if [ $(echo ":y:yes:true:1:" | grep -ic ":$JUST_K8S:") -eq 1 ]; then
149 JUST_K8S=yes
150else
151 JUST_K8S=no
152fi
153
154# Verify DEPLOY_K8S settting and convert uniform value of yes or no
155if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$DEPLOY_K8S:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700156 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$DEPLOY_K8S value of '$DEPLOY_K8S'. Should be 'yes' or 'no'${NORMAL}"
Test Userba1e7e72019-07-10 22:27:54 +0000157 exit 1
158fi
159if [ $(echo ":y:yes:true:1:" | grep -ic ":$DEPLOY_K8S:") -eq 1 ]; then
160 DEPLOY_K8S=yes
161else
162 DEPLOY_K8S=no
163fi
Test User01ed0642019-07-03 20:17:06 +0000164
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700165# Verify INSTALL_KUBECTL settting and convert uniform value of yes or no
166if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$INSTALL_KUBECTL:") -eq 0 ]; then
167 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$INSTALL_KUBECTL value of '$INSTALL_KUBECTL'. Should be 'yes' or 'no'${NORMAL}"
168 exit 1
169fi
170
171if [ $(echo ":y:yes:true:1:" | grep -ic ":$INSTALL_KUBECTL:") -eq 1 ]; then
172 INSTALL_KUBECTL=yes
173else
174 INSTALL_KUBECTL=no
175fi
176
David Bainbridgee10f6d52019-07-25 00:28:13 +0000177# Verify SKIP_RESTART_API settting and convert uniform value of yes or no
178if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$SKIP_RESTART_API:") -eq 0 ]; then
179 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$SKIP_RESTART_API value of '$SKIP_RESTART_API'. Should be 'yes' or 'no'${NORMAL}"
180 exit 1
181fi
182if [ $(echo ":y:yes:true:1:" | grep -ic ":$SKIP_RESTART_API:") -eq 1 ]; then
183 SKIP_RESTART_API=yes
184else
185 SKIP_RESTART_API=no
186fi
187
David Bainbridge1ceabc12019-07-25 17:21:05 +0000188# Verify USE_GO settting and convert uniform value of yes or no
189if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$USE_GO:") -eq 0 ]; then
190 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$USE_GO value of '$USE_GO'. Should be 'yes' or 'no'${NORMAL}"
191 exit 1
192fi
193if [ $(echo ":y:yes:true:1:" | grep -ic ":$USE_GO:") -eq 1 ]; then
194 USE_GO=true
195else
196 USE_GO=false
197fi
198
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700199# Verify INSTALL_HELM settting and convert uniform value of yes or no
200if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$INSTALL_HELM:") -eq 0 ]; then
201 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$INSTALL_HELM value of '$INSTALL_HELM'. Should be 'yes' or 'no'${NORMAL}"
202 exit 1
203fi
204
205if [ $(echo ":y:yes:true:1:" | grep -ic ":$INSTALL_HELM:") -eq 1 ]; then
206 INSTALL_HELM=yes
207else
208 INSTALL_HELM=no
209fi
210
David Bainbridgee87067b2019-08-12 22:00:12 +0000211# Verify WITH_TIMINGS settting and convert uniform value of yes or no
212if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_TIMINGS:") -eq 0 ]; then
213 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_TIMINGS value of '$WITH_TIMINGS'. Should be 'yes' or 'no'${NORMAL}"
214 exit 1
215fi
216
217if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_TIMINGS:") -eq 1 ]; then
218 WITH_TIMINGS=yes
219else
220 WITH_TIMINGS=no
221fi
222
David Bainbridge0774b232019-08-02 06:37:19 +0000223mkdir -p .voltha
224touch .voltha/ports
225HAVE=$(grep $NAME .voltha/ports)
226if [ "$HAVE X" == " X" ]; then
227 # Find free port prefix
228 START=81
229 while true; do
230 if [ $(grep -c $START .voltha/ports) -eq 0 ]; then
231 break
232 fi
233 START=$(expr $START + 1)
234 done
235 DELTA=$(expr $START - 81)
236 ONOS_API_PORT=${START}81
237 ONOS_SSH_PORT=${START}01
238 VOLTHA_API_PORT=5$(expr 55 + $DELTA)55
239 VOLTHA_SSH_PORT=$(expr 50 + $DELTA)22
240 VOLTHA_ETCD_PORT=$(expr 23 + $DELTA)79
Test User01ed0642019-07-03 20:17:06 +0000241else
David Bainbridge0774b232019-08-02 06:37:19 +0000242 VALUES=$(echo $HAVE | sed -e 's/\s//g' | cut -d= -f2)
243 ONOS_API_PORT=$(echo $VALUES | cut -d, -f1)
244 ONOS_SSH_PORT=$(echo $VALUES | cut -d, -f2)
245 VOLTHA_API_PORT=$(echo $VALUES | cut -d, -f3)
246 VOLTHA_SSH_PORT=$(echo $VALUES | cut -d, -f4)
247 VOLTHA_ETCD_PORT=$(echo $VALUES | cut -d, -f5)
Test User01ed0642019-07-03 20:17:06 +0000248fi
249
David Bainbridge0774b232019-08-02 06:37:19 +0000250PORTTMP=$(mktemp -u)
251cat .voltha/ports | grep -v $NAME > $PORTTMP
252echo "$NAME=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT" >> $PORTTMP
253cp $PORTTMP .voltha/ports
254rm -f $PORTTMP
255
David Bainbridge01294952019-07-30 19:33:45 +0000256if [ "$WITH_TP" == "yes" ]; then
257 SADIS_VER=3.1.0
258 OLT_VER=3.0.1
259 AAA_VER=1.9.0
260 DHCP_VER=1.6.0
261else
262 SADIS_VER=2.2.0
263 OLT_VER=2.1.0
264 AAA_VER=1.8.0
265 DHCP_VER=1.5.0
266fi
David Bainbridge0774b232019-08-02 06:37:19 +0000267export ONOS_API_PORT ONOS_SSH_PORT SADIS_VER OLT_VER AAA_VER DHCP_VER
David Bainbridge01294952019-07-30 19:33:45 +0000268
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700269spin() {
Test Userd87942b2019-07-03 07:20:24 +0000270 PARTS="\
271 \xe2\xa2\x8e\xe2\xa1\xb0 \
272 \xe2\xa2\x8e\xe2\xa1\xa1 \
273 \xe2\xa2\x8e\xe2\xa1\x91 \
274 \xe2\xa2\x8e\xe2\xa0\xb1 \
275 \xe2\xa0\x8e\xe2\xa1\xb1 \
276 \xe2\xa2\x8a\xe2\xa1\xb1 \
277 \xe2\xa2\x8c\xe2\xa1\xb1 \
278 \xe2\xa2\x86\xe2\xa1\xb1 \
279 "
280 IDX=1
David Bainbridge38dc1e82019-08-12 15:18:45 +0000281 echo -en $CIVIS
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700282 while true; do
Test Userd87942b2019-07-03 07:20:24 +0000283 C=$(echo $PARTS | cut '-d ' -f $IDX)
284 echo -en "$C"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700285 IDX=$(expr $IDX + 1)
Test Userd87942b2019-07-03 07:20:24 +0000286 if [ $IDX -gt 8 ]; then
287 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700288 fi
289 sleep .15
290 echo -en "\r"
291 done
292}
293
Test Userd87942b2019-07-03 07:20:24 +0000294IDX=1
David Bainbridgee87067b2019-08-12 22:00:12 +0000295CLOCK="TIME:"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000296SPIN_PARTS=
297NOT_VERIFIED=
298VERIFIED=
299HELM=
300OLD_KEY=
301BIRD=
302HIGH_VOLTAGE=
303PLUG=
304RESTART=
305FORWARD=
306INSTALL=
307STOP=
308GO=
309DOWNLOAD=
310GEAR=
311NO_ENTRY=
312LOCK=
313
314if [ $FANCY -eq 1 ]; then
315 SPIN_PARTS="\
316 \xe2\xa2\x8e\xe2\xa1\xb0 \
317 \xe2\xa2\x8e\xe2\xa1\xa1 \
318 \xe2\xa2\x8e\xe2\xa1\x91 \
319 \xe2\xa2\x8e\xe2\xa0\xb1 \
320 \xe2\xa0\x8e\xe2\xa1\xb1 \
321 \xe2\xa2\x8a\xe2\xa1\xb1 \
322 \xe2\xa2\x8c\xe2\xa1\xb1 \
323 \xe2\xa2\x86\xe2\xa1\xb1 \
324 "
David Bainbridgee87067b2019-08-12 22:00:12 +0000325 CLOCK="\xe2\x8f\xb1"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000326 NOT_VERIFIED="\xe2\x9c\x97\x20"
327 VERIFIED="\xe2\x9c\x93\x20"
328 HELM="\xE2\x8E\x88"
329 OLD_KEY="\xF0\x9F\x97\x9D"
330 BIRD="\xF0\x9F\x90\xA6"
331 HIGH_VOLTAGE="\xE2\x9A\xA1"
332 PLUG="\xF0\x9F\xa7\xa9"
333 RESTART="\xf0\x9f\x94\x84"
334 FORWARD="\xE2\x87\xA8"
335 INSTALL="\xF0\x9F\x8F\x97"
336 STOP="\xf0\x9f\x9b\x91"
337 GO="\xf0\x9f\x9a\x80"
338 DOWNLOAD="\xf0\x9f\x93\xa5"
339 GEAR="\xe2\x9a\x99"
340 NO_ENTRY="\xe2\x9b\x94"
341 LOCK="\xf0\x9f\x94\x92"
342fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700343
David Bainbridgee87067b2019-08-12 22:00:12 +0000344timeout() {
345 local INDENT=
346 if [ "$1" == "-" ]; then
347 INDENT=" "
348 shift
349 fi
350 local h=$(expr $1 / 3600)
351 local m=$(expr $1 % 3600 / 60)
352 local s=$(expr $1 % 60)
353 local t=""
354
355 if [ $h -gt 0 ]; then
356 t="$t${h}h"
357 fi
358 if [ $m -gt 0 ]; then
359 t="$t${m}m"
360 fi
361 t="$t${s}s"
362 echo -e "$INDENT $CLOCK $t"
363}
364
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700365bspin() {
Test Userd87942b2019-07-03 07:20:24 +0000366 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700367 local INDENT=
368 if [ "$1" == "-" ]; then
369 INDENT=" "
370 shift
371 fi
David Bainbridge38dc1e82019-08-12 15:18:45 +0000372 if [ $FANCY -eq 0 ]; then
373 LINE=$(echo $* | sed -e 's/[\s+-]//g')
374 if [ "$LINE X" == " X" ]; then
375 return
376 fi
377 echo -e "$CIVIS$INDENT$*"
378 else
379 echo -en "$CIVIS$INDENT $*"
380 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700381}
382
383sspin() {
384 local INDENT=
385 if [ "$1" == "-" ]; then
386 INDENT=" "
387 shift
388 fi
David Bainbridge38dc1e82019-08-12 15:18:45 +0000389 if [ $FANCY -eq 0 ]; then
390 LINE=$(echo $* | sed -e 's/[\s+-]//g')
391 if [ "$LINE X" == " X" ]; then
392 return
393 fi
394 echo -e "$INDENT$*"
395 else
396 C=$(echo $SPIN_PARTS | cut '-d ' -f $IDX)
397 echo -en "\r$INDENT$C $*"
398 IDX=$(expr $IDX + 1)
399 if [ $IDX -gt 8 ]; then
400 IDX=1
401 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700402 fi
403}
404
405espin() {
406 local INDENT=
407 if [ "$1" == "-" ]; then
408 INDENT=" "
409 shift
410 fi
David Bainbridge38dc1e82019-08-12 15:18:45 +0000411 if [ $FANCY -eq 0 ]; then
412 LINE=$(echo $* | sed -e 's/[\s+-]//g')
413 if [ "$LINE X" == " X" ]; then
414 return
415 fi
416 echo -e "$INDENT$*"
417 else
418 echo -e "\r$INDENT$*$CNORM"
419 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700420}
421
David Bainbridgeac7f8072019-08-01 22:15:33 +0000422if [ "$1" == "get" -a "$2" == "voltconfig" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000423 echo "$HOME/.volt/config-$NAME"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000424 exit
425fi
426
427if [ $# -ne 1 -o $(echo ":up:down:dump:" | grep -c ":$1:") -ne 1 ]; then
428 >&2 echo "What wouild you like to do today:"
429 >&2 echo " up - bring up voltha"
430 >&2 echo " down - tear down voltha"
431 >&2 echo " dump - create a debug dump of running system"
432 exit 1
433fi
434
435if [ "$1" == "down" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000436 echo "Tearing down voltha cluster $NAME"
437 LOG="down-$NAME.log"
438 echo $(date -u +"%Y%m%dT%H%M%SZ") >$LOG
David Bainbridgeac7f8072019-08-01 22:15:33 +0000439 if [ $DEPLOY_K8S == "yes" ]; then
440 if [ -x ./bin/kind ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000441 bspin "Delete Kubernetes Kind Cluster"
442 (set -x; ./bin/kind delete cluster --name voltha-$NAME >>$LOG 2>&1) >>$LOG 2>&1
443 espin $VERIFIED
David Bainbridgeac7f8072019-08-01 22:15:33 +0000444 else
David Bainbridge0774b232019-08-02 06:37:19 +0000445 espin "$NO_ENTRY Delete Kubernetes Kind Cluster: kind command not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000446 fi
447 else
448 EXISTS=$(helm list -q)
449 EXPECT="etcd-operator onos open-olt open-onu sim voltha bbsim radius"
David Bainbridge0774b232019-08-02 06:37:19 +0000450 bspin "Remove Helm Deployments"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000451 for i in $EXISTS; do
452 if [ $(echo $EXPECT | grep -c $i) -eq 1 ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000453 sspin "Remove Helm Deployments: $i$CEOL"
454 (set -x; ./bin/helm delete --purge $i >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000455 fi
456 done
David Bainbridge0774b232019-08-02 06:37:19 +0000457 espin "$VERIFIED Remove Helm Deployments$CEOL"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000458 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000459 bspin "Remove port-forwards: onos-ui-$NAME"
460 for i in $(screen -ls | grep onos-ui-$NAME | awk '{print $1}'); do
461 sspin
462 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
463 done
464 sspin "Remove port-forwards: onos-ssh-$NAME$CEOL"
465 for i in $(screen -ls | grep onos-ssh-$NAME | awk '{print $1}'); do
466 sspin
467 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
468 done
469 sspin "Remove port-forwards: voltha-api-$NAME$CEOL"
470 for i in $(screen -ls | grep voltha-api-$NAME | awk '{print $1}'); do
471 sspin
472 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
473 done
474 sspin "Remove port-forwards: voltha-ssh-$NAME$CEOL"
475 for i in $(screen -ls | grep voltha-ssh-$NAME | awk '{print $1}'); do
476 sspin
477 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
478 done
479 sspin "Remove port-forwards: voltha-etcd-$NAME$CEOL"
480 for i in $(screen -ls | grep voltha-etcd-$NAME | awk '{print $1}'); do
481 sspin
482 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
483 done
484 espin "$VERIFIED Remove port-forwards$CEOL"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000485 exit
486fi
487
488if [ "$1" == "dump" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000489 LOG="dump-$NAME.log"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000490 TS=$(date -u +"%Y%m%dT%H%M%SZ")
491 WORK=$(mktemp -u -d)
David Bainbridge0774b232019-08-02 06:37:19 +0000492 DATA=$WORK/voltha-debug-dump-$NAME-$TS
David Bainbridgeac7f8072019-08-01 22:15:33 +0000493 mkdir -p $DATA
494 echo $TS > $LOG
David Bainbridge0774b232019-08-02 06:37:19 +0000495 echo -e "Capturing debug dump to voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000496 bspin - "Copy install log"
David Bainbridge0774b232019-08-02 06:37:19 +0000497 if [ -f install-$NAME.log ]; then
498 (set -x; cp install-$NAME.log $DATA/install-$NAME.log) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000499 espin - $VERIFIED
500 else
David Bainbridge0774b232019-08-02 06:37:19 +0000501 espin - "$NO_ENTRY Copy install log: install-$NAME.log not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000502 fi
503 bspin - "Dumping Kubernetes PODs"
504 (set -x; kubectl get --all-namespaces pods >> $DATA/all-pods.txt 2>&1) >>$LOG 2>&1
505 espin - $VERIFIED
506 bspin - "Dumping Kubernetes SERVICEs"
507 (set -x; kubectl get --all-namespaces svc >> $DATA/all-services.txt 2>&1) >>$LOG 2>&1
508 espin - $VERIFIED
509 bspin - "Dumping Kubernetes EVENTs"
510 (set -x; kubectl get --all-namespaces events >> $DATA/all-events.txt 2>&1) >>$LOG 2>&1
511 espin - $VERIFIED
512 bspin - "Dumping VOLTHA POD details"
513 PODS=$(kubectl get -n voltha pod -o name)
514 for POD in $PODS; do
515 sspin - "Dumping VOLTHA POD details: $POD$CEOL"
516 mkdir -p $DATA/$POD
517 (set -x; kubectl describe -n voltha $POD >> $DATA/$POD/describe.txt 2>&1) >>$LOG 2>&1
518 sspin - "Dumping VOLTHA POD details: $POD"
519 (set -x; kubectl logs -n voltha --all-containers --previous $LOG_ARGS $POD >> $DATA/$POD/logs-previous.txt 2>&1) >>$LOG 2>&1
520 sspin - "Dumping VOLTHA POD details: $POD"
521 (set -x; kubectl logs -n voltha --all-containers $LOG_ARGS $POD >> $DATA/$POD/logs-current.txt 2>&1) >>$LOG 2>&1
522 sspin - "Dumping VOLTHA POD details: $POD"
523 done
524 espin - "$VERIFIED Dumping VOLTHA POD details$CEOL"
525 bspin - "Dumping ETCD"
526 if [ "$(which etcdctl) X" != " X" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000527 (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 +0000528 espin - $VERIFIED
529 else
530 espin - "$NO_ENTRY Dumping ETCD: etcdctl command not available"
531 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000532 bspin - "Creating compressed TAR: voltha-debug-dump-$NAME-$TS.tgz"
533 (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 +0000534 espin - $VERIFIED
535 bspin - "Cleanup"
536 (set -x; rm -rf $WORK) >>$LOG 2>&1
537 espin - $VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +0000538 bspin - "$(ls -l voltha-debug-dump-$NAME-$TS.tgz)"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000539 espin - $VERIFIED
540 exit
541fi
542
543
David Bainbridge0774b232019-08-02 06:37:19 +0000544LOG="install-$NAME.log"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000545date > $LOG
David Bainbridge0774b232019-08-02 06:37:19 +0000546echo "PORTS=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT" >> $LOG
David Bainbridgeac7f8072019-08-01 22:15:33 +0000547
548# Output install options to log
549echo "OPTIONS" >> $LOG
David Bainbridgee87067b2019-08-12 22:00:12 +0000550ALL_OPTIONS="NAME TYPE WITH_TIMINGS WITH_BBSIM WITH_RADIUS WITH_ONOS WITH_TP JUST_K8S DEPLOY_K8S \
David Bainbridgeac7f8072019-08-01 22:15:33 +0000551 SKIP_RESTART_API INSTALL_KUBECTL INSTALL_HELM USE_GO VOLTHA_LOG_LEVEL \
552 VOLTHA_CHART VOLTHA_ADAPTER_SIM_CHART VOLTHA_ADAPTER_OPEN_OLT_CHART \
David Bainbridge0774b232019-08-02 06:37:19 +0000553 VOLTHA_ADAPTER_OPEN_ONU_CHART SADIS_VER OLT_VER AAA_VER DHCP_VER \
554 ONOS_API_PORT ONOS_SSH_PORT VOLTHA_API_PORT VOLTHA_SSH_PORT VOLTHA_ETCD_PORT"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000555for O in $ALL_OPTIONS; do
556 VAL=$(eval echo \$$O)
557 if [ $O == "USE_GO" ]; then
558 VAL="$(echo $VAL| test $(grep -c true) -eq 1 && echo yes || echo no)"
559 fi
560 if [ ! -z "$VAL" ]; then
561 printf " %-30s = %s\n" $O $VAL >> $LOG
562 fi
563done
564
565
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700566count_pods() {
567 local NAMESPACE=$1; shift
568 local PODS=$(kubectl -n $NAMESPACE get pod -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}")
569 local COUNT=0
570 local PATTERNS=$*
571 for POD in $PODS; do
572 local NAME=$(echo $POD | cut -d/ -f 1)
573 local STATE=$(echo $POD | cut -d/ -f 2)
574 local CONTAINERS=$(echo $POD | cut -d/ -f 3 | sed -e 's/_/ /g')
575 if [ "$STATE" == "Running" ]; then
576 local TOTAL=$(echo $CONTAINERS | wc -w)
577 local FOUND=$(echo $CONTAINERS | grep -o true | wc -l)
578 if [ $TOTAL -eq $FOUND ]; then
579 for PATTERN in $PATTERNS; do
580 if [[ $NAME =~ $PATTERN ]]; then
581 COUNT=$(expr $COUNT + 1)
582 fi
583 done
584 fi
585 fi
586 done
587 echo $COUNT
588}
589
590wait_for_pods() {
591 local INDENT=
592 if [ "$1" == "-" ]; then
593 INDENT=$1; shift
594 fi
595 local NAMESPACE=$1; shift
596 local EXPECT=$1; shift
597 local RETRY=$1; shift
598 local MESSAGE=$1; shift
599 local PATTERNS=$*
600 local HAVE=$(count_pods $NAMESPACE $PATTERNS)
601 COUNT=$(expr 300 / 15)
602 bspin $INDENT $MESSAGE
603 sspin $INDENT
604 if [ $HAVE -ne $EXPECT ]; then
605 while [ $HAVE -ne $EXPECT ]; do
606 sspin $INDENT
607 COUNT=$(expr $COUNT - 1)
608 if [ $COUNT -eq 0 ]; then
609 HAVE=$(count_pods $NAMESPACE $PATTERNS)
610 COUNT=$(expr 300 / 15)
611 fi
612 sleep .15
613 done
614 fi
615 espin $INDENT $VERIFIED
616 if [ $HAVE -ne $EXPECT ]; then
617 return 1
618 fi
619 return 0
620}
621
622helm_install() {
623 local INDENT=
624 if [ "$1" == "-" ]; then
625 INDENT=$1; shift
626 fi
627 local NAMESPACE=$1; shift
David Bainbridge0774b232019-08-02 06:37:19 +0000628 local INAME=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700629 local CHART=$1; shift
630 local MESSAGE=$*
631
632 COUNT=$(expr 300 / 15)
633 bspin $INDENT $MESSAGE
David Bainbridge458bb662019-08-02 20:04:23 +0000634 (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 -0700635 SUCCESS=$?
636 while [ $SUCCESS -ne 0 ]; do
637 sspin $INDENT
638 COUNT=$(expr $COUNT - 1)
639 if [ $COUNT -eq 0 ]; then
David Bainbridge458bb662019-08-02 20:04:23 +0000640 (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 -0700641 COUNT=$(expr 300 / 15)
642 fi
643 sleep .15
644 done
645 espin $INDENT $VERIFIED
646}
647
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700648echo "INSTALL TYPE: $TYPE" >> $LOG
649
650bspin "Verify GOPATH"
651export GOPATH=$(pwd)
Test User3d7ad8e2019-07-03 06:15:44 +0000652mkdir -p $GOPATH/bin
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700653espin $VERIFIED
654
David Bainbridgee87067b2019-08-12 22:00:12 +0000655STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700656if [ "$INSTALL_KUBECTL" == "no" ]; then
657 bspin "Skip kubectl install"
658 espin $NO_ENTRY
Test Userc13bdc92019-07-03 20:57:49 +0000659else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700660 bspin "Verify kubectl $HELM"
661 if [ -x $GOPATH/bin/kubectl ]; then
662 espin $VERIFIED
663 else
664 espin $NOT_VERIFIED
665 bspin - "Download and install Kubernetes/kubectl $DOWNLOAD"
666 (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
667 (set -x; chmod 755 $GOPATH/bin/kubectl >>$LOG 2>&1) >>$LOG 2>&1
668 espin - $VERIFIED
669 fi
Test Userc13bdc92019-07-03 20:57:49 +0000670fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000671if [ "$WITH_TIMINGS" == "yes" ]; then
672 timeout $(expr $(date +%s) - $STIME)
673fi
Test Userc13bdc92019-07-03 20:57:49 +0000674
David Bainbridgee87067b2019-08-12 22:00:12 +0000675STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700676if [ "$DEPLOY_K8S" == "no" ]; then
677 bspin "Skip Kubernetes/Kind Deployment"
678 espin $NO_ENTRY
679else
Test Userba1e7e72019-07-10 22:27:54 +0000680 bspin "Verify Kubernetes/Kind $HELM"
681 if [ -x $GOPATH/bin/kind ]; then
682 espin $VERIFIED
683 else
684 espin $NOT_VERIFIED
685 bspin - "Download and install Kubernetes/kind $DOWNLOAD"
David Bainbridge9e2a6662019-07-11 17:07:57 +0000686 (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 +0000687 (set -x; chmod 755 $GOPATH/bin/kind >>$LOG 2>&1) >>$LOG 2>&1
688 espin - $VERIFIED
689 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700690fi
691
David Bainbridgee87067b2019-08-12 22:00:12 +0000692if [ "$WITH_TIMINGS" == "yes" ]; then
693 timeout $(expr $(date +%s) - $STIME)
694fi
695
696STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700697if [ "$INSTALL_HELM" == "no" ]; then
698 bspin "Skip Helm Install"
699 espin $NO_ENTRY
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700700else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700701 bspin "Verify Helm $HELM"
702 if [ -x $GOPATH/bin/helm ]; then
703 espin $VERIFIED
704 else
705 espin $NOT_VERIFIED
706 bspin - "Download and install Helm $DOWNLOAD"
707 (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
708 espin - $VERIFIED
709 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700710fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000711if [ "$WITH_TIMINGS" == "yes" ]; then
712 timeout $(expr $(date +%s) - $STIME)
713fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700714
David Bainbridgee87067b2019-08-12 22:00:12 +0000715STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +0000716bspin "Verify voltctl $HIGH_VOLTAGE"
Test User3d7ad8e2019-07-03 06:15:44 +0000717if [ -x $GOPATH/bin/voltctl ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700718 espin $VERIFIED
719else
720 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000721 bspin - "Download and build voltctl $DOWNLOAD"
Test Userba1e7e72019-07-10 22:27:54 +0000722 (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 +0000723 (set -x; chmod 755 $GOPATH/bin/voltctl >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700724 espin - $VERIFIED
725fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000726if [ "$WITH_TIMINGS" == "yes" ]; then
727 timeout $(expr $(date +%s) - $STIME)
728fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700729
730bspin "Verify command PATH"
Test Userba1e7e72019-07-10 22:27:54 +0000731export PATH=$GOPATH/bin:$PATH
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700732espin $VERIFIED
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700733
David Bainbridgee87067b2019-08-12 22:00:12 +0000734STIME=$(date +%s)
Test Userba1e7e72019-07-10 22:27:54 +0000735if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000736 HAVE=$(kind get clusters | grep -c voltha-$NAME)
Test Userba1e7e72019-07-10 22:27:54 +0000737 bspin "Verify Kubernetes/Kind Cluster"
738 sspin
739 if [ $HAVE -eq 0 ]; then
David Bainbridge491b1bd2019-07-11 17:53:11 +0000740 espin $NOT_VERIFIED
741 bspin - "Verify cluster configuration"
David Bainbridge0774b232019-08-02 06:37:19 +0000742 if [ ! -r ./$NAME-cluster.cfg ]; then
David Bainbridge491b1bd2019-07-11 17:53:11 +0000743 espin - $NOT_VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +0000744 bspin - "Download cluster configuration: $TYPE-cluster.cfg to $NAME-cluster.cfg $DOWNLOAD"
745 (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 -0700746 espin - $VERIFIED
747 else
748 espin - $VERIFIED
749 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000750 kind create cluster --name voltha-$NAME --config $NAME-cluster.cfg
David Bainbridge491b1bd2019-07-11 17:53:11 +0000751 else
752 espin $VERIFIED
Test Userba1e7e72019-07-10 22:27:54 +0000753 fi
754
David Bainbridge0774b232019-08-02 06:37:19 +0000755 export KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$NAME")"
Test Userba1e7e72019-07-10 22:27:54 +0000756 P="coredns-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000757 etcd-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +0000758 kindnet-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000759 kube-apiserver-voltha-$NAME-control-plane \
760 kube-controller-manager-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +0000761 kube-proxy-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000762 kube-scheduler-voltha-$NAME-control-plane"
Test Userba1e7e72019-07-10 22:27:54 +0000763
764 EXPECT=$(test "$TYPE" == "minimal" && echo "12" || echo "14")
765 wait_for_pods - "kube-system" $EXPECT -1 "Waiting for system PODs to start" $P
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700766fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000767if [ "$WITH_TIMINGS" == "yes" ]; then
768 timeout $(expr $(date +%s) - $STIME)
769fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700770
David Bainbridgee87067b2019-08-12 22:00:12 +0000771STIME=$(date +%s)
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700772COUNT=$(count_pods "kube-system" "tiller-deploy-.*")
773bspin "Verify Helm"
Test Userba1e7e72019-07-10 22:27:54 +0000774if [ $COUNT -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700775 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000776 echo -e "Configuring Helm $GEAR"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700777 if [ "$INSTALL_HELM" == "no" ]; then
778 bspin - "Skip Helm/Tiller Initialization"
779 espin - $NO_ENTRY
780 else
781 bspin - "Initialize Helm"
782 (set -x; helm init --upgrade >>$LOG 2>&1) >>$LOG 2>&1
783 espin - $VERIFIED
784 wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
785 fi
Test Userb5712372019-07-03 21:52:17 +0000786 bspin - "Add Google Incubator repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700787 (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
788 espin - $VERIFIED
Test Userba1e7e72019-07-10 22:27:54 +0000789
790 # HACK (sort-of) - the config for tiller is about to be patched, which will
791 # cause the tiller pod to be recreated. This can sometimes cause a timing
792 # issue with the "wait_for_pods" call on tiller as it may incorrectly
793 # identify the running/ready tiller pod that is soon to be terminated as
794 # what it is waiting for. To avoid this issue we do a clean scale down and
795 # scale up of the pod so the script controlls when it should be expecting
796 # things
797 (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 -0700798
Test Userb5712372019-07-03 21:52:17 +0000799 bspin - "Add Google Stable repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700800 (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
801 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000802 bspin - "Add ONF repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700803 (set -x; helm repo add onf https://charts.opencord.org >>$LOG 2>&1) >>$LOG 2>&1
804 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000805 bspin - "Update Helm repository cache"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700806 (set -x; helm repo update >>$LOG 2>&1) >>$LOG 2>&1
807 espin - $VERIFIED
808
809 # Create and k8s service account so that Helm can create pods
Test Userb5712372019-07-03 21:52:17 +0000810 bspin - "Create Tiller ServiceAccount"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700811 (set -x; kubectl create serviceaccount --namespace kube-system tiller >>$LOG 2>&1) >>$LOG 2>&1
812 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000813 bspin - "Create Tiller ClusterRoleBinding"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700814 (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>$LOG 2>&1) >>$LOG 2>&1
815 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000816 bspin - "Update Tiller Manifest"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700817 (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 +0000818
819 # HACK (sort-of) - part to, spin it back up
820 (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 -0700821 espin - $VERIFIED
822else
823 espin $VERIFIED
824fi
Test Userb5712372019-07-03 21:52:17 +0000825wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +0000826if [ "$WITH_TIMINGS" == "yes" ]; then
827 timeout $(expr $(date +%s) - $STIME)
828fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700829
David Bainbridgee87067b2019-08-12 22:00:12 +0000830STIME=$(date +%s)
David Bainbridge0774b232019-08-02 06:37:19 +0000831bspin "Verify Helm values file: $NAME-values.yaml"
832if [ ! -r "./$NAME-values.yaml" ]; then
Test Userba1e7e72019-07-10 22:27:54 +0000833 espin $NOT_VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +0000834 bspin - "Download Helm values file: $TYPE-values.yaml to $NAME-values.yaml $DOWNLOAD"
835 (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 +0000836 espin - $VERIFIED
837else
838 espin $VERIFIED
839fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000840if [ "$WITH_TIMINGS" == "yes" ]; then
841 timeout $(expr $(date +%s) - $STIME)
842fi
Test Userba1e7e72019-07-10 22:27:54 +0000843
844if [ "$JUST_K8S" == "yes" ]; then
845 echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye."
846 echo ""
847 echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
848 echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
849 echo "tools required by VOLTHA in your command path. " | tee -a $LOG
850 echo "" | tee -a $LOG
851 echo -en $BOLD
852 if [ $DEPLOY_K8S == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000853 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +0000854 fi
855 echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
856 echo -en $NORMAL
857 echo "" | tee -a $LOG
858 echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
859 exit 0
860fi
861
David Bainbridgee87067b2019-08-12 22:00:12 +0000862STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +0000863bspin "Verify ETCD Operator $OLD_KEY"
Test User7d866122019-07-09 17:52:35 +0000864if [ $(helm list --deployed --short --namespace voltha "^etcd-operator\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700865 espin $NOT_VERIFIED
866 helm_install - voltha etcd-operator stable/etcd-operator "Install ETCD Operator"
867else
868 espin $VERIFIED
869fi
Test User01ed0642019-07-03 20:17:06 +0000870EXPECT=$(test "$TYPE" == "minimal" && echo "1" || echo "3")
Test Userb5712372019-07-03 21:52:17 +0000871wait_for_pods - "voltha" $EXPECT -1 "Waiting for ETCD Operator to start" "etcd-operator-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +0000872if [ "$WITH_TIMINGS" == "yes" ]; then
873 timeout $(expr $(date +%s) - $STIME)
874fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700875
David Bainbridgee87067b2019-08-12 22:00:12 +0000876STIME=$(date +%s)
David Bainbridgeb270c202019-07-26 01:44:42 +0000877if [ $WITH_ONOS == "yes" ]; then
878 bspin "Verify ONOS installed $BIRD"
879 if [ $(helm list --deployed --short --namespace default "^onos\$" | wc -l) -ne 1 ]; then
880 espin $NOT_VERIFIED
881 helm_install - default onos onf/onos "Install ONOS"
882 else
883 espin $VERIFIED
884 fi
885 wait_for_pods - "default" 1 -1 "Waiting for ONOS to start" "onos-.*"
886
887 bspin - "Forward ONOS API port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +0000888 for i in $(screen -ls | grep onos-ui-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +0000889 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
890 done
David Bainbridge0774b232019-08-02 06:37:19 +0000891 (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 +0000892 espin - $VERIFIED
893 bspin - "Forward ONOS SSH port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +0000894 for i in $(screen -ls | grep onos-ssh-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +0000895 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
896 done
David Bainbridge0774b232019-08-02 06:37:19 +0000897 (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 +0000898 espin - $VERIFIED
899 if [ ! -x ./onos-files/install-onos-applications.sh ]; then
900 bspin - "Verify or download ONOS configuration support files $DOWNLOAD"
901 (set -x; mkdir -p ./onos-files >>$LOG 2>&1) >>$LOG 2>&1
902 for i in dhcp-to-controller-flow.json install-onos-applications.sh olt-onos-enableExtraneousRules.json olt-onos-netcfg.json olt-onos-olt-settings.json radius-config.json; do
903 if [ ! -r ./onos-files/$i ]; then
904 (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
905 fi
906 done
907 (set -x; chmod 755 ./onos-files/install-onos-applications.sh >>$LOG 2>&1) >>$LOG 2>&1
908 espin - $VERIFIED
909 fi
910
911 bspin - "Install required ONOS applications $INSTALL"
912 (set -x; ./onos-files/install-onos-applications.sh >>$LOG 2>&1) >>$LOG 2>&1
Test Userba1e7e72019-07-10 22:27:54 +0000913 espin - $VERIFIED
914fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000915if [ "$WITH_TIMINGS" == "yes" ]; then
916 timeout $(expr $(date +%s) - $STIME)
917fi
Test Userba1e7e72019-07-10 22:27:54 +0000918
David Bainbridgee87067b2019-08-12 22:00:12 +0000919STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +0000920bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
Test User7d866122019-07-09 17:52:35 +0000921if [ $(helm list --deployed --short --namespace voltha "^voltha\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700922 espin $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +0000923 helm_install - voltha voltha $VOLTHA_CHART "Install VOLTHA Core"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700924else
925 espin $VERIFIED
926fi
Test Userba1e7e72019-07-10 22:27:54 +0000927
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700928VOLTHA="ofagent-.* \
929 ro-core.* \
930 rw-core.* \
931 voltha-api-server-.* \
932 voltha-cli-server-.* \
933 voltha-etcd-cluster-.* \
934 voltha-kafka-.* \
935 voltha-zookeeper-.*"
Test User01ed0642019-07-03 20:17:06 +0000936EXPECT=$(test "$TYPE" == "minimal" && echo "9" || echo "11")
Test Userb5712372019-07-03 21:52:17 +0000937wait_for_pods - "voltha" $EXPECT -1 "Waiting for VOLTHA Core to start" $VOLTHA
David Bainbridgee87067b2019-08-12 22:00:12 +0000938if [ "$WITH_TIMINGS" == "yes" ]; then
939 timeout $(expr $(date +%s) - $STIME)
940fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700941
David Bainbridgee87067b2019-08-12 22:00:12 +0000942STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +0000943echo -e "Verify Adapters $PLUG"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700944bspin - "Verify Simulated Adapters installed"
Test User7d866122019-07-09 17:52:35 +0000945if [ $(helm list --deployed --short --namespace voltha "^sim\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700946 espin - $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +0000947 helm_install - voltha sim $VOLTHA_ADAPTER_SIM_CHART "Install Simulated Adapters"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700948else
949 espin - $VERIFIED
950fi
951
952bspin - "Verify OpenOLT Adapter installed"
Test User7d866122019-07-09 17:52:35 +0000953if [ $(helm list --deployed --short --namespace voltha "^open-olt\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700954 espin - $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +0000955 helm_install - voltha open-olt $VOLTHA_ADAPTER_OPEN_OLT_CHART "Install OpenOLT Adapter"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700956else
957 espin - $VERIFIED
958fi
959bspin - "Verify OpenONU Adapter installed"
Test User7d866122019-07-09 17:52:35 +0000960if [ $(helm list --deployed --short --namespace voltha "^open-onu\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700961 espin - $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +0000962 helm_install - voltha open-onu $VOLTHA_ADAPTER_OPEN_ONU_CHART "Install OpenONU Adapter"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700963else
964 espin - $VERIFIED
965fi
966
967ADAPTERS="adapter-.*"
Test Userb5712372019-07-03 21:52:17 +0000968wait_for_pods - "voltha" 4 -1 "Waiting for adapters to start" $ADAPTERS
David Bainbridgee87067b2019-08-12 22:00:12 +0000969if [ "$WITH_TIMINGS" == "yes" ]; then
970 timeout $(expr $(date +%s) - $STIME)
971fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700972
Test User7d866122019-07-09 17:52:35 +0000973if [ $WITH_BBSIM == "yes" ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +0000974 STIME=$(date +%s)
Test User7d866122019-07-09 17:52:35 +0000975 echo -e "Verify BBSIM $PLUG"
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000976 bspin - "Verify BBSIM Installed"
Test User7d866122019-07-09 17:52:35 +0000977 if [ $(helm list --deployed --short --namespace voltha "^bbsim\$" | wc -l) -ne 1 ]; then
978 espin - $NOT_VERIFIED
979 helm_install - voltha bbsim onf/bbsim "Install BBSIM"
980 else
981 espin - $VERIFIED
982 fi
983 wait_for_pods - "voltha" 1 -1 "Waiting for BBSIM to start" "bbsim-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +0000984 if [ "$WITH_TIMINGS" == "yes" ]; then
985 timeout $(expr $(date +%s) - $STIME)
986 fi
Test User7d866122019-07-09 17:52:35 +0000987fi
988
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000989if [ $WITH_RADIUS == "yes" ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +0000990 STIME=$(date +%s)
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000991 echo -e "Verify RADIUS $LOCK"
992 bspin - "Verify RADIUS Installed"
993 if [ $(helm list --deployed --short --namespace voltha "^radius\$" | wc -l) -ne 1 ]; then
994 espin - $NOT_VERIFIED
995 helm_install - voltha radius onf/freeradius "Install RADIUS"
996 else
997 espin - $VERIFIED
998 fi
999 wait_for_pods - "voltha" 1 -1 "Waiting for RADIUS to start" "radius-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001000 if [ "$WITH_TIMINGS" == "yes" ]; then
1001 timeout $(expr $(date +%s) - $STIME)
1002 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001003fi
1004
David Bainbridgee87067b2019-08-12 22:00:12 +00001005STIME=$(date +%s)
David Bainbridgee10f6d52019-07-25 00:28:13 +00001006if [ $SKIP_RESTART_API == "no" ]; then
1007 echo -e "Restart VOLTHA API $RESTART"
1008 API="voltha-api-server-.* ofagent-.*"
1009 (set -x; kubectl scale --replicas=0 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1
1010 wait_for_pods - "voltha" 0 -1 "Wait for API to stop $STOP" $API
1011 (set -x; kubectl scale --replicas=1 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1
1012 wait_for_pods - "voltha" 2 -1 "Wait for API to re-start $GO" $API
1013else
1014 bspin "Skip VOLTHA API Restart"
1015 espin $NO_ENTRY
1016fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001017
Test Userb5712372019-07-03 21:52:17 +00001018bspin - "Forward VOLTHA API port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +00001019for i in $(screen -ls | grep voltha-api-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +00001020 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
1021done
David Bainbridge0774b232019-08-02 06:37:19 +00001022(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 -07001023espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +00001024bspin - "Forward VOLTHA SSH port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +00001025for i in $(screen -ls | grep voltha-ssh-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +00001026 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
1027done
David Bainbridge0774b232019-08-02 06:37:19 +00001028(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 -07001029espin - $VERIFIED
David Bainbridgeac7f8072019-08-01 22:15:33 +00001030bspin - "Forward VOLTHA ETCD port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +00001031for i in $(screen -ls | grep voltha-etcd-$NAME | awk '{print $1}'); do
David Bainbridgeac7f8072019-08-01 22:15:33 +00001032 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
1033done
David Bainbridge0774b232019-08-02 06:37:19 +00001034(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 +00001035espin - $VERIFIED
David Bainbridgee87067b2019-08-12 22:00:12 +00001036if [ "$WITH_TIMINGS" == "yes" ]; then
1037 timeout $(expr $(date +%s) - $STIME)
1038fi
Test User3d7ad8e2019-07-03 06:15:44 +00001039
David Bainbridgeb270c202019-07-26 01:44:42 +00001040if [ $WITH_ONOS == "yes" -a $WITH_RADIUS == "yes" ]; then
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001041 bspin "Configure ONOS RADIUS Connection $GEAR"
1042 (set -x; cat onos-files/radius-config.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 -H Content-type:application/json -d@- >>$LOG 2>&1) >>$LOG 2>&1
1043 espin $VERIFIED
1044fi
1045
1046bspin "Create voltctl configuration file"
Test User3d7ad8e2019-07-03 06:15:44 +00001047(set -x; mkdir -p $HOME/.volt >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridge0774b232019-08-02 06:37:19 +00001048(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 +00001049espin $VERIFIED
Test User08ebbd92019-07-03 17:15:39 +00001050
David Bainbridge0774b232019-08-02 06:37:19 +00001051if [ ! -f "$NAME-env.sh" ]; then
1052 touch $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001053fi
1054
David Bainbridge596f30d2019-07-30 17:07:59 +00001055for O in $ALL_OPTIONS; do
1056 VAL=$(eval echo \$$O)
1057 if [ $O == "USE_GO" ]; then
1058 VAL="$(echo $VAL| test $(grep -c true) -eq 1 && echo yes || echo no)"
1059 fi
David Bainbridge0774b232019-08-02 06:37:19 +00001060 if [ ! -z "$VAL" -a $(grep -c "^export $O=" $NAME-env.sh) -eq 0 ]; then
1061 echo "export $O=\"$(eval echo \$$O)\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001062 fi
1063done
1064
David Bainbridge0774b232019-08-02 06:37:19 +00001065if [ $DEPLOY_K8S == "yes" -a $(grep -c "^export KUBECONFIG=" $NAME-env.sh) -eq 0 ]; then
1066 echo "export KUBECONFIG=\"$(./bin/kind get kubeconfig-path --name=voltha-$NAME)\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001067fi
1068
David Bainbridge0774b232019-08-02 06:37:19 +00001069if [ $(grep -c "^export VOLTCONFIG=" $NAME-env.sh) -eq 0 ]; then
1070 echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001071fi
1072
David Bainbridge0774b232019-08-02 06:37:19 +00001073if [ $(grep -c "^export PATH=" $NAME-env.sh) -eq 0 ]; then
1074 echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001075fi
1076
Test User7d866122019-07-09 17:52:35 +00001077echo ""
Test User08ebbd92019-07-03 17:15:39 +00001078echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
1079echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
1080echo "tools required by VOLTHA in your command path. " | tee -a $LOG
1081echo "" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +00001082echo -en $BOLD
Test Userba1e7e72019-07-10 22:27:54 +00001083if [ $DEPLOY_K8S == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001084 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +00001085fi
David Bainbridge0774b232019-08-02 06:37:19 +00001086echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +00001087echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +00001088echo -en $NORMAL
Test User08ebbd92019-07-03 17:15:39 +00001089echo "" | tee -a $LOG
1090echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
1091