blob: 54397bdcb4664dc5dbbff5f766f52d4dd9ac2714 [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
David Bainbridged31d6122019-08-13 19:37:59 +0000565push_onos_config() {
566 local MSG=$1
567 local RESOURCE=$2
568 local DATA=$3
569
570 bspin - "$MSG $GEAR"
571 until test; do
572 (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
573 if [ $? -eq 0 ]; then
574 break
575 fi
576 sleep .2
577 sspin -
578 done
579 espin - $VERIFIED
580}
David Bainbridgeac7f8072019-08-01 22:15:33 +0000581
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700582count_pods() {
583 local NAMESPACE=$1; shift
584 local PODS=$(kubectl -n $NAMESPACE get pod -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}")
585 local COUNT=0
586 local PATTERNS=$*
587 for POD in $PODS; do
588 local NAME=$(echo $POD | cut -d/ -f 1)
589 local STATE=$(echo $POD | cut -d/ -f 2)
590 local CONTAINERS=$(echo $POD | cut -d/ -f 3 | sed -e 's/_/ /g')
591 if [ "$STATE" == "Running" ]; then
592 local TOTAL=$(echo $CONTAINERS | wc -w)
593 local FOUND=$(echo $CONTAINERS | grep -o true | wc -l)
594 if [ $TOTAL -eq $FOUND ]; then
595 for PATTERN in $PATTERNS; do
596 if [[ $NAME =~ $PATTERN ]]; then
597 COUNT=$(expr $COUNT + 1)
598 fi
599 done
600 fi
601 fi
602 done
603 echo $COUNT
604}
605
606wait_for_pods() {
607 local INDENT=
608 if [ "$1" == "-" ]; then
609 INDENT=$1; shift
610 fi
611 local NAMESPACE=$1; shift
612 local EXPECT=$1; shift
613 local RETRY=$1; shift
614 local MESSAGE=$1; shift
615 local PATTERNS=$*
616 local HAVE=$(count_pods $NAMESPACE $PATTERNS)
617 COUNT=$(expr 300 / 15)
618 bspin $INDENT $MESSAGE
619 sspin $INDENT
620 if [ $HAVE -ne $EXPECT ]; then
621 while [ $HAVE -ne $EXPECT ]; do
622 sspin $INDENT
623 COUNT=$(expr $COUNT - 1)
624 if [ $COUNT -eq 0 ]; then
625 HAVE=$(count_pods $NAMESPACE $PATTERNS)
626 COUNT=$(expr 300 / 15)
627 fi
628 sleep .15
629 done
630 fi
631 espin $INDENT $VERIFIED
632 if [ $HAVE -ne $EXPECT ]; then
633 return 1
634 fi
635 return 0
636}
637
638helm_install() {
639 local INDENT=
640 if [ "$1" == "-" ]; then
641 INDENT=$1; shift
642 fi
643 local NAMESPACE=$1; shift
David Bainbridge0774b232019-08-02 06:37:19 +0000644 local INAME=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700645 local CHART=$1; shift
646 local MESSAGE=$*
647
648 COUNT=$(expr 300 / 15)
649 bspin $INDENT $MESSAGE
David Bainbridge458bb662019-08-02 20:04:23 +0000650 (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 -0700651 SUCCESS=$?
652 while [ $SUCCESS -ne 0 ]; do
653 sspin $INDENT
654 COUNT=$(expr $COUNT - 1)
655 if [ $COUNT -eq 0 ]; then
David Bainbridge458bb662019-08-02 20:04:23 +0000656 (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 -0700657 COUNT=$(expr 300 / 15)
658 fi
659 sleep .15
660 done
661 espin $INDENT $VERIFIED
662}
663
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700664echo "INSTALL TYPE: $TYPE" >> $LOG
665
666bspin "Verify GOPATH"
667export GOPATH=$(pwd)
Test User3d7ad8e2019-07-03 06:15:44 +0000668mkdir -p $GOPATH/bin
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700669espin $VERIFIED
670
David Bainbridgee87067b2019-08-12 22:00:12 +0000671STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700672if [ "$INSTALL_KUBECTL" == "no" ]; then
673 bspin "Skip kubectl install"
674 espin $NO_ENTRY
Test Userc13bdc92019-07-03 20:57:49 +0000675else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700676 bspin "Verify kubectl $HELM"
677 if [ -x $GOPATH/bin/kubectl ]; then
678 espin $VERIFIED
679 else
680 espin $NOT_VERIFIED
681 bspin - "Download and install Kubernetes/kubectl $DOWNLOAD"
682 (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
683 (set -x; chmod 755 $GOPATH/bin/kubectl >>$LOG 2>&1) >>$LOG 2>&1
684 espin - $VERIFIED
685 fi
Test Userc13bdc92019-07-03 20:57:49 +0000686fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000687if [ "$WITH_TIMINGS" == "yes" ]; then
688 timeout $(expr $(date +%s) - $STIME)
689fi
Test Userc13bdc92019-07-03 20:57:49 +0000690
David Bainbridgee87067b2019-08-12 22:00:12 +0000691STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700692if [ "$DEPLOY_K8S" == "no" ]; then
693 bspin "Skip Kubernetes/Kind Deployment"
694 espin $NO_ENTRY
695else
Test Userba1e7e72019-07-10 22:27:54 +0000696 bspin "Verify Kubernetes/Kind $HELM"
697 if [ -x $GOPATH/bin/kind ]; then
698 espin $VERIFIED
699 else
700 espin $NOT_VERIFIED
701 bspin - "Download and install Kubernetes/kind $DOWNLOAD"
David Bainbridge9e2a6662019-07-11 17:07:57 +0000702 (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 +0000703 (set -x; chmod 755 $GOPATH/bin/kind >>$LOG 2>&1) >>$LOG 2>&1
704 espin - $VERIFIED
705 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700706fi
707
David Bainbridgee87067b2019-08-12 22:00:12 +0000708if [ "$WITH_TIMINGS" == "yes" ]; then
709 timeout $(expr $(date +%s) - $STIME)
710fi
711
712STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700713if [ "$INSTALL_HELM" == "no" ]; then
714 bspin "Skip Helm Install"
715 espin $NO_ENTRY
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700716else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700717 bspin "Verify Helm $HELM"
718 if [ -x $GOPATH/bin/helm ]; then
719 espin $VERIFIED
720 else
721 espin $NOT_VERIFIED
722 bspin - "Download and install Helm $DOWNLOAD"
723 (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
724 espin - $VERIFIED
725 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700726fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000727if [ "$WITH_TIMINGS" == "yes" ]; then
728 timeout $(expr $(date +%s) - $STIME)
729fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700730
David Bainbridgee87067b2019-08-12 22:00:12 +0000731STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +0000732bspin "Verify voltctl $HIGH_VOLTAGE"
Test User3d7ad8e2019-07-03 06:15:44 +0000733if [ -x $GOPATH/bin/voltctl ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700734 espin $VERIFIED
735else
736 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000737 bspin - "Download and build voltctl $DOWNLOAD"
Test Userba1e7e72019-07-10 22:27:54 +0000738 (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 +0000739 (set -x; chmod 755 $GOPATH/bin/voltctl >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700740 espin - $VERIFIED
741fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000742if [ "$WITH_TIMINGS" == "yes" ]; then
743 timeout $(expr $(date +%s) - $STIME)
744fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700745
746bspin "Verify command PATH"
Test Userba1e7e72019-07-10 22:27:54 +0000747export PATH=$GOPATH/bin:$PATH
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700748espin $VERIFIED
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700749
David Bainbridgee87067b2019-08-12 22:00:12 +0000750STIME=$(date +%s)
Test Userba1e7e72019-07-10 22:27:54 +0000751if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000752 HAVE=$(kind get clusters | grep -c voltha-$NAME)
Test Userba1e7e72019-07-10 22:27:54 +0000753 bspin "Verify Kubernetes/Kind Cluster"
754 sspin
755 if [ $HAVE -eq 0 ]; then
David Bainbridge491b1bd2019-07-11 17:53:11 +0000756 espin $NOT_VERIFIED
757 bspin - "Verify cluster configuration"
David Bainbridge0774b232019-08-02 06:37:19 +0000758 if [ ! -r ./$NAME-cluster.cfg ]; then
David Bainbridge491b1bd2019-07-11 17:53:11 +0000759 espin - $NOT_VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +0000760 bspin - "Download cluster configuration: $TYPE-cluster.cfg to $NAME-cluster.cfg $DOWNLOAD"
761 (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 -0700762 espin - $VERIFIED
763 else
764 espin - $VERIFIED
765 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000766 kind create cluster --name voltha-$NAME --config $NAME-cluster.cfg
David Bainbridge491b1bd2019-07-11 17:53:11 +0000767 else
768 espin $VERIFIED
Test Userba1e7e72019-07-10 22:27:54 +0000769 fi
770
David Bainbridge0774b232019-08-02 06:37:19 +0000771 export KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$NAME")"
Test Userba1e7e72019-07-10 22:27:54 +0000772 P="coredns-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000773 etcd-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +0000774 kindnet-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000775 kube-apiserver-voltha-$NAME-control-plane \
776 kube-controller-manager-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +0000777 kube-proxy-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000778 kube-scheduler-voltha-$NAME-control-plane"
Test Userba1e7e72019-07-10 22:27:54 +0000779
780 EXPECT=$(test "$TYPE" == "minimal" && echo "12" || echo "14")
781 wait_for_pods - "kube-system" $EXPECT -1 "Waiting for system PODs to start" $P
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700782fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000783if [ "$WITH_TIMINGS" == "yes" ]; then
784 timeout $(expr $(date +%s) - $STIME)
785fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700786
David Bainbridgee87067b2019-08-12 22:00:12 +0000787STIME=$(date +%s)
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700788COUNT=$(count_pods "kube-system" "tiller-deploy-.*")
789bspin "Verify Helm"
Test Userba1e7e72019-07-10 22:27:54 +0000790if [ $COUNT -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700791 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000792 echo -e "Configuring Helm $GEAR"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700793 if [ "$INSTALL_HELM" == "no" ]; then
794 bspin - "Skip Helm/Tiller Initialization"
795 espin - $NO_ENTRY
796 else
797 bspin - "Initialize Helm"
798 (set -x; helm init --upgrade >>$LOG 2>&1) >>$LOG 2>&1
799 espin - $VERIFIED
800 wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
801 fi
Test Userb5712372019-07-03 21:52:17 +0000802 bspin - "Add Google Incubator repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700803 (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
804 espin - $VERIFIED
Test Userba1e7e72019-07-10 22:27:54 +0000805
806 # HACK (sort-of) - the config for tiller is about to be patched, which will
807 # cause the tiller pod to be recreated. This can sometimes cause a timing
808 # issue with the "wait_for_pods" call on tiller as it may incorrectly
809 # identify the running/ready tiller pod that is soon to be terminated as
810 # what it is waiting for. To avoid this issue we do a clean scale down and
811 # scale up of the pod so the script controlls when it should be expecting
812 # things
813 (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 -0700814
Test Userb5712372019-07-03 21:52:17 +0000815 bspin - "Add Google Stable repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700816 (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
817 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000818 bspin - "Add ONF repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700819 (set -x; helm repo add onf https://charts.opencord.org >>$LOG 2>&1) >>$LOG 2>&1
820 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000821 bspin - "Update Helm repository cache"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700822 (set -x; helm repo update >>$LOG 2>&1) >>$LOG 2>&1
823 espin - $VERIFIED
824
825 # Create and k8s service account so that Helm can create pods
Test Userb5712372019-07-03 21:52:17 +0000826 bspin - "Create Tiller ServiceAccount"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700827 (set -x; kubectl create serviceaccount --namespace kube-system tiller >>$LOG 2>&1) >>$LOG 2>&1
828 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000829 bspin - "Create Tiller ClusterRoleBinding"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700830 (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>$LOG 2>&1) >>$LOG 2>&1
831 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000832 bspin - "Update Tiller Manifest"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700833 (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 +0000834
835 # HACK (sort-of) - part to, spin it back up
836 (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 -0700837 espin - $VERIFIED
838else
839 espin $VERIFIED
840fi
Test Userb5712372019-07-03 21:52:17 +0000841wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +0000842if [ "$WITH_TIMINGS" == "yes" ]; then
843 timeout $(expr $(date +%s) - $STIME)
844fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700845
David Bainbridgee87067b2019-08-12 22:00:12 +0000846STIME=$(date +%s)
David Bainbridge0774b232019-08-02 06:37:19 +0000847bspin "Verify Helm values file: $NAME-values.yaml"
848if [ ! -r "./$NAME-values.yaml" ]; then
Test Userba1e7e72019-07-10 22:27:54 +0000849 espin $NOT_VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +0000850 bspin - "Download Helm values file: $TYPE-values.yaml to $NAME-values.yaml $DOWNLOAD"
851 (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 +0000852 espin - $VERIFIED
853else
854 espin $VERIFIED
855fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000856if [ "$WITH_TIMINGS" == "yes" ]; then
857 timeout $(expr $(date +%s) - $STIME)
858fi
Test Userba1e7e72019-07-10 22:27:54 +0000859
860if [ "$JUST_K8S" == "yes" ]; then
861 echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye."
862 echo ""
863 echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
864 echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
865 echo "tools required by VOLTHA in your command path. " | tee -a $LOG
866 echo "" | tee -a $LOG
867 echo -en $BOLD
868 if [ $DEPLOY_K8S == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000869 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +0000870 fi
871 echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
872 echo -en $NORMAL
873 echo "" | tee -a $LOG
874 echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
875 exit 0
876fi
877
David Bainbridgee87067b2019-08-12 22:00:12 +0000878STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +0000879bspin "Verify ETCD Operator $OLD_KEY"
Test User7d866122019-07-09 17:52:35 +0000880if [ $(helm list --deployed --short --namespace voltha "^etcd-operator\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700881 espin $NOT_VERIFIED
882 helm_install - voltha etcd-operator stable/etcd-operator "Install ETCD Operator"
883else
884 espin $VERIFIED
885fi
Test User01ed0642019-07-03 20:17:06 +0000886EXPECT=$(test "$TYPE" == "minimal" && echo "1" || echo "3")
Test Userb5712372019-07-03 21:52:17 +0000887wait_for_pods - "voltha" $EXPECT -1 "Waiting for ETCD Operator to start" "etcd-operator-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +0000888if [ "$WITH_TIMINGS" == "yes" ]; then
889 timeout $(expr $(date +%s) - $STIME)
890fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700891
David Bainbridgee87067b2019-08-12 22:00:12 +0000892STIME=$(date +%s)
David Bainbridgeb270c202019-07-26 01:44:42 +0000893if [ $WITH_ONOS == "yes" ]; then
894 bspin "Verify ONOS installed $BIRD"
895 if [ $(helm list --deployed --short --namespace default "^onos\$" | wc -l) -ne 1 ]; then
896 espin $NOT_VERIFIED
897 helm_install - default onos onf/onos "Install ONOS"
898 else
899 espin $VERIFIED
900 fi
901 wait_for_pods - "default" 1 -1 "Waiting for ONOS to start" "onos-.*"
902
903 bspin - "Forward ONOS API port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +0000904 for i in $(screen -ls | grep onos-ui-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +0000905 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
906 done
David Bainbridge0774b232019-08-02 06:37:19 +0000907 (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 +0000908 espin - $VERIFIED
909 bspin - "Forward ONOS SSH port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +0000910 for i in $(screen -ls | grep onos-ssh-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +0000911 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
912 done
David Bainbridge0774b232019-08-02 06:37:19 +0000913 (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 +0000914 espin - $VERIFIED
David Bainbridged31d6122019-08-13 19:37:59 +0000915 bspin - "Verify or download ONOS configuration support files $DOWNLOAD"
916 (set -x; mkdir -p ./onos-files >>$LOG 2>&1) >>$LOG 2>&1
917 for i in dhcp-to-controller-flow.json olt-onos-enableExtraneousRules.json olt-onos-netcfg.json olt-onos-olt-settings.json radius-config.json; do
918 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 Bainbridged31d6122019-08-13 19:37:59 +0000923
924 push_onos_config "Push ONOS Network Configuration" "network/configuration" "onos-files/olt-onos-netcfg.json"
925 push_onos_config "Enable VOLTHA ONOS DHCP provisioning" "configuration/org.opencord.olt.impl.Olt" "onos-files/olt-onos-olt-settings.json"
926 push_onos_config "Enabling extraneous rules for ONOS" "configuration/org.onosproject.net.flow.impl.FlowRuleManager" "onos-files/olt-onos-enableExtraneousRules.json"
Test Userba1e7e72019-07-10 22:27:54 +0000927fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000928if [ "$WITH_TIMINGS" == "yes" ]; then
929 timeout $(expr $(date +%s) - $STIME)
930fi
Test Userba1e7e72019-07-10 22:27:54 +0000931
David Bainbridgee87067b2019-08-12 22:00:12 +0000932STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +0000933bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
Test User7d866122019-07-09 17:52:35 +0000934if [ $(helm list --deployed --short --namespace voltha "^voltha\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700935 espin $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +0000936 helm_install - voltha voltha $VOLTHA_CHART "Install VOLTHA Core"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700937else
938 espin $VERIFIED
939fi
Test Userba1e7e72019-07-10 22:27:54 +0000940
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700941VOLTHA="ofagent-.* \
942 ro-core.* \
943 rw-core.* \
944 voltha-api-server-.* \
945 voltha-cli-server-.* \
946 voltha-etcd-cluster-.* \
947 voltha-kafka-.* \
948 voltha-zookeeper-.*"
Test User01ed0642019-07-03 20:17:06 +0000949EXPECT=$(test "$TYPE" == "minimal" && echo "9" || echo "11")
Test Userb5712372019-07-03 21:52:17 +0000950wait_for_pods - "voltha" $EXPECT -1 "Waiting for VOLTHA Core to start" $VOLTHA
David Bainbridgee87067b2019-08-12 22:00:12 +0000951if [ "$WITH_TIMINGS" == "yes" ]; then
952 timeout $(expr $(date +%s) - $STIME)
953fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700954
David Bainbridgee87067b2019-08-12 22:00:12 +0000955STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +0000956echo -e "Verify Adapters $PLUG"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700957bspin - "Verify Simulated Adapters installed"
Test User7d866122019-07-09 17:52:35 +0000958if [ $(helm list --deployed --short --namespace voltha "^sim\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700959 espin - $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +0000960 helm_install - voltha sim $VOLTHA_ADAPTER_SIM_CHART "Install Simulated Adapters"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700961else
962 espin - $VERIFIED
963fi
964
965bspin - "Verify OpenOLT Adapter installed"
Test User7d866122019-07-09 17:52:35 +0000966if [ $(helm list --deployed --short --namespace voltha "^open-olt\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700967 espin - $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +0000968 helm_install - voltha open-olt $VOLTHA_ADAPTER_OPEN_OLT_CHART "Install OpenOLT Adapter"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700969else
970 espin - $VERIFIED
971fi
972bspin - "Verify OpenONU Adapter installed"
Test User7d866122019-07-09 17:52:35 +0000973if [ $(helm list --deployed --short --namespace voltha "^open-onu\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700974 espin - $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +0000975 helm_install - voltha open-onu $VOLTHA_ADAPTER_OPEN_ONU_CHART "Install OpenONU Adapter"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700976else
977 espin - $VERIFIED
978fi
979
980ADAPTERS="adapter-.*"
Test Userb5712372019-07-03 21:52:17 +0000981wait_for_pods - "voltha" 4 -1 "Waiting for adapters to start" $ADAPTERS
David Bainbridgee87067b2019-08-12 22:00:12 +0000982if [ "$WITH_TIMINGS" == "yes" ]; then
983 timeout $(expr $(date +%s) - $STIME)
984fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700985
Test User7d866122019-07-09 17:52:35 +0000986if [ $WITH_BBSIM == "yes" ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +0000987 STIME=$(date +%s)
Test User7d866122019-07-09 17:52:35 +0000988 echo -e "Verify BBSIM $PLUG"
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000989 bspin - "Verify BBSIM Installed"
Test User7d866122019-07-09 17:52:35 +0000990 if [ $(helm list --deployed --short --namespace voltha "^bbsim\$" | wc -l) -ne 1 ]; then
991 espin - $NOT_VERIFIED
992 helm_install - voltha bbsim onf/bbsim "Install BBSIM"
993 else
994 espin - $VERIFIED
995 fi
996 wait_for_pods - "voltha" 1 -1 "Waiting for BBSIM to start" "bbsim-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +0000997 if [ "$WITH_TIMINGS" == "yes" ]; then
998 timeout $(expr $(date +%s) - $STIME)
999 fi
Test User7d866122019-07-09 17:52:35 +00001000fi
1001
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001002if [ $WITH_RADIUS == "yes" ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +00001003 STIME=$(date +%s)
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001004 echo -e "Verify RADIUS $LOCK"
1005 bspin - "Verify RADIUS Installed"
1006 if [ $(helm list --deployed --short --namespace voltha "^radius\$" | wc -l) -ne 1 ]; then
1007 espin - $NOT_VERIFIED
1008 helm_install - voltha radius onf/freeradius "Install RADIUS"
1009 else
1010 espin - $VERIFIED
1011 fi
1012 wait_for_pods - "voltha" 1 -1 "Waiting for RADIUS to start" "radius-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001013 if [ "$WITH_TIMINGS" == "yes" ]; then
1014 timeout $(expr $(date +%s) - $STIME)
1015 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001016fi
1017
David Bainbridgee87067b2019-08-12 22:00:12 +00001018STIME=$(date +%s)
David Bainbridgee10f6d52019-07-25 00:28:13 +00001019if [ $SKIP_RESTART_API == "no" ]; then
1020 echo -e "Restart VOLTHA API $RESTART"
1021 API="voltha-api-server-.* ofagent-.*"
1022 (set -x; kubectl scale --replicas=0 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1
1023 wait_for_pods - "voltha" 0 -1 "Wait for API to stop $STOP" $API
1024 (set -x; kubectl scale --replicas=1 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1
1025 wait_for_pods - "voltha" 2 -1 "Wait for API to re-start $GO" $API
1026else
1027 bspin "Skip VOLTHA API Restart"
1028 espin $NO_ENTRY
1029fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001030
Test Userb5712372019-07-03 21:52:17 +00001031bspin - "Forward VOLTHA API port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +00001032for i in $(screen -ls | grep voltha-api-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +00001033 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
1034done
David Bainbridge0774b232019-08-02 06:37:19 +00001035(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 -07001036espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +00001037bspin - "Forward VOLTHA SSH port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +00001038for i in $(screen -ls | grep voltha-ssh-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +00001039 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
1040done
David Bainbridge0774b232019-08-02 06:37:19 +00001041(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 -07001042espin - $VERIFIED
David Bainbridgeac7f8072019-08-01 22:15:33 +00001043bspin - "Forward VOLTHA ETCD port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +00001044for i in $(screen -ls | grep voltha-etcd-$NAME | awk '{print $1}'); do
David Bainbridgeac7f8072019-08-01 22:15:33 +00001045 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
1046done
David Bainbridge0774b232019-08-02 06:37:19 +00001047(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 +00001048espin - $VERIFIED
David Bainbridgee87067b2019-08-12 22:00:12 +00001049if [ "$WITH_TIMINGS" == "yes" ]; then
1050 timeout $(expr $(date +%s) - $STIME)
1051fi
Test User3d7ad8e2019-07-03 06:15:44 +00001052
David Bainbridgeb270c202019-07-26 01:44:42 +00001053if [ $WITH_ONOS == "yes" -a $WITH_RADIUS == "yes" ]; then
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001054 bspin "Configure ONOS RADIUS Connection $GEAR"
1055 (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
1056 espin $VERIFIED
1057fi
1058
1059bspin "Create voltctl configuration file"
Test User3d7ad8e2019-07-03 06:15:44 +00001060(set -x; mkdir -p $HOME/.volt >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridge0774b232019-08-02 06:37:19 +00001061(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 +00001062espin $VERIFIED
Test User08ebbd92019-07-03 17:15:39 +00001063
David Bainbridge0774b232019-08-02 06:37:19 +00001064if [ ! -f "$NAME-env.sh" ]; then
1065 touch $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001066fi
1067
David Bainbridge596f30d2019-07-30 17:07:59 +00001068for O in $ALL_OPTIONS; do
1069 VAL=$(eval echo \$$O)
1070 if [ $O == "USE_GO" ]; then
1071 VAL="$(echo $VAL| test $(grep -c true) -eq 1 && echo yes || echo no)"
1072 fi
David Bainbridge0774b232019-08-02 06:37:19 +00001073 if [ ! -z "$VAL" -a $(grep -c "^export $O=" $NAME-env.sh) -eq 0 ]; then
1074 echo "export $O=\"$(eval echo \$$O)\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001075 fi
1076done
1077
David Bainbridge0774b232019-08-02 06:37:19 +00001078if [ $DEPLOY_K8S == "yes" -a $(grep -c "^export KUBECONFIG=" $NAME-env.sh) -eq 0 ]; then
1079 echo "export KUBECONFIG=\"$(./bin/kind get kubeconfig-path --name=voltha-$NAME)\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001080fi
1081
David Bainbridge0774b232019-08-02 06:37:19 +00001082if [ $(grep -c "^export VOLTCONFIG=" $NAME-env.sh) -eq 0 ]; then
1083 echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001084fi
1085
David Bainbridge0774b232019-08-02 06:37:19 +00001086if [ $(grep -c "^export PATH=" $NAME-env.sh) -eq 0 ]; then
1087 echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001088fi
1089
Test User7d866122019-07-09 17:52:35 +00001090echo ""
Test User08ebbd92019-07-03 17:15:39 +00001091echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
1092echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
1093echo "tools required by VOLTHA in your command path. " | tee -a $LOG
1094echo "" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +00001095echo -en $BOLD
Test Userba1e7e72019-07-10 22:27:54 +00001096if [ $DEPLOY_K8S == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001097 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +00001098fi
David Bainbridge0774b232019-08-02 06:37:19 +00001099echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +00001100echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +00001101echo -en $NORMAL
Test User08ebbd92019-07-03 17:15:39 +00001102echo "" | tee -a $LOG
1103echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
1104