blob: 04cd2ff3ceadc1cdace0c00513227f682c075070 [file] [log] [blame]
Test User01ed0642019-07-03 20:17:06 +00001#!/bin/bash
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002# Copyright 2019 Ciena Corporation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16# trap ctrl-c and call ctrl_c()
17trap ctrl_c INT
18
19function ctrl_c() {
20 tput cnorm
21 echo ""
22 echo "ctrl-c trapped"
23 echo "Thank you for trying 'votlha up'"
24 exit
25}
26
Test User08ebbd92019-07-03 17:15:39 +000027VOLTCTL_VERSION=${VOLTCTL_VERSION:-0.0.5-dev}
28KIND_VERSION=${KIND_VERSION:-v0.4.0}
29_VOLTCTL_VERSION=$(echo $VOLTCTL_VERSION | sed -e 's/-/_/g')
30
Test User7d866122019-07-09 17:52:35 +000031BLACK=$(tput setaf 0)
32RED=$(tput setaf 1)
33GREEN=$(tput setaf 2)
34YELLOW=$(tput setaf 3)
35BLUE=$(tput setaf 4)
36MAGENTA=$(tput setaf 5)
37CYAN=$(tput setaf 6)
38WHITE=$(tput setaf 7)
39BOLD=$(tput bold)
40NORMAL=$(tput sgr0)
41ERROR="\xe2\x9c\x97\x20"
42
Test User3d7ad8e2019-07-03 06:15:44 +000043TYPE=${TYPE:-minimal}
Test User7d866122019-07-09 17:52:35 +000044WITH_BBSIM=${WITH_BBSIM:-no}
David Bainbridge5b7b96b2019-07-25 20:29:13 +000045WITH_RADIUS=${WITH_RADIUS:-no}
David Bainbridgeb270c202019-07-26 01:44:42 +000046WITH_ONOS=${WITH_ONOS:-yes}
David Bainbridge01294952019-07-30 19:33:45 +000047WITH_TP=${WITH_TP:-yes}
Test Userba1e7e72019-07-10 22:27:54 +000048JUST_K8S=${JUST_K8S:-no}
49DEPLOY_K8S=${DEPLOY_K8S:-yes}
David Bainbridgee10f6d52019-07-25 00:28:13 +000050SKIP_RESTART_API=${SKIP_RESTART_API:-no}
David K. Bainbridge0e89cb92019-07-17 11:30:10 -070051INSTALL_KUBECTL=${INSTALL_KUBECTL:-yes}
52INSTALL_HELM=${INSTALL_HELM:-yes}
David Bainbridge5b7b96b2019-07-25 20:29:13 +000053USE_GO=${USE_GO:-yes}
54VOLTHA_LOG_LEVEL=${VOLTHA_LOG_LEVEL:-WARN}
David Bainbridgee10f6d52019-07-25 00:28:13 +000055VOLTHA_CHART=${VOLTHA_CHART:=onf/voltha}
56VOLTHA_ADAPTER_SIM_CHART=${VOLTHA_ADAPTER_SIM_CHART:-onf/voltha-adapter-simulated}
57VOLTHA_ADAPTER_OPEN_OLT_CHART=${VOLTHA_ADAPTER_OPEN_OLT_CHART:-onf/voltha-adapter-openolt}
58VOLTHA_ADAPTER_OPEN_ONU_CHART=${VOLTHA_ADAPTER_OPEN_ONU_CHART:-onf/voltha-adapter-openonu}
Test Userba1e7e72019-07-10 22:27:54 +000059
60HAVE_GO=$(which go >/dev/null 2>&1 && echo "yes" || echo "no")
61HOSTOS=$(uname -s | tr "[:upper:]" "[:lower:"])
62HOSTARCH=$(uname -m | tr "[:upper:]" "[:lower:"])
63if [ $HOSTARCH == "x86_64" ]; then
64 HOSTARCH="amd64"
65fi
Test User7d866122019-07-09 17:52:35 +000066
67# Verify TYPE setting
68if [ $(echo ":minimal:full:" | grep -ic ":$TYPE:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -070069 >&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 +000070 exit 1
71fi
72
73# Verify WITH_BBSIM settting and convert uniform value of yes or no
74if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_BBSIM:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -070075 >&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 +000076 exit 1
77fi
78if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_BBSIM:") -eq 1 ]; then
79 WITH_BBSIM=yes
80else
81 WITH_BBSIM=no
82fi
83
David Bainbridge5b7b96b2019-07-25 20:29:13 +000084# Verify WITH_RADIUS settting and convert uniform value of yes or no
85if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_RADIUS:") -eq 0 ]; then
86 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_RADIUS value of '$WITH_RADIUS'. Should be 'yes' or 'no'${NORMAL}"
87 exit 1
88fi
89if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_RADIUS:") -eq 1 ]; then
90 WITH_RADIUS=yes
91else
92 WITH_RADIUS=no
93fi
94
David Bainbridge01294952019-07-30 19:33:45 +000095# Verify WITH_TP settting and convert uniform value of yes or no
96if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_TP:") -eq 0 ]; then
97 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_TP value of '$WITH_TP'. Should be 'yes' or 'no'${NORMAL}"
98 exit 1
99fi
100if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_TP:") -eq 1 ]; then
101 WITH_TP=yes
102else
103 WITH_TP=no
104fi
105
David Bainbridgeb270c202019-07-26 01:44:42 +0000106# Verify WITH_ONOS settting and convert uniform value of yes or no
107if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_ONOS:") -eq 0 ]; then
108 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_ONOS value of '$WITH_ONOS'. Should be 'yes' or 'no'${NORMAL}"
109 exit 1
110fi
111if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_ONOS:") -eq 1 ]; then
112 WITH_ONOS=yes
113else
114 WITH_ONOS=no
115fi
116
Test Userba1e7e72019-07-10 22:27:54 +0000117# Verify JUST_K8S settting and convert uniform value of yes or no
118if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$JUST_K8S:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700119 >&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 +0000120 exit 1
121fi
122if [ $(echo ":y:yes:true:1:" | grep -ic ":$JUST_K8S:") -eq 1 ]; then
123 JUST_K8S=yes
124else
125 JUST_K8S=no
126fi
127
128# Verify DEPLOY_K8S settting and convert uniform value of yes or no
129if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$DEPLOY_K8S:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700130 >&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 +0000131 exit 1
132fi
133if [ $(echo ":y:yes:true:1:" | grep -ic ":$DEPLOY_K8S:") -eq 1 ]; then
134 DEPLOY_K8S=yes
135else
136 DEPLOY_K8S=no
137fi
Test User01ed0642019-07-03 20:17:06 +0000138
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700139# Verify INSTALL_KUBECTL settting and convert uniform value of yes or no
140if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$INSTALL_KUBECTL:") -eq 0 ]; then
141 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$INSTALL_KUBECTL value of '$INSTALL_KUBECTL'. Should be 'yes' or 'no'${NORMAL}"
142 exit 1
143fi
144
145if [ $(echo ":y:yes:true:1:" | grep -ic ":$INSTALL_KUBECTL:") -eq 1 ]; then
146 INSTALL_KUBECTL=yes
147else
148 INSTALL_KUBECTL=no
149fi
150
David Bainbridgee10f6d52019-07-25 00:28:13 +0000151# Verify SKIP_RESTART_API settting and convert uniform value of yes or no
152if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$SKIP_RESTART_API:") -eq 0 ]; then
153 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$SKIP_RESTART_API value of '$SKIP_RESTART_API'. Should be 'yes' or 'no'${NORMAL}"
154 exit 1
155fi
156if [ $(echo ":y:yes:true:1:" | grep -ic ":$SKIP_RESTART_API:") -eq 1 ]; then
157 SKIP_RESTART_API=yes
158else
159 SKIP_RESTART_API=no
160fi
161
David Bainbridge1ceabc12019-07-25 17:21:05 +0000162# Verify USE_GO settting and convert uniform value of yes or no
163if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$USE_GO:") -eq 0 ]; then
164 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$USE_GO value of '$USE_GO'. Should be 'yes' or 'no'${NORMAL}"
165 exit 1
166fi
167if [ $(echo ":y:yes:true:1:" | grep -ic ":$USE_GO:") -eq 1 ]; then
168 USE_GO=true
169else
170 USE_GO=false
171fi
172
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700173# Verify INSTALL_HELM settting and convert uniform value of yes or no
174if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$INSTALL_HELM:") -eq 0 ]; then
175 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$INSTALL_HELM value of '$INSTALL_HELM'. Should be 'yes' or 'no'${NORMAL}"
176 exit 1
177fi
178
179if [ $(echo ":y:yes:true:1:" | grep -ic ":$INSTALL_HELM:") -eq 1 ]; then
180 INSTALL_HELM=yes
181else
182 INSTALL_HELM=no
183fi
184
Test User01ed0642019-07-03 20:17:06 +0000185if [ "$TYPE" == "full" ]; then
David Bainbridge01294952019-07-30 19:33:45 +0000186 ONOS_API_PORT=${ONOS_API_PORT:-8182}
187 ONOS_SSH_PORT=${ONOS_SSH_PORT:-8102}
188 VOLTHA_API_PORT=${VOLTHA_API_PORT:-55556}
189 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-5023}
Test User01ed0642019-07-03 20:17:06 +0000190else
191 ONOS_API_PORT=${ONOS_API_PORT:-8181}
192 ONOS_SSH_PORT=${ONOS_SSH_PORT:-8101}
193 VOLTHA_API_PORT=${VOLTHA_API_PORT:-55555}
194 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-5022}
195fi
196
David Bainbridge01294952019-07-30 19:33:45 +0000197if [ "$WITH_TP" == "yes" ]; then
198 SADIS_VER=3.1.0
199 OLT_VER=3.0.1
200 AAA_VER=1.9.0
201 DHCP_VER=1.6.0
202else
203 SADIS_VER=2.2.0
204 OLT_VER=2.1.0
205 AAA_VER=1.8.0
206 DHCP_VER=1.5.0
207fi
208
209export SADIS_VER OLT_VER AAA_VER DHCP_VER
210
Test User01ed0642019-07-03 20:17:06 +0000211if [ "$1" == "get" -a "$2" == "voltconfig" ]; then
212 echo "$HOME/.volt/config-$TYPE"
213 exit
214fi
Test User3d7ad8e2019-07-03 06:15:44 +0000215
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700216if [ $# -ne 1 -o $(echo ":up:down:" | grep -c ":$1:") -ne 1 ]; then
217 >&2 echo "up or down?"
218 exit 1
219fi
220
221if [ "$1" == "down" ]; then
Test Userba1e7e72019-07-10 22:27:54 +0000222 if [ $DEPLOY_K8S == "yes" ]; then
223 if [ -x ./bin/kind ]; then
224 exec ./bin/kind delete cluster --name voltha-$TYPE
225 else
226 >&2 echo "Kind doesn't seem to be installed, so nothing to do. Bye."
227 fi
Test User08ebbd92019-07-03 17:15:39 +0000228 else
Test Userba1e7e72019-07-10 22:27:54 +0000229 EXISTS=$(helm list -q)
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000230 EXPECT="etcd-operator onos open-olt open-onu sim voltha bbsim radius"
Test Userba1e7e72019-07-10 22:27:54 +0000231 INTERSECT=
232 for i in $EXISTS; do
233 if [ $(echo $EXPECT | grep -c $i) -eq 1 ]; then
234 HAVE="$HAVE $i"
235 fi
236 done
David Bainbridge7831a662019-07-25 18:12:25 +0000237 if [ "$HAVE X" != " X" ]; then
238 ./bin/helm delete --purge $HAVE
239 fi
Test Userba1e7e72019-07-10 22:27:54 +0000240fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700241 exit
242fi
243
Test User01ed0642019-07-03 20:17:06 +0000244LOG="install-$TYPE.log"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700245date > $LOG
246
David Bainbridge1ceabc12019-07-25 17:21:05 +0000247# Output install options to log
248echo "OPTIONS" >> $LOG
David Bainbridge01294952019-07-30 19:33:45 +0000249ALL_OPTIONS="TYPE WITH_BBSIM WITH_RADIUS WITH_ONOS WITH_TP JUST_K8S DEPLOY_K8S \
David Bainbridge596f30d2019-07-30 17:07:59 +0000250 SKIP_RESTART_API INSTALL_KUBECTL INSTALL_HELM USE_GO VOLTHA_LOG_LEVEL \
251 VOLTHA_CHART VOLTHA_ADAPTER_SIM_CHART VOLTHA_ADAPTER_OPEN_OLT_CHART \
David Bainbridgeabd5a4b2019-07-30 18:33:09 +0000252 VOLTHA_ADAPTER_OPEN_ONU_CHART SADIS_VER OLT_VER AAA_VER DHCP_VER"
David Bainbridge596f30d2019-07-30 17:07:59 +0000253for O in $ALL_OPTIONS; do
254 VAL=$(eval echo \$$O)
255 if [ $O == "USE_GO" ]; then
256 VAL="$(echo $VAL| test $(grep -c true) -eq 1 && echo yes || echo no)"
257 fi
258 if [ ! -z "$VAL" ]; then
259 printf " %-30s = %s\n" $O $VAL >> $LOG
260 fi
261done
David Bainbridge1ceabc12019-07-25 17:21:05 +0000262
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700263spin() {
Test Userd87942b2019-07-03 07:20:24 +0000264 PARTS="\
265 \xe2\xa2\x8e\xe2\xa1\xb0 \
266 \xe2\xa2\x8e\xe2\xa1\xa1 \
267 \xe2\xa2\x8e\xe2\xa1\x91 \
268 \xe2\xa2\x8e\xe2\xa0\xb1 \
269 \xe2\xa0\x8e\xe2\xa1\xb1 \
270 \xe2\xa2\x8a\xe2\xa1\xb1 \
271 \xe2\xa2\x8c\xe2\xa1\xb1 \
272 \xe2\xa2\x86\xe2\xa1\xb1 \
273 "
274 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700275 tput civis
276 while true; do
Test Userd87942b2019-07-03 07:20:24 +0000277 C=$(echo $PARTS | cut '-d ' -f $IDX)
278 echo -en "$C"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700279 IDX=$(expr $IDX + 1)
Test Userd87942b2019-07-03 07:20:24 +0000280 if [ $IDX -gt 8 ]; then
281 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700282 fi
283 sleep .15
284 echo -en "\r"
285 done
286}
287
Test Userd87942b2019-07-03 07:20:24 +0000288SPIN_PARTS="\
289 \xe2\xa2\x8e\xe2\xa1\xb0 \
290 \xe2\xa2\x8e\xe2\xa1\xa1 \
291 \xe2\xa2\x8e\xe2\xa1\x91 \
292 \xe2\xa2\x8e\xe2\xa0\xb1 \
293 \xe2\xa0\x8e\xe2\xa1\xb1 \
294 \xe2\xa2\x8a\xe2\xa1\xb1 \
295 \xe2\xa2\x8c\xe2\xa1\xb1 \
296 \xe2\xa2\x86\xe2\xa1\xb1 \
297 "
298IDX=1
299NOT_VERIFIED="\xe2\x9c\x97\x20"
300VERIFIED="\xe2\x9c\x93\x20"
Test Userb5712372019-07-03 21:52:17 +0000301HELM="\xE2\x8E\x88"
302OLD_KEY="\xF0\x9F\x97\x9D"
303BIRD="\xF0\x9F\x90\xA6"
304HIGH_VOLTAGE="\xE2\x9A\xA1"
305PLUG="\xF0\x9F\xa7\xa9"
306RESTART="\xf0\x9f\x94\x84"
307FORWARD="\xE2\x87\xA8"
308INSTALL="\xF0\x9F\x8F\x97"
309STOP="\xf0\x9f\x9b\x91"
310GO="\xf0\x9f\x9a\x80"
311DOWNLOAD="\xf0\x9f\x93\xa5"
312GEAR="\xe2\x9a\x99"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700313NO_ENTRY="\xe2\x9b\x94"
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000314LOCK="\xf0\x9f\x94\x92"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700315
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700316bspin() {
317 tput civis
Test Userd87942b2019-07-03 07:20:24 +0000318 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700319 local INDENT=
320 if [ "$1" == "-" ]; then
321 INDENT=" "
322 shift
323 fi
Test Userd87942b2019-07-03 07:20:24 +0000324 echo -en "$INDENT $*"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700325}
326
327sspin() {
328 local INDENT=
329 if [ "$1" == "-" ]; then
330 INDENT=" "
331 shift
332 fi
Test Userd87942b2019-07-03 07:20:24 +0000333 C=$(echo $SPIN_PARTS | cut '-d ' -f $IDX)
334 echo -en "\r$INDENT$C $*"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700335 IDX=$(expr $IDX + 1)
Test Userd87942b2019-07-03 07:20:24 +0000336 if [ $IDX -gt 8 ]; then
337 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700338 fi
339}
340
341espin() {
342 local INDENT=
343 if [ "$1" == "-" ]; then
344 INDENT=" "
345 shift
346 fi
347 echo -e "\r$INDENT$*"
348 tput cnorm
349}
350
351count_pods() {
352 local NAMESPACE=$1; shift
353 local PODS=$(kubectl -n $NAMESPACE get pod -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}")
354 local COUNT=0
355 local PATTERNS=$*
356 for POD in $PODS; do
357 local NAME=$(echo $POD | cut -d/ -f 1)
358 local STATE=$(echo $POD | cut -d/ -f 2)
359 local CONTAINERS=$(echo $POD | cut -d/ -f 3 | sed -e 's/_/ /g')
360 if [ "$STATE" == "Running" ]; then
361 local TOTAL=$(echo $CONTAINERS | wc -w)
362 local FOUND=$(echo $CONTAINERS | grep -o true | wc -l)
363 if [ $TOTAL -eq $FOUND ]; then
364 for PATTERN in $PATTERNS; do
365 if [[ $NAME =~ $PATTERN ]]; then
366 COUNT=$(expr $COUNT + 1)
367 fi
368 done
369 fi
370 fi
371 done
372 echo $COUNT
373}
374
375wait_for_pods() {
376 local INDENT=
377 if [ "$1" == "-" ]; then
378 INDENT=$1; shift
379 fi
380 local NAMESPACE=$1; shift
381 local EXPECT=$1; shift
382 local RETRY=$1; shift
383 local MESSAGE=$1; shift
384 local PATTERNS=$*
385 local HAVE=$(count_pods $NAMESPACE $PATTERNS)
386 COUNT=$(expr 300 / 15)
387 bspin $INDENT $MESSAGE
388 sspin $INDENT
389 if [ $HAVE -ne $EXPECT ]; then
390 while [ $HAVE -ne $EXPECT ]; do
391 sspin $INDENT
392 COUNT=$(expr $COUNT - 1)
393 if [ $COUNT -eq 0 ]; then
394 HAVE=$(count_pods $NAMESPACE $PATTERNS)
395 COUNT=$(expr 300 / 15)
396 fi
397 sleep .15
398 done
399 fi
400 espin $INDENT $VERIFIED
401 if [ $HAVE -ne $EXPECT ]; then
402 return 1
403 fi
404 return 0
405}
406
407helm_install() {
408 local INDENT=
409 if [ "$1" == "-" ]; then
410 INDENT=$1; shift
411 fi
412 local NAMESPACE=$1; shift
413 local NAME=$1; shift
414 local CHART=$1; shift
415 local MESSAGE=$*
416
417 COUNT=$(expr 300 / 15)
418 bspin $INDENT $MESSAGE
David Bainbridge1ceabc12019-07-25 17:21:05 +0000419 (set -x; helm install -f $TYPE-values.yaml --set use_go=$USE_GO --set defaults.log_level=$VOLTHA_LOG_LEVEL --namespace $NAMESPACE --name $NAME $CHART >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700420 SUCCESS=$?
421 while [ $SUCCESS -ne 0 ]; do
422 sspin $INDENT
423 COUNT=$(expr $COUNT - 1)
424 if [ $COUNT -eq 0 ]; then
David Bainbridgee10f6d52019-07-25 00:28:13 +0000425 (set -x; helm install -f $TYPE-values.yaml --set defaults.log_level=$VOLTHA_LOG_LEVEL --namespace $NAMESPACE --name $NAME $CHART >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700426 COUNT=$(expr 300 / 15)
427 fi
428 sleep .15
429 done
430 espin $INDENT $VERIFIED
431}
432
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700433echo "INSTALL TYPE: $TYPE" >> $LOG
434
435bspin "Verify GOPATH"
436export GOPATH=$(pwd)
Test User3d7ad8e2019-07-03 06:15:44 +0000437mkdir -p $GOPATH/bin
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700438espin $VERIFIED
439
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700440if [ "$INSTALL_KUBECTL" == "no" ]; then
441 bspin "Skip kubectl install"
442 espin $NO_ENTRY
Test Userc13bdc92019-07-03 20:57:49 +0000443else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700444 bspin "Verify kubectl $HELM"
445 if [ -x $GOPATH/bin/kubectl ]; then
446 espin $VERIFIED
447 else
448 espin $NOT_VERIFIED
449 bspin - "Download and install Kubernetes/kubectl $DOWNLOAD"
450 (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
451 (set -x; chmod 755 $GOPATH/bin/kubectl >>$LOG 2>&1) >>$LOG 2>&1
452 espin - $VERIFIED
453 fi
Test Userc13bdc92019-07-03 20:57:49 +0000454fi
455
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700456if [ "$DEPLOY_K8S" == "no" ]; then
457 bspin "Skip Kubernetes/Kind Deployment"
458 espin $NO_ENTRY
459else
Test Userba1e7e72019-07-10 22:27:54 +0000460 bspin "Verify Kubernetes/Kind $HELM"
461 if [ -x $GOPATH/bin/kind ]; then
462 espin $VERIFIED
463 else
464 espin $NOT_VERIFIED
465 bspin - "Download and install Kubernetes/kind $DOWNLOAD"
David Bainbridge9e2a6662019-07-11 17:07:57 +0000466 (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 +0000467 (set -x; chmod 755 $GOPATH/bin/kind >>$LOG 2>&1) >>$LOG 2>&1
468 espin - $VERIFIED
469 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700470fi
471
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700472if [ "$INSTALL_HELM" == "no" ]; then
473 bspin "Skip Helm Install"
474 espin $NO_ENTRY
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700475else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700476 bspin "Verify Helm $HELM"
477 if [ -x $GOPATH/bin/helm ]; then
478 espin $VERIFIED
479 else
480 espin $NOT_VERIFIED
481 bspin - "Download and install Helm $DOWNLOAD"
482 (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
483 espin - $VERIFIED
484 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700485fi
486
Test Userb5712372019-07-03 21:52:17 +0000487bspin "Verify voltctl $HIGH_VOLTAGE"
Test User3d7ad8e2019-07-03 06:15:44 +0000488if [ -x $GOPATH/bin/voltctl ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700489 espin $VERIFIED
490else
491 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000492 bspin - "Download and build voltctl $DOWNLOAD"
Test Userba1e7e72019-07-10 22:27:54 +0000493 (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 +0000494 (set -x; chmod 755 $GOPATH/bin/voltctl >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700495 espin - $VERIFIED
496fi
497
498bspin "Verify command PATH"
Test Userba1e7e72019-07-10 22:27:54 +0000499export PATH=$GOPATH/bin:$PATH
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700500espin $VERIFIED
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700501
Test Userba1e7e72019-07-10 22:27:54 +0000502if [ "$DEPLOY_K8S" == "yes" ]; then
503 HAVE=$(kind get clusters | grep -c voltha-$TYPE)
504 bspin "Verify Kubernetes/Kind Cluster"
505 sspin
506 if [ $HAVE -eq 0 ]; then
David Bainbridge491b1bd2019-07-11 17:53:11 +0000507 espin $NOT_VERIFIED
508 bspin - "Verify cluster configuration"
509 if [ ! -r ./$TYPE-cluster.cfg ]; then
510 espin - $NOT_VERIFIED
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700511 bspin - "Download cluster configuration: $TYPE-cluster.cfg $DOWNLOAD"
David Bainbridge491b1bd2019-07-11 17:53:11 +0000512 (set -x; curl -o ./$TYPE-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 -0700513 espin - $VERIFIED
514 else
515 espin - $VERIFIED
516 fi
David Bainbridge491b1bd2019-07-11 17:53:11 +0000517 kind create cluster --name voltha-$TYPE --config $TYPE-cluster.cfg
518 else
519 espin $VERIFIED
Test Userba1e7e72019-07-10 22:27:54 +0000520 fi
521
522 export KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$TYPE")"
523 P="coredns-.* \
524 etcd-voltha-$TYPE-control-plane \
525 kindnet-.* \
526 kube-apiserver-voltha-$TYPE-control-plane \
527 kube-controller-manager-voltha-$TYPE-control-plane \
528 kube-proxy-.* \
529 kube-scheduler-voltha-$TYPE-control-plane"
530
531 EXPECT=$(test "$TYPE" == "minimal" && echo "12" || echo "14")
532 wait_for_pods - "kube-system" $EXPECT -1 "Waiting for system PODs to start" $P
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700533fi
534
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700535COUNT=$(count_pods "kube-system" "tiller-deploy-.*")
536bspin "Verify Helm"
Test Userba1e7e72019-07-10 22:27:54 +0000537if [ $COUNT -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700538 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000539 echo -e "Configuring Helm $GEAR"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700540 if [ "$INSTALL_HELM" == "no" ]; then
541 bspin - "Skip Helm/Tiller Initialization"
542 espin - $NO_ENTRY
543 else
544 bspin - "Initialize Helm"
545 (set -x; helm init --upgrade >>$LOG 2>&1) >>$LOG 2>&1
546 espin - $VERIFIED
547 wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
548 fi
Test Userb5712372019-07-03 21:52:17 +0000549 bspin - "Add Google Incubator repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700550 (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
551 espin - $VERIFIED
Test Userba1e7e72019-07-10 22:27:54 +0000552
553 # HACK (sort-of) - the config for tiller is about to be patched, which will
554 # cause the tiller pod to be recreated. This can sometimes cause a timing
555 # issue with the "wait_for_pods" call on tiller as it may incorrectly
556 # identify the running/ready tiller pod that is soon to be terminated as
557 # what it is waiting for. To avoid this issue we do a clean scale down and
558 # scale up of the pod so the script controlls when it should be expecting
559 # things
560 (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 -0700561
Test Userb5712372019-07-03 21:52:17 +0000562 bspin - "Add Google Stable repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700563 (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
564 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000565 bspin - "Add ONF repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700566 (set -x; helm repo add onf https://charts.opencord.org >>$LOG 2>&1) >>$LOG 2>&1
567 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000568 bspin - "Update Helm repository cache"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700569 (set -x; helm repo update >>$LOG 2>&1) >>$LOG 2>&1
570 espin - $VERIFIED
571
572 # Create and k8s service account so that Helm can create pods
Test Userb5712372019-07-03 21:52:17 +0000573 bspin - "Create Tiller ServiceAccount"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700574 (set -x; kubectl create serviceaccount --namespace kube-system tiller >>$LOG 2>&1) >>$LOG 2>&1
575 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000576 bspin - "Create Tiller ClusterRoleBinding"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700577 (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>$LOG 2>&1) >>$LOG 2>&1
578 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000579 bspin - "Update Tiller Manifest"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700580 (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 +0000581
582 # HACK (sort-of) - part to, spin it back up
583 (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 -0700584 espin - $VERIFIED
585else
586 espin $VERIFIED
587fi
Test Userb5712372019-07-03 21:52:17 +0000588wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700589
Test Userba1e7e72019-07-10 22:27:54 +0000590bspin "Verify Helm values file: $TYPE-values.yaml"
591if [ ! -r "./$TYPE-values.yaml" ]; then
592 espin $NOT_VERIFIED
593 bspin - "Download Helm values file: $TYPE-values.yaml $DOWNLOAD"
594 (set -x; curl -o ./$TYPE-values.yaml -sSL https://raw.githubusercontent.com/ciena/kind-voltha/master/$TYPE-values.yaml >>$LOG 2>&1) >>$LOG 2>&1
595 espin - $VERIFIED
596else
597 espin $VERIFIED
598fi
599
600if [ "$JUST_K8S" == "yes" ]; then
601 echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye."
602 echo ""
603 echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
604 echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
605 echo "tools required by VOLTHA in your command path. " | tee -a $LOG
606 echo "" | tee -a $LOG
607 echo -en $BOLD
608 if [ $DEPLOY_K8S == "yes" ]; then
609 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$TYPE\")\"" | tee -a $LOG
610 fi
611 echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
612 echo -en $NORMAL
613 echo "" | tee -a $LOG
614 echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
615 exit 0
616fi
617
Test Userb5712372019-07-03 21:52:17 +0000618bspin "Verify ETCD Operator $OLD_KEY"
Test User7d866122019-07-09 17:52:35 +0000619if [ $(helm list --deployed --short --namespace voltha "^etcd-operator\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700620 espin $NOT_VERIFIED
621 helm_install - voltha etcd-operator stable/etcd-operator "Install ETCD Operator"
622else
623 espin $VERIFIED
624fi
Test User01ed0642019-07-03 20:17:06 +0000625EXPECT=$(test "$TYPE" == "minimal" && echo "1" || echo "3")
Test Userb5712372019-07-03 21:52:17 +0000626wait_for_pods - "voltha" $EXPECT -1 "Waiting for ETCD Operator to start" "etcd-operator-.*"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700627
David Bainbridgeb270c202019-07-26 01:44:42 +0000628if [ $WITH_ONOS == "yes" ]; then
629 bspin "Verify ONOS installed $BIRD"
630 if [ $(helm list --deployed --short --namespace default "^onos\$" | wc -l) -ne 1 ]; then
631 espin $NOT_VERIFIED
632 helm_install - default onos onf/onos "Install ONOS"
633 else
634 espin $VERIFIED
635 fi
636 wait_for_pods - "default" 1 -1 "Waiting for ONOS to start" "onos-.*"
637
638 bspin - "Forward ONOS API port $FORWARD"
David Bainbridge82bd1212019-07-29 19:19:31 +0000639 for i in $(screen -ls | grep onos-ui-$TYPE | awk '{print $1}'); do
640 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
641 done
642 (set -x; screen -dmS onos-ui-$TYPE 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 +0000643 espin - $VERIFIED
644 bspin - "Forward ONOS SSH port $FORWARD"
David Bainbridge82bd1212019-07-29 19:19:31 +0000645 for i in $(screen -ls | grep onos-ssh-$TYPE | awk '{print $1}'); do
646 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
647 done
648 (set -x; screen -dmS onos-ssh-$TYPE 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 +0000649 espin - $VERIFIED
650 if [ ! -x ./onos-files/install-onos-applications.sh ]; then
651 bspin - "Verify or download ONOS configuration support files $DOWNLOAD"
652 (set -x; mkdir -p ./onos-files >>$LOG 2>&1) >>$LOG 2>&1
653 for i in dhcp-to-controller-flow.json install-onos-applications.sh olt-onos-enableExtraneousRules.json olt-onos-netcfg.json olt-onos-olt-settings.json radius-config.json; do
654 if [ ! -r ./onos-files/$i ]; then
655 (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
656 fi
657 done
658 (set -x; chmod 755 ./onos-files/install-onos-applications.sh >>$LOG 2>&1) >>$LOG 2>&1
659 espin - $VERIFIED
660 fi
661
662 bspin - "Install required ONOS applications $INSTALL"
663 (set -x; ./onos-files/install-onos-applications.sh >>$LOG 2>&1) >>$LOG 2>&1
Test Userba1e7e72019-07-10 22:27:54 +0000664 espin - $VERIFIED
665fi
666
Test Userb5712372019-07-03 21:52:17 +0000667bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
Test User7d866122019-07-09 17:52:35 +0000668if [ $(helm list --deployed --short --namespace voltha "^voltha\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700669 espin $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +0000670 helm_install - voltha voltha $VOLTHA_CHART "Install VOLTHA Core"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700671else
672 espin $VERIFIED
673fi
Test Userba1e7e72019-07-10 22:27:54 +0000674
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700675VOLTHA="ofagent-.* \
676 ro-core.* \
677 rw-core.* \
678 voltha-api-server-.* \
679 voltha-cli-server-.* \
680 voltha-etcd-cluster-.* \
681 voltha-kafka-.* \
682 voltha-zookeeper-.*"
Test User01ed0642019-07-03 20:17:06 +0000683EXPECT=$(test "$TYPE" == "minimal" && echo "9" || echo "11")
Test Userb5712372019-07-03 21:52:17 +0000684wait_for_pods - "voltha" $EXPECT -1 "Waiting for VOLTHA Core to start" $VOLTHA
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700685
Test Userb5712372019-07-03 21:52:17 +0000686echo -e "Verify Adapters $PLUG"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700687bspin - "Verify Simulated Adapters installed"
Test User7d866122019-07-09 17:52:35 +0000688if [ $(helm list --deployed --short --namespace voltha "^sim\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700689 espin - $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +0000690 helm_install - voltha sim $VOLTHA_ADAPTER_SIM_CHART "Install Simulated Adapters"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700691else
692 espin - $VERIFIED
693fi
694
695bspin - "Verify OpenOLT Adapter installed"
Test User7d866122019-07-09 17:52:35 +0000696if [ $(helm list --deployed --short --namespace voltha "^open-olt\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700697 espin - $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +0000698 helm_install - voltha open-olt $VOLTHA_ADAPTER_OPEN_OLT_CHART "Install OpenOLT Adapter"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700699else
700 espin - $VERIFIED
701fi
702bspin - "Verify OpenONU Adapter installed"
Test User7d866122019-07-09 17:52:35 +0000703if [ $(helm list --deployed --short --namespace voltha "^open-onu\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700704 espin - $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +0000705 helm_install - voltha open-onu $VOLTHA_ADAPTER_OPEN_ONU_CHART "Install OpenONU Adapter"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700706else
707 espin - $VERIFIED
708fi
709
710ADAPTERS="adapter-.*"
Test Userb5712372019-07-03 21:52:17 +0000711wait_for_pods - "voltha" 4 -1 "Waiting for adapters to start" $ADAPTERS
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700712
Test User7d866122019-07-09 17:52:35 +0000713if [ $WITH_BBSIM == "yes" ]; then
714 echo -e "Verify BBSIM $PLUG"
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000715 bspin - "Verify BBSIM Installed"
Test User7d866122019-07-09 17:52:35 +0000716 if [ $(helm list --deployed --short --namespace voltha "^bbsim\$" | wc -l) -ne 1 ]; then
717 espin - $NOT_VERIFIED
718 helm_install - voltha bbsim onf/bbsim "Install BBSIM"
719 else
720 espin - $VERIFIED
721 fi
722 wait_for_pods - "voltha" 1 -1 "Waiting for BBSIM to start" "bbsim-.*"
723fi
724
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000725if [ $WITH_RADIUS == "yes" ]; then
726 echo -e "Verify RADIUS $LOCK"
727 bspin - "Verify RADIUS Installed"
728 if [ $(helm list --deployed --short --namespace voltha "^radius\$" | wc -l) -ne 1 ]; then
729 espin - $NOT_VERIFIED
730 helm_install - voltha radius onf/freeradius "Install RADIUS"
731 else
732 espin - $VERIFIED
733 fi
734 wait_for_pods - "voltha" 1 -1 "Waiting for RADIUS to start" "radius-.*"
735fi
736
David Bainbridgee10f6d52019-07-25 00:28:13 +0000737if [ $SKIP_RESTART_API == "no" ]; then
738 echo -e "Restart VOLTHA API $RESTART"
739 API="voltha-api-server-.* ofagent-.*"
740 (set -x; kubectl scale --replicas=0 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1
741 wait_for_pods - "voltha" 0 -1 "Wait for API to stop $STOP" $API
742 (set -x; kubectl scale --replicas=1 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1
743 wait_for_pods - "voltha" 2 -1 "Wait for API to re-start $GO" $API
744else
745 bspin "Skip VOLTHA API Restart"
746 espin $NO_ENTRY
747fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700748
Test Userb5712372019-07-03 21:52:17 +0000749bspin - "Forward VOLTHA API port $FORWARD"
David Bainbridge82bd1212019-07-29 19:19:31 +0000750for i in $(screen -ls | grep voltha-api-$TYPE | awk '{print $1}'); do
751 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
752done
753(set -x; screen -dmS voltha-api-$TYPE 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 -0700754espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000755bspin - "Forward VOLTHA SSH port $FORWARD"
David Bainbridge82bd1212019-07-29 19:19:31 +0000756for i in $(screen -ls | grep voltha-ssh-$TYPE | awk '{print $1}'); do
757 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
758done
759(set -x; screen -dmS voltha-ssh-$TYPE 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 -0700760espin - $VERIFIED
Test User3d7ad8e2019-07-03 06:15:44 +0000761
David Bainbridgeb270c202019-07-26 01:44:42 +0000762if [ $WITH_ONOS == "yes" -a $WITH_RADIUS == "yes" ]; then
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000763 bspin "Configure ONOS RADIUS Connection $GEAR"
764 (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
765 espin $VERIFIED
766fi
767
768bspin "Create voltctl configuration file"
Test User3d7ad8e2019-07-03 06:15:44 +0000769(set -x; mkdir -p $HOME/.volt >>$LOG 2>&1) >>$LOG 2>&1
Test User01ed0642019-07-03 20:17:06 +0000770(set -x; voltctl -a v2 -s localhost:$VOLTHA_API_PORT config > $HOME/.volt/config-$TYPE 2>>$LOG) >>$LOG 2>&1
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000771espin $VERIFIED
Test User08ebbd92019-07-03 17:15:39 +0000772
David Bainbridgeb07fdf72019-07-29 22:51:40 +0000773if [ ! -f "$TYPE-env.sh" ]; then
774 touch $TYPE-env.sh
775fi
776
David Bainbridge596f30d2019-07-30 17:07:59 +0000777for O in $ALL_OPTIONS; do
778 VAL=$(eval echo \$$O)
779 if [ $O == "USE_GO" ]; then
780 VAL="$(echo $VAL| test $(grep -c true) -eq 1 && echo yes || echo no)"
781 fi
782 if [ ! -z "$VAL" -a $(grep -c "^export $O=" $TYPE-env.sh) -eq 0 ]; then
David Bainbridgeb07fdf72019-07-29 22:51:40 +0000783 echo "export $O=\"$(eval echo \$$O)\"" >> $TYPE-env.sh
784 fi
785done
786
787if [ $DEPLOY_K8S == "yes" -a $(grep -c "^export KUBECONFIG=" $TYPE-env.sh) -eq 0 ]; then
788 echo "export KUBECONFIG=\"$(./bin/kind get kubeconfig-path --name=voltha-$TYPE)\"" >> $TYPE-env.sh
789fi
790
791if [ $(grep -c "^export VOLTCONFIG=" $TYPE-env.sh) -eq 0 ]; then
792 echo "export VOLTCONFIG=\"$HOME/.volt/config-$TYPE\"" >> $TYPE-env.sh
793fi
794
795if [ $(grep -c "^export PATH=" $TYPE-env.sh) -eq 0 ]; then
796 echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> $TYPE-env.sh
797fi
798
Test User7d866122019-07-09 17:52:35 +0000799echo ""
Test User08ebbd92019-07-03 17:15:39 +0000800echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
801echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
802echo "tools required by VOLTHA in your command path. " | tee -a $LOG
803echo "" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +0000804echo -en $BOLD
Test Userba1e7e72019-07-10 22:27:54 +0000805if [ $DEPLOY_K8S == "yes" ]; then
806 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$TYPE\")\"" | tee -a $LOG
807fi
Test Userfa30f7f2019-07-03 20:35:19 +0000808echo "export VOLTCONFIG=\"$HOME/.volt/config-$TYPE\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +0000809echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +0000810echo -en $NORMAL
Test User08ebbd92019-07-03 17:15:39 +0000811echo "" | tee -a $LOG
812echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
813