blob: 95a3d1bbbfc2efcb06190d9a3c6b7d381fa5c4d0 [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"
David Bainbridgeac7f8072019-08-01 22:15:33 +000042CEOL=$(tput el)
Test User7d866122019-07-09 17:52:35 +000043
Test User3d7ad8e2019-07-03 06:15:44 +000044TYPE=${TYPE:-minimal}
Test User7d866122019-07-09 17:52:35 +000045WITH_BBSIM=${WITH_BBSIM:-no}
David Bainbridge5b7b96b2019-07-25 20:29:13 +000046WITH_RADIUS=${WITH_RADIUS:-no}
David Bainbridgeb270c202019-07-26 01:44:42 +000047WITH_ONOS=${WITH_ONOS:-yes}
David Bainbridge01294952019-07-30 19:33:45 +000048WITH_TP=${WITH_TP:-yes}
Test Userba1e7e72019-07-10 22:27:54 +000049JUST_K8S=${JUST_K8S:-no}
50DEPLOY_K8S=${DEPLOY_K8S:-yes}
David Bainbridgee10f6d52019-07-25 00:28:13 +000051SKIP_RESTART_API=${SKIP_RESTART_API:-no}
David K. Bainbridge0e89cb92019-07-17 11:30:10 -070052INSTALL_KUBECTL=${INSTALL_KUBECTL:-yes}
53INSTALL_HELM=${INSTALL_HELM:-yes}
David Bainbridge5b7b96b2019-07-25 20:29:13 +000054USE_GO=${USE_GO:-yes}
55VOLTHA_LOG_LEVEL=${VOLTHA_LOG_LEVEL:-WARN}
David Bainbridgee10f6d52019-07-25 00:28:13 +000056VOLTHA_CHART=${VOLTHA_CHART:=onf/voltha}
57VOLTHA_ADAPTER_SIM_CHART=${VOLTHA_ADAPTER_SIM_CHART:-onf/voltha-adapter-simulated}
58VOLTHA_ADAPTER_OPEN_OLT_CHART=${VOLTHA_ADAPTER_OPEN_OLT_CHART:-onf/voltha-adapter-openolt}
59VOLTHA_ADAPTER_OPEN_ONU_CHART=${VOLTHA_ADAPTER_OPEN_ONU_CHART:-onf/voltha-adapter-openonu}
Test Userba1e7e72019-07-10 22:27:54 +000060
61HAVE_GO=$(which go >/dev/null 2>&1 && echo "yes" || echo "no")
62HOSTOS=$(uname -s | tr "[:upper:]" "[:lower:"])
63HOSTARCH=$(uname -m | tr "[:upper:]" "[:lower:"])
64if [ $HOSTARCH == "x86_64" ]; then
65 HOSTARCH="amd64"
66fi
Test User7d866122019-07-09 17:52:35 +000067
68# Verify TYPE setting
69if [ $(echo ":minimal:full:" | grep -ic ":$TYPE:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -070070 >&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 +000071 exit 1
72fi
73
74# Verify WITH_BBSIM settting and convert uniform value of yes or no
75if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_BBSIM:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -070076 >&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 +000077 exit 1
78fi
79if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_BBSIM:") -eq 1 ]; then
80 WITH_BBSIM=yes
81else
82 WITH_BBSIM=no
83fi
84
David Bainbridge5b7b96b2019-07-25 20:29:13 +000085# Verify WITH_RADIUS settting and convert uniform value of yes or no
86if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_RADIUS:") -eq 0 ]; then
87 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_RADIUS value of '$WITH_RADIUS'. Should be 'yes' or 'no'${NORMAL}"
88 exit 1
89fi
90if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_RADIUS:") -eq 1 ]; then
91 WITH_RADIUS=yes
92else
93 WITH_RADIUS=no
94fi
95
David Bainbridge01294952019-07-30 19:33:45 +000096# Verify WITH_TP settting and convert uniform value of yes or no
97if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_TP:") -eq 0 ]; then
98 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_TP value of '$WITH_TP'. Should be 'yes' or 'no'${NORMAL}"
99 exit 1
100fi
101if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_TP:") -eq 1 ]; then
102 WITH_TP=yes
103else
104 WITH_TP=no
105fi
106
David Bainbridgeb270c202019-07-26 01:44:42 +0000107# Verify WITH_ONOS settting and convert uniform value of yes or no
108if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_ONOS:") -eq 0 ]; then
109 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_ONOS value of '$WITH_ONOS'. Should be 'yes' or 'no'${NORMAL}"
110 exit 1
111fi
112if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_ONOS:") -eq 1 ]; then
113 WITH_ONOS=yes
114else
115 WITH_ONOS=no
116fi
117
Test Userba1e7e72019-07-10 22:27:54 +0000118# Verify JUST_K8S settting and convert uniform value of yes or no
119if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$JUST_K8S:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700120 >&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 +0000121 exit 1
122fi
123if [ $(echo ":y:yes:true:1:" | grep -ic ":$JUST_K8S:") -eq 1 ]; then
124 JUST_K8S=yes
125else
126 JUST_K8S=no
127fi
128
129# Verify DEPLOY_K8S settting and convert uniform value of yes or no
130if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$DEPLOY_K8S:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700131 >&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 +0000132 exit 1
133fi
134if [ $(echo ":y:yes:true:1:" | grep -ic ":$DEPLOY_K8S:") -eq 1 ]; then
135 DEPLOY_K8S=yes
136else
137 DEPLOY_K8S=no
138fi
Test User01ed0642019-07-03 20:17:06 +0000139
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700140# Verify INSTALL_KUBECTL settting and convert uniform value of yes or no
141if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$INSTALL_KUBECTL:") -eq 0 ]; then
142 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$INSTALL_KUBECTL value of '$INSTALL_KUBECTL'. Should be 'yes' or 'no'${NORMAL}"
143 exit 1
144fi
145
146if [ $(echo ":y:yes:true:1:" | grep -ic ":$INSTALL_KUBECTL:") -eq 1 ]; then
147 INSTALL_KUBECTL=yes
148else
149 INSTALL_KUBECTL=no
150fi
151
David Bainbridgee10f6d52019-07-25 00:28:13 +0000152# Verify SKIP_RESTART_API settting and convert uniform value of yes or no
153if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$SKIP_RESTART_API:") -eq 0 ]; then
154 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$SKIP_RESTART_API value of '$SKIP_RESTART_API'. Should be 'yes' or 'no'${NORMAL}"
155 exit 1
156fi
157if [ $(echo ":y:yes:true:1:" | grep -ic ":$SKIP_RESTART_API:") -eq 1 ]; then
158 SKIP_RESTART_API=yes
159else
160 SKIP_RESTART_API=no
161fi
162
David Bainbridge1ceabc12019-07-25 17:21:05 +0000163# Verify USE_GO settting and convert uniform value of yes or no
164if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$USE_GO:") -eq 0 ]; then
165 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$USE_GO value of '$USE_GO'. Should be 'yes' or 'no'${NORMAL}"
166 exit 1
167fi
168if [ $(echo ":y:yes:true:1:" | grep -ic ":$USE_GO:") -eq 1 ]; then
169 USE_GO=true
170else
171 USE_GO=false
172fi
173
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700174# Verify INSTALL_HELM settting and convert uniform value of yes or no
175if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$INSTALL_HELM:") -eq 0 ]; then
176 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$INSTALL_HELM value of '$INSTALL_HELM'. Should be 'yes' or 'no'${NORMAL}"
177 exit 1
178fi
179
180if [ $(echo ":y:yes:true:1:" | grep -ic ":$INSTALL_HELM:") -eq 1 ]; then
181 INSTALL_HELM=yes
182else
183 INSTALL_HELM=no
184fi
185
Test User01ed0642019-07-03 20:17:06 +0000186if [ "$TYPE" == "full" ]; then
David Bainbridge01294952019-07-30 19:33:45 +0000187 ONOS_API_PORT=${ONOS_API_PORT:-8182}
188 ONOS_SSH_PORT=${ONOS_SSH_PORT:-8102}
189 VOLTHA_API_PORT=${VOLTHA_API_PORT:-55556}
190 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-5023}
David Bainbridgeac7f8072019-08-01 22:15:33 +0000191 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-2379}
Test User01ed0642019-07-03 20:17:06 +0000192else
193 ONOS_API_PORT=${ONOS_API_PORT:-8181}
194 ONOS_SSH_PORT=${ONOS_SSH_PORT:-8101}
195 VOLTHA_API_PORT=${VOLTHA_API_PORT:-55555}
196 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-5022}
David Bainbridgeac7f8072019-08-01 22:15:33 +0000197 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-2379}
Test User01ed0642019-07-03 20:17:06 +0000198fi
199
David Bainbridge01294952019-07-30 19:33:45 +0000200if [ "$WITH_TP" == "yes" ]; then
201 SADIS_VER=3.1.0
202 OLT_VER=3.0.1
203 AAA_VER=1.9.0
204 DHCP_VER=1.6.0
205else
206 SADIS_VER=2.2.0
207 OLT_VER=2.1.0
208 AAA_VER=1.8.0
209 DHCP_VER=1.5.0
210fi
211
212export SADIS_VER OLT_VER AAA_VER DHCP_VER
213
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700214spin() {
Test Userd87942b2019-07-03 07:20:24 +0000215 PARTS="\
216 \xe2\xa2\x8e\xe2\xa1\xb0 \
217 \xe2\xa2\x8e\xe2\xa1\xa1 \
218 \xe2\xa2\x8e\xe2\xa1\x91 \
219 \xe2\xa2\x8e\xe2\xa0\xb1 \
220 \xe2\xa0\x8e\xe2\xa1\xb1 \
221 \xe2\xa2\x8a\xe2\xa1\xb1 \
222 \xe2\xa2\x8c\xe2\xa1\xb1 \
223 \xe2\xa2\x86\xe2\xa1\xb1 \
224 "
225 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700226 tput civis
227 while true; do
Test Userd87942b2019-07-03 07:20:24 +0000228 C=$(echo $PARTS | cut '-d ' -f $IDX)
229 echo -en "$C"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700230 IDX=$(expr $IDX + 1)
Test Userd87942b2019-07-03 07:20:24 +0000231 if [ $IDX -gt 8 ]; then
232 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700233 fi
234 sleep .15
235 echo -en "\r"
236 done
237}
238
Test Userd87942b2019-07-03 07:20:24 +0000239SPIN_PARTS="\
240 \xe2\xa2\x8e\xe2\xa1\xb0 \
241 \xe2\xa2\x8e\xe2\xa1\xa1 \
242 \xe2\xa2\x8e\xe2\xa1\x91 \
243 \xe2\xa2\x8e\xe2\xa0\xb1 \
244 \xe2\xa0\x8e\xe2\xa1\xb1 \
245 \xe2\xa2\x8a\xe2\xa1\xb1 \
246 \xe2\xa2\x8c\xe2\xa1\xb1 \
247 \xe2\xa2\x86\xe2\xa1\xb1 \
248 "
249IDX=1
250NOT_VERIFIED="\xe2\x9c\x97\x20"
251VERIFIED="\xe2\x9c\x93\x20"
Test Userb5712372019-07-03 21:52:17 +0000252HELM="\xE2\x8E\x88"
253OLD_KEY="\xF0\x9F\x97\x9D"
254BIRD="\xF0\x9F\x90\xA6"
255HIGH_VOLTAGE="\xE2\x9A\xA1"
256PLUG="\xF0\x9F\xa7\xa9"
257RESTART="\xf0\x9f\x94\x84"
258FORWARD="\xE2\x87\xA8"
259INSTALL="\xF0\x9F\x8F\x97"
260STOP="\xf0\x9f\x9b\x91"
261GO="\xf0\x9f\x9a\x80"
262DOWNLOAD="\xf0\x9f\x93\xa5"
263GEAR="\xe2\x9a\x99"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700264NO_ENTRY="\xe2\x9b\x94"
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000265LOCK="\xf0\x9f\x94\x92"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700266
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700267bspin() {
268 tput civis
Test Userd87942b2019-07-03 07:20:24 +0000269 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700270 local INDENT=
271 if [ "$1" == "-" ]; then
272 INDENT=" "
273 shift
274 fi
Test Userd87942b2019-07-03 07:20:24 +0000275 echo -en "$INDENT $*"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700276}
277
278sspin() {
279 local INDENT=
280 if [ "$1" == "-" ]; then
281 INDENT=" "
282 shift
283 fi
Test Userd87942b2019-07-03 07:20:24 +0000284 C=$(echo $SPIN_PARTS | cut '-d ' -f $IDX)
285 echo -en "\r$INDENT$C $*"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700286 IDX=$(expr $IDX + 1)
Test Userd87942b2019-07-03 07:20:24 +0000287 if [ $IDX -gt 8 ]; then
288 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700289 fi
290}
291
292espin() {
293 local INDENT=
294 if [ "$1" == "-" ]; then
295 INDENT=" "
296 shift
297 fi
298 echo -e "\r$INDENT$*"
299 tput cnorm
300}
301
David Bainbridgeac7f8072019-08-01 22:15:33 +0000302if [ "$1" == "get" -a "$2" == "voltconfig" ]; then
303 echo "$HOME/.volt/config-$TYPE"
304 exit
305fi
306
307if [ $# -ne 1 -o $(echo ":up:down:dump:" | grep -c ":$1:") -ne 1 ]; then
308 >&2 echo "What wouild you like to do today:"
309 >&2 echo " up - bring up voltha"
310 >&2 echo " down - tear down voltha"
311 >&2 echo " dump - create a debug dump of running system"
312 exit 1
313fi
314
315if [ "$1" == "down" ]; then
316 if [ $DEPLOY_K8S == "yes" ]; then
317 if [ -x ./bin/kind ]; then
318 exec ./bin/kind delete cluster --name voltha-$TYPE
319 else
320 >&2 echo "Kind doesn't seem to be installed, so nothing to do. Bye."
321 fi
322 else
323 EXISTS=$(helm list -q)
324 EXPECT="etcd-operator onos open-olt open-onu sim voltha bbsim radius"
325 INTERSECT=
326 for i in $EXISTS; do
327 if [ $(echo $EXPECT | grep -c $i) -eq 1 ]; then
328 HAVE="$HAVE $i"
329 fi
330 done
331 if [ "$HAVE X" != " X" ]; then
332 ./bin/helm delete --purge $HAVE
333 fi
334 fi
335 exit
336fi
337
338if [ "$1" == "dump" ]; then
339 LOG="dump-$TYPE.log"
340 TS=$(date -u +"%Y%m%dT%H%M%SZ")
341 WORK=$(mktemp -u -d)
342 DATA=$WORK/voltha-debug-dump-$TS
343 mkdir -p $DATA
344 echo $TS > $LOG
345 echo -e "Capturing debug dump to voltha-debug-dump-$TS.tgz"
346 bspin - "Copy install log"
347 if [ -f install-$TYPE.log ]; then
348 (set -x; cp install-$TYPE.log $DATA/install-$TYPE.log) >>$LOG 2>&1
349 espin - $VERIFIED
350 else
351 espin - "$NO_ENTRY Copy install log: install-$TYPE.log not found"
352 fi
353 bspin - "Dumping Kubernetes PODs"
354 (set -x; kubectl get --all-namespaces pods >> $DATA/all-pods.txt 2>&1) >>$LOG 2>&1
355 espin - $VERIFIED
356 bspin - "Dumping Kubernetes SERVICEs"
357 (set -x; kubectl get --all-namespaces svc >> $DATA/all-services.txt 2>&1) >>$LOG 2>&1
358 espin - $VERIFIED
359 bspin - "Dumping Kubernetes EVENTs"
360 (set -x; kubectl get --all-namespaces events >> $DATA/all-events.txt 2>&1) >>$LOG 2>&1
361 espin - $VERIFIED
362 bspin - "Dumping VOLTHA POD details"
363 PODS=$(kubectl get -n voltha pod -o name)
364 for POD in $PODS; do
365 sspin - "Dumping VOLTHA POD details: $POD$CEOL"
366 mkdir -p $DATA/$POD
367 (set -x; kubectl describe -n voltha $POD >> $DATA/$POD/describe.txt 2>&1) >>$LOG 2>&1
368 sspin - "Dumping VOLTHA POD details: $POD"
369 (set -x; kubectl logs -n voltha --all-containers --previous $LOG_ARGS $POD >> $DATA/$POD/logs-previous.txt 2>&1) >>$LOG 2>&1
370 sspin - "Dumping VOLTHA POD details: $POD"
371 (set -x; kubectl logs -n voltha --all-containers $LOG_ARGS $POD >> $DATA/$POD/logs-current.txt 2>&1) >>$LOG 2>&1
372 sspin - "Dumping VOLTHA POD details: $POD"
373 done
374 espin - "$VERIFIED Dumping VOLTHA POD details$CEOL"
375 bspin - "Dumping ETCD"
376 if [ "$(which etcdctl) X" != " X" ]; then
377 (set -x; ETCDCTL_API=3 etcdctl --endpoints localhost:2379 get --prefix service/voltha | hexdump -C >> $DATA/etcd.hex 2>&1) >>$LOG 2>&1
378 espin - $VERIFIED
379 else
380 espin - "$NO_ENTRY Dumping ETCD: etcdctl command not available"
381 fi
382 bspin - "Creating compressed TAR: voltha-debug-dump-$TS.tgz"
383 (set -x; tar -C $WORK -zcf voltha-debug-dump-$TS.tgz ./voltha-debug-dump-$TS) >>$LOG 2>&1
384 espin - $VERIFIED
385 bspin - "Cleanup"
386 (set -x; rm -rf $WORK) >>$LOG 2>&1
387 espin - $VERIFIED
388 bspin - "$(ls -l voltha-debug-dump-$TS.tgz)"
389 espin - $VERIFIED
390 exit
391fi
392
393
394LOG="install-$TYPE.log"
395date > $LOG
396
397# Output install options to log
398echo "OPTIONS" >> $LOG
399ALL_OPTIONS="TYPE WITH_BBSIM WITH_RADIUS WITH_ONOS WITH_TP JUST_K8S DEPLOY_K8S \
400 SKIP_RESTART_API INSTALL_KUBECTL INSTALL_HELM USE_GO VOLTHA_LOG_LEVEL \
401 VOLTHA_CHART VOLTHA_ADAPTER_SIM_CHART VOLTHA_ADAPTER_OPEN_OLT_CHART \
402 VOLTHA_ADAPTER_OPEN_ONU_CHART SADIS_VER OLT_VER AAA_VER DHCP_VER"
403for O in $ALL_OPTIONS; do
404 VAL=$(eval echo \$$O)
405 if [ $O == "USE_GO" ]; then
406 VAL="$(echo $VAL| test $(grep -c true) -eq 1 && echo yes || echo no)"
407 fi
408 if [ ! -z "$VAL" ]; then
409 printf " %-30s = %s\n" $O $VAL >> $LOG
410 fi
411done
412
413
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700414count_pods() {
415 local NAMESPACE=$1; shift
416 local PODS=$(kubectl -n $NAMESPACE get pod -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}")
417 local COUNT=0
418 local PATTERNS=$*
419 for POD in $PODS; do
420 local NAME=$(echo $POD | cut -d/ -f 1)
421 local STATE=$(echo $POD | cut -d/ -f 2)
422 local CONTAINERS=$(echo $POD | cut -d/ -f 3 | sed -e 's/_/ /g')
423 if [ "$STATE" == "Running" ]; then
424 local TOTAL=$(echo $CONTAINERS | wc -w)
425 local FOUND=$(echo $CONTAINERS | grep -o true | wc -l)
426 if [ $TOTAL -eq $FOUND ]; then
427 for PATTERN in $PATTERNS; do
428 if [[ $NAME =~ $PATTERN ]]; then
429 COUNT=$(expr $COUNT + 1)
430 fi
431 done
432 fi
433 fi
434 done
435 echo $COUNT
436}
437
438wait_for_pods() {
439 local INDENT=
440 if [ "$1" == "-" ]; then
441 INDENT=$1; shift
442 fi
443 local NAMESPACE=$1; shift
444 local EXPECT=$1; shift
445 local RETRY=$1; shift
446 local MESSAGE=$1; shift
447 local PATTERNS=$*
448 local HAVE=$(count_pods $NAMESPACE $PATTERNS)
449 COUNT=$(expr 300 / 15)
450 bspin $INDENT $MESSAGE
451 sspin $INDENT
452 if [ $HAVE -ne $EXPECT ]; then
453 while [ $HAVE -ne $EXPECT ]; do
454 sspin $INDENT
455 COUNT=$(expr $COUNT - 1)
456 if [ $COUNT -eq 0 ]; then
457 HAVE=$(count_pods $NAMESPACE $PATTERNS)
458 COUNT=$(expr 300 / 15)
459 fi
460 sleep .15
461 done
462 fi
463 espin $INDENT $VERIFIED
464 if [ $HAVE -ne $EXPECT ]; then
465 return 1
466 fi
467 return 0
468}
469
470helm_install() {
471 local INDENT=
472 if [ "$1" == "-" ]; then
473 INDENT=$1; shift
474 fi
475 local NAMESPACE=$1; shift
476 local NAME=$1; shift
477 local CHART=$1; shift
478 local MESSAGE=$*
479
480 COUNT=$(expr 300 / 15)
481 bspin $INDENT $MESSAGE
David Bainbridge1ceabc12019-07-25 17:21:05 +0000482 (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 -0700483 SUCCESS=$?
484 while [ $SUCCESS -ne 0 ]; do
485 sspin $INDENT
486 COUNT=$(expr $COUNT - 1)
487 if [ $COUNT -eq 0 ]; then
David Bainbridgee10f6d52019-07-25 00:28:13 +0000488 (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 -0700489 COUNT=$(expr 300 / 15)
490 fi
491 sleep .15
492 done
493 espin $INDENT $VERIFIED
494}
495
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700496echo "INSTALL TYPE: $TYPE" >> $LOG
497
498bspin "Verify GOPATH"
499export GOPATH=$(pwd)
Test User3d7ad8e2019-07-03 06:15:44 +0000500mkdir -p $GOPATH/bin
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700501espin $VERIFIED
502
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700503if [ "$INSTALL_KUBECTL" == "no" ]; then
504 bspin "Skip kubectl install"
505 espin $NO_ENTRY
Test Userc13bdc92019-07-03 20:57:49 +0000506else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700507 bspin "Verify kubectl $HELM"
508 if [ -x $GOPATH/bin/kubectl ]; then
509 espin $VERIFIED
510 else
511 espin $NOT_VERIFIED
512 bspin - "Download and install Kubernetes/kubectl $DOWNLOAD"
513 (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
514 (set -x; chmod 755 $GOPATH/bin/kubectl >>$LOG 2>&1) >>$LOG 2>&1
515 espin - $VERIFIED
516 fi
Test Userc13bdc92019-07-03 20:57:49 +0000517fi
518
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700519if [ "$DEPLOY_K8S" == "no" ]; then
520 bspin "Skip Kubernetes/Kind Deployment"
521 espin $NO_ENTRY
522else
Test Userba1e7e72019-07-10 22:27:54 +0000523 bspin "Verify Kubernetes/Kind $HELM"
524 if [ -x $GOPATH/bin/kind ]; then
525 espin $VERIFIED
526 else
527 espin $NOT_VERIFIED
528 bspin - "Download and install Kubernetes/kind $DOWNLOAD"
David Bainbridge9e2a6662019-07-11 17:07:57 +0000529 (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 +0000530 (set -x; chmod 755 $GOPATH/bin/kind >>$LOG 2>&1) >>$LOG 2>&1
531 espin - $VERIFIED
532 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700533fi
534
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700535if [ "$INSTALL_HELM" == "no" ]; then
536 bspin "Skip Helm Install"
537 espin $NO_ENTRY
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700538else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700539 bspin "Verify Helm $HELM"
540 if [ -x $GOPATH/bin/helm ]; then
541 espin $VERIFIED
542 else
543 espin $NOT_VERIFIED
544 bspin - "Download and install Helm $DOWNLOAD"
545 (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
546 espin - $VERIFIED
547 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700548fi
549
Test Userb5712372019-07-03 21:52:17 +0000550bspin "Verify voltctl $HIGH_VOLTAGE"
Test User3d7ad8e2019-07-03 06:15:44 +0000551if [ -x $GOPATH/bin/voltctl ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700552 espin $VERIFIED
553else
554 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000555 bspin - "Download and build voltctl $DOWNLOAD"
Test Userba1e7e72019-07-10 22:27:54 +0000556 (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 +0000557 (set -x; chmod 755 $GOPATH/bin/voltctl >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700558 espin - $VERIFIED
559fi
560
561bspin "Verify command PATH"
Test Userba1e7e72019-07-10 22:27:54 +0000562export PATH=$GOPATH/bin:$PATH
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700563espin $VERIFIED
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700564
Test Userba1e7e72019-07-10 22:27:54 +0000565if [ "$DEPLOY_K8S" == "yes" ]; then
566 HAVE=$(kind get clusters | grep -c voltha-$TYPE)
567 bspin "Verify Kubernetes/Kind Cluster"
568 sspin
569 if [ $HAVE -eq 0 ]; then
David Bainbridge491b1bd2019-07-11 17:53:11 +0000570 espin $NOT_VERIFIED
571 bspin - "Verify cluster configuration"
572 if [ ! -r ./$TYPE-cluster.cfg ]; then
573 espin - $NOT_VERIFIED
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700574 bspin - "Download cluster configuration: $TYPE-cluster.cfg $DOWNLOAD"
David Bainbridge491b1bd2019-07-11 17:53:11 +0000575 (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 -0700576 espin - $VERIFIED
577 else
578 espin - $VERIFIED
579 fi
David Bainbridge491b1bd2019-07-11 17:53:11 +0000580 kind create cluster --name voltha-$TYPE --config $TYPE-cluster.cfg
581 else
582 espin $VERIFIED
Test Userba1e7e72019-07-10 22:27:54 +0000583 fi
584
585 export KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$TYPE")"
586 P="coredns-.* \
587 etcd-voltha-$TYPE-control-plane \
588 kindnet-.* \
589 kube-apiserver-voltha-$TYPE-control-plane \
590 kube-controller-manager-voltha-$TYPE-control-plane \
591 kube-proxy-.* \
592 kube-scheduler-voltha-$TYPE-control-plane"
593
594 EXPECT=$(test "$TYPE" == "minimal" && echo "12" || echo "14")
595 wait_for_pods - "kube-system" $EXPECT -1 "Waiting for system PODs to start" $P
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700596fi
597
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700598COUNT=$(count_pods "kube-system" "tiller-deploy-.*")
599bspin "Verify Helm"
Test Userba1e7e72019-07-10 22:27:54 +0000600if [ $COUNT -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700601 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000602 echo -e "Configuring Helm $GEAR"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700603 if [ "$INSTALL_HELM" == "no" ]; then
604 bspin - "Skip Helm/Tiller Initialization"
605 espin - $NO_ENTRY
606 else
607 bspin - "Initialize Helm"
608 (set -x; helm init --upgrade >>$LOG 2>&1) >>$LOG 2>&1
609 espin - $VERIFIED
610 wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
611 fi
Test Userb5712372019-07-03 21:52:17 +0000612 bspin - "Add Google Incubator repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700613 (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
614 espin - $VERIFIED
Test Userba1e7e72019-07-10 22:27:54 +0000615
616 # HACK (sort-of) - the config for tiller is about to be patched, which will
617 # cause the tiller pod to be recreated. This can sometimes cause a timing
618 # issue with the "wait_for_pods" call on tiller as it may incorrectly
619 # identify the running/ready tiller pod that is soon to be terminated as
620 # what it is waiting for. To avoid this issue we do a clean scale down and
621 # scale up of the pod so the script controlls when it should be expecting
622 # things
623 (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 -0700624
Test Userb5712372019-07-03 21:52:17 +0000625 bspin - "Add Google Stable repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700626 (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
627 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000628 bspin - "Add ONF repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700629 (set -x; helm repo add onf https://charts.opencord.org >>$LOG 2>&1) >>$LOG 2>&1
630 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000631 bspin - "Update Helm repository cache"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700632 (set -x; helm repo update >>$LOG 2>&1) >>$LOG 2>&1
633 espin - $VERIFIED
634
635 # Create and k8s service account so that Helm can create pods
Test Userb5712372019-07-03 21:52:17 +0000636 bspin - "Create Tiller ServiceAccount"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700637 (set -x; kubectl create serviceaccount --namespace kube-system tiller >>$LOG 2>&1) >>$LOG 2>&1
638 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000639 bspin - "Create Tiller ClusterRoleBinding"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700640 (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>$LOG 2>&1) >>$LOG 2>&1
641 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000642 bspin - "Update Tiller Manifest"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700643 (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 +0000644
645 # HACK (sort-of) - part to, spin it back up
646 (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 -0700647 espin - $VERIFIED
648else
649 espin $VERIFIED
650fi
Test Userb5712372019-07-03 21:52:17 +0000651wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700652
Test Userba1e7e72019-07-10 22:27:54 +0000653bspin "Verify Helm values file: $TYPE-values.yaml"
654if [ ! -r "./$TYPE-values.yaml" ]; then
655 espin $NOT_VERIFIED
656 bspin - "Download Helm values file: $TYPE-values.yaml $DOWNLOAD"
657 (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
658 espin - $VERIFIED
659else
660 espin $VERIFIED
661fi
662
663if [ "$JUST_K8S" == "yes" ]; then
664 echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye."
665 echo ""
666 echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
667 echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
668 echo "tools required by VOLTHA in your command path. " | tee -a $LOG
669 echo "" | tee -a $LOG
670 echo -en $BOLD
671 if [ $DEPLOY_K8S == "yes" ]; then
672 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$TYPE\")\"" | tee -a $LOG
673 fi
674 echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
675 echo -en $NORMAL
676 echo "" | tee -a $LOG
677 echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
678 exit 0
679fi
680
Test Userb5712372019-07-03 21:52:17 +0000681bspin "Verify ETCD Operator $OLD_KEY"
Test User7d866122019-07-09 17:52:35 +0000682if [ $(helm list --deployed --short --namespace voltha "^etcd-operator\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700683 espin $NOT_VERIFIED
684 helm_install - voltha etcd-operator stable/etcd-operator "Install ETCD Operator"
685else
686 espin $VERIFIED
687fi
Test User01ed0642019-07-03 20:17:06 +0000688EXPECT=$(test "$TYPE" == "minimal" && echo "1" || echo "3")
Test Userb5712372019-07-03 21:52:17 +0000689wait_for_pods - "voltha" $EXPECT -1 "Waiting for ETCD Operator to start" "etcd-operator-.*"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700690
David Bainbridgeb270c202019-07-26 01:44:42 +0000691if [ $WITH_ONOS == "yes" ]; then
692 bspin "Verify ONOS installed $BIRD"
693 if [ $(helm list --deployed --short --namespace default "^onos\$" | wc -l) -ne 1 ]; then
694 espin $NOT_VERIFIED
695 helm_install - default onos onf/onos "Install ONOS"
696 else
697 espin $VERIFIED
698 fi
699 wait_for_pods - "default" 1 -1 "Waiting for ONOS to start" "onos-.*"
700
701 bspin - "Forward ONOS API port $FORWARD"
David Bainbridge82bd1212019-07-29 19:19:31 +0000702 for i in $(screen -ls | grep onos-ui-$TYPE | awk '{print $1}'); do
703 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
704 done
705 (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 +0000706 espin - $VERIFIED
707 bspin - "Forward ONOS SSH port $FORWARD"
David Bainbridge82bd1212019-07-29 19:19:31 +0000708 for i in $(screen -ls | grep onos-ssh-$TYPE | awk '{print $1}'); do
709 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
710 done
711 (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 +0000712 espin - $VERIFIED
713 if [ ! -x ./onos-files/install-onos-applications.sh ]; then
714 bspin - "Verify or download ONOS configuration support files $DOWNLOAD"
715 (set -x; mkdir -p ./onos-files >>$LOG 2>&1) >>$LOG 2>&1
716 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
717 if [ ! -r ./onos-files/$i ]; then
718 (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
719 fi
720 done
721 (set -x; chmod 755 ./onos-files/install-onos-applications.sh >>$LOG 2>&1) >>$LOG 2>&1
722 espin - $VERIFIED
723 fi
724
725 bspin - "Install required ONOS applications $INSTALL"
726 (set -x; ./onos-files/install-onos-applications.sh >>$LOG 2>&1) >>$LOG 2>&1
Test Userba1e7e72019-07-10 22:27:54 +0000727 espin - $VERIFIED
728fi
729
Test Userb5712372019-07-03 21:52:17 +0000730bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
Test User7d866122019-07-09 17:52:35 +0000731if [ $(helm list --deployed --short --namespace voltha "^voltha\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700732 espin $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +0000733 helm_install - voltha voltha $VOLTHA_CHART "Install VOLTHA Core"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700734else
735 espin $VERIFIED
736fi
Test Userba1e7e72019-07-10 22:27:54 +0000737
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700738VOLTHA="ofagent-.* \
739 ro-core.* \
740 rw-core.* \
741 voltha-api-server-.* \
742 voltha-cli-server-.* \
743 voltha-etcd-cluster-.* \
744 voltha-kafka-.* \
745 voltha-zookeeper-.*"
Test User01ed0642019-07-03 20:17:06 +0000746EXPECT=$(test "$TYPE" == "minimal" && echo "9" || echo "11")
Test Userb5712372019-07-03 21:52:17 +0000747wait_for_pods - "voltha" $EXPECT -1 "Waiting for VOLTHA Core to start" $VOLTHA
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700748
Test Userb5712372019-07-03 21:52:17 +0000749echo -e "Verify Adapters $PLUG"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700750bspin - "Verify Simulated Adapters installed"
Test User7d866122019-07-09 17:52:35 +0000751if [ $(helm list --deployed --short --namespace voltha "^sim\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700752 espin - $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +0000753 helm_install - voltha sim $VOLTHA_ADAPTER_SIM_CHART "Install Simulated Adapters"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700754else
755 espin - $VERIFIED
756fi
757
758bspin - "Verify OpenOLT Adapter installed"
Test User7d866122019-07-09 17:52:35 +0000759if [ $(helm list --deployed --short --namespace voltha "^open-olt\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700760 espin - $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +0000761 helm_install - voltha open-olt $VOLTHA_ADAPTER_OPEN_OLT_CHART "Install OpenOLT Adapter"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700762else
763 espin - $VERIFIED
764fi
765bspin - "Verify OpenONU Adapter installed"
Test User7d866122019-07-09 17:52:35 +0000766if [ $(helm list --deployed --short --namespace voltha "^open-onu\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700767 espin - $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +0000768 helm_install - voltha open-onu $VOLTHA_ADAPTER_OPEN_ONU_CHART "Install OpenONU Adapter"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700769else
770 espin - $VERIFIED
771fi
772
773ADAPTERS="adapter-.*"
Test Userb5712372019-07-03 21:52:17 +0000774wait_for_pods - "voltha" 4 -1 "Waiting for adapters to start" $ADAPTERS
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700775
Test User7d866122019-07-09 17:52:35 +0000776if [ $WITH_BBSIM == "yes" ]; then
777 echo -e "Verify BBSIM $PLUG"
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000778 bspin - "Verify BBSIM Installed"
Test User7d866122019-07-09 17:52:35 +0000779 if [ $(helm list --deployed --short --namespace voltha "^bbsim\$" | wc -l) -ne 1 ]; then
780 espin - $NOT_VERIFIED
781 helm_install - voltha bbsim onf/bbsim "Install BBSIM"
782 else
783 espin - $VERIFIED
784 fi
785 wait_for_pods - "voltha" 1 -1 "Waiting for BBSIM to start" "bbsim-.*"
786fi
787
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000788if [ $WITH_RADIUS == "yes" ]; then
789 echo -e "Verify RADIUS $LOCK"
790 bspin - "Verify RADIUS Installed"
791 if [ $(helm list --deployed --short --namespace voltha "^radius\$" | wc -l) -ne 1 ]; then
792 espin - $NOT_VERIFIED
793 helm_install - voltha radius onf/freeradius "Install RADIUS"
794 else
795 espin - $VERIFIED
796 fi
797 wait_for_pods - "voltha" 1 -1 "Waiting for RADIUS to start" "radius-.*"
798fi
799
David Bainbridgee10f6d52019-07-25 00:28:13 +0000800if [ $SKIP_RESTART_API == "no" ]; then
801 echo -e "Restart VOLTHA API $RESTART"
802 API="voltha-api-server-.* ofagent-.*"
803 (set -x; kubectl scale --replicas=0 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1
804 wait_for_pods - "voltha" 0 -1 "Wait for API to stop $STOP" $API
805 (set -x; kubectl scale --replicas=1 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1
806 wait_for_pods - "voltha" 2 -1 "Wait for API to re-start $GO" $API
807else
808 bspin "Skip VOLTHA API Restart"
809 espin $NO_ENTRY
810fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700811
Test Userb5712372019-07-03 21:52:17 +0000812bspin - "Forward VOLTHA API port $FORWARD"
David Bainbridge82bd1212019-07-29 19:19:31 +0000813for i in $(screen -ls | grep voltha-api-$TYPE | awk '{print $1}'); do
814 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
815done
816(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 -0700817espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000818bspin - "Forward VOLTHA SSH port $FORWARD"
David Bainbridge82bd1212019-07-29 19:19:31 +0000819for i in $(screen -ls | grep voltha-ssh-$TYPE | awk '{print $1}'); do
820 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
821done
822(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 -0700823espin - $VERIFIED
David Bainbridgeac7f8072019-08-01 22:15:33 +0000824bspin - "Forward VOLTHA ETCD port $FORWARD"
825for i in $(screen -ls | grep voltha-etcd-$TYPE | awk '{print $1}'); do
826 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
827done
828(set -x; screen -dmS voltha-etcd-$TYPE 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
829espin - $VERIFIED
Test User3d7ad8e2019-07-03 06:15:44 +0000830
David Bainbridgeb270c202019-07-26 01:44:42 +0000831if [ $WITH_ONOS == "yes" -a $WITH_RADIUS == "yes" ]; then
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000832 bspin "Configure ONOS RADIUS Connection $GEAR"
833 (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
834 espin $VERIFIED
835fi
836
837bspin "Create voltctl configuration file"
Test User3d7ad8e2019-07-03 06:15:44 +0000838(set -x; mkdir -p $HOME/.volt >>$LOG 2>&1) >>$LOG 2>&1
Test User01ed0642019-07-03 20:17:06 +0000839(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 +0000840espin $VERIFIED
Test User08ebbd92019-07-03 17:15:39 +0000841
David Bainbridgeb07fdf72019-07-29 22:51:40 +0000842if [ ! -f "$TYPE-env.sh" ]; then
843 touch $TYPE-env.sh
844fi
845
David Bainbridge596f30d2019-07-30 17:07:59 +0000846for O in $ALL_OPTIONS; do
847 VAL=$(eval echo \$$O)
848 if [ $O == "USE_GO" ]; then
849 VAL="$(echo $VAL| test $(grep -c true) -eq 1 && echo yes || echo no)"
850 fi
851 if [ ! -z "$VAL" -a $(grep -c "^export $O=" $TYPE-env.sh) -eq 0 ]; then
David Bainbridgeb07fdf72019-07-29 22:51:40 +0000852 echo "export $O=\"$(eval echo \$$O)\"" >> $TYPE-env.sh
853 fi
854done
855
856if [ $DEPLOY_K8S == "yes" -a $(grep -c "^export KUBECONFIG=" $TYPE-env.sh) -eq 0 ]; then
857 echo "export KUBECONFIG=\"$(./bin/kind get kubeconfig-path --name=voltha-$TYPE)\"" >> $TYPE-env.sh
858fi
859
860if [ $(grep -c "^export VOLTCONFIG=" $TYPE-env.sh) -eq 0 ]; then
861 echo "export VOLTCONFIG=\"$HOME/.volt/config-$TYPE\"" >> $TYPE-env.sh
862fi
863
864if [ $(grep -c "^export PATH=" $TYPE-env.sh) -eq 0 ]; then
865 echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> $TYPE-env.sh
866fi
867
Test User7d866122019-07-09 17:52:35 +0000868echo ""
Test User08ebbd92019-07-03 17:15:39 +0000869echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
870echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
871echo "tools required by VOLTHA in your command path. " | tee -a $LOG
872echo "" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +0000873echo -en $BOLD
Test Userba1e7e72019-07-10 22:27:54 +0000874if [ $DEPLOY_K8S == "yes" ]; then
875 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$TYPE\")\"" | tee -a $LOG
876fi
Test Userfa30f7f2019-07-03 20:35:19 +0000877echo "export VOLTCONFIG=\"$HOME/.volt/config-$TYPE\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +0000878echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +0000879echo -en $NORMAL
Test User08ebbd92019-07-03 17:15:39 +0000880echo "" | tee -a $LOG
881echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
882