blob: c316a2c3a9c825c7197922296e8b2d62760fca8d [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 Bainbridge27790d62019-08-13 22:43:19 +000074INSTALL_ONOS_APPS=${INSTALL_ONOS_APPS:-no}
David Bainbridge01294952019-07-30 19:33:45 +000075WITH_TP=${WITH_TP:-yes}
Test Userba1e7e72019-07-10 22:27:54 +000076JUST_K8S=${JUST_K8S:-no}
77DEPLOY_K8S=${DEPLOY_K8S:-yes}
David Bainbridgee10f6d52019-07-25 00:28:13 +000078SKIP_RESTART_API=${SKIP_RESTART_API:-no}
David K. Bainbridge0e89cb92019-07-17 11:30:10 -070079INSTALL_KUBECTL=${INSTALL_KUBECTL:-yes}
80INSTALL_HELM=${INSTALL_HELM:-yes}
David Bainbridge5b7b96b2019-07-25 20:29:13 +000081USE_GO=${USE_GO:-yes}
82VOLTHA_LOG_LEVEL=${VOLTHA_LOG_LEVEL:-WARN}
David Bainbridgee10f6d52019-07-25 00:28:13 +000083VOLTHA_CHART=${VOLTHA_CHART:=onf/voltha}
84VOLTHA_ADAPTER_SIM_CHART=${VOLTHA_ADAPTER_SIM_CHART:-onf/voltha-adapter-simulated}
85VOLTHA_ADAPTER_OPEN_OLT_CHART=${VOLTHA_ADAPTER_OPEN_OLT_CHART:-onf/voltha-adapter-openolt}
86VOLTHA_ADAPTER_OPEN_ONU_CHART=${VOLTHA_ADAPTER_OPEN_ONU_CHART:-onf/voltha-adapter-openonu}
Test Userba1e7e72019-07-10 22:27:54 +000087
88HAVE_GO=$(which go >/dev/null 2>&1 && echo "yes" || echo "no")
89HOSTOS=$(uname -s | tr "[:upper:]" "[:lower:"])
90HOSTARCH=$(uname -m | tr "[:upper:]" "[:lower:"])
91if [ $HOSTARCH == "x86_64" ]; then
92 HOSTARCH="amd64"
93fi
Test User7d866122019-07-09 17:52:35 +000094
95# Verify TYPE setting
96if [ $(echo ":minimal:full:" | grep -ic ":$TYPE:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -070097 >&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 +000098 exit 1
99fi
100
101# Verify WITH_BBSIM settting and convert uniform value of yes or no
102if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_BBSIM:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700103 >&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 +0000104 exit 1
105fi
106if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_BBSIM:") -eq 1 ]; then
107 WITH_BBSIM=yes
108else
109 WITH_BBSIM=no
110fi
111
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000112# Verify WITH_RADIUS settting and convert uniform value of yes or no
113if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_RADIUS:") -eq 0 ]; then
114 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_RADIUS value of '$WITH_RADIUS'. Should be 'yes' or 'no'${NORMAL}"
115 exit 1
116fi
117if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_RADIUS:") -eq 1 ]; then
118 WITH_RADIUS=yes
119else
120 WITH_RADIUS=no
121fi
122
David Bainbridge01294952019-07-30 19:33:45 +0000123# Verify WITH_TP settting and convert uniform value of yes or no
124if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_TP:") -eq 0 ]; then
125 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_TP value of '$WITH_TP'. Should be 'yes' or 'no'${NORMAL}"
126 exit 1
127fi
128if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_TP:") -eq 1 ]; then
129 WITH_TP=yes
130else
131 WITH_TP=no
132fi
133
David Bainbridgeb270c202019-07-26 01:44:42 +0000134# Verify WITH_ONOS settting and convert uniform value of yes or no
135if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_ONOS:") -eq 0 ]; then
136 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_ONOS value of '$WITH_ONOS'. Should be 'yes' or 'no'${NORMAL}"
137 exit 1
138fi
139if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_ONOS:") -eq 1 ]; then
140 WITH_ONOS=yes
141else
142 WITH_ONOS=no
143fi
144
Test Userba1e7e72019-07-10 22:27:54 +0000145# Verify JUST_K8S settting and convert uniform value of yes or no
146if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$JUST_K8S:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700147 >&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 +0000148 exit 1
149fi
150if [ $(echo ":y:yes:true:1:" | grep -ic ":$JUST_K8S:") -eq 1 ]; then
151 JUST_K8S=yes
152else
153 JUST_K8S=no
154fi
155
156# Verify DEPLOY_K8S settting and convert uniform value of yes or no
157if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$DEPLOY_K8S:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700158 >&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 +0000159 exit 1
160fi
161if [ $(echo ":y:yes:true:1:" | grep -ic ":$DEPLOY_K8S:") -eq 1 ]; then
162 DEPLOY_K8S=yes
163else
164 DEPLOY_K8S=no
165fi
Test User01ed0642019-07-03 20:17:06 +0000166
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700167# Verify INSTALL_KUBECTL settting and convert uniform value of yes or no
168if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$INSTALL_KUBECTL:") -eq 0 ]; then
169 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$INSTALL_KUBECTL value of '$INSTALL_KUBECTL'. Should be 'yes' or 'no'${NORMAL}"
170 exit 1
171fi
172
173if [ $(echo ":y:yes:true:1:" | grep -ic ":$INSTALL_KUBECTL:") -eq 1 ]; then
174 INSTALL_KUBECTL=yes
175else
176 INSTALL_KUBECTL=no
177fi
178
David Bainbridgee10f6d52019-07-25 00:28:13 +0000179# Verify SKIP_RESTART_API settting and convert uniform value of yes or no
180if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$SKIP_RESTART_API:") -eq 0 ]; then
181 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$SKIP_RESTART_API value of '$SKIP_RESTART_API'. Should be 'yes' or 'no'${NORMAL}"
182 exit 1
183fi
184if [ $(echo ":y:yes:true:1:" | grep -ic ":$SKIP_RESTART_API:") -eq 1 ]; then
185 SKIP_RESTART_API=yes
186else
187 SKIP_RESTART_API=no
188fi
189
David Bainbridge1ceabc12019-07-25 17:21:05 +0000190# Verify USE_GO settting and convert uniform value of yes or no
191if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$USE_GO:") -eq 0 ]; then
192 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$USE_GO value of '$USE_GO'. Should be 'yes' or 'no'${NORMAL}"
193 exit 1
194fi
195if [ $(echo ":y:yes:true:1:" | grep -ic ":$USE_GO:") -eq 1 ]; then
196 USE_GO=true
197else
198 USE_GO=false
199fi
200
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700201# Verify INSTALL_HELM settting and convert uniform value of yes or no
202if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$INSTALL_HELM:") -eq 0 ]; then
203 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$INSTALL_HELM value of '$INSTALL_HELM'. Should be 'yes' or 'no'${NORMAL}"
204 exit 1
205fi
206
207if [ $(echo ":y:yes:true:1:" | grep -ic ":$INSTALL_HELM:") -eq 1 ]; then
208 INSTALL_HELM=yes
209else
210 INSTALL_HELM=no
211fi
212
David Bainbridgee87067b2019-08-12 22:00:12 +0000213# Verify WITH_TIMINGS settting and convert uniform value of yes or no
214if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_TIMINGS:") -eq 0 ]; then
215 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_TIMINGS value of '$WITH_TIMINGS'. Should be 'yes' or 'no'${NORMAL}"
216 exit 1
217fi
218
219if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_TIMINGS:") -eq 1 ]; then
220 WITH_TIMINGS=yes
221else
222 WITH_TIMINGS=no
223fi
224
David Bainbridge27790d62019-08-13 22:43:19 +0000225# Verify INSTALL_ONOS_APPS settting and convert uniform value of yes or no
226if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$INSTALL_ONOS_APPS:") -eq 0 ]; then
227 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$INSTALL_ONOS_APPS value of '$INSTALL_ONOS_APPS'. Should be 'yes' or 'no'${NORMAL}"
228 exit 1
229fi
230
231if [ $(echo ":y:yes:true:1:" | grep -ic ":$INSTALL_ONOS_APPS:") -eq 1 ]; then
232 INSTALL_ONOS_APPS=yes
233else
234 INSTALL_ONOS_APPS=no
235fi
236
David Bainbridge0774b232019-08-02 06:37:19 +0000237mkdir -p .voltha
238touch .voltha/ports
239HAVE=$(grep $NAME .voltha/ports)
240if [ "$HAVE X" == " X" ]; then
241 # Find free port prefix
242 START=81
243 while true; do
244 if [ $(grep -c $START .voltha/ports) -eq 0 ]; then
245 break
246 fi
247 START=$(expr $START + 1)
248 done
249 DELTA=$(expr $START - 81)
250 ONOS_API_PORT=${START}81
251 ONOS_SSH_PORT=${START}01
252 VOLTHA_API_PORT=5$(expr 55 + $DELTA)55
253 VOLTHA_SSH_PORT=$(expr 50 + $DELTA)22
254 VOLTHA_ETCD_PORT=$(expr 23 + $DELTA)79
Test User01ed0642019-07-03 20:17:06 +0000255else
David Bainbridge0774b232019-08-02 06:37:19 +0000256 VALUES=$(echo $HAVE | sed -e 's/\s//g' | cut -d= -f2)
257 ONOS_API_PORT=$(echo $VALUES | cut -d, -f1)
258 ONOS_SSH_PORT=$(echo $VALUES | cut -d, -f2)
259 VOLTHA_API_PORT=$(echo $VALUES | cut -d, -f3)
260 VOLTHA_SSH_PORT=$(echo $VALUES | cut -d, -f4)
261 VOLTHA_ETCD_PORT=$(echo $VALUES | cut -d, -f5)
Test User01ed0642019-07-03 20:17:06 +0000262fi
263
David Bainbridge0774b232019-08-02 06:37:19 +0000264PORTTMP=$(mktemp -u)
265cat .voltha/ports | grep -v $NAME > $PORTTMP
266echo "$NAME=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT" >> $PORTTMP
267cp $PORTTMP .voltha/ports
268rm -f $PORTTMP
269
David Bainbridge27790d62019-08-13 22:43:19 +0000270ONOS_TAG=${ONOS_TAG:-}
271if [ "$WITH_TP" == "yes" -a "$ONOS_TAG X" == " X" ]; then
272 ONOS_TAG="voltha-1.7"
David Bainbridge01294952019-07-30 19:33:45 +0000273fi
David Bainbridge27790d62019-08-13 22:43:19 +0000274export ONOS_API_PORT ONOS_SSH_PORT
David Bainbridge01294952019-07-30 19:33:45 +0000275
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700276spin() {
Test Userd87942b2019-07-03 07:20:24 +0000277 PARTS="\
278 \xe2\xa2\x8e\xe2\xa1\xb0 \
279 \xe2\xa2\x8e\xe2\xa1\xa1 \
280 \xe2\xa2\x8e\xe2\xa1\x91 \
281 \xe2\xa2\x8e\xe2\xa0\xb1 \
282 \xe2\xa0\x8e\xe2\xa1\xb1 \
283 \xe2\xa2\x8a\xe2\xa1\xb1 \
284 \xe2\xa2\x8c\xe2\xa1\xb1 \
285 \xe2\xa2\x86\xe2\xa1\xb1 \
286 "
287 IDX=1
David Bainbridge38dc1e82019-08-12 15:18:45 +0000288 echo -en $CIVIS
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700289 while true; do
Test Userd87942b2019-07-03 07:20:24 +0000290 C=$(echo $PARTS | cut '-d ' -f $IDX)
291 echo -en "$C"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700292 IDX=$(expr $IDX + 1)
Test Userd87942b2019-07-03 07:20:24 +0000293 if [ $IDX -gt 8 ]; then
294 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700295 fi
296 sleep .15
297 echo -en "\r"
298 done
299}
300
Test Userd87942b2019-07-03 07:20:24 +0000301IDX=1
David Bainbridgee87067b2019-08-12 22:00:12 +0000302CLOCK="TIME:"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000303SPIN_PARTS=
304NOT_VERIFIED=
305VERIFIED=
306HELM=
307OLD_KEY=
308BIRD=
309HIGH_VOLTAGE=
310PLUG=
311RESTART=
312FORWARD=
313INSTALL=
314STOP=
315GO=
316DOWNLOAD=
317GEAR=
318NO_ENTRY=
319LOCK=
320
321if [ $FANCY -eq 1 ]; then
322 SPIN_PARTS="\
323 \xe2\xa2\x8e\xe2\xa1\xb0 \
324 \xe2\xa2\x8e\xe2\xa1\xa1 \
325 \xe2\xa2\x8e\xe2\xa1\x91 \
326 \xe2\xa2\x8e\xe2\xa0\xb1 \
327 \xe2\xa0\x8e\xe2\xa1\xb1 \
328 \xe2\xa2\x8a\xe2\xa1\xb1 \
329 \xe2\xa2\x8c\xe2\xa1\xb1 \
330 \xe2\xa2\x86\xe2\xa1\xb1 \
331 "
David Bainbridgee87067b2019-08-12 22:00:12 +0000332 CLOCK="\xe2\x8f\xb1"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000333 NOT_VERIFIED="\xe2\x9c\x97\x20"
334 VERIFIED="\xe2\x9c\x93\x20"
335 HELM="\xE2\x8E\x88"
336 OLD_KEY="\xF0\x9F\x97\x9D"
337 BIRD="\xF0\x9F\x90\xA6"
338 HIGH_VOLTAGE="\xE2\x9A\xA1"
339 PLUG="\xF0\x9F\xa7\xa9"
340 RESTART="\xf0\x9f\x94\x84"
341 FORWARD="\xE2\x87\xA8"
342 INSTALL="\xF0\x9F\x8F\x97"
343 STOP="\xf0\x9f\x9b\x91"
344 GO="\xf0\x9f\x9a\x80"
345 DOWNLOAD="\xf0\x9f\x93\xa5"
346 GEAR="\xe2\x9a\x99"
347 NO_ENTRY="\xe2\x9b\x94"
348 LOCK="\xf0\x9f\x94\x92"
349fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700350
David Bainbridge712afb82019-08-14 19:55:58 +0000351duration() {
David Bainbridgee87067b2019-08-12 22:00:12 +0000352 local h=$(expr $1 / 3600)
353 local m=$(expr $1 % 3600 / 60)
354 local s=$(expr $1 % 60)
355 local t=""
356
357 if [ $h -gt 0 ]; then
358 t="$t${h}h"
359 fi
360 if [ $m -gt 0 ]; then
361 t="$t${m}m"
362 fi
David Bainbridge712afb82019-08-14 19:55:58 +0000363 echo "$t${s}s"
364}
365
366printtime() {
367 local INDENT=
368 if [ "$1" == "-" ]; then
369 INDENT=" "
370 shift
371 fi
372 echo -e "$INDENT $CLOCK $(duration $1)"
David Bainbridgee87067b2019-08-12 22:00:12 +0000373}
374
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700375bspin() {
Test Userd87942b2019-07-03 07:20:24 +0000376 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700377 local INDENT=
378 if [ "$1" == "-" ]; then
379 INDENT=" "
380 shift
381 fi
David Bainbridge38dc1e82019-08-12 15:18:45 +0000382 if [ $FANCY -eq 0 ]; then
383 LINE=$(echo $* | sed -e 's/[\s+-]//g')
384 if [ "$LINE X" == " X" ]; then
385 return
386 fi
387 echo -e "$CIVIS$INDENT$*"
388 else
389 echo -en "$CIVIS$INDENT $*"
390 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700391}
392
393sspin() {
394 local INDENT=
395 if [ "$1" == "-" ]; then
396 INDENT=" "
397 shift
398 fi
David Bainbridge38dc1e82019-08-12 15:18:45 +0000399 if [ $FANCY -eq 0 ]; then
400 LINE=$(echo $* | sed -e 's/[\s+-]//g')
401 if [ "$LINE X" == " X" ]; then
402 return
403 fi
404 echo -e "$INDENT$*"
405 else
406 C=$(echo $SPIN_PARTS | cut '-d ' -f $IDX)
407 echo -en "\r$INDENT$C $*"
408 IDX=$(expr $IDX + 1)
409 if [ $IDX -gt 8 ]; then
410 IDX=1
411 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700412 fi
413}
414
415espin() {
416 local INDENT=
417 if [ "$1" == "-" ]; then
418 INDENT=" "
419 shift
420 fi
David Bainbridge38dc1e82019-08-12 15:18:45 +0000421 if [ $FANCY -eq 0 ]; then
422 LINE=$(echo $* | sed -e 's/[\s+-]//g')
423 if [ "$LINE X" == " X" ]; then
424 return
425 fi
426 echo -e "$INDENT$*"
427 else
428 echo -e "\r$INDENT$*$CNORM"
429 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700430}
431
David Bainbridgeac7f8072019-08-01 22:15:33 +0000432if [ "$1" == "get" -a "$2" == "voltconfig" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000433 echo "$HOME/.volt/config-$NAME"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000434 exit
435fi
436
437if [ $# -ne 1 -o $(echo ":up:down:dump:" | grep -c ":$1:") -ne 1 ]; then
438 >&2 echo "What wouild you like to do today:"
439 >&2 echo " up - bring up voltha"
440 >&2 echo " down - tear down voltha"
441 >&2 echo " dump - create a debug dump of running system"
442 exit 1
443fi
444
445if [ "$1" == "down" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000446 echo "Tearing down voltha cluster $NAME"
447 LOG="down-$NAME.log"
448 echo $(date -u +"%Y%m%dT%H%M%SZ") >$LOG
David Bainbridgeac7f8072019-08-01 22:15:33 +0000449 if [ $DEPLOY_K8S == "yes" ]; then
450 if [ -x ./bin/kind ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000451 bspin "Delete Kubernetes Kind Cluster"
452 (set -x; ./bin/kind delete cluster --name voltha-$NAME >>$LOG 2>&1) >>$LOG 2>&1
453 espin $VERIFIED
David Bainbridgeac7f8072019-08-01 22:15:33 +0000454 else
David Bainbridge0774b232019-08-02 06:37:19 +0000455 espin "$NO_ENTRY Delete Kubernetes Kind Cluster: kind command not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000456 fi
457 else
458 EXISTS=$(helm list -q)
459 EXPECT="etcd-operator onos open-olt open-onu sim voltha bbsim radius"
David Bainbridge0774b232019-08-02 06:37:19 +0000460 bspin "Remove Helm Deployments"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000461 for i in $EXISTS; do
462 if [ $(echo $EXPECT | grep -c $i) -eq 1 ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000463 sspin "Remove Helm Deployments: $i$CEOL"
464 (set -x; ./bin/helm delete --purge $i >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000465 fi
466 done
David Bainbridge0774b232019-08-02 06:37:19 +0000467 espin "$VERIFIED Remove Helm Deployments$CEOL"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000468 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000469 bspin "Remove port-forwards: onos-ui-$NAME"
470 for i in $(screen -ls | grep onos-ui-$NAME | awk '{print $1}'); do
471 sspin
472 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
473 done
474 sspin "Remove port-forwards: onos-ssh-$NAME$CEOL"
475 for i in $(screen -ls | grep onos-ssh-$NAME | awk '{print $1}'); do
476 sspin
477 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
478 done
479 sspin "Remove port-forwards: voltha-api-$NAME$CEOL"
480 for i in $(screen -ls | grep voltha-api-$NAME | awk '{print $1}'); do
481 sspin
482 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
483 done
484 sspin "Remove port-forwards: voltha-ssh-$NAME$CEOL"
485 for i in $(screen -ls | grep voltha-ssh-$NAME | awk '{print $1}'); do
486 sspin
487 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
488 done
489 sspin "Remove port-forwards: voltha-etcd-$NAME$CEOL"
490 for i in $(screen -ls | grep voltha-etcd-$NAME | awk '{print $1}'); do
491 sspin
492 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
493 done
494 espin "$VERIFIED Remove port-forwards$CEOL"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000495 exit
496fi
497
498if [ "$1" == "dump" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000499 LOG="dump-$NAME.log"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000500 TS=$(date -u +"%Y%m%dT%H%M%SZ")
501 WORK=$(mktemp -u -d)
David Bainbridge0774b232019-08-02 06:37:19 +0000502 DATA=$WORK/voltha-debug-dump-$NAME-$TS
David Bainbridgeac7f8072019-08-01 22:15:33 +0000503 mkdir -p $DATA
504 echo $TS > $LOG
David Bainbridge0774b232019-08-02 06:37:19 +0000505 echo -e "Capturing debug dump to voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000506 bspin - "Copy install log"
David Bainbridge0774b232019-08-02 06:37:19 +0000507 if [ -f install-$NAME.log ]; then
508 (set -x; cp install-$NAME.log $DATA/install-$NAME.log) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000509 espin - $VERIFIED
510 else
David Bainbridge0774b232019-08-02 06:37:19 +0000511 espin - "$NO_ENTRY Copy install log: install-$NAME.log not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000512 fi
513 bspin - "Dumping Kubernetes PODs"
514 (set -x; kubectl get --all-namespaces pods >> $DATA/all-pods.txt 2>&1) >>$LOG 2>&1
515 espin - $VERIFIED
516 bspin - "Dumping Kubernetes SERVICEs"
517 (set -x; kubectl get --all-namespaces svc >> $DATA/all-services.txt 2>&1) >>$LOG 2>&1
518 espin - $VERIFIED
519 bspin - "Dumping Kubernetes EVENTs"
520 (set -x; kubectl get --all-namespaces events >> $DATA/all-events.txt 2>&1) >>$LOG 2>&1
521 espin - $VERIFIED
522 bspin - "Dumping VOLTHA POD details"
523 PODS=$(kubectl get -n voltha pod -o name)
524 for POD in $PODS; do
525 sspin - "Dumping VOLTHA POD details: $POD$CEOL"
526 mkdir -p $DATA/$POD
527 (set -x; kubectl describe -n voltha $POD >> $DATA/$POD/describe.txt 2>&1) >>$LOG 2>&1
528 sspin - "Dumping VOLTHA POD details: $POD"
529 (set -x; kubectl logs -n voltha --all-containers --previous $LOG_ARGS $POD >> $DATA/$POD/logs-previous.txt 2>&1) >>$LOG 2>&1
530 sspin - "Dumping VOLTHA POD details: $POD"
531 (set -x; kubectl logs -n voltha --all-containers $LOG_ARGS $POD >> $DATA/$POD/logs-current.txt 2>&1) >>$LOG 2>&1
532 sspin - "Dumping VOLTHA POD details: $POD"
533 done
534 espin - "$VERIFIED Dumping VOLTHA POD details$CEOL"
535 bspin - "Dumping ETCD"
536 if [ "$(which etcdctl) X" != " X" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000537 (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 +0000538 espin - $VERIFIED
539 else
540 espin - "$NO_ENTRY Dumping ETCD: etcdctl command not available"
541 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000542 bspin - "Creating compressed TAR: voltha-debug-dump-$NAME-$TS.tgz"
543 (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 +0000544 espin - $VERIFIED
545 bspin - "Cleanup"
546 (set -x; rm -rf $WORK) >>$LOG 2>&1
547 espin - $VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +0000548 bspin - "$(ls -l voltha-debug-dump-$NAME-$TS.tgz)"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000549 espin - $VERIFIED
550 exit
551fi
552
553
David Bainbridge0774b232019-08-02 06:37:19 +0000554LOG="install-$NAME.log"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000555date > $LOG
David Bainbridge0774b232019-08-02 06:37:19 +0000556echo "PORTS=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT" >> $LOG
David Bainbridgeac7f8072019-08-01 22:15:33 +0000557
558# Output install options to log
559echo "OPTIONS" >> $LOG
David Bainbridgee87067b2019-08-12 22:00:12 +0000560ALL_OPTIONS="NAME TYPE WITH_TIMINGS WITH_BBSIM WITH_RADIUS WITH_ONOS WITH_TP JUST_K8S DEPLOY_K8S \
David Bainbridge27790d62019-08-13 22:43:19 +0000561 INSTALL_ONOS_APPS SKIP_RESTART_API INSTALL_KUBECTL INSTALL_HELM USE_GO VOLTHA_LOG_LEVEL \
David Bainbridgeac7f8072019-08-01 22:15:33 +0000562 VOLTHA_CHART VOLTHA_ADAPTER_SIM_CHART VOLTHA_ADAPTER_OPEN_OLT_CHART \
David Bainbridge27790d62019-08-13 22:43:19 +0000563 VOLTHA_ADAPTER_OPEN_ONU_CHART ONOS_TAG \
David Bainbridge0774b232019-08-02 06:37:19 +0000564 ONOS_API_PORT ONOS_SSH_PORT VOLTHA_API_PORT VOLTHA_SSH_PORT VOLTHA_ETCD_PORT"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000565for O in $ALL_OPTIONS; do
566 VAL=$(eval echo \$$O)
567 if [ $O == "USE_GO" ]; then
568 VAL="$(echo $VAL| test $(grep -c true) -eq 1 && echo yes || echo no)"
569 fi
570 if [ ! -z "$VAL" ]; then
571 printf " %-30s = %s\n" $O $VAL >> $LOG
572 fi
573done
574
David Bainbridged31d6122019-08-13 19:37:59 +0000575push_onos_config() {
576 local MSG=$1
577 local RESOURCE=$2
578 local DATA=$3
579
580 bspin - "$MSG $GEAR"
581 until test; do
582 (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
583 if [ $? -eq 0 ]; then
584 break
585 fi
586 sleep .2
587 sspin -
588 done
589 espin - $VERIFIED
590}
David Bainbridgeac7f8072019-08-01 22:15:33 +0000591
David Bainbridge27790d62019-08-13 22:43:19 +0000592override_onos_app() {
593 local APP=$1
594 local NAME=$(basename $APP | sed -e 's/-.*$//g')
595 until test; do
596 sspin -
597 # Attempt to delete old version (if it exists)
598 (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
599 sspin -
600 (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 K. Bainbridgeb7285432019-07-02 22:05:24 -0700608count_pods() {
609 local NAMESPACE=$1; shift
610 local PODS=$(kubectl -n $NAMESPACE get pod -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}")
611 local COUNT=0
612 local PATTERNS=$*
613 for POD in $PODS; do
614 local NAME=$(echo $POD | cut -d/ -f 1)
615 local STATE=$(echo $POD | cut -d/ -f 2)
616 local CONTAINERS=$(echo $POD | cut -d/ -f 3 | sed -e 's/_/ /g')
617 if [ "$STATE" == "Running" ]; then
618 local TOTAL=$(echo $CONTAINERS | wc -w)
619 local FOUND=$(echo $CONTAINERS | grep -o true | wc -l)
620 if [ $TOTAL -eq $FOUND ]; then
621 for PATTERN in $PATTERNS; do
622 if [[ $NAME =~ $PATTERN ]]; then
623 COUNT=$(expr $COUNT + 1)
624 fi
625 done
626 fi
627 fi
628 done
629 echo $COUNT
630}
631
632wait_for_pods() {
633 local INDENT=
634 if [ "$1" == "-" ]; then
635 INDENT=$1; shift
636 fi
637 local NAMESPACE=$1; shift
638 local EXPECT=$1; shift
639 local RETRY=$1; shift
640 local MESSAGE=$1; shift
641 local PATTERNS=$*
642 local HAVE=$(count_pods $NAMESPACE $PATTERNS)
643 COUNT=$(expr 300 / 15)
644 bspin $INDENT $MESSAGE
645 sspin $INDENT
646 if [ $HAVE -ne $EXPECT ]; then
647 while [ $HAVE -ne $EXPECT ]; do
648 sspin $INDENT
649 COUNT=$(expr $COUNT - 1)
650 if [ $COUNT -eq 0 ]; then
651 HAVE=$(count_pods $NAMESPACE $PATTERNS)
652 COUNT=$(expr 300 / 15)
653 fi
654 sleep .15
655 done
656 fi
657 espin $INDENT $VERIFIED
658 if [ $HAVE -ne $EXPECT ]; then
659 return 1
660 fi
661 return 0
662}
663
664helm_install() {
665 local INDENT=
666 if [ "$1" == "-" ]; then
667 INDENT=$1; shift
668 fi
669 local NAMESPACE=$1; shift
David Bainbridge0774b232019-08-02 06:37:19 +0000670 local INAME=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700671 local CHART=$1; shift
672 local MESSAGE=$*
673
674 COUNT=$(expr 300 / 15)
675 bspin $INDENT $MESSAGE
David Bainbridge458bb662019-08-02 20:04:23 +0000676 (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 -0700677 SUCCESS=$?
678 while [ $SUCCESS -ne 0 ]; do
679 sspin $INDENT
680 COUNT=$(expr $COUNT - 1)
681 if [ $COUNT -eq 0 ]; then
David Bainbridge458bb662019-08-02 20:04:23 +0000682 (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 -0700683 COUNT=$(expr 300 / 15)
684 fi
685 sleep .15
686 done
687 espin $INDENT $VERIFIED
688}
689
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700690echo "INSTALL TYPE: $TYPE" >> $LOG
691
692bspin "Verify GOPATH"
693export GOPATH=$(pwd)
Test User3d7ad8e2019-07-03 06:15:44 +0000694mkdir -p $GOPATH/bin
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700695espin $VERIFIED
696
David Bainbridgee87067b2019-08-12 22:00:12 +0000697STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700698if [ "$INSTALL_KUBECTL" == "no" ]; then
699 bspin "Skip kubectl install"
700 espin $NO_ENTRY
Test Userc13bdc92019-07-03 20:57:49 +0000701else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700702 bspin "Verify kubectl $HELM"
703 if [ -x $GOPATH/bin/kubectl ]; then
704 espin $VERIFIED
705 else
706 espin $NOT_VERIFIED
707 bspin - "Download and install Kubernetes/kubectl $DOWNLOAD"
708 (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
709 (set -x; chmod 755 $GOPATH/bin/kubectl >>$LOG 2>&1) >>$LOG 2>&1
710 espin - $VERIFIED
711 fi
Test Userc13bdc92019-07-03 20:57:49 +0000712fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000713if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000714 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000715fi
Test Userc13bdc92019-07-03 20:57:49 +0000716
David Bainbridgee87067b2019-08-12 22:00:12 +0000717STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700718if [ "$DEPLOY_K8S" == "no" ]; then
719 bspin "Skip Kubernetes/Kind Deployment"
720 espin $NO_ENTRY
721else
Test Userba1e7e72019-07-10 22:27:54 +0000722 bspin "Verify Kubernetes/Kind $HELM"
723 if [ -x $GOPATH/bin/kind ]; then
724 espin $VERIFIED
725 else
726 espin $NOT_VERIFIED
727 bspin - "Download and install Kubernetes/kind $DOWNLOAD"
David Bainbridge9e2a6662019-07-11 17:07:57 +0000728 (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 +0000729 (set -x; chmod 755 $GOPATH/bin/kind >>$LOG 2>&1) >>$LOG 2>&1
730 espin - $VERIFIED
731 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700732fi
733
David Bainbridgee87067b2019-08-12 22:00:12 +0000734if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000735 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000736fi
737
738STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700739if [ "$INSTALL_HELM" == "no" ]; then
740 bspin "Skip Helm Install"
741 espin $NO_ENTRY
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700742else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700743 bspin "Verify Helm $HELM"
744 if [ -x $GOPATH/bin/helm ]; then
745 espin $VERIFIED
746 else
747 espin $NOT_VERIFIED
748 bspin - "Download and install Helm $DOWNLOAD"
749 (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
750 espin - $VERIFIED
751 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700752fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000753if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000754 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000755fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700756
David Bainbridgee87067b2019-08-12 22:00:12 +0000757STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +0000758bspin "Verify voltctl $HIGH_VOLTAGE"
Test User3d7ad8e2019-07-03 06:15:44 +0000759if [ -x $GOPATH/bin/voltctl ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700760 espin $VERIFIED
761else
762 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000763 bspin - "Download and build voltctl $DOWNLOAD"
Test Userba1e7e72019-07-10 22:27:54 +0000764 (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 +0000765 (set -x; chmod 755 $GOPATH/bin/voltctl >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700766 espin - $VERIFIED
767fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000768if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000769 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000770fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700771
772bspin "Verify command PATH"
Test Userba1e7e72019-07-10 22:27:54 +0000773export PATH=$GOPATH/bin:$PATH
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700774espin $VERIFIED
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700775
David Bainbridgee87067b2019-08-12 22:00:12 +0000776STIME=$(date +%s)
Test Userba1e7e72019-07-10 22:27:54 +0000777if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000778 HAVE=$(kind get clusters | grep -c voltha-$NAME)
Test Userba1e7e72019-07-10 22:27:54 +0000779 bspin "Verify Kubernetes/Kind Cluster"
780 sspin
781 if [ $HAVE -eq 0 ]; then
David Bainbridge491b1bd2019-07-11 17:53:11 +0000782 espin $NOT_VERIFIED
783 bspin - "Verify cluster configuration"
David Bainbridge0774b232019-08-02 06:37:19 +0000784 if [ ! -r ./$NAME-cluster.cfg ]; then
David Bainbridge491b1bd2019-07-11 17:53:11 +0000785 espin - $NOT_VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +0000786 bspin - "Download cluster configuration: $TYPE-cluster.cfg to $NAME-cluster.cfg $DOWNLOAD"
787 (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 -0700788 espin - $VERIFIED
789 else
790 espin - $VERIFIED
791 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000792 kind create cluster --name voltha-$NAME --config $NAME-cluster.cfg
David Bainbridge491b1bd2019-07-11 17:53:11 +0000793 else
794 espin $VERIFIED
Test Userba1e7e72019-07-10 22:27:54 +0000795 fi
796
David Bainbridge0774b232019-08-02 06:37:19 +0000797 export KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$NAME")"
Test Userba1e7e72019-07-10 22:27:54 +0000798 P="coredns-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000799 etcd-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +0000800 kindnet-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000801 kube-apiserver-voltha-$NAME-control-plane \
802 kube-controller-manager-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +0000803 kube-proxy-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000804 kube-scheduler-voltha-$NAME-control-plane"
Test Userba1e7e72019-07-10 22:27:54 +0000805
806 EXPECT=$(test "$TYPE" == "minimal" && echo "12" || echo "14")
807 wait_for_pods - "kube-system" $EXPECT -1 "Waiting for system PODs to start" $P
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700808fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000809if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000810 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000811fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700812
David Bainbridgee87067b2019-08-12 22:00:12 +0000813STIME=$(date +%s)
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700814COUNT=$(count_pods "kube-system" "tiller-deploy-.*")
815bspin "Verify Helm"
Test Userba1e7e72019-07-10 22:27:54 +0000816if [ $COUNT -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700817 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000818 echo -e "Configuring Helm $GEAR"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700819 if [ "$INSTALL_HELM" == "no" ]; then
820 bspin - "Skip Helm/Tiller Initialization"
821 espin - $NO_ENTRY
822 else
823 bspin - "Initialize Helm"
824 (set -x; helm init --upgrade >>$LOG 2>&1) >>$LOG 2>&1
825 espin - $VERIFIED
826 wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
827 fi
Test Userb5712372019-07-03 21:52:17 +0000828 bspin - "Add Google Incubator repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700829 (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
830 espin - $VERIFIED
Test Userba1e7e72019-07-10 22:27:54 +0000831
832 # HACK (sort-of) - the config for tiller is about to be patched, which will
833 # cause the tiller pod to be recreated. This can sometimes cause a timing
834 # issue with the "wait_for_pods" call on tiller as it may incorrectly
835 # identify the running/ready tiller pod that is soon to be terminated as
836 # what it is waiting for. To avoid this issue we do a clean scale down and
837 # scale up of the pod so the script controlls when it should be expecting
838 # things
839 (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 -0700840
Test Userb5712372019-07-03 21:52:17 +0000841 bspin - "Add Google Stable repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700842 (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
843 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000844 bspin - "Add ONF repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700845 (set -x; helm repo add onf https://charts.opencord.org >>$LOG 2>&1) >>$LOG 2>&1
846 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000847 bspin - "Update Helm repository cache"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700848 (set -x; helm repo update >>$LOG 2>&1) >>$LOG 2>&1
849 espin - $VERIFIED
850
851 # Create and k8s service account so that Helm can create pods
Test Userb5712372019-07-03 21:52:17 +0000852 bspin - "Create Tiller ServiceAccount"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700853 (set -x; kubectl create serviceaccount --namespace kube-system tiller >>$LOG 2>&1) >>$LOG 2>&1
854 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000855 bspin - "Create Tiller ClusterRoleBinding"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700856 (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>$LOG 2>&1) >>$LOG 2>&1
857 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000858 bspin - "Update Tiller Manifest"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700859 (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 +0000860
861 # HACK (sort-of) - part to, spin it back up
862 (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 -0700863 espin - $VERIFIED
864else
865 espin $VERIFIED
866fi
Test Userb5712372019-07-03 21:52:17 +0000867wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +0000868if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000869 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000870fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700871
David Bainbridgee87067b2019-08-12 22:00:12 +0000872STIME=$(date +%s)
David Bainbridge0774b232019-08-02 06:37:19 +0000873bspin "Verify Helm values file: $NAME-values.yaml"
874if [ ! -r "./$NAME-values.yaml" ]; then
Test Userba1e7e72019-07-10 22:27:54 +0000875 espin $NOT_VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +0000876 bspin - "Download Helm values file: $TYPE-values.yaml to $NAME-values.yaml $DOWNLOAD"
877 (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 +0000878 espin - $VERIFIED
879else
880 espin $VERIFIED
881fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000882if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000883 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000884fi
Test Userba1e7e72019-07-10 22:27:54 +0000885
886if [ "$JUST_K8S" == "yes" ]; then
887 echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye."
888 echo ""
889 echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
890 echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
891 echo "tools required by VOLTHA in your command path. " | tee -a $LOG
892 echo "" | tee -a $LOG
893 echo -en $BOLD
894 if [ $DEPLOY_K8S == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000895 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +0000896 fi
897 echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
898 echo -en $NORMAL
899 echo "" | tee -a $LOG
900 echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
901 exit 0
902fi
903
David Bainbridgee87067b2019-08-12 22:00:12 +0000904STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +0000905bspin "Verify ETCD Operator $OLD_KEY"
Test User7d866122019-07-09 17:52:35 +0000906if [ $(helm list --deployed --short --namespace voltha "^etcd-operator\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700907 espin $NOT_VERIFIED
908 helm_install - voltha etcd-operator stable/etcd-operator "Install ETCD Operator"
909else
910 espin $VERIFIED
911fi
Test User01ed0642019-07-03 20:17:06 +0000912EXPECT=$(test "$TYPE" == "minimal" && echo "1" || echo "3")
Test Userb5712372019-07-03 21:52:17 +0000913wait_for_pods - "voltha" $EXPECT -1 "Waiting for ETCD Operator to start" "etcd-operator-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +0000914if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000915 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000916fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700917
David Bainbridgee87067b2019-08-12 22:00:12 +0000918STIME=$(date +%s)
David Bainbridgeb270c202019-07-26 01:44:42 +0000919if [ $WITH_ONOS == "yes" ]; then
920 bspin "Verify ONOS installed $BIRD"
921 if [ $(helm list --deployed --short --namespace default "^onos\$" | wc -l) -ne 1 ]; then
922 espin $NOT_VERIFIED
David Bainbridge27790d62019-08-13 22:43:19 +0000923 SET_TAG=
924 if [ "$ONOS_TAG X" != " X" ]; then
925 SET_TAG="--set images.onos.tag=$ONOS_TAG"
926 fi
927 EXTRA_HELM_FLAGS="$SET_TAG $EXTRA_HELM_FLAGS" helm_install - default onos onf/onos "Install ONOS"
David Bainbridgeb270c202019-07-26 01:44:42 +0000928 else
929 espin $VERIFIED
930 fi
931 wait_for_pods - "default" 1 -1 "Waiting for ONOS to start" "onos-.*"
932
933 bspin - "Forward ONOS API port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +0000934 for i in $(screen -ls | grep onos-ui-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +0000935 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
936 done
David Bainbridge0774b232019-08-02 06:37:19 +0000937 (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 +0000938 espin - $VERIFIED
939 bspin - "Forward ONOS SSH port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +0000940 for i in $(screen -ls | grep onos-ssh-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +0000941 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
942 done
David Bainbridge0774b232019-08-02 06:37:19 +0000943 (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 +0000944 espin - $VERIFIED
David Bainbridged31d6122019-08-13 19:37:59 +0000945 bspin - "Verify or download ONOS configuration support files $DOWNLOAD"
946 (set -x; mkdir -p ./onos-files >>$LOG 2>&1) >>$LOG 2>&1
947 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
948 if [ ! -r ./onos-files/$i ]; then
949 (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
950 fi
951 done
Test Userba1e7e72019-07-10 22:27:54 +0000952 espin - $VERIFIED
David Bainbridge27790d62019-08-13 22:43:19 +0000953
954 if [ $INSTALL_ONOS_APPS == "yes" ]; then
955 bspin - "Installing custom ONOS applications"
956 if [ -x onos-files/onos-apps -a $(ls -1 onos-files/onos-apps/*.oar 2>/dev/null | wc -l) -gt 0 ]; then
957 for OAR in $(ls -1 onos-files/onos-apps/*.oar); do
958 sspin - "Installing custom ONOS applications - $OAR$CEOL"
959 override_onos_app $OAR
960 done
961 espin - "$VERIFIED Installing custom ONOS applications$CEOL"
962 else
963 espin - "$NOT_VERIFIED Installing custom ONOS applications - None Found"
964 fi
965 fi
David Bainbridged31d6122019-08-13 19:37:59 +0000966
967 push_onos_config "Push ONOS Network Configuration" "network/configuration" "onos-files/olt-onos-netcfg.json"
968 push_onos_config "Enable VOLTHA ONOS DHCP provisioning" "configuration/org.opencord.olt.impl.Olt" "onos-files/olt-onos-olt-settings.json"
969 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 +0000970fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000971if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000972 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000973fi
Test Userba1e7e72019-07-10 22:27:54 +0000974
David Bainbridgee87067b2019-08-12 22:00:12 +0000975STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +0000976bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
Test User7d866122019-07-09 17:52:35 +0000977if [ $(helm list --deployed --short --namespace voltha "^voltha\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700978 espin $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +0000979 helm_install - voltha voltha $VOLTHA_CHART "Install VOLTHA Core"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700980else
981 espin $VERIFIED
982fi
Test Userba1e7e72019-07-10 22:27:54 +0000983
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700984VOLTHA="ofagent-.* \
985 ro-core.* \
986 rw-core.* \
987 voltha-api-server-.* \
988 voltha-cli-server-.* \
989 voltha-etcd-cluster-.* \
990 voltha-kafka-.* \
991 voltha-zookeeper-.*"
Test User01ed0642019-07-03 20:17:06 +0000992EXPECT=$(test "$TYPE" == "minimal" && echo "9" || echo "11")
Test Userb5712372019-07-03 21:52:17 +0000993wait_for_pods - "voltha" $EXPECT -1 "Waiting for VOLTHA Core to start" $VOLTHA
David Bainbridgee87067b2019-08-12 22:00:12 +0000994if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000995 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000996fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700997
David Bainbridgee87067b2019-08-12 22:00:12 +0000998STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +0000999echo -e "Verify Adapters $PLUG"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001000bspin - "Verify Simulated Adapters installed"
Test User7d866122019-07-09 17:52:35 +00001001if [ $(helm list --deployed --short --namespace voltha "^sim\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001002 espin - $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +00001003 helm_install - voltha sim $VOLTHA_ADAPTER_SIM_CHART "Install Simulated Adapters"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001004else
1005 espin - $VERIFIED
1006fi
1007
1008bspin - "Verify OpenOLT Adapter installed"
Test User7d866122019-07-09 17:52:35 +00001009if [ $(helm list --deployed --short --namespace voltha "^open-olt\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001010 espin - $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +00001011 helm_install - voltha open-olt $VOLTHA_ADAPTER_OPEN_OLT_CHART "Install OpenOLT Adapter"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001012else
1013 espin - $VERIFIED
1014fi
1015bspin - "Verify OpenONU Adapter installed"
Test User7d866122019-07-09 17:52:35 +00001016if [ $(helm list --deployed --short --namespace voltha "^open-onu\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001017 espin - $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +00001018 helm_install - voltha open-onu $VOLTHA_ADAPTER_OPEN_ONU_CHART "Install OpenONU Adapter"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001019else
1020 espin - $VERIFIED
1021fi
1022
1023ADAPTERS="adapter-.*"
Test Userb5712372019-07-03 21:52:17 +00001024wait_for_pods - "voltha" 4 -1 "Waiting for adapters to start" $ADAPTERS
David Bainbridgee87067b2019-08-12 22:00:12 +00001025if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001026 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001027fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001028
Test User7d866122019-07-09 17:52:35 +00001029if [ $WITH_BBSIM == "yes" ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +00001030 STIME=$(date +%s)
Test User7d866122019-07-09 17:52:35 +00001031 echo -e "Verify BBSIM $PLUG"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001032 bspin - "Verify BBSIM Installed"
Test User7d866122019-07-09 17:52:35 +00001033 if [ $(helm list --deployed --short --namespace voltha "^bbsim\$" | wc -l) -ne 1 ]; then
1034 espin - $NOT_VERIFIED
1035 helm_install - voltha bbsim onf/bbsim "Install BBSIM"
1036 else
1037 espin - $VERIFIED
1038 fi
1039 wait_for_pods - "voltha" 1 -1 "Waiting for BBSIM to start" "bbsim-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001040 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001041 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001042 fi
Test User7d866122019-07-09 17:52:35 +00001043fi
1044
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001045if [ $WITH_RADIUS == "yes" ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +00001046 STIME=$(date +%s)
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001047 echo -e "Verify RADIUS $LOCK"
1048 bspin - "Verify RADIUS Installed"
1049 if [ $(helm list --deployed --short --namespace voltha "^radius\$" | wc -l) -ne 1 ]; then
1050 espin - $NOT_VERIFIED
1051 helm_install - voltha radius onf/freeradius "Install RADIUS"
1052 else
1053 espin - $VERIFIED
1054 fi
1055 wait_for_pods - "voltha" 1 -1 "Waiting for RADIUS to start" "radius-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001056 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001057 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001058 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001059fi
1060
David Bainbridgee87067b2019-08-12 22:00:12 +00001061STIME=$(date +%s)
David Bainbridgee10f6d52019-07-25 00:28:13 +00001062if [ $SKIP_RESTART_API == "no" ]; then
1063 echo -e "Restart VOLTHA API $RESTART"
1064 API="voltha-api-server-.* ofagent-.*"
1065 (set -x; kubectl scale --replicas=0 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1
1066 wait_for_pods - "voltha" 0 -1 "Wait for API to stop $STOP" $API
1067 (set -x; kubectl scale --replicas=1 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1
1068 wait_for_pods - "voltha" 2 -1 "Wait for API to re-start $GO" $API
1069else
1070 bspin "Skip VOLTHA API Restart"
1071 espin $NO_ENTRY
1072fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001073
Test Userb5712372019-07-03 21:52:17 +00001074bspin - "Forward VOLTHA API port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +00001075for i in $(screen -ls | grep voltha-api-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +00001076 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
1077done
David Bainbridge0774b232019-08-02 06:37:19 +00001078(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 -07001079espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +00001080bspin - "Forward VOLTHA SSH port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +00001081for i in $(screen -ls | grep voltha-ssh-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +00001082 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
1083done
David Bainbridge0774b232019-08-02 06:37:19 +00001084(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 -07001085espin - $VERIFIED
David Bainbridgeac7f8072019-08-01 22:15:33 +00001086bspin - "Forward VOLTHA ETCD port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +00001087for i in $(screen -ls | grep voltha-etcd-$NAME | awk '{print $1}'); do
David Bainbridgeac7f8072019-08-01 22:15:33 +00001088 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
1089done
David Bainbridge0774b232019-08-02 06:37:19 +00001090(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 +00001091espin - $VERIFIED
David Bainbridgee87067b2019-08-12 22:00:12 +00001092if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001093 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001094fi
Test User3d7ad8e2019-07-03 06:15:44 +00001095
David Bainbridgeb270c202019-07-26 01:44:42 +00001096if [ $WITH_ONOS == "yes" -a $WITH_RADIUS == "yes" ]; then
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001097 bspin "Configure ONOS RADIUS Connection $GEAR"
1098 (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
1099 espin $VERIFIED
1100fi
1101
1102bspin "Create voltctl configuration file"
Test User3d7ad8e2019-07-03 06:15:44 +00001103(set -x; mkdir -p $HOME/.volt >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridge0774b232019-08-02 06:37:19 +00001104(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 +00001105espin $VERIFIED
Test User08ebbd92019-07-03 17:15:39 +00001106
David Bainbridge0774b232019-08-02 06:37:19 +00001107if [ ! -f "$NAME-env.sh" ]; then
1108 touch $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001109fi
1110
David Bainbridge596f30d2019-07-30 17:07:59 +00001111for O in $ALL_OPTIONS; do
1112 VAL=$(eval echo \$$O)
1113 if [ $O == "USE_GO" ]; then
1114 VAL="$(echo $VAL| test $(grep -c true) -eq 1 && echo yes || echo no)"
1115 fi
David Bainbridge0774b232019-08-02 06:37:19 +00001116 if [ ! -z "$VAL" -a $(grep -c "^export $O=" $NAME-env.sh) -eq 0 ]; then
1117 echo "export $O=\"$(eval echo \$$O)\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001118 fi
1119done
1120
David Bainbridge0774b232019-08-02 06:37:19 +00001121if [ $DEPLOY_K8S == "yes" -a $(grep -c "^export KUBECONFIG=" $NAME-env.sh) -eq 0 ]; then
1122 echo "export KUBECONFIG=\"$(./bin/kind get kubeconfig-path --name=voltha-$NAME)\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001123fi
1124
David Bainbridge0774b232019-08-02 06:37:19 +00001125if [ $(grep -c "^export VOLTCONFIG=" $NAME-env.sh) -eq 0 ]; then
1126 echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001127fi
1128
David Bainbridge0774b232019-08-02 06:37:19 +00001129if [ $(grep -c "^export PATH=" $NAME-env.sh) -eq 0 ]; then
1130 echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001131fi
1132
Test User7d866122019-07-09 17:52:35 +00001133echo ""
Test User08ebbd92019-07-03 17:15:39 +00001134echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
1135echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
1136echo "tools required by VOLTHA in your command path. " | tee -a $LOG
1137echo "" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +00001138echo -en $BOLD
Test Userba1e7e72019-07-10 22:27:54 +00001139if [ $DEPLOY_K8S == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001140 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +00001141fi
David Bainbridge0774b232019-08-02 06:37:19 +00001142echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +00001143echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +00001144echo -en $NORMAL
Test User08ebbd92019-07-03 17:15:39 +00001145echo "" | tee -a $LOG
1146echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
1147
David Bainbridge712afb82019-08-14 19:55:58 +00001148if [ "$WITH_TIMINGS" == "yes" ]; then
1149 echo -e "$CLOCK TOTAL: $(duration $(expr $(date +%s) - $TOTAL_START_TIME))"
1150fi
1151