blob: 6ff3e358cf96518a08cfce27313b4f8cb75cb5c8 [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}
Test Userba1e7e72019-07-10 22:27:54 +000047JUST_K8S=${JUST_K8S:-no}
48DEPLOY_K8S=${DEPLOY_K8S:-yes}
David Bainbridgee10f6d52019-07-25 00:28:13 +000049SKIP_RESTART_API=${SKIP_RESTART_API:-no}
David K. Bainbridge0e89cb92019-07-17 11:30:10 -070050INSTALL_KUBECTL=${INSTALL_KUBECTL:-yes}
51INSTALL_HELM=${INSTALL_HELM:-yes}
David Bainbridge5b7b96b2019-07-25 20:29:13 +000052USE_GO=${USE_GO:-yes}
53VOLTHA_LOG_LEVEL=${VOLTHA_LOG_LEVEL:-WARN}
David Bainbridgee10f6d52019-07-25 00:28:13 +000054VOLTHA_CHART=${VOLTHA_CHART:=onf/voltha}
55VOLTHA_ADAPTER_SIM_CHART=${VOLTHA_ADAPTER_SIM_CHART:-onf/voltha-adapter-simulated}
56VOLTHA_ADAPTER_OPEN_OLT_CHART=${VOLTHA_ADAPTER_OPEN_OLT_CHART:-onf/voltha-adapter-openolt}
57VOLTHA_ADAPTER_OPEN_ONU_CHART=${VOLTHA_ADAPTER_OPEN_ONU_CHART:-onf/voltha-adapter-openonu}
Test Userba1e7e72019-07-10 22:27:54 +000058
59HAVE_GO=$(which go >/dev/null 2>&1 && echo "yes" || echo "no")
60HOSTOS=$(uname -s | tr "[:upper:]" "[:lower:"])
61HOSTARCH=$(uname -m | tr "[:upper:]" "[:lower:"])
62if [ $HOSTARCH == "x86_64" ]; then
63 HOSTARCH="amd64"
64fi
Test User7d866122019-07-09 17:52:35 +000065
66# Verify TYPE setting
67if [ $(echo ":minimal:full:" | grep -ic ":$TYPE:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -070068 >&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 +000069 exit 1
70fi
71
72# Verify WITH_BBSIM settting and convert uniform value of yes or no
73if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_BBSIM:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -070074 >&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 +000075 exit 1
76fi
77if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_BBSIM:") -eq 1 ]; then
78 WITH_BBSIM=yes
79else
80 WITH_BBSIM=no
81fi
82
David Bainbridge5b7b96b2019-07-25 20:29:13 +000083# Verify WITH_RADIUS settting and convert uniform value of yes or no
84if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_RADIUS:") -eq 0 ]; then
85 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_RADIUS value of '$WITH_RADIUS'. Should be 'yes' or 'no'${NORMAL}"
86 exit 1
87fi
88if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_RADIUS:") -eq 1 ]; then
89 WITH_RADIUS=yes
90else
91 WITH_RADIUS=no
92fi
93
David Bainbridgeb270c202019-07-26 01:44:42 +000094# Verify WITH_ONOS settting and convert uniform value of yes or no
95if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_ONOS:") -eq 0 ]; then
96 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_ONOS value of '$WITH_ONOS'. Should be 'yes' or 'no'${NORMAL}"
97 exit 1
98fi
99if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_ONOS:") -eq 1 ]; then
100 WITH_ONOS=yes
101else
102 WITH_ONOS=no
103fi
104
Test Userba1e7e72019-07-10 22:27:54 +0000105# Verify JUST_K8S settting and convert uniform value of yes or no
106if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$JUST_K8S:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700107 >&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 +0000108 exit 1
109fi
110if [ $(echo ":y:yes:true:1:" | grep -ic ":$JUST_K8S:") -eq 1 ]; then
111 JUST_K8S=yes
112else
113 JUST_K8S=no
114fi
115
116# Verify DEPLOY_K8S settting and convert uniform value of yes or no
117if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$DEPLOY_K8S:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700118 >&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 +0000119 exit 1
120fi
121if [ $(echo ":y:yes:true:1:" | grep -ic ":$DEPLOY_K8S:") -eq 1 ]; then
122 DEPLOY_K8S=yes
123else
124 DEPLOY_K8S=no
125fi
Test User01ed0642019-07-03 20:17:06 +0000126
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700127# Verify INSTALL_KUBECTL settting and convert uniform value of yes or no
128if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$INSTALL_KUBECTL:") -eq 0 ]; then
129 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$INSTALL_KUBECTL value of '$INSTALL_KUBECTL'. Should be 'yes' or 'no'${NORMAL}"
130 exit 1
131fi
132
133if [ $(echo ":y:yes:true:1:" | grep -ic ":$INSTALL_KUBECTL:") -eq 1 ]; then
134 INSTALL_KUBECTL=yes
135else
136 INSTALL_KUBECTL=no
137fi
138
David Bainbridgee10f6d52019-07-25 00:28:13 +0000139# Verify SKIP_RESTART_API settting and convert uniform value of yes or no
140if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$SKIP_RESTART_API:") -eq 0 ]; then
141 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$SKIP_RESTART_API value of '$SKIP_RESTART_API'. Should be 'yes' or 'no'${NORMAL}"
142 exit 1
143fi
144if [ $(echo ":y:yes:true:1:" | grep -ic ":$SKIP_RESTART_API:") -eq 1 ]; then
145 SKIP_RESTART_API=yes
146else
147 SKIP_RESTART_API=no
148fi
149
David Bainbridge1ceabc12019-07-25 17:21:05 +0000150# Verify USE_GO settting and convert uniform value of yes or no
151if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$USE_GO:") -eq 0 ]; then
152 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$USE_GO value of '$USE_GO'. Should be 'yes' or 'no'${NORMAL}"
153 exit 1
154fi
155if [ $(echo ":y:yes:true:1:" | grep -ic ":$USE_GO:") -eq 1 ]; then
156 USE_GO=true
157else
158 USE_GO=false
159fi
160
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700161# Verify INSTALL_HELM settting and convert uniform value of yes or no
162if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$INSTALL_HELM:") -eq 0 ]; then
163 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$INSTALL_HELM value of '$INSTALL_HELM'. Should be 'yes' or 'no'${NORMAL}"
164 exit 1
165fi
166
167if [ $(echo ":y:yes:true:1:" | grep -ic ":$INSTALL_HELM:") -eq 1 ]; then
168 INSTALL_HELM=yes
169else
170 INSTALL_HELM=no
171fi
172
Test User01ed0642019-07-03 20:17:06 +0000173if [ "$TYPE" == "full" ]; then
174 ONOS_API_PORT=${ONOS_API_PORT:-8182}
175 ONOS_SSH_PORT=${ONOS_SSH_PORT:-8102}
176 VOLTHA_API_PORT=${VOLTHA_API_PORT:-55556}
177 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-5023}
178else
179 ONOS_API_PORT=${ONOS_API_PORT:-8181}
180 ONOS_SSH_PORT=${ONOS_SSH_PORT:-8101}
181 VOLTHA_API_PORT=${VOLTHA_API_PORT:-55555}
182 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-5022}
183fi
184
185if [ "$1" == "get" -a "$2" == "voltconfig" ]; then
186 echo "$HOME/.volt/config-$TYPE"
187 exit
188fi
Test User3d7ad8e2019-07-03 06:15:44 +0000189
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700190if [ $# -ne 1 -o $(echo ":up:down:" | grep -c ":$1:") -ne 1 ]; then
191 >&2 echo "up or down?"
192 exit 1
193fi
194
195if [ "$1" == "down" ]; then
Test Userba1e7e72019-07-10 22:27:54 +0000196 if [ $DEPLOY_K8S == "yes" ]; then
197 if [ -x ./bin/kind ]; then
198 exec ./bin/kind delete cluster --name voltha-$TYPE
199 else
200 >&2 echo "Kind doesn't seem to be installed, so nothing to do. Bye."
201 fi
Test User08ebbd92019-07-03 17:15:39 +0000202 else
Test Userba1e7e72019-07-10 22:27:54 +0000203 EXISTS=$(helm list -q)
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000204 EXPECT="etcd-operator onos open-olt open-onu sim voltha bbsim radius"
Test Userba1e7e72019-07-10 22:27:54 +0000205 INTERSECT=
206 for i in $EXISTS; do
207 if [ $(echo $EXPECT | grep -c $i) -eq 1 ]; then
208 HAVE="$HAVE $i"
209 fi
210 done
David Bainbridge7831a662019-07-25 18:12:25 +0000211 if [ "$HAVE X" != " X" ]; then
212 ./bin/helm delete --purge $HAVE
213 fi
Test Userba1e7e72019-07-10 22:27:54 +0000214fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700215 exit
216fi
217
Test User01ed0642019-07-03 20:17:06 +0000218LOG="install-$TYPE.log"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700219date > $LOG
220
David Bainbridge1ceabc12019-07-25 17:21:05 +0000221# Output install options to log
222echo "OPTIONS" >> $LOG
David Bainbridge596f30d2019-07-30 17:07:59 +0000223ALL_OPTIONS="TYPE WITH_BBSIM WITH_RADIUS WITH_ONOS JUST_K8S DEPLOY_K8S \
224 SKIP_RESTART_API INSTALL_KUBECTL INSTALL_HELM USE_GO VOLTHA_LOG_LEVEL \
225 VOLTHA_CHART VOLTHA_ADAPTER_SIM_CHART VOLTHA_ADAPTER_OPEN_OLT_CHART \
226 VOLTHA_ADAPTER_OPEN_ONU_CHART CONFIG_VER SADIS_VER OLT_VER AAA_VER DHCP_VER"
227for O in $ALL_OPTIONS; do
228 VAL=$(eval echo \$$O)
229 if [ $O == "USE_GO" ]; then
230 VAL="$(echo $VAL| test $(grep -c true) -eq 1 && echo yes || echo no)"
231 fi
232 if [ ! -z "$VAL" ]; then
233 printf " %-30s = %s\n" $O $VAL >> $LOG
234 fi
235done
David Bainbridge1ceabc12019-07-25 17:21:05 +0000236
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700237spin() {
Test Userd87942b2019-07-03 07:20:24 +0000238 PARTS="\
239 \xe2\xa2\x8e\xe2\xa1\xb0 \
240 \xe2\xa2\x8e\xe2\xa1\xa1 \
241 \xe2\xa2\x8e\xe2\xa1\x91 \
242 \xe2\xa2\x8e\xe2\xa0\xb1 \
243 \xe2\xa0\x8e\xe2\xa1\xb1 \
244 \xe2\xa2\x8a\xe2\xa1\xb1 \
245 \xe2\xa2\x8c\xe2\xa1\xb1 \
246 \xe2\xa2\x86\xe2\xa1\xb1 \
247 "
248 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700249 tput civis
250 while true; do
Test Userd87942b2019-07-03 07:20:24 +0000251 C=$(echo $PARTS | cut '-d ' -f $IDX)
252 echo -en "$C"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700253 IDX=$(expr $IDX + 1)
Test Userd87942b2019-07-03 07:20:24 +0000254 if [ $IDX -gt 8 ]; then
255 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700256 fi
257 sleep .15
258 echo -en "\r"
259 done
260}
261
Test Userd87942b2019-07-03 07:20:24 +0000262SPIN_PARTS="\
263 \xe2\xa2\x8e\xe2\xa1\xb0 \
264 \xe2\xa2\x8e\xe2\xa1\xa1 \
265 \xe2\xa2\x8e\xe2\xa1\x91 \
266 \xe2\xa2\x8e\xe2\xa0\xb1 \
267 \xe2\xa0\x8e\xe2\xa1\xb1 \
268 \xe2\xa2\x8a\xe2\xa1\xb1 \
269 \xe2\xa2\x8c\xe2\xa1\xb1 \
270 \xe2\xa2\x86\xe2\xa1\xb1 \
271 "
272IDX=1
273NOT_VERIFIED="\xe2\x9c\x97\x20"
274VERIFIED="\xe2\x9c\x93\x20"
Test Userb5712372019-07-03 21:52:17 +0000275HELM="\xE2\x8E\x88"
276OLD_KEY="\xF0\x9F\x97\x9D"
277BIRD="\xF0\x9F\x90\xA6"
278HIGH_VOLTAGE="\xE2\x9A\xA1"
279PLUG="\xF0\x9F\xa7\xa9"
280RESTART="\xf0\x9f\x94\x84"
281FORWARD="\xE2\x87\xA8"
282INSTALL="\xF0\x9F\x8F\x97"
283STOP="\xf0\x9f\x9b\x91"
284GO="\xf0\x9f\x9a\x80"
285DOWNLOAD="\xf0\x9f\x93\xa5"
286GEAR="\xe2\x9a\x99"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700287NO_ENTRY="\xe2\x9b\x94"
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000288LOCK="\xf0\x9f\x94\x92"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700289
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700290bspin() {
291 tput civis
Test Userd87942b2019-07-03 07:20:24 +0000292 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700293 local INDENT=
294 if [ "$1" == "-" ]; then
295 INDENT=" "
296 shift
297 fi
Test Userd87942b2019-07-03 07:20:24 +0000298 echo -en "$INDENT $*"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700299}
300
301sspin() {
302 local INDENT=
303 if [ "$1" == "-" ]; then
304 INDENT=" "
305 shift
306 fi
Test Userd87942b2019-07-03 07:20:24 +0000307 C=$(echo $SPIN_PARTS | cut '-d ' -f $IDX)
308 echo -en "\r$INDENT$C $*"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700309 IDX=$(expr $IDX + 1)
Test Userd87942b2019-07-03 07:20:24 +0000310 if [ $IDX -gt 8 ]; then
311 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700312 fi
313}
314
315espin() {
316 local INDENT=
317 if [ "$1" == "-" ]; then
318 INDENT=" "
319 shift
320 fi
321 echo -e "\r$INDENT$*"
322 tput cnorm
323}
324
325count_pods() {
326 local NAMESPACE=$1; shift
327 local PODS=$(kubectl -n $NAMESPACE get pod -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}")
328 local COUNT=0
329 local PATTERNS=$*
330 for POD in $PODS; do
331 local NAME=$(echo $POD | cut -d/ -f 1)
332 local STATE=$(echo $POD | cut -d/ -f 2)
333 local CONTAINERS=$(echo $POD | cut -d/ -f 3 | sed -e 's/_/ /g')
334 if [ "$STATE" == "Running" ]; then
335 local TOTAL=$(echo $CONTAINERS | wc -w)
336 local FOUND=$(echo $CONTAINERS | grep -o true | wc -l)
337 if [ $TOTAL -eq $FOUND ]; then
338 for PATTERN in $PATTERNS; do
339 if [[ $NAME =~ $PATTERN ]]; then
340 COUNT=$(expr $COUNT + 1)
341 fi
342 done
343 fi
344 fi
345 done
346 echo $COUNT
347}
348
349wait_for_pods() {
350 local INDENT=
351 if [ "$1" == "-" ]; then
352 INDENT=$1; shift
353 fi
354 local NAMESPACE=$1; shift
355 local EXPECT=$1; shift
356 local RETRY=$1; shift
357 local MESSAGE=$1; shift
358 local PATTERNS=$*
359 local HAVE=$(count_pods $NAMESPACE $PATTERNS)
360 COUNT=$(expr 300 / 15)
361 bspin $INDENT $MESSAGE
362 sspin $INDENT
363 if [ $HAVE -ne $EXPECT ]; then
364 while [ $HAVE -ne $EXPECT ]; do
365 sspin $INDENT
366 COUNT=$(expr $COUNT - 1)
367 if [ $COUNT -eq 0 ]; then
368 HAVE=$(count_pods $NAMESPACE $PATTERNS)
369 COUNT=$(expr 300 / 15)
370 fi
371 sleep .15
372 done
373 fi
374 espin $INDENT $VERIFIED
375 if [ $HAVE -ne $EXPECT ]; then
376 return 1
377 fi
378 return 0
379}
380
381helm_install() {
382 local INDENT=
383 if [ "$1" == "-" ]; then
384 INDENT=$1; shift
385 fi
386 local NAMESPACE=$1; shift
387 local NAME=$1; shift
388 local CHART=$1; shift
389 local MESSAGE=$*
390
391 COUNT=$(expr 300 / 15)
392 bspin $INDENT $MESSAGE
David Bainbridge1ceabc12019-07-25 17:21:05 +0000393 (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 -0700394 SUCCESS=$?
395 while [ $SUCCESS -ne 0 ]; do
396 sspin $INDENT
397 COUNT=$(expr $COUNT - 1)
398 if [ $COUNT -eq 0 ]; then
David Bainbridgee10f6d52019-07-25 00:28:13 +0000399 (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 -0700400 COUNT=$(expr 300 / 15)
401 fi
402 sleep .15
403 done
404 espin $INDENT $VERIFIED
405}
406
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700407echo "INSTALL TYPE: $TYPE" >> $LOG
408
409bspin "Verify GOPATH"
410export GOPATH=$(pwd)
Test User3d7ad8e2019-07-03 06:15:44 +0000411mkdir -p $GOPATH/bin
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700412espin $VERIFIED
413
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700414if [ "$INSTALL_KUBECTL" == "no" ]; then
415 bspin "Skip kubectl install"
416 espin $NO_ENTRY
Test Userc13bdc92019-07-03 20:57:49 +0000417else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700418 bspin "Verify kubectl $HELM"
419 if [ -x $GOPATH/bin/kubectl ]; then
420 espin $VERIFIED
421 else
422 espin $NOT_VERIFIED
423 bspin - "Download and install Kubernetes/kubectl $DOWNLOAD"
424 (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
425 (set -x; chmod 755 $GOPATH/bin/kubectl >>$LOG 2>&1) >>$LOG 2>&1
426 espin - $VERIFIED
427 fi
Test Userc13bdc92019-07-03 20:57:49 +0000428fi
429
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700430if [ "$DEPLOY_K8S" == "no" ]; then
431 bspin "Skip Kubernetes/Kind Deployment"
432 espin $NO_ENTRY
433else
Test Userba1e7e72019-07-10 22:27:54 +0000434 bspin "Verify Kubernetes/Kind $HELM"
435 if [ -x $GOPATH/bin/kind ]; then
436 espin $VERIFIED
437 else
438 espin $NOT_VERIFIED
439 bspin - "Download and install Kubernetes/kind $DOWNLOAD"
David Bainbridge9e2a6662019-07-11 17:07:57 +0000440 (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 +0000441 (set -x; chmod 755 $GOPATH/bin/kind >>$LOG 2>&1) >>$LOG 2>&1
442 espin - $VERIFIED
443 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700444fi
445
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700446if [ "$INSTALL_HELM" == "no" ]; then
447 bspin "Skip Helm Install"
448 espin $NO_ENTRY
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700449else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700450 bspin "Verify Helm $HELM"
451 if [ -x $GOPATH/bin/helm ]; then
452 espin $VERIFIED
453 else
454 espin $NOT_VERIFIED
455 bspin - "Download and install Helm $DOWNLOAD"
456 (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
457 espin - $VERIFIED
458 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700459fi
460
Test Userb5712372019-07-03 21:52:17 +0000461bspin "Verify voltctl $HIGH_VOLTAGE"
Test User3d7ad8e2019-07-03 06:15:44 +0000462if [ -x $GOPATH/bin/voltctl ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700463 espin $VERIFIED
464else
465 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000466 bspin - "Download and build voltctl $DOWNLOAD"
Test Userba1e7e72019-07-10 22:27:54 +0000467 (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 +0000468 (set -x; chmod 755 $GOPATH/bin/voltctl >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700469 espin - $VERIFIED
470fi
471
472bspin "Verify command PATH"
Test Userba1e7e72019-07-10 22:27:54 +0000473export PATH=$GOPATH/bin:$PATH
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700474espin $VERIFIED
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700475
Test Userba1e7e72019-07-10 22:27:54 +0000476if [ "$DEPLOY_K8S" == "yes" ]; then
477 HAVE=$(kind get clusters | grep -c voltha-$TYPE)
478 bspin "Verify Kubernetes/Kind Cluster"
479 sspin
480 if [ $HAVE -eq 0 ]; then
David Bainbridge491b1bd2019-07-11 17:53:11 +0000481 espin $NOT_VERIFIED
482 bspin - "Verify cluster configuration"
483 if [ ! -r ./$TYPE-cluster.cfg ]; then
484 espin - $NOT_VERIFIED
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700485 bspin - "Download cluster configuration: $TYPE-cluster.cfg $DOWNLOAD"
David Bainbridge491b1bd2019-07-11 17:53:11 +0000486 (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 -0700487 espin - $VERIFIED
488 else
489 espin - $VERIFIED
490 fi
David Bainbridge491b1bd2019-07-11 17:53:11 +0000491 kind create cluster --name voltha-$TYPE --config $TYPE-cluster.cfg
492 else
493 espin $VERIFIED
Test Userba1e7e72019-07-10 22:27:54 +0000494 fi
495
496 export KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$TYPE")"
497 P="coredns-.* \
498 etcd-voltha-$TYPE-control-plane \
499 kindnet-.* \
500 kube-apiserver-voltha-$TYPE-control-plane \
501 kube-controller-manager-voltha-$TYPE-control-plane \
502 kube-proxy-.* \
503 kube-scheduler-voltha-$TYPE-control-plane"
504
505 EXPECT=$(test "$TYPE" == "minimal" && echo "12" || echo "14")
506 wait_for_pods - "kube-system" $EXPECT -1 "Waiting for system PODs to start" $P
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700507fi
508
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700509COUNT=$(count_pods "kube-system" "tiller-deploy-.*")
510bspin "Verify Helm"
Test Userba1e7e72019-07-10 22:27:54 +0000511if [ $COUNT -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700512 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000513 echo -e "Configuring Helm $GEAR"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700514 if [ "$INSTALL_HELM" == "no" ]; then
515 bspin - "Skip Helm/Tiller Initialization"
516 espin - $NO_ENTRY
517 else
518 bspin - "Initialize Helm"
519 (set -x; helm init --upgrade >>$LOG 2>&1) >>$LOG 2>&1
520 espin - $VERIFIED
521 wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
522 fi
Test Userb5712372019-07-03 21:52:17 +0000523 bspin - "Add Google Incubator repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700524 (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
525 espin - $VERIFIED
Test Userba1e7e72019-07-10 22:27:54 +0000526
527 # HACK (sort-of) - the config for tiller is about to be patched, which will
528 # cause the tiller pod to be recreated. This can sometimes cause a timing
529 # issue with the "wait_for_pods" call on tiller as it may incorrectly
530 # identify the running/ready tiller pod that is soon to be terminated as
531 # what it is waiting for. To avoid this issue we do a clean scale down and
532 # scale up of the pod so the script controlls when it should be expecting
533 # things
534 (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 -0700535
Test Userb5712372019-07-03 21:52:17 +0000536 bspin - "Add Google Stable repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700537 (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
538 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000539 bspin - "Add ONF repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700540 (set -x; helm repo add onf https://charts.opencord.org >>$LOG 2>&1) >>$LOG 2>&1
541 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000542 bspin - "Update Helm repository cache"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700543 (set -x; helm repo update >>$LOG 2>&1) >>$LOG 2>&1
544 espin - $VERIFIED
545
546 # Create and k8s service account so that Helm can create pods
Test Userb5712372019-07-03 21:52:17 +0000547 bspin - "Create Tiller ServiceAccount"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700548 (set -x; kubectl create serviceaccount --namespace kube-system tiller >>$LOG 2>&1) >>$LOG 2>&1
549 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000550 bspin - "Create Tiller ClusterRoleBinding"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700551 (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>$LOG 2>&1) >>$LOG 2>&1
552 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000553 bspin - "Update Tiller Manifest"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700554 (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 +0000555
556 # HACK (sort-of) - part to, spin it back up
557 (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 -0700558 espin - $VERIFIED
559else
560 espin $VERIFIED
561fi
Test Userb5712372019-07-03 21:52:17 +0000562wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700563
Test Userba1e7e72019-07-10 22:27:54 +0000564bspin "Verify Helm values file: $TYPE-values.yaml"
565if [ ! -r "./$TYPE-values.yaml" ]; then
566 espin $NOT_VERIFIED
567 bspin - "Download Helm values file: $TYPE-values.yaml $DOWNLOAD"
568 (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
569 espin - $VERIFIED
570else
571 espin $VERIFIED
572fi
573
574if [ "$JUST_K8S" == "yes" ]; then
575 echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye."
576 echo ""
577 echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
578 echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
579 echo "tools required by VOLTHA in your command path. " | tee -a $LOG
580 echo "" | tee -a $LOG
581 echo -en $BOLD
582 if [ $DEPLOY_K8S == "yes" ]; then
583 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$TYPE\")\"" | tee -a $LOG
584 fi
585 echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
586 echo -en $NORMAL
587 echo "" | tee -a $LOG
588 echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
589 exit 0
590fi
591
Test Userb5712372019-07-03 21:52:17 +0000592bspin "Verify ETCD Operator $OLD_KEY"
Test User7d866122019-07-09 17:52:35 +0000593if [ $(helm list --deployed --short --namespace voltha "^etcd-operator\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700594 espin $NOT_VERIFIED
595 helm_install - voltha etcd-operator stable/etcd-operator "Install ETCD Operator"
596else
597 espin $VERIFIED
598fi
Test User01ed0642019-07-03 20:17:06 +0000599EXPECT=$(test "$TYPE" == "minimal" && echo "1" || echo "3")
Test Userb5712372019-07-03 21:52:17 +0000600wait_for_pods - "voltha" $EXPECT -1 "Waiting for ETCD Operator to start" "etcd-operator-.*"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700601
David Bainbridgeb270c202019-07-26 01:44:42 +0000602if [ $WITH_ONOS == "yes" ]; then
603 bspin "Verify ONOS installed $BIRD"
604 if [ $(helm list --deployed --short --namespace default "^onos\$" | wc -l) -ne 1 ]; then
605 espin $NOT_VERIFIED
606 helm_install - default onos onf/onos "Install ONOS"
607 else
608 espin $VERIFIED
609 fi
610 wait_for_pods - "default" 1 -1 "Waiting for ONOS to start" "onos-.*"
611
612 bspin - "Forward ONOS API port $FORWARD"
David Bainbridge82bd1212019-07-29 19:19:31 +0000613 for i in $(screen -ls | grep onos-ui-$TYPE | awk '{print $1}'); do
614 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
615 done
616 (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 +0000617 espin - $VERIFIED
618 bspin - "Forward ONOS SSH port $FORWARD"
David Bainbridge82bd1212019-07-29 19:19:31 +0000619 for i in $(screen -ls | grep onos-ssh-$TYPE | awk '{print $1}'); do
620 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
621 done
622 (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 +0000623 espin - $VERIFIED
624 if [ ! -x ./onos-files/install-onos-applications.sh ]; then
625 bspin - "Verify or download ONOS configuration support files $DOWNLOAD"
626 (set -x; mkdir -p ./onos-files >>$LOG 2>&1) >>$LOG 2>&1
627 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
628 if [ ! -r ./onos-files/$i ]; then
629 (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
630 fi
631 done
632 (set -x; chmod 755 ./onos-files/install-onos-applications.sh >>$LOG 2>&1) >>$LOG 2>&1
633 espin - $VERIFIED
634 fi
635
636 bspin - "Install required ONOS applications $INSTALL"
637 (set -x; ./onos-files/install-onos-applications.sh >>$LOG 2>&1) >>$LOG 2>&1
Test Userba1e7e72019-07-10 22:27:54 +0000638 espin - $VERIFIED
639fi
640
Test Userb5712372019-07-03 21:52:17 +0000641bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
Test User7d866122019-07-09 17:52:35 +0000642if [ $(helm list --deployed --short --namespace voltha "^voltha\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700643 espin $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +0000644 helm_install - voltha voltha $VOLTHA_CHART "Install VOLTHA Core"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700645else
646 espin $VERIFIED
647fi
Test Userba1e7e72019-07-10 22:27:54 +0000648
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700649VOLTHA="ofagent-.* \
650 ro-core.* \
651 rw-core.* \
652 voltha-api-server-.* \
653 voltha-cli-server-.* \
654 voltha-etcd-cluster-.* \
655 voltha-kafka-.* \
656 voltha-zookeeper-.*"
Test User01ed0642019-07-03 20:17:06 +0000657EXPECT=$(test "$TYPE" == "minimal" && echo "9" || echo "11")
Test Userb5712372019-07-03 21:52:17 +0000658wait_for_pods - "voltha" $EXPECT -1 "Waiting for VOLTHA Core to start" $VOLTHA
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700659
Test Userb5712372019-07-03 21:52:17 +0000660echo -e "Verify Adapters $PLUG"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700661bspin - "Verify Simulated Adapters installed"
Test User7d866122019-07-09 17:52:35 +0000662if [ $(helm list --deployed --short --namespace voltha "^sim\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700663 espin - $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +0000664 helm_install - voltha sim $VOLTHA_ADAPTER_SIM_CHART "Install Simulated Adapters"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700665else
666 espin - $VERIFIED
667fi
668
669bspin - "Verify OpenOLT Adapter installed"
Test User7d866122019-07-09 17:52:35 +0000670if [ $(helm list --deployed --short --namespace voltha "^open-olt\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700671 espin - $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +0000672 helm_install - voltha open-olt $VOLTHA_ADAPTER_OPEN_OLT_CHART "Install OpenOLT Adapter"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700673else
674 espin - $VERIFIED
675fi
676bspin - "Verify OpenONU Adapter installed"
Test User7d866122019-07-09 17:52:35 +0000677if [ $(helm list --deployed --short --namespace voltha "^open-onu\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700678 espin - $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +0000679 helm_install - voltha open-onu $VOLTHA_ADAPTER_OPEN_ONU_CHART "Install OpenONU Adapter"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700680else
681 espin - $VERIFIED
682fi
683
684ADAPTERS="adapter-.*"
Test Userb5712372019-07-03 21:52:17 +0000685wait_for_pods - "voltha" 4 -1 "Waiting for adapters to start" $ADAPTERS
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700686
Test User7d866122019-07-09 17:52:35 +0000687if [ $WITH_BBSIM == "yes" ]; then
688 echo -e "Verify BBSIM $PLUG"
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000689 bspin - "Verify BBSIM Installed"
Test User7d866122019-07-09 17:52:35 +0000690 if [ $(helm list --deployed --short --namespace voltha "^bbsim\$" | wc -l) -ne 1 ]; then
691 espin - $NOT_VERIFIED
692 helm_install - voltha bbsim onf/bbsim "Install BBSIM"
693 else
694 espin - $VERIFIED
695 fi
696 wait_for_pods - "voltha" 1 -1 "Waiting for BBSIM to start" "bbsim-.*"
697fi
698
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000699if [ $WITH_RADIUS == "yes" ]; then
700 echo -e "Verify RADIUS $LOCK"
701 bspin - "Verify RADIUS Installed"
702 if [ $(helm list --deployed --short --namespace voltha "^radius\$" | wc -l) -ne 1 ]; then
703 espin - $NOT_VERIFIED
704 helm_install - voltha radius onf/freeradius "Install RADIUS"
705 else
706 espin - $VERIFIED
707 fi
708 wait_for_pods - "voltha" 1 -1 "Waiting for RADIUS to start" "radius-.*"
709fi
710
David Bainbridgee10f6d52019-07-25 00:28:13 +0000711if [ $SKIP_RESTART_API == "no" ]; then
712 echo -e "Restart VOLTHA API $RESTART"
713 API="voltha-api-server-.* ofagent-.*"
714 (set -x; kubectl scale --replicas=0 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1
715 wait_for_pods - "voltha" 0 -1 "Wait for API to stop $STOP" $API
716 (set -x; kubectl scale --replicas=1 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1
717 wait_for_pods - "voltha" 2 -1 "Wait for API to re-start $GO" $API
718else
719 bspin "Skip VOLTHA API Restart"
720 espin $NO_ENTRY
721fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700722
Test Userb5712372019-07-03 21:52:17 +0000723bspin - "Forward VOLTHA API port $FORWARD"
David Bainbridge82bd1212019-07-29 19:19:31 +0000724for i in $(screen -ls | grep voltha-api-$TYPE | awk '{print $1}'); do
725 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
726done
727(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 -0700728espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000729bspin - "Forward VOLTHA SSH port $FORWARD"
David Bainbridge82bd1212019-07-29 19:19:31 +0000730for i in $(screen -ls | grep voltha-ssh-$TYPE | awk '{print $1}'); do
731 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
732done
733(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 -0700734espin - $VERIFIED
Test User3d7ad8e2019-07-03 06:15:44 +0000735
David Bainbridgeb270c202019-07-26 01:44:42 +0000736if [ $WITH_ONOS == "yes" -a $WITH_RADIUS == "yes" ]; then
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000737 bspin "Configure ONOS RADIUS Connection $GEAR"
738 (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
739 espin $VERIFIED
740fi
741
742bspin "Create voltctl configuration file"
Test User3d7ad8e2019-07-03 06:15:44 +0000743(set -x; mkdir -p $HOME/.volt >>$LOG 2>&1) >>$LOG 2>&1
Test User01ed0642019-07-03 20:17:06 +0000744(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 +0000745espin $VERIFIED
Test User08ebbd92019-07-03 17:15:39 +0000746
David Bainbridgeb07fdf72019-07-29 22:51:40 +0000747if [ ! -f "$TYPE-env.sh" ]; then
748 touch $TYPE-env.sh
749fi
750
David Bainbridge596f30d2019-07-30 17:07:59 +0000751for O in $ALL_OPTIONS; do
752 VAL=$(eval echo \$$O)
753 if [ $O == "USE_GO" ]; then
754 VAL="$(echo $VAL| test $(grep -c true) -eq 1 && echo yes || echo no)"
755 fi
756 if [ ! -z "$VAL" -a $(grep -c "^export $O=" $TYPE-env.sh) -eq 0 ]; then
David Bainbridgeb07fdf72019-07-29 22:51:40 +0000757 echo "export $O=\"$(eval echo \$$O)\"" >> $TYPE-env.sh
758 fi
759done
760
761if [ $DEPLOY_K8S == "yes" -a $(grep -c "^export KUBECONFIG=" $TYPE-env.sh) -eq 0 ]; then
762 echo "export KUBECONFIG=\"$(./bin/kind get kubeconfig-path --name=voltha-$TYPE)\"" >> $TYPE-env.sh
763fi
764
765if [ $(grep -c "^export VOLTCONFIG=" $TYPE-env.sh) -eq 0 ]; then
766 echo "export VOLTCONFIG=\"$HOME/.volt/config-$TYPE\"" >> $TYPE-env.sh
767fi
768
769if [ $(grep -c "^export PATH=" $TYPE-env.sh) -eq 0 ]; then
770 echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> $TYPE-env.sh
771fi
772
Test User7d866122019-07-09 17:52:35 +0000773echo ""
Test User08ebbd92019-07-03 17:15:39 +0000774echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
775echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
776echo "tools required by VOLTHA in your command path. " | tee -a $LOG
777echo "" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +0000778echo -en $BOLD
Test Userba1e7e72019-07-10 22:27:54 +0000779if [ $DEPLOY_K8S == "yes" ]; then
780 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$TYPE\")\"" | tee -a $LOG
781fi
Test Userfa30f7f2019-07-03 20:35:19 +0000782echo "export VOLTCONFIG=\"$HOME/.volt/config-$TYPE\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +0000783echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +0000784echo -en $NORMAL
Test User08ebbd92019-07-03 17:15:39 +0000785echo "" | tee -a $LOG
786echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
787