blob: 4685cce2ee9cc916b87acb7d710c3b88656523f9 [file] [log] [blame]
Test User01ed0642019-07-03 20:17:06 +00001#!/bin/bash
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002# Copyright 2019 Ciena Corporation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
David Bainbridge712afb82019-08-14 19:55:58 +000015TOTAL_START_TIME=$(date +%s)
David K. Bainbridgeb7285432019-07-02 22:05:24 -070016
David Bainbridge38dc1e82019-08-12 15:18:45 +000017FANCY=${FANCY:-1}
18if [ "$TERM X" == " X" ]; then
19 FANCY=0
20fi
21
David K. Bainbridgeb7285432019-07-02 22:05:24 -070022# trap ctrl-c and call ctrl_c()
23trap ctrl_c INT
24
25function ctrl_c() {
David Bainbridge38dc1e82019-08-12 15:18:45 +000026 echo -en $CNORM
David K. Bainbridgeb7285432019-07-02 22:05:24 -070027 echo ""
28 echo "ctrl-c trapped"
David Bainbridgec6a6eb62019-10-18 22:50:07 +000029 echo "Thank you for trying 'voltha up'"
David K. Bainbridgeb7285432019-07-02 22:05:24 -070030 exit
31}
32
David K. Bainbridgeebf38d92020-02-10 10:46:31 -080033VOLTCTL_VERSION=${VOLTCTL_VERSION:-latest}
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -080034KIND_VERSION=${KIND_VERSION:-v0.5.1}
David K. Bainbridgeb3a99372020-01-08 14:39:06 -080035VK_RELEASE=${VK_RELEASE:-master}
Test User08ebbd92019-07-03 17:15:39 +000036
David Bainbridge38dc1e82019-08-12 15:18:45 +000037BLACK=
38RED=
39GREEN=
40YELLOW=
41BLUE=
42MAGENTA=
43CYAN=
44WHITE=
45BOLD=
46NORMAL=
47ERROR=
48CEOL=
49CNORM=
50CIVIS=
51if [ $FANCY -eq 1 ]; then
52 BLACK=$(tput setaf 0)
53 RED=$(tput setaf 1)
54 GREEN=$(tput setaf 2)
55 YELLOW=$(tput setaf 3)
56 BLUE=$(tput setaf 4)
57 MAGENTA=$(tput setaf 5)
58 CYAN=$(tput setaf 6)
59 WHITE=$(tput setaf 7)
60 BOLD=$(tput bold)
61 NORMAL=$(tput sgr0)
62 ERROR="\xe2\x9c\x97\x20"
63 CEOL=$(tput el)
64 CNORM=$(tput cnorm)
65 CIVIS=$(tput civis)
66fi
Test User7d866122019-07-09 17:52:35 +000067
Test User3d7ad8e2019-07-03 06:15:44 +000068TYPE=${TYPE:-minimal}
David Bainbridge0774b232019-08-02 06:37:19 +000069NAME=${NAME:-$TYPE}
David K. Bainbridge484d80c2020-03-05 21:44:34 -080070
71ENABLE_ONOS_EXTRANEOUS_RULES=${ENABLE_ONOS_EXTRANEOUS_RULES:-no}
David Bainbridgee87067b2019-08-12 22:00:12 +000072WITH_TIMINGS=${WITH_TIMINGS:-no}
Test User7d866122019-07-09 17:52:35 +000073WITH_BBSIM=${WITH_BBSIM:-no}
David Bainbridge5b7b96b2019-07-25 20:29:13 +000074WITH_RADIUS=${WITH_RADIUS:-no}
Matteo Scandolo78dfee02020-02-13 16:18:03 -080075WITH_EAPOL=${WITH_EAPOL:-yes}
76WITH_DHCP=${WITH_DHCP:-yes}
77WITH_IGMP=${WITH_IGMP:-no}
David Bainbridgeb270c202019-07-26 01:44:42 +000078WITH_ONOS=${WITH_ONOS:-yes}
David Bainbridge99ac7a22019-08-31 02:26:43 +000079WITH_CHAOS=${WITH_CHAOS:-no}
David Bainbridge46505fb2019-10-01 21:13:20 +000080WITH_ADAPTERS=${WITH_ADAPTERS:-yes}
81WITH_SIM_ADAPTERS=${WITH_SIM_ADAPTERS:-yes}
82WITH_OPEN_ADAPTERS=${WITH_OPEN_ADAPTERS:-yes}
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -080083WITH_PORT_FORWARDS=${WITH_PORT_FORWARDS:-yes}
David Bainbridge05cd8822019-11-19 17:43:53 +000084ONLY_ONE=${ONLY_ONE:-yes}
David Bainbridge2b19e832019-08-16 02:40:53 +000085CONFIG_SADIS=${CONFIG_SADIS:-no}
David Bainbridge27790d62019-08-13 22:43:19 +000086INSTALL_ONOS_APPS=${INSTALL_ONOS_APPS:-no}
Test Userba1e7e72019-07-10 22:27:54 +000087JUST_K8S=${JUST_K8S:-no}
88DEPLOY_K8S=${DEPLOY_K8S:-yes}
David K. Bainbridge0e89cb92019-07-17 11:30:10 -070089INSTALL_KUBECTL=${INSTALL_KUBECTL:-yes}
90INSTALL_HELM=${INSTALL_HELM:-yes}
David Bainbridge46505fb2019-10-01 21:13:20 +000091UPDATE_HELM_REPOS=${UPDATE_HELM_REPOS:-yes}
Matteo Scandolofab98622020-01-28 15:17:20 -080092WAIT_ON_DOWN=${WAIT_ON_DOWN:-yes}
David Bainbridge5b7b96b2019-07-25 20:29:13 +000093VOLTHA_LOG_LEVEL=${VOLTHA_LOG_LEVEL:-WARN}
David Bainbridge90fd8e32019-08-21 23:32:47 +000094VOLTHA_CHART=${VOLTHA_CHART:-onf/voltha}
95VOLTHA_CHART_VERSION=${VOLTHA_CHART_VERSION:-latest}
96VOLTHA_BBSIM_CHART=${VOLTHA_BBSIM_CHART:-onf/bbsim}
Matteo Scandolodcd29f52019-10-07 15:42:42 -070097VOLTHA_BBSIM_CHART_VERSION=${VOLTHA_BBSIM_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +000098VOLTHA_ADAPTER_SIM_CHART=${VOLTHA_ADAPTER_SIM_CHART:-onf/voltha-adapter-simulated}
David Bainbridge90fd8e32019-08-21 23:32:47 +000099VOLTHA_ADAPTER_SIM_CHART_VERSION=${VOLTHA_ADAPTER_SIM_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000100VOLTHA_ADAPTER_OPEN_OLT_CHART=${VOLTHA_ADAPTER_OPEN_OLT_CHART:-onf/voltha-adapter-openolt}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000101VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION=${VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000102VOLTHA_ADAPTER_OPEN_ONU_CHART=${VOLTHA_ADAPTER_OPEN_ONU_CHART:-onf/voltha-adapter-openonu}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000103VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION=${VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION:-latest}
Andrea Campanella21323292019-12-18 11:44:19 -0800104ONOS_CHART_VERSION=${ONOS_CHART_VERSION:-latest}
David Bainbridge70c0ea82019-11-14 23:25:26 +0000105EXTRA_HELM_INSTALL_ARGS=
uottrembb16d3982020-02-28 08:34:36 +0100106NUM_OF_BBSIM=${NUM_OF_BBSIM:-1}
107MAX_NUM_OF_BBSIM=10
Test Userba1e7e72019-07-10 22:27:54 +0000108
109HAVE_GO=$(which go >/dev/null 2>&1 && echo "yes" || echo "no")
110HOSTOS=$(uname -s | tr "[:upper:]" "[:lower:"])
111HOSTARCH=$(uname -m | tr "[:upper:]" "[:lower:"])
112if [ $HOSTARCH == "x86_64" ]; then
113 HOSTARCH="amd64"
114fi
Test User7d866122019-07-09 17:52:35 +0000115
uottrembb16d3982020-02-28 08:34:36 +0100116# check number (range) of bbsim, max bbsim must not exceed 10 instances!
117# note: instances will be numbered from 0 to 9
118if [ "$1" == "up" ]; then
119 if [ "$NUM_OF_BBSIM" -lt 1 ]; then
120 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid setting of BBSIM instances. NUM_OF_BBSIM is less than 1${NORMAL}"
121 exit 1
122 fi
123 if [ "$NUM_OF_BBSIM" -gt $MAX_NUM_OF_BBSIM ]; then
124 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid setting of BBSIM instances. NUM_OF_BBSIM is greater than $MAX_NUM_OF_BBSIM${NORMAL}"
125 exit 1
126 fi
127fi
Test User7d866122019-07-09 17:52:35 +0000128# Verify TYPE setting
129if [ $(echo ":minimal:full:" | grep -ic ":$TYPE:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700130 >&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 +0000131 exit 1
132fi
133
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800134function get_service_ep() {
135 local NS=$1
136 local NAME=$2
137 kubectl -n $NS get service $NAME -o json | jq -r '.spec.clusterIP + ":" + (.spec.ports[0].port|tostring)'
138}
139
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000140# Used to verify configuration values are set to "yes" or "no" value or convert
141# equivalents to "yes" or "no"
142function verify_yes_no() {
143 local VAR=$1
144 local VAL=$(eval echo \$$VAR)
145 if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$VAL:") -eq 0 ]; then
146 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid '$VAR' value of '$VAL'. Should be 'yes' or 'no'${NORMAL}"
147 echo "INVALID"
148 return 1
149 fi
150 if [ $(echo ":y:yes:true:1:" | grep -ic ":$VAL:") -eq 1 ]; then
151 echo "yes"
152 else
153 echo "no"
154 fi
155 return 0
156}
Test User7d866122019-07-09 17:52:35 +0000157
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000158ALL_YES_NO="\
David K. Bainbridge484d80c2020-03-05 21:44:34 -0800159 ENABLE_ONOS_EXTRANEOUS_RULES \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000160 WITH_TIMINGS \
161 WITH_BBSIM \
162 WITH_RADIUS \
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800163 WITH_EAPOL \
164 WITH_DHCP \
165 WITH_IGMP \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000166 WITH_ONOS \
David Bainbridge99ac7a22019-08-31 02:26:43 +0000167 WITH_CHAOS \
David Bainbridge46505fb2019-10-01 21:13:20 +0000168 WITH_ADAPTERS \
169 WITH_SIM_ADAPTERS \
170 WITH_OPEN_ADAPTERS \
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800171 WITH_PORT_FORWARDS \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000172 CONFIG_SADIS \
173 JUST_K8S \
174 DEPLOY_K8S \
175 INSTALL_ONOS_APPS \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000176 INSTALL_KUBECTL \
177 INSTALL_HELM \
David Bainbridge46505fb2019-10-01 21:13:20 +0000178 UPDATE_HELM_REPOS \
David Bainbridge4f1b5562019-08-19 04:46:52 +0000179 WAIT_ON_DOWN \
David Bainbridge70c0ea82019-11-14 23:25:26 +0000180 ONLY_ONE \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000181 "
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000182
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000183ALL_OPTIONS="\
184 NAME \
185 TYPE \
186 $ALL_YES_NO \
187 VOLTHA_LOG_LEVEL \
188 VOLTHA_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000189 VOLTHA_CHART_VERSION \
190 VOLTHA_BBSIM_CHART \
191 VOLTHA_BBSIM_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000192 VOLTHA_ADAPTER_SIM_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000193 VOLTHA_ADAPTER_SIM_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000194 VOLTHA_ADAPTER_OPEN_OLT_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000195 VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000196 VOLTHA_ADAPTER_OPEN_ONU_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000197 VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION \
Andrea Campanella21323292019-12-18 11:44:19 -0800198 ONOS_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000199 ONOS_API_PORT \
200 ONOS_SSH_PORT \
201 VOLTHA_API_PORT \
202 VOLTHA_SSH_PORT \
203 VOLTHA_ETCD_PORT \
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800204 VOLTHA_KAFKA_PORT \
David K. Bainbridge8f7f30b2020-01-08 13:06:16 -0800205 VK_RELEASE \
206 KIND_VERSION \
207 VOLTCTL_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000208 "
David Bainbridge01294952019-07-30 19:33:45 +0000209
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000210# Iterate over yes/no configuration options and validate
211for VAR in $ALL_YES_NO; do
212 eval $VAR=$(verify_yes_no $VAR)
213 if [ "$(eval echo \$$VAR)" == "INVALID" ]; then
214 exit 1;
215 fi
216done
David Bainbridgeb270c202019-07-26 01:44:42 +0000217
David Bainbridge0774b232019-08-02 06:37:19 +0000218mkdir -p .voltha
219touch .voltha/ports
220HAVE=$(grep $NAME .voltha/ports)
221if [ "$HAVE X" == " X" ]; then
222 # Find free port prefix
223 START=81
224 while true; do
225 if [ $(grep -c $START .voltha/ports) -eq 0 ]; then
226 break
227 fi
228 START=$(expr $START + 1)
229 done
230 DELTA=$(expr $START - 81)
David Bainbridgea2595422019-10-22 03:54:28 +0000231 ONOS_API_PORT=${ONOS_API_PORT:-${START}81}
232 ONOS_SSH_PORT=${ONOS_SSH_PORT:-${START}01}
233 VOLTHA_API_PORT=${VOLTHA_API_PORT:-5$(expr 55 + $DELTA)55}
234 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$(expr 50 + $DELTA)22}
235 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$(expr 23 + $DELTA)79}
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800236 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(expr 90 + $DELTA)92}
Test User01ed0642019-07-03 20:17:06 +0000237else
David Bainbridge0774b232019-08-02 06:37:19 +0000238 VALUES=$(echo $HAVE | sed -e 's/\s//g' | cut -d= -f2)
David Bainbridgea2595422019-10-22 03:54:28 +0000239 ONOS_API_PORT=${ONOS_API_PORT:-$(echo $VALUES | cut -d, -f1)}
240 ONOS_SSH_PORT=${ONOS_SSH_PORT:-$(echo $VALUES | cut -d, -f2)}
241 VOLTHA_API_PORT=${VOLTHA_API_PORT:-$(echo $VALUES | cut -d, -f3)}
242 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$(echo $VALUES | cut -d, -f4)}
243 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$(echo $VALUES | cut -d, -f5)}
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800244 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(echo $VALUES | cut -d, -f6)}
245
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800246 # A bit of a hueristic required here as the KAFKA port forward was
247 # added after the .voltha/ports files was created. Basically, if
248 # the VOLTHA_KAFKA_PORT isn't in the file then calculate the original
249 # DELTA from the VOLTHA_SSH_PORT and apply it to the VOLTHA_KAFKA_PORT
250 if [ -z "$VOLTHA_KAFKA_PORT" ]; then
251 DELTA=$((VOLTHA_SSH_PORT/100-50))
252 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(expr 90 + $DELTA)92}
253 fi
Test User01ed0642019-07-03 20:17:06 +0000254fi
255
David Bainbridge0774b232019-08-02 06:37:19 +0000256PORTTMP=$(mktemp -u)
257cat .voltha/ports | grep -v $NAME > $PORTTMP
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800258echo "$NAME=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT,$VOLTHA_KAFKA_PORT" >> $PORTTMP
David Bainbridge0774b232019-08-02 06:37:19 +0000259cp $PORTTMP .voltha/ports
260rm -f $PORTTMP
261
David Bainbridge27790d62019-08-13 22:43:19 +0000262export ONOS_API_PORT ONOS_SSH_PORT
David Bainbridge01294952019-07-30 19:33:45 +0000263
Test Userd87942b2019-07-03 07:20:24 +0000264IDX=1
David Bainbridgee87067b2019-08-12 22:00:12 +0000265CLOCK="TIME:"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000266SPIN_PARTS=
267NOT_VERIFIED=
David Bainbridgef858a022019-08-14 21:25:11 +0000268THEX=
269BUILD=
270CROSS=
271ENTER=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000272VERIFIED=
273HELM=
274OLD_KEY=
275BIRD=
276HIGH_VOLTAGE=
277PLUG=
278RESTART=
279FORWARD=
280INSTALL=
281STOP=
282GO=
283DOWNLOAD=
284GEAR=
285NO_ENTRY=
286LOCK=
287
288if [ $FANCY -eq 1 ]; then
289 SPIN_PARTS="\
290 \xe2\xa2\x8e\xe2\xa1\xb0 \
291 \xe2\xa2\x8e\xe2\xa1\xa1 \
292 \xe2\xa2\x8e\xe2\xa1\x91 \
293 \xe2\xa2\x8e\xe2\xa0\xb1 \
294 \xe2\xa0\x8e\xe2\xa1\xb1 \
295 \xe2\xa2\x8a\xe2\xa1\xb1 \
296 \xe2\xa2\x8c\xe2\xa1\xb1 \
297 \xe2\xa2\x86\xe2\xa1\xb1 \
298 "
David Bainbridgee87067b2019-08-12 22:00:12 +0000299 CLOCK="\xe2\x8f\xb1"
David Bainbridgef858a022019-08-14 21:25:11 +0000300 THEX="${RED}${BOLD}\xe2\x9c\x97\x20${NORMAL}"
301 ENTER="${YELLOW}${BOLD}\xe2\x8e\x86${NORMAL}"
302 CROSS="${YELLOW}${BOLD}\xe2\x9c\x9a${NORMAL}"
303 BUILD="${YELLOW}${BOLD}\xf0\x9f\x8f\x97${NORMAL}"
304 NOT_VERIFIED="$BUILD"
305 VERIFIED="${GREEN}${BOLD}\xe2\x9c\x93\x20${NORMAL}"
306 HELM="${BLUE}${BOLD}\xE2\x8E\x88${NORMAL}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000307 OLD_KEY="\xF0\x9F\x97\x9D"
308 BIRD="\xF0\x9F\x90\xA6"
309 HIGH_VOLTAGE="\xE2\x9A\xA1"
310 PLUG="\xF0\x9F\xa7\xa9"
311 RESTART="\xf0\x9f\x94\x84"
312 FORWARD="\xE2\x87\xA8"
313 INSTALL="\xF0\x9F\x8F\x97"
314 STOP="\xf0\x9f\x9b\x91"
315 GO="\xf0\x9f\x9a\x80"
316 DOWNLOAD="\xf0\x9f\x93\xa5"
317 GEAR="\xe2\x9a\x99"
318 NO_ENTRY="\xe2\x9b\x94"
319 LOCK="\xf0\x9f\x94\x92"
320fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700321
David Bainbridge712afb82019-08-14 19:55:58 +0000322duration() {
David Bainbridgee87067b2019-08-12 22:00:12 +0000323 local h=$(expr $1 / 3600)
324 local m=$(expr $1 % 3600 / 60)
325 local s=$(expr $1 % 60)
326 local t=""
327
328 if [ $h -gt 0 ]; then
329 t="$t${h}h"
330 fi
331 if [ $m -gt 0 ]; then
332 t="$t${m}m"
333 fi
David Bainbridge712afb82019-08-14 19:55:58 +0000334 echo "$t${s}s"
335}
336
337printtime() {
338 local INDENT=
339 if [ "$1" == "-" ]; then
340 INDENT=" "
341 shift
342 fi
343 echo -e "$INDENT $CLOCK $(duration $1)"
David Bainbridgee87067b2019-08-12 22:00:12 +0000344}
345
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700346bspin() {
Test Userd87942b2019-07-03 07:20:24 +0000347 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700348 local INDENT=
349 if [ "$1" == "-" ]; then
350 INDENT=" "
351 shift
352 fi
David Bainbridge38dc1e82019-08-12 15:18:45 +0000353 if [ $FANCY -eq 0 ]; then
354 LINE=$(echo $* | sed -e 's/[\s+-]//g')
355 if [ "$LINE X" == " X" ]; then
356 return
357 fi
358 echo -e "$CIVIS$INDENT$*"
359 else
360 echo -en "$CIVIS$INDENT $*"
361 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700362}
363
364sspin() {
365 local INDENT=
366 if [ "$1" == "-" ]; then
367 INDENT=" "
368 shift
369 fi
David Bainbridge38dc1e82019-08-12 15:18:45 +0000370 if [ $FANCY -eq 0 ]; then
371 LINE=$(echo $* | sed -e 's/[\s+-]//g')
372 if [ "$LINE X" == " X" ]; then
373 return
374 fi
375 echo -e "$INDENT$*"
376 else
377 C=$(echo $SPIN_PARTS | cut '-d ' -f $IDX)
378 echo -en "\r$INDENT$C $*"
379 IDX=$(expr $IDX + 1)
380 if [ $IDX -gt 8 ]; then
381 IDX=1
382 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700383 fi
384}
385
386espin() {
387 local INDENT=
388 if [ "$1" == "-" ]; then
389 INDENT=" "
390 shift
391 fi
David Bainbridge38dc1e82019-08-12 15:18:45 +0000392 if [ $FANCY -eq 0 ]; then
393 LINE=$(echo $* | sed -e 's/[\s+-]//g')
394 if [ "$LINE X" == " X" ]; then
395 return
396 fi
397 echo -e "$INDENT$*"
398 else
399 echo -e "\r$INDENT$*$CNORM"
400 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700401}
402
David Bainbridgeac7f8072019-08-01 22:15:33 +0000403if [ "$1" == "get" -a "$2" == "voltconfig" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000404 echo "$HOME/.volt/config-$NAME"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000405 exit
406fi
407
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -0700408if [ $# -ne 1 -o $(echo ":up:down:dump:" | grep -c ":$1:") -ne 1 ]; then
David Bainbridgeac7f8072019-08-01 22:15:33 +0000409 >&2 echo "What wouild you like to do today:"
410 >&2 echo " up - bring up voltha"
411 >&2 echo " down - tear down voltha"
412 >&2 echo " dump - create a debug dump of running system"
413 exit 1
414fi
415
David Bainbridge4f1b5562019-08-19 04:46:52 +0000416push_onos_config() {
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800417 local TYPE=$1
418 local MSG=$2
419 local RESOURCE=$3
420 local DATA=$4
David Bainbridge4f1b5562019-08-19 04:46:52 +0000421
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800422 # Thanks to the latest version of ONOS using the return code 207 this gets a
423 # whole lot nastier. Can't thank them enough for doing this. So in order to
424 # capture the command and the output in the log file as well as capture the
425 # status code to verify it is 200 and not 207 mutltiple files and a bit of
426 # hackery must be used. Thanks again ONOS.
427 local CMD_ECHO=$(mktemp -u)
428 local CMD_OUTPUT=$(mktemp -u)
429 local SC_OUTPUT=$(mktemp -u)
430
David Bainbridge4f1b5562019-08-19 04:46:52 +0000431 bspin - "$MSG $GEAR"
432 while true; do
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800433 if [ $TYPE == "file" ]; then
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800434 (set -x; curl --fail -sSL --user karaf:karaf -w "%{http_code}" -o $CMD_OUTPUT -X POST -H Content-Type:application/json http://$_ONOS_API_EP/onos/v1/$RESOURCE --data @$DATA >$SC_OUTPUT 2>/dev/null) >>$CMD_ECHO 2>&1
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800435 fi
436 if [ $TYPE == "json" ]; then
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800437 (set -x; curl --fail -sSL --user karaf:karaf -w "%{http_code}" -o $CMD_OUTPUT -X POST -H Content-Type:application/json http://$_ONOS_API_EP/onos/v1/$RESOURCE --data $DATA >$SC_OUTPUT 2>/dev/null) >>$CMD_ECHO 2>&1
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800438 fi
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800439 RESULT=$?
440 # Dump everything to the log
441 cat $CMD_ECHO >> $LOG
442 cat $CMD_OUTPUT >> $LOG
443 SC=$(cat $SC_OUTPUT)
444
445 # clean up temp files
446 rm -f $CMD_ECHO $CMD_OUTPUT $SC_OUTPUT
447 if [ $RESULT -eq 0 -a "$SC" == "200" ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000448 break
449 fi
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800450 sleep 1
David Bainbridge4f1b5562019-08-19 04:46:52 +0000451 sspin -
452 done
453 espin - $VERIFIED
454}
455
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800456check_onos_app_active() {
457 local APP_ID=$1
458
459 bspin - "Checking that $APP_ID is active $CLOCK"
460 while true; do
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800461 (set -x; curl --fail -sSL --user karaf:karaf -X GET http://$_ONOS_API_EP/onos/v1/applications/$APP_ID | grep ACTIVE >>$LOG 2>&1) >>$LOG 2>&1
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800462 if [ $? -eq 0 ]; then
463 break
464 fi
465 sleep 1
466 sspin -
467 done
468 sleep 5 # OSGI components take a little longer that the app to activate
469 espin - $VERIFIED
470}
471
David Bainbridge4f1b5562019-08-19 04:46:52 +0000472override_onos_app() {
473 local APP=$1
474 local NAME=$(basename $APP | sed -e 's/^[0-9][0-9]*-//g' -e 's/-.*$//g')
475 while true; do
476 sspin -
477 # Attempt to delete old version (if it exists)
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800478 (set -x; curl --fail -sSL --user karaf:karaf -X DELETE http://$_ONOS_API_EP/onos/v1/applications/$NAME >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridge4f1b5562019-08-19 04:46:52 +0000479 sspin -
480 if [ $? -ne 0 ]; then
481 continue
482 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800483 (set -x; curl --fail -sSL --user karaf:karaf -X POST -H Content-Type:application/octet-stream http://$_ONOS_API_EP/onos/v1/applications?activate=true --data-binary @$APP >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridge4f1b5562019-08-19 04:46:52 +0000484 if [ $? -eq 0 ]; then
485 break
486 fi
487 sleep .2
488 done
489}
490
491activate_onos_app() {
492 local MSG="$1"
493 local APP=$2
494
495 bspin - "$MSG $GO"
496 while true; do
497 sspin -
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800498 (set -x; curl --fail -sSL --user karaf:karaf -X POST http://$_ONOS_API_EP/onos/v1/applications/$APP/active >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridge4f1b5562019-08-19 04:46:52 +0000499 if [ $? -eq 0 ]; then
500 break
501 fi
502 sleep .2
503 done
504 espin - "$VERIFIED"
505}
506
507count_pods() {
508 local NAMESPACE=$1; shift
509 if [ "$NAMESPACE" == "all-namespaces" ]; then
510 NAMESPACE="--all-namespaces"
511 else
512 NAMESPACE="-n $NAMESPACE"
513 fi
514 echo "$NAMESPACE" > /tmp/t
515 local STATES=$1; shift
516 echo "$STATES" >> /tmp/t
517 local PODS=$(kubectl get $NAMESPACE pod -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}")
518 local COUNT=0
519 local PATTERNS="$*"
520 for POD in $PODS; do
521 local NAME=$(echo $POD | cut -d/ -f 1)
522 local STATE=$(echo $POD | cut -d/ -f 2)
523 local CONTAINERS=$(echo $POD | cut -d/ -f 3 | sed -e 's/_/ /g')
524 if [ "$STATES" == "*" -o $(echo "$STATES" | grep -c ":$STATE:") -ne 0 ]; then
525 echo "IN WITH $POD" >> /tmp/t
526 local TOTAL=$(echo $CONTAINERS | wc -w)
527 local FOUND=$(echo $CONTAINERS | grep -o true | wc -l)
528 if [ $TOTAL -eq $FOUND ]; then
529 for PATTERN in $PATTERNS; do
530 echo "TEST $PATTERN AGAINST $NAME" >> /tmp/t
531 if [[ $NAME =~ $PATTERN ]]; then
532 echo "COUNT $NAME" >> /tmp/t
533 COUNT=$(expr $COUNT + 1)
534 break
535 fi
536 done
537 fi
538 fi
539 done
540 echo $COUNT >> /tmp/t
541 echo $COUNT
542}
543
544wait_for_pods() {
545 local INDENT=
546 if [ "$1" == "-" ]; then
547 INDENT=$1; shift
548 fi
549 local NAMESPACE=$1; shift
550 local EXPECT=$1; shift
551 local TYPE=$1; shift
552 local RETRY=$1; shift
553 local MESSAGE=$1; shift
554 local PATTERNS=$*
David Bainbridge99ac7a22019-08-31 02:26:43 +0000555 local STATES=":Running:"
556 if [ "$TYPE" == "not" ]; then
557 STATES="*"
558 fi
559 local HAVE=$(count_pods $NAMESPACE "$STATES" $PATTERNS)
David Bainbridge4f1b5562019-08-19 04:46:52 +0000560 local ALL=$HAVE
561 if [ "$TYPE" == "only" ]; then
562 ALL=$(count_pods "all-namespaces" "*" ".*")
563 fi
564 COUNT=$(expr 300 / 15)
565 bspin $INDENT $MESSAGE
566 sspin $INDENT
567 if [ $HAVE -ne $EXPECT -o $ALL -ne $HAVE ]; then
568 while [ $HAVE -ne $EXPECT -o $ALL -ne $HAVE ]; do
569 sspin $INDENT
570 COUNT=$(expr $COUNT - 1)
571 if [ $COUNT -eq 0 ]; then
David Bainbridge99ac7a22019-08-31 02:26:43 +0000572 HAVE=$(count_pods $NAMESPACE "$STATES" $PATTERNS)
David Bainbridge4f1b5562019-08-19 04:46:52 +0000573 ALL=$HAVE
574 if [ "$TYPE" == "only" ]; then
575 ALL=$(count_pods "all-namespaces" "*" ".*")
576 fi
577 COUNT=$(expr 300 / 15)
578 fi
579 sleep .15
580 done
581 fi
582 espin $INDENT $VERIFIED
583 if [ $HAVE -ne $EXPECT ]; then
584 return 1
585 fi
586 return 0
587}
588
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800589port_forward() {
590 local NS=$1
591 local SVC=$2
592 local FROM_PORT=$3
593 local TO_PORT=$4
594 local TAG=$SVC-$NAME
595
596 (set -x; _TAG=$TAG bash -c "while true; do kubectl port-forward -n $NS service/$SVC $FROM_PORT:$TO_PORT; done" >>$LOG 2>&1 &) >>$LOG 2>&1
597}
598
599kill_port_forward() {
600 local TAG=$1-$NAME
David Bainbridgec6871d22019-11-13 17:10:31 +0000601 local P_IDS=$(ps e -ww -A | grep "_TAG=$TAG" | grep -v grep | awk '{print $1}')
David Bainbridgebcf235b2019-11-12 21:33:58 +0000602 local PARENTS=
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800603 local KIDS=
David Bainbridgec6871d22019-11-13 17:10:31 +0000604 local UNKNOWN=
605 if [ ! -z "$P_IDS" ]; then
606 for P_ID in $P_IDS; do
607 local PP_ID=$(ps -o ppid $P_ID | tail -n +2)
608 if [ ! -z "$PP_ID" ]; then
609 if [ $PP_ID -eq 1 ]; then
610 PARENTS="$PARENTS $P_ID"
611 else
612 KIDS="$KIDS $P_ID"
613 fi
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800614 else
David Bainbridgec6871d22019-11-13 17:10:31 +0000615 UNKNOWN="$UNKNOWN $P_ID"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800616 fi
617 done
David Bainbridgec6871d22019-11-13 17:10:31 +0000618 (set -x; kill -9 $PARENTS $KIDS $UNKNOWN >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800619 fi
620}
621
David Bainbridgeac7f8072019-08-01 22:15:33 +0000622if [ "$1" == "down" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000623 echo "Tearing down voltha cluster $NAME"
624 LOG="down-$NAME.log"
625 echo $(date -u +"%Y%m%dT%H%M%SZ") >$LOG
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800626 bspin "Remove port-forwards: onos-ui-$NAME"
627 kill_port_forward onos-ui
628 sspin "Remove port-forwards: onos-ssh-$NAME$CEOL"
629 kill_port_forward onos-ssh
630 sspin "Remove port-forwards: voltha-api-$NAME$CEOL"
631 kill_port_forward voltha-api
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800632 sspin "Remove port-forwards: voltha-etcd-$NAME$CEOL"
633 kill_port_forward voltha-etcd-cluster-client
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800634 sspin "Remove port-forwards: voltha-kafka-$NAME$CEOL"
635 kill_port_forward voltha-kafka
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800636 espin "$VERIFIED Remove port-forwards$CEOL"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000637 if [ $DEPLOY_K8S == "yes" ]; then
638 if [ -x ./bin/kind ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000639 bspin "Delete Kubernetes Kind Cluster"
640 (set -x; ./bin/kind delete cluster --name voltha-$NAME >>$LOG 2>&1) >>$LOG 2>&1
641 espin $VERIFIED
David Bainbridgeac7f8072019-08-01 22:15:33 +0000642 else
David Bainbridge0774b232019-08-02 06:37:19 +0000643 espin "$NO_ENTRY Delete Kubernetes Kind Cluster: kind command not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000644 fi
645 else
646 EXISTS=$(helm list -q)
647 EXPECT="etcd-operator onos open-olt open-onu sim voltha bbsim radius"
David Bainbridge0774b232019-08-02 06:37:19 +0000648 bspin "Remove Helm Deployments"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000649 for i in $EXISTS; do
uottrembb16d3982020-02-28 08:34:36 +0100650 for j in $EXPECT; do
651 if [[ $i =~ $j ]]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000652 sspin "Remove Helm Deployments: $i$CEOL"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800653 (set -x; ./bin/helm delete --no-hooks --purge $i >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000654 fi
655 done
uottrembb16d3982020-02-28 08:34:36 +0100656 done
David Bainbridge0774b232019-08-02 06:37:19 +0000657 espin "$VERIFIED Remove Helm Deployments$CEOL"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000658 if [ "$WAIT_ON_DOWN" == "yes" ]; then
659 # There should only be 13 or 15 PODs in the kube-system name
660 # space and no other PODs
David Bainbridge4f1b5562019-08-19 04:46:52 +0000661 PODS="coredns-.* \
662 etcd-voltha-$NAME-control-plane \
663 kindnet-.* \
664 kube-apiserver-voltha-$NAME-control-plane \
665 kube-controller-manager-voltha-$NAME-control-plane \
666 kube-proxy-.* \
667 kube-scheduler-voltha-$NAME-control-plane \
668 tiller-deploy-.*"
669 EXPECT=$(test "$TYPE" == "minimal" && echo "13" || echo "15")
David Bainbridge99ac7a22019-08-31 02:26:43 +0000670 PODS="adapter-.* \
671 bbsim.* \
672 etcd-operator.* \
673 radius.* \
674 voltha-.*"
Matteo Scandolo73442f92020-01-29 09:53:22 -0800675
David Bainbridge99ac7a22019-08-31 02:26:43 +0000676 EXPECT=0
677
Matteo Scandolo73442f92020-01-29 09:53:22 -0800678 if [ "$WITH_ONOS" == "yes" ]; then
679 ONOS_PODS="onos-.*"
680 wait_for_pods "default" $EXPECT "not" -1 "Waiting for ONOS PODs to terminate" $ONOS_PODS
681 fi
David Bainbridge99ac7a22019-08-31 02:26:43 +0000682 wait_for_pods "voltha" $EXPECT "not" -1 "Waiting for VOLTHA PODs to terminate" $PODS
David Bainbridge4f1b5562019-08-19 04:46:52 +0000683 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +0000684 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -0700685 exit
David Bainbridgeac7f8072019-08-01 22:15:33 +0000686fi
687
688if [ "$1" == "dump" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000689 LOG="dump-$NAME.log"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000690 TS=$(date -u +"%Y%m%dT%H%M%SZ")
David Bainbridge76514a02019-10-08 01:50:35 +0000691 if [ ! -z "$DUMP_FROM" ]; then
692 TS=$(echo $DUMP_FROM | sed -e 's/[:-]//g')
693 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +0000694 WORK=$(mktemp -u -d)
David Bainbridge0774b232019-08-02 06:37:19 +0000695 DATA=$WORK/voltha-debug-dump-$NAME-$TS
David Bainbridgeac7f8072019-08-01 22:15:33 +0000696 mkdir -p $DATA
697 echo $TS > $LOG
David Bainbridge0774b232019-08-02 06:37:19 +0000698 echo -e "Capturing debug dump to voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000699 bspin - "Copy install log"
David Bainbridge0774b232019-08-02 06:37:19 +0000700 if [ -f install-$NAME.log ]; then
701 (set -x; cp install-$NAME.log $DATA/install-$NAME.log) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000702 espin - $VERIFIED
703 else
David Bainbridge0774b232019-08-02 06:37:19 +0000704 espin - "$NO_ENTRY Copy install log: install-$NAME.log not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000705 fi
706 bspin - "Dumping Kubernetes PODs"
707 (set -x; kubectl get --all-namespaces pods >> $DATA/all-pods.txt 2>&1) >>$LOG 2>&1
708 espin - $VERIFIED
709 bspin - "Dumping Kubernetes SERVICEs"
710 (set -x; kubectl get --all-namespaces svc >> $DATA/all-services.txt 2>&1) >>$LOG 2>&1
711 espin - $VERIFIED
712 bspin - "Dumping Kubernetes EVENTs"
713 (set -x; kubectl get --all-namespaces events >> $DATA/all-events.txt 2>&1) >>$LOG 2>&1
714 espin - $VERIFIED
715 bspin - "Dumping VOLTHA POD details"
Matteo Scandolodcd29f52019-10-07 15:42:42 -0700716 PODS="$(kubectl -n default get pod -o name | grep onos | sed -e 's/^/default:/g') $(kubectl get -n voltha pod -o name | sed -e 's/^/voltha:/g')"
David Bainbridgecfd7ca12019-10-06 03:31:41 +0000717 SINCE=
718 if [ ! -z "$DUMP_FROM" ]; then
719 SINCE="--since-time=$DUMP_FROM"
720 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +0000721 for POD in $PODS; do
David Bainbridge1f0655a2019-10-01 22:08:48 +0000722 NS=$(echo $POD | cut -d: -f1)
723 POD=$(echo $POD | cut -d: -f2)
David Bainbridgeac7f8072019-08-01 22:15:33 +0000724 sspin - "Dumping VOLTHA POD details: $POD$CEOL"
725 mkdir -p $DATA/$POD
David Bainbridge1f0655a2019-10-01 22:08:48 +0000726 (set -x; kubectl describe -n $NS $POD >> $DATA/$POD/describe.txt 2>&1) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000727 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridgecfd7ca12019-10-06 03:31:41 +0000728 (set -x; kubectl logs -n $NS --all-containers $SINCE --previous $LOG_ARGS $POD >> $DATA/$POD/logs-previous.txt 2>&1) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000729 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridgecfd7ca12019-10-06 03:31:41 +0000730 (set -x; kubectl logs -n $NS --all-containers $SINCE $LOG_ARGS $POD >> $DATA/$POD/logs-current.txt 2>&1) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000731 sspin - "Dumping VOLTHA POD details: $POD"
732 done
733 espin - "$VERIFIED Dumping VOLTHA POD details$CEOL"
734 bspin - "Dumping ETCD"
735 if [ "$(which etcdctl) X" != " X" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000736 (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 +0000737 espin - $VERIFIED
738 else
739 espin - "$NO_ENTRY Dumping ETCD: etcdctl command not available"
740 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000741 bspin - "Creating compressed TAR: voltha-debug-dump-$NAME-$TS.tgz"
742 (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 +0000743 espin - $VERIFIED
744 bspin - "Cleanup"
745 (set -x; rm -rf $WORK) >>$LOG 2>&1
746 espin - $VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +0000747 bspin - "$(ls -l voltha-debug-dump-$NAME-$TS.tgz)"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000748 espin - $VERIFIED
749 exit
750fi
751
David Bainbridge0774b232019-08-02 06:37:19 +0000752LOG="install-$NAME.log"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000753date > $LOG
David Bainbridge0774b232019-08-02 06:37:19 +0000754echo "PORTS=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT" >> $LOG
David Bainbridgeac7f8072019-08-01 22:15:33 +0000755
756# Output install options to log
757echo "OPTIONS" >> $LOG
David Bainbridgeac7f8072019-08-01 22:15:33 +0000758for O in $ALL_OPTIONS; do
759 VAL=$(eval echo \$$O)
David Bainbridgeac7f8072019-08-01 22:15:33 +0000760 if [ ! -z "$VAL" ]; then
761 printf " %-30s = %s\n" $O $VAL >> $LOG
762 fi
763done
764
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -0700765helm_install() {
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700766 local INDENT=
767 if [ "$1" == "-" ]; then
768 INDENT=$1; shift
769 fi
770 local NAMESPACE=$1; shift
David Bainbridge0774b232019-08-02 06:37:19 +0000771 local INAME=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700772 local CHART=$1; shift
David Bainbridge90fd8e32019-08-21 23:32:47 +0000773 local CHART_VERSION=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700774 local MESSAGE=$*
775
David Bainbridge90fd8e32019-08-21 23:32:47 +0000776 if [ "$CHART_VERSION X" != " X" -a "$CHART_VERSION" != "latest" ]; then
777 CHART_VERSION="--version $CHART_VERSION"
778 else
779 CHART_VERSION=
780 fi
781
David Bainbridge99ac7a22019-08-31 02:26:43 +0000782 local CHART_ARGS=
783 if [ -r "${INAME}-values.yaml" ]; then
784 CHART_ARGS="-f ${INAME}-values.yaml"
785 fi
786
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700787 COUNT=$(expr 300 / 15)
788 bspin $INDENT $MESSAGE
David Bainbridge70c0ea82019-11-14 23:25:26 +0000789 (set -x; helm install -f $NAME-values.yaml $CHART_ARGS $EXTRA_HELM_INSTALL_ARGS --set defaults.log_level=$VOLTHA_LOG_LEVEL --namespace $NAMESPACE --name $INAME $CHART_VERSION $EXTRA_HELM_FLAGS $CHART >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700790 SUCCESS=$?
791 while [ $SUCCESS -ne 0 ]; do
792 sspin $INDENT
793 COUNT=$(expr $COUNT - 1)
794 if [ $COUNT -eq 0 ]; then
Andy Baviere22ff252019-12-19 11:40:31 -0700795 (set -x; helm delete --purge $INAME >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridge99ac7a22019-08-31 02:26:43 +0000796 (set -x; helm install -f $NAME-values.yaml $CHART_ARGS --set defaults.log_level=$VOLTHA_LOG_LEVEL --namespace $NAMESPACE --name $INAME $CHART_VERSION $EXTRA_HELM_FLAGS $CHART >>$LOG 2>&1) >>$LOG 2>&1
Andy Baviere22ff252019-12-19 11:40:31 -0700797 SUCCESS=$?
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700798 COUNT=$(expr 300 / 15)
799 fi
800 sleep .15
801 done
802 espin $INDENT $VERIFIED
803}
804
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700805echo "INSTALL TYPE: $TYPE" >> $LOG
806
807bspin "Verify GOPATH"
808export GOPATH=$(pwd)
Test User3d7ad8e2019-07-03 06:15:44 +0000809mkdir -p $GOPATH/bin
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700810espin $VERIFIED
811
David Bainbridgee87067b2019-08-12 22:00:12 +0000812STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700813if [ "$INSTALL_KUBECTL" == "no" ]; then
814 bspin "Skip kubectl install"
815 espin $NO_ENTRY
Test Userc13bdc92019-07-03 20:57:49 +0000816else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700817 bspin "Verify kubectl $HELM"
818 if [ -x $GOPATH/bin/kubectl ]; then
819 espin $VERIFIED
820 else
821 espin $NOT_VERIFIED
822 bspin - "Download and install Kubernetes/kubectl $DOWNLOAD"
823 (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
824 (set -x; chmod 755 $GOPATH/bin/kubectl >>$LOG 2>&1) >>$LOG 2>&1
825 espin - $VERIFIED
826 fi
Test Userc13bdc92019-07-03 20:57:49 +0000827fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000828if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000829 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000830fi
Test Userc13bdc92019-07-03 20:57:49 +0000831
David Bainbridgee87067b2019-08-12 22:00:12 +0000832STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700833if [ "$DEPLOY_K8S" == "no" ]; then
834 bspin "Skip Kubernetes/Kind Deployment"
835 espin $NO_ENTRY
836else
Test Userba1e7e72019-07-10 22:27:54 +0000837 bspin "Verify Kubernetes/Kind $HELM"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800838 IS_INSTALLED=0
839 OP_TYPE="install"
Test Userba1e7e72019-07-10 22:27:54 +0000840 if [ -x $GOPATH/bin/kind ]; then
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800841 OP_TYPE="upgrade"
842 if [ $($GOPATH/bin/kind --version | grep -c $KIND_VERSION) -eq 1 ]; then
843 IS_INSTALLED=1
844 espin $VERIFIED
845 fi
846 fi
847 if [ $IS_INSTALLED -eq 0 ]; then
Test Userba1e7e72019-07-10 22:27:54 +0000848 espin $NOT_VERIFIED
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800849 bspin - "Download and $OP_TYPE Kubernetes/kind $DOWNLOAD"
David Bainbridge9e2a6662019-07-11 17:07:57 +0000850 (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 +0000851 (set -x; chmod 755 $GOPATH/bin/kind >>$LOG 2>&1) >>$LOG 2>&1
852 espin - $VERIFIED
853 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700854fi
855
David Bainbridgee87067b2019-08-12 22:00:12 +0000856if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000857 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000858fi
859
860STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700861if [ "$INSTALL_HELM" == "no" ]; then
862 bspin "Skip Helm Install"
863 espin $NO_ENTRY
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700864else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700865 bspin "Verify Helm $HELM"
866 if [ -x $GOPATH/bin/helm ]; then
867 espin $VERIFIED
868 else
869 espin $NOT_VERIFIED
870 bspin - "Download and install Helm $DOWNLOAD"
David Bainbridgec6a6eb62019-10-18 22:50:07 +0000871 (set -x; curl -sSL https://git.io/get_helm.sh | DESIRED_VERSION=v2.14.3 USE_SUDO=false HELM_INSTALL_DIR=$GOPATH/bin bash >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700872 espin - $VERIFIED
873 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700874fi
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800875
David Bainbridgee87067b2019-08-12 22:00:12 +0000876if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000877 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000878fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700879
David Bainbridgee87067b2019-08-12 22:00:12 +0000880STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +0000881bspin "Verify voltctl $HIGH_VOLTAGE"
David Bainbridged2811972019-12-14 01:14:09 +0000882VOK=0
883VMESSAGE="install"
David K. Bainbridgeebf38d92020-02-10 10:46:31 -0800884export VC_VERSION="$VOLTCTL_VERSION"
885if [ "$VC_VERSION" == "latest" ]; then
886 export VC_VERSION=$(curl -sSL https://api.github.com/repos/opencord/voltctl/releases/latest | jq -r .tag_name | sed -e 's/^v//g')
887fi
Test User3d7ad8e2019-07-03 06:15:44 +0000888if [ -x $GOPATH/bin/voltctl ]; then
David Bainbridge1ba64f12019-12-18 00:40:13 +0000889 VHAVE=$($GOPATH/bin/voltctl version --clientonly -o json | jq -r .version)
David K. Bainbridgeebf38d92020-02-10 10:46:31 -0800890 if [ $? -eq 0 -a "$VHAVE" == "$VC_VERSION" ]; then
David Bainbridged2811972019-12-14 01:14:09 +0000891 VOK=1
David Bainbridge1ba64f12019-12-18 00:40:13 +0000892 espin $VERIFIED
893 else
David K. Bainbridgeebf38d92020-02-10 10:46:31 -0800894 VCHECK=$(echo -e "$VHAVE\n$VC_VERSION" | sort -V | head -1)
895 if [ "$VCHECK" == "$VHAVE" ]; then
896 VMESSAGE="upgrade"
897 else
898 VMESSAGE="downgrade"
899 fi
David Bainbridged2811972019-12-14 01:14:09 +0000900 fi
901fi
902
David Bainbridge1ba64f12019-12-18 00:40:13 +0000903if [ $VOK -eq 0 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700904 espin $NOT_VERIFIED
David Bainbridged2811972019-12-14 01:14:09 +0000905 bspin - "Download and $VMESSAGE voltctl $DOWNLOAD"
David K. Bainbridgeebf38d92020-02-10 10:46:31 -0800906 (set -x; curl -o $GOPATH/bin/voltctl -sSL https://github.com/opencord/voltctl/releases/download/v$VC_VERSION/voltctl-$VC_VERSION-$HOSTOS-$HOSTARCH >>$LOG 2>&1) >>$LOG 2>&1
Test User08ebbd92019-07-03 17:15:39 +0000907 (set -x; chmod 755 $GOPATH/bin/voltctl >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700908 espin - $VERIFIED
909fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000910if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000911 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000912fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700913
914bspin "Verify command PATH"
Test Userba1e7e72019-07-10 22:27:54 +0000915export PATH=$GOPATH/bin:$PATH
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700916espin $VERIFIED
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700917
David Bainbridgee87067b2019-08-12 22:00:12 +0000918STIME=$(date +%s)
Test Userba1e7e72019-07-10 22:27:54 +0000919if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000920 HAVE=$(kind get clusters | grep -c voltha-$NAME)
Test Userba1e7e72019-07-10 22:27:54 +0000921 bspin "Verify Kubernetes/Kind Cluster"
922 sspin
923 if [ $HAVE -eq 0 ]; then
David Bainbridge491b1bd2019-07-11 17:53:11 +0000924 espin $NOT_VERIFIED
925 bspin - "Verify cluster configuration"
David Bainbridge0774b232019-08-02 06:37:19 +0000926 if [ ! -r ./$NAME-cluster.cfg ]; then
David Bainbridge491b1bd2019-07-11 17:53:11 +0000927 espin - $NOT_VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +0000928 bspin - "Download cluster configuration: $TYPE-cluster.cfg to $NAME-cluster.cfg $DOWNLOAD"
David K. Bainbridgea00736b2020-01-08 14:33:17 -0800929 ERR_OUT=$(mktemp)
930 (set -x; curl --fail -o ./$NAME-cluster.cfg -sSL https://raw.githubusercontent.com/ciena/kind-voltha/$VK_RELEASE/$TYPE-cluster.cfg >>$LOG 2>>$ERR_OUT) >>$LOG 2>&1
931 if [ $? -ne 0 ]; then
932 espin - $THEX
933 echo -e "${RED}${BOLD}${ERROR}ERROR: $NAME-cluster.cfg${NORMAL}${RED} - $(cat $ERR_OUT)${NORMAL}"
934 echo "ERROR: $(cat $ERR_OUT)" >>$LOG
935 rm -rf $ERR_OUT ./$NAME-cluster.cfg
936 exit 1
937 fi
938 rm -rf $ERR_OUT
939 else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700940 espin - $VERIFIED
David K. Bainbridgea00736b2020-01-08 14:33:17 -0800941 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000942 kind create cluster --name voltha-$NAME --config $NAME-cluster.cfg
David Bainbridge491b1bd2019-07-11 17:53:11 +0000943 else
944 espin $VERIFIED
Test Userba1e7e72019-07-10 22:27:54 +0000945 fi
946
David Bainbridge0774b232019-08-02 06:37:19 +0000947 export KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$NAME")"
Test Userba1e7e72019-07-10 22:27:54 +0000948 P="coredns-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000949 etcd-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +0000950 kindnet-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000951 kube-apiserver-voltha-$NAME-control-plane \
952 kube-controller-manager-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +0000953 kube-proxy-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000954 kube-scheduler-voltha-$NAME-control-plane"
Test Userba1e7e72019-07-10 22:27:54 +0000955
956 EXPECT=$(test "$TYPE" == "minimal" && echo "12" || echo "14")
David Bainbridge4f1b5562019-08-19 04:46:52 +0000957 wait_for_pods - "kube-system" $EXPECT "includes" -1 "Waiting for system PODs to start" $P
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700958fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000959if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000960 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000961fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700962
David Bainbridgee87067b2019-08-12 22:00:12 +0000963STIME=$(date +%s)
David Bainbridge4c6289c2019-09-03 21:11:32 +0000964COUNT=$(count_pods "kube-system" ":Running:" "tiller-deploy-.*")
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700965bspin "Verify Helm"
Test Userba1e7e72019-07-10 22:27:54 +0000966if [ $COUNT -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700967 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000968 echo -e "Configuring Helm $GEAR"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700969 if [ "$INSTALL_HELM" == "no" ]; then
970 bspin - "Skip Helm/Tiller Initialization"
971 espin - $NO_ENTRY
972 else
973 bspin - "Initialize Helm"
974 (set -x; helm init --upgrade >>$LOG 2>&1) >>$LOG 2>&1
975 espin - $VERIFIED
David Bainbridge4f1b5562019-08-19 04:46:52 +0000976 wait_for_pods - "kube-system" 1 "includes" -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700977 fi
Test Userb5712372019-07-03 21:52:17 +0000978 bspin - "Add Google Incubator repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700979 (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
980 espin - $VERIFIED
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -0700981
Test Userba1e7e72019-07-10 22:27:54 +0000982 # HACK (sort-of) - the config for tiller is about to be patched, which will
983 # cause the tiller pod to be recreated. This can sometimes cause a timing
984 # issue with the "wait_for_pods" call on tiller as it may incorrectly
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -0700985 # identify the running/ready tiller pod that is soon to be terminated as
Test Userba1e7e72019-07-10 22:27:54 +0000986 # what it is waiting for. To avoid this issue we do a clean scale down and
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -0700987 # scale up of the pod so the script controlls when it should be expecting
Test Userba1e7e72019-07-10 22:27:54 +0000988 # things
989 (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 -0700990
Test Userb5712372019-07-03 21:52:17 +0000991 bspin - "Add Google Stable repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700992 (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
993 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000994 bspin - "Add ONF repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700995 (set -x; helm repo add onf https://charts.opencord.org >>$LOG 2>&1) >>$LOG 2>&1
996 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000997 bspin - "Update Helm repository cache"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700998 (set -x; helm repo update >>$LOG 2>&1) >>$LOG 2>&1
999 espin - $VERIFIED
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001000
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001001 # Create and k8s service account so that Helm can create pods
Test Userb5712372019-07-03 21:52:17 +00001002 bspin - "Create Tiller ServiceAccount"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001003 (set -x; kubectl create serviceaccount --namespace kube-system tiller >>$LOG 2>&1) >>$LOG 2>&1
1004 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +00001005 bspin - "Create Tiller ClusterRoleBinding"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001006 (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>$LOG 2>&1) >>$LOG 2>&1
1007 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +00001008 bspin - "Update Tiller Manifest"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001009 (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 +00001010
1011 # HACK (sort-of) - part to, spin it back up
1012 (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 -07001013 espin - $VERIFIED
1014else
1015 espin $VERIFIED
David Bainbridge46505fb2019-10-01 21:13:20 +00001016 if [ "$UPDATE_HELM_REPOS" == "yes" ]; then
1017 bspin - "Update Helm repository cache"
1018 (set -x; helm repo update >>$LOG 2>&1) >>$LOG 2>&1
1019 espin - $VERIFIED
1020 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001021fi
David Bainbridge4f1b5562019-08-19 04:46:52 +00001022wait_for_pods - "kube-system" 1 "includes" -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001023if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001024 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001025fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001026
David Bainbridgee87067b2019-08-12 22:00:12 +00001027STIME=$(date +%s)
David Bainbridge0774b232019-08-02 06:37:19 +00001028bspin "Verify Helm values file: $NAME-values.yaml"
1029if [ ! -r "./$NAME-values.yaml" ]; then
Test Userba1e7e72019-07-10 22:27:54 +00001030 espin $NOT_VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +00001031 bspin - "Download Helm values file: $TYPE-values.yaml to $NAME-values.yaml $DOWNLOAD"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001032 ERR_OUT=$(mktemp)
1033 (set -x; curl --fail -o ./$NAME-values.yaml -sSL https://raw.githubusercontent.com/ciena/kind-voltha/$VK_RELEASE/$TYPE-values.yaml >>$LOG 2>$ERR_OUT) >>$LOG 2>&1
1034 if [ $? -ne 0 ]; then
1035 espin - $THEX
1036 echo -e "${RED}${BOLD}${ERROR}ERROR: $NAME-values.yaml${NORMAL}${RED} - $(cat $ERR_OUT)${NORMAL}"
1037 echo "ERROR: $(cat $ERR_OUT)" >>$LOG
1038 rm -rf $ERR_OUT ./$NAME-values.yaml
1039 exit 1
1040 fi
1041 rm -rf $ERR_OUT
Test Userba1e7e72019-07-10 22:27:54 +00001042 espin - $VERIFIED
1043else
1044 espin $VERIFIED
1045fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001046if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001047 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001048fi
Test Userba1e7e72019-07-10 22:27:54 +00001049
David Bainbridge99ac7a22019-08-31 02:26:43 +00001050STIME=$(date +%s)
1051bspin "Verify or download chart specific values files $DOWNLOAD"
1052VALUES_FILES="monkey-values.yaml"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001053ERR_OUT=$(mktemp)
David Bainbridge99ac7a22019-08-31 02:26:43 +00001054for i in $VALUES_FILES; do
1055 if [ ! -r ./$i ]; then
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001056 (set -x; curl --fail -o ./$i -sSL https://raw.githubusercontent.com/ciena/kind-voltha/$VK_RELEASE/$i >>$LOG 2>$ERR_OUT) >>$LOG 2>&1
1057 if [ $? -ne 0 ]; then
1058 espin $THEX
1059 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat $ERR_OUT)${NORMAL}"
1060 echo "ERROR: $i - $(cat $ERR_OUT)" >>$LOG
1061 rm -rf $ERR_OUT ./$i
1062 exit 1
1063 fi
1064 rm -rf $ERR_OUT
David Bainbridge99ac7a22019-08-31 02:26:43 +00001065 fi
1066done
1067espin $VERIFIED
1068if [ "$WITH_TIMINGS" == "yes" ]; then
1069 printtime $(expr $(date +%s) - $STIME)
1070fi
1071
1072if [ "$WITH_CHAOS" == "yes" ]; then
1073 bspin "Verify or clone kube-monkey helm chart $DOWNLOAD"
1074 if [ -r ./kube-monkey ]; then
1075 espin $VERIFIED
1076 else
1077 espin $NOT_VERIFIED
1078 bspin - "GIT clone kube-monkey"
1079 (set -x; git clone https://github.com/asobti/kube-monkey kube-monkey >>$LOG 2>&1) >>$LOG 2>&1
1080 espin - $VERIFIED
1081 fi
1082fi
1083
Test Userba1e7e72019-07-10 22:27:54 +00001084if [ "$JUST_K8S" == "yes" ]; then
1085 echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye."
1086 echo ""
1087 echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
1088 echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
1089 echo "tools required by VOLTHA in your command path. " | tee -a $LOG
1090 echo "" | tee -a $LOG
1091 echo -en $BOLD
1092 if [ $DEPLOY_K8S == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001093 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +00001094 fi
1095 echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
1096 echo -en $NORMAL
1097 echo "" | tee -a $LOG
1098 echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
1099 exit 0
1100fi
1101
David Bainbridgee87067b2019-08-12 22:00:12 +00001102STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +00001103bspin "Verify ETCD Operator $OLD_KEY"
Test User7d866122019-07-09 17:52:35 +00001104if [ $(helm list --deployed --short --namespace voltha "^etcd-operator\$" | wc -l) -ne 1 ]; then
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001105 espin $NOT_VERIFIED
David Bainbridge90fd8e32019-08-21 23:32:47 +00001106 helm_install - voltha etcd-operator stable/etcd-operator latest "Install ETCD Operator"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001107else
1108 espin $VERIFIED
1109fi
Test User01ed0642019-07-03 20:17:06 +00001110EXPECT=$(test "$TYPE" == "minimal" && echo "1" || echo "3")
David Bainbridge4f1b5562019-08-19 04:46:52 +00001111wait_for_pods - "voltha" $EXPECT "includes" -1 "Waiting for ETCD Operator to start" "etcd-operator-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001112if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001113 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001114fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001115
David Bainbridgee87067b2019-08-12 22:00:12 +00001116STIME=$(date +%s)
David Bainbridgeb270c202019-07-26 01:44:42 +00001117if [ $WITH_ONOS == "yes" ]; then
1118 bspin "Verify ONOS installed $BIRD"
1119 if [ $(helm list --deployed --short --namespace default "^onos\$" | wc -l) -ne 1 ]; then
1120 espin $NOT_VERIFIED
Andrea Campanella6afcb082019-12-18 16:51:30 -08001121 EXTRA_HELM_FLAGS="$SET_TAG $EXTRA_HELM_FLAGS" helm_install - default onos onf/onos $ONOS_CHART_VERSION "Install ONOS"
David Bainbridgeb270c202019-07-26 01:44:42 +00001122 else
1123 espin $VERIFIED
1124 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +00001125 wait_for_pods - "default" 1 "includes" -1 "Waiting for ONOS to start" "onos-.*"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001126
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001127 if [ $WITH_PORT_FORWARDS == "yes" ]; then
1128 bspin - "Forward ONOS API port $FORWARD"
1129 kill_port_forward onos-ui
1130 port_forward default onos-ui $ONOS_API_PORT 8181
1131 espin - $VERIFIED
1132 bspin - "Forward ONOS SSH port $FORWARD"
1133 kill_port_forward onos-ssh
1134 port_forward default onos-ssh $ONOS_SSH_PORT 8101
1135 espin - $VERIFIED
1136 _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT"
1137 else
1138 _ONOS_API_EP=$(get_service_ep default onos-ui)
1139 fi
David Bainbridged31d6122019-08-13 19:37:59 +00001140 bspin - "Verify or download ONOS configuration support files $DOWNLOAD"
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001141 ONOS_FILES="olt-onos-enableExtraneousRules.json onos-aaa.json \
David Bainbridge90fd8e32019-08-21 23:32:47 +00001142 onos-dhcpl2relay.json onos-kafka.json onos-sadis-sample.json"
David Bainbridged31d6122019-08-13 19:37:59 +00001143 (set -x; mkdir -p ./onos-files >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001144 ERR_OUT=$(mktemp)
David Bainbridge2b19e832019-08-16 02:40:53 +00001145 for i in $ONOS_FILES; do
David Bainbridged31d6122019-08-13 19:37:59 +00001146 if [ ! -r ./onos-files/$i ]; then
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001147 (set -x; curl --fail -o ./onos-files/$i -sSL https://raw.githubusercontent.com/ciena/kind-voltha/$VK_RELEASE/onos-files/$i >>$LOG 2>$ERR_OUT) >>$LOG 2>&1
1148 if [ $? -ne 0 ]; then
1149 espin - $THEX
1150 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat $ERR_OUT)${NORMAL}"
1151 echo "ERROR: $(cat $ERR_OUT)" >>$LOG
1152 rm -rf $ERR_OUT ./onos-files/$i
1153 exit 1
1154 fi
1155 rm -rf $ERR_OUT
David Bainbridged31d6122019-08-13 19:37:59 +00001156 fi
1157 done
Test Userba1e7e72019-07-10 22:27:54 +00001158 espin - $VERIFIED
David Bainbridge27790d62019-08-13 22:43:19 +00001159
1160 if [ $INSTALL_ONOS_APPS == "yes" ]; then
1161 bspin - "Installing custom ONOS applications"
1162 if [ -x onos-files/onos-apps -a $(ls -1 onos-files/onos-apps/*.oar 2>/dev/null | wc -l) -gt 0 ]; then
1163 for OAR in $(ls -1 onos-files/onos-apps/*.oar); do
1164 sspin - "Installing custom ONOS applications - $OAR$CEOL"
David Bainbridge2b19e832019-08-16 02:40:53 +00001165 override_onos_app $OAR
David Bainbridge27790d62019-08-13 22:43:19 +00001166 done
1167 espin - "$VERIFIED Installing custom ONOS applications$CEOL"
1168 else
1169 espin - "$NOT_VERIFIED Installing custom ONOS applications - None Found"
1170 fi
1171 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001172
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001173 check_onos_app_active org.opencord.kafka
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001174 push_onos_config "file" "Push ONOS Kafka Configuration" "network/configuration/apps/org.opencord.kafka" "onos-files/onos-kafka.json"
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001175 check_onos_app_active org.opencord.dhcpl2relay
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001176 push_onos_config "file" "Push ONOS DHCP L2 Relay Configuration" "network/configuration/apps/org.opencord.dhcpl2relay" "onos-files/onos-dhcpl2relay.json"
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001177 check_onos_app_active org.opencord.olt
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001178 # FIXME use WITH_DHCP and WITH_EAPOL flags to configre OLT App
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001179 # Default value for "enableEapol" is true in OLT App
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001180 if [ $WITH_EAPOL == "yes" ]; then
1181 push_onos_config "json" "Enable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":true}'
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001182 elif [ $WITH_EAPOL == "no" ]; then
1183 push_onos_config "json" "Disable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001184 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001185 # Default value for "enableDhcpOnProvisioning" is false and for "enableDhcpV4" is true in OLT App
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001186 if [ $WITH_DHCP == "yes" ]; then
1187 push_onos_config "json" "Enable VOLTHA ONOS DHCP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableDhcpOnProvisioning":true,"enableDhcpV4":true}'
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001188 elif [ $WITH_DHCP == "no" ]; then
1189 push_onos_config "json" "Disable VOLTHA ONOS DHCP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableDhcpOnProvisioning":false,"enableDhcpV4":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001190 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001191 # Default value for "enableIgmpOnProvisioning" is false in OLT App
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001192 if [ $WITH_IGMP == "yes" ]; then
1193 push_onos_config "json" "Enable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":true}'
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001194 elif [ $WITH_IGMP == "no" ]; then
1195 push_onos_config "json" "Disable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001196 fi
David K. Bainbridge484d80c2020-03-05 21:44:34 -08001197 if [ $ENABLE_ONOS_EXTRANEOUS_RULES == "yes" ]; then
1198 push_onos_config "file" "Enabling extraneous rules for ONOS" "configuration/org.onosproject.net.flow.impl.FlowRuleManager" "onos-files/olt-onos-enableExtraneousRules.json"
1199 fi
David Bainbridge2b19e832019-08-16 02:40:53 +00001200 if [ -f onos-files/onos-sadis.json ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001201 push_onos_config "file" "[optional] Push ONOS SADIS Configuration" "network/configuration/apps/org.opencord.sadis" "onos-files/onos-sadis.json"
David Bainbridge2b19e832019-08-16 02:40:53 +00001202 elif [ "$CONFIG_SADIS" == "yes" ]; then
David Bainbridge90fd8e32019-08-21 23:32:47 +00001203 SADIS_CFG=onos-files/onos-sadis-sample.json
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001204 check_onos_app_active org.opencord.sadis
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001205 push_onos_config "file" "[optional] Push ONOS SADIS Configuration" "network/configuration/apps/org.opencord.sadis" "$SADIS_CFG"
David Bainbridge2b19e832019-08-16 02:40:53 +00001206 fi
Test Userba1e7e72019-07-10 22:27:54 +00001207fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001208if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001209 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001210fi
Test Userba1e7e72019-07-10 22:27:54 +00001211
David Bainbridgee87067b2019-08-12 22:00:12 +00001212STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +00001213bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
Test User7d866122019-07-09 17:52:35 +00001214if [ $(helm list --deployed --short --namespace voltha "^voltha\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001215 espin $NOT_VERIFIED
David Bainbridge70c0ea82019-11-14 23:25:26 +00001216 if [ "$ONLY_ONE" == "yes" ]; then
1217 EXTRA_HELM_INSTALL_ARGS="--set therecanbeonlyone=true"=
1218 fi
David Bainbridge90fd8e32019-08-21 23:32:47 +00001219 helm_install - voltha voltha $VOLTHA_CHART $VOLTHA_CHART_VERSION "Install VOLTHA Core"
David Bainbridge70c0ea82019-11-14 23:25:26 +00001220 EXTRA_HELM_INSTALL_ARGS=
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001221else
1222 espin $VERIFIED
1223fi
Test Userba1e7e72019-07-10 22:27:54 +00001224
David Bainbridge90fd8e32019-08-21 23:32:47 +00001225VOLTHA="voltha-ofagent-.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001226 ro-core.* \
1227 rw-core.* \
1228 voltha-api-server-.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001229 voltha-etcd-cluster-.* \
1230 voltha-kafka-.* \
1231 voltha-zookeeper-.*"
David Bainbridge70c0ea82019-11-14 23:25:26 +00001232if [ "$ONLY_ONE" == "yes" ]; then
David Bainbridge1ba64f12019-12-18 00:40:13 +00001233 EXPECT=$(test "$TYPE" == "minimal" && echo "5" || echo "7")
David Bainbridge70c0ea82019-11-14 23:25:26 +00001234else
David Bainbridge1ba64f12019-12-18 00:40:13 +00001235 EXPECT=$(test "$TYPE" == "minimal" && echo "8" || echo "10")
David Bainbridge70c0ea82019-11-14 23:25:26 +00001236fi
David Bainbridge4f1b5562019-08-19 04:46:52 +00001237wait_for_pods - "voltha" $EXPECT "includes" -1 "Waiting for VOLTHA Core to start" $VOLTHA
David Bainbridgee87067b2019-08-12 22:00:12 +00001238if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001239 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001240fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001241
David Bainbridge46505fb2019-10-01 21:13:20 +00001242if [ "$WITH_ADAPTERS" == "yes" ]; then
1243 STIME=$(date +%s)
1244 EXPECT=0
1245 echo -e "Verify Adapters $PLUG"
1246 if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then
1247 bspin - "Verify Simulated Adapters installed"
1248 if [ $(helm list --deployed --short --namespace voltha "^sim\$" | wc -l) -ne 1 ]; then
1249 espin - $NOT_VERIFIED
1250 helm_install - voltha sim $VOLTHA_ADAPTER_SIM_CHART $VOLTHA_ADAPTER_SIM_CHART_VERSION "Install Simulated Adapters"
1251 else
1252 espin - $VERIFIED
1253 fi
1254 EXPECT=$(expr $EXPECT + 2)
1255 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001256
David Bainbridge46505fb2019-10-01 21:13:20 +00001257 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
1258 bspin - "Verify OpenOLT Adapter installed"
1259 if [ $(helm list --deployed --short --namespace voltha "^open-olt\$" | wc -l) -ne 1 ]; then
1260 espin - $NOT_VERIFIED
1261 helm_install - voltha open-olt $VOLTHA_ADAPTER_OPEN_OLT_CHART $VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION "Install OpenOLT Adapter"
1262 else
1263 espin - $VERIFIED
1264 fi
1265 bspin - "Verify OpenONU Adapter installed"
1266 if [ $(helm list --deployed --short --namespace voltha "^open-onu\$" | wc -l) -ne 1 ]; then
1267 espin - $NOT_VERIFIED
1268 helm_install - voltha open-onu $VOLTHA_ADAPTER_OPEN_ONU_CHART $VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION "Install OpenONU Adapter"
1269 else
1270 espin - $VERIFIED
1271 fi
1272 EXPECT=$(expr $EXPECT + 2)
1273 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001274
David Bainbridge46505fb2019-10-01 21:13:20 +00001275 ADAPTERS="adapter-.*"
1276 wait_for_pods - "voltha" $EXPECT "includes" -1 "Waiting for adapters to start" $ADAPTERS
1277 if [ "$WITH_TIMINGS" == "yes" ]; then
1278 printtime $(expr $(date +%s) - $STIME)
1279 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001280fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001281
Test User7d866122019-07-09 17:52:35 +00001282if [ $WITH_BBSIM == "yes" ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +00001283 STIME=$(date +%s)
Test User7d866122019-07-09 17:52:35 +00001284 echo -e "Verify BBSIM $PLUG"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001285 bspin - "Verify BBSIM Installed"
uottrembb16d3982020-02-28 08:34:36 +01001286 for instance in $(seq 0 $(($NUM_OF_BBSIM-1))); do
1287 if [ $instance -eq 0 ]; then
1288 instance_num=""
1289 else
1290 instance_num=$instance
1291 fi
1292 if [ $(helm list --deployed --short --namespace voltha "^bbsim${instance_num}\$" | wc -l) -ne 1 ]; then
1293 espin - $NOT_VERIFIED
1294 helm_install - voltha bbsim${instance_num} $VOLTHA_BBSIM_CHART $VOLTHA_BBSIM_CHART_VERSION "Install BBSIM${instance_num}"
1295 else
1296 espin - $VERIFIED
1297 fi
1298 done
1299 wait_for_pods - "voltha" $NUM_OF_BBSIM "includes" -1 "Waiting for BBSIM to start" "bbsim*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001300 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001301 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001302 fi
Test User7d866122019-07-09 17:52:35 +00001303fi
1304
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001305if [ $WITH_RADIUS == "yes" ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +00001306 STIME=$(date +%s)
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001307 echo -e "Verify RADIUS $LOCK"
1308 bspin - "Verify RADIUS Installed"
1309 if [ $(helm list --deployed --short --namespace voltha "^radius\$" | wc -l) -ne 1 ]; then
1310 espin - $NOT_VERIFIED
David Bainbridge90fd8e32019-08-21 23:32:47 +00001311 helm_install - voltha radius onf/freeradius latest "Install RADIUS"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001312 else
1313 espin - $VERIFIED
1314 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +00001315 wait_for_pods - "voltha" 1 "includes" -1 "Waiting for RADIUS to start" "radius-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001316 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001317 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001318 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001319fi
1320
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001321if [ $WITH_PORT_FORWARDS == "yes" ]; then
1322 STIME=$(date +%s)
1323 bspin - "Forward VOLTHA API port $FORWARD"
1324 kill_port_forward voltha-api
1325 port_forward voltha voltha-api $VOLTHA_API_PORT 55555
1326 espin - $VERIFIED
1327 bspin - "Forward VOLTHA ETCD port $FORWARD"
1328 kill_port_forward voltha-etcd-cluster-client
1329 port_forward voltha voltha-etcd-cluster-client $VOLTHA_ETCD_PORT 2379
1330 espin - $VERIFIED
1331 bspin - "Forward VOLTHA Kafka port $FORWARD"
1332 kill_port_forward voltha-kafka
1333 port_forward voltha voltha-kafka $VOLTHA_KAFKA_PORT 9092
1334 espin - $VERIFIED
1335 if [ "$WITH_TIMINGS" == "yes" ]; then
1336 printtime $(expr $(date +%s) - $STIME)
1337 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001338fi
Test User3d7ad8e2019-07-03 06:15:44 +00001339
David Bainbridgeb270c202019-07-26 01:44:42 +00001340if [ $WITH_ONOS == "yes" -a $WITH_RADIUS == "yes" ]; then
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001341 bspin "Configure ONOS RADIUS Connection $GEAR"
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001342 (set -x; cat onos-files/onos-aaa.json | sed -e "s/:RADIUS_IP:/$(kubectl -n voltha get service/radius -o jsonpath={.spec.clusterIP})/g" | curl --fail -sSL --user karaf:karaf -X POST http://$_ONOS_API_EP/onos/v1/network/configuration/apps/org.opencord.aaa -H Content-type:application/json -d@- >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001343 espin $VERIFIED
1344fi
1345
David Bainbridge99ac7a22019-08-31 02:26:43 +00001346if [ "$WITH_CHAOS" == "yes" ]; then
1347 STIME=$(date +%s)
1348 echo -e "Verify kube-monkey $LOCK"
1349 bspin - "Verify kube-monkey Installed"
1350 if [ $(helm list --deployed --short --namespace kube-monkey "^monkey\$" | wc -l) -ne 1 ]; then
1351 espin - $NOT_VERIFIED
1352 helm_install - kube-monkey monkey ./kube-monkey/helm/kubemonkey latest "Install Chaos Monkey"
1353 else
1354 espin - $VERIFIED
1355 fi
1356 wait_for_pods - "kube-monkey" 1 "includes" -1 "Waiting for Chaos to start" "monkey-.*"
1357 if [ "$WITH_TIMINGS" == "yes" ]; then
1358 printtime $(expr $(date +%s) - $STIME)
1359 fi
1360fi
1361
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001362bspin "Create voltctl configuration file"
Test User3d7ad8e2019-07-03 06:15:44 +00001363(set -x; mkdir -p $HOME/.volt >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001364if [ $WITH_PORT_FORWARDS == "yes" ]; then
1365 (set -x; voltctl -a v3 -k localhost:$VOLTHA_KAFKA_PORT -s localhost:$VOLTHA_API_PORT config > $HOME/.volt/config-$NAME 2>>$LOG) >>$LOG 2>&1
1366else
1367 (set -x; voltctl -a v3 -k $(get_service_ep voltha voltha-kafka) -s $(get_service_ep voltha voltha-api) config > $HOME/.volt/config-$NAME 2>>$LOG) >>$LOG 2>&1
1368fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001369espin $VERIFIED
Test User08ebbd92019-07-03 17:15:39 +00001370
David Bainbridge0774b232019-08-02 06:37:19 +00001371if [ ! -f "$NAME-env.sh" ]; then
1372 touch $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001373fi
1374
David Bainbridge596f30d2019-07-30 17:07:59 +00001375for O in $ALL_OPTIONS; do
1376 VAL=$(eval echo \$$O)
David Bainbridge0774b232019-08-02 06:37:19 +00001377 if [ ! -z "$VAL" -a $(grep -c "^export $O=" $NAME-env.sh) -eq 0 ]; then
1378 echo "export $O=\"$(eval echo \$$O)\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001379 fi
1380done
1381
David Bainbridge0774b232019-08-02 06:37:19 +00001382if [ $DEPLOY_K8S == "yes" -a $(grep -c "^export KUBECONFIG=" $NAME-env.sh) -eq 0 ]; then
1383 echo "export KUBECONFIG=\"$(./bin/kind get kubeconfig-path --name=voltha-$NAME)\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001384fi
1385
David Bainbridge0774b232019-08-02 06:37:19 +00001386if [ $(grep -c "^export VOLTCONFIG=" $NAME-env.sh) -eq 0 ]; then
1387 echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001388fi
1389
David Bainbridge0774b232019-08-02 06:37:19 +00001390if [ $(grep -c "^export PATH=" $NAME-env.sh) -eq 0 ]; then
1391 echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001392fi
1393
Test User7d866122019-07-09 17:52:35 +00001394echo ""
Test User08ebbd92019-07-03 17:15:39 +00001395echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
1396echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
1397echo "tools required by VOLTHA in your command path. " | tee -a $LOG
1398echo "" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +00001399echo -en $BOLD
Test Userba1e7e72019-07-10 22:27:54 +00001400if [ $DEPLOY_K8S == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001401 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +00001402fi
David Bainbridge0774b232019-08-02 06:37:19 +00001403echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +00001404echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +00001405echo -en $NORMAL
Test User08ebbd92019-07-03 17:15:39 +00001406echo "" | tee -a $LOG
1407echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
1408
David Bainbridge712afb82019-08-14 19:55:58 +00001409if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridgef858a022019-08-14 21:25:11 +00001410 echo -e "$CLOCK ${BOLD}TOTAL: $(duration $(expr $(date +%s) - $TOTAL_START_TIME))${NORMAL}"
David Bainbridge712afb82019-08-14 19:55:58 +00001411fi