blob: 2a45b2a38297b7d0ca8e7fadc0a5ae651b6fc1ed [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 Bainbridge27790d62019-08-13 22:43:19 +000073INSTALL_ONOS_APPS=${INSTALL_ONOS_APPS:-no}
David Bainbridge01294952019-07-30 19:33:45 +000074WITH_TP=${WITH_TP:-yes}
Test Userba1e7e72019-07-10 22:27:54 +000075JUST_K8S=${JUST_K8S:-no}
76DEPLOY_K8S=${DEPLOY_K8S:-yes}
David Bainbridgee10f6d52019-07-25 00:28:13 +000077SKIP_RESTART_API=${SKIP_RESTART_API:-no}
David K. Bainbridge0e89cb92019-07-17 11:30:10 -070078INSTALL_KUBECTL=${INSTALL_KUBECTL:-yes}
79INSTALL_HELM=${INSTALL_HELM:-yes}
David Bainbridge5b7b96b2019-07-25 20:29:13 +000080USE_GO=${USE_GO:-yes}
81VOLTHA_LOG_LEVEL=${VOLTHA_LOG_LEVEL:-WARN}
David Bainbridgee10f6d52019-07-25 00:28:13 +000082VOLTHA_CHART=${VOLTHA_CHART:=onf/voltha}
83VOLTHA_ADAPTER_SIM_CHART=${VOLTHA_ADAPTER_SIM_CHART:-onf/voltha-adapter-simulated}
84VOLTHA_ADAPTER_OPEN_OLT_CHART=${VOLTHA_ADAPTER_OPEN_OLT_CHART:-onf/voltha-adapter-openolt}
85VOLTHA_ADAPTER_OPEN_ONU_CHART=${VOLTHA_ADAPTER_OPEN_ONU_CHART:-onf/voltha-adapter-openonu}
Test Userba1e7e72019-07-10 22:27:54 +000086
87HAVE_GO=$(which go >/dev/null 2>&1 && echo "yes" || echo "no")
88HOSTOS=$(uname -s | tr "[:upper:]" "[:lower:"])
89HOSTARCH=$(uname -m | tr "[:upper:]" "[:lower:"])
90if [ $HOSTARCH == "x86_64" ]; then
91 HOSTARCH="amd64"
92fi
Test User7d866122019-07-09 17:52:35 +000093
94# Verify TYPE setting
95if [ $(echo ":minimal:full:" | grep -ic ":$TYPE:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -070096 >&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 +000097 exit 1
98fi
99
100# Verify WITH_BBSIM settting and convert uniform value of yes or no
101if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_BBSIM:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700102 >&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 +0000103 exit 1
104fi
105if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_BBSIM:") -eq 1 ]; then
106 WITH_BBSIM=yes
107else
108 WITH_BBSIM=no
109fi
110
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000111# Verify WITH_RADIUS settting and convert uniform value of yes or no
112if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_RADIUS:") -eq 0 ]; then
113 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_RADIUS value of '$WITH_RADIUS'. Should be 'yes' or 'no'${NORMAL}"
114 exit 1
115fi
116if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_RADIUS:") -eq 1 ]; then
117 WITH_RADIUS=yes
118else
119 WITH_RADIUS=no
120fi
121
David Bainbridge01294952019-07-30 19:33:45 +0000122# Verify WITH_TP settting and convert uniform value of yes or no
123if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_TP:") -eq 0 ]; then
124 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_TP value of '$WITH_TP'. Should be 'yes' or 'no'${NORMAL}"
125 exit 1
126fi
127if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_TP:") -eq 1 ]; then
128 WITH_TP=yes
129else
130 WITH_TP=no
131fi
132
David Bainbridgeb270c202019-07-26 01:44:42 +0000133# Verify WITH_ONOS settting and convert uniform value of yes or no
134if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_ONOS:") -eq 0 ]; then
135 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_ONOS value of '$WITH_ONOS'. Should be 'yes' or 'no'${NORMAL}"
136 exit 1
137fi
138if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_ONOS:") -eq 1 ]; then
139 WITH_ONOS=yes
140else
141 WITH_ONOS=no
142fi
143
Test Userba1e7e72019-07-10 22:27:54 +0000144# Verify JUST_K8S settting and convert uniform value of yes or no
145if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$JUST_K8S:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700146 >&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 +0000147 exit 1
148fi
149if [ $(echo ":y:yes:true:1:" | grep -ic ":$JUST_K8S:") -eq 1 ]; then
150 JUST_K8S=yes
151else
152 JUST_K8S=no
153fi
154
155# Verify DEPLOY_K8S settting and convert uniform value of yes or no
156if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$DEPLOY_K8S:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700157 >&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 +0000158 exit 1
159fi
160if [ $(echo ":y:yes:true:1:" | grep -ic ":$DEPLOY_K8S:") -eq 1 ]; then
161 DEPLOY_K8S=yes
162else
163 DEPLOY_K8S=no
164fi
Test User01ed0642019-07-03 20:17:06 +0000165
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700166# Verify INSTALL_KUBECTL settting and convert uniform value of yes or no
167if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$INSTALL_KUBECTL:") -eq 0 ]; then
168 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$INSTALL_KUBECTL value of '$INSTALL_KUBECTL'. Should be 'yes' or 'no'${NORMAL}"
169 exit 1
170fi
171
172if [ $(echo ":y:yes:true:1:" | grep -ic ":$INSTALL_KUBECTL:") -eq 1 ]; then
173 INSTALL_KUBECTL=yes
174else
175 INSTALL_KUBECTL=no
176fi
177
David Bainbridgee10f6d52019-07-25 00:28:13 +0000178# Verify SKIP_RESTART_API settting and convert uniform value of yes or no
179if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$SKIP_RESTART_API:") -eq 0 ]; then
180 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$SKIP_RESTART_API value of '$SKIP_RESTART_API'. Should be 'yes' or 'no'${NORMAL}"
181 exit 1
182fi
183if [ $(echo ":y:yes:true:1:" | grep -ic ":$SKIP_RESTART_API:") -eq 1 ]; then
184 SKIP_RESTART_API=yes
185else
186 SKIP_RESTART_API=no
187fi
188
David Bainbridge1ceabc12019-07-25 17:21:05 +0000189# Verify USE_GO settting and convert uniform value of yes or no
190if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$USE_GO:") -eq 0 ]; then
191 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$USE_GO value of '$USE_GO'. Should be 'yes' or 'no'${NORMAL}"
192 exit 1
193fi
194if [ $(echo ":y:yes:true:1:" | grep -ic ":$USE_GO:") -eq 1 ]; then
195 USE_GO=true
196else
197 USE_GO=false
198fi
199
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700200# Verify INSTALL_HELM settting and convert uniform value of yes or no
201if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$INSTALL_HELM:") -eq 0 ]; then
202 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$INSTALL_HELM value of '$INSTALL_HELM'. Should be 'yes' or 'no'${NORMAL}"
203 exit 1
204fi
205
206if [ $(echo ":y:yes:true:1:" | grep -ic ":$INSTALL_HELM:") -eq 1 ]; then
207 INSTALL_HELM=yes
208else
209 INSTALL_HELM=no
210fi
211
David Bainbridgee87067b2019-08-12 22:00:12 +0000212# Verify WITH_TIMINGS settting and convert uniform value of yes or no
213if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_TIMINGS:") -eq 0 ]; then
214 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_TIMINGS value of '$WITH_TIMINGS'. Should be 'yes' or 'no'${NORMAL}"
215 exit 1
216fi
217
218if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_TIMINGS:") -eq 1 ]; then
219 WITH_TIMINGS=yes
220else
221 WITH_TIMINGS=no
222fi
223
David Bainbridge27790d62019-08-13 22:43:19 +0000224# Verify INSTALL_ONOS_APPS settting and convert uniform value of yes or no
225if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$INSTALL_ONOS_APPS:") -eq 0 ]; then
226 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$INSTALL_ONOS_APPS value of '$INSTALL_ONOS_APPS'. Should be 'yes' or 'no'${NORMAL}"
227 exit 1
228fi
229
230if [ $(echo ":y:yes:true:1:" | grep -ic ":$INSTALL_ONOS_APPS:") -eq 1 ]; then
231 INSTALL_ONOS_APPS=yes
232else
233 INSTALL_ONOS_APPS=no
234fi
235
David Bainbridge0774b232019-08-02 06:37:19 +0000236mkdir -p .voltha
237touch .voltha/ports
238HAVE=$(grep $NAME .voltha/ports)
239if [ "$HAVE X" == " X" ]; then
240 # Find free port prefix
241 START=81
242 while true; do
243 if [ $(grep -c $START .voltha/ports) -eq 0 ]; then
244 break
245 fi
246 START=$(expr $START + 1)
247 done
248 DELTA=$(expr $START - 81)
249 ONOS_API_PORT=${START}81
250 ONOS_SSH_PORT=${START}01
251 VOLTHA_API_PORT=5$(expr 55 + $DELTA)55
252 VOLTHA_SSH_PORT=$(expr 50 + $DELTA)22
253 VOLTHA_ETCD_PORT=$(expr 23 + $DELTA)79
Test User01ed0642019-07-03 20:17:06 +0000254else
David Bainbridge0774b232019-08-02 06:37:19 +0000255 VALUES=$(echo $HAVE | sed -e 's/\s//g' | cut -d= -f2)
256 ONOS_API_PORT=$(echo $VALUES | cut -d, -f1)
257 ONOS_SSH_PORT=$(echo $VALUES | cut -d, -f2)
258 VOLTHA_API_PORT=$(echo $VALUES | cut -d, -f3)
259 VOLTHA_SSH_PORT=$(echo $VALUES | cut -d, -f4)
260 VOLTHA_ETCD_PORT=$(echo $VALUES | cut -d, -f5)
Test User01ed0642019-07-03 20:17:06 +0000261fi
262
David Bainbridge0774b232019-08-02 06:37:19 +0000263PORTTMP=$(mktemp -u)
264cat .voltha/ports | grep -v $NAME > $PORTTMP
265echo "$NAME=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT" >> $PORTTMP
266cp $PORTTMP .voltha/ports
267rm -f $PORTTMP
268
David Bainbridge27790d62019-08-13 22:43:19 +0000269ONOS_TAG=${ONOS_TAG:-}
270if [ "$WITH_TP" == "yes" -a "$ONOS_TAG X" == " X" ]; then
271 ONOS_TAG="voltha-1.7"
David Bainbridge01294952019-07-30 19:33:45 +0000272fi
David Bainbridge27790d62019-08-13 22:43:19 +0000273export ONOS_API_PORT ONOS_SSH_PORT
David Bainbridge01294952019-07-30 19:33:45 +0000274
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700275spin() {
Test Userd87942b2019-07-03 07:20:24 +0000276 PARTS="\
277 \xe2\xa2\x8e\xe2\xa1\xb0 \
278 \xe2\xa2\x8e\xe2\xa1\xa1 \
279 \xe2\xa2\x8e\xe2\xa1\x91 \
280 \xe2\xa2\x8e\xe2\xa0\xb1 \
281 \xe2\xa0\x8e\xe2\xa1\xb1 \
282 \xe2\xa2\x8a\xe2\xa1\xb1 \
283 \xe2\xa2\x8c\xe2\xa1\xb1 \
284 \xe2\xa2\x86\xe2\xa1\xb1 \
285 "
286 IDX=1
David Bainbridge38dc1e82019-08-12 15:18:45 +0000287 echo -en $CIVIS
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700288 while true; do
Test Userd87942b2019-07-03 07:20:24 +0000289 C=$(echo $PARTS | cut '-d ' -f $IDX)
290 echo -en "$C"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700291 IDX=$(expr $IDX + 1)
Test Userd87942b2019-07-03 07:20:24 +0000292 if [ $IDX -gt 8 ]; then
293 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700294 fi
295 sleep .15
296 echo -en "\r"
297 done
298}
299
Test Userd87942b2019-07-03 07:20:24 +0000300IDX=1
David Bainbridgee87067b2019-08-12 22:00:12 +0000301CLOCK="TIME:"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000302SPIN_PARTS=
303NOT_VERIFIED=
304VERIFIED=
305HELM=
306OLD_KEY=
307BIRD=
308HIGH_VOLTAGE=
309PLUG=
310RESTART=
311FORWARD=
312INSTALL=
313STOP=
314GO=
315DOWNLOAD=
316GEAR=
317NO_ENTRY=
318LOCK=
319
320if [ $FANCY -eq 1 ]; then
321 SPIN_PARTS="\
322 \xe2\xa2\x8e\xe2\xa1\xb0 \
323 \xe2\xa2\x8e\xe2\xa1\xa1 \
324 \xe2\xa2\x8e\xe2\xa1\x91 \
325 \xe2\xa2\x8e\xe2\xa0\xb1 \
326 \xe2\xa0\x8e\xe2\xa1\xb1 \
327 \xe2\xa2\x8a\xe2\xa1\xb1 \
328 \xe2\xa2\x8c\xe2\xa1\xb1 \
329 \xe2\xa2\x86\xe2\xa1\xb1 \
330 "
David Bainbridgee87067b2019-08-12 22:00:12 +0000331 CLOCK="\xe2\x8f\xb1"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000332 NOT_VERIFIED="\xe2\x9c\x97\x20"
333 VERIFIED="\xe2\x9c\x93\x20"
334 HELM="\xE2\x8E\x88"
335 OLD_KEY="\xF0\x9F\x97\x9D"
336 BIRD="\xF0\x9F\x90\xA6"
337 HIGH_VOLTAGE="\xE2\x9A\xA1"
338 PLUG="\xF0\x9F\xa7\xa9"
339 RESTART="\xf0\x9f\x94\x84"
340 FORWARD="\xE2\x87\xA8"
341 INSTALL="\xF0\x9F\x8F\x97"
342 STOP="\xf0\x9f\x9b\x91"
343 GO="\xf0\x9f\x9a\x80"
344 DOWNLOAD="\xf0\x9f\x93\xa5"
345 GEAR="\xe2\x9a\x99"
346 NO_ENTRY="\xe2\x9b\x94"
347 LOCK="\xf0\x9f\x94\x92"
348fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700349
David Bainbridgee87067b2019-08-12 22:00:12 +0000350timeout() {
351 local INDENT=
352 if [ "$1" == "-" ]; then
353 INDENT=" "
354 shift
355 fi
356 local h=$(expr $1 / 3600)
357 local m=$(expr $1 % 3600 / 60)
358 local s=$(expr $1 % 60)
359 local t=""
360
361 if [ $h -gt 0 ]; then
362 t="$t${h}h"
363 fi
364 if [ $m -gt 0 ]; then
365 t="$t${m}m"
366 fi
367 t="$t${s}s"
368 echo -e "$INDENT $CLOCK $t"
369}
370
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700371bspin() {
Test Userd87942b2019-07-03 07:20:24 +0000372 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700373 local INDENT=
374 if [ "$1" == "-" ]; then
375 INDENT=" "
376 shift
377 fi
David Bainbridge38dc1e82019-08-12 15:18:45 +0000378 if [ $FANCY -eq 0 ]; then
379 LINE=$(echo $* | sed -e 's/[\s+-]//g')
380 if [ "$LINE X" == " X" ]; then
381 return
382 fi
383 echo -e "$CIVIS$INDENT$*"
384 else
385 echo -en "$CIVIS$INDENT $*"
386 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700387}
388
389sspin() {
390 local INDENT=
391 if [ "$1" == "-" ]; then
392 INDENT=" "
393 shift
394 fi
David Bainbridge38dc1e82019-08-12 15:18:45 +0000395 if [ $FANCY -eq 0 ]; then
396 LINE=$(echo $* | sed -e 's/[\s+-]//g')
397 if [ "$LINE X" == " X" ]; then
398 return
399 fi
400 echo -e "$INDENT$*"
401 else
402 C=$(echo $SPIN_PARTS | cut '-d ' -f $IDX)
403 echo -en "\r$INDENT$C $*"
404 IDX=$(expr $IDX + 1)
405 if [ $IDX -gt 8 ]; then
406 IDX=1
407 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700408 fi
409}
410
411espin() {
412 local INDENT=
413 if [ "$1" == "-" ]; then
414 INDENT=" "
415 shift
416 fi
David Bainbridge38dc1e82019-08-12 15:18:45 +0000417 if [ $FANCY -eq 0 ]; then
418 LINE=$(echo $* | sed -e 's/[\s+-]//g')
419 if [ "$LINE X" == " X" ]; then
420 return
421 fi
422 echo -e "$INDENT$*"
423 else
424 echo -e "\r$INDENT$*$CNORM"
425 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700426}
427
David Bainbridgeac7f8072019-08-01 22:15:33 +0000428if [ "$1" == "get" -a "$2" == "voltconfig" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000429 echo "$HOME/.volt/config-$NAME"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000430 exit
431fi
432
433if [ $# -ne 1 -o $(echo ":up:down:dump:" | grep -c ":$1:") -ne 1 ]; then
434 >&2 echo "What wouild you like to do today:"
435 >&2 echo " up - bring up voltha"
436 >&2 echo " down - tear down voltha"
437 >&2 echo " dump - create a debug dump of running system"
438 exit 1
439fi
440
441if [ "$1" == "down" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000442 echo "Tearing down voltha cluster $NAME"
443 LOG="down-$NAME.log"
444 echo $(date -u +"%Y%m%dT%H%M%SZ") >$LOG
David Bainbridgeac7f8072019-08-01 22:15:33 +0000445 if [ $DEPLOY_K8S == "yes" ]; then
446 if [ -x ./bin/kind ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000447 bspin "Delete Kubernetes Kind Cluster"
448 (set -x; ./bin/kind delete cluster --name voltha-$NAME >>$LOG 2>&1) >>$LOG 2>&1
449 espin $VERIFIED
David Bainbridgeac7f8072019-08-01 22:15:33 +0000450 else
David Bainbridge0774b232019-08-02 06:37:19 +0000451 espin "$NO_ENTRY Delete Kubernetes Kind Cluster: kind command not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000452 fi
453 else
454 EXISTS=$(helm list -q)
455 EXPECT="etcd-operator onos open-olt open-onu sim voltha bbsim radius"
David Bainbridge0774b232019-08-02 06:37:19 +0000456 bspin "Remove Helm Deployments"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000457 for i in $EXISTS; do
458 if [ $(echo $EXPECT | grep -c $i) -eq 1 ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000459 sspin "Remove Helm Deployments: $i$CEOL"
460 (set -x; ./bin/helm delete --purge $i >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000461 fi
462 done
David Bainbridge0774b232019-08-02 06:37:19 +0000463 espin "$VERIFIED Remove Helm Deployments$CEOL"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000464 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000465 bspin "Remove port-forwards: onos-ui-$NAME"
466 for i in $(screen -ls | grep onos-ui-$NAME | awk '{print $1}'); do
467 sspin
468 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
469 done
470 sspin "Remove port-forwards: onos-ssh-$NAME$CEOL"
471 for i in $(screen -ls | grep onos-ssh-$NAME | awk '{print $1}'); do
472 sspin
473 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
474 done
475 sspin "Remove port-forwards: voltha-api-$NAME$CEOL"
476 for i in $(screen -ls | grep voltha-api-$NAME | awk '{print $1}'); do
477 sspin
478 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
479 done
480 sspin "Remove port-forwards: voltha-ssh-$NAME$CEOL"
481 for i in $(screen -ls | grep voltha-ssh-$NAME | awk '{print $1}'); do
482 sspin
483 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
484 done
485 sspin "Remove port-forwards: voltha-etcd-$NAME$CEOL"
486 for i in $(screen -ls | grep voltha-etcd-$NAME | awk '{print $1}'); do
487 sspin
488 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
489 done
490 espin "$VERIFIED Remove port-forwards$CEOL"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000491 exit
492fi
493
494if [ "$1" == "dump" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000495 LOG="dump-$NAME.log"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000496 TS=$(date -u +"%Y%m%dT%H%M%SZ")
497 WORK=$(mktemp -u -d)
David Bainbridge0774b232019-08-02 06:37:19 +0000498 DATA=$WORK/voltha-debug-dump-$NAME-$TS
David Bainbridgeac7f8072019-08-01 22:15:33 +0000499 mkdir -p $DATA
500 echo $TS > $LOG
David Bainbridge0774b232019-08-02 06:37:19 +0000501 echo -e "Capturing debug dump to voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000502 bspin - "Copy install log"
David Bainbridge0774b232019-08-02 06:37:19 +0000503 if [ -f install-$NAME.log ]; then
504 (set -x; cp install-$NAME.log $DATA/install-$NAME.log) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000505 espin - $VERIFIED
506 else
David Bainbridge0774b232019-08-02 06:37:19 +0000507 espin - "$NO_ENTRY Copy install log: install-$NAME.log not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000508 fi
509 bspin - "Dumping Kubernetes PODs"
510 (set -x; kubectl get --all-namespaces pods >> $DATA/all-pods.txt 2>&1) >>$LOG 2>&1
511 espin - $VERIFIED
512 bspin - "Dumping Kubernetes SERVICEs"
513 (set -x; kubectl get --all-namespaces svc >> $DATA/all-services.txt 2>&1) >>$LOG 2>&1
514 espin - $VERIFIED
515 bspin - "Dumping Kubernetes EVENTs"
516 (set -x; kubectl get --all-namespaces events >> $DATA/all-events.txt 2>&1) >>$LOG 2>&1
517 espin - $VERIFIED
518 bspin - "Dumping VOLTHA POD details"
519 PODS=$(kubectl get -n voltha pod -o name)
520 for POD in $PODS; do
521 sspin - "Dumping VOLTHA POD details: $POD$CEOL"
522 mkdir -p $DATA/$POD
523 (set -x; kubectl describe -n voltha $POD >> $DATA/$POD/describe.txt 2>&1) >>$LOG 2>&1
524 sspin - "Dumping VOLTHA POD details: $POD"
525 (set -x; kubectl logs -n voltha --all-containers --previous $LOG_ARGS $POD >> $DATA/$POD/logs-previous.txt 2>&1) >>$LOG 2>&1
526 sspin - "Dumping VOLTHA POD details: $POD"
527 (set -x; kubectl logs -n voltha --all-containers $LOG_ARGS $POD >> $DATA/$POD/logs-current.txt 2>&1) >>$LOG 2>&1
528 sspin - "Dumping VOLTHA POD details: $POD"
529 done
530 espin - "$VERIFIED Dumping VOLTHA POD details$CEOL"
531 bspin - "Dumping ETCD"
532 if [ "$(which etcdctl) X" != " X" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000533 (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 +0000534 espin - $VERIFIED
535 else
536 espin - "$NO_ENTRY Dumping ETCD: etcdctl command not available"
537 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000538 bspin - "Creating compressed TAR: voltha-debug-dump-$NAME-$TS.tgz"
539 (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 +0000540 espin - $VERIFIED
541 bspin - "Cleanup"
542 (set -x; rm -rf $WORK) >>$LOG 2>&1
543 espin - $VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +0000544 bspin - "$(ls -l voltha-debug-dump-$NAME-$TS.tgz)"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000545 espin - $VERIFIED
546 exit
547fi
548
549
David Bainbridge0774b232019-08-02 06:37:19 +0000550LOG="install-$NAME.log"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000551date > $LOG
David Bainbridge0774b232019-08-02 06:37:19 +0000552echo "PORTS=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT" >> $LOG
David Bainbridgeac7f8072019-08-01 22:15:33 +0000553
554# Output install options to log
555echo "OPTIONS" >> $LOG
David Bainbridgee87067b2019-08-12 22:00:12 +0000556ALL_OPTIONS="NAME TYPE WITH_TIMINGS WITH_BBSIM WITH_RADIUS WITH_ONOS WITH_TP JUST_K8S DEPLOY_K8S \
David Bainbridge27790d62019-08-13 22:43:19 +0000557 INSTALL_ONOS_APPS SKIP_RESTART_API INSTALL_KUBECTL INSTALL_HELM USE_GO VOLTHA_LOG_LEVEL \
David Bainbridgeac7f8072019-08-01 22:15:33 +0000558 VOLTHA_CHART VOLTHA_ADAPTER_SIM_CHART VOLTHA_ADAPTER_OPEN_OLT_CHART \
David Bainbridge27790d62019-08-13 22:43:19 +0000559 VOLTHA_ADAPTER_OPEN_ONU_CHART ONOS_TAG \
David Bainbridge0774b232019-08-02 06:37:19 +0000560 ONOS_API_PORT ONOS_SSH_PORT VOLTHA_API_PORT VOLTHA_SSH_PORT VOLTHA_ETCD_PORT"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000561for O in $ALL_OPTIONS; do
562 VAL=$(eval echo \$$O)
563 if [ $O == "USE_GO" ]; then
564 VAL="$(echo $VAL| test $(grep -c true) -eq 1 && echo yes || echo no)"
565 fi
566 if [ ! -z "$VAL" ]; then
567 printf " %-30s = %s\n" $O $VAL >> $LOG
568 fi
569done
570
David Bainbridged31d6122019-08-13 19:37:59 +0000571push_onos_config() {
572 local MSG=$1
573 local RESOURCE=$2
574 local DATA=$3
575
576 bspin - "$MSG $GEAR"
577 until test; do
578 (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
579 if [ $? -eq 0 ]; then
580 break
581 fi
582 sleep .2
583 sspin -
584 done
585 espin - $VERIFIED
586}
David Bainbridgeac7f8072019-08-01 22:15:33 +0000587
David Bainbridge27790d62019-08-13 22:43:19 +0000588override_onos_app() {
589 local APP=$1
590 local NAME=$(basename $APP | sed -e 's/-.*$//g')
591 until test; do
592 sspin -
593 # Attempt to delete old version (if it exists)
594 (set -x; curl --fail -sSL --user karaf:karaf -X DELETE http://127.0.0.1:$ONOS_API_PORT/onos/v1/applications/$NAME >>$LOG 2>&1) >>$LOG 2>&1
595 sspin -
596 (set -x; curl --fail -sSL --user karaf:karaf -X POST -H Content-Type:application/octet-stream http://127.0.0.1:$ONOS_API_PORT/onos/v1/applications?activate=true --data-binary @$APP >>$LOG 2>&1) >>$LOG 2>&1
597 if [ $? -eq 0 ]; then
598 break
599 fi
600 sleep .2
601 done
602}
603
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700604count_pods() {
605 local NAMESPACE=$1; shift
606 local PODS=$(kubectl -n $NAMESPACE get pod -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}")
607 local COUNT=0
608 local PATTERNS=$*
609 for POD in $PODS; do
610 local NAME=$(echo $POD | cut -d/ -f 1)
611 local STATE=$(echo $POD | cut -d/ -f 2)
612 local CONTAINERS=$(echo $POD | cut -d/ -f 3 | sed -e 's/_/ /g')
613 if [ "$STATE" == "Running" ]; then
614 local TOTAL=$(echo $CONTAINERS | wc -w)
615 local FOUND=$(echo $CONTAINERS | grep -o true | wc -l)
616 if [ $TOTAL -eq $FOUND ]; then
617 for PATTERN in $PATTERNS; do
618 if [[ $NAME =~ $PATTERN ]]; then
619 COUNT=$(expr $COUNT + 1)
620 fi
621 done
622 fi
623 fi
624 done
625 echo $COUNT
626}
627
628wait_for_pods() {
629 local INDENT=
630 if [ "$1" == "-" ]; then
631 INDENT=$1; shift
632 fi
633 local NAMESPACE=$1; shift
634 local EXPECT=$1; shift
635 local RETRY=$1; shift
636 local MESSAGE=$1; shift
637 local PATTERNS=$*
638 local HAVE=$(count_pods $NAMESPACE $PATTERNS)
639 COUNT=$(expr 300 / 15)
640 bspin $INDENT $MESSAGE
641 sspin $INDENT
642 if [ $HAVE -ne $EXPECT ]; then
643 while [ $HAVE -ne $EXPECT ]; do
644 sspin $INDENT
645 COUNT=$(expr $COUNT - 1)
646 if [ $COUNT -eq 0 ]; then
647 HAVE=$(count_pods $NAMESPACE $PATTERNS)
648 COUNT=$(expr 300 / 15)
649 fi
650 sleep .15
651 done
652 fi
653 espin $INDENT $VERIFIED
654 if [ $HAVE -ne $EXPECT ]; then
655 return 1
656 fi
657 return 0
658}
659
660helm_install() {
661 local INDENT=
662 if [ "$1" == "-" ]; then
663 INDENT=$1; shift
664 fi
665 local NAMESPACE=$1; shift
David Bainbridge0774b232019-08-02 06:37:19 +0000666 local INAME=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700667 local CHART=$1; shift
668 local MESSAGE=$*
669
670 COUNT=$(expr 300 / 15)
671 bspin $INDENT $MESSAGE
David Bainbridge458bb662019-08-02 20:04:23 +0000672 (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 -0700673 SUCCESS=$?
674 while [ $SUCCESS -ne 0 ]; do
675 sspin $INDENT
676 COUNT=$(expr $COUNT - 1)
677 if [ $COUNT -eq 0 ]; then
David Bainbridge458bb662019-08-02 20:04:23 +0000678 (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 -0700679 COUNT=$(expr 300 / 15)
680 fi
681 sleep .15
682 done
683 espin $INDENT $VERIFIED
684}
685
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700686echo "INSTALL TYPE: $TYPE" >> $LOG
687
688bspin "Verify GOPATH"
689export GOPATH=$(pwd)
Test User3d7ad8e2019-07-03 06:15:44 +0000690mkdir -p $GOPATH/bin
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700691espin $VERIFIED
692
David Bainbridgee87067b2019-08-12 22:00:12 +0000693STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700694if [ "$INSTALL_KUBECTL" == "no" ]; then
695 bspin "Skip kubectl install"
696 espin $NO_ENTRY
Test Userc13bdc92019-07-03 20:57:49 +0000697else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700698 bspin "Verify kubectl $HELM"
699 if [ -x $GOPATH/bin/kubectl ]; then
700 espin $VERIFIED
701 else
702 espin $NOT_VERIFIED
703 bspin - "Download and install Kubernetes/kubectl $DOWNLOAD"
704 (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
705 (set -x; chmod 755 $GOPATH/bin/kubectl >>$LOG 2>&1) >>$LOG 2>&1
706 espin - $VERIFIED
707 fi
Test Userc13bdc92019-07-03 20:57:49 +0000708fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000709if [ "$WITH_TIMINGS" == "yes" ]; then
710 timeout $(expr $(date +%s) - $STIME)
711fi
Test Userc13bdc92019-07-03 20:57:49 +0000712
David Bainbridgee87067b2019-08-12 22:00:12 +0000713STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700714if [ "$DEPLOY_K8S" == "no" ]; then
715 bspin "Skip Kubernetes/Kind Deployment"
716 espin $NO_ENTRY
717else
Test Userba1e7e72019-07-10 22:27:54 +0000718 bspin "Verify Kubernetes/Kind $HELM"
719 if [ -x $GOPATH/bin/kind ]; then
720 espin $VERIFIED
721 else
722 espin $NOT_VERIFIED
723 bspin - "Download and install Kubernetes/kind $DOWNLOAD"
David Bainbridge9e2a6662019-07-11 17:07:57 +0000724 (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 +0000725 (set -x; chmod 755 $GOPATH/bin/kind >>$LOG 2>&1) >>$LOG 2>&1
726 espin - $VERIFIED
727 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700728fi
729
David Bainbridgee87067b2019-08-12 22:00:12 +0000730if [ "$WITH_TIMINGS" == "yes" ]; then
731 timeout $(expr $(date +%s) - $STIME)
732fi
733
734STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700735if [ "$INSTALL_HELM" == "no" ]; then
736 bspin "Skip Helm Install"
737 espin $NO_ENTRY
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700738else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700739 bspin "Verify Helm $HELM"
740 if [ -x $GOPATH/bin/helm ]; then
741 espin $VERIFIED
742 else
743 espin $NOT_VERIFIED
744 bspin - "Download and install Helm $DOWNLOAD"
745 (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
746 espin - $VERIFIED
747 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700748fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000749if [ "$WITH_TIMINGS" == "yes" ]; then
750 timeout $(expr $(date +%s) - $STIME)
751fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700752
David Bainbridgee87067b2019-08-12 22:00:12 +0000753STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +0000754bspin "Verify voltctl $HIGH_VOLTAGE"
Test User3d7ad8e2019-07-03 06:15:44 +0000755if [ -x $GOPATH/bin/voltctl ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700756 espin $VERIFIED
757else
758 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000759 bspin - "Download and build voltctl $DOWNLOAD"
Test Userba1e7e72019-07-10 22:27:54 +0000760 (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 +0000761 (set -x; chmod 755 $GOPATH/bin/voltctl >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700762 espin - $VERIFIED
763fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000764if [ "$WITH_TIMINGS" == "yes" ]; then
765 timeout $(expr $(date +%s) - $STIME)
766fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700767
768bspin "Verify command PATH"
Test Userba1e7e72019-07-10 22:27:54 +0000769export PATH=$GOPATH/bin:$PATH
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700770espin $VERIFIED
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700771
David Bainbridgee87067b2019-08-12 22:00:12 +0000772STIME=$(date +%s)
Test Userba1e7e72019-07-10 22:27:54 +0000773if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000774 HAVE=$(kind get clusters | grep -c voltha-$NAME)
Test Userba1e7e72019-07-10 22:27:54 +0000775 bspin "Verify Kubernetes/Kind Cluster"
776 sspin
777 if [ $HAVE -eq 0 ]; then
David Bainbridge491b1bd2019-07-11 17:53:11 +0000778 espin $NOT_VERIFIED
779 bspin - "Verify cluster configuration"
David Bainbridge0774b232019-08-02 06:37:19 +0000780 if [ ! -r ./$NAME-cluster.cfg ]; then
David Bainbridge491b1bd2019-07-11 17:53:11 +0000781 espin - $NOT_VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +0000782 bspin - "Download cluster configuration: $TYPE-cluster.cfg to $NAME-cluster.cfg $DOWNLOAD"
783 (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 -0700784 espin - $VERIFIED
785 else
786 espin - $VERIFIED
787 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000788 kind create cluster --name voltha-$NAME --config $NAME-cluster.cfg
David Bainbridge491b1bd2019-07-11 17:53:11 +0000789 else
790 espin $VERIFIED
Test Userba1e7e72019-07-10 22:27:54 +0000791 fi
792
David Bainbridge0774b232019-08-02 06:37:19 +0000793 export KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$NAME")"
Test Userba1e7e72019-07-10 22:27:54 +0000794 P="coredns-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000795 etcd-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +0000796 kindnet-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000797 kube-apiserver-voltha-$NAME-control-plane \
798 kube-controller-manager-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +0000799 kube-proxy-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000800 kube-scheduler-voltha-$NAME-control-plane"
Test Userba1e7e72019-07-10 22:27:54 +0000801
802 EXPECT=$(test "$TYPE" == "minimal" && echo "12" || echo "14")
803 wait_for_pods - "kube-system" $EXPECT -1 "Waiting for system PODs to start" $P
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700804fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000805if [ "$WITH_TIMINGS" == "yes" ]; then
806 timeout $(expr $(date +%s) - $STIME)
807fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700808
David Bainbridgee87067b2019-08-12 22:00:12 +0000809STIME=$(date +%s)
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700810COUNT=$(count_pods "kube-system" "tiller-deploy-.*")
811bspin "Verify Helm"
Test Userba1e7e72019-07-10 22:27:54 +0000812if [ $COUNT -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700813 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000814 echo -e "Configuring Helm $GEAR"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700815 if [ "$INSTALL_HELM" == "no" ]; then
816 bspin - "Skip Helm/Tiller Initialization"
817 espin - $NO_ENTRY
818 else
819 bspin - "Initialize Helm"
820 (set -x; helm init --upgrade >>$LOG 2>&1) >>$LOG 2>&1
821 espin - $VERIFIED
822 wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
823 fi
Test Userb5712372019-07-03 21:52:17 +0000824 bspin - "Add Google Incubator repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700825 (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
826 espin - $VERIFIED
Test Userba1e7e72019-07-10 22:27:54 +0000827
828 # HACK (sort-of) - the config for tiller is about to be patched, which will
829 # cause the tiller pod to be recreated. This can sometimes cause a timing
830 # issue with the "wait_for_pods" call on tiller as it may incorrectly
831 # identify the running/ready tiller pod that is soon to be terminated as
832 # what it is waiting for. To avoid this issue we do a clean scale down and
833 # scale up of the pod so the script controlls when it should be expecting
834 # things
835 (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 -0700836
Test Userb5712372019-07-03 21:52:17 +0000837 bspin - "Add Google Stable repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700838 (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
839 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000840 bspin - "Add ONF repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700841 (set -x; helm repo add onf https://charts.opencord.org >>$LOG 2>&1) >>$LOG 2>&1
842 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000843 bspin - "Update Helm repository cache"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700844 (set -x; helm repo update >>$LOG 2>&1) >>$LOG 2>&1
845 espin - $VERIFIED
846
847 # Create and k8s service account so that Helm can create pods
Test Userb5712372019-07-03 21:52:17 +0000848 bspin - "Create Tiller ServiceAccount"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700849 (set -x; kubectl create serviceaccount --namespace kube-system tiller >>$LOG 2>&1) >>$LOG 2>&1
850 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000851 bspin - "Create Tiller ClusterRoleBinding"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700852 (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>$LOG 2>&1) >>$LOG 2>&1
853 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000854 bspin - "Update Tiller Manifest"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700855 (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 +0000856
857 # HACK (sort-of) - part to, spin it back up
858 (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 -0700859 espin - $VERIFIED
860else
861 espin $VERIFIED
862fi
Test Userb5712372019-07-03 21:52:17 +0000863wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +0000864if [ "$WITH_TIMINGS" == "yes" ]; then
865 timeout $(expr $(date +%s) - $STIME)
866fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700867
David Bainbridgee87067b2019-08-12 22:00:12 +0000868STIME=$(date +%s)
David Bainbridge0774b232019-08-02 06:37:19 +0000869bspin "Verify Helm values file: $NAME-values.yaml"
870if [ ! -r "./$NAME-values.yaml" ]; then
Test Userba1e7e72019-07-10 22:27:54 +0000871 espin $NOT_VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +0000872 bspin - "Download Helm values file: $TYPE-values.yaml to $NAME-values.yaml $DOWNLOAD"
873 (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 +0000874 espin - $VERIFIED
875else
876 espin $VERIFIED
877fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000878if [ "$WITH_TIMINGS" == "yes" ]; then
879 timeout $(expr $(date +%s) - $STIME)
880fi
Test Userba1e7e72019-07-10 22:27:54 +0000881
882if [ "$JUST_K8S" == "yes" ]; then
883 echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye."
884 echo ""
885 echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
886 echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
887 echo "tools required by VOLTHA in your command path. " | tee -a $LOG
888 echo "" | tee -a $LOG
889 echo -en $BOLD
890 if [ $DEPLOY_K8S == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000891 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +0000892 fi
893 echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
894 echo -en $NORMAL
895 echo "" | tee -a $LOG
896 echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
897 exit 0
898fi
899
David Bainbridgee87067b2019-08-12 22:00:12 +0000900STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +0000901bspin "Verify ETCD Operator $OLD_KEY"
Test User7d866122019-07-09 17:52:35 +0000902if [ $(helm list --deployed --short --namespace voltha "^etcd-operator\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700903 espin $NOT_VERIFIED
904 helm_install - voltha etcd-operator stable/etcd-operator "Install ETCD Operator"
905else
906 espin $VERIFIED
907fi
Test User01ed0642019-07-03 20:17:06 +0000908EXPECT=$(test "$TYPE" == "minimal" && echo "1" || echo "3")
Test Userb5712372019-07-03 21:52:17 +0000909wait_for_pods - "voltha" $EXPECT -1 "Waiting for ETCD Operator to start" "etcd-operator-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +0000910if [ "$WITH_TIMINGS" == "yes" ]; then
911 timeout $(expr $(date +%s) - $STIME)
912fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700913
David Bainbridgee87067b2019-08-12 22:00:12 +0000914STIME=$(date +%s)
David Bainbridgeb270c202019-07-26 01:44:42 +0000915if [ $WITH_ONOS == "yes" ]; then
916 bspin "Verify ONOS installed $BIRD"
917 if [ $(helm list --deployed --short --namespace default "^onos\$" | wc -l) -ne 1 ]; then
918 espin $NOT_VERIFIED
David Bainbridge27790d62019-08-13 22:43:19 +0000919 SET_TAG=
920 if [ "$ONOS_TAG X" != " X" ]; then
921 SET_TAG="--set images.onos.tag=$ONOS_TAG"
922 fi
923 EXTRA_HELM_FLAGS="$SET_TAG $EXTRA_HELM_FLAGS" helm_install - default onos onf/onos "Install ONOS"
David Bainbridgeb270c202019-07-26 01:44:42 +0000924 else
925 espin $VERIFIED
926 fi
927 wait_for_pods - "default" 1 -1 "Waiting for ONOS to start" "onos-.*"
928
929 bspin - "Forward ONOS API port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +0000930 for i in $(screen -ls | grep onos-ui-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +0000931 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
932 done
David Bainbridge0774b232019-08-02 06:37:19 +0000933 (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 +0000934 espin - $VERIFIED
935 bspin - "Forward ONOS SSH port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +0000936 for i in $(screen -ls | grep onos-ssh-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +0000937 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
938 done
David Bainbridge0774b232019-08-02 06:37:19 +0000939 (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 +0000940 espin - $VERIFIED
David Bainbridged31d6122019-08-13 19:37:59 +0000941 bspin - "Verify or download ONOS configuration support files $DOWNLOAD"
942 (set -x; mkdir -p ./onos-files >>$LOG 2>&1) >>$LOG 2>&1
943 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
944 if [ ! -r ./onos-files/$i ]; then
945 (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
946 fi
947 done
Test Userba1e7e72019-07-10 22:27:54 +0000948 espin - $VERIFIED
David Bainbridge27790d62019-08-13 22:43:19 +0000949
950 if [ $INSTALL_ONOS_APPS == "yes" ]; then
951 bspin - "Installing custom ONOS applications"
952 if [ -x onos-files/onos-apps -a $(ls -1 onos-files/onos-apps/*.oar 2>/dev/null | wc -l) -gt 0 ]; then
953 for OAR in $(ls -1 onos-files/onos-apps/*.oar); do
954 sspin - "Installing custom ONOS applications - $OAR$CEOL"
955 override_onos_app $OAR
956 done
957 espin - "$VERIFIED Installing custom ONOS applications$CEOL"
958 else
959 espin - "$NOT_VERIFIED Installing custom ONOS applications - None Found"
960 fi
961 fi
David Bainbridged31d6122019-08-13 19:37:59 +0000962
963 push_onos_config "Push ONOS Network Configuration" "network/configuration" "onos-files/olt-onos-netcfg.json"
964 push_onos_config "Enable VOLTHA ONOS DHCP provisioning" "configuration/org.opencord.olt.impl.Olt" "onos-files/olt-onos-olt-settings.json"
965 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 +0000966fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000967if [ "$WITH_TIMINGS" == "yes" ]; then
968 timeout $(expr $(date +%s) - $STIME)
969fi
Test Userba1e7e72019-07-10 22:27:54 +0000970
David Bainbridgee87067b2019-08-12 22:00:12 +0000971STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +0000972bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
Test User7d866122019-07-09 17:52:35 +0000973if [ $(helm list --deployed --short --namespace voltha "^voltha\$" | 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 voltha $VOLTHA_CHART "Install VOLTHA Core"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700976else
977 espin $VERIFIED
978fi
Test Userba1e7e72019-07-10 22:27:54 +0000979
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700980VOLTHA="ofagent-.* \
981 ro-core.* \
982 rw-core.* \
983 voltha-api-server-.* \
984 voltha-cli-server-.* \
985 voltha-etcd-cluster-.* \
986 voltha-kafka-.* \
987 voltha-zookeeper-.*"
Test User01ed0642019-07-03 20:17:06 +0000988EXPECT=$(test "$TYPE" == "minimal" && echo "9" || echo "11")
Test Userb5712372019-07-03 21:52:17 +0000989wait_for_pods - "voltha" $EXPECT -1 "Waiting for VOLTHA Core to start" $VOLTHA
David Bainbridgee87067b2019-08-12 22:00:12 +0000990if [ "$WITH_TIMINGS" == "yes" ]; then
991 timeout $(expr $(date +%s) - $STIME)
992fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700993
David Bainbridgee87067b2019-08-12 22:00:12 +0000994STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +0000995echo -e "Verify Adapters $PLUG"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700996bspin - "Verify Simulated Adapters installed"
Test User7d866122019-07-09 17:52:35 +0000997if [ $(helm list --deployed --short --namespace voltha "^sim\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700998 espin - $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +0000999 helm_install - voltha sim $VOLTHA_ADAPTER_SIM_CHART "Install Simulated Adapters"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001000else
1001 espin - $VERIFIED
1002fi
1003
1004bspin - "Verify OpenOLT Adapter installed"
Test User7d866122019-07-09 17:52:35 +00001005if [ $(helm list --deployed --short --namespace voltha "^open-olt\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001006 espin - $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +00001007 helm_install - voltha open-olt $VOLTHA_ADAPTER_OPEN_OLT_CHART "Install OpenOLT Adapter"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001008else
1009 espin - $VERIFIED
1010fi
1011bspin - "Verify OpenONU Adapter installed"
Test User7d866122019-07-09 17:52:35 +00001012if [ $(helm list --deployed --short --namespace voltha "^open-onu\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001013 espin - $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +00001014 helm_install - voltha open-onu $VOLTHA_ADAPTER_OPEN_ONU_CHART "Install OpenONU Adapter"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001015else
1016 espin - $VERIFIED
1017fi
1018
1019ADAPTERS="adapter-.*"
Test Userb5712372019-07-03 21:52:17 +00001020wait_for_pods - "voltha" 4 -1 "Waiting for adapters to start" $ADAPTERS
David Bainbridgee87067b2019-08-12 22:00:12 +00001021if [ "$WITH_TIMINGS" == "yes" ]; then
1022 timeout $(expr $(date +%s) - $STIME)
1023fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001024
Test User7d866122019-07-09 17:52:35 +00001025if [ $WITH_BBSIM == "yes" ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +00001026 STIME=$(date +%s)
Test User7d866122019-07-09 17:52:35 +00001027 echo -e "Verify BBSIM $PLUG"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001028 bspin - "Verify BBSIM Installed"
Test User7d866122019-07-09 17:52:35 +00001029 if [ $(helm list --deployed --short --namespace voltha "^bbsim\$" | wc -l) -ne 1 ]; then
1030 espin - $NOT_VERIFIED
1031 helm_install - voltha bbsim onf/bbsim "Install BBSIM"
1032 else
1033 espin - $VERIFIED
1034 fi
1035 wait_for_pods - "voltha" 1 -1 "Waiting for BBSIM to start" "bbsim-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001036 if [ "$WITH_TIMINGS" == "yes" ]; then
1037 timeout $(expr $(date +%s) - $STIME)
1038 fi
Test User7d866122019-07-09 17:52:35 +00001039fi
1040
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001041if [ $WITH_RADIUS == "yes" ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +00001042 STIME=$(date +%s)
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001043 echo -e "Verify RADIUS $LOCK"
1044 bspin - "Verify RADIUS Installed"
1045 if [ $(helm list --deployed --short --namespace voltha "^radius\$" | wc -l) -ne 1 ]; then
1046 espin - $NOT_VERIFIED
1047 helm_install - voltha radius onf/freeradius "Install RADIUS"
1048 else
1049 espin - $VERIFIED
1050 fi
1051 wait_for_pods - "voltha" 1 -1 "Waiting for RADIUS to start" "radius-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001052 if [ "$WITH_TIMINGS" == "yes" ]; then
1053 timeout $(expr $(date +%s) - $STIME)
1054 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001055fi
1056
David Bainbridgee87067b2019-08-12 22:00:12 +00001057STIME=$(date +%s)
David Bainbridgee10f6d52019-07-25 00:28:13 +00001058if [ $SKIP_RESTART_API == "no" ]; then
1059 echo -e "Restart VOLTHA API $RESTART"
1060 API="voltha-api-server-.* ofagent-.*"
1061 (set -x; kubectl scale --replicas=0 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1
1062 wait_for_pods - "voltha" 0 -1 "Wait for API to stop $STOP" $API
1063 (set -x; kubectl scale --replicas=1 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1
1064 wait_for_pods - "voltha" 2 -1 "Wait for API to re-start $GO" $API
1065else
1066 bspin "Skip VOLTHA API Restart"
1067 espin $NO_ENTRY
1068fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001069
Test Userb5712372019-07-03 21:52:17 +00001070bspin - "Forward VOLTHA API port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +00001071for i in $(screen -ls | grep voltha-api-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +00001072 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
1073done
David Bainbridge0774b232019-08-02 06:37:19 +00001074(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 -07001075espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +00001076bspin - "Forward VOLTHA SSH port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +00001077for i in $(screen -ls | grep voltha-ssh-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +00001078 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
1079done
David Bainbridge0774b232019-08-02 06:37:19 +00001080(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 -07001081espin - $VERIFIED
David Bainbridgeac7f8072019-08-01 22:15:33 +00001082bspin - "Forward VOLTHA ETCD port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +00001083for i in $(screen -ls | grep voltha-etcd-$NAME | awk '{print $1}'); do
David Bainbridgeac7f8072019-08-01 22:15:33 +00001084 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
1085done
David Bainbridge0774b232019-08-02 06:37:19 +00001086(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 +00001087espin - $VERIFIED
David Bainbridgee87067b2019-08-12 22:00:12 +00001088if [ "$WITH_TIMINGS" == "yes" ]; then
1089 timeout $(expr $(date +%s) - $STIME)
1090fi
Test User3d7ad8e2019-07-03 06:15:44 +00001091
David Bainbridgeb270c202019-07-26 01:44:42 +00001092if [ $WITH_ONOS == "yes" -a $WITH_RADIUS == "yes" ]; then
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001093 bspin "Configure ONOS RADIUS Connection $GEAR"
1094 (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
1095 espin $VERIFIED
1096fi
1097
1098bspin "Create voltctl configuration file"
Test User3d7ad8e2019-07-03 06:15:44 +00001099(set -x; mkdir -p $HOME/.volt >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridge0774b232019-08-02 06:37:19 +00001100(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 +00001101espin $VERIFIED
Test User08ebbd92019-07-03 17:15:39 +00001102
David Bainbridge0774b232019-08-02 06:37:19 +00001103if [ ! -f "$NAME-env.sh" ]; then
1104 touch $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001105fi
1106
David Bainbridge596f30d2019-07-30 17:07:59 +00001107for O in $ALL_OPTIONS; do
1108 VAL=$(eval echo \$$O)
1109 if [ $O == "USE_GO" ]; then
1110 VAL="$(echo $VAL| test $(grep -c true) -eq 1 && echo yes || echo no)"
1111 fi
David Bainbridge0774b232019-08-02 06:37:19 +00001112 if [ ! -z "$VAL" -a $(grep -c "^export $O=" $NAME-env.sh) -eq 0 ]; then
1113 echo "export $O=\"$(eval echo \$$O)\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001114 fi
1115done
1116
David Bainbridge0774b232019-08-02 06:37:19 +00001117if [ $DEPLOY_K8S == "yes" -a $(grep -c "^export KUBECONFIG=" $NAME-env.sh) -eq 0 ]; then
1118 echo "export KUBECONFIG=\"$(./bin/kind get kubeconfig-path --name=voltha-$NAME)\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001119fi
1120
David Bainbridge0774b232019-08-02 06:37:19 +00001121if [ $(grep -c "^export VOLTCONFIG=" $NAME-env.sh) -eq 0 ]; then
1122 echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001123fi
1124
David Bainbridge0774b232019-08-02 06:37:19 +00001125if [ $(grep -c "^export PATH=" $NAME-env.sh) -eq 0 ]; then
1126 echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001127fi
1128
Test User7d866122019-07-09 17:52:35 +00001129echo ""
Test User08ebbd92019-07-03 17:15:39 +00001130echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
1131echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
1132echo "tools required by VOLTHA in your command path. " | tee -a $LOG
1133echo "" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +00001134echo -en $BOLD
Test Userba1e7e72019-07-10 22:27:54 +00001135if [ $DEPLOY_K8S == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001136 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +00001137fi
David Bainbridge0774b232019-08-02 06:37:19 +00001138echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +00001139echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +00001140echo -en $NORMAL
Test User08ebbd92019-07-03 17:15:39 +00001141echo "" | tee -a $LOG
1142echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
1143