blob: 376b7dfdbe25a2ec50fb86b0ac48112535dab099 [file] [log] [blame]
Test User01ed0642019-07-03 20:17:06 +00001#!/bin/bash
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002# Copyright 2019 Ciena Corporation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
David Bainbridge712afb82019-08-14 19:55:58 +000015TOTAL_START_TIME=$(date +%s)
David K. Bainbridgeb7285432019-07-02 22:05:24 -070016
David Bainbridge38dc1e82019-08-12 15:18:45 +000017FANCY=${FANCY:-1}
18if [ "$TERM X" == " X" ]; then
19 FANCY=0
20fi
21
David K. Bainbridgeb7285432019-07-02 22:05:24 -070022# trap ctrl-c and call ctrl_c()
23trap ctrl_c INT
24
25function ctrl_c() {
David Bainbridge38dc1e82019-08-12 15:18:45 +000026 echo -en $CNORM
David K. Bainbridgeb7285432019-07-02 22:05:24 -070027 echo ""
28 echo "ctrl-c trapped"
29 echo "Thank you for trying 'votlha up'"
30 exit
31}
32
Test User08ebbd92019-07-03 17:15:39 +000033VOLTCTL_VERSION=${VOLTCTL_VERSION:-0.0.5-dev}
34KIND_VERSION=${KIND_VERSION:-v0.4.0}
35_VOLTCTL_VERSION=$(echo $VOLTCTL_VERSION | sed -e 's/-/_/g')
36
David Bainbridge38dc1e82019-08-12 15:18:45 +000037BLACK=
38RED=
39GREEN=
40YELLOW=
41BLUE=
42MAGENTA=
43CYAN=
44WHITE=
45BOLD=
46NORMAL=
47ERROR=
48CEOL=
49CNORM=
50CIVIS=
51if [ $FANCY -eq 1 ]; then
52 BLACK=$(tput setaf 0)
53 RED=$(tput setaf 1)
54 GREEN=$(tput setaf 2)
55 YELLOW=$(tput setaf 3)
56 BLUE=$(tput setaf 4)
57 MAGENTA=$(tput setaf 5)
58 CYAN=$(tput setaf 6)
59 WHITE=$(tput setaf 7)
60 BOLD=$(tput bold)
61 NORMAL=$(tput sgr0)
62 ERROR="\xe2\x9c\x97\x20"
63 CEOL=$(tput el)
64 CNORM=$(tput cnorm)
65 CIVIS=$(tput civis)
66fi
Test User7d866122019-07-09 17:52:35 +000067
Test User3d7ad8e2019-07-03 06:15:44 +000068TYPE=${TYPE:-minimal}
David Bainbridge0774b232019-08-02 06:37:19 +000069NAME=${NAME:-$TYPE}
David Bainbridgee87067b2019-08-12 22:00:12 +000070WITH_TIMINGS=${WITH_TIMINGS:-no}
Test User7d866122019-07-09 17:52:35 +000071WITH_BBSIM=${WITH_BBSIM:-no}
David Bainbridge5b7b96b2019-07-25 20:29:13 +000072WITH_RADIUS=${WITH_RADIUS:-no}
David Bainbridgeb270c202019-07-26 01:44:42 +000073WITH_ONOS=${WITH_ONOS:-yes}
David Bainbridge2b19e832019-08-16 02:40:53 +000074CONFIG_SADIS=${CONFIG_SADIS:-no}
David Bainbridge27790d62019-08-13 22:43:19 +000075INSTALL_ONOS_APPS=${INSTALL_ONOS_APPS:-no}
David Bainbridge01294952019-07-30 19:33:45 +000076WITH_TP=${WITH_TP:-yes}
Test Userba1e7e72019-07-10 22:27:54 +000077JUST_K8S=${JUST_K8S:-no}
78DEPLOY_K8S=${DEPLOY_K8S:-yes}
David Bainbridgee10f6d52019-07-25 00:28:13 +000079SKIP_RESTART_API=${SKIP_RESTART_API:-no}
David K. Bainbridge0e89cb92019-07-17 11:30:10 -070080INSTALL_KUBECTL=${INSTALL_KUBECTL:-yes}
81INSTALL_HELM=${INSTALL_HELM:-yes}
David Bainbridge5b7b96b2019-07-25 20:29:13 +000082USE_GO=${USE_GO:-yes}
83VOLTHA_LOG_LEVEL=${VOLTHA_LOG_LEVEL:-WARN}
David Bainbridgee10f6d52019-07-25 00:28:13 +000084VOLTHA_CHART=${VOLTHA_CHART:=onf/voltha}
85VOLTHA_ADAPTER_SIM_CHART=${VOLTHA_ADAPTER_SIM_CHART:-onf/voltha-adapter-simulated}
86VOLTHA_ADAPTER_OPEN_OLT_CHART=${VOLTHA_ADAPTER_OPEN_OLT_CHART:-onf/voltha-adapter-openolt}
87VOLTHA_ADAPTER_OPEN_ONU_CHART=${VOLTHA_ADAPTER_OPEN_ONU_CHART:-onf/voltha-adapter-openonu}
Test Userba1e7e72019-07-10 22:27:54 +000088
89HAVE_GO=$(which go >/dev/null 2>&1 && echo "yes" || echo "no")
90HOSTOS=$(uname -s | tr "[:upper:]" "[:lower:"])
91HOSTARCH=$(uname -m | tr "[:upper:]" "[:lower:"])
92if [ $HOSTARCH == "x86_64" ]; then
93 HOSTARCH="amd64"
94fi
Test User7d866122019-07-09 17:52:35 +000095
96# Verify TYPE setting
97if [ $(echo ":minimal:full:" | grep -ic ":$TYPE:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -070098 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$TYPE value of '$TYPE'. Should be 'minimal' or 'full'${NORMAL}"
Test User7d866122019-07-09 17:52:35 +000099 exit 1
100fi
101
102# Verify WITH_BBSIM settting and convert uniform value of yes or no
103if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_BBSIM:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700104 >&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 +0000105 exit 1
106fi
107if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_BBSIM:") -eq 1 ]; then
108 WITH_BBSIM=yes
109else
110 WITH_BBSIM=no
111fi
112
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000113# Verify WITH_RADIUS settting and convert uniform value of yes or no
114if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_RADIUS:") -eq 0 ]; then
115 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_RADIUS value of '$WITH_RADIUS'. Should be 'yes' or 'no'${NORMAL}"
116 exit 1
117fi
118if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_RADIUS:") -eq 1 ]; then
119 WITH_RADIUS=yes
120else
121 WITH_RADIUS=no
122fi
123
David Bainbridge01294952019-07-30 19:33:45 +0000124# Verify WITH_TP settting and convert uniform value of yes or no
125if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_TP:") -eq 0 ]; then
126 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_TP value of '$WITH_TP'. Should be 'yes' or 'no'${NORMAL}"
127 exit 1
128fi
129if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_TP:") -eq 1 ]; then
130 WITH_TP=yes
131else
132 WITH_TP=no
133fi
134
David Bainbridgeb270c202019-07-26 01:44:42 +0000135# Verify WITH_ONOS settting and convert uniform value of yes or no
136if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_ONOS:") -eq 0 ]; then
137 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_ONOS value of '$WITH_ONOS'. Should be 'yes' or 'no'${NORMAL}"
138 exit 1
139fi
140if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_ONOS:") -eq 1 ]; then
141 WITH_ONOS=yes
142else
143 WITH_ONOS=no
144fi
145
Test Userba1e7e72019-07-10 22:27:54 +0000146# Verify JUST_K8S settting and convert uniform value of yes or no
147if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$JUST_K8S:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700148 >&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 +0000149 exit 1
150fi
151if [ $(echo ":y:yes:true:1:" | grep -ic ":$JUST_K8S:") -eq 1 ]; then
152 JUST_K8S=yes
153else
154 JUST_K8S=no
155fi
156
157# Verify DEPLOY_K8S settting and convert uniform value of yes or no
158if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$DEPLOY_K8S:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700159 >&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 +0000160 exit 1
161fi
162if [ $(echo ":y:yes:true:1:" | grep -ic ":$DEPLOY_K8S:") -eq 1 ]; then
163 DEPLOY_K8S=yes
164else
165 DEPLOY_K8S=no
166fi
Test User01ed0642019-07-03 20:17:06 +0000167
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700168# Verify INSTALL_KUBECTL settting and convert uniform value of yes or no
169if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$INSTALL_KUBECTL:") -eq 0 ]; then
170 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$INSTALL_KUBECTL value of '$INSTALL_KUBECTL'. Should be 'yes' or 'no'${NORMAL}"
171 exit 1
172fi
173
174if [ $(echo ":y:yes:true:1:" | grep -ic ":$INSTALL_KUBECTL:") -eq 1 ]; then
175 INSTALL_KUBECTL=yes
176else
177 INSTALL_KUBECTL=no
178fi
179
David Bainbridgee10f6d52019-07-25 00:28:13 +0000180# Verify SKIP_RESTART_API settting and convert uniform value of yes or no
181if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$SKIP_RESTART_API:") -eq 0 ]; then
182 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$SKIP_RESTART_API value of '$SKIP_RESTART_API'. Should be 'yes' or 'no'${NORMAL}"
183 exit 1
184fi
185if [ $(echo ":y:yes:true:1:" | grep -ic ":$SKIP_RESTART_API:") -eq 1 ]; then
186 SKIP_RESTART_API=yes
187else
188 SKIP_RESTART_API=no
189fi
190
David Bainbridge1ceabc12019-07-25 17:21:05 +0000191# Verify USE_GO settting and convert uniform value of yes or no
192if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$USE_GO:") -eq 0 ]; then
193 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$USE_GO value of '$USE_GO'. Should be 'yes' or 'no'${NORMAL}"
194 exit 1
195fi
196if [ $(echo ":y:yes:true:1:" | grep -ic ":$USE_GO:") -eq 1 ]; then
197 USE_GO=true
198else
199 USE_GO=false
200fi
201
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700202# Verify INSTALL_HELM settting and convert uniform value of yes or no
203if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$INSTALL_HELM:") -eq 0 ]; then
204 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$INSTALL_HELM value of '$INSTALL_HELM'. Should be 'yes' or 'no'${NORMAL}"
205 exit 1
206fi
207
208if [ $(echo ":y:yes:true:1:" | grep -ic ":$INSTALL_HELM:") -eq 1 ]; then
209 INSTALL_HELM=yes
210else
211 INSTALL_HELM=no
212fi
213
David Bainbridgee87067b2019-08-12 22:00:12 +0000214# Verify WITH_TIMINGS settting and convert uniform value of yes or no
215if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_TIMINGS:") -eq 0 ]; then
216 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_TIMINGS value of '$WITH_TIMINGS'. Should be 'yes' or 'no'${NORMAL}"
217 exit 1
218fi
219
220if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_TIMINGS:") -eq 1 ]; then
221 WITH_TIMINGS=yes
222else
223 WITH_TIMINGS=no
224fi
225
David Bainbridge27790d62019-08-13 22:43:19 +0000226# Verify INSTALL_ONOS_APPS settting and convert uniform value of yes or no
227if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$INSTALL_ONOS_APPS:") -eq 0 ]; then
228 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$INSTALL_ONOS_APPS value of '$INSTALL_ONOS_APPS'. Should be 'yes' or 'no'${NORMAL}"
229 exit 1
230fi
231
232if [ $(echo ":y:yes:true:1:" | grep -ic ":$INSTALL_ONOS_APPS:") -eq 1 ]; then
233 INSTALL_ONOS_APPS=yes
234else
235 INSTALL_ONOS_APPS=no
236fi
237
David Bainbridge2b19e832019-08-16 02:40:53 +0000238# Verify CONFIG_SADIS settting and convert uniform value of yes or no
239if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$CONFIG_SADIS:") -eq 0 ]; then
240 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$CONFIG_SADIS value of '$CONFIG_SADIS'. Should be 'yes' or 'no'${NORMAL}"
241 exit 1
242fi
243
244if [ $(echo ":y:yes:true:1:" | grep -ic ":$CONFIG_SADIS:") -eq 1 ]; then
245 CONFIG_SADIS=yes
246else
247 CONFIG_SADIS=no
248fi
249
David Bainbridge0774b232019-08-02 06:37:19 +0000250mkdir -p .voltha
251touch .voltha/ports
252HAVE=$(grep $NAME .voltha/ports)
253if [ "$HAVE X" == " X" ]; then
254 # Find free port prefix
255 START=81
256 while true; do
257 if [ $(grep -c $START .voltha/ports) -eq 0 ]; then
258 break
259 fi
260 START=$(expr $START + 1)
261 done
262 DELTA=$(expr $START - 81)
263 ONOS_API_PORT=${START}81
264 ONOS_SSH_PORT=${START}01
265 VOLTHA_API_PORT=5$(expr 55 + $DELTA)55
266 VOLTHA_SSH_PORT=$(expr 50 + $DELTA)22
267 VOLTHA_ETCD_PORT=$(expr 23 + $DELTA)79
Test User01ed0642019-07-03 20:17:06 +0000268else
David Bainbridge0774b232019-08-02 06:37:19 +0000269 VALUES=$(echo $HAVE | sed -e 's/\s//g' | cut -d= -f2)
270 ONOS_API_PORT=$(echo $VALUES | cut -d, -f1)
271 ONOS_SSH_PORT=$(echo $VALUES | cut -d, -f2)
272 VOLTHA_API_PORT=$(echo $VALUES | cut -d, -f3)
273 VOLTHA_SSH_PORT=$(echo $VALUES | cut -d, -f4)
274 VOLTHA_ETCD_PORT=$(echo $VALUES | cut -d, -f5)
Test User01ed0642019-07-03 20:17:06 +0000275fi
276
David Bainbridge0774b232019-08-02 06:37:19 +0000277PORTTMP=$(mktemp -u)
278cat .voltha/ports | grep -v $NAME > $PORTTMP
279echo "$NAME=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT" >> $PORTTMP
280cp $PORTTMP .voltha/ports
281rm -f $PORTTMP
282
David Bainbridge27790d62019-08-13 22:43:19 +0000283ONOS_TAG=${ONOS_TAG:-}
284if [ "$WITH_TP" == "yes" -a "$ONOS_TAG X" == " X" ]; then
285 ONOS_TAG="voltha-1.7"
David Bainbridge01294952019-07-30 19:33:45 +0000286fi
David Bainbridge27790d62019-08-13 22:43:19 +0000287export ONOS_API_PORT ONOS_SSH_PORT
David Bainbridge01294952019-07-30 19:33:45 +0000288
Test Userd87942b2019-07-03 07:20:24 +0000289IDX=1
David Bainbridgee87067b2019-08-12 22:00:12 +0000290CLOCK="TIME:"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000291SPIN_PARTS=
292NOT_VERIFIED=
David Bainbridgef858a022019-08-14 21:25:11 +0000293THEX=
294BUILD=
295CROSS=
296ENTER=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000297VERIFIED=
298HELM=
299OLD_KEY=
300BIRD=
301HIGH_VOLTAGE=
302PLUG=
303RESTART=
304FORWARD=
305INSTALL=
306STOP=
307GO=
308DOWNLOAD=
309GEAR=
310NO_ENTRY=
311LOCK=
312
313if [ $FANCY -eq 1 ]; then
314 SPIN_PARTS="\
315 \xe2\xa2\x8e\xe2\xa1\xb0 \
316 \xe2\xa2\x8e\xe2\xa1\xa1 \
317 \xe2\xa2\x8e\xe2\xa1\x91 \
318 \xe2\xa2\x8e\xe2\xa0\xb1 \
319 \xe2\xa0\x8e\xe2\xa1\xb1 \
320 \xe2\xa2\x8a\xe2\xa1\xb1 \
321 \xe2\xa2\x8c\xe2\xa1\xb1 \
322 \xe2\xa2\x86\xe2\xa1\xb1 \
323 "
David Bainbridgee87067b2019-08-12 22:00:12 +0000324 CLOCK="\xe2\x8f\xb1"
David Bainbridgef858a022019-08-14 21:25:11 +0000325 THEX="${RED}${BOLD}\xe2\x9c\x97\x20${NORMAL}"
326 ENTER="${YELLOW}${BOLD}\xe2\x8e\x86${NORMAL}"
327 CROSS="${YELLOW}${BOLD}\xe2\x9c\x9a${NORMAL}"
328 BUILD="${YELLOW}${BOLD}\xf0\x9f\x8f\x97${NORMAL}"
329 NOT_VERIFIED="$BUILD"
330 VERIFIED="${GREEN}${BOLD}\xe2\x9c\x93\x20${NORMAL}"
331 HELM="${BLUE}${BOLD}\xE2\x8E\x88${NORMAL}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000332 OLD_KEY="\xF0\x9F\x97\x9D"
333 BIRD="\xF0\x9F\x90\xA6"
334 HIGH_VOLTAGE="\xE2\x9A\xA1"
335 PLUG="\xF0\x9F\xa7\xa9"
336 RESTART="\xf0\x9f\x94\x84"
337 FORWARD="\xE2\x87\xA8"
338 INSTALL="\xF0\x9F\x8F\x97"
339 STOP="\xf0\x9f\x9b\x91"
340 GO="\xf0\x9f\x9a\x80"
341 DOWNLOAD="\xf0\x9f\x93\xa5"
342 GEAR="\xe2\x9a\x99"
343 NO_ENTRY="\xe2\x9b\x94"
344 LOCK="\xf0\x9f\x94\x92"
345fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700346
David Bainbridge712afb82019-08-14 19:55:58 +0000347duration() {
David Bainbridgee87067b2019-08-12 22:00:12 +0000348 local h=$(expr $1 / 3600)
349 local m=$(expr $1 % 3600 / 60)
350 local s=$(expr $1 % 60)
351 local t=""
352
353 if [ $h -gt 0 ]; then
354 t="$t${h}h"
355 fi
356 if [ $m -gt 0 ]; then
357 t="$t${m}m"
358 fi
David Bainbridge712afb82019-08-14 19:55:58 +0000359 echo "$t${s}s"
360}
361
362printtime() {
363 local INDENT=
364 if [ "$1" == "-" ]; then
365 INDENT=" "
366 shift
367 fi
368 echo -e "$INDENT $CLOCK $(duration $1)"
David Bainbridgee87067b2019-08-12 22:00:12 +0000369}
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 Bainbridge2b19e832019-08-16 02:40:53 +0000556ALL_OPTIONS="NAME TYPE WITH_TIMINGS WITH_BBSIM WITH_RADIUS WITH_ONOS WITH_TP \
557 CONFIG_SADIS JUST_K8S DEPLOY_K8S \
David Bainbridge27790d62019-08-13 22:43:19 +0000558 INSTALL_ONOS_APPS SKIP_RESTART_API INSTALL_KUBECTL INSTALL_HELM USE_GO VOLTHA_LOG_LEVEL \
David Bainbridgeac7f8072019-08-01 22:15:33 +0000559 VOLTHA_CHART VOLTHA_ADAPTER_SIM_CHART VOLTHA_ADAPTER_OPEN_OLT_CHART \
David Bainbridge27790d62019-08-13 22:43:19 +0000560 VOLTHA_ADAPTER_OPEN_ONU_CHART ONOS_TAG \
David Bainbridge0774b232019-08-02 06:37:19 +0000561 ONOS_API_PORT ONOS_SSH_PORT VOLTHA_API_PORT VOLTHA_SSH_PORT VOLTHA_ETCD_PORT"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000562for O in $ALL_OPTIONS; do
563 VAL=$(eval echo \$$O)
564 if [ $O == "USE_GO" ]; then
565 VAL="$(echo $VAL| test $(grep -c true) -eq 1 && echo yes || echo no)"
566 fi
567 if [ ! -z "$VAL" ]; then
568 printf " %-30s = %s\n" $O $VAL >> $LOG
569 fi
570done
571
David Bainbridged31d6122019-08-13 19:37:59 +0000572push_onos_config() {
573 local MSG=$1
574 local RESOURCE=$2
575 local DATA=$3
576
577 bspin - "$MSG $GEAR"
David Bainbridge2b19e832019-08-16 02:40:53 +0000578 while true; do
David Bainbridged31d6122019-08-13 19:37:59 +0000579 (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
580 if [ $? -eq 0 ]; then
581 break
582 fi
583 sleep .2
584 sspin -
585 done
586 espin - $VERIFIED
587}
David Bainbridgeac7f8072019-08-01 22:15:33 +0000588
David Bainbridge27790d62019-08-13 22:43:19 +0000589override_onos_app() {
590 local APP=$1
David Bainbridge2b19e832019-08-16 02:40:53 +0000591 local NAME=$(basename $APP | sed -e 's/^[0-9][0-9]*-//g' -e 's/-.*$//g')
592 while true; do
David Bainbridge27790d62019-08-13 22:43:19 +0000593 sspin -
594 # Attempt to delete old version (if it exists)
595 (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
596 sspin -
David Bainbridge2b19e832019-08-16 02:40:53 +0000597 if [ $? -ne 0 ]; then
598 continue
599 fi
David Bainbridge27790d62019-08-13 22:43:19 +0000600 (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
601 if [ $? -eq 0 ]; then
602 break
603 fi
604 sleep .2
605 done
606}
607
David Bainbridge2b19e832019-08-16 02:40:53 +0000608activate_onos_app() {
609 local MSG="$1"
610 local APP=$2
611
612 bspin - "$MSG $GO"
613 while true; do
614 sspin -
615 (set -x; curl --fail -sSL --user karaf:karaf -X POST http://127.0.0.1:$ONOS_API_PORT/onos/v1/applications/$APP/active >>$LOG 2>&1) >>$LOG 2>&1
616 if [ $? -eq 0 ]; then
617 break
618 fi
619 sleep .2
620 done
621 espin - "$VERIFIED"
622}
623
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700624count_pods() {
625 local NAMESPACE=$1; shift
626 local PODS=$(kubectl -n $NAMESPACE get pod -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}")
627 local COUNT=0
628 local PATTERNS=$*
629 for POD in $PODS; do
630 local NAME=$(echo $POD | cut -d/ -f 1)
631 local STATE=$(echo $POD | cut -d/ -f 2)
632 local CONTAINERS=$(echo $POD | cut -d/ -f 3 | sed -e 's/_/ /g')
633 if [ "$STATE" == "Running" ]; then
634 local TOTAL=$(echo $CONTAINERS | wc -w)
635 local FOUND=$(echo $CONTAINERS | grep -o true | wc -l)
636 if [ $TOTAL -eq $FOUND ]; then
637 for PATTERN in $PATTERNS; do
638 if [[ $NAME =~ $PATTERN ]]; then
639 COUNT=$(expr $COUNT + 1)
640 fi
641 done
642 fi
643 fi
644 done
645 echo $COUNT
646}
647
648wait_for_pods() {
649 local INDENT=
650 if [ "$1" == "-" ]; then
651 INDENT=$1; shift
652 fi
653 local NAMESPACE=$1; shift
654 local EXPECT=$1; shift
655 local RETRY=$1; shift
656 local MESSAGE=$1; shift
657 local PATTERNS=$*
658 local HAVE=$(count_pods $NAMESPACE $PATTERNS)
659 COUNT=$(expr 300 / 15)
660 bspin $INDENT $MESSAGE
661 sspin $INDENT
662 if [ $HAVE -ne $EXPECT ]; then
663 while [ $HAVE -ne $EXPECT ]; do
664 sspin $INDENT
665 COUNT=$(expr $COUNT - 1)
666 if [ $COUNT -eq 0 ]; then
667 HAVE=$(count_pods $NAMESPACE $PATTERNS)
668 COUNT=$(expr 300 / 15)
669 fi
670 sleep .15
671 done
672 fi
673 espin $INDENT $VERIFIED
674 if [ $HAVE -ne $EXPECT ]; then
675 return 1
676 fi
677 return 0
678}
679
680helm_install() {
681 local INDENT=
682 if [ "$1" == "-" ]; then
683 INDENT=$1; shift
684 fi
685 local NAMESPACE=$1; shift
David Bainbridge0774b232019-08-02 06:37:19 +0000686 local INAME=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700687 local CHART=$1; shift
688 local MESSAGE=$*
689
690 COUNT=$(expr 300 / 15)
691 bspin $INDENT $MESSAGE
David Bainbridge458bb662019-08-02 20:04:23 +0000692 (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 -0700693 SUCCESS=$?
694 while [ $SUCCESS -ne 0 ]; do
695 sspin $INDENT
696 COUNT=$(expr $COUNT - 1)
697 if [ $COUNT -eq 0 ]; then
David Bainbridge458bb662019-08-02 20:04:23 +0000698 (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 -0700699 COUNT=$(expr 300 / 15)
700 fi
701 sleep .15
702 done
703 espin $INDENT $VERIFIED
704}
705
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700706echo "INSTALL TYPE: $TYPE" >> $LOG
707
708bspin "Verify GOPATH"
709export GOPATH=$(pwd)
Test User3d7ad8e2019-07-03 06:15:44 +0000710mkdir -p $GOPATH/bin
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700711espin $VERIFIED
712
David Bainbridgee87067b2019-08-12 22:00:12 +0000713STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700714if [ "$INSTALL_KUBECTL" == "no" ]; then
715 bspin "Skip kubectl install"
716 espin $NO_ENTRY
Test Userc13bdc92019-07-03 20:57:49 +0000717else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700718 bspin "Verify kubectl $HELM"
719 if [ -x $GOPATH/bin/kubectl ]; then
720 espin $VERIFIED
721 else
722 espin $NOT_VERIFIED
723 bspin - "Download and install Kubernetes/kubectl $DOWNLOAD"
724 (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
725 (set -x; chmod 755 $GOPATH/bin/kubectl >>$LOG 2>&1) >>$LOG 2>&1
726 espin - $VERIFIED
727 fi
Test Userc13bdc92019-07-03 20:57:49 +0000728fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000729if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000730 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000731fi
Test Userc13bdc92019-07-03 20:57:49 +0000732
David Bainbridgee87067b2019-08-12 22:00:12 +0000733STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700734if [ "$DEPLOY_K8S" == "no" ]; then
735 bspin "Skip Kubernetes/Kind Deployment"
736 espin $NO_ENTRY
737else
Test Userba1e7e72019-07-10 22:27:54 +0000738 bspin "Verify Kubernetes/Kind $HELM"
739 if [ -x $GOPATH/bin/kind ]; then
740 espin $VERIFIED
741 else
742 espin $NOT_VERIFIED
743 bspin - "Download and install Kubernetes/kind $DOWNLOAD"
David Bainbridge9e2a6662019-07-11 17:07:57 +0000744 (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 +0000745 (set -x; chmod 755 $GOPATH/bin/kind >>$LOG 2>&1) >>$LOG 2>&1
746 espin - $VERIFIED
747 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700748fi
749
David Bainbridgee87067b2019-08-12 22:00:12 +0000750if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000751 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000752fi
753
754STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700755if [ "$INSTALL_HELM" == "no" ]; then
756 bspin "Skip Helm Install"
757 espin $NO_ENTRY
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700758else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700759 bspin "Verify Helm $HELM"
760 if [ -x $GOPATH/bin/helm ]; then
761 espin $VERIFIED
762 else
763 espin $NOT_VERIFIED
764 bspin - "Download and install Helm $DOWNLOAD"
765 (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
766 espin - $VERIFIED
767 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700768fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000769if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000770 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000771fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700772
David Bainbridgee87067b2019-08-12 22:00:12 +0000773STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +0000774bspin "Verify voltctl $HIGH_VOLTAGE"
Test User3d7ad8e2019-07-03 06:15:44 +0000775if [ -x $GOPATH/bin/voltctl ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700776 espin $VERIFIED
777else
778 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000779 bspin - "Download and build voltctl $DOWNLOAD"
Test Userba1e7e72019-07-10 22:27:54 +0000780 (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 +0000781 (set -x; chmod 755 $GOPATH/bin/voltctl >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700782 espin - $VERIFIED
783fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000784if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000785 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000786fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700787
788bspin "Verify command PATH"
Test Userba1e7e72019-07-10 22:27:54 +0000789export PATH=$GOPATH/bin:$PATH
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700790espin $VERIFIED
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700791
David Bainbridgee87067b2019-08-12 22:00:12 +0000792STIME=$(date +%s)
Test Userba1e7e72019-07-10 22:27:54 +0000793if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000794 HAVE=$(kind get clusters | grep -c voltha-$NAME)
Test Userba1e7e72019-07-10 22:27:54 +0000795 bspin "Verify Kubernetes/Kind Cluster"
796 sspin
797 if [ $HAVE -eq 0 ]; then
David Bainbridge491b1bd2019-07-11 17:53:11 +0000798 espin $NOT_VERIFIED
799 bspin - "Verify cluster configuration"
David Bainbridge0774b232019-08-02 06:37:19 +0000800 if [ ! -r ./$NAME-cluster.cfg ]; then
David Bainbridge491b1bd2019-07-11 17:53:11 +0000801 espin - $NOT_VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +0000802 bspin - "Download cluster configuration: $TYPE-cluster.cfg to $NAME-cluster.cfg $DOWNLOAD"
803 (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 -0700804 espin - $VERIFIED
805 else
806 espin - $VERIFIED
807 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000808 kind create cluster --name voltha-$NAME --config $NAME-cluster.cfg
David Bainbridge491b1bd2019-07-11 17:53:11 +0000809 else
810 espin $VERIFIED
Test Userba1e7e72019-07-10 22:27:54 +0000811 fi
812
David Bainbridge0774b232019-08-02 06:37:19 +0000813 export KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$NAME")"
Test Userba1e7e72019-07-10 22:27:54 +0000814 P="coredns-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000815 etcd-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +0000816 kindnet-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000817 kube-apiserver-voltha-$NAME-control-plane \
818 kube-controller-manager-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +0000819 kube-proxy-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000820 kube-scheduler-voltha-$NAME-control-plane"
Test Userba1e7e72019-07-10 22:27:54 +0000821
822 EXPECT=$(test "$TYPE" == "minimal" && echo "12" || echo "14")
823 wait_for_pods - "kube-system" $EXPECT -1 "Waiting for system PODs to start" $P
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700824fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000825if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000826 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000827fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700828
David Bainbridgee87067b2019-08-12 22:00:12 +0000829STIME=$(date +%s)
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700830COUNT=$(count_pods "kube-system" "tiller-deploy-.*")
831bspin "Verify Helm"
Test Userba1e7e72019-07-10 22:27:54 +0000832if [ $COUNT -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700833 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000834 echo -e "Configuring Helm $GEAR"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700835 if [ "$INSTALL_HELM" == "no" ]; then
836 bspin - "Skip Helm/Tiller Initialization"
837 espin - $NO_ENTRY
838 else
839 bspin - "Initialize Helm"
840 (set -x; helm init --upgrade >>$LOG 2>&1) >>$LOG 2>&1
841 espin - $VERIFIED
842 wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
843 fi
Test Userb5712372019-07-03 21:52:17 +0000844 bspin - "Add Google Incubator repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700845 (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
846 espin - $VERIFIED
Test Userba1e7e72019-07-10 22:27:54 +0000847
848 # HACK (sort-of) - the config for tiller is about to be patched, which will
849 # cause the tiller pod to be recreated. This can sometimes cause a timing
850 # issue with the "wait_for_pods" call on tiller as it may incorrectly
851 # identify the running/ready tiller pod that is soon to be terminated as
852 # what it is waiting for. To avoid this issue we do a clean scale down and
853 # scale up of the pod so the script controlls when it should be expecting
854 # things
855 (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 -0700856
Test Userb5712372019-07-03 21:52:17 +0000857 bspin - "Add Google Stable repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700858 (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
859 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000860 bspin - "Add ONF repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700861 (set -x; helm repo add onf https://charts.opencord.org >>$LOG 2>&1) >>$LOG 2>&1
862 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000863 bspin - "Update Helm repository cache"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700864 (set -x; helm repo update >>$LOG 2>&1) >>$LOG 2>&1
865 espin - $VERIFIED
866
867 # Create and k8s service account so that Helm can create pods
Test Userb5712372019-07-03 21:52:17 +0000868 bspin - "Create Tiller ServiceAccount"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700869 (set -x; kubectl create serviceaccount --namespace kube-system tiller >>$LOG 2>&1) >>$LOG 2>&1
870 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000871 bspin - "Create Tiller ClusterRoleBinding"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700872 (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>$LOG 2>&1) >>$LOG 2>&1
873 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000874 bspin - "Update Tiller Manifest"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700875 (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 +0000876
877 # HACK (sort-of) - part to, spin it back up
878 (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 -0700879 espin - $VERIFIED
880else
881 espin $VERIFIED
882fi
Test Userb5712372019-07-03 21:52:17 +0000883wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +0000884if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000885 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000886fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700887
David Bainbridgee87067b2019-08-12 22:00:12 +0000888STIME=$(date +%s)
David Bainbridge0774b232019-08-02 06:37:19 +0000889bspin "Verify Helm values file: $NAME-values.yaml"
890if [ ! -r "./$NAME-values.yaml" ]; then
Test Userba1e7e72019-07-10 22:27:54 +0000891 espin $NOT_VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +0000892 bspin - "Download Helm values file: $TYPE-values.yaml to $NAME-values.yaml $DOWNLOAD"
893 (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 +0000894 espin - $VERIFIED
895else
896 espin $VERIFIED
897fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000898if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000899 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000900fi
Test Userba1e7e72019-07-10 22:27:54 +0000901
902if [ "$JUST_K8S" == "yes" ]; then
903 echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye."
904 echo ""
905 echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
906 echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
907 echo "tools required by VOLTHA in your command path. " | tee -a $LOG
908 echo "" | tee -a $LOG
909 echo -en $BOLD
910 if [ $DEPLOY_K8S == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000911 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +0000912 fi
913 echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
914 echo -en $NORMAL
915 echo "" | tee -a $LOG
916 echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
917 exit 0
918fi
919
David Bainbridgee87067b2019-08-12 22:00:12 +0000920STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +0000921bspin "Verify ETCD Operator $OLD_KEY"
Test User7d866122019-07-09 17:52:35 +0000922if [ $(helm list --deployed --short --namespace voltha "^etcd-operator\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700923 espin $NOT_VERIFIED
924 helm_install - voltha etcd-operator stable/etcd-operator "Install ETCD Operator"
925else
926 espin $VERIFIED
927fi
Test User01ed0642019-07-03 20:17:06 +0000928EXPECT=$(test "$TYPE" == "minimal" && echo "1" || echo "3")
Test Userb5712372019-07-03 21:52:17 +0000929wait_for_pods - "voltha" $EXPECT -1 "Waiting for ETCD Operator to start" "etcd-operator-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +0000930if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000931 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000932fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700933
David Bainbridgee87067b2019-08-12 22:00:12 +0000934STIME=$(date +%s)
David Bainbridgeb270c202019-07-26 01:44:42 +0000935if [ $WITH_ONOS == "yes" ]; then
936 bspin "Verify ONOS installed $BIRD"
937 if [ $(helm list --deployed --short --namespace default "^onos\$" | wc -l) -ne 1 ]; then
938 espin $NOT_VERIFIED
David Bainbridge27790d62019-08-13 22:43:19 +0000939 SET_TAG=
940 if [ "$ONOS_TAG X" != " X" ]; then
941 SET_TAG="--set images.onos.tag=$ONOS_TAG"
942 fi
943 EXTRA_HELM_FLAGS="$SET_TAG $EXTRA_HELM_FLAGS" helm_install - default onos onf/onos "Install ONOS"
David Bainbridgeb270c202019-07-26 01:44:42 +0000944 else
945 espin $VERIFIED
946 fi
947 wait_for_pods - "default" 1 -1 "Waiting for ONOS to start" "onos-.*"
948
949 bspin - "Forward ONOS API port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +0000950 for i in $(screen -ls | grep onos-ui-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +0000951 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
952 done
David Bainbridge0774b232019-08-02 06:37:19 +0000953 (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 +0000954 espin - $VERIFIED
955 bspin - "Forward ONOS SSH port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +0000956 for i in $(screen -ls | grep onos-ssh-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +0000957 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
958 done
David Bainbridge2b19e832019-08-16 02:40:53 +0000959
960
David Bainbridge0774b232019-08-02 06:37:19 +0000961 (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 +0000962 espin - $VERIFIED
David Bainbridged31d6122019-08-13 19:37:59 +0000963 bspin - "Verify or download ONOS configuration support files $DOWNLOAD"
David Bainbridge2b19e832019-08-16 02:40:53 +0000964 ONOS_FILES="olt-onos-enableExtraneousRules.json olt-onos-olt-settings.json onos-aaa.json \
965 onos-dhcpl2relay.json onos-kafka.json onos-sadis-no-tp.json onos-sadis-tp.json"
David Bainbridged31d6122019-08-13 19:37:59 +0000966 (set -x; mkdir -p ./onos-files >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridge2b19e832019-08-16 02:40:53 +0000967 for i in $ONOS_FILES; do
David Bainbridged31d6122019-08-13 19:37:59 +0000968 if [ ! -r ./onos-files/$i ]; then
969 (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
970 fi
971 done
Test Userba1e7e72019-07-10 22:27:54 +0000972 espin - $VERIFIED
David Bainbridge27790d62019-08-13 22:43:19 +0000973
974 if [ $INSTALL_ONOS_APPS == "yes" ]; then
975 bspin - "Installing custom ONOS applications"
976 if [ -x onos-files/onos-apps -a $(ls -1 onos-files/onos-apps/*.oar 2>/dev/null | wc -l) -gt 0 ]; then
977 for OAR in $(ls -1 onos-files/onos-apps/*.oar); do
978 sspin - "Installing custom ONOS applications - $OAR$CEOL"
David Bainbridge2b19e832019-08-16 02:40:53 +0000979 override_onos_app $OAR
David Bainbridge27790d62019-08-13 22:43:19 +0000980 done
981 espin - "$VERIFIED Installing custom ONOS applications$CEOL"
982 else
983 espin - "$NOT_VERIFIED Installing custom ONOS applications - None Found"
984 fi
985 fi
David Bainbridge2b19e832019-08-16 02:40:53 +0000986
987 push_onos_config "Push ONOS Kafka Configuration" "network/configuration/apps/org.opencord.kafka" "onos-files/onos-kafka.json"
988 push_onos_config "Push ONOS DHCP L2 Relay Configuration" "network/configuration/apps/org.opencord.dhcpl2relay" "onos-files/onos-dhcpl2relay.json"
David Bainbridged31d6122019-08-13 19:37:59 +0000989 push_onos_config "Enable VOLTHA ONOS DHCP provisioning" "configuration/org.opencord.olt.impl.Olt" "onos-files/olt-onos-olt-settings.json"
990 push_onos_config "Enabling extraneous rules for ONOS" "configuration/org.onosproject.net.flow.impl.FlowRuleManager" "onos-files/olt-onos-enableExtraneousRules.json"
David Bainbridge2b19e832019-08-16 02:40:53 +0000991 if [ -f onos-files/onos-sadis.json ]; then
992 push_onos_config "[optional] Push ONOS SADIS Configuration" "network/configuration/apps/org.opencord.sadis" "onos-files/onos-sadis.json"
993 elif [ "$CONFIG_SADIS" == "yes" ]; then
994 SADIS_CFG=onos-files/onos-sadis-no-tp.json
995 if [ "$WITH_TP" == "yes" ]; then
996 SADIS_CFG=onos-files/onos-sadis-tp.json
997 fi
998 push_onos_config "[optional] Push ONOS SADIS Configuration" "network/configuration/apps/org.opencord.sadis" "$SADIS_CFG"
999 fi
Test Userba1e7e72019-07-10 22:27:54 +00001000fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001001if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001002 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001003fi
Test Userba1e7e72019-07-10 22:27:54 +00001004
David Bainbridgee87067b2019-08-12 22:00:12 +00001005STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +00001006bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
Test User7d866122019-07-09 17:52:35 +00001007if [ $(helm list --deployed --short --namespace voltha "^voltha\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001008 espin $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +00001009 helm_install - voltha voltha $VOLTHA_CHART "Install VOLTHA Core"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001010else
1011 espin $VERIFIED
1012fi
Test Userba1e7e72019-07-10 22:27:54 +00001013
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001014VOLTHA="ofagent-.* \
1015 ro-core.* \
1016 rw-core.* \
1017 voltha-api-server-.* \
1018 voltha-cli-server-.* \
1019 voltha-etcd-cluster-.* \
1020 voltha-kafka-.* \
1021 voltha-zookeeper-.*"
Test User01ed0642019-07-03 20:17:06 +00001022EXPECT=$(test "$TYPE" == "minimal" && echo "9" || echo "11")
Test Userb5712372019-07-03 21:52:17 +00001023wait_for_pods - "voltha" $EXPECT -1 "Waiting for VOLTHA Core to start" $VOLTHA
David Bainbridgee87067b2019-08-12 22:00:12 +00001024if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001025 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001026fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001027
David Bainbridgee87067b2019-08-12 22:00:12 +00001028STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +00001029echo -e "Verify Adapters $PLUG"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001030bspin - "Verify Simulated Adapters installed"
Test User7d866122019-07-09 17:52:35 +00001031if [ $(helm list --deployed --short --namespace voltha "^sim\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001032 espin - $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +00001033 helm_install - voltha sim $VOLTHA_ADAPTER_SIM_CHART "Install Simulated Adapters"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001034else
1035 espin - $VERIFIED
1036fi
1037
1038bspin - "Verify OpenOLT Adapter installed"
Test User7d866122019-07-09 17:52:35 +00001039if [ $(helm list --deployed --short --namespace voltha "^open-olt\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001040 espin - $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +00001041 helm_install - voltha open-olt $VOLTHA_ADAPTER_OPEN_OLT_CHART "Install OpenOLT Adapter"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001042else
1043 espin - $VERIFIED
1044fi
1045bspin - "Verify OpenONU Adapter installed"
Test User7d866122019-07-09 17:52:35 +00001046if [ $(helm list --deployed --short --namespace voltha "^open-onu\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001047 espin - $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +00001048 helm_install - voltha open-onu $VOLTHA_ADAPTER_OPEN_ONU_CHART "Install OpenONU Adapter"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001049else
1050 espin - $VERIFIED
1051fi
1052
1053ADAPTERS="adapter-.*"
Test Userb5712372019-07-03 21:52:17 +00001054wait_for_pods - "voltha" 4 -1 "Waiting for adapters to start" $ADAPTERS
David Bainbridgee87067b2019-08-12 22:00:12 +00001055if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001056 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001057fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001058
Test User7d866122019-07-09 17:52:35 +00001059if [ $WITH_BBSIM == "yes" ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +00001060 STIME=$(date +%s)
Test User7d866122019-07-09 17:52:35 +00001061 echo -e "Verify BBSIM $PLUG"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001062 bspin - "Verify BBSIM Installed"
Test User7d866122019-07-09 17:52:35 +00001063 if [ $(helm list --deployed --short --namespace voltha "^bbsim\$" | wc -l) -ne 1 ]; then
1064 espin - $NOT_VERIFIED
1065 helm_install - voltha bbsim onf/bbsim "Install BBSIM"
1066 else
1067 espin - $VERIFIED
1068 fi
1069 wait_for_pods - "voltha" 1 -1 "Waiting for BBSIM to start" "bbsim-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001070 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001071 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001072 fi
Test User7d866122019-07-09 17:52:35 +00001073fi
1074
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001075if [ $WITH_RADIUS == "yes" ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +00001076 STIME=$(date +%s)
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001077 echo -e "Verify RADIUS $LOCK"
1078 bspin - "Verify RADIUS Installed"
1079 if [ $(helm list --deployed --short --namespace voltha "^radius\$" | wc -l) -ne 1 ]; then
1080 espin - $NOT_VERIFIED
1081 helm_install - voltha radius onf/freeradius "Install RADIUS"
1082 else
1083 espin - $VERIFIED
1084 fi
1085 wait_for_pods - "voltha" 1 -1 "Waiting for RADIUS to start" "radius-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001086 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001087 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001088 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001089fi
1090
David Bainbridgee87067b2019-08-12 22:00:12 +00001091STIME=$(date +%s)
David Bainbridgee10f6d52019-07-25 00:28:13 +00001092if [ $SKIP_RESTART_API == "no" ]; then
1093 echo -e "Restart VOLTHA API $RESTART"
1094 API="voltha-api-server-.* ofagent-.*"
1095 (set -x; kubectl scale --replicas=0 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1
1096 wait_for_pods - "voltha" 0 -1 "Wait for API to stop $STOP" $API
1097 (set -x; kubectl scale --replicas=1 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1
1098 wait_for_pods - "voltha" 2 -1 "Wait for API to re-start $GO" $API
1099else
1100 bspin "Skip VOLTHA API Restart"
1101 espin $NO_ENTRY
1102fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001103
Test Userb5712372019-07-03 21:52:17 +00001104bspin - "Forward VOLTHA API port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +00001105for i in $(screen -ls | grep voltha-api-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +00001106 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
1107done
David Bainbridge0774b232019-08-02 06:37:19 +00001108(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 -07001109espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +00001110bspin - "Forward VOLTHA SSH port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +00001111for i in $(screen -ls | grep voltha-ssh-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +00001112 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
1113done
David Bainbridge0774b232019-08-02 06:37:19 +00001114(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 -07001115espin - $VERIFIED
David Bainbridgeac7f8072019-08-01 22:15:33 +00001116bspin - "Forward VOLTHA ETCD port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +00001117for i in $(screen -ls | grep voltha-etcd-$NAME | awk '{print $1}'); do
David Bainbridgeac7f8072019-08-01 22:15:33 +00001118 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
1119done
David Bainbridge0774b232019-08-02 06:37:19 +00001120(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 +00001121espin - $VERIFIED
David Bainbridgee87067b2019-08-12 22:00:12 +00001122if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001123 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001124fi
Test User3d7ad8e2019-07-03 06:15:44 +00001125
David Bainbridgeb270c202019-07-26 01:44:42 +00001126if [ $WITH_ONOS == "yes" -a $WITH_RADIUS == "yes" ]; then
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001127 bspin "Configure ONOS RADIUS Connection $GEAR"
David Bainbridge2b19e832019-08-16 02:40:53 +00001128 (set -x; cat onos-files/onos-aaa.json | sed -e "s/:RADIUS_IP:/$(kubectl -n voltha get service/radius -o jsonpath={.spec.clusterIP})/g" | curl -XPOST -sSL http://karaf:karaf@localhost:8181/onos/v1/network/configuration/apps/org.opencord.aaa -H Content-type:application/json -d@- >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001129 espin $VERIFIED
1130fi
1131
1132bspin "Create voltctl configuration file"
Test User3d7ad8e2019-07-03 06:15:44 +00001133(set -x; mkdir -p $HOME/.volt >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridge0774b232019-08-02 06:37:19 +00001134(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 +00001135espin $VERIFIED
Test User08ebbd92019-07-03 17:15:39 +00001136
David Bainbridge0774b232019-08-02 06:37:19 +00001137if [ ! -f "$NAME-env.sh" ]; then
1138 touch $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001139fi
1140
David Bainbridge596f30d2019-07-30 17:07:59 +00001141for O in $ALL_OPTIONS; do
1142 VAL=$(eval echo \$$O)
1143 if [ $O == "USE_GO" ]; then
1144 VAL="$(echo $VAL| test $(grep -c true) -eq 1 && echo yes || echo no)"
1145 fi
David Bainbridge0774b232019-08-02 06:37:19 +00001146 if [ ! -z "$VAL" -a $(grep -c "^export $O=" $NAME-env.sh) -eq 0 ]; then
1147 echo "export $O=\"$(eval echo \$$O)\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001148 fi
1149done
1150
David Bainbridge0774b232019-08-02 06:37:19 +00001151if [ $DEPLOY_K8S == "yes" -a $(grep -c "^export KUBECONFIG=" $NAME-env.sh) -eq 0 ]; then
1152 echo "export KUBECONFIG=\"$(./bin/kind get kubeconfig-path --name=voltha-$NAME)\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001153fi
1154
David Bainbridge0774b232019-08-02 06:37:19 +00001155if [ $(grep -c "^export VOLTCONFIG=" $NAME-env.sh) -eq 0 ]; then
1156 echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001157fi
1158
David Bainbridge0774b232019-08-02 06:37:19 +00001159if [ $(grep -c "^export PATH=" $NAME-env.sh) -eq 0 ]; then
1160 echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001161fi
1162
Test User7d866122019-07-09 17:52:35 +00001163echo ""
Test User08ebbd92019-07-03 17:15:39 +00001164echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
1165echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
1166echo "tools required by VOLTHA in your command path. " | tee -a $LOG
1167echo "" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +00001168echo -en $BOLD
Test Userba1e7e72019-07-10 22:27:54 +00001169if [ $DEPLOY_K8S == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001170 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +00001171fi
David Bainbridge0774b232019-08-02 06:37:19 +00001172echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +00001173echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +00001174echo -en $NORMAL
Test User08ebbd92019-07-03 17:15:39 +00001175echo "" | tee -a $LOG
1176echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
1177
David Bainbridge712afb82019-08-14 19:55:58 +00001178if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridgef858a022019-08-14 21:25:11 +00001179 echo -e "$CLOCK ${BOLD}TOTAL: $(duration $(expr $(date +%s) - $TOTAL_START_TIME))${NORMAL}"
David Bainbridge712afb82019-08-14 19:55:58 +00001180fi
1181