blob: 9b9a6390fb49214c8ed6983703a9ab13d50e86e0 [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}
David Bainbridge0774b232019-08-02 06:37:19 +000045NAME=${NAME:-$TYPE}
Test User7d866122019-07-09 17:52:35 +000046WITH_BBSIM=${WITH_BBSIM:-no}
David Bainbridge5b7b96b2019-07-25 20:29:13 +000047WITH_RADIUS=${WITH_RADIUS:-no}
David Bainbridgeb270c202019-07-26 01:44:42 +000048WITH_ONOS=${WITH_ONOS:-yes}
David Bainbridge01294952019-07-30 19:33:45 +000049WITH_TP=${WITH_TP:-yes}
Test Userba1e7e72019-07-10 22:27:54 +000050JUST_K8S=${JUST_K8S:-no}
51DEPLOY_K8S=${DEPLOY_K8S:-yes}
David Bainbridgee10f6d52019-07-25 00:28:13 +000052SKIP_RESTART_API=${SKIP_RESTART_API:-no}
David K. Bainbridge0e89cb92019-07-17 11:30:10 -070053INSTALL_KUBECTL=${INSTALL_KUBECTL:-yes}
54INSTALL_HELM=${INSTALL_HELM:-yes}
David Bainbridge5b7b96b2019-07-25 20:29:13 +000055USE_GO=${USE_GO:-yes}
56VOLTHA_LOG_LEVEL=${VOLTHA_LOG_LEVEL:-WARN}
David Bainbridgee10f6d52019-07-25 00:28:13 +000057VOLTHA_CHART=${VOLTHA_CHART:=onf/voltha}
58VOLTHA_ADAPTER_SIM_CHART=${VOLTHA_ADAPTER_SIM_CHART:-onf/voltha-adapter-simulated}
59VOLTHA_ADAPTER_OPEN_OLT_CHART=${VOLTHA_ADAPTER_OPEN_OLT_CHART:-onf/voltha-adapter-openolt}
60VOLTHA_ADAPTER_OPEN_ONU_CHART=${VOLTHA_ADAPTER_OPEN_ONU_CHART:-onf/voltha-adapter-openonu}
Test Userba1e7e72019-07-10 22:27:54 +000061
62HAVE_GO=$(which go >/dev/null 2>&1 && echo "yes" || echo "no")
63HOSTOS=$(uname -s | tr "[:upper:]" "[:lower:"])
64HOSTARCH=$(uname -m | tr "[:upper:]" "[:lower:"])
65if [ $HOSTARCH == "x86_64" ]; then
66 HOSTARCH="amd64"
67fi
Test User7d866122019-07-09 17:52:35 +000068
69# Verify TYPE setting
70if [ $(echo ":minimal:full:" | grep -ic ":$TYPE:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -070071 >&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 +000072 exit 1
73fi
74
75# Verify WITH_BBSIM settting and convert uniform value of yes or no
76if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_BBSIM:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -070077 >&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 +000078 exit 1
79fi
80if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_BBSIM:") -eq 1 ]; then
81 WITH_BBSIM=yes
82else
83 WITH_BBSIM=no
84fi
85
David Bainbridge5b7b96b2019-07-25 20:29:13 +000086# Verify WITH_RADIUS settting and convert uniform value of yes or no
87if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_RADIUS:") -eq 0 ]; then
88 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_RADIUS value of '$WITH_RADIUS'. Should be 'yes' or 'no'${NORMAL}"
89 exit 1
90fi
91if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_RADIUS:") -eq 1 ]; then
92 WITH_RADIUS=yes
93else
94 WITH_RADIUS=no
95fi
96
David Bainbridge01294952019-07-30 19:33:45 +000097# Verify WITH_TP settting and convert uniform value of yes or no
98if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_TP:") -eq 0 ]; then
99 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_TP value of '$WITH_TP'. Should be 'yes' or 'no'${NORMAL}"
100 exit 1
101fi
102if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_TP:") -eq 1 ]; then
103 WITH_TP=yes
104else
105 WITH_TP=no
106fi
107
David Bainbridgeb270c202019-07-26 01:44:42 +0000108# Verify WITH_ONOS settting and convert uniform value of yes or no
109if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_ONOS:") -eq 0 ]; then
110 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_ONOS value of '$WITH_ONOS'. Should be 'yes' or 'no'${NORMAL}"
111 exit 1
112fi
113if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_ONOS:") -eq 1 ]; then
114 WITH_ONOS=yes
115else
116 WITH_ONOS=no
117fi
118
Test Userba1e7e72019-07-10 22:27:54 +0000119# Verify JUST_K8S settting and convert uniform value of yes or no
120if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$JUST_K8S:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700121 >&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 +0000122 exit 1
123fi
124if [ $(echo ":y:yes:true:1:" | grep -ic ":$JUST_K8S:") -eq 1 ]; then
125 JUST_K8S=yes
126else
127 JUST_K8S=no
128fi
129
130# Verify DEPLOY_K8S settting and convert uniform value of yes or no
131if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$DEPLOY_K8S:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700132 >&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 +0000133 exit 1
134fi
135if [ $(echo ":y:yes:true:1:" | grep -ic ":$DEPLOY_K8S:") -eq 1 ]; then
136 DEPLOY_K8S=yes
137else
138 DEPLOY_K8S=no
139fi
Test User01ed0642019-07-03 20:17:06 +0000140
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700141# Verify INSTALL_KUBECTL settting and convert uniform value of yes or no
142if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$INSTALL_KUBECTL:") -eq 0 ]; then
143 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$INSTALL_KUBECTL value of '$INSTALL_KUBECTL'. Should be 'yes' or 'no'${NORMAL}"
144 exit 1
145fi
146
147if [ $(echo ":y:yes:true:1:" | grep -ic ":$INSTALL_KUBECTL:") -eq 1 ]; then
148 INSTALL_KUBECTL=yes
149else
150 INSTALL_KUBECTL=no
151fi
152
David Bainbridgee10f6d52019-07-25 00:28:13 +0000153# Verify SKIP_RESTART_API settting and convert uniform value of yes or no
154if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$SKIP_RESTART_API:") -eq 0 ]; then
155 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$SKIP_RESTART_API value of '$SKIP_RESTART_API'. Should be 'yes' or 'no'${NORMAL}"
156 exit 1
157fi
158if [ $(echo ":y:yes:true:1:" | grep -ic ":$SKIP_RESTART_API:") -eq 1 ]; then
159 SKIP_RESTART_API=yes
160else
161 SKIP_RESTART_API=no
162fi
163
David Bainbridge1ceabc12019-07-25 17:21:05 +0000164# Verify USE_GO settting and convert uniform value of yes or no
165if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$USE_GO:") -eq 0 ]; then
166 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$USE_GO value of '$USE_GO'. Should be 'yes' or 'no'${NORMAL}"
167 exit 1
168fi
169if [ $(echo ":y:yes:true:1:" | grep -ic ":$USE_GO:") -eq 1 ]; then
170 USE_GO=true
171else
172 USE_GO=false
173fi
174
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700175# Verify INSTALL_HELM settting and convert uniform value of yes or no
176if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$INSTALL_HELM:") -eq 0 ]; then
177 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$INSTALL_HELM value of '$INSTALL_HELM'. Should be 'yes' or 'no'${NORMAL}"
178 exit 1
179fi
180
181if [ $(echo ":y:yes:true:1:" | grep -ic ":$INSTALL_HELM:") -eq 1 ]; then
182 INSTALL_HELM=yes
183else
184 INSTALL_HELM=no
185fi
186
David Bainbridge0774b232019-08-02 06:37:19 +0000187mkdir -p .voltha
188touch .voltha/ports
189HAVE=$(grep $NAME .voltha/ports)
190if [ "$HAVE X" == " X" ]; then
191 # Find free port prefix
192 START=81
193 while true; do
194 if [ $(grep -c $START .voltha/ports) -eq 0 ]; then
195 break
196 fi
197 START=$(expr $START + 1)
198 done
199 DELTA=$(expr $START - 81)
200 ONOS_API_PORT=${START}81
201 ONOS_SSH_PORT=${START}01
202 VOLTHA_API_PORT=5$(expr 55 + $DELTA)55
203 VOLTHA_SSH_PORT=$(expr 50 + $DELTA)22
204 VOLTHA_ETCD_PORT=$(expr 23 + $DELTA)79
Test User01ed0642019-07-03 20:17:06 +0000205else
David Bainbridge0774b232019-08-02 06:37:19 +0000206 VALUES=$(echo $HAVE | sed -e 's/\s//g' | cut -d= -f2)
207 ONOS_API_PORT=$(echo $VALUES | cut -d, -f1)
208 ONOS_SSH_PORT=$(echo $VALUES | cut -d, -f2)
209 VOLTHA_API_PORT=$(echo $VALUES | cut -d, -f3)
210 VOLTHA_SSH_PORT=$(echo $VALUES | cut -d, -f4)
211 VOLTHA_ETCD_PORT=$(echo $VALUES | cut -d, -f5)
Test User01ed0642019-07-03 20:17:06 +0000212fi
213
David Bainbridge0774b232019-08-02 06:37:19 +0000214PORTTMP=$(mktemp -u)
215cat .voltha/ports | grep -v $NAME > $PORTTMP
216echo "$NAME=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT" >> $PORTTMP
217cp $PORTTMP .voltha/ports
218rm -f $PORTTMP
219
David Bainbridge01294952019-07-30 19:33:45 +0000220if [ "$WITH_TP" == "yes" ]; then
221 SADIS_VER=3.1.0
222 OLT_VER=3.0.1
223 AAA_VER=1.9.0
224 DHCP_VER=1.6.0
225else
226 SADIS_VER=2.2.0
227 OLT_VER=2.1.0
228 AAA_VER=1.8.0
229 DHCP_VER=1.5.0
230fi
David Bainbridge0774b232019-08-02 06:37:19 +0000231export ONOS_API_PORT ONOS_SSH_PORT SADIS_VER OLT_VER AAA_VER DHCP_VER
David Bainbridge01294952019-07-30 19:33:45 +0000232
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700233spin() {
Test Userd87942b2019-07-03 07:20:24 +0000234 PARTS="\
235 \xe2\xa2\x8e\xe2\xa1\xb0 \
236 \xe2\xa2\x8e\xe2\xa1\xa1 \
237 \xe2\xa2\x8e\xe2\xa1\x91 \
238 \xe2\xa2\x8e\xe2\xa0\xb1 \
239 \xe2\xa0\x8e\xe2\xa1\xb1 \
240 \xe2\xa2\x8a\xe2\xa1\xb1 \
241 \xe2\xa2\x8c\xe2\xa1\xb1 \
242 \xe2\xa2\x86\xe2\xa1\xb1 \
243 "
244 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700245 tput civis
246 while true; do
Test Userd87942b2019-07-03 07:20:24 +0000247 C=$(echo $PARTS | cut '-d ' -f $IDX)
248 echo -en "$C"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700249 IDX=$(expr $IDX + 1)
Test Userd87942b2019-07-03 07:20:24 +0000250 if [ $IDX -gt 8 ]; then
251 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700252 fi
253 sleep .15
254 echo -en "\r"
255 done
256}
257
Test Userd87942b2019-07-03 07:20:24 +0000258SPIN_PARTS="\
259 \xe2\xa2\x8e\xe2\xa1\xb0 \
260 \xe2\xa2\x8e\xe2\xa1\xa1 \
261 \xe2\xa2\x8e\xe2\xa1\x91 \
262 \xe2\xa2\x8e\xe2\xa0\xb1 \
263 \xe2\xa0\x8e\xe2\xa1\xb1 \
264 \xe2\xa2\x8a\xe2\xa1\xb1 \
265 \xe2\xa2\x8c\xe2\xa1\xb1 \
266 \xe2\xa2\x86\xe2\xa1\xb1 \
267 "
268IDX=1
269NOT_VERIFIED="\xe2\x9c\x97\x20"
270VERIFIED="\xe2\x9c\x93\x20"
Test Userb5712372019-07-03 21:52:17 +0000271HELM="\xE2\x8E\x88"
272OLD_KEY="\xF0\x9F\x97\x9D"
273BIRD="\xF0\x9F\x90\xA6"
274HIGH_VOLTAGE="\xE2\x9A\xA1"
275PLUG="\xF0\x9F\xa7\xa9"
276RESTART="\xf0\x9f\x94\x84"
277FORWARD="\xE2\x87\xA8"
278INSTALL="\xF0\x9F\x8F\x97"
279STOP="\xf0\x9f\x9b\x91"
280GO="\xf0\x9f\x9a\x80"
281DOWNLOAD="\xf0\x9f\x93\xa5"
282GEAR="\xe2\x9a\x99"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700283NO_ENTRY="\xe2\x9b\x94"
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000284LOCK="\xf0\x9f\x94\x92"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700285
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700286bspin() {
287 tput civis
Test Userd87942b2019-07-03 07:20:24 +0000288 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700289 local INDENT=
290 if [ "$1" == "-" ]; then
291 INDENT=" "
292 shift
293 fi
Test Userd87942b2019-07-03 07:20:24 +0000294 echo -en "$INDENT $*"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700295}
296
297sspin() {
298 local INDENT=
299 if [ "$1" == "-" ]; then
300 INDENT=" "
301 shift
302 fi
Test Userd87942b2019-07-03 07:20:24 +0000303 C=$(echo $SPIN_PARTS | cut '-d ' -f $IDX)
304 echo -en "\r$INDENT$C $*"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700305 IDX=$(expr $IDX + 1)
Test Userd87942b2019-07-03 07:20:24 +0000306 if [ $IDX -gt 8 ]; then
307 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700308 fi
309}
310
311espin() {
312 local INDENT=
313 if [ "$1" == "-" ]; then
314 INDENT=" "
315 shift
316 fi
317 echo -e "\r$INDENT$*"
318 tput cnorm
319}
320
David Bainbridgeac7f8072019-08-01 22:15:33 +0000321if [ "$1" == "get" -a "$2" == "voltconfig" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000322 echo "$HOME/.volt/config-$NAME"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000323 exit
324fi
325
326if [ $# -ne 1 -o $(echo ":up:down:dump:" | grep -c ":$1:") -ne 1 ]; then
327 >&2 echo "What wouild you like to do today:"
328 >&2 echo " up - bring up voltha"
329 >&2 echo " down - tear down voltha"
330 >&2 echo " dump - create a debug dump of running system"
331 exit 1
332fi
333
334if [ "$1" == "down" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000335 echo "Tearing down voltha cluster $NAME"
336 LOG="down-$NAME.log"
337 echo $(date -u +"%Y%m%dT%H%M%SZ") >$LOG
David Bainbridgeac7f8072019-08-01 22:15:33 +0000338 if [ $DEPLOY_K8S == "yes" ]; then
339 if [ -x ./bin/kind ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000340 bspin "Delete Kubernetes Kind Cluster"
341 (set -x; ./bin/kind delete cluster --name voltha-$NAME >>$LOG 2>&1) >>$LOG 2>&1
342 espin $VERIFIED
David Bainbridgeac7f8072019-08-01 22:15:33 +0000343 else
David Bainbridge0774b232019-08-02 06:37:19 +0000344 espin "$NO_ENTRY Delete Kubernetes Kind Cluster: kind command not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000345 fi
346 else
347 EXISTS=$(helm list -q)
348 EXPECT="etcd-operator onos open-olt open-onu sim voltha bbsim radius"
David Bainbridge0774b232019-08-02 06:37:19 +0000349 bspin "Remove Helm Deployments"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000350 for i in $EXISTS; do
351 if [ $(echo $EXPECT | grep -c $i) -eq 1 ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000352 sspin "Remove Helm Deployments: $i$CEOL"
353 (set -x; ./bin/helm delete --purge $i >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000354 fi
355 done
David Bainbridge0774b232019-08-02 06:37:19 +0000356 espin "$VERIFIED Remove Helm Deployments$CEOL"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000357 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000358 bspin "Remove port-forwards: onos-ui-$NAME"
359 for i in $(screen -ls | grep onos-ui-$NAME | awk '{print $1}'); do
360 sspin
361 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
362 done
363 sspin "Remove port-forwards: onos-ssh-$NAME$CEOL"
364 for i in $(screen -ls | grep onos-ssh-$NAME | awk '{print $1}'); do
365 sspin
366 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
367 done
368 sspin "Remove port-forwards: voltha-api-$NAME$CEOL"
369 for i in $(screen -ls | grep voltha-api-$NAME | awk '{print $1}'); do
370 sspin
371 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
372 done
373 sspin "Remove port-forwards: voltha-ssh-$NAME$CEOL"
374 for i in $(screen -ls | grep voltha-ssh-$NAME | awk '{print $1}'); do
375 sspin
376 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
377 done
378 sspin "Remove port-forwards: voltha-etcd-$NAME$CEOL"
379 for i in $(screen -ls | grep voltha-etcd-$NAME | awk '{print $1}'); do
380 sspin
381 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
382 done
383 espin "$VERIFIED Remove port-forwards$CEOL"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000384 exit
385fi
386
387if [ "$1" == "dump" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000388 LOG="dump-$NAME.log"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000389 TS=$(date -u +"%Y%m%dT%H%M%SZ")
390 WORK=$(mktemp -u -d)
David Bainbridge0774b232019-08-02 06:37:19 +0000391 DATA=$WORK/voltha-debug-dump-$NAME-$TS
David Bainbridgeac7f8072019-08-01 22:15:33 +0000392 mkdir -p $DATA
393 echo $TS > $LOG
David Bainbridge0774b232019-08-02 06:37:19 +0000394 echo -e "Capturing debug dump to voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000395 bspin - "Copy install log"
David Bainbridge0774b232019-08-02 06:37:19 +0000396 if [ -f install-$NAME.log ]; then
397 (set -x; cp install-$NAME.log $DATA/install-$NAME.log) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000398 espin - $VERIFIED
399 else
David Bainbridge0774b232019-08-02 06:37:19 +0000400 espin - "$NO_ENTRY Copy install log: install-$NAME.log not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000401 fi
402 bspin - "Dumping Kubernetes PODs"
403 (set -x; kubectl get --all-namespaces pods >> $DATA/all-pods.txt 2>&1) >>$LOG 2>&1
404 espin - $VERIFIED
405 bspin - "Dumping Kubernetes SERVICEs"
406 (set -x; kubectl get --all-namespaces svc >> $DATA/all-services.txt 2>&1) >>$LOG 2>&1
407 espin - $VERIFIED
408 bspin - "Dumping Kubernetes EVENTs"
409 (set -x; kubectl get --all-namespaces events >> $DATA/all-events.txt 2>&1) >>$LOG 2>&1
410 espin - $VERIFIED
411 bspin - "Dumping VOLTHA POD details"
412 PODS=$(kubectl get -n voltha pod -o name)
413 for POD in $PODS; do
414 sspin - "Dumping VOLTHA POD details: $POD$CEOL"
415 mkdir -p $DATA/$POD
416 (set -x; kubectl describe -n voltha $POD >> $DATA/$POD/describe.txt 2>&1) >>$LOG 2>&1
417 sspin - "Dumping VOLTHA POD details: $POD"
418 (set -x; kubectl logs -n voltha --all-containers --previous $LOG_ARGS $POD >> $DATA/$POD/logs-previous.txt 2>&1) >>$LOG 2>&1
419 sspin - "Dumping VOLTHA POD details: $POD"
420 (set -x; kubectl logs -n voltha --all-containers $LOG_ARGS $POD >> $DATA/$POD/logs-current.txt 2>&1) >>$LOG 2>&1
421 sspin - "Dumping VOLTHA POD details: $POD"
422 done
423 espin - "$VERIFIED Dumping VOLTHA POD details$CEOL"
424 bspin - "Dumping ETCD"
425 if [ "$(which etcdctl) X" != " X" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000426 (set -x; ETCDCTL_API=3 etcdctl --endpoints localhost:$VOLTHA_ETCD_PORT get --prefix service/voltha | hexdump -C >> $DATA/etcd.hex 2>&1) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000427 espin - $VERIFIED
428 else
429 espin - "$NO_ENTRY Dumping ETCD: etcdctl command not available"
430 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000431 bspin - "Creating compressed TAR: voltha-debug-dump-$NAME-$TS.tgz"
432 (set -x; tar -C $WORK -zcf voltha-debug-dump-$NAME-$TS.tgz ./voltha-debug-dump-$NAME-$TS) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000433 espin - $VERIFIED
434 bspin - "Cleanup"
435 (set -x; rm -rf $WORK) >>$LOG 2>&1
436 espin - $VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +0000437 bspin - "$(ls -l voltha-debug-dump-$NAME-$TS.tgz)"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000438 espin - $VERIFIED
439 exit
440fi
441
442
David Bainbridge0774b232019-08-02 06:37:19 +0000443LOG="install-$NAME.log"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000444date > $LOG
David Bainbridge0774b232019-08-02 06:37:19 +0000445echo "PORTS=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT" >> $LOG
David Bainbridgeac7f8072019-08-01 22:15:33 +0000446
447# Output install options to log
448echo "OPTIONS" >> $LOG
David Bainbridge0774b232019-08-02 06:37:19 +0000449ALL_OPTIONS="NAME TYPE WITH_BBSIM WITH_RADIUS WITH_ONOS WITH_TP JUST_K8S DEPLOY_K8S \
David Bainbridgeac7f8072019-08-01 22:15:33 +0000450 SKIP_RESTART_API INSTALL_KUBECTL INSTALL_HELM USE_GO VOLTHA_LOG_LEVEL \
451 VOLTHA_CHART VOLTHA_ADAPTER_SIM_CHART VOLTHA_ADAPTER_OPEN_OLT_CHART \
David Bainbridge0774b232019-08-02 06:37:19 +0000452 VOLTHA_ADAPTER_OPEN_ONU_CHART SADIS_VER OLT_VER AAA_VER DHCP_VER \
453 ONOS_API_PORT ONOS_SSH_PORT VOLTHA_API_PORT VOLTHA_SSH_PORT VOLTHA_ETCD_PORT"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000454for O in $ALL_OPTIONS; do
455 VAL=$(eval echo \$$O)
456 if [ $O == "USE_GO" ]; then
457 VAL="$(echo $VAL| test $(grep -c true) -eq 1 && echo yes || echo no)"
458 fi
459 if [ ! -z "$VAL" ]; then
460 printf " %-30s = %s\n" $O $VAL >> $LOG
461 fi
462done
463
464
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700465count_pods() {
466 local NAMESPACE=$1; shift
467 local PODS=$(kubectl -n $NAMESPACE get pod -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}")
468 local COUNT=0
469 local PATTERNS=$*
470 for POD in $PODS; do
471 local NAME=$(echo $POD | cut -d/ -f 1)
472 local STATE=$(echo $POD | cut -d/ -f 2)
473 local CONTAINERS=$(echo $POD | cut -d/ -f 3 | sed -e 's/_/ /g')
474 if [ "$STATE" == "Running" ]; then
475 local TOTAL=$(echo $CONTAINERS | wc -w)
476 local FOUND=$(echo $CONTAINERS | grep -o true | wc -l)
477 if [ $TOTAL -eq $FOUND ]; then
478 for PATTERN in $PATTERNS; do
479 if [[ $NAME =~ $PATTERN ]]; then
480 COUNT=$(expr $COUNT + 1)
481 fi
482 done
483 fi
484 fi
485 done
486 echo $COUNT
487}
488
489wait_for_pods() {
490 local INDENT=
491 if [ "$1" == "-" ]; then
492 INDENT=$1; shift
493 fi
494 local NAMESPACE=$1; shift
495 local EXPECT=$1; shift
496 local RETRY=$1; shift
497 local MESSAGE=$1; shift
498 local PATTERNS=$*
499 local HAVE=$(count_pods $NAMESPACE $PATTERNS)
500 COUNT=$(expr 300 / 15)
501 bspin $INDENT $MESSAGE
502 sspin $INDENT
503 if [ $HAVE -ne $EXPECT ]; then
504 while [ $HAVE -ne $EXPECT ]; do
505 sspin $INDENT
506 COUNT=$(expr $COUNT - 1)
507 if [ $COUNT -eq 0 ]; then
508 HAVE=$(count_pods $NAMESPACE $PATTERNS)
509 COUNT=$(expr 300 / 15)
510 fi
511 sleep .15
512 done
513 fi
514 espin $INDENT $VERIFIED
515 if [ $HAVE -ne $EXPECT ]; then
516 return 1
517 fi
518 return 0
519}
520
521helm_install() {
522 local INDENT=
523 if [ "$1" == "-" ]; then
524 INDENT=$1; shift
525 fi
526 local NAMESPACE=$1; shift
David Bainbridge0774b232019-08-02 06:37:19 +0000527 local INAME=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700528 local CHART=$1; shift
529 local MESSAGE=$*
530
531 COUNT=$(expr 300 / 15)
532 bspin $INDENT $MESSAGE
David Bainbridge0774b232019-08-02 06:37:19 +0000533 (set -x; helm install -f $NAME-values.yaml --set use_go=$USE_GO --set defaults.log_level=$VOLTHA_LOG_LEVEL --namespace $NAMESPACE --name $INAME $CHART >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700534 SUCCESS=$?
535 while [ $SUCCESS -ne 0 ]; do
536 sspin $INDENT
537 COUNT=$(expr $COUNT - 1)
538 if [ $COUNT -eq 0 ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000539 (set -x; helm install -f $NAME-values.yaml --set
540 defaults.log_level=$VOLTHA_LOG_LEVEL --namespace $NAMESPACE --name $INAME $CHART >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700541 COUNT=$(expr 300 / 15)
542 fi
543 sleep .15
544 done
545 espin $INDENT $VERIFIED
546}
547
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700548echo "INSTALL TYPE: $TYPE" >> $LOG
549
550bspin "Verify GOPATH"
551export GOPATH=$(pwd)
Test User3d7ad8e2019-07-03 06:15:44 +0000552mkdir -p $GOPATH/bin
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700553espin $VERIFIED
554
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700555if [ "$INSTALL_KUBECTL" == "no" ]; then
556 bspin "Skip kubectl install"
557 espin $NO_ENTRY
Test Userc13bdc92019-07-03 20:57:49 +0000558else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700559 bspin "Verify kubectl $HELM"
560 if [ -x $GOPATH/bin/kubectl ]; then
561 espin $VERIFIED
562 else
563 espin $NOT_VERIFIED
564 bspin - "Download and install Kubernetes/kubectl $DOWNLOAD"
565 (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
566 (set -x; chmod 755 $GOPATH/bin/kubectl >>$LOG 2>&1) >>$LOG 2>&1
567 espin - $VERIFIED
568 fi
Test Userc13bdc92019-07-03 20:57:49 +0000569fi
570
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700571if [ "$DEPLOY_K8S" == "no" ]; then
572 bspin "Skip Kubernetes/Kind Deployment"
573 espin $NO_ENTRY
574else
Test Userba1e7e72019-07-10 22:27:54 +0000575 bspin "Verify Kubernetes/Kind $HELM"
576 if [ -x $GOPATH/bin/kind ]; then
577 espin $VERIFIED
578 else
579 espin $NOT_VERIFIED
580 bspin - "Download and install Kubernetes/kind $DOWNLOAD"
David Bainbridge9e2a6662019-07-11 17:07:57 +0000581 (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 +0000582 (set -x; chmod 755 $GOPATH/bin/kind >>$LOG 2>&1) >>$LOG 2>&1
583 espin - $VERIFIED
584 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700585fi
586
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700587if [ "$INSTALL_HELM" == "no" ]; then
588 bspin "Skip Helm Install"
589 espin $NO_ENTRY
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700590else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700591 bspin "Verify Helm $HELM"
592 if [ -x $GOPATH/bin/helm ]; then
593 espin $VERIFIED
594 else
595 espin $NOT_VERIFIED
596 bspin - "Download and install Helm $DOWNLOAD"
597 (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
598 espin - $VERIFIED
599 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700600fi
601
Test Userb5712372019-07-03 21:52:17 +0000602bspin "Verify voltctl $HIGH_VOLTAGE"
Test User3d7ad8e2019-07-03 06:15:44 +0000603if [ -x $GOPATH/bin/voltctl ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700604 espin $VERIFIED
605else
606 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000607 bspin - "Download and build voltctl $DOWNLOAD"
Test Userba1e7e72019-07-10 22:27:54 +0000608 (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 +0000609 (set -x; chmod 755 $GOPATH/bin/voltctl >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700610 espin - $VERIFIED
611fi
612
613bspin "Verify command PATH"
Test Userba1e7e72019-07-10 22:27:54 +0000614export PATH=$GOPATH/bin:$PATH
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700615espin $VERIFIED
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700616
Test Userba1e7e72019-07-10 22:27:54 +0000617if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000618 HAVE=$(kind get clusters | grep -c voltha-$NAME)
Test Userba1e7e72019-07-10 22:27:54 +0000619 bspin "Verify Kubernetes/Kind Cluster"
620 sspin
621 if [ $HAVE -eq 0 ]; then
David Bainbridge491b1bd2019-07-11 17:53:11 +0000622 espin $NOT_VERIFIED
623 bspin - "Verify cluster configuration"
David Bainbridge0774b232019-08-02 06:37:19 +0000624 if [ ! -r ./$NAME-cluster.cfg ]; then
David Bainbridge491b1bd2019-07-11 17:53:11 +0000625 espin - $NOT_VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +0000626 bspin - "Download cluster configuration: $TYPE-cluster.cfg to $NAME-cluster.cfg $DOWNLOAD"
627 (set -x; curl -o ./$NAME-cluster.cfg -sSL https://raw.githubusercontent.com/ciena/kind-voltha/master/$TYPE-cluster.cfg >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700628 espin - $VERIFIED
629 else
630 espin - $VERIFIED
631 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000632 kind create cluster --name voltha-$NAME --config $NAME-cluster.cfg
David Bainbridge491b1bd2019-07-11 17:53:11 +0000633 else
634 espin $VERIFIED
Test Userba1e7e72019-07-10 22:27:54 +0000635 fi
636
David Bainbridge0774b232019-08-02 06:37:19 +0000637 export KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$NAME")"
Test Userba1e7e72019-07-10 22:27:54 +0000638 P="coredns-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000639 etcd-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +0000640 kindnet-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000641 kube-apiserver-voltha-$NAME-control-plane \
642 kube-controller-manager-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +0000643 kube-proxy-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000644 kube-scheduler-voltha-$NAME-control-plane"
Test Userba1e7e72019-07-10 22:27:54 +0000645
646 EXPECT=$(test "$TYPE" == "minimal" && echo "12" || echo "14")
647 wait_for_pods - "kube-system" $EXPECT -1 "Waiting for system PODs to start" $P
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700648fi
649
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700650COUNT=$(count_pods "kube-system" "tiller-deploy-.*")
651bspin "Verify Helm"
Test Userba1e7e72019-07-10 22:27:54 +0000652if [ $COUNT -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700653 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000654 echo -e "Configuring Helm $GEAR"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700655 if [ "$INSTALL_HELM" == "no" ]; then
656 bspin - "Skip Helm/Tiller Initialization"
657 espin - $NO_ENTRY
658 else
659 bspin - "Initialize Helm"
660 (set -x; helm init --upgrade >>$LOG 2>&1) >>$LOG 2>&1
661 espin - $VERIFIED
662 wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
663 fi
Test Userb5712372019-07-03 21:52:17 +0000664 bspin - "Add Google Incubator repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700665 (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
666 espin - $VERIFIED
Test Userba1e7e72019-07-10 22:27:54 +0000667
668 # HACK (sort-of) - the config for tiller is about to be patched, which will
669 # cause the tiller pod to be recreated. This can sometimes cause a timing
670 # issue with the "wait_for_pods" call on tiller as it may incorrectly
671 # identify the running/ready tiller pod that is soon to be terminated as
672 # what it is waiting for. To avoid this issue we do a clean scale down and
673 # scale up of the pod so the script controlls when it should be expecting
674 # things
675 (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 -0700676
Test Userb5712372019-07-03 21:52:17 +0000677 bspin - "Add Google Stable repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700678 (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
679 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000680 bspin - "Add ONF repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700681 (set -x; helm repo add onf https://charts.opencord.org >>$LOG 2>&1) >>$LOG 2>&1
682 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000683 bspin - "Update Helm repository cache"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700684 (set -x; helm repo update >>$LOG 2>&1) >>$LOG 2>&1
685 espin - $VERIFIED
686
687 # Create and k8s service account so that Helm can create pods
Test Userb5712372019-07-03 21:52:17 +0000688 bspin - "Create Tiller ServiceAccount"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700689 (set -x; kubectl create serviceaccount --namespace kube-system tiller >>$LOG 2>&1) >>$LOG 2>&1
690 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000691 bspin - "Create Tiller ClusterRoleBinding"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700692 (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>$LOG 2>&1) >>$LOG 2>&1
693 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000694 bspin - "Update Tiller Manifest"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700695 (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 +0000696
697 # HACK (sort-of) - part to, spin it back up
698 (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 -0700699 espin - $VERIFIED
700else
701 espin $VERIFIED
702fi
Test Userb5712372019-07-03 21:52:17 +0000703wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700704
David Bainbridge0774b232019-08-02 06:37:19 +0000705bspin "Verify Helm values file: $NAME-values.yaml"
706if [ ! -r "./$NAME-values.yaml" ]; then
Test Userba1e7e72019-07-10 22:27:54 +0000707 espin $NOT_VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +0000708 bspin - "Download Helm values file: $TYPE-values.yaml to $NAME-values.yaml $DOWNLOAD"
709 (set -x; curl -o ./$NAME-values.yaml -sSL https://raw.githubusercontent.com/ciena/kind-voltha/master/$TYPE-values.yaml >>$LOG 2>&1) >>$LOG 2>&1
Test Userba1e7e72019-07-10 22:27:54 +0000710 espin - $VERIFIED
711else
712 espin $VERIFIED
713fi
714
715if [ "$JUST_K8S" == "yes" ]; then
716 echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye."
717 echo ""
718 echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
719 echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
720 echo "tools required by VOLTHA in your command path. " | tee -a $LOG
721 echo "" | tee -a $LOG
722 echo -en $BOLD
723 if [ $DEPLOY_K8S == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000724 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +0000725 fi
726 echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
727 echo -en $NORMAL
728 echo "" | tee -a $LOG
729 echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
730 exit 0
731fi
732
Test Userb5712372019-07-03 21:52:17 +0000733bspin "Verify ETCD Operator $OLD_KEY"
Test User7d866122019-07-09 17:52:35 +0000734if [ $(helm list --deployed --short --namespace voltha "^etcd-operator\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700735 espin $NOT_VERIFIED
736 helm_install - voltha etcd-operator stable/etcd-operator "Install ETCD Operator"
737else
738 espin $VERIFIED
739fi
Test User01ed0642019-07-03 20:17:06 +0000740EXPECT=$(test "$TYPE" == "minimal" && echo "1" || echo "3")
Test Userb5712372019-07-03 21:52:17 +0000741wait_for_pods - "voltha" $EXPECT -1 "Waiting for ETCD Operator to start" "etcd-operator-.*"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700742
David Bainbridgeb270c202019-07-26 01:44:42 +0000743if [ $WITH_ONOS == "yes" ]; then
744 bspin "Verify ONOS installed $BIRD"
745 if [ $(helm list --deployed --short --namespace default "^onos\$" | wc -l) -ne 1 ]; then
746 espin $NOT_VERIFIED
747 helm_install - default onos onf/onos "Install ONOS"
748 else
749 espin $VERIFIED
750 fi
751 wait_for_pods - "default" 1 -1 "Waiting for ONOS to start" "onos-.*"
752
753 bspin - "Forward ONOS API port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +0000754 for i in $(screen -ls | grep onos-ui-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +0000755 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
756 done
David Bainbridge0774b232019-08-02 06:37:19 +0000757 (set -x; screen -dmS onos-ui-$NAME bash -c "while true; do kubectl port-forward service/onos-ui $ONOS_API_PORT:8181; done" >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridgeb270c202019-07-26 01:44:42 +0000758 espin - $VERIFIED
759 bspin - "Forward ONOS SSH port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +0000760 for i in $(screen -ls | grep onos-ssh-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +0000761 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
762 done
David Bainbridge0774b232019-08-02 06:37:19 +0000763 (set -x; screen -dmS onos-ssh-$NAME bash -c "while true; do kubectl port-forward service/onos-ssh $ONOS_SSH_PORT:8101; done" >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridgeb270c202019-07-26 01:44:42 +0000764 espin - $VERIFIED
765 if [ ! -x ./onos-files/install-onos-applications.sh ]; then
766 bspin - "Verify or download ONOS configuration support files $DOWNLOAD"
767 (set -x; mkdir -p ./onos-files >>$LOG 2>&1) >>$LOG 2>&1
768 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
769 if [ ! -r ./onos-files/$i ]; then
770 (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
771 fi
772 done
773 (set -x; chmod 755 ./onos-files/install-onos-applications.sh >>$LOG 2>&1) >>$LOG 2>&1
774 espin - $VERIFIED
775 fi
776
777 bspin - "Install required ONOS applications $INSTALL"
778 (set -x; ./onos-files/install-onos-applications.sh >>$LOG 2>&1) >>$LOG 2>&1
Test Userba1e7e72019-07-10 22:27:54 +0000779 espin - $VERIFIED
780fi
781
Test Userb5712372019-07-03 21:52:17 +0000782bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
Test User7d866122019-07-09 17:52:35 +0000783if [ $(helm list --deployed --short --namespace voltha "^voltha\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700784 espin $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +0000785 helm_install - voltha voltha $VOLTHA_CHART "Install VOLTHA Core"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700786else
787 espin $VERIFIED
788fi
Test Userba1e7e72019-07-10 22:27:54 +0000789
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700790VOLTHA="ofagent-.* \
791 ro-core.* \
792 rw-core.* \
793 voltha-api-server-.* \
794 voltha-cli-server-.* \
795 voltha-etcd-cluster-.* \
796 voltha-kafka-.* \
797 voltha-zookeeper-.*"
Test User01ed0642019-07-03 20:17:06 +0000798EXPECT=$(test "$TYPE" == "minimal" && echo "9" || echo "11")
Test Userb5712372019-07-03 21:52:17 +0000799wait_for_pods - "voltha" $EXPECT -1 "Waiting for VOLTHA Core to start" $VOLTHA
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700800
Test Userb5712372019-07-03 21:52:17 +0000801echo -e "Verify Adapters $PLUG"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700802bspin - "Verify Simulated Adapters installed"
Test User7d866122019-07-09 17:52:35 +0000803if [ $(helm list --deployed --short --namespace voltha "^sim\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700804 espin - $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +0000805 helm_install - voltha sim $VOLTHA_ADAPTER_SIM_CHART "Install Simulated Adapters"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700806else
807 espin - $VERIFIED
808fi
809
810bspin - "Verify OpenOLT Adapter installed"
Test User7d866122019-07-09 17:52:35 +0000811if [ $(helm list --deployed --short --namespace voltha "^open-olt\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700812 espin - $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +0000813 helm_install - voltha open-olt $VOLTHA_ADAPTER_OPEN_OLT_CHART "Install OpenOLT Adapter"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700814else
815 espin - $VERIFIED
816fi
817bspin - "Verify OpenONU Adapter installed"
Test User7d866122019-07-09 17:52:35 +0000818if [ $(helm list --deployed --short --namespace voltha "^open-onu\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700819 espin - $NOT_VERIFIED
David Bainbridgee10f6d52019-07-25 00:28:13 +0000820 helm_install - voltha open-onu $VOLTHA_ADAPTER_OPEN_ONU_CHART "Install OpenONU Adapter"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700821else
822 espin - $VERIFIED
823fi
824
825ADAPTERS="adapter-.*"
Test Userb5712372019-07-03 21:52:17 +0000826wait_for_pods - "voltha" 4 -1 "Waiting for adapters to start" $ADAPTERS
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700827
Test User7d866122019-07-09 17:52:35 +0000828if [ $WITH_BBSIM == "yes" ]; then
829 echo -e "Verify BBSIM $PLUG"
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000830 bspin - "Verify BBSIM Installed"
Test User7d866122019-07-09 17:52:35 +0000831 if [ $(helm list --deployed --short --namespace voltha "^bbsim\$" | wc -l) -ne 1 ]; then
832 espin - $NOT_VERIFIED
833 helm_install - voltha bbsim onf/bbsim "Install BBSIM"
834 else
835 espin - $VERIFIED
836 fi
837 wait_for_pods - "voltha" 1 -1 "Waiting for BBSIM to start" "bbsim-.*"
838fi
839
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000840if [ $WITH_RADIUS == "yes" ]; then
841 echo -e "Verify RADIUS $LOCK"
842 bspin - "Verify RADIUS Installed"
843 if [ $(helm list --deployed --short --namespace voltha "^radius\$" | wc -l) -ne 1 ]; then
844 espin - $NOT_VERIFIED
845 helm_install - voltha radius onf/freeradius "Install RADIUS"
846 else
847 espin - $VERIFIED
848 fi
849 wait_for_pods - "voltha" 1 -1 "Waiting for RADIUS to start" "radius-.*"
850fi
851
David Bainbridgee10f6d52019-07-25 00:28:13 +0000852if [ $SKIP_RESTART_API == "no" ]; then
853 echo -e "Restart VOLTHA API $RESTART"
854 API="voltha-api-server-.* ofagent-.*"
855 (set -x; kubectl scale --replicas=0 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1
856 wait_for_pods - "voltha" 0 -1 "Wait for API to stop $STOP" $API
857 (set -x; kubectl scale --replicas=1 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1
858 wait_for_pods - "voltha" 2 -1 "Wait for API to re-start $GO" $API
859else
860 bspin "Skip VOLTHA API Restart"
861 espin $NO_ENTRY
862fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700863
Test Userb5712372019-07-03 21:52:17 +0000864bspin - "Forward VOLTHA API port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +0000865for i in $(screen -ls | grep voltha-api-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +0000866 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
867done
David Bainbridge0774b232019-08-02 06:37:19 +0000868(set -x; screen -dmS voltha-api-$NAME bash -c "while true; do kubectl port-forward -n voltha service/voltha-api $VOLTHA_API_PORT:55555; done" >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700869espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000870bspin - "Forward VOLTHA SSH port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +0000871for i in $(screen -ls | grep voltha-ssh-$NAME | awk '{print $1}'); do
David Bainbridge82bd1212019-07-29 19:19:31 +0000872 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
873done
David Bainbridge0774b232019-08-02 06:37:19 +0000874(set -x; screen -dmS voltha-ssh-$NAME bash -c "while true; do kubectl port-forward -n voltha service/voltha-cli $VOLTHA_SSH_PORT:5022; done" >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700875espin - $VERIFIED
David Bainbridgeac7f8072019-08-01 22:15:33 +0000876bspin - "Forward VOLTHA ETCD port $FORWARD"
David Bainbridge0774b232019-08-02 06:37:19 +0000877for i in $(screen -ls | grep voltha-etcd-$NAME | awk '{print $1}'); do
David Bainbridgeac7f8072019-08-01 22:15:33 +0000878 (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1
879done
David Bainbridge0774b232019-08-02 06:37:19 +0000880(set -x; screen -dmS voltha-etcd-$NAME bash -c "while true; do kubectl port-forward -n voltha service/voltha-etcd-cluster-client $VOLTHA_ETCD_PORT:2379; done" >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000881espin - $VERIFIED
Test User3d7ad8e2019-07-03 06:15:44 +0000882
David Bainbridgeb270c202019-07-26 01:44:42 +0000883if [ $WITH_ONOS == "yes" -a $WITH_RADIUS == "yes" ]; then
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000884 bspin "Configure ONOS RADIUS Connection $GEAR"
885 (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
886 espin $VERIFIED
887fi
888
889bspin "Create voltctl configuration file"
Test User3d7ad8e2019-07-03 06:15:44 +0000890(set -x; mkdir -p $HOME/.volt >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridge0774b232019-08-02 06:37:19 +0000891(set -x; voltctl -a v2 -s localhost:$VOLTHA_API_PORT config > $HOME/.volt/config-$NAME 2>>$LOG) >>$LOG 2>&1
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000892espin $VERIFIED
Test User08ebbd92019-07-03 17:15:39 +0000893
David Bainbridge0774b232019-08-02 06:37:19 +0000894if [ ! -f "$NAME-env.sh" ]; then
895 touch $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +0000896fi
897
David Bainbridge596f30d2019-07-30 17:07:59 +0000898for O in $ALL_OPTIONS; do
899 VAL=$(eval echo \$$O)
900 if [ $O == "USE_GO" ]; then
901 VAL="$(echo $VAL| test $(grep -c true) -eq 1 && echo yes || echo no)"
902 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000903 if [ ! -z "$VAL" -a $(grep -c "^export $O=" $NAME-env.sh) -eq 0 ]; then
904 echo "export $O=\"$(eval echo \$$O)\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +0000905 fi
906done
907
David Bainbridge0774b232019-08-02 06:37:19 +0000908if [ $DEPLOY_K8S == "yes" -a $(grep -c "^export KUBECONFIG=" $NAME-env.sh) -eq 0 ]; then
909 echo "export KUBECONFIG=\"$(./bin/kind get kubeconfig-path --name=voltha-$NAME)\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +0000910fi
911
David Bainbridge0774b232019-08-02 06:37:19 +0000912if [ $(grep -c "^export VOLTCONFIG=" $NAME-env.sh) -eq 0 ]; then
913 echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +0000914fi
915
David Bainbridge0774b232019-08-02 06:37:19 +0000916if [ $(grep -c "^export PATH=" $NAME-env.sh) -eq 0 ]; then
917 echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +0000918fi
919
Test User7d866122019-07-09 17:52:35 +0000920echo ""
Test User08ebbd92019-07-03 17:15:39 +0000921echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
922echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
923echo "tools required by VOLTHA in your command path. " | tee -a $LOG
924echo "" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +0000925echo -en $BOLD
Test Userba1e7e72019-07-10 22:27:54 +0000926if [ $DEPLOY_K8S == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000927 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +0000928fi
David Bainbridge0774b232019-08-02 06:37:19 +0000929echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +0000930echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +0000931echo -en $NORMAL
Test User08ebbd92019-07-03 17:15:39 +0000932echo "" | tee -a $LOG
933echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
934