blob: 9522d3a239104a80cb437c136fd2b10e4ec8e10e [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 Bainbridged049a612020-03-16 17:22:54 -070015set -f
David Bainbridged18f4942020-04-14 16:46:13 -070016unalias -a
17TOTAL_START_TIME="$(date +%s)"
David K. Bainbridgeb7285432019-07-02 22:05:24 -070018
David Bainbridge38dc1e82019-08-12 15:18:45 +000019FANCY=${FANCY:-1}
20if [ "$TERM X" == " X" ]; then
21 FANCY=0
22fi
23
David K. Bainbridgeb7285432019-07-02 22:05:24 -070024# trap ctrl-c and call ctrl_c()
25trap ctrl_c INT
26
27function ctrl_c() {
David Bainbridged18f4942020-04-14 16:46:13 -070028 echo -en "$CNORM"
David K. Bainbridgeb7285432019-07-02 22:05:24 -070029 echo ""
30 echo "ctrl-c trapped"
David Bainbridgec6a6eb62019-10-18 22:50:07 +000031 echo "Thank you for trying 'voltha up'"
David K. Bainbridgeb7285432019-07-02 22:05:24 -070032 exit
33}
34
David Bainbridgea34993d2020-04-01 09:15:42 -070035HELM_VERSION=${HELM_VERSION:-v2.14.3}
David K. Bainbridgeebf38d92020-02-10 10:46:31 -080036VOLTCTL_VERSION=${VOLTCTL_VERSION:-latest}
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -080037KIND_VERSION=${KIND_VERSION:-v0.5.1}
David K. Bainbridgeb3a99372020-01-08 14:39:06 -080038VK_RELEASE=${VK_RELEASE:-master}
Test User08ebbd92019-07-03 17:15:39 +000039
David Bainbridge38dc1e82019-08-12 15:18:45 +000040RED=
41GREEN=
42YELLOW=
43BLUE=
David Bainbridge38dc1e82019-08-12 15:18:45 +000044BOLD=
45NORMAL=
46ERROR=
47CEOL=
48CNORM=
49CIVIS=
David Bainbridged18f4942020-04-14 16:46:13 -070050if [ "$FANCY" -eq 1 ]; then
51 RED="$(tput setaf 1)"
52 GREEN="$(tput setaf 2)"
53 YELLOW="$(tput setaf 3)"
54 BLUE="$(tput setaf 4)"
55 BOLD="$(tput bold)"
56 NORMAL="$(tput sgr0)"
David Bainbridge38dc1e82019-08-12 15:18:45 +000057 ERROR="\xe2\x9c\x97\x20"
David Bainbridged18f4942020-04-14 16:46:13 -070058 CEOL="$(tput el)"
59 CNORM="$(tput cnorm)"
60 CIVIS="$(tput civis)"
David Bainbridge38dc1e82019-08-12 15:18:45 +000061fi
Test User7d866122019-07-09 17:52:35 +000062
Test User3d7ad8e2019-07-03 06:15:44 +000063TYPE=${TYPE:-minimal}
David Bainbridge0774b232019-08-02 06:37:19 +000064NAME=${NAME:-$TYPE}
David K. Bainbridge484d80c2020-03-05 21:44:34 -080065
66ENABLE_ONOS_EXTRANEOUS_RULES=${ENABLE_ONOS_EXTRANEOUS_RULES:-no}
David Bainbridge76afd812020-04-06 09:53:52 -070067INFRA_NS=${INFRA_NS:-default}
68VOLTHA_NS=${VOLTHA_NS:-voltha}
69BBSIM_NS=${BBSIM_NS:-voltha}
70ADAPTER_NS=${ADAPTER_NS:-voltha}
David Bainbridgee87067b2019-08-12 22:00:12 +000071WITH_TIMINGS=${WITH_TIMINGS:-no}
Test User7d866122019-07-09 17:52:35 +000072WITH_BBSIM=${WITH_BBSIM:-no}
David Bainbridge5b7b96b2019-07-25 20:29:13 +000073WITH_RADIUS=${WITH_RADIUS:-no}
Matteo Scandolo78dfee02020-02-13 16:18:03 -080074WITH_EAPOL=${WITH_EAPOL:-yes}
75WITH_DHCP=${WITH_DHCP:-yes}
76WITH_IGMP=${WITH_IGMP:-no}
David Bainbridgeb270c202019-07-26 01:44:42 +000077WITH_ONOS=${WITH_ONOS:-yes}
David Bainbridge99ac7a22019-08-31 02:26:43 +000078WITH_CHAOS=${WITH_CHAOS:-no}
David Bainbridge46505fb2019-10-01 21:13:20 +000079WITH_ADAPTERS=${WITH_ADAPTERS:-yes}
David K. Bainbridgeda33d652020-03-06 10:31:23 -080080WITH_SIM_ADAPTERS=${WITH_SIM_ADAPTERS:-no}
David Bainbridge46505fb2019-10-01 21:13:20 +000081WITH_OPEN_ADAPTERS=${WITH_OPEN_ADAPTERS:-yes}
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -080082WITH_PORT_FORWARDS=${WITH_PORT_FORWARDS:-yes}
David Bainbridge696bc632020-04-05 21:49:37 -070083WITH_KAFKA=${WITH_KAFKA:-yes}
84WITH_ETCD=${WITH_ETCD:-yes}
David Bainbridge05cd8822019-11-19 17:43:53 +000085ONLY_ONE=${ONLY_ONE:-yes}
David K. Bainbridgeb859e912020-03-13 14:07:52 -070086CONFIG_SADIS=${CONFIG_SADIS:-no} # yes | no | file | bbsim | URL
David Bainbridge76afd812020-04-06 09:53:52 -070087SADIS_SUBSCRIBERS=${SADIS_SUBSCRIBERS:-http://bbsim.$VOLTHA_NS.svc:50074/v2/subscribers/%s}
88SADIS_BANDWIDTH_PROFILES=${SADIS_BANDWIDTH_PROFILES:-http://bbsim.$VOLTHA_NS.svc:50074/v2/bandwidthprofiles/%s}
Hardik Windlassb3147602020-03-09 16:59:15 +053089SADIS_CFG=${SADIS_CFG:-onos-files/onos-sadis-sample.json}
David Bainbridge27790d62019-08-13 22:43:19 +000090INSTALL_ONOS_APPS=${INSTALL_ONOS_APPS:-no}
Test Userba1e7e72019-07-10 22:27:54 +000091JUST_K8S=${JUST_K8S:-no}
92DEPLOY_K8S=${DEPLOY_K8S:-yes}
David K. Bainbridge0e89cb92019-07-17 11:30:10 -070093INSTALL_KUBECTL=${INSTALL_KUBECTL:-yes}
94INSTALL_HELM=${INSTALL_HELM:-yes}
David Bainbridge7f8bf992020-04-08 21:53:22 -070095HELM_USE_UPGRADE=${HELM_USE_UPGRADE:-no}
David Bainbridge46505fb2019-10-01 21:13:20 +000096UPDATE_HELM_REPOS=${UPDATE_HELM_REPOS:-yes}
Matteo Scandolofab98622020-01-28 15:17:20 -080097WAIT_ON_DOWN=${WAIT_ON_DOWN:-yes}
David Bainbridge52e6e9d2020-03-23 13:48:27 -070098WAIT_TIMEOUT=${WAIT_TIMEOUT:-30m}
99VOLTHA_DOWN_ON_TIMEOUT=${VOLTHA_DOWN_ON_TIMEOUT:-no}
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000100VOLTHA_LOG_LEVEL=${VOLTHA_LOG_LEVEL:-WARN}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000101VOLTHA_CHART=${VOLTHA_CHART:-onf/voltha}
102VOLTHA_CHART_VERSION=${VOLTHA_CHART_VERSION:-latest}
103VOLTHA_BBSIM_CHART=${VOLTHA_BBSIM_CHART:-onf/bbsim}
Matteo Scandolodcd29f52019-10-07 15:42:42 -0700104VOLTHA_BBSIM_CHART_VERSION=${VOLTHA_BBSIM_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000105VOLTHA_ADAPTER_SIM_CHART=${VOLTHA_ADAPTER_SIM_CHART:-onf/voltha-adapter-simulated}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000106VOLTHA_ADAPTER_SIM_CHART_VERSION=${VOLTHA_ADAPTER_SIM_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000107VOLTHA_ADAPTER_OPEN_OLT_CHART=${VOLTHA_ADAPTER_OPEN_OLT_CHART:-onf/voltha-adapter-openolt}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000108VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION=${VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000109VOLTHA_ADAPTER_OPEN_ONU_CHART=${VOLTHA_ADAPTER_OPEN_ONU_CHART:-onf/voltha-adapter-openonu}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000110VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION=${VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION:-latest}
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800111ONOS_CHART=${ONOS_CHART:-onf/onos}
Andrea Campanella21323292019-12-18 11:44:19 -0800112ONOS_CHART_VERSION=${ONOS_CHART_VERSION:-latest}
David Bainbridgeb9093522020-04-15 14:32:44 -0700113KAFKA_CHART_VERSION=${KAFKA_CHART_VERSION:=0.15.3}
David Bainbridge2eaf2cf2020-03-18 12:54:08 -0700114EXTRA_HELM_INSTALL_ARGS=${EXTRA_HELM_INSTALL_ARGS:-}
115INTERNAL_EXTRA_HELM_INSTALL_ARGS=
uottrembb16d3982020-02-28 08:34:36 +0100116NUM_OF_BBSIM=${NUM_OF_BBSIM:-1}
Matteo Scandolo67335f02020-04-09 11:19:53 -0700117NUM_OF_OPENONU=${NUM_OF_OPENONU:-1}
uottrembb16d3982020-02-28 08:34:36 +0100118MAX_NUM_OF_BBSIM=10
Matteo Scandolo67335f02020-04-09 11:19:53 -0700119MAX_NUM_OF_OPENONU=10
Test Userba1e7e72019-07-10 22:27:54 +0000120
David Bainbridged18f4942020-04-14 16:46:13 -0700121HOSTOS="$(uname -s | tr "[:upper:]" "[:lower:"])"
122HOSTARCH="$(uname -m | tr "[:upper:]" "[:lower:"])"
123if [ "$HOSTARCH" == "x86_64" ]; then
Test Userba1e7e72019-07-10 22:27:54 +0000124 HOSTARCH="amd64"
125fi
David Bainbridge7db44002020-04-09 12:54:29 -0700126BBSIM_LABEL="-l app=bbsim"
David Bainbridged18f4942020-04-14 16:46:13 -0700127NO_LABEL=
Test User7d866122019-07-09 17:52:35 +0000128
uottrembb16d3982020-02-28 08:34:36 +0100129# check number (range) of bbsim, max bbsim must not exceed 10 instances!
130# note: instances will be numbered from 0 to 9
131if [ "$1" == "up" ]; then
David K. Bainbridge43422402020-03-06 07:41:22 -0800132 if [ "$NUM_OF_BBSIM" -lt 1 ]; then
Matteo Scandolo67335f02020-04-09 11:19:53 -0700133 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid setting of BBSIM instances. NUM_OF_BBSIM (${NUM_OF_BBSIM}) is less than 1${NORMAL}"
David K. Bainbridge43422402020-03-06 07:41:22 -0800134 exit 1
135 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700136 if [ "$NUM_OF_BBSIM" -gt "$MAX_NUM_OF_BBSIM" ]; then
Matteo Scandolo67335f02020-04-09 11:19:53 -0700137 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid setting of BBSIM instances. NUM_OF_BBSIM (${NUM_OF_BBSIM}) is greater than $MAX_NUM_OF_BBSIM${NORMAL}"
138 exit 1
139 fi
140
141 if [ "$NUM_OF_OPENONU" -lt 1 ]; then
142 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid setting of OPENONU instances. NUM_OF_OPENONU (${NUM_OF_OPENONU}) is less than 1${NORMAL}"
143 exit 1
144 fi
145 if [ "$NUM_OF_OPENONU" -gt "$MAX_NUM_OF_OPENONU" ]; then
146 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid setting of OPENONU instances. NUM_OF_OPENONU (${NUM_OF_OPENONU}) is greater than $MAX_NUM_OF_OPENONU${NORMAL}"
David K. Bainbridge43422402020-03-06 07:41:22 -0800147 exit 1
148 fi
uottrembb16d3982020-02-28 08:34:36 +0100149fi
Test User7d866122019-07-09 17:52:35 +0000150# Verify TYPE setting
David Bainbridged18f4942020-04-14 16:46:13 -0700151if [ "$(echo ":minimal:full:" | grep -ic ":$TYPE:")" -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700152 >&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 +0000153 exit 1
154fi
155
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700156function parseDuration() {
David Bainbridged18f4942020-04-14 16:46:13 -0700157 local DUR RESULT TERM TERMS VALUE UNIT
158 DUR=$1
159 RESULT=0
160 TERMS="$(echo "$DUR" | sed -Ee 's/([sSmMhHdD])/\1 /g' -e 's/,$//g')"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700161 for TERM in $TERMS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700162 VALUE="$(echo "$TERM" | sed -Ee 's/([0-9]+)[sSmMhHdD]/\1/')"
163 UNIT="$(echo "$TERM" | sed -Ee 's/[0-9]+([sSmMhHdD])/\1/')"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700164 case $UNIT in
165 s|S)
David Bainbridged18f4942020-04-14 16:46:13 -0700166 RESULT=$((RESULT + VALUE)) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700167 m|M)
David Bainbridged18f4942020-04-14 16:46:13 -0700168 RESULT=$((RESULT + (VALUE * 60))) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700169 h|H)
David Bainbridged18f4942020-04-14 16:46:13 -0700170 RESULT=$((RESULT + (VALUE * 3600))) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700171 d|D)
David Bainbridged18f4942020-04-14 16:46:13 -0700172 RESULT=$((RESULT + (VALUE * 86400))) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700173 *) ;;
174 esac
175 done
176 echo $RESULT
177}
178
179function doTimeout() {
180 local MSG=$1
181 2>&1 echo -e "\n${RED}${BOLD}${ERROR}TIMEOUT:${NORMAL}${RED} Operation timed out after '$WAIT_TIMEOUT': $MSG"
182 exit 125
183}
184
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800185function get_service_ep() {
186 local NS=$1
187 local NAME=$2
David Bainbridged18f4942020-04-14 16:46:13 -0700188 kubectl -n "$NS" get service "$NAME" -o json | jq -r '.spec.clusterIP + ":" + (.spec.ports[0].port|tostring)'
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800189}
190
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000191# Used to verify configuration values are set to "yes" or "no" value or convert
192# equivalents to "yes" or "no"
193function verify_yes_no() {
David Bainbridged18f4942020-04-14 16:46:13 -0700194 local VAR VAL
195 VAR=$1
196 VAL="$(eval echo "\$$VAR")"
197 if [ "$(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$VAL:")" -eq 0 ]; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000198 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid '$VAR' value of '$VAL'. Should be 'yes' or 'no'${NORMAL}"
199 echo "INVALID"
200 return 1
201 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700202 if [ "$(echo ":y:yes:true:1:" | grep -ic ":$VAL:")" -eq 1 ]; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000203 echo "yes"
204 else
205 echo "no"
206 fi
207 return 0
208}
Test User7d866122019-07-09 17:52:35 +0000209
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000210ALL_YES_NO="\
David K. Bainbridge484d80c2020-03-05 21:44:34 -0800211 ENABLE_ONOS_EXTRANEOUS_RULES \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000212 WITH_TIMINGS \
213 WITH_BBSIM \
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800214 WITH_EAPOL \
215 WITH_DHCP \
216 WITH_IGMP \
David Bainbridge99ac7a22019-08-31 02:26:43 +0000217 WITH_CHAOS \
David Bainbridge46505fb2019-10-01 21:13:20 +0000218 WITH_ADAPTERS \
219 WITH_SIM_ADAPTERS \
220 WITH_OPEN_ADAPTERS \
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800221 WITH_PORT_FORWARDS \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000222 JUST_K8S \
223 DEPLOY_K8S \
224 INSTALL_ONOS_APPS \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000225 INSTALL_KUBECTL \
226 INSTALL_HELM \
David Bainbridge7f8bf992020-04-08 21:53:22 -0700227 HELM_USE_UPGRADE \
David Bainbridge46505fb2019-10-01 21:13:20 +0000228 UPDATE_HELM_REPOS \
David Bainbridge4f1b5562019-08-19 04:46:52 +0000229 WAIT_ON_DOWN \
David Bainbridge70c0ea82019-11-14 23:25:26 +0000230 ONLY_ONE \
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700231 VOLTHA_DOWN_ON_TIMEOUT \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000232 "
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000233
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000234ALL_OPTIONS="\
235 NAME \
236 TYPE \
237 $ALL_YES_NO \
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700238 WAIT_TIMEOUT \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000239 VOLTHA_LOG_LEVEL \
240 VOLTHA_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000241 VOLTHA_CHART_VERSION \
242 VOLTHA_BBSIM_CHART \
243 VOLTHA_BBSIM_CHART_VERSION \
uottrembd5a20572020-03-06 09:15:01 +0100244 NUM_OF_BBSIM \
Matteo Scandolo67335f02020-04-09 11:19:53 -0700245 NUM_OF_OPENONU \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000246 VOLTHA_ADAPTER_SIM_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000247 VOLTHA_ADAPTER_SIM_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000248 VOLTHA_ADAPTER_OPEN_OLT_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000249 VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000250 VOLTHA_ADAPTER_OPEN_ONU_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000251 VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION \
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800252 ONOS_CHART \
Andrea Campanella21323292019-12-18 11:44:19 -0800253 ONOS_CHART_VERSION \
David Bainbridgeb9093522020-04-15 14:32:44 -0700254 KAFKA_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000255 ONOS_API_PORT \
256 ONOS_SSH_PORT \
David K. Bainbridgeb859e912020-03-13 14:07:52 -0700257 CONFIG_SADIS \
Hardik Windlassb3147602020-03-09 16:59:15 +0530258 SADIS_CFG \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000259 VOLTHA_API_PORT \
260 VOLTHA_SSH_PORT \
261 VOLTHA_ETCD_PORT \
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800262 VOLTHA_KAFKA_PORT \
David K. Bainbridge8f7f30b2020-01-08 13:06:16 -0800263 VK_RELEASE \
264 KIND_VERSION \
265 VOLTCTL_VERSION \
David Bainbridgea34993d2020-04-01 09:15:42 -0700266 HELM_VERSION \
David Bainbridge696bc632020-04-05 21:49:37 -0700267 WITH_RADIUS \
268 WITH_KAFKA \
269 WITH_ETCD \
David Bainbridge76afd812020-04-06 09:53:52 -0700270 WITH_ONOS \
David Bainbridge6ca40102020-04-08 11:30:40 -0700271 VOLTHA_NS \
272 ADAPTER_NS \
273 INFRA_NS \
274 BBSIM_NS \
David Bainbridge7db44002020-04-09 12:54:29 -0700275 SADIS_BANDWIDTH_PROFILES \
276 SADIS_SUBSCRIBERS \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000277 "
David Bainbridge01294952019-07-30 19:33:45 +0000278
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000279# Iterate over yes/no configuration options and validate
280for VAR in $ALL_YES_NO; do
David Bainbridged18f4942020-04-14 16:46:13 -0700281 eval "$VAR"="$(verify_yes_no "$VAR")"
282 if [ "$(eval echo "\$$VAR")" == "INVALID" ]; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000283 exit 1;
284 fi
285done
David Bainbridgeb270c202019-07-26 01:44:42 +0000286
David Bainbridge15f6f232020-03-30 09:15:43 -0700287# Special case for CONFIG_SADIS
David Bainbridged18f4942020-04-14 16:46:13 -0700288if [ "$(echo ":y:yes:true:1:" | grep -ic ":$CONFIG_SADIS:")" -eq 1 ]; then
David Bainbridge15f6f232020-03-30 09:15:43 -0700289 CONFIG_SADIS="yes"
290fi
David Bainbridged18f4942020-04-14 16:46:13 -0700291if [ "$(echo ":n:no:false:0:" | grep -ic ":$CONFIG_SADIS:")" -eq 1 ]; then
David Bainbridge15f6f232020-03-30 09:15:43 -0700292 CONFIG_SADIS="no"
293fi
294
David Bainbridge76afd812020-04-06 09:53:52 -0700295# Special case for WITH_ONOS, WITH_RADIUS, WITH_KAFKA, and WITH_ETCD
David Bainbridged18f4942020-04-14 16:46:13 -0700296if [ "$(echo ":y:yes:true:1:" | grep -ic ":$WITH_KAFKA:")" -eq 1 ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700297 WITH_KAFKA="yes"
298fi
David Bainbridged18f4942020-04-14 16:46:13 -0700299if [ "$(echo ":n:no:false:0:" | grep -ic ":$WITH_KAFKA:")" -eq 1 ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700300 WITH_KAFKA="no"
301fi
David Bainbridged18f4942020-04-14 16:46:13 -0700302if [ "$(echo ":external:" | grep -ic ":$WITH_KAFKA:")" -eq 1 ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700303 WITH_KAFKA="external"
304fi
David Bainbridged18f4942020-04-14 16:46:13 -0700305if [ "$(echo ":y:yes:true:1:" | grep -ic ":$WITH_ETCD:")" -eq 1 ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700306 WITH_ETCD="yes"
307fi
David Bainbridged18f4942020-04-14 16:46:13 -0700308if [ "$(echo ":n:no:false:0:" | grep -ic ":$WITH_ETCD:")" -eq 1 ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700309 WITH_ETCD="no"
310fi
David Bainbridged18f4942020-04-14 16:46:13 -0700311if [ "$(echo ":external:" | grep -ic ":$WITH_ETCD:")" -eq 1 ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700312 WITH_ETCD="external"
313fi
David Bainbridged18f4942020-04-14 16:46:13 -0700314if [ "$(echo ":y:yes:true:1:" | grep -ic ":$WITH_RADIUS:")" -eq 1 ]; then
David Bainbridge29c31cb2020-04-06 09:45:50 -0700315 WITH_RADIUS="yes"
316fi
David Bainbridged18f4942020-04-14 16:46:13 -0700317if [ "$(echo ":n:no:false:0:" | grep -ic ":$WITH_RADIUS:")" -eq 1 ]; then
David Bainbridge29c31cb2020-04-06 09:45:50 -0700318 WITH_RADIUS="no"
319fi
David Bainbridged18f4942020-04-14 16:46:13 -0700320if [ "$(echo ":y:yes:true:1:" | grep -ic ":$WITH_ONOS:")" -eq 1 ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700321 WITH_ONOS="yes"
322fi
David Bainbridged18f4942020-04-14 16:46:13 -0700323if [ "$(echo ":n:no:false:0:" | grep -ic ":$WITH_ONOS:")" -eq 1 ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700324 WITH_ONOS="no"
325fi
David Bainbridge696bc632020-04-05 21:49:37 -0700326
David Bainbridged18f4942020-04-14 16:46:13 -0700327if [ "$HELM_USE_UPGRADE" == "yes" ]; then
David Bainbridge7f8bf992020-04-08 21:53:22 -0700328 _HELM_DESC="Upgrade/Install"
329else
330 _HELM_DESC="Install"
331fi
332
David Bainbridged18f4942020-04-14 16:46:13 -0700333ETCD_PREFIX=
334KAFKA_PREFIX=
335if [ "$WITH_ETCD" == "yes" ]; then
336 ETCD_PREFIX="voltha-"
337fi
338if [ "$WITH_KAFKA" == "yes" ]; then
339 KAFKA_PREFIX="voltha-"
340fi
341
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800342# Check for prerequiste tools
David K. Bainbridge726ff6a2020-03-06 11:09:50 -0800343TOOLS="curl sed jq"
David Bainbridged18f4942020-04-14 16:46:13 -0700344if [ "$DEPLOY_K8S" == "yes" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800345 TOOLS+=" docker"
346fi
347NOT_FOUND=""
348for T in $TOOLS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700349 if [ -z "$(command -v "$T")" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800350 NOT_FOUND+=" $T"
351 fi
352done
353
David Bainbridged18f4942020-04-14 16:46:13 -0700354if [ -n "$NOT_FOUND" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800355 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} The following required tools where not found, please install them:$NOT_FOUND"
356 exit 1
357fi
358
David Bainbridged18f4942020-04-14 16:46:13 -0700359TIMEOUT_SECONDS="$(parseDuration "$WAIT_TIMEOUT")"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700360
David Bainbridge0774b232019-08-02 06:37:19 +0000361mkdir -p .voltha
362touch .voltha/ports
David Bainbridged18f4942020-04-14 16:46:13 -0700363HAVE="$(grep "$NAME" .voltha/ports)"
David Bainbridge0774b232019-08-02 06:37:19 +0000364if [ "$HAVE X" == " X" ]; then
365 # Find free port prefix
366 START=81
367 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700368 if [ "$(grep -c $START .voltha/ports)" -eq 0 ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000369 break
370 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700371 START="$((START + 1))"
David Bainbridge0774b232019-08-02 06:37:19 +0000372 done
David Bainbridged18f4942020-04-14 16:46:13 -0700373 DELTA="$((START - 81))"
David Bainbridgea2595422019-10-22 03:54:28 +0000374 ONOS_API_PORT=${ONOS_API_PORT:-${START}81}
375 ONOS_SSH_PORT=${ONOS_SSH_PORT:-${START}01}
David Bainbridged18f4942020-04-14 16:46:13 -0700376 VOLTHA_API_PORT=${VOLTHA_API_PORT:-5$((55 + DELTA))55}
377 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$((50 + DELTA))22}
378 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$((23 + DELTA))79}
379 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$((90 + DELTA))92}
Test User01ed0642019-07-03 20:17:06 +0000380else
David Bainbridged18f4942020-04-14 16:46:13 -0700381 VALUES="$(echo "$HAVE" | sed -e 's/\s//g' | cut -d= -f2)"
382 ONOS_API_PORT=${ONOS_API_PORT:-$(echo "$VALUES" | cut -d, -f1)}
383 ONOS_SSH_PORT=${ONOS_SSH_PORT:-$(echo "$VALUES" | cut -d, -f2)}
384 VOLTHA_API_PORT=${VOLTHA_API_PORT:-$(echo "$VALUES" | cut -d, -f3)}
385 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$(echo "$VALUES" | cut -d, -f4)}
386 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$(echo "$VALUES" | cut -d, -f5)}
387 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(echo "$VALUES" | cut -d, -f6)}
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800388
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800389 # A bit of a hueristic required here as the KAFKA port forward was
390 # added after the .voltha/ports files was created. Basically, if
391 # the VOLTHA_KAFKA_PORT isn't in the file then calculate the original
392 # DELTA from the VOLTHA_SSH_PORT and apply it to the VOLTHA_KAFKA_PORT
393 if [ -z "$VOLTHA_KAFKA_PORT" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -0700394 DELTA="$((VOLTHA_SSH_PORT/100-50))"
395 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$((90 + DELTA))92}
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800396 fi
Test User01ed0642019-07-03 20:17:06 +0000397fi
398
David Bainbridged18f4942020-04-14 16:46:13 -0700399PORTTMP="$(mktemp -u)"
400grep -v "$NAME" .voltha/ports > "$PORTTMP"
401echo "$NAME=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT,$VOLTHA_KAFKA_PORT" >> "$PORTTMP"
402cp "$PORTTMP" .voltha/ports
403rm -f "$PORTTMP"
David Bainbridge0774b232019-08-02 06:37:19 +0000404
David Bainbridge27790d62019-08-13 22:43:19 +0000405export ONOS_API_PORT ONOS_SSH_PORT
David Bainbridge01294952019-07-30 19:33:45 +0000406
Test Userd87942b2019-07-03 07:20:24 +0000407IDX=1
David Bainbridgee87067b2019-08-12 22:00:12 +0000408CLOCK="TIME:"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000409SPIN_PARTS=
410NOT_VERIFIED=
David Bainbridgef858a022019-08-14 21:25:11 +0000411THEX=
412BUILD=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000413VERIFIED=
414HELM=
415OLD_KEY=
416BIRD=
417HIGH_VOLTAGE=
418PLUG=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000419FORWARD=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000420GO=
421DOWNLOAD=
422GEAR=
423NO_ENTRY=
424LOCK=
425
David Bainbridged18f4942020-04-14 16:46:13 -0700426if [ "$FANCY" -eq 1 ]; then
427 SPIN_PARTS="\xe2\xa2\x8e\xe2\xa1\xb0 \xe2\xa2\x8e\xe2\xa1\xa1 \xe2\xa2\x8e\xe2\xa1\x91 \xe2\xa2\x8e\xe2\xa0\xb1 \xe2\xa0\x8e\xe2\xa1\xb1 \xe2\xa2\x8a\xe2\xa1\xb1 \xe2\xa2\x8c\xe2\xa1\xb1 \xe2\xa2\x86\xe2\xa1\xb1"
David Bainbridgee87067b2019-08-12 22:00:12 +0000428 CLOCK="\xe2\x8f\xb1"
David Bainbridgef858a022019-08-14 21:25:11 +0000429 THEX="${RED}${BOLD}\xe2\x9c\x97\x20${NORMAL}"
David Bainbridgef858a022019-08-14 21:25:11 +0000430 BUILD="${YELLOW}${BOLD}\xf0\x9f\x8f\x97${NORMAL}"
431 NOT_VERIFIED="$BUILD"
432 VERIFIED="${GREEN}${BOLD}\xe2\x9c\x93\x20${NORMAL}"
433 HELM="${BLUE}${BOLD}\xE2\x8E\x88${NORMAL}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000434 OLD_KEY="\xF0\x9F\x97\x9D"
435 BIRD="\xF0\x9F\x90\xA6"
436 HIGH_VOLTAGE="\xE2\x9A\xA1"
437 PLUG="\xF0\x9F\xa7\xa9"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000438 FORWARD="\xE2\x87\xA8"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000439 GO="\xf0\x9f\x9a\x80"
440 DOWNLOAD="\xf0\x9f\x93\xa5"
441 GEAR="\xe2\x9a\x99"
442 NO_ENTRY="\xe2\x9b\x94"
443 LOCK="\xf0\x9f\x94\x92"
444fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700445
David Bainbridge712afb82019-08-14 19:55:58 +0000446duration() {
David Bainbridged18f4942020-04-14 16:46:13 -0700447 local h m s t
448 h="$(($1 / 3600))"
449 m="$(($1 % 3600 / 60))"
450 s="$(($1 % 60))"
451 t=""
David Bainbridgee87067b2019-08-12 22:00:12 +0000452
David Bainbridged18f4942020-04-14 16:46:13 -0700453 if [ "$h" -gt 0 ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +0000454 t="$t${h}h"
455 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700456 if [ "$m" -gt 0 ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +0000457 t="$t${m}m"
458 fi
David Bainbridge712afb82019-08-14 19:55:58 +0000459 echo "$t${s}s"
460}
461
462printtime() {
David Bainbridged18f4942020-04-14 16:46:13 -0700463 local INDENT
David Bainbridge712afb82019-08-14 19:55:58 +0000464 if [ "$1" == "-" ]; then
465 INDENT=" "
466 shift
467 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700468 echo -e "$INDENT $CLOCK $(duration "$1")"
David Bainbridgee87067b2019-08-12 22:00:12 +0000469}
470
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700471bspin() {
Test Userd87942b2019-07-03 07:20:24 +0000472 IDX=1
David Bainbridged18f4942020-04-14 16:46:13 -0700473 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700474 if [ "$1" == "-" ]; then
475 INDENT=" "
476 shift
477 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700478 if [ "$FANCY" -eq 0 ]; then
479 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000480 if [ "$LINE X" == " X" ]; then
481 return
482 fi
483 echo -e "$CIVIS$INDENT$*"
484 else
485 echo -en "$CIVIS$INDENT $*"
486 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700487}
488
489sspin() {
David Bainbridged18f4942020-04-14 16:46:13 -0700490 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700491 if [ "$1" == "-" ]; then
492 INDENT=" "
493 shift
494 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700495 if [ "$FANCY" -eq 0 ]; then
496 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000497 if [ "$LINE X" == " X" ]; then
498 return
499 fi
500 echo -e "$INDENT$*"
501 else
David Bainbridged18f4942020-04-14 16:46:13 -0700502 C="$(echo "$SPIN_PARTS" | cut '-d ' -f "$IDX")"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000503 echo -en "\r$INDENT$C $*"
David Bainbridged18f4942020-04-14 16:46:13 -0700504 IDX="$((IDX + 1))"
505 if [ "$IDX" -gt 8 ]; then
David Bainbridge38dc1e82019-08-12 15:18:45 +0000506 IDX=1
507 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700508 fi
509}
510
511espin() {
David Bainbridged18f4942020-04-14 16:46:13 -0700512 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700513 if [ "$1" == "-" ]; then
514 INDENT=" "
515 shift
516 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700517 if [ "$FANCY" -eq 0 ]; then
518 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000519 if [ "$LINE X" == " X" ]; then
520 return
521 fi
522 echo -e "$INDENT$*"
523 else
524 echo -e "\r$INDENT$*$CNORM"
525 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700526}
527
David Bainbridged18f4942020-04-14 16:46:13 -0700528if [ "$1" == "get" ] && [ "$2" == "voltconfig" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000529 echo "$HOME/.volt/config-$NAME"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000530 exit
531fi
532
David Bainbridged18f4942020-04-14 16:46:13 -0700533if [ $# -ne 1 ] || [ "$(echo ":up:down:dump:" | grep -c ":$1:")" -ne 1 ]; then
David Bainbridgeac7f8072019-08-01 22:15:33 +0000534 >&2 echo "What wouild you like to do today:"
535 >&2 echo " up - bring up voltha"
536 >&2 echo " down - tear down voltha"
537 >&2 echo " dump - create a debug dump of running system"
538 exit 1
539fi
540
David Bainbridge4f1b5562019-08-19 04:46:52 +0000541push_onos_config() {
David Bainbridged18f4942020-04-14 16:46:13 -0700542 local TYPE MSG RESOURCE DATA CMD_ECHO CMD_OUTPUT SC_OUTPUT WAIT_START NOW
543 TYPE=$1
544 MSG=$2
545 RESOURCE=$3
546 DATA=$4
David Bainbridge4f1b5562019-08-19 04:46:52 +0000547
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800548 # Thanks to the latest version of ONOS using the return code 207 this gets a
549 # whole lot nastier. Can't thank them enough for doing this. So in order to
550 # capture the command and the output in the log file as well as capture the
551 # status code to verify it is 200 and not 207 mutltiple files and a bit of
552 # hackery must be used. Thanks again ONOS.
David Bainbridged18f4942020-04-14 16:46:13 -0700553 CMD_ECHO="$(mktemp -u)"
554 CMD_OUTPUT="$(mktemp -u)"
555 SC_OUTPUT="$(mktemp -u)"
556 WAIT_START="$(date +%s)"
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800557
David Bainbridge4f1b5562019-08-19 04:46:52 +0000558 bspin - "$MSG $GEAR"
559 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700560 NOW="$(date +%s)"
561 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700562 espin - "$THEX"
David Bainbridged18f4942020-04-14 16:46:13 -0700563 rm -f "$CMD_ECHO" "$CMD_OUTPUT" "$SC_OUTPUT"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700564 doTimeout "waiting for ONOS config push on $RESOURCE"
565 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700566 if [ "$TYPE" == "file" ]; then
567 (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
David K. Bainbridgeb859e912020-03-13 14:07:52 -0700568 RESULT=$?
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800569 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700570 if [ "$TYPE" == "json" ]; then
571 (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
David K. Bainbridgeb859e912020-03-13 14:07:52 -0700572 RESULT=$?
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800573 fi
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800574 # Dump everything to the log
David Bainbridged18f4942020-04-14 16:46:13 -0700575 cat "$CMD_ECHO" >> "$LOG"
576 test -r "$CMD_OUTPUT" && cat "$CMD_OUTPUT" >> "$LOG"
577 SC="$(cat "$SC_OUTPUT")"
578 echo "RESPONSE CODE: $SC" >> "$LOG"
579 echo "ERROR CODE: $RESULT" >> "$LOG"
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800580
581 # clean up temp files
David Bainbridged18f4942020-04-14 16:46:13 -0700582 rm -f "$CMD_ECHO" "$CMD_OUTPUT" "$SC_OUTPUT"
583 if [ "$RESULT" -eq 0 ] && [ "$SC" == "200" ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000584 break
585 fi
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800586 sleep 1
David Bainbridge4f1b5562019-08-19 04:46:52 +0000587 sspin -
588 done
David Bainbridged18f4942020-04-14 16:46:13 -0700589 espin - "$VERIFIED"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000590}
591
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800592check_onos_app_active() {
David Bainbridged18f4942020-04-14 16:46:13 -0700593 local APP_ID WAIT_START RESULT NOW
594 APP_ID=$1
595 WAIT_START="$(date +%s)"
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800596
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700597 bspin - "Checking that $APP_ID is active $CLOCK"
598 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700599 NOW="$(date +%s)"
600 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700601 espin - "$THEX"
602 doTimeout "waiting for ONOS application activation '$APP_ID'"
603 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700604 if (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; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700605 break
606 fi
607 sleep 1
608 sspin -
609 done
610 sleep 5 # OSGI components take a little longer that the app to activate
David Bainbridged18f4942020-04-14 16:46:13 -0700611 espin - "$VERIFIED"
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800612}
613
David Bainbridge4f1b5562019-08-19 04:46:52 +0000614override_onos_app() {
David Bainbridged18f4942020-04-14 16:46:13 -0700615 local APP NAME WAIT_START NOW
616 APP=$1
617 NAME="$(basename "$APP" | sed -e 's/^[0-9][0-9]*-//g' -e 's/-.*$//g')"
618 WAIT_START="$(date +%s)"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700619
David Bainbridge4f1b5562019-08-19 04:46:52 +0000620 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700621 NOW="$(date +%s)"
622 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700623 espin - "$THEX"
624 doTimeout "waiting to overwrite ONOS application '$APP'"
625 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +0000626 sspin -
627 # Attempt to delete old version (if it exists)
David Bainbridged18f4942020-04-14 16:46:13 -0700628 (set -x; curl --fail -sSL --user karaf:karaf -X DELETE "http://$_ONOS_API_EP/onos/v1/applications/$NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
629 RESULT=$?
David Bainbridge4f1b5562019-08-19 04:46:52 +0000630 sspin -
David Bainbridged18f4942020-04-14 16:46:13 -0700631 if [ $RESULT -ne 0 ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000632 continue
633 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700634 if (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; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000635 break
636 fi
637 sleep .2
638 done
639}
640
641activate_onos_app() {
David Bainbridged18f4942020-04-14 16:46:13 -0700642 local MSG APP WAIT_START NOW
643 MSG="$1"
644 APP=$2
645 WAIT_START="$(date +%s)"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000646
647 bspin - "$MSG $GO"
648 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700649 NOW="$(date +%s)"
650 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700651 espin - "$THEX"
652 doTimeout "waiting to activate ONOS application '$APP'"
653 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +0000654 sspin -
David Bainbridged18f4942020-04-14 16:46:13 -0700655 if (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; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000656 break
657 fi
658 sleep .2
659 done
660 espin - "$VERIFIED"
661}
662
663count_pods() {
David Bainbridged18f4942020-04-14 16:46:13 -0700664 local NAMESPACE STATES LABELS CMD PODS
665 NAMESPACE=$1; shift
David Bainbridge4f1b5562019-08-19 04:46:52 +0000666 if [ "$NAMESPACE" == "all-namespaces" ]; then
667 NAMESPACE="--all-namespaces"
668 else
669 NAMESPACE="-n $NAMESPACE"
670 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700671 STATES=$1; shift
672 LABELS=$1; shift
673 CMD=("kubectl get $NAMESPACE $LABELS pod")
674 PODS=$(${CMD[*]} -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}")
David Bainbridge4f1b5562019-08-19 04:46:52 +0000675 local COUNT=0
676 local PATTERNS="$*"
677 for POD in $PODS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700678 local NAME STATE CONTAINERS TOTAL FOUND
679 NAME="$(echo "$POD" | cut -d/ -f 1)"
680 STATE="$(echo "$POD" | cut -d/ -f 2)"
681 CONTAINERS="$(echo "$POD" | cut -d/ -f 3 | sed -e 's/_/ /g')"
682 if [ "$STATES" == "*" ] || [ "$(echo "$STATES" | grep -c ":$STATE:")" -ne 0 ]; then
683 TOTAL="$(echo "$CONTAINERS" | wc -w)"
684 FOUND="$(echo "$CONTAINERS" | grep -o true | wc -l)"
685 if [ "$TOTAL" -eq "$FOUND" ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000686 for PATTERN in $PATTERNS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700687 if [[ "$NAME" =~ $PATTERN ]]; then
688 COUNT="$((COUNT + 1))"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000689 break
690 fi
691 done
692 fi
693 fi
694 done
David Bainbridge4f1b5562019-08-19 04:46:52 +0000695 echo $COUNT
696}
697
698wait_for_pods() {
David Bainbridged18f4942020-04-14 16:46:13 -0700699 local INDENT NAMESPACE EXPECT TYPE MESSAGE LABELS PATTERNS STATES HAVE ALL WAIT_START NOW
David Bainbridge4f1b5562019-08-19 04:46:52 +0000700 if [ "$1" == "-" ]; then
701 INDENT=$1; shift
702 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700703 NAMESPACE=$1; shift
704 EXPECT=$1; shift
705 TYPE=$1; shift
706 MESSAGE=$1; shift
707 LABELS=$1; shift
708 PATTERNS=("$*")
709 STATES=":Running:"
David Bainbridge99ac7a22019-08-31 02:26:43 +0000710 if [ "$TYPE" == "not" ]; then
711 STATES="*"
712 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700713 HAVE="$(count_pods "$NAMESPACE" "$STATES" "$LABELS" "${PATTERNS[@]}")"
714 ALL=$HAVE
David Bainbridge4f1b5562019-08-19 04:46:52 +0000715 if [ "$TYPE" == "only" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -0700716 ALL="$(count_pods "all-namespaces" "*" ".*")"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000717 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700718 COUNT="$((300 / 15))"
719 WAIT_START="$(date +%s)"
720 bspin "$INDENT" "$MESSAGE"
721 sspin "$INDENT"
722 if [ "$HAVE" -ne "$EXPECT" ] || [ "$ALL" -ne "$HAVE" ]; then
723 while [ "$HAVE" -ne "$EXPECT" ] || [ "$ALL" -ne "$HAVE" ]; do
724 NOW="$(date +%s)"
725 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
726 espin "$INDENT" "$THEX"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700727 doTimeout "waiting for PODs to start"
728 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700729 sspin "$INDENT"
730 COUNT="$((COUNT - 1))"
731 if [ "$COUNT" -eq 0 ]; then
732 HAVE="$(count_pods "$NAMESPACE" "$STATES" "$LABELS" "${PATTERNS[@]}")"
733 ALL="$HAVE"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000734 if [ "$TYPE" == "only" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -0700735 ALL="$(count_pods "all-namespaces" "*" ".*")"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000736 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700737 COUNT="$((300 / 15))"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000738 fi
739 sleep .15
740 done
741 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700742 espin "$INDENT" "$VERIFIED"
743 if [ "$HAVE" -ne "$EXPECT" ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000744 return 1
745 fi
746 return 0
747}
748
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800749port_forward() {
750 local NS=$1
751 local SVC=$2
752 local FROM_PORT=$3
753 local TO_PORT=$4
754 local TAG=$SVC-$NAME
755
David Bainbridged18f4942020-04-14 16:46:13 -0700756 (set -x; _TAG="$TAG" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n $NS service/$SVC $FROM_PORT:$TO_PORT; done" >>"$LOG" 2>&1 &) >>"$LOG" 2>&1
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800757}
758
759kill_port_forward() {
David Bainbridged18f4942020-04-14 16:46:13 -0700760 local TAG P_IDS PARENTS KIDS UNKNOWN PP_ID
761 TAG="$1-$NAME"
762 # shellcheck disable=SC2009
763 P_IDS="$(ps e -ww -A | grep "_TAG=$TAG" | grep -v grep | awk '{print $1}')"
764 if [ -n "$P_IDS" ]; then
David Bainbridgec6871d22019-11-13 17:10:31 +0000765 for P_ID in $P_IDS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700766 PP_ID="$(ps -o ppid "$P_ID" | tail -n +2)"
767 if [ -n "$PP_ID" ]; then
768 if [ "$PP_ID" -eq 1 ]; then
David Bainbridgec6871d22019-11-13 17:10:31 +0000769 PARENTS="$PARENTS $P_ID"
770 else
771 KIDS="$KIDS $P_ID"
772 fi
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800773 else
David Bainbridgec6871d22019-11-13 17:10:31 +0000774 UNKNOWN="$UNKNOWN $P_ID"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800775 fi
776 done
David Bainbridged18f4942020-04-14 16:46:13 -0700777 (set -x; kill -9 "$PARENTS" "$KIDS" "$UNKNOWN" >>"$LOG" 2>&1) >>"$LOG" 2>&1
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800778 fi
779}
780
Jonathan Hart6a91e6c2020-04-16 14:28:33 -0700781# Compares two semver-formatted version strings (e.g. 2.4.3)
782# Returns 0 if $1 == $2, returns 1 if $1 > $2 and returns 2 if $1 < $2
783compare_versions() {
784 [ "$1" == "$2" ] && return 0
785 [ "$1" == "latest" ] && return 1
786 [ "$2" == "latest" ] && return 2
787 local lowest
788 lowest=$(echo -e "$1\n$2" | sort -V | head -1)
789 [ "$lowest" == "$1" ] && return 2
790 return 1
791}
792
David Bainbridgeac7f8072019-08-01 22:15:33 +0000793if [ "$1" == "down" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000794 echo "Tearing down voltha cluster $NAME"
795 LOG="down-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -0700796 date -u +"%Y%m%dT%H%M%SZ" >"$LOG"
797 if [ "$WITH_ONOS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700798 bspin "Remove port-forwards: onos-ui-$NAME"
799 kill_port_forward onos-ui
800 sspin "Remove port-forwards: onos-ssh-$NAME$CEOL"
801 kill_port_forward onos-ssh
802 fi
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800803 sspin "Remove port-forwards: voltha-api-$NAME$CEOL"
804 kill_port_forward voltha-api
David Bainbridged18f4942020-04-14 16:46:13 -0700805 if [ "$WITH_ETCD" == "yes" ] || [ "$WITH_ETCD" == "external" ]; then
806 sspin "Remove port-forwards: ${ETCD_PREFIX}etcd-$NAME$CEOL"
807 kill_port_forward "${ETCD_PREFIX}etcd-cluster-client"
David Bainbridge696bc632020-04-05 21:49:37 -0700808 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700809 if [ "$WITH_KAFKA" == "yes" ] || [ "$WITH_KAFKA" == "external" ]; then
810 sspin "Remove port-forwards: ${KAFKA_PREFIX}kafka-$NAME$CEOL"
811 kill_port_forward "${KAFKA_PREFIX}kafka"
David Bainbridge696bc632020-04-05 21:49:37 -0700812 fi
813
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800814 espin "$VERIFIED Remove port-forwards$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -0700815 if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridgeac7f8072019-08-01 22:15:33 +0000816 if [ -x ./bin/kind ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000817 bspin "Delete Kubernetes Kind Cluster"
David Bainbridged18f4942020-04-14 16:46:13 -0700818 (set -x; ./bin/kind delete cluster --name "voltha-$NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
819 espin "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000820 else
David Bainbridge0774b232019-08-02 06:37:19 +0000821 espin "$NO_ENTRY Delete Kubernetes Kind Cluster: kind command not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000822 fi
823 else
David Bainbridged18f4942020-04-14 16:46:13 -0700824 EXISTS="$(helm list -q)"
David Bainbridge76afd812020-04-06 09:53:52 -0700825 EXPECT="voltha"
David Bainbridged18f4942020-04-14 16:46:13 -0700826 if [ "$WITH_ONOS" == yes ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700827 EXPECT+=" onos"
828 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700829 if [ "$WITH_RADIUS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700830 EXPECT+=" radius"
831 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700832 if [ "$WITH_BBSIM" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700833 EXPECT+=" bbsim"
834 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700835 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700836 EXPECT+=" open-olt open-onu"
837 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700838 if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700839 EXPECT+=" sim"
840 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700841 if [ "$WITH_ETCD" == "external" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700842 EXPECT+=" etcd-operator etcd-cluster"
David Bainbridged18f4942020-04-14 16:46:13 -0700843 elif [ "$WITH_ETCD" == "yes" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700844 EXPECT+=" etcd-operator"
845 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700846 if [ "$WITH_KAFKA" == "external" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700847 EXPECT+=" kafka"
848 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000849 bspin "Remove Helm Deployments"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000850 for i in $EXISTS; do
David K. Bainbridge43422402020-03-06 07:41:22 -0800851 for j in $EXPECT; do
David Bainbridged18f4942020-04-14 16:46:13 -0700852 if [[ "$i" =~ $j ]]; then
David K. Bainbridge43422402020-03-06 07:41:22 -0800853 sspin "Remove Helm Deployments: $i$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -0700854 (set -x; ./bin/helm delete --no-hooks --purge "$i" >>"$LOG" 2>&1) >>"$LOG" 2>&1
David K. Bainbridge43422402020-03-06 07:41:22 -0800855 fi
856 done
uottrembb16d3982020-02-28 08:34:36 +0100857 done
David Bainbridge0774b232019-08-02 06:37:19 +0000858 espin "$VERIFIED Remove Helm Deployments$CEOL"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000859 if [ "$WAIT_ON_DOWN" == "yes" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700860 PODS="voltha-kafka.* voltha-ofagent.* voltha-rw-core.* voltha-etcd.*"
861 INFRA_PODS=
862 ADAPT_PODS=
863 SIM_PODS=
David Bainbridged18f4942020-04-14 16:46:13 -0700864 if [ "$WITH_RADIUS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700865 PODS+=" radius.*"
866 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700867 if [ "$WITH_BBSIM" == "yes" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700868 SIM_PODS+=" bbsim.*"
David Bainbridge696bc632020-04-05 21:49:37 -0700869 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700870 if [ "$WITH_OPEN_ADAPTERS" ] || [ "$WITH_SIM_ADAPTERS" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700871 ADAPT_PODS+=" adapter-*"
David Bainbridge696bc632020-04-05 21:49:37 -0700872 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700873 if [ "$WITH_ONOS" == "yes" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700874 INFRA_PODS+=" onos-.*"
875 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700876 if [ "$WITH_ETCD" == "external" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700877 INFRA_PODS+=" etcd-operator.* etcd-cluster.*"
David Bainbridged18f4942020-04-14 16:46:13 -0700878 elif [ "$WITH_ETCD" == "yes" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700879 PODS+=" etcd-operator.*"
880 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700881 if [ "$WITH_KAFKA" == "external" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700882 INFRA_PODS+=" kafka.*"
883 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700884 if [ -n "$SIM_PODS" ]; then
885 wait_for_pods "$BBSIM_NS" 0 "not" "Waiting for BBSIM PODs to terminate" "$BBSIM_LABEL" "$SIM_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -0700886 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700887 if [ -n "$INFRA_PODS" ]; then
888 wait_for_pods "$INFRA_NS" 0 "not" "Waiting for infrastructure PODs to terminate" "$NO_LABEL" "$INFRA_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -0700889 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700890 if [ -n "$ADAPT_PODS" ]; then
891 wait_for_pods "$ADAPTER_NS" 0 "not" "Waiting for adapter PODs to terminate" "$NO_LABEL" "$ADAPT_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -0700892 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700893 wait_for_pods "$VOLTHA_NS" 0 "not" "Waiting for VOLTHA PODs to terminate" "$NO_LABEL" "$PODS"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000894 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +0000895 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -0700896 exit
David Bainbridgeac7f8072019-08-01 22:15:33 +0000897fi
898
899if [ "$1" == "dump" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000900 LOG="dump-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -0700901 TS="$(date -u +"%Y%m%dT%H%M%SZ")"
902 if [ -n "$DUMP_FROM" ]; then
903 TS=${DUMP_FROM//[:-]}
David Bainbridge76514a02019-10-08 01:50:35 +0000904 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700905 WORK="$(mktemp -u -d)"
David Bainbridge0774b232019-08-02 06:37:19 +0000906 DATA=$WORK/voltha-debug-dump-$NAME-$TS
David Bainbridged18f4942020-04-14 16:46:13 -0700907 mkdir -p "$DATA"
908 echo "$TS" > "$LOG"
David Bainbridge0774b232019-08-02 06:37:19 +0000909 echo -e "Capturing debug dump to voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000910 bspin - "Copy install log"
David Bainbridged18f4942020-04-14 16:46:13 -0700911 if [ -f "install-$NAME.log" ]; then
912 (set -x; cp "install-$NAME.log" "$DATA/install-$NAME.log") >>"$LOG" 2>&1
913 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000914 else
David Bainbridge0774b232019-08-02 06:37:19 +0000915 espin - "$NO_ENTRY Copy install log: install-$NAME.log not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000916 fi
917 bspin - "Dumping Kubernetes PODs"
David Bainbridged18f4942020-04-14 16:46:13 -0700918 (set -x; kubectl get --all-namespaces pods >> "$DATA/all-pods.txt" 2>&1) >>"$LOG" 2>&1
919 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000920 bspin - "Dumping Kubernetes SERVICEs"
David Bainbridged18f4942020-04-14 16:46:13 -0700921 (set -x; kubectl get --all-namespaces svc >> "$DATA/all-services.txt" 2>&1) >>"$LOG" 2>&1
922 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000923 bspin - "Dumping Kubernetes EVENTs"
David Bainbridged18f4942020-04-14 16:46:13 -0700924 (set -x; kubectl get --all-namespaces events >> "$DATA/all-events.txt" 2>&1) >>"$LOG" 2>&1
925 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000926 bspin - "Dumping VOLTHA POD details"
David Bainbridged18f4942020-04-14 16:46:13 -0700927 PODS="$(kubectl -n "$INFRA_NS" get pod -o name | grep onos | sed -e "s/^/$INFRA_NS:/g") $(kubectl get -n "$VOLTHA_NS" pod -o name | sed -e "s/^/$VOLTHA_NS:/g")"
David Bainbridgecfd7ca12019-10-06 03:31:41 +0000928 SINCE=
David Bainbridged18f4942020-04-14 16:46:13 -0700929 if [ -n "$DUMP_FROM" ]; then
David Bainbridgecfd7ca12019-10-06 03:31:41 +0000930 SINCE="--since-time=$DUMP_FROM"
931 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +0000932 for POD in $PODS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700933 NS="$(echo "$POD" | cut -d: -f1)"
934 POD="$(echo "$POD" | cut -d: -f2)"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000935 sspin - "Dumping VOLTHA POD details: $POD$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -0700936 mkdir -p "$DATA/$POD"
937 (set -x; kubectl describe -n "$NS" "$POD" >> "$DATA/$POD/describe.txt" 2>&1) >>"$LOG" 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000938 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridged18f4942020-04-14 16:46:13 -0700939 (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 +0000940 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridged18f4942020-04-14 16:46:13 -0700941 (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 +0000942 sspin - "Dumping VOLTHA POD details: $POD"
943 done
944 espin - "$VERIFIED Dumping VOLTHA POD details$CEOL"
945 bspin - "Dumping ETCD"
David Bainbridged18f4942020-04-14 16:46:13 -0700946 if [ -n "$(command -v etcdctl)" ]; then
947 (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
948 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000949 else
950 espin - "$NO_ENTRY Dumping ETCD: etcdctl command not available"
951 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000952 bspin - "Creating compressed TAR: voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridged18f4942020-04-14 16:46:13 -0700953 (set -x; tar -C "$WORK" -zcf "voltha-debug-dump-$NAME-$TS.tgz" "./voltha-debug-dump-$NAME-$TS") >>"$LOG" 2>&1
954 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000955 bspin - "Cleanup"
David Bainbridged18f4942020-04-14 16:46:13 -0700956 (set -x; rm -rf "$WORK") >>"$LOG" 2>&1
957 espin - "$VERIFIED"
958 bspin - "$(ls -l "voltha-debug-dump-$NAME-$TS.tgz")"
959 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000960 exit
961fi
962
David Bainbridge0774b232019-08-02 06:37:19 +0000963LOG="install-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -0700964date > "$LOG"
965echo "PORTS=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT" >> "$LOG"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000966
967# Output install options to log
David Bainbridged18f4942020-04-14 16:46:13 -0700968echo "OPTIONS" >> "$LOG"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000969for O in $ALL_OPTIONS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700970 VAL="$(eval echo "\$$O")"
971 if [ -n "$VAL" ]; then
972 printf " %-30s = %s\n" "$O" "$VAL" >> "$LOG"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000973 fi
974done
975
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -0700976helm_install() {
David Bainbridged18f4942020-04-14 16:46:13 -0700977 local INDENT NOW
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700978 if [ "$1" == "-" ]; then
979 INDENT=$1; shift
980 fi
981 local NAMESPACE=$1; shift
David Bainbridge0774b232019-08-02 06:37:19 +0000982 local INAME=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700983 local CHART=$1; shift
David Bainbridge90fd8e32019-08-21 23:32:47 +0000984 local CHART_VERSION=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700985 local MESSAGE=$*
986
David Bainbridged18f4942020-04-14 16:46:13 -0700987 if [ "$CHART_VERSION X" != " X" ] && [ "$CHART_VERSION" != "latest" ]; then
David Bainbridge90fd8e32019-08-21 23:32:47 +0000988 CHART_VERSION="--version $CHART_VERSION"
989 else
990 CHART_VERSION=
991 fi
992
David Bainbridge99ac7a22019-08-31 02:26:43 +0000993 local CHART_ARGS=
994 if [ -r "${INAME}-values.yaml" ]; then
995 CHART_ARGS="-f ${INAME}-values.yaml"
996 fi
997
David Bainbridged18f4942020-04-14 16:46:13 -0700998 local WAIT_START CMD
999 WAIT_START="$(date +%s)"
1000 COUNT="$((300 / 15))"
1001 bspin "$INDENT" "$MESSAGE"
1002 if [ "$HELM_USE_UPGRADE" == "yes" ]; then
David Bainbridge7f8bf992020-04-08 21:53:22 -07001003 _HELM_COMMAND="upgrade --install"
1004 _HELM_ARGS="$INAME"
1005 else
1006 _HELM_COMMAND="install"
1007 _HELM_ARGS="--name $INAME"
1008 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001009 CMD=("helm $_HELM_COMMAND -f $NAME-values.yaml $CHART_ARGS $INTERNAL_EXTRA_HELM_INSTALL_ARGS $EXTRA_HELM_INSTALL_ARGS --set defaults.log_level=$VOLTHA_LOG_LEVEL --namespace $NAMESPACE $_HELM_ARGS $CHART_VERSION $EXTRA_HELM_FLAGS $CHART")
1010 (set -x; ${CMD[*]} >>"$LOG" 2>&1) >>"$LOG" 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001011 SUCCESS=$?
David Bainbridged18f4942020-04-14 16:46:13 -07001012 while [ "$SUCCESS" -ne 0 ]; do
1013 NOW="$(date +%s)"
1014 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -07001015 espin "$THEX"
1016 doTimeout "waiting for helm install $CHART"
1017 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001018 sspin "$INDENT"
1019 COUNT="$((COUNT - 1))"
1020 if [ "$COUNT" -eq 0 ]; then
1021 if [ "$HELM_USE_UPGRADE" == "no" ]; then
1022 (set -x; helm delete --purge "$INAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
David Bainbridge7f8bf992020-04-08 21:53:22 -07001023 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001024 (set -x; ${CMD[*]} >>"$LOG" 2>&1) >>"$LOG" 2>&1
Andy Baviere22ff252019-12-19 11:40:31 -07001025 SUCCESS=$?
David Bainbridged18f4942020-04-14 16:46:13 -07001026 COUNT="$((300 / 15))"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001027 fi
1028 sleep .15
1029 done
David Bainbridged18f4942020-04-14 16:46:13 -07001030 espin "$INDENT" "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001031}
1032
David Bainbridged18f4942020-04-14 16:46:13 -07001033echo "INSTALL TYPE: $TYPE" >> "$LOG"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001034
1035bspin "Verify GOPATH"
David Bainbridged18f4942020-04-14 16:46:13 -07001036GOPATH="$(pwd)"; export GOPATH
1037mkdir -p "$GOPATH/bin"
1038espin "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001039
David Bainbridged18f4942020-04-14 16:46:13 -07001040STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001041if [ "$INSTALL_KUBECTL" == "no" ]; then
1042 bspin "Skip kubectl install"
1043 espin $NO_ENTRY
Test Userc13bdc92019-07-03 20:57:49 +00001044else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001045 bspin "Verify kubectl $HELM"
David Bainbridged18f4942020-04-14 16:46:13 -07001046 if [ -x "$GOPATH/bin/kubectl" ]; then
1047 espin "$VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001048 else
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001049 ERR_OUT="$(mktemp)"
David Bainbridged18f4942020-04-14 16:46:13 -07001050 espin "$NOT_VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001051 bspin - "Download and install Kubernetes/kubectl $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001052 (set -x; curl --fail -o "$GOPATH/bin/kubectl" -sSL "https://storage.googleapis.com/kubernetes-release/release/$(curl --fail -sSL https://storage.googleapis.com/kubernetes-release/release/stable.txt 2>>"$ERR_OUT")/bin/$HOSTOS/$HOSTARCH/kubectl" >>"$LOG" 2>>"$ERR_OUT") >>"$LOG" 2>&1
1053 RESULT=$?
1054 if [ "$RESULT" -ne 0 ]; then
1055 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001056 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download kubectl: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001057 cat "$ERR_OUT" >> "$LOG"
1058 rm -rf $"ERR_OUT" "$GOPATH/bin/kubectl"
1059 exit 1
1060 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001061 (set -x; chmod 755 "$GOPATH/bin/kubectl" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1062 espin - "$VERIFIED"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001063 rm -rf "$ERR_OUT"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001064 fi
Test Userc13bdc92019-07-03 20:57:49 +00001065fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001066if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001067 NOW="$(date +%s)"
1068 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001069fi
Test Userc13bdc92019-07-03 20:57:49 +00001070
David Bainbridged18f4942020-04-14 16:46:13 -07001071STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001072if [ "$DEPLOY_K8S" == "no" ]; then
1073 bspin "Skip Kubernetes/Kind Deployment"
1074 espin $NO_ENTRY
1075else
Test Userba1e7e72019-07-10 22:27:54 +00001076 bspin "Verify Kubernetes/Kind $HELM"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001077 IS_INSTALLED=0
1078 OP_TYPE="install"
David Bainbridged18f4942020-04-14 16:46:13 -07001079 if [ -x "$GOPATH/bin/kind" ]; then
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001080 OP_TYPE="upgrade"
David Bainbridged18f4942020-04-14 16:46:13 -07001081 if [ "$("$GOPATH/bin/kind" --version | grep -c "$KIND_VERSION")" -eq 1 ]; then
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001082 IS_INSTALLED=1
David Bainbridged18f4942020-04-14 16:46:13 -07001083 espin "$VERIFIED"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001084 fi
1085 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001086 if [ "$IS_INSTALLED" -eq 0 ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001087 ERR_OUT="$(mktemp)"
David Bainbridged18f4942020-04-14 16:46:13 -07001088 espin "$NOT_VERIFIED"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001089 bspin - "Download and $OP_TYPE Kubernetes/kind $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001090 (set -x; curl -o "$GOPATH/bin/kind" --fail -sSL "https://github.com/kubernetes-sigs/kind/releases/download/$KIND_VERSION/kind-$HOSTOS-$HOSTARCH" >>"$LOG" 2>"$ERR_OUT") >>"$LOG" 2>&1
1091 RESULT=$?
1092 if [ $RESULT -ne 0 ]; then
1093 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001094 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download kind: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001095 cat "$ERR_OUT" >> "$LOG"
1096 rm -rf $"ERR_OUT" "$GOPATH/bin/kind"
1097 exit 1
1098 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001099 (set -x; chmod 755 "$GOPATH/bin/kind" >>"$LOG" 2>&1) >>"$LOG" 2>&1
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001100 rm -rf "$ERR_OUT"
David Bainbridged18f4942020-04-14 16:46:13 -07001101 espin - "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001102 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001103fi
1104
David Bainbridgee87067b2019-08-12 22:00:12 +00001105if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001106 NOW="$(date +%s)"
1107 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001108fi
1109
David Bainbridged18f4942020-04-14 16:46:13 -07001110STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001111if [ "$INSTALL_HELM" == "no" ]; then
1112 bspin "Skip Helm Install"
1113 espin $NO_ENTRY
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001114else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001115 bspin "Verify Helm $HELM"
David Bainbridgea34993d2020-04-01 09:15:42 -07001116 HELM_UPGRADE=0
1117 HELM_UPGRADE_DESC="install"
David Bainbridged18f4942020-04-14 16:46:13 -07001118 if [ -x "$GOPATH/bin/helm" ]; then
1119 HAVE_VER="$("$GOPATH/bin/helm" version -c --template '{{.Client.SemVer}}')"
1120 HELM_UP_DOWN="$(echo -e "$HAVE_VER\n$HELM_VERSION" | sort -V | head -1)"
1121 if [ "$HAVE_VER" != "$HELM_VERSION" ]; then
1122 if [ "$HELM_UP_DOWN" == "$HELM_VERSION" ]; then
David Bainbridgea34993d2020-04-01 09:15:42 -07001123 HELM_UPGRADE_DESC="downgrade"
1124 else
1125 HELM_UPGRADE_DESC="upgrade"
1126 fi
1127 HELM_UPGRADE=1
1128 else
David Bainbridged18f4942020-04-14 16:46:13 -07001129 espin "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001130 fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001131 else
David Bainbridgea34993d2020-04-01 09:15:42 -07001132 HELM_UPGRADE=1
1133 fi
1134
David Bainbridged18f4942020-04-14 16:46:13 -07001135 if [ "$HELM_UPGRADE" -ne 0 ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001136 ERR_OUT="$(mktemp)"
1137 INSTALL_HELM_BIN=$(mktemp)
David Bainbridged18f4942020-04-14 16:46:13 -07001138 espin "$NOT_VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001139 bspin - "Download and $HELM_UPGRADE_DESC Helm $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001140 (set -x; curl -o "$INSTALL_HELM_BIN" --fail -sSL https://git.io/get_helm.sh >>"$LOG" 2>"$ERR_OUT") >>"$LOG" 2>&1
1141 RESULT=$?
1142 if [ $RESULT -ne 0 ]; then
1143 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001144 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download helm installer: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001145 cat "$ERR_OUT" >> "$LOG"
1146 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT" "$GOPATH/bin/helm" "$GOPATH/bin/tiller"
1147 exit 1
1148 fi
1149 rm -rf "$ERR_OUT"
1150 chmod +x "$INSTALL_HELM_BIN"
1151 (set -x; PATH="$GOPATH/bin:$PATH" DESIRED_VERSION=$HELM_VERSION USE_SUDO=false HELM_INSTALL_DIR=$GOPATH/bin "$INSTALL_HELM_BIN" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1152 RESULT=$?
1153 if [ $RESULT -ne 0 ]; then
1154 espin - "$THEX"
1155 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to install helm, see install log for details${NORMAL}"
1156 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT" "$GOPATH/bin/helm" "$GOPATH/bin/tiller"
1157 exit 1
1158 fi
1159 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT"
David Bainbridged18f4942020-04-14 16:46:13 -07001160 espin - "$VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001161 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001162fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001163if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001164 NOW="$(date +%s)"
1165 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001166fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001167
David Bainbridged18f4942020-04-14 16:46:13 -07001168STIME="$(date +%s)"
Test Userb5712372019-07-03 21:52:17 +00001169bspin "Verify voltctl $HIGH_VOLTAGE"
David Bainbridged2811972019-12-14 01:14:09 +00001170VOK=0
1171VMESSAGE="install"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001172ERR_OUT=$(mktemp)
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001173export VC_VERSION="$VOLTCTL_VERSION"
1174if [ "$VC_VERSION" == "latest" ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001175 set -o pipefail # TODO: would be nice to run all in pipefail mode
1176 VC_VERSION="$(curl --fail -sSL https://api.github.com/repos/opencord/voltctl/releases/latest 2>"$ERR_OUT" | jq -r .tag_name | sed -e 's/^v//g')"
1177 RESULT=$?
1178 set +o pipefail
1179 if [ "$RESULT" -ne 0 ]; then
1180 espin - "$THEX"
1181 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to determine released version of voltctl: $(cat "$ERR_OUT")${NORMAL}"
1182 rm -rf "$ERR_OUT" "$GOPATH/bin/voltctl"
1183 exit 1
1184 fi
1185 export VC_VERSION
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001186fi
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001187
David Bainbridged18f4942020-04-14 16:46:13 -07001188if [ -x "$GOPATH/bin/voltctl" ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001189 VHAVE="$("$GOPATH/bin/voltctl" version --clientonly -o json 2>/dev/null | jq -r .version)"
David Bainbridged18f4942020-04-14 16:46:13 -07001190 RESULT=$?
1191 if [ $RESULT -eq 0 ] && [ "$VHAVE" == "$VC_VERSION" ]; then
David Bainbridged2811972019-12-14 01:14:09 +00001192 VOK=1
David Bainbridged18f4942020-04-14 16:46:13 -07001193 espin "$VERIFIED"
David Bainbridge1ba64f12019-12-18 00:40:13 +00001194 else
David Bainbridged18f4942020-04-14 16:46:13 -07001195 VCHECK="$(echo -e "$VHAVE\n$VC_VERSION" | sort -V | head -1)"
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001196 if [ "$VCHECK" == "$VHAVE" ]; then
1197 VMESSAGE="upgrade"
1198 else
1199 VMESSAGE="downgrade"
1200 fi
David Bainbridged2811972019-12-14 01:14:09 +00001201 fi
1202fi
1203
David Bainbridged18f4942020-04-14 16:46:13 -07001204if [ "$VOK" -eq 0 ]; then
1205 espin "$NOT_VERIFIED"
David Bainbridged2811972019-12-14 01:14:09 +00001206 bspin - "Download and $VMESSAGE voltctl $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001207 (set -x; curl --fail -o "$GOPATH/bin/voltctl" -sSL "https://github.com/opencord/voltctl/releases/download/v$VC_VERSION/voltctl-$VC_VERSION-$HOSTOS-$HOSTARCH" >>"$LOG" 2>"$ERR_OUT") >>"$LOG" 2>&1
1208 RESULT=$?
1209 if [ $RESULT -ne 0 ]; then
1210 espin - "$THEX"
1211 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download voltctl (version $VC_VERSION): $(cat "$ERR_OUT")${NORMAL}"
1212 rm -rf "$ERR_OUT" "$GOPATH/bin/voltctl"
1213 exit 1
1214 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001215 (set -x; chmod 755 "$GOPATH/bin/voltctl" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1216 espin - "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001217fi
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001218rm -rf "$ERR_OUT"
David Bainbridgee87067b2019-08-12 22:00:12 +00001219if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001220 NOW="$(date +%s)"
1221 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001222fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001223
1224bspin "Verify command PATH"
Test Userba1e7e72019-07-10 22:27:54 +00001225export PATH=$GOPATH/bin:$PATH
David Bainbridged18f4942020-04-14 16:46:13 -07001226espin "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001227
David Bainbridged18f4942020-04-14 16:46:13 -07001228STIME="$(date +%s)"
Test Userba1e7e72019-07-10 22:27:54 +00001229if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001230 HAVE="$(kind get clusters | grep -c "voltha-$NAME")"
Test Userba1e7e72019-07-10 22:27:54 +00001231 bspin "Verify Kubernetes/Kind Cluster"
1232 sspin
David Bainbridged18f4942020-04-14 16:46:13 -07001233 if [ "$HAVE" -eq 0 ]; then
1234 espin "$NOT_VERIFIED"
David Bainbridge491b1bd2019-07-11 17:53:11 +00001235 bspin - "Verify cluster configuration"
David Bainbridged18f4942020-04-14 16:46:13 -07001236 if [ ! -r "./$NAME-cluster.cfg" ]; then
1237 espin - "$NOT_VERIFIED"
David K. Bainbridge43422402020-03-06 07:41:22 -08001238 bspin - "Download cluster configuration: $TYPE-cluster.cfg to $NAME-cluster.cfg $DOWNLOAD"
David Bainbridged18f4942020-04-14 16:46:13 -07001239 ERR_OUT="$(mktemp)"
1240 if ! (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; then
1241 espin - "$THEX"
1242 echo -e "${RED}${BOLD}${ERROR}ERROR: $NAME-cluster.cfg${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1243 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
1244 rm -rf "$ERR_OUT" "./$NAME-cluster.cfg"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001245 exit 1
1246 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001247 rm -rf "$ERR_OUT"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001248 else
David Bainbridged18f4942020-04-14 16:46:13 -07001249 espin - "$VERIFIED"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001250 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001251 kind create cluster --name "voltha-$NAME" --config "$NAME-cluster.cfg"
David Bainbridge491b1bd2019-07-11 17:53:11 +00001252 else
David Bainbridged18f4942020-04-14 16:46:13 -07001253 espin "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001254 fi
1255
David Bainbridged18f4942020-04-14 16:46:13 -07001256 KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$NAME")"; export KUBECONFIG
Test Userba1e7e72019-07-10 22:27:54 +00001257 P="coredns-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001258 etcd-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +00001259 kindnet-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001260 kube-apiserver-voltha-$NAME-control-plane \
1261 kube-controller-manager-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +00001262 kube-proxy-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001263 kube-scheduler-voltha-$NAME-control-plane"
Test Userba1e7e72019-07-10 22:27:54 +00001264
David Bainbridged18f4942020-04-14 16:46:13 -07001265 EXPECT="$(test "$TYPE" == "minimal" && echo "12" || echo "14")"
1266 wait_for_pods - "kube-system" "$EXPECT" "includes" "Waiting for system PODs to start" "$NO_LABEL" "$P"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001267fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001268if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001269 NOW="$(date +%s)"
1270 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001271fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001272
David Bainbridged18f4942020-04-14 16:46:13 -07001273STIME="$(date +%s)"
1274COUNT="$(count_pods "kube-system" ":Running:" "$NO_LABEL" "tiller-deploy-.*")"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001275bspin "Verify Helm"
David Bainbridged18f4942020-04-14 16:46:13 -07001276if [ "$COUNT" -ne 1 ]; then
1277 espin "$NOT_VERIFIED"
Test Userb5712372019-07-03 21:52:17 +00001278 echo -e "Configuring Helm $GEAR"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001279 if [ "$INSTALL_HELM" == "no" ]; then
1280 bspin - "Skip Helm/Tiller Initialization"
1281 espin - $NO_ENTRY
1282 else
1283 bspin - "Initialize Helm"
David Bainbridged18f4942020-04-14 16:46:13 -07001284 (set -x; helm init --upgrade >>"$LOG" 2>&1) >>"$LOG" 2>&1
1285 espin - "$VERIFIED"
1286 wait_for_pods - "kube-system" 1 "includes" "Waiting for Tiller POD to start" "$NO_LABEL" "tiller-deploy-.*"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001287 fi
Test Userb5712372019-07-03 21:52:17 +00001288 bspin - "Add Google Incubator repository to Helm"
David Bainbridged18f4942020-04-14 16:46:13 -07001289 (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>"$LOG" 2>&1) >>"$LOG" 2>&1
1290 espin - "$VERIFIED"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001291
Test Userba1e7e72019-07-10 22:27:54 +00001292 # HACK (sort-of) - the config for tiller is about to be patched, which will
1293 # cause the tiller pod to be recreated. This can sometimes cause a timing
1294 # issue with the "wait_for_pods" call on tiller as it may incorrectly
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001295 # identify the running/ready tiller pod that is soon to be terminated as
Test Userba1e7e72019-07-10 22:27:54 +00001296 # what it is waiting for. To avoid this issue we do a clean scale down and
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001297 # scale up of the pod so the script controlls when it should be expecting
Test Userba1e7e72019-07-10 22:27:54 +00001298 # things
David Bainbridged18f4942020-04-14 16:46:13 -07001299 (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 -07001300
Test Userb5712372019-07-03 21:52:17 +00001301 bspin - "Add Google Stable repository to Helm"
David Bainbridged18f4942020-04-14 16:46:13 -07001302 (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>"$LOG" 2>&1) >>"$LOG" 2>&1
1303 espin - "$VERIFIED"
Test Userb5712372019-07-03 21:52:17 +00001304 bspin - "Add ONF repository to Helm"
David Bainbridged18f4942020-04-14 16:46:13 -07001305 (set -x; helm repo add onf https://charts.opencord.org >>"$LOG" 2>&1) >>"$LOG" 2>&1
1306 espin - "$VERIFIED"
Test Userb5712372019-07-03 21:52:17 +00001307 bspin - "Update Helm repository cache"
David Bainbridged18f4942020-04-14 16:46:13 -07001308 (set -x; helm repo update >>"$LOG" 2>&1) >>"$LOG" 2>&1
1309 espin - "$VERIFIED"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001310
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001311 # Create and k8s service account so that Helm can create pods
Test Userb5712372019-07-03 21:52:17 +00001312 bspin - "Create Tiller ServiceAccount"
David Bainbridged18f4942020-04-14 16:46:13 -07001313 (set -x; kubectl create serviceaccount --namespace kube-system tiller >>"$LOG" 2>&1) >>"$LOG" 2>&1
1314 espin - "$VERIFIED"
Test Userb5712372019-07-03 21:52:17 +00001315 bspin - "Create Tiller ClusterRoleBinding"
David Bainbridged18f4942020-04-14 16:46:13 -07001316 (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>"$LOG" 2>&1) >>"$LOG" 2>&1
1317 espin - "$VERIFIED"
Test Userb5712372019-07-03 21:52:17 +00001318 bspin - "Update Tiller Manifest"
David Bainbridged18f4942020-04-14 16:46:13 -07001319 (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 +00001320
1321 # HACK (sort-of) - part to, spin it back up
David Bainbridged18f4942020-04-14 16:46:13 -07001322 (set -x; kubectl -n kube-system scale deploy tiller-deploy --replicas=1 >>"$LOG" 2>&1) >>"$LOG" 2>&1
1323 espin - "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001324else
David Bainbridged18f4942020-04-14 16:46:13 -07001325 if [ "$(helm version -s --template '{{.Server.SemVer}}')" != "$HELM_VERSION" ]; then
1326 espin "$NOT_VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001327 bspin - "Sync Tiller server version with helm client"
David Bainbridged18f4942020-04-14 16:46:13 -07001328 (set -x; helm init --upgrade --force-upgrade --wait >>"$LOG" 2>&1) >>"$LOG" 2>&1
1329 espin - "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001330 else
David Bainbridged18f4942020-04-14 16:46:13 -07001331 espin "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001332 fi
1333
David Bainbridge46505fb2019-10-01 21:13:20 +00001334 if [ "$UPDATE_HELM_REPOS" == "yes" ]; then
1335 bspin - "Update Helm repository cache"
David Bainbridged18f4942020-04-14 16:46:13 -07001336 (set -x; helm repo update >>"$LOG" 2>&1) >>"$LOG" 2>&1
1337 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00001338 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001339fi
David Bainbridged18f4942020-04-14 16:46:13 -07001340wait_for_pods - "kube-system" 1 "includes" "Waiting for Tiller POD to start" "$NO_LABEL" "tiller-deploy-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001341if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001342 NOW="$(date +%s)"
1343 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001344fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001345
David Bainbridged18f4942020-04-14 16:46:13 -07001346STIME="$(date +%s)"
David Bainbridge0774b232019-08-02 06:37:19 +00001347bspin "Verify Helm values file: $NAME-values.yaml"
1348if [ ! -r "./$NAME-values.yaml" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001349 espin "$NOT_VERIFIED"
David Bainbridge0774b232019-08-02 06:37:19 +00001350 bspin - "Download Helm values file: $TYPE-values.yaml to $NAME-values.yaml $DOWNLOAD"
David Bainbridged18f4942020-04-14 16:46:13 -07001351 ERR_OUT="$(mktemp)"
1352 if ! (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; then
1353 espin - "$THEX"
1354 echo -e "${RED}${BOLD}${ERROR}ERROR: $NAME-values.yaml${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1355 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
1356 rm -rf "$ERR_OUT" "./$NAME-values.yaml"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001357 exit 1
1358 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001359 rm -rf "$ERR_OUT"
1360 espin - "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001361else
David Bainbridged18f4942020-04-14 16:46:13 -07001362 espin "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001363fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001364if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001365 NOW="$(date +%s)"
1366 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001367fi
Test Userba1e7e72019-07-10 22:27:54 +00001368
David Bainbridged18f4942020-04-14 16:46:13 -07001369STIME="$(date +%s)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001370bspin "Verify or download chart specific values files $DOWNLOAD"
1371VALUES_FILES="monkey-values.yaml"
David Bainbridged18f4942020-04-14 16:46:13 -07001372ERR_OUT="$(mktemp)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001373for i in $VALUES_FILES; do
1374 if [ ! -r ./$i ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001375 if ! (set -x; curl --fail -o "./$i" -sSL "https://raw.githubusercontent.com/ciena/kind-voltha/$VK_RELEASE/$i" >>"$LOG" 2>"$ERR_OUT") >>"$LOG" 2>&1; then
1376 espin "$THEX"
1377 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1378 echo "ERROR: $i - $(cat "$ERR_OUT")" >>"$LOG"
1379 rm -rf "$ERR_OUT" "./$i"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001380 exit 1
1381 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001382 rm -rf "$ERR_OUT"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001383 fi
1384done
David Bainbridged18f4942020-04-14 16:46:13 -07001385rm -rf "$ERR_OUT"
1386espin "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001387if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001388 NOW="$(date +%s)"
1389 printtime $((NOW - STIME))
David Bainbridge99ac7a22019-08-31 02:26:43 +00001390fi
1391
1392if [ "$WITH_CHAOS" == "yes" ]; then
1393 bspin "Verify or clone kube-monkey helm chart $DOWNLOAD"
1394 if [ -r ./kube-monkey ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001395 espin "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001396 else
David Bainbridged18f4942020-04-14 16:46:13 -07001397 espin "$NOT_VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001398 bspin - "GIT clone kube-monkey"
David Bainbridged18f4942020-04-14 16:46:13 -07001399 (set -x; git clone https://github.com/asobti/kube-monkey kube-monkey >>"$LOG" 2>&1) >>"$LOG" 2>&1
1400 espin - "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001401 fi
1402fi
1403
Test Userba1e7e72019-07-10 22:27:54 +00001404if [ "$JUST_K8S" == "yes" ]; then
1405 echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye."
1406 echo ""
David Bainbridged18f4942020-04-14 16:46:13 -07001407 echo "Please issue the following commands in your terminal to ensure that you" | tee -a "$LOG"
1408 echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a "$LOG"
1409 echo "tools required by VOLTHA in your command path. " | tee -a "$LOG"
1410 echo "" | tee -a "$LOG"
1411 echo -en "$BOLD"
1412 if [ "$DEPLOY_K8S" == "yes" ]; then
1413 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00001414 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001415 echo "export PATH=$GOPATH/bin:\$PATH" | tee -a "$LOG"
1416 echo -en "$NORMAL"
1417 echo "" | tee -a "$LOG"
1418 echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00001419 exit 0
1420fi
1421
David Bainbridged18f4942020-04-14 16:46:13 -07001422if [ "$WITH_ETCD" != "yes" ] && [ "$WITH_ETCD" != "external" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001423 bspin "Skip ETCD Operator Deployment"
1424 espin $NO_ENTRY
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001425else
David Bainbridged18f4942020-04-14 16:46:13 -07001426 STIME="$(date +%s)"
David Bainbridge76afd812020-04-06 09:53:52 -07001427 NS=$VOLTHA_NS
David Bainbridged18f4942020-04-14 16:46:13 -07001428 if [ "$WITH_ETCD" == "external" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -07001429 NS=$INFRA_NS
1430 fi
David Bainbridge696bc632020-04-05 21:49:37 -07001431 bspin "Verify ETCD Operator $OLD_KEY"
David Bainbridged18f4942020-04-14 16:46:13 -07001432 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$NS" "^etcd-operator\$" | wc -l)" -ne 1 ]; then
1433 espin "$NOT_VERIFIED"
1434 helm_install - "$NS" etcd-operator stable/etcd-operator latest "$_HELM_DESC ETCD Operator"
David Bainbridge696bc632020-04-05 21:49:37 -07001435 else
David Bainbridged18f4942020-04-14 16:46:13 -07001436 espin "$VERIFIED"
David Bainbridge696bc632020-04-05 21:49:37 -07001437 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001438 EXPECT="$(test "$TYPE" == "minimal" && echo "1" || echo "3")"
1439 wait_for_pods - "$NS" "$EXPECT" "includes" "Waiting for ETCD Operator to start" "$NO_LABEL" "etcd-operator-.*"
David Bainbridge696bc632020-04-05 21:49:37 -07001440 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001441 NOW="$(date +%s)"
1442 printtime $((NOW - STIME))
David Bainbridge696bc632020-04-05 21:49:37 -07001443 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001444fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001445
David Bainbridged18f4942020-04-14 16:46:13 -07001446STIME="$(date +%s)"
1447if [ "$WITH_ONOS" == "yes" ]; then
David Bainbridgeb270c202019-07-26 01:44:42 +00001448 bspin "Verify ONOS installed $BIRD"
David Bainbridged18f4942020-04-14 16:46:13 -07001449 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^onos\$" | wc -l)" -ne 1 ]; then
1450 espin "$NOT_VERIFIED"
1451 EXTRA_HELM_FLAGS="$SET_TAG $EXTRA_HELM_FLAGS" helm_install - "$INFRA_NS" onos "$ONOS_CHART" "$ONOS_CHART_VERSION" "$_HELM_DESC ONOS"
David Bainbridgeb270c202019-07-26 01:44:42 +00001452 else
David Bainbridged18f4942020-04-14 16:46:13 -07001453 espin "$VERIFIED"
David Bainbridgeb270c202019-07-26 01:44:42 +00001454 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001455 wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for ONOS to start" "$NO_LABEL" "onos-.*"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001456
David Bainbridged18f4942020-04-14 16:46:13 -07001457 if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001458 bspin - "Forward ONOS API port $FORWARD"
1459 kill_port_forward onos-ui
David Bainbridged18f4942020-04-14 16:46:13 -07001460 port_forward "$INFRA_NS" onos-ui "$ONOS_API_PORT" 8181
1461 espin - "$VERIFIED"
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001462 bspin - "Forward ONOS SSH port $FORWARD"
1463 kill_port_forward onos-ssh
David Bainbridged18f4942020-04-14 16:46:13 -07001464 port_forward "$INFRA_NS" onos-ssh "$ONOS_SSH_PORT" 8101
1465 espin - "$VERIFIED"
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001466 _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT"
1467 else
David Bainbridged18f4942020-04-14 16:46:13 -07001468 _ONOS_API_EP="$(get_service_ep "$INFRA_NS" onos-ui)"
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001469 fi
David Bainbridged31d6122019-08-13 19:37:59 +00001470 bspin - "Verify or download ONOS configuration support files $DOWNLOAD"
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001471 ONOS_FILES="olt-onos-enableExtraneousRules.json onos-aaa.json \
David Bainbridge696bc632020-04-05 21:49:37 -07001472 onos-dhcpl2relay.json onos-sadis-sample.json"
David Bainbridged18f4942020-04-14 16:46:13 -07001473 (set -x; mkdir -p ./onos-files >>"$LOG" 2>&1) >>"$LOG" 2>&1
1474 ERR_OUT="$(mktemp)"
David Bainbridge2b19e832019-08-16 02:40:53 +00001475 for i in $ONOS_FILES; do
David Bainbridged18f4942020-04-14 16:46:13 -07001476 if [ ! -r "./onos-files/$i" ]; then
1477 if ! (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; then
1478 espin - "$THEX"
1479 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1480 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
1481 rm -rf "$ERR_OUT" "./onos-files/$i"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001482 exit 1
1483 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001484 rm -rf "$ERR_OUT"
David Bainbridged31d6122019-08-13 19:37:59 +00001485 fi
1486 done
David Bainbridged18f4942020-04-14 16:46:13 -07001487 rm -rf "$ERR_OUT"
1488 espin - "$VERIFIED"
David Bainbridge27790d62019-08-13 22:43:19 +00001489
David Bainbridged18f4942020-04-14 16:46:13 -07001490 if [ "$INSTALL_ONOS_APPS" == "yes" ]; then
David Bainbridge27790d62019-08-13 22:43:19 +00001491 bspin - "Installing custom ONOS applications"
David Bainbridged18f4942020-04-14 16:46:13 -07001492 if [ -x onos-files/onos-apps ] && [ "$(find onos-files/onos-apps -name "*.oar" 2>/dev/null | wc -l)" -gt 0 ]; then
1493 for OAR in onos-files/onos-apps/*.oar; do
David Bainbridge27790d62019-08-13 22:43:19 +00001494 sspin - "Installing custom ONOS applications - $OAR$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -07001495 override_onos_app "$OAR"
David Bainbridge27790d62019-08-13 22:43:19 +00001496 done
1497 espin - "$VERIFIED Installing custom ONOS applications$CEOL"
1498 else
1499 espin - "$NOT_VERIFIED Installing custom ONOS applications - None Found"
1500 fi
1501 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001502
David Bainbridged18f4942020-04-14 16:46:13 -07001503 if [ "$WITH_KAFKA" != "no" ]; then
David Bainbridge837e8bd2020-04-06 13:17:14 -07001504 check_onos_app_active org.opencord.kafka
David Bainbridge76afd812020-04-06 09:53:52 -07001505 _HOST=voltha-kafka.$INFRA_NS.svc.cluster.local
David Bainbridge837e8bd2020-04-06 13:17:14 -07001506 _PORT=9092
David Bainbridged18f4942020-04-14 16:46:13 -07001507 if [ "$WITH_KAFKA" == "yes" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -07001508 _HOST=voltha-kafka.$VOLTHA_NS.svc.cluster.local
1509 _PORT=9092
David Bainbridged18f4942020-04-14 16:46:13 -07001510 elif [ "$WITH_KAFKA" == "external" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -07001511 _HOST=kafka.$INFRA_NS.svc.cluster.local
1512 _PORT=9092
1513 else
David Bainbridged18f4942020-04-14 16:46:13 -07001514 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
1515 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge837e8bd2020-04-06 13:17:14 -07001516 _PORT=${_PORT:-9092}
1517 fi
1518 push_onos_config "json" "Push ONOS Kafka Configuration" "network/configuration/apps/org.opencord.kafka" \
David Bainbridged18f4942020-04-14 16:46:13 -07001519 "$(cat <<EOJ | tr -d '[:space:]'
David Bainbridge696bc632020-04-05 21:49:37 -07001520{
1521 "kafka": {
1522 "bootstrapServers": "$_HOST:$_PORT"
1523 }
1524}
1525EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07001526)"
David Bainbridge837e8bd2020-04-06 13:17:14 -07001527 fi
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001528 check_onos_app_active org.opencord.dhcpl2relay
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001529 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 -08001530 check_onos_app_active org.opencord.olt
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001531 # FIXME use WITH_DHCP and WITH_EAPOL flags to configre OLT App
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001532 # Default value for "enableEapol" is true in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07001533 if [ "$WITH_EAPOL" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001534 push_onos_config "json" "Enable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":true}'
David Bainbridged18f4942020-04-14 16:46:13 -07001535 elif [ "$WITH_EAPOL" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001536 push_onos_config "json" "Disable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001537 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001538 # Default value for "enableDhcpOnProvisioning" is false and for "enableDhcpV4" is true in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07001539 if [ "$WITH_DHCP" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001540 push_onos_config "json" "Enable VOLTHA ONOS DHCP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableDhcpOnProvisioning":true,"enableDhcpV4":true}'
David Bainbridged18f4942020-04-14 16:46:13 -07001541 elif [ "$WITH_DHCP" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001542 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 -08001543 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001544 # Default value for "enableIgmpOnProvisioning" is false in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07001545 if [ "$WITH_IGMP" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001546 push_onos_config "json" "Enable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":true}'
David Bainbridged18f4942020-04-14 16:46:13 -07001547 elif [ "$WITH_IGMP" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001548 push_onos_config "json" "Disable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001549 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001550 if [ "$ENABLE_ONOS_EXTRANEOUS_RULES" == "yes" ]; then
David K. Bainbridge484d80c2020-03-05 21:44:34 -08001551 push_onos_config "file" "Enabling extraneous rules for ONOS" "configuration/org.onosproject.net.flow.impl.FlowRuleManager" "onos-files/olt-onos-enableExtraneousRules.json"
1552 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001553 if [ "$(echo ":yes:file:" | grep -c ":$CONFIG_SADIS:")" -eq 1 ]; then
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001554 check_onos_app_active org.opencord.sadis
Hardik Windlassb3147602020-03-09 16:59:15 +05301555 push_onos_config "file" "[optional] Push ONOS SADIS Configuration: $SADIS_CFG" "network/configuration/apps/org.opencord.sadis" "$SADIS_CFG"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001556 elif [ "$CONFIG_SADIS" == "bbsim" ]; then
1557 push_onos_config "json" \
1558 "[optional] Push ONOS configuration for BBSIM SADIS servers" \
1559 "network/configuration/apps/org.opencord.sadis" \
David Bainbridged18f4942020-04-14 16:46:13 -07001560 "$(cat <<EOJ | tr -d '[:space:]'
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001561{
1562 "sadis": {
1563 "integration": {
David Bainbridge76afd812020-04-06 09:53:52 -07001564 "url": "http://bbsim.$BBSIM_NS.svc.cluster.local:50074/v2/subscribers/%s",
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001565 "cache": {
1566 "enabled": true,
1567 "maxsize": 50,
1568 "ttl": "PT1m"
1569 }
1570 }
1571 },
1572 "bandwidthprofile": {
1573 "integration": {
David Bainbridge76afd812020-04-06 09:53:52 -07001574 "url": "http://bbsim.$BBSIM_NS.svc.cluster.local:50074/v2/bandwidthprofiles/%s",
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001575 "cache": {
1576 "enabled": true,
1577 "maxsize": 50,
1578 "ttl": "PT1m"
1579 }
1580 }
1581 }
1582}
1583EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07001584)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001585 elif [ "$CONFIG_SADIS" == "url" ]; then
1586 push_onos_config "json" \
1587 "[optional] Push ONOS configuration for custom SADIS and Bandwidth Profile servers" \
1588 "network/configuration/apps/org.opencord.sadis" \
David Bainbridged18f4942020-04-14 16:46:13 -07001589 "$(cat <<EOJ | tr -d '[:space:]'
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001590{
1591 "sadis": {
1592 "integration": {
1593 "url": "$SADIS_SUBSCRIBERS",
1594 "cache": {
1595 "enabled": true,
1596 "maxsize": 50,
1597 "ttl": "PT1m"
1598 }
1599 }
1600 },
1601 "bandwidthprofile": {
1602 "integration": {
1603 "url": "$SADIS_BANDWIDTH_PROFILES",
1604 "cache": {
1605 "enabled": true,
1606 "maxsize": 50,
1607 "ttl": "PT1m"
1608 }
1609 }
1610 }
1611}
1612EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07001613)"
David Bainbridge2b19e832019-08-16 02:40:53 +00001614 fi
Test Userba1e7e72019-07-10 22:27:54 +00001615fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001616if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001617 NOW="$(date +%s)"
1618 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001619fi
Test Userba1e7e72019-07-10 22:27:54 +00001620
David Bainbridged18f4942020-04-14 16:46:13 -07001621if [ "$WITH_ETCD" == "external" ]; then
1622 STIME="$(date +%s)"
David Bainbridge76afd812020-04-06 09:53:52 -07001623 bspin "Verify external ETCD cluster $OLD_KEY"
David Bainbridged18f4942020-04-14 16:46:13 -07001624 EXPECT="$(test "$TYPE" == "minimal" && echo "1" || echo "3")"
1625 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^etcd-cluster\$" | wc -l)" -ne 1 ]; then
1626 espin "$NOT_VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07001627 INTERNAL_EXTRA_HELM_INSTALL_ARGS+="--set clusterName=etcd-cluster --set autoCompactionRetention=1 --set clusterSize=$EXPECT"
David Bainbridged18f4942020-04-14 16:46:13 -07001628 helm_install - "$INFRA_NS" etcd-cluster onf/voltha-etcd-cluster latest "$_HELM_DESC external ETCD cluster"
David Bainbridge76afd812020-04-06 09:53:52 -07001629 else
David Bainbridged18f4942020-04-14 16:46:13 -07001630 espin "$VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07001631 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001632 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for ETCD cluster to start" "$NO_LABEL" "etcd-cluster-.*"
David Bainbridge76afd812020-04-06 09:53:52 -07001633 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001634 NOW="$(date +%s)"
1635 printtime $((NOW - STIME))
David Bainbridge76afd812020-04-06 09:53:52 -07001636 fi
1637fi
1638
David Bainbridged18f4942020-04-14 16:46:13 -07001639if [ "$WITH_KAFKA" == "external" ]; then
1640 _TMP="$(mktemp -u)"
1641 _COUNT="$(test "$TYPE" == "minimal" && echo "1" || echo "3")"
1642 cat << EOC > "$_TMP"
David Bainbridge76afd812020-04-06 09:53:52 -07001643configurationOverrides:
1644 "default.replication.factor": $_COUNT
1645 "offsets.topic.replication.factor": $_COUNT
1646 "log.retention.hours": 4
1647 "log.message.timestamp.type": "LogAppendTime"
1648persistence:
1649 enabled: false
1650zookeeper:
1651 replicaCount: 1
1652 persistence:
1653 enabled: false
1654replicas: $_COUNT
1655EOC
David Bainbridged18f4942020-04-14 16:46:13 -07001656 STIME="$(date +%s)"
David Bainbridge76afd812020-04-06 09:53:52 -07001657 bspin "Verify external Kafka cluster $OLD_KEY"
David Bainbridged18f4942020-04-14 16:46:13 -07001658 EXPECT="$(test "$TYPE" == "minimal" && echo "2" || echo "4")"
1659 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^kafka\$" | wc -l)" -ne 1 ]; then
1660 espin "$NOT_VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07001661 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" -f $_TMP"
David Bainbridgeb9093522020-04-15 14:32:44 -07001662 helm_install - "$INFRA_NS" kafka incubator/kafka "$KAFKA_CHART_VERSION" "$_HELM_DESC external Kafka cluster"
David Bainbridge76afd812020-04-06 09:53:52 -07001663 else
David Bainbridged18f4942020-04-14 16:46:13 -07001664 espin "$VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07001665 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001666 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for Kafka cluster to start" "$NO_LABEL" "kafka-.*"
David Bainbridge76afd812020-04-06 09:53:52 -07001667 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001668 NOW="$(date +%s)"
1669 printtime $((NOW - STIME))
David Bainbridge76afd812020-04-06 09:53:52 -07001670 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001671 rm -rf "$_TMP"
David Bainbridge76afd812020-04-06 09:53:52 -07001672fi
1673
David Bainbridged18f4942020-04-14 16:46:13 -07001674STIME="$(date +%s)"
David Bainbridge696bc632020-04-05 21:49:37 -07001675EXPECT=1
1676if [ "$ONLY_ONE" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001677 EXPECT="$((EXPECT+1))"
David Bainbridge696bc632020-04-05 21:49:37 -07001678 INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set therecanbeonlyone=true"
1679else
David Bainbridged18f4942020-04-14 16:46:13 -07001680 EXPECT="$((EXPECT+2))"
David Bainbridge696bc632020-04-05 21:49:37 -07001681fi
Matteo Scandolo67335f02020-04-09 11:19:53 -07001682case $WITH_ETCD in
David Bainbridge76afd812020-04-06 09:53:52 -07001683 no)
1684 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set private_etcd_cluster=false"
1685 ;;
1686 yes)
1687 _HOST="voltha-etcd-cluster-client.$VOLTHA_NS.svc.cluster.local"
1688 _PORT=2379
1689 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridged18f4942020-04-14 16:46:13 -07001690 EXPECT="$((EXPECT+$(test "$TYPE" == "minimal" && echo "1" || echo "3")))"
David Bainbridge76afd812020-04-06 09:53:52 -07001691 ;;
1692 external)
1693 _HOST="etcd-cluster-client.$INFRA_NS.svc.cluster.local"
1694 _PORT=2379
1695 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set private_etcd_cluster=false --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
1696 ;;
1697 *)
David Bainbridged18f4942020-04-14 16:46:13 -07001698 _HOST="$(echo "$WITH_ETCD" | cut -d: -f1)"
1699 _PORT="$(echo "$WITH_ETCD" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07001700 _PORT=${_PORT:-2379}
David Bainbridge76afd812020-04-06 09:53:52 -07001701 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set private_etcd_cluster=false --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
1702 ;;
1703esac
1704case $WITH_KAFKA in
1705 no)
1706 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set private_kafka_cluster=false"
1707 ;;
1708 yes)
1709 _HOST=voltha-kafka.$VOLTHA_NS.svc.cluster.local
1710 _PORT=9092
1711 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafka_broker=$_HOST:$_PORT --set services.kafka.adapter.service=$_HOST --set services.kafka.adapter.port=$_PORT --set services.kafka.cluster.service=$_HOST --set services.kafka.cluster.port=$_PORT"
David Bainbridged18f4942020-04-14 16:46:13 -07001712 EXPECT="$((EXPECT+$(test "$TYPE" == "minimal" && echo "2" || echo "4")))"
David Bainbridge76afd812020-04-06 09:53:52 -07001713 ;;
1714 external)
1715 _HOST=kafka.$INFRA_NS.svc.cluster.local
1716 _PORT=9092
1717 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set private_kafka_cluster=false --set kafka_broker=$_HOST:$_PORT --set services.kafka.adapter.service=$_HOST --set services.kafka.adapter.port=$_PORT --set services.kafka.cluster.service=$_HOST --set services.kafka.cluster.port=$_PORT"
1718 ;;
1719 *)
David Bainbridged18f4942020-04-14 16:46:13 -07001720 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
1721 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07001722 _PORT=${_PORT:-9092}
David Bainbridge76afd812020-04-06 09:53:52 -07001723 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set private_kafka_cluster=false --set kafka_broker=$_HOST:$_PORT --set services.kafka.adapter.service=$_HOST --set services.kafka.adapter.port=$_PORT --set services.kafka.cluster.service=$_HOST --set services.kafka.cluster.port=$_PORT"
1724 ;;
1725esac
1726
David Bainbridged18f4942020-04-14 16:46:13 -07001727if [ "$WITH_ONOS" == "yes" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -07001728 _HOST=onos-openflow.$INFRA_NS.svc.cluster.local
1729 _PORT=6653
David Bainbridged18f4942020-04-14 16:46:13 -07001730elif [ "$WITH_ONOS" != "no" ]; then
1731 _HOST="$(echo "$WITH_ONOS" | cut -d: -f1)"
1732 _PORT="$(echo "$WITH_ONOS" | cut -s -d: -f2)"
David Bainbridge76afd812020-04-06 09:53:52 -07001733 _PORT=${_PORT:-6653}
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07001734fi
1735compare_versions "$VOLTHA_CHART_VERSION" 2.4.2
1736if [ "$?" == "1" ]; then
1737 # voltha chart > 2.4.2 uses list of controllers
1738 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.controller[0].service=$_HOST --set services.controller[0].port=$_PORT"
1739else
1740 # voltha chart <= 2.4.2 uses single controller
David Bainbridge76afd812020-04-06 09:53:52 -07001741 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.controller.service=$_HOST --set services.controller.port=$_PORT"
David Bainbridge696bc632020-04-05 21:49:37 -07001742fi
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07001743
Test Userb5712372019-07-03 21:52:17 +00001744bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
David Bainbridged18f4942020-04-14 16:46:13 -07001745if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$VOLTHA_NS" "^voltha\$" | wc -l)" -ne 1 ]; then
1746 espin "$NOT_VERIFIED"
1747 helm_install - "$VOLTHA_NS" voltha "$VOLTHA_CHART" "$VOLTHA_CHART_VERSION" "$_HELM_DESC VOLTHA Core"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001748else
David Bainbridged18f4942020-04-14 16:46:13 -07001749 espin "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001750fi
David Bainbridge696bc632020-04-05 21:49:37 -07001751INTERNAL_EXTRA_HELM_INSTALL_ARGS=
Test Userba1e7e72019-07-10 22:27:54 +00001752
David Bainbridge90fd8e32019-08-21 23:32:47 +00001753VOLTHA="voltha-ofagent-.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001754 rw-core.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001755 voltha-etcd-cluster-.* \
1756 voltha-kafka-.* \
1757 voltha-zookeeper-.*"
David Bainbridged18f4942020-04-14 16:46:13 -07001758wait_for_pods - "$VOLTHA_NS" "$EXPECT" "includes" "Waiting for VOLTHA Core to start" "$NO_LABEL" "$VOLTHA"
David Bainbridgee87067b2019-08-12 22:00:12 +00001759if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001760 NOW="$(date +%s)"
1761 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001762fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001763
David Bainbridge46505fb2019-10-01 21:13:20 +00001764if [ "$WITH_ADAPTERS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001765 STIME="$(date +%s)"
David Bainbridge46505fb2019-10-01 21:13:20 +00001766 EXPECT=0
David Bainbridged18f4942020-04-14 16:46:13 -07001767 if [ "$WITH_ETCD" == "yes" ]; then
David Bainbridge3517f6c2020-04-08 12:14:08 -07001768 _HOST=voltha-etcd-cluster-client.$VOLTHA_NS.svc.cluster.local
1769 _PORT=2379
1770 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridged18f4942020-04-14 16:46:13 -07001771 elif [ "$WITH_ETCD" == "external" ]; then
David Bainbridge3517f6c2020-04-08 12:14:08 -07001772 _HOST=etcd-cluster-client.$INFRA_NS.svc.cluster.local
1773 _PORT=2379
1774 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridged18f4942020-04-14 16:46:13 -07001775 elif [ "$WITH_ETCD" != "no" ]; then
1776 _HOST="$(echo "$WITH_ETCD" | cut -d: -f1)"
1777 _PORT="$(echo "$WITH_ETCD" | cut -s -d: -f2)"
David Bainbridge3517f6c2020-04-08 12:14:08 -07001778 _PORT=${_PORT:-2379}
1779 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridge696bc632020-04-05 21:49:37 -07001780 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001781 if [ "$WITH_KAFKA" == "yes" ]; then
David Bainbridge3517f6c2020-04-08 12:14:08 -07001782 _HOST=voltha-kafka.$VOLTHA_NS.svc.cluster.local
1783 _PORT=9092
1784 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafka_broker=$_HOST:$_PORT --set services.kafka.adapter.service=$_HOST --set services.kafka.adapter.port=$_PORT --set services.kafka.cluster.service=$_HOST --set services.kafka.cluster.port=$_PORT"
David Bainbridged18f4942020-04-14 16:46:13 -07001785 elif [ "$WITH_KAFKA" == "external" ]; then
David Bainbridge3517f6c2020-04-08 12:14:08 -07001786 _HOST=kafka.$INFRA_NS.svc.cluster.local
1787 _PORT=9092
1788 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafka_broker=$_HOST:$_PORT --set services.kafka.adapter.service=$_HOST --set services.kafka.adapter.port=$_PORT --set services.kafka.cluster.service=$_HOST --set services.kafka.cluster.port=$_PORT"
David Bainbridged18f4942020-04-14 16:46:13 -07001789 elif [ "$WITH_KAFKA" != "no" ]; then
1790 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
1791 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge3517f6c2020-04-08 12:14:08 -07001792 _PORT=${_PORT:-9092}
1793 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafka_broker=$_HOST:$_PORT --set services.kafka.adapter.service=$_HOST --set services.kafka.adapter.port=$_PORT --set services.kafka.cluster.service=$_HOST --set services.kafka.cluster.port=$_PORT"
David Bainbridge696bc632020-04-05 21:49:37 -07001794 fi
David Bainbridge46505fb2019-10-01 21:13:20 +00001795 echo -e "Verify Adapters $PLUG"
1796 if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then
1797 bspin - "Verify Simulated Adapters installed"
David Bainbridged18f4942020-04-14 16:46:13 -07001798 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$ADAPTER_NS" "^sim\$" | wc -l)" -ne 1 ]; then
1799 espin - "$NOT_VERIFIED"
1800 helm_install - "$ADAPTER_NS" sim "$VOLTHA_ADAPTER_SIM_CHART" "$VOLTHA_ADAPTER_SIM_CHART_VERSION" "$_HELM_DESC Simulated Adapters"
David Bainbridge46505fb2019-10-01 21:13:20 +00001801 else
David Bainbridged18f4942020-04-14 16:46:13 -07001802 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00001803 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001804 EXPECT="$((EXPECT + 2))"
David Bainbridge46505fb2019-10-01 21:13:20 +00001805 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001806
David Bainbridge46505fb2019-10-01 21:13:20 +00001807 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
1808 bspin - "Verify OpenOLT Adapter installed"
David Bainbridged18f4942020-04-14 16:46:13 -07001809 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$ADAPTER_NS" "^open-olt\$" | wc -l)" -ne 1 ]; then
1810 espin - "$NOT_VERIFIED"
1811 helm_install - "$ADAPTER_NS" open-olt "$VOLTHA_ADAPTER_OPEN_OLT_CHART" "$VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION" "$_HELM_DESC OpenOLT Adapter"
David Bainbridge46505fb2019-10-01 21:13:20 +00001812 else
David Bainbridged18f4942020-04-14 16:46:13 -07001813 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00001814 fi
Matteo Scandolo67335f02020-04-09 11:19:53 -07001815 EXPECT="$((EXPECT + 1))"
David Bainbridge46505fb2019-10-01 21:13:20 +00001816 bspin - "Verify OpenONU Adapter installed"
David Bainbridged18f4942020-04-14 16:46:13 -07001817 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$ADAPTER_NS" "^open-onu\$" | wc -l)" -ne 1 ]; then
Matteo Scandolo67335f02020-04-09 11:19:53 -07001818 _ORIGINAL_EXTRA_HELM_INSTALL_ARGS="$INTERNAL_EXTRA_HELM_INSTALL_ARGS"
1819 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set replicas.adapter_open_onu=$NUM_OF_OPENONU"
David Bainbridged18f4942020-04-14 16:46:13 -07001820 espin - "$NOT_VERIFIED"
Matteo Scandolo67335f02020-04-09 11:19:53 -07001821 helm_install - "$ADAPTER_NS" open-onu "$VOLTHA_ADAPTER_OPEN_ONU_CHART" "$VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION" "$_HELM_DESC OpenONU Adapter"
1822 INTERNAL_EXTRA_HELM_INSTALL_ARGS="$_ORIGINAL_EXTRA_HELM_INSTALL_ARGS"
David Bainbridge46505fb2019-10-01 21:13:20 +00001823 else
David Bainbridged18f4942020-04-14 16:46:13 -07001824 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00001825 fi
Matteo Scandolo67335f02020-04-09 11:19:53 -07001826 EXPECT=$((EXPECT + NUM_OF_OPENONU))
David Bainbridge46505fb2019-10-01 21:13:20 +00001827 fi
David Bainbridge696bc632020-04-05 21:49:37 -07001828 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001829
David Bainbridge46505fb2019-10-01 21:13:20 +00001830 ADAPTERS="adapter-.*"
David Bainbridged18f4942020-04-14 16:46:13 -07001831 wait_for_pods - "$ADAPTER_NS" "$EXPECT" "includes" "Waiting for adapters to start" "$NO_LABEL" "$ADAPTERS"
David Bainbridge46505fb2019-10-01 21:13:20 +00001832 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001833 NOW="$(date +%s)"
1834 printtime $((NOW - STIME))
David Bainbridge46505fb2019-10-01 21:13:20 +00001835 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001836fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001837
David Bainbridged18f4942020-04-14 16:46:13 -07001838if [ "$WITH_BBSIM" == "yes" ]; then
1839 STIME="$(date +%s)"
Test User7d866122019-07-09 17:52:35 +00001840 echo -e "Verify BBSIM $PLUG"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001841 bspin - "Verify BBSIM Installed"
David Bainbridged18f4942020-04-14 16:46:13 -07001842 for instance in $(seq 0 $((NUM_OF_BBSIM-1))); do
1843 if [ "$instance" -eq 0 ]; then
David K. Bainbridge43422402020-03-06 07:41:22 -08001844 instance_num=""
1845 else
1846 instance_num=$instance
1847 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001848 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$BBSIM_NS" "^bbsim${instance_num}\$" | wc -l)" -ne 1 ]; then
1849 espin - "$NOT_VERIFIED"
1850 S_TAG="$((900+instance))"
Matteo Scandolo5a149572020-04-01 10:14:57 -07001851 INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set olt_id=$instance,s_tag=$S_TAG"
David Bainbridged18f4942020-04-14 16:46:13 -07001852 helm_install - "$BBSIM_NS" "bbsim${instance_num}" "$VOLTHA_BBSIM_CHART" "$VOLTHA_BBSIM_CHART_VERSION" "$_HELM_DESC BBSIM${instance_num}"
David Bainbridge2eaf2cf2020-03-18 12:54:08 -07001853 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
David K. Bainbridge43422402020-03-06 07:41:22 -08001854 else
David Bainbridged18f4942020-04-14 16:46:13 -07001855 espin - "$VERIFIED"
David K. Bainbridge43422402020-03-06 07:41:22 -08001856 fi
1857 done
David Bainbridged18f4942020-04-14 16:46:13 -07001858 wait_for_pods - "$BBSIM_NS" "$NUM_OF_BBSIM" "includes" "Waiting for BBSIM to start" "$BBSIM_LABEL" "bbsim*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001859 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001860 NOW="$(date +%s)"
1861 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001862 fi
Test User7d866122019-07-09 17:52:35 +00001863fi
1864
David Bainbridged18f4942020-04-14 16:46:13 -07001865if [ "$WITH_RADIUS" == "yes" ]; then
1866 STIME="$(date +%s)"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001867 echo -e "Verify RADIUS $LOCK"
1868 bspin - "Verify RADIUS Installed"
David Bainbridged18f4942020-04-14 16:46:13 -07001869 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^radius\$" | wc -l)" -ne 1 ]; then
1870 espin - "$NOT_VERIFIED"
1871 helm_install - "$INFRA_NS" radius onf/freeradius latest "$_HELM_DESC RADIUS"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001872 else
David Bainbridged18f4942020-04-14 16:46:13 -07001873 espin - "$VERIFIED"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001874 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001875 wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for RADIUS to start" "$NO_LABEL" "radius-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001876 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001877 NOW="$(date +%s)"
1878 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001879 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001880fi
1881
David Bainbridged18f4942020-04-14 16:46:13 -07001882if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
1883 STIME="$(date +%s)"
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001884 bspin - "Forward VOLTHA API port $FORWARD"
1885 kill_port_forward voltha-api
David Bainbridged18f4942020-04-14 16:46:13 -07001886 port_forward "$VOLTHA_NS" voltha-api "$VOLTHA_API_PORT" 55555
1887 espin - "$VERIFIED"
1888 if [ "$WITH_ETCD" == "yes" ] || [ "$WITH_ETCD" == "external" ]; then
1889 _NS="$(test "$WITH_ETCD" == "yes" && echo "$VOLTHA_NS" || echo "$INFRA_NS")"
David Bainbridge696bc632020-04-05 21:49:37 -07001890 bspin - "Forward VOLTHA ETCD port $FORWARD"
David Bainbridged18f4942020-04-14 16:46:13 -07001891 kill_port_forward "${ETCD_PREFIX}etcd-cluster-client"
1892 port_forward "$_NS" "${ETCD_PREFIX}etcd-cluster-client" "$VOLTHA_ETCD_PORT" 2379
1893 espin - "$VERIFIED"
David Bainbridge696bc632020-04-05 21:49:37 -07001894 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001895 if [ "$WITH_KAFKA" == "yes" ] || [ $WITH_KAFKA == "external" ]; then
1896 _NS="$(test "$WITH_ETCD" == "yes" && echo "$VOLTHA_NS" || echo "$INFRA_NS")"
David Bainbridge696bc632020-04-05 21:49:37 -07001897 bspin - "Forward VOLTHA Kafka port $FORWARD"
David Bainbridged18f4942020-04-14 16:46:13 -07001898 kill_port_forward "${KAFKA_PREFIX}kafka"
1899 port_forward "$_NS" ${KAFKA_PREFIX}kafka "$VOLTHA_KAFKA_PORT" 9092
1900 espin - "$VERIFIED"
David Bainbridge696bc632020-04-05 21:49:37 -07001901 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001902 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001903 NOW="$(date +%s)"
1904 printtime $((NOW - STIME))
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001905 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001906fi
Test User3d7ad8e2019-07-03 06:15:44 +00001907
David Bainbridged18f4942020-04-14 16:46:13 -07001908if [ "$WITH_ONOS" == "yes" ] && [ "$WITH_RADIUS" != "no" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -07001909 _HOST=radius.$INFRA_NS.svc.cluster.local
David Bainbridge696bc632020-04-05 21:49:37 -07001910 _PORT=1812
David Bainbridged18f4942020-04-14 16:46:13 -07001911 if [ "$WITH_RADIUS" != "yes" ]; then
1912 _HOST="$(echo "$WITH_RADIUS" | cut -d: -f1)"
1913 _PORT="$(echo "$WITH_RADIUS" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07001914 _PORT=${_PORT:-1812}
1915 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001916 bspin "Configure ONOS RADIUS Connection $GEAR"
David Bainbridged18f4942020-04-14 16:46:13 -07001917 (set -x; sed -e "s/:RADIUS_SVC:/$_HOST/g" -e "s/:RADIUS_PORT:/$_PORT/" onos-files/onos-aaa.json | 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
1918 espin "$VERIFIED"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001919fi
1920
David Bainbridge99ac7a22019-08-31 02:26:43 +00001921if [ "$WITH_CHAOS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001922 STIME="$(date +%s)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001923 echo -e "Verify kube-monkey $LOCK"
1924 bspin - "Verify kube-monkey Installed"
David Bainbridged18f4942020-04-14 16:46:13 -07001925 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace kube-monkey "^monkey\$" | wc -l)" -ne 1 ]; then
1926 espin - "$NOT_VERIFIED"
David Bainbridge7f8bf992020-04-08 21:53:22 -07001927 helm_install - kube-monkey monkey ./kube-monkey/helm/kubemonkey latest "$_HELM_DESC Chaos Monkey"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001928 else
David Bainbridged18f4942020-04-14 16:46:13 -07001929 espin - "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001930 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001931 wait_for_pods - "kube-monkey" 1 "includes" "Waiting for Chaos to start" "$NO_LABEL" "monkey-.*"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001932 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001933 NOW="$(date +%s)"
1934 printtime $((NOW - STIME))
David Bainbridge99ac7a22019-08-31 02:26:43 +00001935 fi
1936fi
1937
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001938bspin "Create voltctl configuration file"
David Bainbridged18f4942020-04-14 16:46:13 -07001939(set -x; mkdir -p "$HOME/.volt" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1940MIN_VC_VERSION="$(echo -e "1.0.15\n$VC_VERSION" | sort -V | head -1)"
1941if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001942 KAFKA_FLAG="-k localhost:$VOLTHA_KAFKA_PORT"
1943 SERVER_FLAG="-s localhost:$VOLTHA_API_PORT"
1944 ETCD_FLAG=
1945 if [ "$MIN_VC_VERSION" == "1.0.15" ]; then
1946 ETCD_FLAG="-e localhost:$VOLTHA_ETCD_PORT"
1947 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001948else
David Bainbridged18f4942020-04-14 16:46:13 -07001949 KAFKA_FLAG="-k $(get_service_ep "$INFRA_NS" "${KAFKA_PREFIX}kafka")"
1950 SERVER_FLAG="-s $(get_service_ep "$VOLTHA_NS" voltha-api)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001951 ETCD_FLAG=
1952 if [ "$MIN_VC_VERSION" == "1.0.15" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001953 ETCD_FLAG="-e $(get_service_ep "$INFRA_NS" ${ETCD_PREFIX}etcd-client)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001954 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001955fi
David Bainbridged18f4942020-04-14 16:46:13 -07001956CMD=("voltctl -a v3 $KAFKA_FLAG $SERVER_FLAG $ETCD_FLAG config")
1957(set -x; ${CMD[*]} > "$HOME/.volt/config-$NAME" 2>>"$LOG") >>"$LOG" 2>&1
1958#(set -x; voltctl -a v3 "$KAFKA_FLAG" "$SERVER_FLAG" "$ETCD_FLAG" config > "$HOME/.volt/config-$NAME" 2>>"$LOG") >>"$LOG" 2>&1
1959espin "$VERIFIED"
Test User08ebbd92019-07-03 17:15:39 +00001960
David Bainbridge0774b232019-08-02 06:37:19 +00001961if [ ! -f "$NAME-env.sh" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001962 touch "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001963fi
1964
David Bainbridge596f30d2019-07-30 17:07:59 +00001965for O in $ALL_OPTIONS; do
David Bainbridged18f4942020-04-14 16:46:13 -07001966 VAL="$(eval echo "\$$O")"
1967 if [ -n "$VAL" ] && [ "$(grep -c "^export $O=" "$NAME-env.sh")" -eq 0 ]; then
1968 echo "export $O=\"$(eval echo "\$$O")\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001969 fi
1970done
1971
David Bainbridged18f4942020-04-14 16:46:13 -07001972if [ "$DEPLOY_K8S" == "yes" ] && [ "$(grep -c "^export KUBECONFIG=" "$NAME-env.sh")" -eq 0 ]; then
1973 echo "export KUBECONFIG=\"$(./bin/kind get kubeconfig-path "--name=voltha-$NAME")\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001974fi
1975
David Bainbridged18f4942020-04-14 16:46:13 -07001976if [ "$(grep -c "^export VOLTCONFIG=" "$NAME-env.sh")" -eq 0 ]; then
1977 echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001978fi
1979
David Bainbridged18f4942020-04-14 16:46:13 -07001980if [ "$(grep -c "^export PATH=" "$NAME-env.sh")" -eq 0 ]; then
1981 echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001982fi
1983
Test User7d866122019-07-09 17:52:35 +00001984echo ""
David Bainbridged18f4942020-04-14 16:46:13 -07001985echo "Please issue the following commands in your terminal to ensure that you" | tee -a "$LOG"
1986echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a "$LOG"
1987echo "tools required by VOLTHA in your command path. " | tee -a "$LOG"
1988echo "" | tee -a "$LOG"
1989echo -en "$BOLD"
1990if [ "$DEPLOY_K8S" == "yes" ]; then
1991 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00001992fi
David Bainbridged18f4942020-04-14 16:46:13 -07001993echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" | tee -a "$LOG"
1994echo "export PATH=$GOPATH/bin:\$PATH" | tee -a "$LOG"
1995echo -en "$NORMAL"
1996echo "" | tee -a "$LOG"
1997echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a "$LOG"
Test User08ebbd92019-07-03 17:15:39 +00001998
David Bainbridge712afb82019-08-14 19:55:58 +00001999if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002000 NOW="$(date +%s)"
2001 echo -e "$CLOCK ${BOLD}TOTAL: $(duration $((NOW - TOTAL_START_TIME)))${NORMAL}"
David Bainbridge712afb82019-08-14 19:55:58 +00002002fi