blob: 0ce23ac5d216f914d0720115aea1c243fc1d5905 [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=
David Bainbridgef858a022019-08-14 21:25:11 +0000305THEX=
306BUILD=
307CROSS=
308ENTER=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000309VERIFIED=
310HELM=
311OLD_KEY=
312BIRD=
313HIGH_VOLTAGE=
314PLUG=
315RESTART=
316FORWARD=
317INSTALL=
318STOP=
319GO=
320DOWNLOAD=
321GEAR=
322NO_ENTRY=
323LOCK=
324
325if [ $FANCY -eq 1 ]; then
326 SPIN_PARTS="\
327 \xe2\xa2\x8e\xe2\xa1\xb0 \
328 \xe2\xa2\x8e\xe2\xa1\xa1 \
329 \xe2\xa2\x8e\xe2\xa1\x91 \
330 \xe2\xa2\x8e\xe2\xa0\xb1 \
331 \xe2\xa0\x8e\xe2\xa1\xb1 \
332 \xe2\xa2\x8a\xe2\xa1\xb1 \
333 \xe2\xa2\x8c\xe2\xa1\xb1 \
334 \xe2\xa2\x86\xe2\xa1\xb1 \
335 "
David Bainbridgee87067b2019-08-12 22:00:12 +0000336 CLOCK="\xe2\x8f\xb1"
David Bainbridgef858a022019-08-14 21:25:11 +0000337 THEX="${RED}${BOLD}\xe2\x9c\x97\x20${NORMAL}"
338 ENTER="${YELLOW}${BOLD}\xe2\x8e\x86${NORMAL}"
339 CROSS="${YELLOW}${BOLD}\xe2\x9c\x9a${NORMAL}"
340 BUILD="${YELLOW}${BOLD}\xf0\x9f\x8f\x97${NORMAL}"
341 NOT_VERIFIED="$BUILD"
342 VERIFIED="${GREEN}${BOLD}\xe2\x9c\x93\x20${NORMAL}"
343 HELM="${BLUE}${BOLD}\xE2\x8E\x88${NORMAL}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000344 OLD_KEY="\xF0\x9F\x97\x9D"
345 BIRD="\xF0\x9F\x90\xA6"
346 HIGH_VOLTAGE="\xE2\x9A\xA1"
347 PLUG="\xF0\x9F\xa7\xa9"
348 RESTART="\xf0\x9f\x94\x84"
349 FORWARD="\xE2\x87\xA8"
350 INSTALL="\xF0\x9F\x8F\x97"
351 STOP="\xf0\x9f\x9b\x91"
352 GO="\xf0\x9f\x9a\x80"
353 DOWNLOAD="\xf0\x9f\x93\xa5"
354 GEAR="\xe2\x9a\x99"
355 NO_ENTRY="\xe2\x9b\x94"
356 LOCK="\xf0\x9f\x94\x92"
357fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700358
David Bainbridge712afb82019-08-14 19:55:58 +0000359duration() {
David Bainbridgee87067b2019-08-12 22:00:12 +0000360 local h=$(expr $1 / 3600)
361 local m=$(expr $1 % 3600 / 60)
362 local s=$(expr $1 % 60)
363 local t=""
364
365 if [ $h -gt 0 ]; then
366 t="$t${h}h"
367 fi
368 if [ $m -gt 0 ]; then
369 t="$t${m}m"
370 fi
David Bainbridge712afb82019-08-14 19:55:58 +0000371 echo "$t${s}s"
372}
373
374printtime() {
375 local INDENT=
376 if [ "$1" == "-" ]; then
377 INDENT=" "
378 shift
379 fi
380 echo -e "$INDENT $CLOCK $(duration $1)"
David Bainbridgee87067b2019-08-12 22:00:12 +0000381}
382
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700383bspin() {
Test Userd87942b2019-07-03 07:20:24 +0000384 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700385 local INDENT=
386 if [ "$1" == "-" ]; then
387 INDENT=" "
388 shift
389 fi
David Bainbridge38dc1e82019-08-12 15:18:45 +0000390 if [ $FANCY -eq 0 ]; then
391 LINE=$(echo $* | sed -e 's/[\s+-]//g')
392 if [ "$LINE X" == " X" ]; then
393 return
394 fi
395 echo -e "$CIVIS$INDENT$*"
396 else
397 echo -en "$CIVIS$INDENT $*"
398 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700399}
400
401sspin() {
402 local INDENT=
403 if [ "$1" == "-" ]; then
404 INDENT=" "
405 shift
406 fi
David Bainbridge38dc1e82019-08-12 15:18:45 +0000407 if [ $FANCY -eq 0 ]; then
408 LINE=$(echo $* | sed -e 's/[\s+-]//g')
409 if [ "$LINE X" == " X" ]; then
410 return
411 fi
412 echo -e "$INDENT$*"
413 else
414 C=$(echo $SPIN_PARTS | cut '-d ' -f $IDX)
415 echo -en "\r$INDENT$C $*"
416 IDX=$(expr $IDX + 1)
417 if [ $IDX -gt 8 ]; then
418 IDX=1
419 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700420 fi
421}
422
423espin() {
424 local INDENT=
425 if [ "$1" == "-" ]; then
426 INDENT=" "
427 shift
428 fi
David Bainbridge38dc1e82019-08-12 15:18:45 +0000429 if [ $FANCY -eq 0 ]; then
430 LINE=$(echo $* | sed -e 's/[\s+-]//g')
431 if [ "$LINE X" == " X" ]; then
432 return
433 fi
434 echo -e "$INDENT$*"
435 else
436 echo -e "\r$INDENT$*$CNORM"
437 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700438}
439
David Bainbridgeac7f8072019-08-01 22:15:33 +0000440if [ "$1" == "get" -a "$2" == "voltconfig" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000441 echo "$HOME/.volt/config-$NAME"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000442 exit
443fi
444
445if [ $# -ne 1 -o $(echo ":up:down:dump:" | grep -c ":$1:") -ne 1 ]; then
446 >&2 echo "What wouild you like to do today:"
447 >&2 echo " up - bring up voltha"
448 >&2 echo " down - tear down voltha"
449 >&2 echo " dump - create a debug dump of running system"
450 exit 1
451fi
452
453if [ "$1" == "down" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000454 echo "Tearing down voltha cluster $NAME"
455 LOG="down-$NAME.log"
456 echo $(date -u +"%Y%m%dT%H%M%SZ") >$LOG
David Bainbridgeac7f8072019-08-01 22:15:33 +0000457 if [ $DEPLOY_K8S == "yes" ]; then
458 if [ -x ./bin/kind ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000459 bspin "Delete Kubernetes Kind Cluster"
460 (set -x; ./bin/kind delete cluster --name voltha-$NAME >>$LOG 2>&1) >>$LOG 2>&1
461 espin $VERIFIED
David Bainbridgeac7f8072019-08-01 22:15:33 +0000462 else
David Bainbridge0774b232019-08-02 06:37:19 +0000463 espin "$NO_ENTRY Delete Kubernetes Kind Cluster: kind command not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000464 fi
465 else
466 EXISTS=$(helm list -q)
467 EXPECT="etcd-operator onos open-olt open-onu sim voltha bbsim radius"
David Bainbridge0774b232019-08-02 06:37:19 +0000468 bspin "Remove Helm Deployments"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000469 for i in $EXISTS; do
470 if [ $(echo $EXPECT | grep -c $i) -eq 1 ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000471 sspin "Remove Helm Deployments: $i$CEOL"
472 (set -x; ./bin/helm delete --purge $i >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000473 fi
474 done
David Bainbridge0774b232019-08-02 06:37:19 +0000475 espin "$VERIFIED Remove Helm Deployments$CEOL"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000476 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000477 bspin "Remove port-forwards: onos-ui-$NAME"
478 for i in $(screen -ls | grep onos-ui-$NAME | awk '{print $1}'); do
479 sspin
480 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
481 done
482 sspin "Remove port-forwards: onos-ssh-$NAME$CEOL"
483 for i in $(screen -ls | grep onos-ssh-$NAME | awk '{print $1}'); do
484 sspin
485 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
486 done
487 sspin "Remove port-forwards: voltha-api-$NAME$CEOL"
488 for i in $(screen -ls | grep voltha-api-$NAME | awk '{print $1}'); do
489 sspin
490 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
491 done
492 sspin "Remove port-forwards: voltha-ssh-$NAME$CEOL"
493 for i in $(screen -ls | grep voltha-ssh-$NAME | awk '{print $1}'); do
494 sspin
495 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
496 done
497 sspin "Remove port-forwards: voltha-etcd-$NAME$CEOL"
498 for i in $(screen -ls | grep voltha-etcd-$NAME | awk '{print $1}'); do
499 sspin
500 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
501 done
502 espin "$VERIFIED Remove port-forwards$CEOL"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000503 exit
504fi
505
506if [ "$1" == "dump" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000507 LOG="dump-$NAME.log"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000508 TS=$(date -u +"%Y%m%dT%H%M%SZ")
509 WORK=$(mktemp -u -d)
David Bainbridge0774b232019-08-02 06:37:19 +0000510 DATA=$WORK/voltha-debug-dump-$NAME-$TS
David Bainbridgeac7f8072019-08-01 22:15:33 +0000511 mkdir -p $DATA
512 echo $TS > $LOG
David Bainbridge0774b232019-08-02 06:37:19 +0000513 echo -e "Capturing debug dump to voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000514 bspin - "Copy install log"
David Bainbridge0774b232019-08-02 06:37:19 +0000515 if [ -f install-$NAME.log ]; then
516 (set -x; cp install-$NAME.log $DATA/install-$NAME.log) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000517 espin - $VERIFIED
518 else
David Bainbridge0774b232019-08-02 06:37:19 +0000519 espin - "$NO_ENTRY Copy install log: install-$NAME.log not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000520 fi
521 bspin - "Dumping Kubernetes PODs"
522 (set -x; kubectl get --all-namespaces pods >> $DATA/all-pods.txt 2>&1) >>$LOG 2>&1
523 espin - $VERIFIED
524 bspin - "Dumping Kubernetes SERVICEs"
525 (set -x; kubectl get --all-namespaces svc >> $DATA/all-services.txt 2>&1) >>$LOG 2>&1
526 espin - $VERIFIED
527 bspin - "Dumping Kubernetes EVENTs"
528 (set -x; kubectl get --all-namespaces events >> $DATA/all-events.txt 2>&1) >>$LOG 2>&1
529 espin - $VERIFIED
530 bspin - "Dumping VOLTHA POD details"
531 PODS=$(kubectl get -n voltha pod -o name)
532 for POD in $PODS; do
533 sspin - "Dumping VOLTHA POD details: $POD$CEOL"
534 mkdir -p $DATA/$POD
535 (set -x; kubectl describe -n voltha $POD >> $DATA/$POD/describe.txt 2>&1) >>$LOG 2>&1
536 sspin - "Dumping VOLTHA POD details: $POD"
537 (set -x; kubectl logs -n voltha --all-containers --previous $LOG_ARGS $POD >> $DATA/$POD/logs-previous.txt 2>&1) >>$LOG 2>&1
538 sspin - "Dumping VOLTHA POD details: $POD"
539 (set -x; kubectl logs -n voltha --all-containers $LOG_ARGS $POD >> $DATA/$POD/logs-current.txt 2>&1) >>$LOG 2>&1
540 sspin - "Dumping VOLTHA POD details: $POD"
541 done
542 espin - "$VERIFIED Dumping VOLTHA POD details$CEOL"
543 bspin - "Dumping ETCD"
544 if [ "$(which etcdctl) X" != " X" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000545 (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 +0000546 espin - $VERIFIED
547 else
548 espin - "$NO_ENTRY Dumping ETCD: etcdctl command not available"
549 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000550 bspin - "Creating compressed TAR: voltha-debug-dump-$NAME-$TS.tgz"
551 (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 +0000552 espin - $VERIFIED
553 bspin - "Cleanup"
554 (set -x; rm -rf $WORK) >>$LOG 2>&1
555 espin - $VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +0000556 bspin - "$(ls -l voltha-debug-dump-$NAME-$TS.tgz)"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000557 espin - $VERIFIED
558 exit
559fi
560
561
David Bainbridge0774b232019-08-02 06:37:19 +0000562LOG="install-$NAME.log"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000563date > $LOG
David Bainbridge0774b232019-08-02 06:37:19 +0000564echo "PORTS=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT" >> $LOG
David Bainbridgeac7f8072019-08-01 22:15:33 +0000565
566# Output install options to log
567echo "OPTIONS" >> $LOG
David Bainbridgee87067b2019-08-12 22:00:12 +0000568ALL_OPTIONS="NAME TYPE WITH_TIMINGS WITH_BBSIM WITH_RADIUS WITH_ONOS WITH_TP JUST_K8S DEPLOY_K8S \
David Bainbridge27790d62019-08-13 22:43:19 +0000569 INSTALL_ONOS_APPS SKIP_RESTART_API INSTALL_KUBECTL INSTALL_HELM USE_GO VOLTHA_LOG_LEVEL \
David Bainbridgeac7f8072019-08-01 22:15:33 +0000570 VOLTHA_CHART VOLTHA_ADAPTER_SIM_CHART VOLTHA_ADAPTER_OPEN_OLT_CHART \
David Bainbridge27790d62019-08-13 22:43:19 +0000571 VOLTHA_ADAPTER_OPEN_ONU_CHART ONOS_TAG \
David Bainbridge0774b232019-08-02 06:37:19 +0000572 ONOS_API_PORT ONOS_SSH_PORT VOLTHA_API_PORT VOLTHA_SSH_PORT VOLTHA_ETCD_PORT"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000573for O in $ALL_OPTIONS; do
574 VAL=$(eval echo \$$O)
575 if [ $O == "USE_GO" ]; then
576 VAL="$(echo $VAL| test $(grep -c true) -eq 1 && echo yes || echo no)"
577 fi
578 if [ ! -z "$VAL" ]; then
579 printf " %-30s = %s\n" $O $VAL >> $LOG
580 fi
581done
582
David Bainbridged31d6122019-08-13 19:37:59 +0000583push_onos_config() {
584 local MSG=$1
585 local RESOURCE=$2
586 local DATA=$3
587
588 bspin - "$MSG $GEAR"
589 until test; do
590 (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
591 if [ $? -eq 0 ]; then
592 break
593 fi
594 sleep .2
595 sspin -
596 done
597 espin - $VERIFIED
598}
David Bainbridgeac7f8072019-08-01 22:15:33 +0000599
David Bainbridge27790d62019-08-13 22:43:19 +0000600override_onos_app() {
601 local APP=$1
602 local NAME=$(basename $APP | sed -e 's/-.*$//g')
603 until test; do
604 sspin -
605 # Attempt to delete old version (if it exists)
606 (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
607 sspin -
608 (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
609 if [ $? -eq 0 ]; then
610 break
611 fi
612 sleep .2
613 done
614}
615
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700616count_pods() {
617 local NAMESPACE=$1; shift
618 local PODS=$(kubectl -n $NAMESPACE get pod -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}")
619 local COUNT=0
620 local PATTERNS=$*
621 for POD in $PODS; do
622 local NAME=$(echo $POD | cut -d/ -f 1)
623 local STATE=$(echo $POD | cut -d/ -f 2)
624 local CONTAINERS=$(echo $POD | cut -d/ -f 3 | sed -e 's/_/ /g')
625 if [ "$STATE" == "Running" ]; then
626 local TOTAL=$(echo $CONTAINERS | wc -w)
627 local FOUND=$(echo $CONTAINERS | grep -o true | wc -l)
628 if [ $TOTAL -eq $FOUND ]; then
629 for PATTERN in $PATTERNS; do
630 if [[ $NAME =~ $PATTERN ]]; then
631 COUNT=$(expr $COUNT + 1)
632 fi
633 done
634 fi
635 fi
636 done
637 echo $COUNT
638}
639
640wait_for_pods() {
641 local INDENT=
642 if [ "$1" == "-" ]; then
643 INDENT=$1; shift
644 fi
645 local NAMESPACE=$1; shift
646 local EXPECT=$1; shift
647 local RETRY=$1; shift
648 local MESSAGE=$1; shift
649 local PATTERNS=$*
650 local HAVE=$(count_pods $NAMESPACE $PATTERNS)
651 COUNT=$(expr 300 / 15)
652 bspin $INDENT $MESSAGE
653 sspin $INDENT
654 if [ $HAVE -ne $EXPECT ]; then
655 while [ $HAVE -ne $EXPECT ]; do
656 sspin $INDENT
657 COUNT=$(expr $COUNT - 1)
658 if [ $COUNT -eq 0 ]; then
659 HAVE=$(count_pods $NAMESPACE $PATTERNS)
660 COUNT=$(expr 300 / 15)
661 fi
662 sleep .15
663 done
664 fi
665 espin $INDENT $VERIFIED
666 if [ $HAVE -ne $EXPECT ]; then
667 return 1
668 fi
669 return 0
670}
671
672helm_install() {
673 local INDENT=
674 if [ "$1" == "-" ]; then
675 INDENT=$1; shift
676 fi
677 local NAMESPACE=$1; shift
David Bainbridge0774b232019-08-02 06:37:19 +0000678 local INAME=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700679 local CHART=$1; shift
680 local MESSAGE=$*
681
682 COUNT=$(expr 300 / 15)
683 bspin $INDENT $MESSAGE
David Bainbridge458bb662019-08-02 20:04:23 +0000684 (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 -0700685 SUCCESS=$?
686 while [ $SUCCESS -ne 0 ]; do
687 sspin $INDENT
688 COUNT=$(expr $COUNT - 1)
689 if [ $COUNT -eq 0 ]; then
David Bainbridge458bb662019-08-02 20:04:23 +0000690 (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 -0700691 COUNT=$(expr 300 / 15)
692 fi
693 sleep .15
694 done
695 espin $INDENT $VERIFIED
696}
697
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700698echo "INSTALL TYPE: $TYPE" >> $LOG
699
700bspin "Verify GOPATH"
701export GOPATH=$(pwd)
Test User3d7ad8e2019-07-03 06:15:44 +0000702mkdir -p $GOPATH/bin
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700703espin $VERIFIED
704
David Bainbridgee87067b2019-08-12 22:00:12 +0000705STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700706if [ "$INSTALL_KUBECTL" == "no" ]; then
707 bspin "Skip kubectl install"
708 espin $NO_ENTRY
Test Userc13bdc92019-07-03 20:57:49 +0000709else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700710 bspin "Verify kubectl $HELM"
711 if [ -x $GOPATH/bin/kubectl ]; then
712 espin $VERIFIED
713 else
714 espin $NOT_VERIFIED
715 bspin - "Download and install Kubernetes/kubectl $DOWNLOAD"
716 (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
717 (set -x; chmod 755 $GOPATH/bin/kubectl >>$LOG 2>&1) >>$LOG 2>&1
718 espin - $VERIFIED
719 fi
Test Userc13bdc92019-07-03 20:57:49 +0000720fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000721if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000722 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000723fi
Test Userc13bdc92019-07-03 20:57:49 +0000724
David Bainbridgee87067b2019-08-12 22:00:12 +0000725STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700726if [ "$DEPLOY_K8S" == "no" ]; then
727 bspin "Skip Kubernetes/Kind Deployment"
728 espin $NO_ENTRY
729else
Test Userba1e7e72019-07-10 22:27:54 +0000730 bspin "Verify Kubernetes/Kind $HELM"
731 if [ -x $GOPATH/bin/kind ]; then
732 espin $VERIFIED
733 else
734 espin $NOT_VERIFIED
735 bspin - "Download and install Kubernetes/kind $DOWNLOAD"
David Bainbridge9e2a6662019-07-11 17:07:57 +0000736 (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 +0000737 (set -x; chmod 755 $GOPATH/bin/kind >>$LOG 2>&1) >>$LOG 2>&1
738 espin - $VERIFIED
739 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700740fi
741
David Bainbridgee87067b2019-08-12 22:00:12 +0000742if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000743 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000744fi
745
746STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700747if [ "$INSTALL_HELM" == "no" ]; then
748 bspin "Skip Helm Install"
749 espin $NO_ENTRY
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700750else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700751 bspin "Verify Helm $HELM"
752 if [ -x $GOPATH/bin/helm ]; then
753 espin $VERIFIED
754 else
755 espin $NOT_VERIFIED
756 bspin - "Download and install Helm $DOWNLOAD"
757 (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
758 espin - $VERIFIED
759 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700760fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000761if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000762 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000763fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700764
David Bainbridgee87067b2019-08-12 22:00:12 +0000765STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +0000766bspin "Verify voltctl $HIGH_VOLTAGE"
Test User3d7ad8e2019-07-03 06:15:44 +0000767if [ -x $GOPATH/bin/voltctl ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700768 espin $VERIFIED
769else
770 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000771 bspin - "Download and build voltctl $DOWNLOAD"
Test Userba1e7e72019-07-10 22:27:54 +0000772 (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 +0000773 (set -x; chmod 755 $GOPATH/bin/voltctl >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700774 espin - $VERIFIED
775fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000776if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000777 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000778fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700779
780bspin "Verify command PATH"
Test Userba1e7e72019-07-10 22:27:54 +0000781export PATH=$GOPATH/bin:$PATH
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700782espin $VERIFIED
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700783
David Bainbridgee87067b2019-08-12 22:00:12 +0000784STIME=$(date +%s)
Test Userba1e7e72019-07-10 22:27:54 +0000785if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000786 HAVE=$(kind get clusters | grep -c voltha-$NAME)
Test Userba1e7e72019-07-10 22:27:54 +0000787 bspin "Verify Kubernetes/Kind Cluster"
788 sspin
789 if [ $HAVE -eq 0 ]; then
David Bainbridge491b1bd2019-07-11 17:53:11 +0000790 espin $NOT_VERIFIED
791 bspin - "Verify cluster configuration"
David Bainbridge0774b232019-08-02 06:37:19 +0000792 if [ ! -r ./$NAME-cluster.cfg ]; then
David Bainbridge491b1bd2019-07-11 17:53:11 +0000793 espin - $NOT_VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +0000794 bspin - "Download cluster configuration: $TYPE-cluster.cfg to $NAME-cluster.cfg $DOWNLOAD"
795 (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 -0700796 espin - $VERIFIED
797 else
798 espin - $VERIFIED
799 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000800 kind create cluster --name voltha-$NAME --config $NAME-cluster.cfg
David Bainbridge491b1bd2019-07-11 17:53:11 +0000801 else
802 espin $VERIFIED
Test Userba1e7e72019-07-10 22:27:54 +0000803 fi
804
David Bainbridge0774b232019-08-02 06:37:19 +0000805 export KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$NAME")"
Test Userba1e7e72019-07-10 22:27:54 +0000806 P="coredns-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000807 etcd-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +0000808 kindnet-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000809 kube-apiserver-voltha-$NAME-control-plane \
810 kube-controller-manager-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +0000811 kube-proxy-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000812 kube-scheduler-voltha-$NAME-control-plane"
Test Userba1e7e72019-07-10 22:27:54 +0000813
814 EXPECT=$(test "$TYPE" == "minimal" && echo "12" || echo "14")
815 wait_for_pods - "kube-system" $EXPECT -1 "Waiting for system PODs to start" $P
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700816fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000817if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000818 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000819fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700820
David Bainbridgee87067b2019-08-12 22:00:12 +0000821STIME=$(date +%s)
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700822COUNT=$(count_pods "kube-system" "tiller-deploy-.*")
823bspin "Verify Helm"
Test Userba1e7e72019-07-10 22:27:54 +0000824if [ $COUNT -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700825 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000826 echo -e "Configuring Helm $GEAR"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700827 if [ "$INSTALL_HELM" == "no" ]; then
828 bspin - "Skip Helm/Tiller Initialization"
829 espin - $NO_ENTRY
830 else
831 bspin - "Initialize Helm"
832 (set -x; helm init --upgrade >>$LOG 2>&1) >>$LOG 2>&1
833 espin - $VERIFIED
834 wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
835 fi
Test Userb5712372019-07-03 21:52:17 +0000836 bspin - "Add Google Incubator repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700837 (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
838 espin - $VERIFIED
Test Userba1e7e72019-07-10 22:27:54 +0000839
840 # HACK (sort-of) - the config for tiller is about to be patched, which will
841 # cause the tiller pod to be recreated. This can sometimes cause a timing
842 # issue with the "wait_for_pods" call on tiller as it may incorrectly
843 # identify the running/ready tiller pod that is soon to be terminated as
844 # what it is waiting for. To avoid this issue we do a clean scale down and
845 # scale up of the pod so the script controlls when it should be expecting
846 # things
847 (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 -0700848
Test Userb5712372019-07-03 21:52:17 +0000849 bspin - "Add Google Stable repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700850 (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
851 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000852 bspin - "Add ONF repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700853 (set -x; helm repo add onf https://charts.opencord.org >>$LOG 2>&1) >>$LOG 2>&1
854 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000855 bspin - "Update Helm repository cache"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700856 (set -x; helm repo update >>$LOG 2>&1) >>$LOG 2>&1
857 espin - $VERIFIED
858
859 # Create and k8s service account so that Helm can create pods
Test Userb5712372019-07-03 21:52:17 +0000860 bspin - "Create Tiller ServiceAccount"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700861 (set -x; kubectl create serviceaccount --namespace kube-system tiller >>$LOG 2>&1) >>$LOG 2>&1
862 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000863 bspin - "Create Tiller ClusterRoleBinding"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700864 (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>$LOG 2>&1) >>$LOG 2>&1
865 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000866 bspin - "Update Tiller Manifest"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700867 (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 +0000868
869 # HACK (sort-of) - part to, spin it back up
870 (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 -0700871 espin - $VERIFIED
872else
873 espin $VERIFIED
874fi
Test Userb5712372019-07-03 21:52:17 +0000875wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +0000876if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000877 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000878fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700879
David Bainbridgee87067b2019-08-12 22:00:12 +0000880STIME=$(date +%s)
David Bainbridge0774b232019-08-02 06:37:19 +0000881bspin "Verify Helm values file: $NAME-values.yaml"
882if [ ! -r "./$NAME-values.yaml" ]; then
Test Userba1e7e72019-07-10 22:27:54 +0000883 espin $NOT_VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +0000884 bspin - "Download Helm values file: $TYPE-values.yaml to $NAME-values.yaml $DOWNLOAD"
885 (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 +0000886 espin - $VERIFIED
887else
888 espin $VERIFIED
889fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000890if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000891 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000892fi
Test Userba1e7e72019-07-10 22:27:54 +0000893
894if [ "$JUST_K8S" == "yes" ]; then
895 echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye."
896 echo ""
897 echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
898 echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
899 echo "tools required by VOLTHA in your command path. " | tee -a $LOG
900 echo "" | tee -a $LOG
901 echo -en $BOLD
902 if [ $DEPLOY_K8S == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000903 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +0000904 fi
905 echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
906 echo -en $NORMAL
907 echo "" | tee -a $LOG
908 echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
909 exit 0
910fi
911
David Bainbridgee87067b2019-08-12 22:00:12 +0000912STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +0000913bspin "Verify ETCD Operator $OLD_KEY"
Test User7d866122019-07-09 17:52:35 +0000914if [ $(helm list --deployed --short --namespace voltha "^etcd-operator\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700915 espin $NOT_VERIFIED
916 helm_install - voltha etcd-operator stable/etcd-operator "Install ETCD Operator"
917else
918 espin $VERIFIED
919fi
Test User01ed0642019-07-03 20:17:06 +0000920EXPECT=$(test "$TYPE" == "minimal" && echo "1" || echo "3")
Test Userb5712372019-07-03 21:52:17 +0000921wait_for_pods - "voltha" $EXPECT -1 "Waiting for ETCD Operator to start" "etcd-operator-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +0000922if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000923 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000924fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700925
David Bainbridgee87067b2019-08-12 22:00:12 +0000926STIME=$(date +%s)
David Bainbridgeb270c202019-07-26 01:44:42 +0000927if [ $WITH_ONOS == "yes" ]; then
928 bspin "Verify ONOS installed $BIRD"
929 if [ $(helm list --deployed --short --namespace default "^onos\$" | wc -l) -ne 1 ]; then
930 espin $NOT_VERIFIED
David Bainbridge27790d62019-08-13 22:43:19 +0000931 SET_TAG=
932 if [ "$ONOS_TAG X" != " X" ]; then
933 SET_TAG="--set images.onos.tag=$ONOS_TAG"
934 fi
935 EXTRA_HELM_FLAGS="$SET_TAG $EXTRA_HELM_FLAGS" helm_install - default onos onf/onos "Install ONOS"
David Bainbridgeb270c202019-07-26 01:44:42 +0000936 else
937 espin $VERIFIED
938 fi
939 wait_for_pods - "default" 1 -1 "Waiting for ONOS to start" "onos-.*"
940
941 bspin - "Forward ONOS API port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +0000942 for i in $(screen -ls | grep onos-ui-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +0000943 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
944 done
David Bainbridge0774b232019-08-02 06:37:19 +0000945 (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 +0000946 espin - $VERIFIED
947 bspin - "Forward ONOS SSH port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +0000948 for i in $(screen -ls | grep onos-ssh-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +0000949 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
950 done
David Bainbridge0774b232019-08-02 06:37:19 +0000951 (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 +0000952 espin - $VERIFIED
David Bainbridged31d6122019-08-13 19:37:59 +0000953 bspin - "Verify or download ONOS configuration support files $DOWNLOAD"
954 (set -x; mkdir -p ./onos-files >>$LOG 2>&1) >>$LOG 2>&1
955 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
956 if [ ! -r ./onos-files/$i ]; then
957 (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
958 fi
959 done
Test Userba1e7e72019-07-10 22:27:54 +0000960 espin - $VERIFIED
David Bainbridge27790d62019-08-13 22:43:19 +0000961
962 if [ $INSTALL_ONOS_APPS == "yes" ]; then
963 bspin - "Installing custom ONOS applications"
964 if [ -x onos-files/onos-apps -a $(ls -1 onos-files/onos-apps/*.oar 2>/dev/null | wc -l) -gt 0 ]; then
965 for OAR in $(ls -1 onos-files/onos-apps/*.oar); do
966 sspin - "Installing custom ONOS applications - $OAR$CEOL"
967 override_onos_app $OAR
968 done
969 espin - "$VERIFIED Installing custom ONOS applications$CEOL"
970 else
971 espin - "$NOT_VERIFIED Installing custom ONOS applications - None Found"
972 fi
973 fi
David Bainbridged31d6122019-08-13 19:37:59 +0000974
975 push_onos_config "Push ONOS Network Configuration" "network/configuration" "onos-files/olt-onos-netcfg.json"
976 push_onos_config "Enable VOLTHA ONOS DHCP provisioning" "configuration/org.opencord.olt.impl.Olt" "onos-files/olt-onos-olt-settings.json"
977 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 +0000978fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000979if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000980 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000981fi
Test Userba1e7e72019-07-10 22:27:54 +0000982
David Bainbridgee87067b2019-08-12 22:00:12 +0000983STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +0000984bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
Test User7d866122019-07-09 17:52:35 +0000985if [ $(helm list --deployed --short --namespace voltha "^voltha\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700986 espin $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +0000987 helm_install - voltha voltha $VOLTHA_CHART "Install VOLTHA Core"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700988else
989 espin $VERIFIED
990fi
Test Userba1e7e72019-07-10 22:27:54 +0000991
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700992VOLTHA="ofagent-.* \
993 ro-core.* \
994 rw-core.* \
995 voltha-api-server-.* \
996 voltha-cli-server-.* \
997 voltha-etcd-cluster-.* \
998 voltha-kafka-.* \
999 voltha-zookeeper-.*"
Test User01ed0642019-07-03 20:17:06 +00001000EXPECT=$(test "$TYPE" == "minimal" && echo "9" || echo "11")
Test Userb5712372019-07-03 21:52:17 +00001001wait_for_pods - "voltha" $EXPECT -1 "Waiting for VOLTHA Core to start" $VOLTHA
David Bainbridgee87067b2019-08-12 22:00:12 +00001002if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001003 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001004fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001005
David Bainbridgee87067b2019-08-12 22:00:12 +00001006STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +00001007echo -e "Verify Adapters $PLUG"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001008bspin - "Verify Simulated Adapters installed"
Test User7d866122019-07-09 17:52:35 +00001009if [ $(helm list --deployed --short --namespace voltha "^sim\$" | 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 sim $VOLTHA_ADAPTER_SIM_CHART "Install Simulated Adapters"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001012else
1013 espin - $VERIFIED
1014fi
1015
1016bspin - "Verify OpenOLT Adapter installed"
Test User7d866122019-07-09 17:52:35 +00001017if [ $(helm list --deployed --short --namespace voltha "^open-olt\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001018 espin - $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +00001019 helm_install - voltha open-olt $VOLTHA_ADAPTER_OPEN_OLT_CHART "Install OpenOLT Adapter"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001020else
1021 espin - $VERIFIED
1022fi
1023bspin - "Verify OpenONU Adapter installed"
Test User7d866122019-07-09 17:52:35 +00001024if [ $(helm list --deployed --short --namespace voltha "^open-onu\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001025 espin - $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +00001026 helm_install - voltha open-onu $VOLTHA_ADAPTER_OPEN_ONU_CHART "Install OpenONU Adapter"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001027else
1028 espin - $VERIFIED
1029fi
1030
1031ADAPTERS="adapter-.*"
Test Userb5712372019-07-03 21:52:17 +00001032wait_for_pods - "voltha" 4 -1 "Waiting for adapters to start" $ADAPTERS
David Bainbridgee87067b2019-08-12 22:00:12 +00001033if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001034 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001035fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001036
Test User7d866122019-07-09 17:52:35 +00001037if [ $WITH_BBSIM == "yes" ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +00001038 STIME=$(date +%s)
Test User7d866122019-07-09 17:52:35 +00001039 echo -e "Verify BBSIM $PLUG"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001040 bspin - "Verify BBSIM Installed"
Test User7d866122019-07-09 17:52:35 +00001041 if [ $(helm list --deployed --short --namespace voltha "^bbsim\$" | wc -l) -ne 1 ]; then
1042 espin - $NOT_VERIFIED
1043 helm_install - voltha bbsim onf/bbsim "Install BBSIM"
1044 else
1045 espin - $VERIFIED
1046 fi
1047 wait_for_pods - "voltha" 1 -1 "Waiting for BBSIM to start" "bbsim-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001048 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001049 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001050 fi
Test User7d866122019-07-09 17:52:35 +00001051fi
1052
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001053if [ $WITH_RADIUS == "yes" ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +00001054 STIME=$(date +%s)
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001055 echo -e "Verify RADIUS $LOCK"
1056 bspin - "Verify RADIUS Installed"
1057 if [ $(helm list --deployed --short --namespace voltha "^radius\$" | wc -l) -ne 1 ]; then
1058 espin - $NOT_VERIFIED
1059 helm_install - voltha radius onf/freeradius "Install RADIUS"
1060 else
1061 espin - $VERIFIED
1062 fi
1063 wait_for_pods - "voltha" 1 -1 "Waiting for RADIUS to start" "radius-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001064 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001065 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001066 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001067fi
1068
David Bainbridgee87067b2019-08-12 22:00:12 +00001069STIME=$(date +%s)
David Bainbridgee10f6d52019-07-25 00:28:13 +00001070if [ $SKIP_RESTART_API == "no" ]; then
1071 echo -e "Restart VOLTHA API $RESTART"
1072 API="voltha-api-server-.* ofagent-.*"
1073 (set -x; kubectl scale --replicas=0 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1
1074 wait_for_pods - "voltha" 0 -1 "Wait for API to stop $STOP" $API
1075 (set -x; kubectl scale --replicas=1 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1
1076 wait_for_pods - "voltha" 2 -1 "Wait for API to re-start $GO" $API
1077else
1078 bspin "Skip VOLTHA API Restart"
1079 espin $NO_ENTRY
1080fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001081
Test Userb5712372019-07-03 21:52:17 +00001082bspin - "Forward VOLTHA API port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +00001083for i in $(screen -ls | grep voltha-api-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +00001084 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
1085done
David Bainbridge0774b232019-08-02 06:37:19 +00001086(set -x; screen -dmS voltha-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 -07001087espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +00001088bspin - "Forward VOLTHA SSH port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +00001089for i in $(screen -ls | grep voltha-ssh-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +00001090 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
1091done
David Bainbridge0774b232019-08-02 06:37:19 +00001092(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 -07001093espin - $VERIFIED
David Bainbridgeac7f8072019-08-01 22:15:33 +00001094bspin - "Forward VOLTHA ETCD port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +00001095for i in $(screen -ls | grep voltha-etcd-$NAME | awk '{print $1}'); do
David Bainbridgeac7f8072019-08-01 22:15:33 +00001096 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
1097done
David Bainbridge0774b232019-08-02 06:37:19 +00001098(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 +00001099espin - $VERIFIED
David Bainbridgee87067b2019-08-12 22:00:12 +00001100if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001101 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001102fi
Test User3d7ad8e2019-07-03 06:15:44 +00001103
David Bainbridgeb270c202019-07-26 01:44:42 +00001104if [ $WITH_ONOS == "yes" -a $WITH_RADIUS == "yes" ]; then
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001105 bspin "Configure ONOS RADIUS Connection $GEAR"
1106 (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
1107 espin $VERIFIED
1108fi
1109
1110bspin "Create voltctl configuration file"
Test User3d7ad8e2019-07-03 06:15:44 +00001111(set -x; mkdir -p $HOME/.volt >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridge0774b232019-08-02 06:37:19 +00001112(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 +00001113espin $VERIFIED
Test User08ebbd92019-07-03 17:15:39 +00001114
David Bainbridge0774b232019-08-02 06:37:19 +00001115if [ ! -f "$NAME-env.sh" ]; then
1116 touch $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001117fi
1118
David Bainbridge596f30d2019-07-30 17:07:59 +00001119for O in $ALL_OPTIONS; do
1120 VAL=$(eval echo \$$O)
1121 if [ $O == "USE_GO" ]; then
1122 VAL="$(echo $VAL| test $(grep -c true) -eq 1 && echo yes || echo no)"
1123 fi
David Bainbridge0774b232019-08-02 06:37:19 +00001124 if [ ! -z "$VAL" -a $(grep -c "^export $O=" $NAME-env.sh) -eq 0 ]; then
1125 echo "export $O=\"$(eval echo \$$O)\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001126 fi
1127done
1128
David Bainbridge0774b232019-08-02 06:37:19 +00001129if [ $DEPLOY_K8S == "yes" -a $(grep -c "^export KUBECONFIG=" $NAME-env.sh) -eq 0 ]; then
1130 echo "export KUBECONFIG=\"$(./bin/kind get kubeconfig-path --name=voltha-$NAME)\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001131fi
1132
David Bainbridge0774b232019-08-02 06:37:19 +00001133if [ $(grep -c "^export VOLTCONFIG=" $NAME-env.sh) -eq 0 ]; then
1134 echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001135fi
1136
David Bainbridge0774b232019-08-02 06:37:19 +00001137if [ $(grep -c "^export PATH=" $NAME-env.sh) -eq 0 ]; then
1138 echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001139fi
1140
Test User7d866122019-07-09 17:52:35 +00001141echo ""
Test User08ebbd92019-07-03 17:15:39 +00001142echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
1143echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
1144echo "tools required by VOLTHA in your command path. " | tee -a $LOG
1145echo "" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +00001146echo -en $BOLD
Test Userba1e7e72019-07-10 22:27:54 +00001147if [ $DEPLOY_K8S == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001148 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +00001149fi
David Bainbridge0774b232019-08-02 06:37:19 +00001150echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +00001151echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +00001152echo -en $NORMAL
Test User08ebbd92019-07-03 17:15:39 +00001153echo "" | tee -a $LOG
1154echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
1155
David Bainbridge712afb82019-08-14 19:55:58 +00001156if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridgef858a022019-08-14 21:25:11 +00001157 echo -e "$CLOCK ${BOLD}TOTAL: $(duration $(expr $(date +%s) - $TOTAL_START_TIME))${NORMAL}"
David Bainbridge712afb82019-08-14 19:55:58 +00001158fi
1159