blob: 6ac1be7b7b15654631d6de8257c3bd260f274ad3 [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
David Bainbridgeac7f8072019-08-01 22:15:33 +0000781if [ "$1" == "down" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000782 echo "Tearing down voltha cluster $NAME"
783 LOG="down-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -0700784 date -u +"%Y%m%dT%H%M%SZ" >"$LOG"
785 if [ "$WITH_ONOS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700786 bspin "Remove port-forwards: onos-ui-$NAME"
787 kill_port_forward onos-ui
788 sspin "Remove port-forwards: onos-ssh-$NAME$CEOL"
789 kill_port_forward onos-ssh
790 fi
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800791 sspin "Remove port-forwards: voltha-api-$NAME$CEOL"
792 kill_port_forward voltha-api
David Bainbridged18f4942020-04-14 16:46:13 -0700793 if [ "$WITH_ETCD" == "yes" ] || [ "$WITH_ETCD" == "external" ]; then
794 sspin "Remove port-forwards: ${ETCD_PREFIX}etcd-$NAME$CEOL"
795 kill_port_forward "${ETCD_PREFIX}etcd-cluster-client"
David Bainbridge696bc632020-04-05 21:49:37 -0700796 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700797 if [ "$WITH_KAFKA" == "yes" ] || [ "$WITH_KAFKA" == "external" ]; then
798 sspin "Remove port-forwards: ${KAFKA_PREFIX}kafka-$NAME$CEOL"
799 kill_port_forward "${KAFKA_PREFIX}kafka"
David Bainbridge696bc632020-04-05 21:49:37 -0700800 fi
801
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800802 espin "$VERIFIED Remove port-forwards$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -0700803 if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridgeac7f8072019-08-01 22:15:33 +0000804 if [ -x ./bin/kind ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000805 bspin "Delete Kubernetes Kind Cluster"
David Bainbridged18f4942020-04-14 16:46:13 -0700806 (set -x; ./bin/kind delete cluster --name "voltha-$NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
807 espin "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000808 else
David Bainbridge0774b232019-08-02 06:37:19 +0000809 espin "$NO_ENTRY Delete Kubernetes Kind Cluster: kind command not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000810 fi
811 else
David Bainbridged18f4942020-04-14 16:46:13 -0700812 EXISTS="$(helm list -q)"
David Bainbridge76afd812020-04-06 09:53:52 -0700813 EXPECT="voltha"
David Bainbridged18f4942020-04-14 16:46:13 -0700814 if [ "$WITH_ONOS" == yes ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700815 EXPECT+=" onos"
816 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700817 if [ "$WITH_RADIUS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700818 EXPECT+=" radius"
819 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700820 if [ "$WITH_BBSIM" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700821 EXPECT+=" bbsim"
822 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700823 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700824 EXPECT+=" open-olt open-onu"
825 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700826 if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700827 EXPECT+=" sim"
828 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700829 if [ "$WITH_ETCD" == "external" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700830 EXPECT+=" etcd-operator etcd-cluster"
David Bainbridged18f4942020-04-14 16:46:13 -0700831 elif [ "$WITH_ETCD" == "yes" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700832 EXPECT+=" etcd-operator"
833 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700834 if [ "$WITH_KAFKA" == "external" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700835 EXPECT+=" kafka"
836 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000837 bspin "Remove Helm Deployments"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000838 for i in $EXISTS; do
David K. Bainbridge43422402020-03-06 07:41:22 -0800839 for j in $EXPECT; do
David Bainbridged18f4942020-04-14 16:46:13 -0700840 if [[ "$i" =~ $j ]]; then
David K. Bainbridge43422402020-03-06 07:41:22 -0800841 sspin "Remove Helm Deployments: $i$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -0700842 (set -x; ./bin/helm delete --no-hooks --purge "$i" >>"$LOG" 2>&1) >>"$LOG" 2>&1
David K. Bainbridge43422402020-03-06 07:41:22 -0800843 fi
844 done
uottrembb16d3982020-02-28 08:34:36 +0100845 done
David Bainbridge0774b232019-08-02 06:37:19 +0000846 espin "$VERIFIED Remove Helm Deployments$CEOL"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000847 if [ "$WAIT_ON_DOWN" == "yes" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700848 PODS="voltha-kafka.* voltha-ofagent.* voltha-rw-core.* voltha-etcd.*"
849 INFRA_PODS=
850 ADAPT_PODS=
851 SIM_PODS=
David Bainbridged18f4942020-04-14 16:46:13 -0700852 if [ "$WITH_RADIUS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700853 PODS+=" radius.*"
854 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700855 if [ "$WITH_BBSIM" == "yes" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700856 SIM_PODS+=" bbsim.*"
David Bainbridge696bc632020-04-05 21:49:37 -0700857 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700858 if [ "$WITH_OPEN_ADAPTERS" ] || [ "$WITH_SIM_ADAPTERS" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700859 ADAPT_PODS+=" adapter-*"
David Bainbridge696bc632020-04-05 21:49:37 -0700860 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700861 if [ "$WITH_ONOS" == "yes" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700862 INFRA_PODS+=" onos-.*"
863 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700864 if [ "$WITH_ETCD" == "external" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700865 INFRA_PODS+=" etcd-operator.* etcd-cluster.*"
David Bainbridged18f4942020-04-14 16:46:13 -0700866 elif [ "$WITH_ETCD" == "yes" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700867 PODS+=" etcd-operator.*"
868 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700869 if [ "$WITH_KAFKA" == "external" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700870 INFRA_PODS+=" kafka.*"
871 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700872 if [ -n "$SIM_PODS" ]; then
873 wait_for_pods "$BBSIM_NS" 0 "not" "Waiting for BBSIM PODs to terminate" "$BBSIM_LABEL" "$SIM_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -0700874 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700875 if [ -n "$INFRA_PODS" ]; then
876 wait_for_pods "$INFRA_NS" 0 "not" "Waiting for infrastructure PODs to terminate" "$NO_LABEL" "$INFRA_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -0700877 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700878 if [ -n "$ADAPT_PODS" ]; then
879 wait_for_pods "$ADAPTER_NS" 0 "not" "Waiting for adapter PODs to terminate" "$NO_LABEL" "$ADAPT_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -0700880 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700881 wait_for_pods "$VOLTHA_NS" 0 "not" "Waiting for VOLTHA PODs to terminate" "$NO_LABEL" "$PODS"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000882 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +0000883 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -0700884 exit
David Bainbridgeac7f8072019-08-01 22:15:33 +0000885fi
886
887if [ "$1" == "dump" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000888 LOG="dump-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -0700889 TS="$(date -u +"%Y%m%dT%H%M%SZ")"
890 if [ -n "$DUMP_FROM" ]; then
891 TS=${DUMP_FROM//[:-]}
David Bainbridge76514a02019-10-08 01:50:35 +0000892 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700893 WORK="$(mktemp -u -d)"
David Bainbridge0774b232019-08-02 06:37:19 +0000894 DATA=$WORK/voltha-debug-dump-$NAME-$TS
David Bainbridged18f4942020-04-14 16:46:13 -0700895 mkdir -p "$DATA"
896 echo "$TS" > "$LOG"
David Bainbridge0774b232019-08-02 06:37:19 +0000897 echo -e "Capturing debug dump to voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000898 bspin - "Copy install log"
David Bainbridged18f4942020-04-14 16:46:13 -0700899 if [ -f "install-$NAME.log" ]; then
900 (set -x; cp "install-$NAME.log" "$DATA/install-$NAME.log") >>"$LOG" 2>&1
901 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000902 else
David Bainbridge0774b232019-08-02 06:37:19 +0000903 espin - "$NO_ENTRY Copy install log: install-$NAME.log not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000904 fi
905 bspin - "Dumping Kubernetes PODs"
David Bainbridged18f4942020-04-14 16:46:13 -0700906 (set -x; kubectl get --all-namespaces pods >> "$DATA/all-pods.txt" 2>&1) >>"$LOG" 2>&1
907 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000908 bspin - "Dumping Kubernetes SERVICEs"
David Bainbridged18f4942020-04-14 16:46:13 -0700909 (set -x; kubectl get --all-namespaces svc >> "$DATA/all-services.txt" 2>&1) >>"$LOG" 2>&1
910 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000911 bspin - "Dumping Kubernetes EVENTs"
David Bainbridged18f4942020-04-14 16:46:13 -0700912 (set -x; kubectl get --all-namespaces events >> "$DATA/all-events.txt" 2>&1) >>"$LOG" 2>&1
913 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000914 bspin - "Dumping VOLTHA POD details"
David Bainbridged18f4942020-04-14 16:46:13 -0700915 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 +0000916 SINCE=
David Bainbridged18f4942020-04-14 16:46:13 -0700917 if [ -n "$DUMP_FROM" ]; then
David Bainbridgecfd7ca12019-10-06 03:31:41 +0000918 SINCE="--since-time=$DUMP_FROM"
919 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +0000920 for POD in $PODS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700921 NS="$(echo "$POD" | cut -d: -f1)"
922 POD="$(echo "$POD" | cut -d: -f2)"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000923 sspin - "Dumping VOLTHA POD details: $POD$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -0700924 mkdir -p "$DATA/$POD"
925 (set -x; kubectl describe -n "$NS" "$POD" >> "$DATA/$POD/describe.txt" 2>&1) >>"$LOG" 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000926 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridged18f4942020-04-14 16:46:13 -0700927 (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 +0000928 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridged18f4942020-04-14 16:46:13 -0700929 (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 +0000930 sspin - "Dumping VOLTHA POD details: $POD"
931 done
932 espin - "$VERIFIED Dumping VOLTHA POD details$CEOL"
933 bspin - "Dumping ETCD"
David Bainbridged18f4942020-04-14 16:46:13 -0700934 if [ -n "$(command -v etcdctl)" ]; then
935 (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
936 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000937 else
938 espin - "$NO_ENTRY Dumping ETCD: etcdctl command not available"
939 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000940 bspin - "Creating compressed TAR: voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridged18f4942020-04-14 16:46:13 -0700941 (set -x; tar -C "$WORK" -zcf "voltha-debug-dump-$NAME-$TS.tgz" "./voltha-debug-dump-$NAME-$TS") >>"$LOG" 2>&1
942 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000943 bspin - "Cleanup"
David Bainbridged18f4942020-04-14 16:46:13 -0700944 (set -x; rm -rf "$WORK") >>"$LOG" 2>&1
945 espin - "$VERIFIED"
946 bspin - "$(ls -l "voltha-debug-dump-$NAME-$TS.tgz")"
947 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000948 exit
949fi
950
David Bainbridge0774b232019-08-02 06:37:19 +0000951LOG="install-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -0700952date > "$LOG"
953echo "PORTS=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT" >> "$LOG"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000954
955# Output install options to log
David Bainbridged18f4942020-04-14 16:46:13 -0700956echo "OPTIONS" >> "$LOG"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000957for O in $ALL_OPTIONS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700958 VAL="$(eval echo "\$$O")"
959 if [ -n "$VAL" ]; then
960 printf " %-30s = %s\n" "$O" "$VAL" >> "$LOG"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000961 fi
962done
963
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -0700964helm_install() {
David Bainbridged18f4942020-04-14 16:46:13 -0700965 local INDENT NOW
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700966 if [ "$1" == "-" ]; then
967 INDENT=$1; shift
968 fi
969 local NAMESPACE=$1; shift
David Bainbridge0774b232019-08-02 06:37:19 +0000970 local INAME=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700971 local CHART=$1; shift
David Bainbridge90fd8e32019-08-21 23:32:47 +0000972 local CHART_VERSION=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700973 local MESSAGE=$*
974
David Bainbridged18f4942020-04-14 16:46:13 -0700975 if [ "$CHART_VERSION X" != " X" ] && [ "$CHART_VERSION" != "latest" ]; then
David Bainbridge90fd8e32019-08-21 23:32:47 +0000976 CHART_VERSION="--version $CHART_VERSION"
977 else
978 CHART_VERSION=
979 fi
980
David Bainbridge99ac7a22019-08-31 02:26:43 +0000981 local CHART_ARGS=
982 if [ -r "${INAME}-values.yaml" ]; then
983 CHART_ARGS="-f ${INAME}-values.yaml"
984 fi
985
David Bainbridged18f4942020-04-14 16:46:13 -0700986 local WAIT_START CMD
987 WAIT_START="$(date +%s)"
988 COUNT="$((300 / 15))"
989 bspin "$INDENT" "$MESSAGE"
990 if [ "$HELM_USE_UPGRADE" == "yes" ]; then
David Bainbridge7f8bf992020-04-08 21:53:22 -0700991 _HELM_COMMAND="upgrade --install"
992 _HELM_ARGS="$INAME"
993 else
994 _HELM_COMMAND="install"
995 _HELM_ARGS="--name $INAME"
996 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700997 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")
998 (set -x; ${CMD[*]} >>"$LOG" 2>&1) >>"$LOG" 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700999 SUCCESS=$?
David Bainbridged18f4942020-04-14 16:46:13 -07001000 while [ "$SUCCESS" -ne 0 ]; do
1001 NOW="$(date +%s)"
1002 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -07001003 espin "$THEX"
1004 doTimeout "waiting for helm install $CHART"
1005 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001006 sspin "$INDENT"
1007 COUNT="$((COUNT - 1))"
1008 if [ "$COUNT" -eq 0 ]; then
1009 if [ "$HELM_USE_UPGRADE" == "no" ]; then
1010 (set -x; helm delete --purge "$INAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
David Bainbridge7f8bf992020-04-08 21:53:22 -07001011 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001012 (set -x; ${CMD[*]} >>"$LOG" 2>&1) >>"$LOG" 2>&1
Andy Baviere22ff252019-12-19 11:40:31 -07001013 SUCCESS=$?
David Bainbridged18f4942020-04-14 16:46:13 -07001014 COUNT="$((300 / 15))"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001015 fi
1016 sleep .15
1017 done
David Bainbridged18f4942020-04-14 16:46:13 -07001018 espin "$INDENT" "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001019}
1020
David Bainbridged18f4942020-04-14 16:46:13 -07001021echo "INSTALL TYPE: $TYPE" >> "$LOG"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001022
1023bspin "Verify GOPATH"
David Bainbridged18f4942020-04-14 16:46:13 -07001024GOPATH="$(pwd)"; export GOPATH
1025mkdir -p "$GOPATH/bin"
1026espin "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001027
David Bainbridged18f4942020-04-14 16:46:13 -07001028STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001029if [ "$INSTALL_KUBECTL" == "no" ]; then
1030 bspin "Skip kubectl install"
1031 espin $NO_ENTRY
Test Userc13bdc92019-07-03 20:57:49 +00001032else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001033 bspin "Verify kubectl $HELM"
David Bainbridged18f4942020-04-14 16:46:13 -07001034 if [ -x "$GOPATH/bin/kubectl" ]; then
1035 espin "$VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001036 else
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001037 ERR_OUT="$(mktemp)"
David Bainbridged18f4942020-04-14 16:46:13 -07001038 espin "$NOT_VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001039 bspin - "Download and install Kubernetes/kubectl $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001040 (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
1041 RESULT=$?
1042 if [ "$RESULT" -ne 0 ]; then
1043 espin - "$THEX"
1044 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download kubectl: $(tail $ERR_OUT)${NORMAL}"
1045 cat "$ERR_OUT" >> "$LOG"
1046 rm -rf $"ERR_OUT" "$GOPATH/bin/kubectl"
1047 exit 1
1048 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001049 (set -x; chmod 755 "$GOPATH/bin/kubectl" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1050 espin - "$VERIFIED"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001051 rm -rf "$ERR_OUT"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001052 fi
Test Userc13bdc92019-07-03 20:57:49 +00001053fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001054if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001055 NOW="$(date +%s)"
1056 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001057fi
Test Userc13bdc92019-07-03 20:57:49 +00001058
David Bainbridged18f4942020-04-14 16:46:13 -07001059STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001060if [ "$DEPLOY_K8S" == "no" ]; then
1061 bspin "Skip Kubernetes/Kind Deployment"
1062 espin $NO_ENTRY
1063else
Test Userba1e7e72019-07-10 22:27:54 +00001064 bspin "Verify Kubernetes/Kind $HELM"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001065 IS_INSTALLED=0
1066 OP_TYPE="install"
David Bainbridged18f4942020-04-14 16:46:13 -07001067 if [ -x "$GOPATH/bin/kind" ]; then
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001068 OP_TYPE="upgrade"
David Bainbridged18f4942020-04-14 16:46:13 -07001069 if [ "$("$GOPATH/bin/kind" --version | grep -c "$KIND_VERSION")" -eq 1 ]; then
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001070 IS_INSTALLED=1
David Bainbridged18f4942020-04-14 16:46:13 -07001071 espin "$VERIFIED"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001072 fi
1073 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001074 if [ "$IS_INSTALLED" -eq 0 ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001075 ERR_OUT="$(mktemp)"
David Bainbridged18f4942020-04-14 16:46:13 -07001076 espin "$NOT_VERIFIED"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001077 bspin - "Download and $OP_TYPE Kubernetes/kind $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001078 (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
1079 RESULT=$?
1080 if [ $RESULT -ne 0 ]; then
1081 espin - "$THEX"
1082 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download kind: $(tail $ERR_OUT)${NORMAL}"
1083 cat "$ERR_OUT" >> "$LOG"
1084 rm -rf $"ERR_OUT" "$GOPATH/bin/kind"
1085 exit 1
1086 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001087 (set -x; chmod 755 "$GOPATH/bin/kind" >>"$LOG" 2>&1) >>"$LOG" 2>&1
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001088 rm -rf "$ERR_OUT"
David Bainbridged18f4942020-04-14 16:46:13 -07001089 espin - "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001090 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001091fi
1092
David Bainbridgee87067b2019-08-12 22:00:12 +00001093if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001094 NOW="$(date +%s)"
1095 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001096fi
1097
David Bainbridged18f4942020-04-14 16:46:13 -07001098STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001099if [ "$INSTALL_HELM" == "no" ]; then
1100 bspin "Skip Helm Install"
1101 espin $NO_ENTRY
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001102else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001103 bspin "Verify Helm $HELM"
David Bainbridgea34993d2020-04-01 09:15:42 -07001104 HELM_UPGRADE=0
1105 HELM_UPGRADE_DESC="install"
David Bainbridged18f4942020-04-14 16:46:13 -07001106 if [ -x "$GOPATH/bin/helm" ]; then
1107 HAVE_VER="$("$GOPATH/bin/helm" version -c --template '{{.Client.SemVer}}')"
1108 HELM_UP_DOWN="$(echo -e "$HAVE_VER\n$HELM_VERSION" | sort -V | head -1)"
1109 if [ "$HAVE_VER" != "$HELM_VERSION" ]; then
1110 if [ "$HELM_UP_DOWN" == "$HELM_VERSION" ]; then
David Bainbridgea34993d2020-04-01 09:15:42 -07001111 HELM_UPGRADE_DESC="downgrade"
1112 else
1113 HELM_UPGRADE_DESC="upgrade"
1114 fi
1115 HELM_UPGRADE=1
1116 else
David Bainbridged18f4942020-04-14 16:46:13 -07001117 espin "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001118 fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001119 else
David Bainbridgea34993d2020-04-01 09:15:42 -07001120 HELM_UPGRADE=1
1121 fi
1122
David Bainbridged18f4942020-04-14 16:46:13 -07001123 if [ "$HELM_UPGRADE" -ne 0 ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001124 ERR_OUT="$(mktemp)"
1125 INSTALL_HELM_BIN=$(mktemp)
David Bainbridged18f4942020-04-14 16:46:13 -07001126 espin "$NOT_VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001127 bspin - "Download and $HELM_UPGRADE_DESC Helm $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001128 (set -x; curl -o "$INSTALL_HELM_BIN" --fail -sSL https://git.io/get_helm.sh >>"$LOG" 2>"$ERR_OUT") >>"$LOG" 2>&1
1129 RESULT=$?
1130 if [ $RESULT -ne 0 ]; then
1131 espin - "$THEX"
1132 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download helm installer: $(tail $ERR_OUT)${NORMAL}"
1133 cat "$ERR_OUT" >> "$LOG"
1134 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT" "$GOPATH/bin/helm" "$GOPATH/bin/tiller"
1135 exit 1
1136 fi
1137 rm -rf "$ERR_OUT"
1138 chmod +x "$INSTALL_HELM_BIN"
1139 (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
1140 RESULT=$?
1141 if [ $RESULT -ne 0 ]; then
1142 espin - "$THEX"
1143 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to install helm, see install log for details${NORMAL}"
1144 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT" "$GOPATH/bin/helm" "$GOPATH/bin/tiller"
1145 exit 1
1146 fi
1147 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT"
David Bainbridged18f4942020-04-14 16:46:13 -07001148 espin - "$VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001149 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001150fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001151if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001152 NOW="$(date +%s)"
1153 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001154fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001155
David Bainbridged18f4942020-04-14 16:46:13 -07001156STIME="$(date +%s)"
Test Userb5712372019-07-03 21:52:17 +00001157bspin "Verify voltctl $HIGH_VOLTAGE"
David Bainbridged2811972019-12-14 01:14:09 +00001158VOK=0
1159VMESSAGE="install"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001160ERR_OUT=$(mktemp)
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001161export VC_VERSION="$VOLTCTL_VERSION"
1162if [ "$VC_VERSION" == "latest" ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001163 set -o pipefail # TODO: would be nice to run all in pipefail mode
1164 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')"
1165 RESULT=$?
1166 set +o pipefail
1167 if [ "$RESULT" -ne 0 ]; then
1168 espin - "$THEX"
1169 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to determine released version of voltctl: $(cat "$ERR_OUT")${NORMAL}"
1170 rm -rf "$ERR_OUT" "$GOPATH/bin/voltctl"
1171 exit 1
1172 fi
1173 export VC_VERSION
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001174fi
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001175
David Bainbridged18f4942020-04-14 16:46:13 -07001176if [ -x "$GOPATH/bin/voltctl" ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001177 VHAVE="$("$GOPATH/bin/voltctl" version --clientonly -o json 2>/dev/null | jq -r .version)"
David Bainbridged18f4942020-04-14 16:46:13 -07001178 RESULT=$?
1179 if [ $RESULT -eq 0 ] && [ "$VHAVE" == "$VC_VERSION" ]; then
David Bainbridged2811972019-12-14 01:14:09 +00001180 VOK=1
David Bainbridged18f4942020-04-14 16:46:13 -07001181 espin "$VERIFIED"
David Bainbridge1ba64f12019-12-18 00:40:13 +00001182 else
David Bainbridged18f4942020-04-14 16:46:13 -07001183 VCHECK="$(echo -e "$VHAVE\n$VC_VERSION" | sort -V | head -1)"
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001184 if [ "$VCHECK" == "$VHAVE" ]; then
1185 VMESSAGE="upgrade"
1186 else
1187 VMESSAGE="downgrade"
1188 fi
David Bainbridged2811972019-12-14 01:14:09 +00001189 fi
1190fi
1191
David Bainbridged18f4942020-04-14 16:46:13 -07001192if [ "$VOK" -eq 0 ]; then
1193 espin "$NOT_VERIFIED"
David Bainbridged2811972019-12-14 01:14:09 +00001194 bspin - "Download and $VMESSAGE voltctl $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001195 (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
1196 RESULT=$?
1197 if [ $RESULT -ne 0 ]; then
1198 espin - "$THEX"
1199 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download voltctl (version $VC_VERSION): $(cat "$ERR_OUT")${NORMAL}"
1200 rm -rf "$ERR_OUT" "$GOPATH/bin/voltctl"
1201 exit 1
1202 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001203 (set -x; chmod 755 "$GOPATH/bin/voltctl" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1204 espin - "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001205fi
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001206rm -rf "$ERR_OUT"
David Bainbridgee87067b2019-08-12 22:00:12 +00001207if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001208 NOW="$(date +%s)"
1209 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001210fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001211
1212bspin "Verify command PATH"
Test Userba1e7e72019-07-10 22:27:54 +00001213export PATH=$GOPATH/bin:$PATH
David Bainbridged18f4942020-04-14 16:46:13 -07001214espin "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001215
David Bainbridged18f4942020-04-14 16:46:13 -07001216STIME="$(date +%s)"
Test Userba1e7e72019-07-10 22:27:54 +00001217if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001218 HAVE="$(kind get clusters | grep -c "voltha-$NAME")"
Test Userba1e7e72019-07-10 22:27:54 +00001219 bspin "Verify Kubernetes/Kind Cluster"
1220 sspin
David Bainbridged18f4942020-04-14 16:46:13 -07001221 if [ "$HAVE" -eq 0 ]; then
1222 espin "$NOT_VERIFIED"
David Bainbridge491b1bd2019-07-11 17:53:11 +00001223 bspin - "Verify cluster configuration"
David Bainbridged18f4942020-04-14 16:46:13 -07001224 if [ ! -r "./$NAME-cluster.cfg" ]; then
1225 espin - "$NOT_VERIFIED"
David K. Bainbridge43422402020-03-06 07:41:22 -08001226 bspin - "Download cluster configuration: $TYPE-cluster.cfg to $NAME-cluster.cfg $DOWNLOAD"
David Bainbridged18f4942020-04-14 16:46:13 -07001227 ERR_OUT="$(mktemp)"
1228 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
1229 espin - "$THEX"
1230 echo -e "${RED}${BOLD}${ERROR}ERROR: $NAME-cluster.cfg${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1231 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
1232 rm -rf "$ERR_OUT" "./$NAME-cluster.cfg"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001233 exit 1
1234 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001235 rm -rf "$ERR_OUT"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001236 else
David Bainbridged18f4942020-04-14 16:46:13 -07001237 espin - "$VERIFIED"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001238 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001239 kind create cluster --name "voltha-$NAME" --config "$NAME-cluster.cfg"
David Bainbridge491b1bd2019-07-11 17:53:11 +00001240 else
David Bainbridged18f4942020-04-14 16:46:13 -07001241 espin "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001242 fi
1243
David Bainbridged18f4942020-04-14 16:46:13 -07001244 KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$NAME")"; export KUBECONFIG
Test Userba1e7e72019-07-10 22:27:54 +00001245 P="coredns-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001246 etcd-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +00001247 kindnet-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001248 kube-apiserver-voltha-$NAME-control-plane \
1249 kube-controller-manager-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +00001250 kube-proxy-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001251 kube-scheduler-voltha-$NAME-control-plane"
Test Userba1e7e72019-07-10 22:27:54 +00001252
David Bainbridged18f4942020-04-14 16:46:13 -07001253 EXPECT="$(test "$TYPE" == "minimal" && echo "12" || echo "14")"
1254 wait_for_pods - "kube-system" "$EXPECT" "includes" "Waiting for system PODs to start" "$NO_LABEL" "$P"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001255fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001256if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001257 NOW="$(date +%s)"
1258 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001259fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001260
David Bainbridged18f4942020-04-14 16:46:13 -07001261STIME="$(date +%s)"
1262COUNT="$(count_pods "kube-system" ":Running:" "$NO_LABEL" "tiller-deploy-.*")"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001263bspin "Verify Helm"
David Bainbridged18f4942020-04-14 16:46:13 -07001264if [ "$COUNT" -ne 1 ]; then
1265 espin "$NOT_VERIFIED"
Test Userb5712372019-07-03 21:52:17 +00001266 echo -e "Configuring Helm $GEAR"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001267 if [ "$INSTALL_HELM" == "no" ]; then
1268 bspin - "Skip Helm/Tiller Initialization"
1269 espin - $NO_ENTRY
1270 else
1271 bspin - "Initialize Helm"
David Bainbridged18f4942020-04-14 16:46:13 -07001272 (set -x; helm init --upgrade >>"$LOG" 2>&1) >>"$LOG" 2>&1
1273 espin - "$VERIFIED"
1274 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 -07001275 fi
Test Userb5712372019-07-03 21:52:17 +00001276 bspin - "Add Google Incubator repository to Helm"
David Bainbridged18f4942020-04-14 16:46:13 -07001277 (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>"$LOG" 2>&1) >>"$LOG" 2>&1
1278 espin - "$VERIFIED"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001279
Test Userba1e7e72019-07-10 22:27:54 +00001280 # HACK (sort-of) - the config for tiller is about to be patched, which will
1281 # cause the tiller pod to be recreated. This can sometimes cause a timing
1282 # issue with the "wait_for_pods" call on tiller as it may incorrectly
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001283 # identify the running/ready tiller pod that is soon to be terminated as
Test Userba1e7e72019-07-10 22:27:54 +00001284 # what it is waiting for. To avoid this issue we do a clean scale down and
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001285 # scale up of the pod so the script controlls when it should be expecting
Test Userba1e7e72019-07-10 22:27:54 +00001286 # things
David Bainbridged18f4942020-04-14 16:46:13 -07001287 (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 -07001288
Test Userb5712372019-07-03 21:52:17 +00001289 bspin - "Add Google Stable repository to Helm"
David Bainbridged18f4942020-04-14 16:46:13 -07001290 (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>"$LOG" 2>&1) >>"$LOG" 2>&1
1291 espin - "$VERIFIED"
Test Userb5712372019-07-03 21:52:17 +00001292 bspin - "Add ONF repository to Helm"
David Bainbridged18f4942020-04-14 16:46:13 -07001293 (set -x; helm repo add onf https://charts.opencord.org >>"$LOG" 2>&1) >>"$LOG" 2>&1
1294 espin - "$VERIFIED"
Test Userb5712372019-07-03 21:52:17 +00001295 bspin - "Update Helm repository cache"
David Bainbridged18f4942020-04-14 16:46:13 -07001296 (set -x; helm repo update >>"$LOG" 2>&1) >>"$LOG" 2>&1
1297 espin - "$VERIFIED"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001298
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001299 # Create and k8s service account so that Helm can create pods
Test Userb5712372019-07-03 21:52:17 +00001300 bspin - "Create Tiller ServiceAccount"
David Bainbridged18f4942020-04-14 16:46:13 -07001301 (set -x; kubectl create serviceaccount --namespace kube-system tiller >>"$LOG" 2>&1) >>"$LOG" 2>&1
1302 espin - "$VERIFIED"
Test Userb5712372019-07-03 21:52:17 +00001303 bspin - "Create Tiller ClusterRoleBinding"
David Bainbridged18f4942020-04-14 16:46:13 -07001304 (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>"$LOG" 2>&1) >>"$LOG" 2>&1
1305 espin - "$VERIFIED"
Test Userb5712372019-07-03 21:52:17 +00001306 bspin - "Update Tiller Manifest"
David Bainbridged18f4942020-04-14 16:46:13 -07001307 (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 +00001308
1309 # HACK (sort-of) - part to, spin it back up
David Bainbridged18f4942020-04-14 16:46:13 -07001310 (set -x; kubectl -n kube-system scale deploy tiller-deploy --replicas=1 >>"$LOG" 2>&1) >>"$LOG" 2>&1
1311 espin - "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001312else
David Bainbridged18f4942020-04-14 16:46:13 -07001313 if [ "$(helm version -s --template '{{.Server.SemVer}}')" != "$HELM_VERSION" ]; then
1314 espin "$NOT_VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001315 bspin - "Sync Tiller server version with helm client"
David Bainbridged18f4942020-04-14 16:46:13 -07001316 (set -x; helm init --upgrade --force-upgrade --wait >>"$LOG" 2>&1) >>"$LOG" 2>&1
1317 espin - "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001318 else
David Bainbridged18f4942020-04-14 16:46:13 -07001319 espin "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001320 fi
1321
David Bainbridge46505fb2019-10-01 21:13:20 +00001322 if [ "$UPDATE_HELM_REPOS" == "yes" ]; then
1323 bspin - "Update Helm repository cache"
David Bainbridged18f4942020-04-14 16:46:13 -07001324 (set -x; helm repo update >>"$LOG" 2>&1) >>"$LOG" 2>&1
1325 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00001326 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001327fi
David Bainbridged18f4942020-04-14 16:46:13 -07001328wait_for_pods - "kube-system" 1 "includes" "Waiting for Tiller POD to start" "$NO_LABEL" "tiller-deploy-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001329if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001330 NOW="$(date +%s)"
1331 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001332fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001333
David Bainbridged18f4942020-04-14 16:46:13 -07001334STIME="$(date +%s)"
David Bainbridge0774b232019-08-02 06:37:19 +00001335bspin "Verify Helm values file: $NAME-values.yaml"
1336if [ ! -r "./$NAME-values.yaml" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001337 espin "$NOT_VERIFIED"
David Bainbridge0774b232019-08-02 06:37:19 +00001338 bspin - "Download Helm values file: $TYPE-values.yaml to $NAME-values.yaml $DOWNLOAD"
David Bainbridged18f4942020-04-14 16:46:13 -07001339 ERR_OUT="$(mktemp)"
1340 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
1341 espin - "$THEX"
1342 echo -e "${RED}${BOLD}${ERROR}ERROR: $NAME-values.yaml${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1343 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
1344 rm -rf "$ERR_OUT" "./$NAME-values.yaml"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001345 exit 1
1346 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001347 rm -rf "$ERR_OUT"
1348 espin - "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001349else
David Bainbridged18f4942020-04-14 16:46:13 -07001350 espin "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001351fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001352if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001353 NOW="$(date +%s)"
1354 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001355fi
Test Userba1e7e72019-07-10 22:27:54 +00001356
David Bainbridged18f4942020-04-14 16:46:13 -07001357STIME="$(date +%s)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001358bspin "Verify or download chart specific values files $DOWNLOAD"
1359VALUES_FILES="monkey-values.yaml"
David Bainbridged18f4942020-04-14 16:46:13 -07001360ERR_OUT="$(mktemp)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001361for i in $VALUES_FILES; do
1362 if [ ! -r ./$i ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001363 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
1364 espin "$THEX"
1365 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1366 echo "ERROR: $i - $(cat "$ERR_OUT")" >>"$LOG"
1367 rm -rf "$ERR_OUT" "./$i"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001368 exit 1
1369 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001370 rm -rf "$ERR_OUT"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001371 fi
1372done
David Bainbridged18f4942020-04-14 16:46:13 -07001373rm -rf "$ERR_OUT"
1374espin "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001375if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001376 NOW="$(date +%s)"
1377 printtime $((NOW - STIME))
David Bainbridge99ac7a22019-08-31 02:26:43 +00001378fi
1379
1380if [ "$WITH_CHAOS" == "yes" ]; then
1381 bspin "Verify or clone kube-monkey helm chart $DOWNLOAD"
1382 if [ -r ./kube-monkey ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001383 espin "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001384 else
David Bainbridged18f4942020-04-14 16:46:13 -07001385 espin "$NOT_VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001386 bspin - "GIT clone kube-monkey"
David Bainbridged18f4942020-04-14 16:46:13 -07001387 (set -x; git clone https://github.com/asobti/kube-monkey kube-monkey >>"$LOG" 2>&1) >>"$LOG" 2>&1
1388 espin - "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001389 fi
1390fi
1391
Test Userba1e7e72019-07-10 22:27:54 +00001392if [ "$JUST_K8S" == "yes" ]; then
1393 echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye."
1394 echo ""
David Bainbridged18f4942020-04-14 16:46:13 -07001395 echo "Please issue the following commands in your terminal to ensure that you" | tee -a "$LOG"
1396 echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a "$LOG"
1397 echo "tools required by VOLTHA in your command path. " | tee -a "$LOG"
1398 echo "" | tee -a "$LOG"
1399 echo -en "$BOLD"
1400 if [ "$DEPLOY_K8S" == "yes" ]; then
1401 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00001402 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001403 echo "export PATH=$GOPATH/bin:\$PATH" | tee -a "$LOG"
1404 echo -en "$NORMAL"
1405 echo "" | tee -a "$LOG"
1406 echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00001407 exit 0
1408fi
1409
David Bainbridged18f4942020-04-14 16:46:13 -07001410if [ "$WITH_ETCD" != "yes" ] && [ "$WITH_ETCD" != "external" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001411 bspin "Skip ETCD Operator Deployment"
1412 espin $NO_ENTRY
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001413else
David Bainbridged18f4942020-04-14 16:46:13 -07001414 STIME="$(date +%s)"
David Bainbridge76afd812020-04-06 09:53:52 -07001415 NS=$VOLTHA_NS
David Bainbridged18f4942020-04-14 16:46:13 -07001416 if [ "$WITH_ETCD" == "external" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -07001417 NS=$INFRA_NS
1418 fi
David Bainbridge696bc632020-04-05 21:49:37 -07001419 bspin "Verify ETCD Operator $OLD_KEY"
David Bainbridged18f4942020-04-14 16:46:13 -07001420 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$NS" "^etcd-operator\$" | wc -l)" -ne 1 ]; then
1421 espin "$NOT_VERIFIED"
1422 helm_install - "$NS" etcd-operator stable/etcd-operator latest "$_HELM_DESC ETCD Operator"
David Bainbridge696bc632020-04-05 21:49:37 -07001423 else
David Bainbridged18f4942020-04-14 16:46:13 -07001424 espin "$VERIFIED"
David Bainbridge696bc632020-04-05 21:49:37 -07001425 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001426 EXPECT="$(test "$TYPE" == "minimal" && echo "1" || echo "3")"
1427 wait_for_pods - "$NS" "$EXPECT" "includes" "Waiting for ETCD Operator to start" "$NO_LABEL" "etcd-operator-.*"
David Bainbridge696bc632020-04-05 21:49:37 -07001428 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001429 NOW="$(date +%s)"
1430 printtime $((NOW - STIME))
David Bainbridge696bc632020-04-05 21:49:37 -07001431 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001432fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001433
David Bainbridged18f4942020-04-14 16:46:13 -07001434STIME="$(date +%s)"
1435if [ "$WITH_ONOS" == "yes" ]; then
David Bainbridgeb270c202019-07-26 01:44:42 +00001436 bspin "Verify ONOS installed $BIRD"
David Bainbridged18f4942020-04-14 16:46:13 -07001437 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^onos\$" | wc -l)" -ne 1 ]; then
1438 espin "$NOT_VERIFIED"
1439 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 +00001440 else
David Bainbridged18f4942020-04-14 16:46:13 -07001441 espin "$VERIFIED"
David Bainbridgeb270c202019-07-26 01:44:42 +00001442 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001443 wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for ONOS to start" "$NO_LABEL" "onos-.*"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001444
David Bainbridged18f4942020-04-14 16:46:13 -07001445 if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001446 bspin - "Forward ONOS API port $FORWARD"
1447 kill_port_forward onos-ui
David Bainbridged18f4942020-04-14 16:46:13 -07001448 port_forward "$INFRA_NS" onos-ui "$ONOS_API_PORT" 8181
1449 espin - "$VERIFIED"
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001450 bspin - "Forward ONOS SSH port $FORWARD"
1451 kill_port_forward onos-ssh
David Bainbridged18f4942020-04-14 16:46:13 -07001452 port_forward "$INFRA_NS" onos-ssh "$ONOS_SSH_PORT" 8101
1453 espin - "$VERIFIED"
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001454 _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT"
1455 else
David Bainbridged18f4942020-04-14 16:46:13 -07001456 _ONOS_API_EP="$(get_service_ep "$INFRA_NS" onos-ui)"
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001457 fi
David Bainbridged31d6122019-08-13 19:37:59 +00001458 bspin - "Verify or download ONOS configuration support files $DOWNLOAD"
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001459 ONOS_FILES="olt-onos-enableExtraneousRules.json onos-aaa.json \
David Bainbridge696bc632020-04-05 21:49:37 -07001460 onos-dhcpl2relay.json onos-sadis-sample.json"
David Bainbridged18f4942020-04-14 16:46:13 -07001461 (set -x; mkdir -p ./onos-files >>"$LOG" 2>&1) >>"$LOG" 2>&1
1462 ERR_OUT="$(mktemp)"
David Bainbridge2b19e832019-08-16 02:40:53 +00001463 for i in $ONOS_FILES; do
David Bainbridged18f4942020-04-14 16:46:13 -07001464 if [ ! -r "./onos-files/$i" ]; then
1465 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
1466 espin - "$THEX"
1467 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1468 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
1469 rm -rf "$ERR_OUT" "./onos-files/$i"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001470 exit 1
1471 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001472 rm -rf "$ERR_OUT"
David Bainbridged31d6122019-08-13 19:37:59 +00001473 fi
1474 done
David Bainbridged18f4942020-04-14 16:46:13 -07001475 rm -rf "$ERR_OUT"
1476 espin - "$VERIFIED"
David Bainbridge27790d62019-08-13 22:43:19 +00001477
David Bainbridged18f4942020-04-14 16:46:13 -07001478 if [ "$INSTALL_ONOS_APPS" == "yes" ]; then
David Bainbridge27790d62019-08-13 22:43:19 +00001479 bspin - "Installing custom ONOS applications"
David Bainbridged18f4942020-04-14 16:46:13 -07001480 if [ -x onos-files/onos-apps ] && [ "$(find onos-files/onos-apps -name "*.oar" 2>/dev/null | wc -l)" -gt 0 ]; then
1481 for OAR in onos-files/onos-apps/*.oar; do
David Bainbridge27790d62019-08-13 22:43:19 +00001482 sspin - "Installing custom ONOS applications - $OAR$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -07001483 override_onos_app "$OAR"
David Bainbridge27790d62019-08-13 22:43:19 +00001484 done
1485 espin - "$VERIFIED Installing custom ONOS applications$CEOL"
1486 else
1487 espin - "$NOT_VERIFIED Installing custom ONOS applications - None Found"
1488 fi
1489 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001490
David Bainbridged18f4942020-04-14 16:46:13 -07001491 if [ "$WITH_KAFKA" != "no" ]; then
David Bainbridge837e8bd2020-04-06 13:17:14 -07001492 check_onos_app_active org.opencord.kafka
David Bainbridge76afd812020-04-06 09:53:52 -07001493 _HOST=voltha-kafka.$INFRA_NS.svc.cluster.local
David Bainbridge837e8bd2020-04-06 13:17:14 -07001494 _PORT=9092
David Bainbridged18f4942020-04-14 16:46:13 -07001495 if [ "$WITH_KAFKA" == "yes" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -07001496 _HOST=voltha-kafka.$VOLTHA_NS.svc.cluster.local
1497 _PORT=9092
David Bainbridged18f4942020-04-14 16:46:13 -07001498 elif [ "$WITH_KAFKA" == "external" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -07001499 _HOST=kafka.$INFRA_NS.svc.cluster.local
1500 _PORT=9092
1501 else
David Bainbridged18f4942020-04-14 16:46:13 -07001502 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
1503 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge837e8bd2020-04-06 13:17:14 -07001504 _PORT=${_PORT:-9092}
1505 fi
1506 push_onos_config "json" "Push ONOS Kafka Configuration" "network/configuration/apps/org.opencord.kafka" \
David Bainbridged18f4942020-04-14 16:46:13 -07001507 "$(cat <<EOJ | tr -d '[:space:]'
David Bainbridge696bc632020-04-05 21:49:37 -07001508{
1509 "kafka": {
1510 "bootstrapServers": "$_HOST:$_PORT"
1511 }
1512}
1513EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07001514)"
David Bainbridge837e8bd2020-04-06 13:17:14 -07001515 fi
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001516 check_onos_app_active org.opencord.dhcpl2relay
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001517 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 -08001518 check_onos_app_active org.opencord.olt
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001519 # FIXME use WITH_DHCP and WITH_EAPOL flags to configre OLT App
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001520 # Default value for "enableEapol" is true in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07001521 if [ "$WITH_EAPOL" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001522 push_onos_config "json" "Enable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":true}'
David Bainbridged18f4942020-04-14 16:46:13 -07001523 elif [ "$WITH_EAPOL" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001524 push_onos_config "json" "Disable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001525 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001526 # Default value for "enableDhcpOnProvisioning" is false and for "enableDhcpV4" is true in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07001527 if [ "$WITH_DHCP" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001528 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 -07001529 elif [ "$WITH_DHCP" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001530 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 -08001531 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001532 # Default value for "enableIgmpOnProvisioning" is false in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07001533 if [ "$WITH_IGMP" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001534 push_onos_config "json" "Enable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":true}'
David Bainbridged18f4942020-04-14 16:46:13 -07001535 elif [ "$WITH_IGMP" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001536 push_onos_config "json" "Disable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001537 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001538 if [ "$ENABLE_ONOS_EXTRANEOUS_RULES" == "yes" ]; then
David K. Bainbridge484d80c2020-03-05 21:44:34 -08001539 push_onos_config "file" "Enabling extraneous rules for ONOS" "configuration/org.onosproject.net.flow.impl.FlowRuleManager" "onos-files/olt-onos-enableExtraneousRules.json"
1540 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001541 if [ "$(echo ":yes:file:" | grep -c ":$CONFIG_SADIS:")" -eq 1 ]; then
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001542 check_onos_app_active org.opencord.sadis
Hardik Windlassb3147602020-03-09 16:59:15 +05301543 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 -07001544 elif [ "$CONFIG_SADIS" == "bbsim" ]; then
1545 push_onos_config "json" \
1546 "[optional] Push ONOS configuration for BBSIM SADIS servers" \
1547 "network/configuration/apps/org.opencord.sadis" \
David Bainbridged18f4942020-04-14 16:46:13 -07001548 "$(cat <<EOJ | tr -d '[:space:]'
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001549{
1550 "sadis": {
1551 "integration": {
David Bainbridge76afd812020-04-06 09:53:52 -07001552 "url": "http://bbsim.$BBSIM_NS.svc.cluster.local:50074/v2/subscribers/%s",
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001553 "cache": {
1554 "enabled": true,
1555 "maxsize": 50,
1556 "ttl": "PT1m"
1557 }
1558 }
1559 },
1560 "bandwidthprofile": {
1561 "integration": {
David Bainbridge76afd812020-04-06 09:53:52 -07001562 "url": "http://bbsim.$BBSIM_NS.svc.cluster.local:50074/v2/bandwidthprofiles/%s",
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001563 "cache": {
1564 "enabled": true,
1565 "maxsize": 50,
1566 "ttl": "PT1m"
1567 }
1568 }
1569 }
1570}
1571EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07001572)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001573 elif [ "$CONFIG_SADIS" == "url" ]; then
1574 push_onos_config "json" \
1575 "[optional] Push ONOS configuration for custom SADIS and Bandwidth Profile servers" \
1576 "network/configuration/apps/org.opencord.sadis" \
David Bainbridged18f4942020-04-14 16:46:13 -07001577 "$(cat <<EOJ | tr -d '[:space:]'
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001578{
1579 "sadis": {
1580 "integration": {
1581 "url": "$SADIS_SUBSCRIBERS",
1582 "cache": {
1583 "enabled": true,
1584 "maxsize": 50,
1585 "ttl": "PT1m"
1586 }
1587 }
1588 },
1589 "bandwidthprofile": {
1590 "integration": {
1591 "url": "$SADIS_BANDWIDTH_PROFILES",
1592 "cache": {
1593 "enabled": true,
1594 "maxsize": 50,
1595 "ttl": "PT1m"
1596 }
1597 }
1598 }
1599}
1600EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07001601)"
David Bainbridge2b19e832019-08-16 02:40:53 +00001602 fi
Test Userba1e7e72019-07-10 22:27:54 +00001603fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001604if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001605 NOW="$(date +%s)"
1606 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001607fi
Test Userba1e7e72019-07-10 22:27:54 +00001608
David Bainbridged18f4942020-04-14 16:46:13 -07001609if [ "$WITH_ETCD" == "external" ]; then
1610 STIME="$(date +%s)"
David Bainbridge76afd812020-04-06 09:53:52 -07001611 bspin "Verify external ETCD cluster $OLD_KEY"
David Bainbridged18f4942020-04-14 16:46:13 -07001612 EXPECT="$(test "$TYPE" == "minimal" && echo "1" || echo "3")"
1613 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^etcd-cluster\$" | wc -l)" -ne 1 ]; then
1614 espin "$NOT_VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07001615 INTERNAL_EXTRA_HELM_INSTALL_ARGS+="--set clusterName=etcd-cluster --set autoCompactionRetention=1 --set clusterSize=$EXPECT"
David Bainbridged18f4942020-04-14 16:46:13 -07001616 helm_install - "$INFRA_NS" etcd-cluster onf/voltha-etcd-cluster latest "$_HELM_DESC external ETCD cluster"
David Bainbridge76afd812020-04-06 09:53:52 -07001617 else
David Bainbridged18f4942020-04-14 16:46:13 -07001618 espin "$VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07001619 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001620 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for ETCD cluster to start" "$NO_LABEL" "etcd-cluster-.*"
David Bainbridge76afd812020-04-06 09:53:52 -07001621 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001622 NOW="$(date +%s)"
1623 printtime $((NOW - STIME))
David Bainbridge76afd812020-04-06 09:53:52 -07001624 fi
1625fi
1626
David Bainbridged18f4942020-04-14 16:46:13 -07001627if [ "$WITH_KAFKA" == "external" ]; then
1628 _TMP="$(mktemp -u)"
1629 _COUNT="$(test "$TYPE" == "minimal" && echo "1" || echo "3")"
1630 cat << EOC > "$_TMP"
David Bainbridge76afd812020-04-06 09:53:52 -07001631configurationOverrides:
1632 "default.replication.factor": $_COUNT
1633 "offsets.topic.replication.factor": $_COUNT
1634 "log.retention.hours": 4
1635 "log.message.timestamp.type": "LogAppendTime"
1636persistence:
1637 enabled: false
1638zookeeper:
1639 replicaCount: 1
1640 persistence:
1641 enabled: false
1642replicas: $_COUNT
1643EOC
David Bainbridged18f4942020-04-14 16:46:13 -07001644 STIME="$(date +%s)"
David Bainbridge76afd812020-04-06 09:53:52 -07001645 bspin "Verify external Kafka cluster $OLD_KEY"
David Bainbridged18f4942020-04-14 16:46:13 -07001646 EXPECT="$(test "$TYPE" == "minimal" && echo "2" || echo "4")"
1647 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^kafka\$" | wc -l)" -ne 1 ]; then
1648 espin "$NOT_VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07001649 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" -f $_TMP"
David Bainbridgeb9093522020-04-15 14:32:44 -07001650 helm_install - "$INFRA_NS" kafka incubator/kafka "$KAFKA_CHART_VERSION" "$_HELM_DESC external Kafka cluster"
David Bainbridge76afd812020-04-06 09:53:52 -07001651 else
David Bainbridged18f4942020-04-14 16:46:13 -07001652 espin "$VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07001653 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001654 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for Kafka cluster to start" "$NO_LABEL" "kafka-.*"
David Bainbridge76afd812020-04-06 09:53:52 -07001655 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001656 NOW="$(date +%s)"
1657 printtime $((NOW - STIME))
David Bainbridge76afd812020-04-06 09:53:52 -07001658 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001659 rm -rf "$_TMP"
David Bainbridge76afd812020-04-06 09:53:52 -07001660fi
1661
David Bainbridged18f4942020-04-14 16:46:13 -07001662STIME="$(date +%s)"
David Bainbridge696bc632020-04-05 21:49:37 -07001663EXPECT=1
1664if [ "$ONLY_ONE" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001665 EXPECT="$((EXPECT+1))"
David Bainbridge696bc632020-04-05 21:49:37 -07001666 INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set therecanbeonlyone=true"
1667else
David Bainbridged18f4942020-04-14 16:46:13 -07001668 EXPECT="$((EXPECT+2))"
David Bainbridge696bc632020-04-05 21:49:37 -07001669fi
Matteo Scandolo67335f02020-04-09 11:19:53 -07001670case $WITH_ETCD in
David Bainbridge76afd812020-04-06 09:53:52 -07001671 no)
1672 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set private_etcd_cluster=false"
1673 ;;
1674 yes)
1675 _HOST="voltha-etcd-cluster-client.$VOLTHA_NS.svc.cluster.local"
1676 _PORT=2379
1677 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridged18f4942020-04-14 16:46:13 -07001678 EXPECT="$((EXPECT+$(test "$TYPE" == "minimal" && echo "1" || echo "3")))"
David Bainbridge76afd812020-04-06 09:53:52 -07001679 ;;
1680 external)
1681 _HOST="etcd-cluster-client.$INFRA_NS.svc.cluster.local"
1682 _PORT=2379
1683 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set private_etcd_cluster=false --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
1684 ;;
1685 *)
David Bainbridged18f4942020-04-14 16:46:13 -07001686 _HOST="$(echo "$WITH_ETCD" | cut -d: -f1)"
1687 _PORT="$(echo "$WITH_ETCD" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07001688 _PORT=${_PORT:-2379}
David Bainbridge76afd812020-04-06 09:53:52 -07001689 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set private_etcd_cluster=false --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
1690 ;;
1691esac
1692case $WITH_KAFKA in
1693 no)
1694 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set private_kafka_cluster=false"
1695 ;;
1696 yes)
1697 _HOST=voltha-kafka.$VOLTHA_NS.svc.cluster.local
1698 _PORT=9092
1699 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 -07001700 EXPECT="$((EXPECT+$(test "$TYPE" == "minimal" && echo "2" || echo "4")))"
David Bainbridge76afd812020-04-06 09:53:52 -07001701 ;;
1702 external)
1703 _HOST=kafka.$INFRA_NS.svc.cluster.local
1704 _PORT=9092
1705 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"
1706 ;;
1707 *)
David Bainbridged18f4942020-04-14 16:46:13 -07001708 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
1709 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07001710 _PORT=${_PORT:-9092}
David Bainbridge76afd812020-04-06 09:53:52 -07001711 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"
1712 ;;
1713esac
1714
David Bainbridged18f4942020-04-14 16:46:13 -07001715if [ "$WITH_ONOS" == "yes" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -07001716 _HOST=onos-openflow.$INFRA_NS.svc.cluster.local
1717 _PORT=6653
1718 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.controller.service=$_HOST --set services.controller.port=$_PORT"
David Bainbridged18f4942020-04-14 16:46:13 -07001719elif [ "$WITH_ONOS" != "no" ]; then
1720 _HOST="$(echo "$WITH_ONOS" | cut -d: -f1)"
1721 _PORT="$(echo "$WITH_ONOS" | cut -s -d: -f2)"
David Bainbridge76afd812020-04-06 09:53:52 -07001722 _PORT=${_PORT:-6653}
1723 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.controller.service=$_HOST --set services.controller.port=$_PORT"
David Bainbridge696bc632020-04-05 21:49:37 -07001724fi
Test Userb5712372019-07-03 21:52:17 +00001725bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
David Bainbridged18f4942020-04-14 16:46:13 -07001726if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$VOLTHA_NS" "^voltha\$" | wc -l)" -ne 1 ]; then
1727 espin "$NOT_VERIFIED"
1728 helm_install - "$VOLTHA_NS" voltha "$VOLTHA_CHART" "$VOLTHA_CHART_VERSION" "$_HELM_DESC VOLTHA Core"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001729else
David Bainbridged18f4942020-04-14 16:46:13 -07001730 espin "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001731fi
David Bainbridge696bc632020-04-05 21:49:37 -07001732INTERNAL_EXTRA_HELM_INSTALL_ARGS=
Test Userba1e7e72019-07-10 22:27:54 +00001733
David Bainbridge90fd8e32019-08-21 23:32:47 +00001734VOLTHA="voltha-ofagent-.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001735 rw-core.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001736 voltha-etcd-cluster-.* \
1737 voltha-kafka-.* \
1738 voltha-zookeeper-.*"
David Bainbridged18f4942020-04-14 16:46:13 -07001739wait_for_pods - "$VOLTHA_NS" "$EXPECT" "includes" "Waiting for VOLTHA Core to start" "$NO_LABEL" "$VOLTHA"
David Bainbridgee87067b2019-08-12 22:00:12 +00001740if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001741 NOW="$(date +%s)"
1742 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001743fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001744
David Bainbridge46505fb2019-10-01 21:13:20 +00001745if [ "$WITH_ADAPTERS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001746 STIME="$(date +%s)"
David Bainbridge46505fb2019-10-01 21:13:20 +00001747 EXPECT=0
David Bainbridged18f4942020-04-14 16:46:13 -07001748 if [ "$WITH_ETCD" == "yes" ]; then
David Bainbridge3517f6c2020-04-08 12:14:08 -07001749 _HOST=voltha-etcd-cluster-client.$VOLTHA_NS.svc.cluster.local
1750 _PORT=2379
1751 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridged18f4942020-04-14 16:46:13 -07001752 elif [ "$WITH_ETCD" == "external" ]; then
David Bainbridge3517f6c2020-04-08 12:14:08 -07001753 _HOST=etcd-cluster-client.$INFRA_NS.svc.cluster.local
1754 _PORT=2379
1755 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridged18f4942020-04-14 16:46:13 -07001756 elif [ "$WITH_ETCD" != "no" ]; then
1757 _HOST="$(echo "$WITH_ETCD" | cut -d: -f1)"
1758 _PORT="$(echo "$WITH_ETCD" | cut -s -d: -f2)"
David Bainbridge3517f6c2020-04-08 12:14:08 -07001759 _PORT=${_PORT:-2379}
1760 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridge696bc632020-04-05 21:49:37 -07001761 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001762 if [ "$WITH_KAFKA" == "yes" ]; then
David Bainbridge3517f6c2020-04-08 12:14:08 -07001763 _HOST=voltha-kafka.$VOLTHA_NS.svc.cluster.local
1764 _PORT=9092
1765 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 -07001766 elif [ "$WITH_KAFKA" == "external" ]; then
David Bainbridge3517f6c2020-04-08 12:14:08 -07001767 _HOST=kafka.$INFRA_NS.svc.cluster.local
1768 _PORT=9092
1769 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 -07001770 elif [ "$WITH_KAFKA" != "no" ]; then
1771 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
1772 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge3517f6c2020-04-08 12:14:08 -07001773 _PORT=${_PORT:-9092}
1774 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 -07001775 fi
David Bainbridge46505fb2019-10-01 21:13:20 +00001776 echo -e "Verify Adapters $PLUG"
1777 if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then
1778 bspin - "Verify Simulated Adapters installed"
David Bainbridged18f4942020-04-14 16:46:13 -07001779 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$ADAPTER_NS" "^sim\$" | wc -l)" -ne 1 ]; then
1780 espin - "$NOT_VERIFIED"
1781 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 +00001782 else
David Bainbridged18f4942020-04-14 16:46:13 -07001783 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00001784 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001785 EXPECT="$((EXPECT + 2))"
David Bainbridge46505fb2019-10-01 21:13:20 +00001786 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001787
David Bainbridge46505fb2019-10-01 21:13:20 +00001788 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
1789 bspin - "Verify OpenOLT Adapter installed"
David Bainbridged18f4942020-04-14 16:46:13 -07001790 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$ADAPTER_NS" "^open-olt\$" | wc -l)" -ne 1 ]; then
1791 espin - "$NOT_VERIFIED"
1792 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 +00001793 else
David Bainbridged18f4942020-04-14 16:46:13 -07001794 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00001795 fi
Matteo Scandolo67335f02020-04-09 11:19:53 -07001796 EXPECT="$((EXPECT + 1))"
David Bainbridge46505fb2019-10-01 21:13:20 +00001797 bspin - "Verify OpenONU Adapter installed"
David Bainbridged18f4942020-04-14 16:46:13 -07001798 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 -07001799 _ORIGINAL_EXTRA_HELM_INSTALL_ARGS="$INTERNAL_EXTRA_HELM_INSTALL_ARGS"
1800 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set replicas.adapter_open_onu=$NUM_OF_OPENONU"
David Bainbridged18f4942020-04-14 16:46:13 -07001801 espin - "$NOT_VERIFIED"
Matteo Scandolo67335f02020-04-09 11:19:53 -07001802 helm_install - "$ADAPTER_NS" open-onu "$VOLTHA_ADAPTER_OPEN_ONU_CHART" "$VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION" "$_HELM_DESC OpenONU Adapter"
1803 INTERNAL_EXTRA_HELM_INSTALL_ARGS="$_ORIGINAL_EXTRA_HELM_INSTALL_ARGS"
David Bainbridge46505fb2019-10-01 21:13:20 +00001804 else
David Bainbridged18f4942020-04-14 16:46:13 -07001805 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00001806 fi
Matteo Scandolo67335f02020-04-09 11:19:53 -07001807 EXPECT=$((EXPECT + NUM_OF_OPENONU))
David Bainbridge46505fb2019-10-01 21:13:20 +00001808 fi
David Bainbridge696bc632020-04-05 21:49:37 -07001809 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001810
David Bainbridge46505fb2019-10-01 21:13:20 +00001811 ADAPTERS="adapter-.*"
David Bainbridged18f4942020-04-14 16:46:13 -07001812 wait_for_pods - "$ADAPTER_NS" "$EXPECT" "includes" "Waiting for adapters to start" "$NO_LABEL" "$ADAPTERS"
David Bainbridge46505fb2019-10-01 21:13:20 +00001813 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001814 NOW="$(date +%s)"
1815 printtime $((NOW - STIME))
David Bainbridge46505fb2019-10-01 21:13:20 +00001816 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001817fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001818
David Bainbridged18f4942020-04-14 16:46:13 -07001819if [ "$WITH_BBSIM" == "yes" ]; then
1820 STIME="$(date +%s)"
Test User7d866122019-07-09 17:52:35 +00001821 echo -e "Verify BBSIM $PLUG"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001822 bspin - "Verify BBSIM Installed"
David Bainbridged18f4942020-04-14 16:46:13 -07001823 for instance in $(seq 0 $((NUM_OF_BBSIM-1))); do
1824 if [ "$instance" -eq 0 ]; then
David K. Bainbridge43422402020-03-06 07:41:22 -08001825 instance_num=""
1826 else
1827 instance_num=$instance
1828 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001829 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$BBSIM_NS" "^bbsim${instance_num}\$" | wc -l)" -ne 1 ]; then
1830 espin - "$NOT_VERIFIED"
1831 S_TAG="$((900+instance))"
Matteo Scandolo5a149572020-04-01 10:14:57 -07001832 INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set olt_id=$instance,s_tag=$S_TAG"
David Bainbridged18f4942020-04-14 16:46:13 -07001833 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 -07001834 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
David K. Bainbridge43422402020-03-06 07:41:22 -08001835 else
David Bainbridged18f4942020-04-14 16:46:13 -07001836 espin - "$VERIFIED"
David K. Bainbridge43422402020-03-06 07:41:22 -08001837 fi
1838 done
David Bainbridged18f4942020-04-14 16:46:13 -07001839 wait_for_pods - "$BBSIM_NS" "$NUM_OF_BBSIM" "includes" "Waiting for BBSIM to start" "$BBSIM_LABEL" "bbsim*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001840 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001841 NOW="$(date +%s)"
1842 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001843 fi
Test User7d866122019-07-09 17:52:35 +00001844fi
1845
David Bainbridged18f4942020-04-14 16:46:13 -07001846if [ "$WITH_RADIUS" == "yes" ]; then
1847 STIME="$(date +%s)"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001848 echo -e "Verify RADIUS $LOCK"
1849 bspin - "Verify RADIUS Installed"
David Bainbridged18f4942020-04-14 16:46:13 -07001850 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^radius\$" | wc -l)" -ne 1 ]; then
1851 espin - "$NOT_VERIFIED"
1852 helm_install - "$INFRA_NS" radius onf/freeradius latest "$_HELM_DESC RADIUS"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001853 else
David Bainbridged18f4942020-04-14 16:46:13 -07001854 espin - "$VERIFIED"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001855 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001856 wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for RADIUS to start" "$NO_LABEL" "radius-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001857 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001858 NOW="$(date +%s)"
1859 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001860 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001861fi
1862
David Bainbridged18f4942020-04-14 16:46:13 -07001863if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
1864 STIME="$(date +%s)"
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001865 bspin - "Forward VOLTHA API port $FORWARD"
1866 kill_port_forward voltha-api
David Bainbridged18f4942020-04-14 16:46:13 -07001867 port_forward "$VOLTHA_NS" voltha-api "$VOLTHA_API_PORT" 55555
1868 espin - "$VERIFIED"
1869 if [ "$WITH_ETCD" == "yes" ] || [ "$WITH_ETCD" == "external" ]; then
1870 _NS="$(test "$WITH_ETCD" == "yes" && echo "$VOLTHA_NS" || echo "$INFRA_NS")"
David Bainbridge696bc632020-04-05 21:49:37 -07001871 bspin - "Forward VOLTHA ETCD port $FORWARD"
David Bainbridged18f4942020-04-14 16:46:13 -07001872 kill_port_forward "${ETCD_PREFIX}etcd-cluster-client"
1873 port_forward "$_NS" "${ETCD_PREFIX}etcd-cluster-client" "$VOLTHA_ETCD_PORT" 2379
1874 espin - "$VERIFIED"
David Bainbridge696bc632020-04-05 21:49:37 -07001875 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001876 if [ "$WITH_KAFKA" == "yes" ] || [ $WITH_KAFKA == "external" ]; then
1877 _NS="$(test "$WITH_ETCD" == "yes" && echo "$VOLTHA_NS" || echo "$INFRA_NS")"
David Bainbridge696bc632020-04-05 21:49:37 -07001878 bspin - "Forward VOLTHA Kafka port $FORWARD"
David Bainbridged18f4942020-04-14 16:46:13 -07001879 kill_port_forward "${KAFKA_PREFIX}kafka"
1880 port_forward "$_NS" ${KAFKA_PREFIX}kafka "$VOLTHA_KAFKA_PORT" 9092
1881 espin - "$VERIFIED"
David Bainbridge696bc632020-04-05 21:49:37 -07001882 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001883 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001884 NOW="$(date +%s)"
1885 printtime $((NOW - STIME))
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001886 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001887fi
Test User3d7ad8e2019-07-03 06:15:44 +00001888
David Bainbridged18f4942020-04-14 16:46:13 -07001889if [ "$WITH_ONOS" == "yes" ] && [ "$WITH_RADIUS" != "no" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -07001890 _HOST=radius.$INFRA_NS.svc.cluster.local
David Bainbridge696bc632020-04-05 21:49:37 -07001891 _PORT=1812
David Bainbridged18f4942020-04-14 16:46:13 -07001892 if [ "$WITH_RADIUS" != "yes" ]; then
1893 _HOST="$(echo "$WITH_RADIUS" | cut -d: -f1)"
1894 _PORT="$(echo "$WITH_RADIUS" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07001895 _PORT=${_PORT:-1812}
1896 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001897 bspin "Configure ONOS RADIUS Connection $GEAR"
David Bainbridged18f4942020-04-14 16:46:13 -07001898 (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
1899 espin "$VERIFIED"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001900fi
1901
David Bainbridge99ac7a22019-08-31 02:26:43 +00001902if [ "$WITH_CHAOS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001903 STIME="$(date +%s)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001904 echo -e "Verify kube-monkey $LOCK"
1905 bspin - "Verify kube-monkey Installed"
David Bainbridged18f4942020-04-14 16:46:13 -07001906 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace kube-monkey "^monkey\$" | wc -l)" -ne 1 ]; then
1907 espin - "$NOT_VERIFIED"
David Bainbridge7f8bf992020-04-08 21:53:22 -07001908 helm_install - kube-monkey monkey ./kube-monkey/helm/kubemonkey latest "$_HELM_DESC Chaos Monkey"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001909 else
David Bainbridged18f4942020-04-14 16:46:13 -07001910 espin - "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001911 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001912 wait_for_pods - "kube-monkey" 1 "includes" "Waiting for Chaos to start" "$NO_LABEL" "monkey-.*"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001913 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001914 NOW="$(date +%s)"
1915 printtime $((NOW - STIME))
David Bainbridge99ac7a22019-08-31 02:26:43 +00001916 fi
1917fi
1918
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001919bspin "Create voltctl configuration file"
David Bainbridged18f4942020-04-14 16:46:13 -07001920(set -x; mkdir -p "$HOME/.volt" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1921MIN_VC_VERSION="$(echo -e "1.0.15\n$VC_VERSION" | sort -V | head -1)"
1922if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001923 KAFKA_FLAG="-k localhost:$VOLTHA_KAFKA_PORT"
1924 SERVER_FLAG="-s localhost:$VOLTHA_API_PORT"
1925 ETCD_FLAG=
1926 if [ "$MIN_VC_VERSION" == "1.0.15" ]; then
1927 ETCD_FLAG="-e localhost:$VOLTHA_ETCD_PORT"
1928 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001929else
David Bainbridged18f4942020-04-14 16:46:13 -07001930 KAFKA_FLAG="-k $(get_service_ep "$INFRA_NS" "${KAFKA_PREFIX}kafka")"
1931 SERVER_FLAG="-s $(get_service_ep "$VOLTHA_NS" voltha-api)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001932 ETCD_FLAG=
1933 if [ "$MIN_VC_VERSION" == "1.0.15" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001934 ETCD_FLAG="-e $(get_service_ep "$INFRA_NS" ${ETCD_PREFIX}etcd-client)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001935 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001936fi
David Bainbridged18f4942020-04-14 16:46:13 -07001937CMD=("voltctl -a v3 $KAFKA_FLAG $SERVER_FLAG $ETCD_FLAG config")
1938(set -x; ${CMD[*]} > "$HOME/.volt/config-$NAME" 2>>"$LOG") >>"$LOG" 2>&1
1939#(set -x; voltctl -a v3 "$KAFKA_FLAG" "$SERVER_FLAG" "$ETCD_FLAG" config > "$HOME/.volt/config-$NAME" 2>>"$LOG") >>"$LOG" 2>&1
1940espin "$VERIFIED"
Test User08ebbd92019-07-03 17:15:39 +00001941
David Bainbridge0774b232019-08-02 06:37:19 +00001942if [ ! -f "$NAME-env.sh" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001943 touch "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001944fi
1945
David Bainbridge596f30d2019-07-30 17:07:59 +00001946for O in $ALL_OPTIONS; do
David Bainbridged18f4942020-04-14 16:46:13 -07001947 VAL="$(eval echo "\$$O")"
1948 if [ -n "$VAL" ] && [ "$(grep -c "^export $O=" "$NAME-env.sh")" -eq 0 ]; then
1949 echo "export $O=\"$(eval echo "\$$O")\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001950 fi
1951done
1952
David Bainbridged18f4942020-04-14 16:46:13 -07001953if [ "$DEPLOY_K8S" == "yes" ] && [ "$(grep -c "^export KUBECONFIG=" "$NAME-env.sh")" -eq 0 ]; then
1954 echo "export KUBECONFIG=\"$(./bin/kind get kubeconfig-path "--name=voltha-$NAME")\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001955fi
1956
David Bainbridged18f4942020-04-14 16:46:13 -07001957if [ "$(grep -c "^export VOLTCONFIG=" "$NAME-env.sh")" -eq 0 ]; then
1958 echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001959fi
1960
David Bainbridged18f4942020-04-14 16:46:13 -07001961if [ "$(grep -c "^export PATH=" "$NAME-env.sh")" -eq 0 ]; then
1962 echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001963fi
1964
Test User7d866122019-07-09 17:52:35 +00001965echo ""
David Bainbridged18f4942020-04-14 16:46:13 -07001966echo "Please issue the following commands in your terminal to ensure that you" | tee -a "$LOG"
1967echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a "$LOG"
1968echo "tools required by VOLTHA in your command path. " | tee -a "$LOG"
1969echo "" | tee -a "$LOG"
1970echo -en "$BOLD"
1971if [ "$DEPLOY_K8S" == "yes" ]; then
1972 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00001973fi
David Bainbridged18f4942020-04-14 16:46:13 -07001974echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" | tee -a "$LOG"
1975echo "export PATH=$GOPATH/bin:\$PATH" | tee -a "$LOG"
1976echo -en "$NORMAL"
1977echo "" | tee -a "$LOG"
1978echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a "$LOG"
Test User08ebbd92019-07-03 17:15:39 +00001979
David Bainbridge712afb82019-08-14 19:55:58 +00001980if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001981 NOW="$(date +%s)"
1982 echo -e "$CLOCK ${BOLD}TOTAL: $(duration $((NOW - TOTAL_START_TIME)))${NORMAL}"
David Bainbridge712afb82019-08-14 19:55:58 +00001983fi