blob: 8ced0a850760131971caa16fe51367769c683167 [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
David Bainbridge60ffc0f2020-04-27 22:13:22 -070017shopt -s extglob
David Bainbridged18f4942020-04-14 16:46:13 -070018TOTAL_START_TIME="$(date +%s)"
David K. Bainbridgeb7285432019-07-02 22:05:24 -070019
David Bainbridge38dc1e82019-08-12 15:18:45 +000020FANCY=${FANCY:-1}
21if [ "$TERM X" == " X" ]; then
22 FANCY=0
23fi
24
David K. Bainbridgeb7285432019-07-02 22:05:24 -070025# trap ctrl-c and call ctrl_c()
26trap ctrl_c INT
27
28function ctrl_c() {
David Bainbridged18f4942020-04-14 16:46:13 -070029 echo -en "$CNORM"
David K. Bainbridgeb7285432019-07-02 22:05:24 -070030 echo ""
31 echo "ctrl-c trapped"
David Bainbridgec6a6eb62019-10-18 22:50:07 +000032 echo "Thank you for trying 'voltha up'"
David K. Bainbridgeb7285432019-07-02 22:05:24 -070033 exit
34}
35
David Bainbridgea34993d2020-04-01 09:15:42 -070036HELM_VERSION=${HELM_VERSION:-v2.14.3}
David K. Bainbridgeebf38d92020-02-10 10:46:31 -080037VOLTCTL_VERSION=${VOLTCTL_VERSION:-latest}
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -080038KIND_VERSION=${KIND_VERSION:-v0.5.1}
David K. Bainbridgeb3a99372020-01-08 14:39:06 -080039VK_RELEASE=${VK_RELEASE:-master}
David Bainbridge60ffc0f2020-04-27 22:13:22 -070040EXTRA_TOOLS=
Test User08ebbd92019-07-03 17:15:39 +000041
David Bainbridge38dc1e82019-08-12 15:18:45 +000042RED=
43GREEN=
44YELLOW=
45BLUE=
David Bainbridge38dc1e82019-08-12 15:18:45 +000046BOLD=
47NORMAL=
48ERROR=
49CEOL=
50CNORM=
51CIVIS=
David Bainbridged18f4942020-04-14 16:46:13 -070052if [ "$FANCY" -eq 1 ]; then
53 RED="$(tput setaf 1)"
54 GREEN="$(tput setaf 2)"
55 YELLOW="$(tput setaf 3)"
56 BLUE="$(tput setaf 4)"
57 BOLD="$(tput bold)"
58 NORMAL="$(tput sgr0)"
David Bainbridge38dc1e82019-08-12 15:18:45 +000059 ERROR="\xe2\x9c\x97\x20"
David Bainbridged18f4942020-04-14 16:46:13 -070060 CEOL="$(tput el)"
61 CNORM="$(tput cnorm)"
62 CIVIS="$(tput civis)"
David Bainbridge38dc1e82019-08-12 15:18:45 +000063fi
Test User7d866122019-07-09 17:52:35 +000064
Test User3d7ad8e2019-07-03 06:15:44 +000065TYPE=${TYPE:-minimal}
David Bainbridge0774b232019-08-02 06:37:19 +000066NAME=${NAME:-$TYPE}
David K. Bainbridge484d80c2020-03-05 21:44:34 -080067
68ENABLE_ONOS_EXTRANEOUS_RULES=${ENABLE_ONOS_EXTRANEOUS_RULES:-no}
David Bainbridge76afd812020-04-06 09:53:52 -070069INFRA_NS=${INFRA_NS:-default}
70VOLTHA_NS=${VOLTHA_NS:-voltha}
71BBSIM_NS=${BBSIM_NS:-voltha}
72ADAPTER_NS=${ADAPTER_NS:-voltha}
David Bainbridgee87067b2019-08-12 22:00:12 +000073WITH_TIMINGS=${WITH_TIMINGS:-no}
Test User7d866122019-07-09 17:52:35 +000074WITH_BBSIM=${WITH_BBSIM:-no}
David Bainbridge5b7b96b2019-07-25 20:29:13 +000075WITH_RADIUS=${WITH_RADIUS:-no}
Matteo Scandolo78dfee02020-02-13 16:18:03 -080076WITH_EAPOL=${WITH_EAPOL:-yes}
77WITH_DHCP=${WITH_DHCP:-yes}
78WITH_IGMP=${WITH_IGMP:-no}
David Bainbridgeb270c202019-07-26 01:44:42 +000079WITH_ONOS=${WITH_ONOS:-yes}
David Bainbridge60ffc0f2020-04-27 22:13:22 -070080NUM_OF_ONOS=${NUM_OF_ONOS:-1}
81NUM_OF_ATOMIX=${NUM_OF_ATOMIX:-0}
David Bainbridge99ac7a22019-08-31 02:26:43 +000082WITH_CHAOS=${WITH_CHAOS:-no}
David Bainbridge46505fb2019-10-01 21:13:20 +000083WITH_ADAPTERS=${WITH_ADAPTERS:-yes}
David K. Bainbridgeda33d652020-03-06 10:31:23 -080084WITH_SIM_ADAPTERS=${WITH_SIM_ADAPTERS:-no}
David Bainbridge46505fb2019-10-01 21:13:20 +000085WITH_OPEN_ADAPTERS=${WITH_OPEN_ADAPTERS:-yes}
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -080086WITH_PORT_FORWARDS=${WITH_PORT_FORWARDS:-yes}
David Bainbridge696bc632020-04-05 21:49:37 -070087WITH_KAFKA=${WITH_KAFKA:-yes}
88WITH_ETCD=${WITH_ETCD:-yes}
Matteo Scandoloefee0432020-05-05 13:56:20 -070089WITH_PPROF=${WITH_PPROF:-no}
Girish Gowdra4cc5d8b2020-06-11 17:12:00 -070090WITH_INCREMENTAL_EVTO_UPDATE=${WITH_INCREMENTAL_EVTO_UPDATE:-no}
David Bainbridgee4d11ca2020-05-08 10:21:10 -070091SCHEDULE_ON_CONTROL_NODES=${SCHEDULE_ON_CONTROL_NODES:-no}
David Bainbridge309099c2020-05-05 08:47:29 -070092CONFIG_SADIS=${CONFIG_SADIS:-no} # yes | no | file | bbsim | external | URL
Hardik Windlassb3147602020-03-09 16:59:15 +053093SADIS_CFG=${SADIS_CFG:-onos-files/onos-sadis-sample.json}
David Bainbridge27790d62019-08-13 22:43:19 +000094INSTALL_ONOS_APPS=${INSTALL_ONOS_APPS:-no}
Test Userba1e7e72019-07-10 22:27:54 +000095JUST_K8S=${JUST_K8S:-no}
96DEPLOY_K8S=${DEPLOY_K8S:-yes}
David K. Bainbridge0e89cb92019-07-17 11:30:10 -070097INSTALL_KUBECTL=${INSTALL_KUBECTL:-yes}
98INSTALL_HELM=${INSTALL_HELM:-yes}
David Bainbridge7f8bf992020-04-08 21:53:22 -070099HELM_USE_UPGRADE=${HELM_USE_UPGRADE:-no}
David Bainbridge46505fb2019-10-01 21:13:20 +0000100UPDATE_HELM_REPOS=${UPDATE_HELM_REPOS:-yes}
Matteo Scandolofab98622020-01-28 15:17:20 -0800101WAIT_ON_DOWN=${WAIT_ON_DOWN:-yes}
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700102WAIT_TIMEOUT=${WAIT_TIMEOUT:-30m}
103VOLTHA_DOWN_ON_TIMEOUT=${VOLTHA_DOWN_ON_TIMEOUT:-no}
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000104VOLTHA_LOG_LEVEL=${VOLTHA_LOG_LEVEL:-WARN}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000105VOLTHA_CHART=${VOLTHA_CHART:-onf/voltha}
106VOLTHA_CHART_VERSION=${VOLTHA_CHART_VERSION:-latest}
107VOLTHA_BBSIM_CHART=${VOLTHA_BBSIM_CHART:-onf/bbsim}
Matteo Scandolodcd29f52019-10-07 15:42:42 -0700108VOLTHA_BBSIM_CHART_VERSION=${VOLTHA_BBSIM_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000109VOLTHA_ADAPTER_SIM_CHART=${VOLTHA_ADAPTER_SIM_CHART:-onf/voltha-adapter-simulated}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000110VOLTHA_ADAPTER_SIM_CHART_VERSION=${VOLTHA_ADAPTER_SIM_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000111VOLTHA_ADAPTER_OPEN_OLT_CHART=${VOLTHA_ADAPTER_OPEN_OLT_CHART:-onf/voltha-adapter-openolt}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000112VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION=${VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000113VOLTHA_ADAPTER_OPEN_ONU_CHART=${VOLTHA_ADAPTER_OPEN_ONU_CHART:-onf/voltha-adapter-openonu}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000114VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION=${VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION:-latest}
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800115ONOS_CHART=${ONOS_CHART:-onf/onos}
Andrea Campanella21323292019-12-18 11:44:19 -0800116ONOS_CHART_VERSION=${ONOS_CHART_VERSION:-latest}
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700117ONOS_CLASSIC_CHART=${ONOS_CLASSIC_CHART:-onos/onos-classic}
118ONOS_CLASSIC_CHART_VERSION=${ONOS_CHART_VERSION:-latest}
David Bainbridgecf546362020-04-21 23:18:50 -0700119KAFKA_CHART=${KAFKA_CHART:-incubator/kafka}
David Bainbridgeb9093522020-04-15 14:32:44 -0700120KAFKA_CHART_VERSION=${KAFKA_CHART_VERSION:=0.15.3}
David Bainbridge309099c2020-05-05 08:47:29 -0700121BBSIM_SADIS_SERVER_CHART=${BBSIM_SADIS_SERVER_CHART:-bbsim-sadis/bbsim-sadis-server}
122BBSIM_SADIS_SERVER_CHART_VERSION=${BBSIM_SADIS_SERVER_CHART_VERSION:-latest}
David Bainbridgec7220622020-05-28 12:31:47 -0700123ETCD_CHART=${ETCD_CHART:-incubator/etcd}
124ETCD_CHART_VERSION=${ETCD_CHART_VERSION:-latest}
David Bainbridge879439b2020-06-12 15:59:35 -0700125RADIUS_CHART=${RADIUS_CHART:-onf/freeradius}
126RADIUS_CHART_VERSION=${RADIUS_CHART_VERSION:-latest}
David Bainbridge2eaf2cf2020-03-18 12:54:08 -0700127EXTRA_HELM_INSTALL_ARGS=${EXTRA_HELM_INSTALL_ARGS:-}
128INTERNAL_EXTRA_HELM_INSTALL_ARGS=
uottrembb16d3982020-02-28 08:34:36 +0100129NUM_OF_BBSIM=${NUM_OF_BBSIM:-1}
Matteo Scandolo67335f02020-04-09 11:19:53 -0700130NUM_OF_OPENONU=${NUM_OF_OPENONU:-1}
uottrembb16d3982020-02-28 08:34:36 +0100131MAX_NUM_OF_BBSIM=10
Matteo Scandolo67335f02020-04-09 11:19:53 -0700132MAX_NUM_OF_OPENONU=10
Matteo Scandoloc2eb0672020-05-01 14:43:15 -0700133LEGACY_BBSIM_INDEX=${LEGACY_BBSIM_INDEX:-no}
Test Userba1e7e72019-07-10 22:27:54 +0000134
David Bainbridged18f4942020-04-14 16:46:13 -0700135HOSTOS="$(uname -s | tr "[:upper:]" "[:lower:"])"
136HOSTARCH="$(uname -m | tr "[:upper:]" "[:lower:"])"
137if [ "$HOSTARCH" == "x86_64" ]; then
Test Userba1e7e72019-07-10 22:27:54 +0000138 HOSTARCH="amd64"
139fi
David Bainbridge7db44002020-04-09 12:54:29 -0700140BBSIM_LABEL="-l app=bbsim"
David Bainbridged18f4942020-04-14 16:46:13 -0700141NO_LABEL=
Test User7d866122019-07-09 17:52:35 +0000142
uottrembb16d3982020-02-28 08:34:36 +0100143# check number (range) of bbsim, max bbsim must not exceed 10 instances!
144# note: instances will be numbered from 0 to 9
145if [ "$1" == "up" ]; then
David K. Bainbridge43422402020-03-06 07:41:22 -0800146 if [ "$NUM_OF_BBSIM" -lt 1 ]; then
Matteo Scandolo67335f02020-04-09 11:19:53 -0700147 >&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 -0800148 exit 1
149 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700150 if [ "$NUM_OF_BBSIM" -gt "$MAX_NUM_OF_BBSIM" ]; then
Matteo Scandolo67335f02020-04-09 11:19:53 -0700151 >&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}"
152 exit 1
153 fi
154
155 if [ "$NUM_OF_OPENONU" -lt 1 ]; then
156 >&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}"
157 exit 1
158 fi
159 if [ "$NUM_OF_OPENONU" -gt "$MAX_NUM_OF_OPENONU" ]; then
160 >&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 -0800161 exit 1
162 fi
uottrembb16d3982020-02-28 08:34:36 +0100163fi
Test User7d866122019-07-09 17:52:35 +0000164# Verify TYPE setting
David Bainbridged18f4942020-04-14 16:46:13 -0700165if [ "$(echo ":minimal:full:" | grep -ic ":$TYPE:")" -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700166 >&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 +0000167 exit 1
168fi
169
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700170# checks to see if a given WORD is in the given LIST of words
171function is_in() {
172 local WORD LIST
173 WORD="$1"; shift
174 LIST="$*"
175 LIST=${LIST//+([[:space:],|])/:}
176
177 [ "$(echo ":$LIST:" | grep -ic ":$WORD:")" -ne 0 ]
178}
179
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700180function parseDuration() {
David Bainbridged18f4942020-04-14 16:46:13 -0700181 local DUR RESULT TERM TERMS VALUE UNIT
182 DUR=$1
183 RESULT=0
184 TERMS="$(echo "$DUR" | sed -Ee 's/([sSmMhHdD])/\1 /g' -e 's/,$//g')"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700185 for TERM in $TERMS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700186 VALUE="$(echo "$TERM" | sed -Ee 's/([0-9]+)[sSmMhHdD]/\1/')"
187 UNIT="$(echo "$TERM" | sed -Ee 's/[0-9]+([sSmMhHdD])/\1/')"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700188 case $UNIT in
189 s|S)
David Bainbridged18f4942020-04-14 16:46:13 -0700190 RESULT=$((RESULT + VALUE)) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700191 m|M)
David Bainbridged18f4942020-04-14 16:46:13 -0700192 RESULT=$((RESULT + (VALUE * 60))) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700193 h|H)
David Bainbridged18f4942020-04-14 16:46:13 -0700194 RESULT=$((RESULT + (VALUE * 3600))) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700195 d|D)
David Bainbridged18f4942020-04-14 16:46:13 -0700196 RESULT=$((RESULT + (VALUE * 86400))) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700197 *) ;;
198 esac
199 done
200 echo $RESULT
201}
202
203function doTimeout() {
204 local MSG=$1
205 2>&1 echo -e "\n${RED}${BOLD}${ERROR}TIMEOUT:${NORMAL}${RED} Operation timed out after '$WAIT_TIMEOUT': $MSG"
206 exit 125
207}
208
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800209function get_service_ep() {
210 local NS=$1
211 local NAME=$2
David Bainbridged18f4942020-04-14 16:46:13 -0700212 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 -0800213}
214
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000215# Used to verify configuration values are set to "yes" or "no" value or convert
216# equivalents to "yes" or "no"
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700217YES="y,yes,t,true,1"
218NO="n,no,f,false,0"
219YES_OR_NO="$YES,$NO"
220
221# If the given VAR matches a truth value then normalize that
222# value, else return original value
223function normalize_yes_no() {
224 local VAR VAL
225 VAR=$1
226 VAL="$(eval echo "\$$VAR")"
227 if ! is_in "$VAL" "$YES_OR_NO"; then
228 echo "$VAL"
229 return 1
230 fi
231 if is_in "$VAL" "$YES"; then
232 echo "yes"
233 else
234 echo "no"
235 fi
236 return 0
237}
238
239# If the given VAR matches a truth value then normalize that
240# value, else display an error
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000241function verify_yes_no() {
David Bainbridged18f4942020-04-14 16:46:13 -0700242 local VAR VAL
243 VAR=$1
244 VAL="$(eval echo "\$$VAR")"
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700245 if ! is_in "$VAL" "$YES_OR_NO"; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000246 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid '$VAR' value of '$VAL'. Should be 'yes' or 'no'${NORMAL}"
247 echo "INVALID"
248 return 1
249 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700250 if is_in "$VAL" "$YES"; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000251 echo "yes"
252 else
253 echo "no"
254 fi
255 return 0
256}
Test User7d866122019-07-09 17:52:35 +0000257
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000258ALL_YES_NO="\
David K. Bainbridge484d80c2020-03-05 21:44:34 -0800259 ENABLE_ONOS_EXTRANEOUS_RULES \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000260 WITH_TIMINGS \
261 WITH_BBSIM \
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800262 WITH_EAPOL \
263 WITH_DHCP \
264 WITH_IGMP \
David Bainbridge99ac7a22019-08-31 02:26:43 +0000265 WITH_CHAOS \
David Bainbridge46505fb2019-10-01 21:13:20 +0000266 WITH_ADAPTERS \
267 WITH_SIM_ADAPTERS \
268 WITH_OPEN_ADAPTERS \
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800269 WITH_PORT_FORWARDS \
Matteo Scandoloefee0432020-05-05 13:56:20 -0700270 WITH_PPROF \
Girish Gowdra4cc5d8b2020-06-11 17:12:00 -0700271 WITH_INCREMENTAL_EVTO_UPDATE \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000272 JUST_K8S \
273 DEPLOY_K8S \
274 INSTALL_ONOS_APPS \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000275 INSTALL_KUBECTL \
276 INSTALL_HELM \
David Bainbridge7f8bf992020-04-08 21:53:22 -0700277 HELM_USE_UPGRADE \
David Bainbridge46505fb2019-10-01 21:13:20 +0000278 UPDATE_HELM_REPOS \
David Bainbridge4f1b5562019-08-19 04:46:52 +0000279 WAIT_ON_DOWN \
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700280 VOLTHA_DOWN_ON_TIMEOUT \
Matteo Scandoloc2eb0672020-05-01 14:43:15 -0700281 LEGACY_BBSIM_INDEX \
David Bainbridgee4d11ca2020-05-08 10:21:10 -0700282 SCHEDULE_ON_CONTROL_NODES \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000283 "
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000284
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700285OPT_YES_NO="\
286 CONFIG_SADIS \
287 WITH_KAFKA \
288 WITH_RADIUS \
289 WITH_ETCD \
290 WITH_ONOS \
291 "
292
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000293ALL_OPTIONS="\
294 NAME \
295 TYPE \
296 $ALL_YES_NO \
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700297 $OPT_YES_NO \
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700298 WAIT_TIMEOUT \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000299 VOLTHA_LOG_LEVEL \
300 VOLTHA_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000301 VOLTHA_CHART_VERSION \
302 VOLTHA_BBSIM_CHART \
303 VOLTHA_BBSIM_CHART_VERSION \
David Bainbridge879439b2020-06-12 15:59:35 -0700304 BBSIM_SADIS_SERVER_CHART \
305 BBSIM_SADIS_SERVER_CHART_VERSION \
uottrembd5a20572020-03-06 09:15:01 +0100306 NUM_OF_BBSIM \
Matteo Scandolo67335f02020-04-09 11:19:53 -0700307 NUM_OF_OPENONU \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000308 VOLTHA_ADAPTER_SIM_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000309 VOLTHA_ADAPTER_SIM_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000310 VOLTHA_ADAPTER_OPEN_OLT_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000311 VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000312 VOLTHA_ADAPTER_OPEN_ONU_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000313 VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION \
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800314 ONOS_CHART \
Andrea Campanella21323292019-12-18 11:44:19 -0800315 ONOS_CHART_VERSION \
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700316 ONOS_CLASSIC_CHART \
317 ONOS_CLASSIC_CHART_VERSION \
David Bainbridgecf546362020-04-21 23:18:50 -0700318 KAFKA_CHART \
David Bainbridgeb9093522020-04-15 14:32:44 -0700319 KAFKA_CHART_VERSION \
David Bainbridge879439b2020-06-12 15:59:35 -0700320 ETCD_CHART \
321 ETCD_CHART_VERSION \
322 RADIUS_CHART \
323 RADIUS_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000324 ONOS_API_PORT \
325 ONOS_SSH_PORT \
Hardik Windlassb3147602020-03-09 16:59:15 +0530326 SADIS_CFG \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000327 VOLTHA_API_PORT \
328 VOLTHA_SSH_PORT \
329 VOLTHA_ETCD_PORT \
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800330 VOLTHA_KAFKA_PORT \
Matteo Scandoloefee0432020-05-05 13:56:20 -0700331 VOLTHA_PPROF_PORT \
332 OPENOLT_PPROF_PORT \
Matteo Scandolo65c35192020-05-13 10:41:21 -0700333 OFAGENT_PPROF_PORT \
David K. Bainbridge8f7f30b2020-01-08 13:06:16 -0800334 VK_RELEASE \
335 KIND_VERSION \
336 VOLTCTL_VERSION \
David Bainbridgea34993d2020-04-01 09:15:42 -0700337 HELM_VERSION \
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700338 NUM_OF_ONOS \
339 NUM_OF_ATOMIX \
David Bainbridge6ca40102020-04-08 11:30:40 -0700340 VOLTHA_NS \
341 ADAPTER_NS \
342 INFRA_NS \
343 BBSIM_NS \
David Bainbridge7db44002020-04-09 12:54:29 -0700344 SADIS_BANDWIDTH_PROFILES \
345 SADIS_SUBSCRIBERS \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000346 "
David Bainbridge01294952019-07-30 19:33:45 +0000347
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000348# Iterate over yes/no configuration options and validate
349for VAR in $ALL_YES_NO; do
David Bainbridged18f4942020-04-14 16:46:13 -0700350 eval "$VAR"="$(verify_yes_no "$VAR")"
351 if [ "$(eval echo "\$$VAR")" == "INVALID" ]; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000352 exit 1;
353 fi
354done
David Bainbridgeb270c202019-07-26 01:44:42 +0000355
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700356# Iterate over optional yes/no configuration options and
357# normalize values if they are truth values
358for VAR in $OPT_YES_NO; do
359 eval "$VAR"="$(normalize_yes_no "$VAR")"
360done
David Bainbridge15f6f232020-03-30 09:15:43 -0700361
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700362# normalize non-truth value options
363if is_in "$WITH_KAFKA" "e,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -0700364 WITH_KAFKA="external"
365fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700366if is_in "$WITH_ETCD" "e,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -0700367 WITH_ETCD="external"
368fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700369if is_in "$WITH_ONOS" "l,legacy"; then
370 WITH_ONOS="legacy"
371elif is_in "$WITH_ONOS" "c,classic"; then
372 WITH_ONOS="classic"
373elif is_in "$WITH_ONOS" "u,m,micro"; then
374 WITH_ONOS="micro"
David Bainbridge29c31cb2020-04-06 09:45:50 -0700375fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700376
377if [ "$WITH_ONOS" == "micro" ]; then
378 >&2 echo -e "${YELLOW}${BOLD}${ERROR}WARNING:${NORMAL}${YELLOW} The value specified as WITH_ONOS, '$WITH_ONOS', is not valid.${NORMAL}"
379 exit 1
David Bainbridge29c31cb2020-04-06 09:45:50 -0700380fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700381
382if is_in "$WITH_ONOS" "yes,classic"; then
383 # there is an extra utility required if we are using ONOS CLASSIC as
384 # the chart for classic specifies images differently
385 EXTRA_TOOLS+=" yq"
David Bainbridge76afd812020-04-06 09:53:52 -0700386fi
David Bainbridge696bc632020-04-05 21:49:37 -0700387
David Bainbridge22db5dd2020-05-26 12:21:21 -0700388if [ "$LEGACY_BBSIM_INDEX" == "no" ]; then
389 BBSIM_SADIS_SVC="bbsim0"
390else
391 BBSIM_SADIS_SVC="bbsim"
392fi
393
394SADIS_SUBSCRIBERS=${SADIS_SUBSCRIBERS:-http://$BBSIM_SADIS_SVC.$VOLTHA_NS.svc:50074/v2/subscribers/%s}
395SADIS_BANDWIDTH_PROFILES=${SADIS_BANDWIDTH_PROFILES:-http://$BBSIM_SADIS_SVC.$VOLTHA_NS.svc:50074/v2/bandwidthprofiles/%s}
396
David Bainbridged18f4942020-04-14 16:46:13 -0700397if [ "$HELM_USE_UPGRADE" == "yes" ]; then
David Bainbridge7f8bf992020-04-08 21:53:22 -0700398 _HELM_DESC="Upgrade/Install"
399else
400 _HELM_DESC="Install"
401fi
402
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800403# Check for prerequiste tools
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700404TOOLS="curl sed jq $EXTRA_TOOLS"
David Bainbridged18f4942020-04-14 16:46:13 -0700405if [ "$DEPLOY_K8S" == "yes" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800406 TOOLS+=" docker"
407fi
408NOT_FOUND=""
409for T in $TOOLS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700410 if [ -z "$(command -v "$T")" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800411 NOT_FOUND+=" $T"
412 fi
413done
414
David Bainbridged18f4942020-04-14 16:46:13 -0700415if [ -n "$NOT_FOUND" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800416 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} The following required tools where not found, please install them:$NOT_FOUND"
417 exit 1
418fi
419
David Bainbridged18f4942020-04-14 16:46:13 -0700420TIMEOUT_SECONDS="$(parseDuration "$WAIT_TIMEOUT")"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700421
David Bainbridge0774b232019-08-02 06:37:19 +0000422mkdir -p .voltha
423touch .voltha/ports
David Bainbridged18f4942020-04-14 16:46:13 -0700424HAVE="$(grep "$NAME" .voltha/ports)"
David Bainbridge0774b232019-08-02 06:37:19 +0000425if [ "$HAVE X" == " X" ]; then
426 # Find free port prefix
427 START=81
428 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700429 if [ "$(grep -c $START .voltha/ports)" -eq 0 ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000430 break
431 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700432 START="$((START + 1))"
David Bainbridge0774b232019-08-02 06:37:19 +0000433 done
David Bainbridged18f4942020-04-14 16:46:13 -0700434 DELTA="$((START - 81))"
David Bainbridgea2595422019-10-22 03:54:28 +0000435 ONOS_API_PORT=${ONOS_API_PORT:-${START}81}
436 ONOS_SSH_PORT=${ONOS_SSH_PORT:-${START}01}
David Bainbridged18f4942020-04-14 16:46:13 -0700437 VOLTHA_API_PORT=${VOLTHA_API_PORT:-5$((55 + DELTA))55}
438 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$((50 + DELTA))22}
439 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$((23 + DELTA))79}
440 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$((90 + DELTA))92}
Matteo Scandoloefee0432020-05-05 13:56:20 -0700441 VOLTHA_PPROF_PORT=${VOLTHA_PPROF_PORT:-$((60 + DELTA))60}
442 OPENOLT_PPROF_PORT=${OPENOLT_PPROF_PORT:-$((60 + DELTA))61}
Matteo Scandolo65c35192020-05-13 10:41:21 -0700443 OFAGENT_PPROF_PORT=${OFAGENT_PPROF_PORT:-$((60 + DELTA))62}
Test User01ed0642019-07-03 20:17:06 +0000444else
David Bainbridged18f4942020-04-14 16:46:13 -0700445 VALUES="$(echo "$HAVE" | sed -e 's/\s//g' | cut -d= -f2)"
446 ONOS_API_PORT=${ONOS_API_PORT:-$(echo "$VALUES" | cut -d, -f1)}
447 ONOS_SSH_PORT=${ONOS_SSH_PORT:-$(echo "$VALUES" | cut -d, -f2)}
448 VOLTHA_API_PORT=${VOLTHA_API_PORT:-$(echo "$VALUES" | cut -d, -f3)}
449 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$(echo "$VALUES" | cut -d, -f4)}
450 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$(echo "$VALUES" | cut -d, -f5)}
451 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(echo "$VALUES" | cut -d, -f6)}
Matteo Scandoloefee0432020-05-05 13:56:20 -0700452 VOLTHA_PPROF_PORT=${VOLTHA_PPROF_PORT:-$(echo "$VALUES" | cut -d, -f7)}
453 OPENOLT_PPROF_PORT=${OPENOLT_PPROF_PORT:-$(echo "$VALUES" | cut -d, -f8)}
Matteo Scandolo65c35192020-05-13 10:41:21 -0700454 OFAGENT_PPROF_PORT=${OFAGENT_PPROF_PORT:-$(echo "$VALUES" | cut -d, -f9)}
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800455
Matteo Scandoloefee0432020-05-05 13:56:20 -0700456 # Some ports were added after the .voltha/ports files was created.
457 # Calculate the original DELTA from the VOLTHA_SSH_PORT so that it can
458 # be used to set up newer port-forwards.
459 DELTA="$((VOLTHA_SSH_PORT/100-50))"
460
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800461 if [ -z "$VOLTHA_KAFKA_PORT" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -0700462 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$((90 + DELTA))92}
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800463 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -0700464
465 if [ -z "$VOLTHA_PPROF_PORT" ]; then
466 VOLTHA_PPROF_PORT=${VOLTHA_PPROF_PORT:-$((60 + DELTA))60}
467 fi
468 if [ -z "$OPENOLT_PPROF_PORT" ]; then
469 OPENOLT_PPROF_PORT=${OPENOLT_PPROF_PORT:-$((60 + DELTA))61}
470 fi
Matteo Scandolo65c35192020-05-13 10:41:21 -0700471 if [ -z "$OFAGENT_PPROF_PORT" ]; then
472 OFAGENT_PPROF_PORT=${OFAGENT_PPROF_PORT:-$((60 + DELTA))62}
473 fi
Test User01ed0642019-07-03 20:17:06 +0000474fi
475
David Bainbridged18f4942020-04-14 16:46:13 -0700476PORTTMP="$(mktemp -u)"
477grep -v "$NAME" .voltha/ports > "$PORTTMP"
Matteo Scandolo65c35192020-05-13 10:41:21 -0700478echo "$NAME=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT,$VOLTHA_KAFKA_PORT,$VOLTHA_PPROF_PORT,$OPENOLT_PPROF_PORT,$OFAGENT_PPROF_PORT" >> "$PORTTMP"
David Bainbridged18f4942020-04-14 16:46:13 -0700479cp "$PORTTMP" .voltha/ports
480rm -f "$PORTTMP"
David Bainbridge0774b232019-08-02 06:37:19 +0000481
David Bainbridge27790d62019-08-13 22:43:19 +0000482export ONOS_API_PORT ONOS_SSH_PORT
David Bainbridge01294952019-07-30 19:33:45 +0000483
Test Userd87942b2019-07-03 07:20:24 +0000484IDX=1
David Bainbridgee87067b2019-08-12 22:00:12 +0000485CLOCK="TIME:"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000486SPIN_PARTS=
487NOT_VERIFIED=
David Bainbridgef858a022019-08-14 21:25:11 +0000488THEX=
489BUILD=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000490VERIFIED=
491HELM=
492OLD_KEY=
493BIRD=
494HIGH_VOLTAGE=
495PLUG=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000496FORWARD=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000497GO=
498DOWNLOAD=
499GEAR=
500NO_ENTRY=
501LOCK=
502
David Bainbridged18f4942020-04-14 16:46:13 -0700503if [ "$FANCY" -eq 1 ]; then
504 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 +0000505 CLOCK="\xe2\x8f\xb1"
David Bainbridgef858a022019-08-14 21:25:11 +0000506 THEX="${RED}${BOLD}\xe2\x9c\x97\x20${NORMAL}"
David Bainbridgef858a022019-08-14 21:25:11 +0000507 BUILD="${YELLOW}${BOLD}\xf0\x9f\x8f\x97${NORMAL}"
508 NOT_VERIFIED="$BUILD"
509 VERIFIED="${GREEN}${BOLD}\xe2\x9c\x93\x20${NORMAL}"
510 HELM="${BLUE}${BOLD}\xE2\x8E\x88${NORMAL}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000511 OLD_KEY="\xF0\x9F\x97\x9D"
512 BIRD="\xF0\x9F\x90\xA6"
513 HIGH_VOLTAGE="\xE2\x9A\xA1"
514 PLUG="\xF0\x9F\xa7\xa9"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000515 FORWARD="\xE2\x87\xA8"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000516 GO="\xf0\x9f\x9a\x80"
517 DOWNLOAD="\xf0\x9f\x93\xa5"
518 GEAR="\xe2\x9a\x99"
519 NO_ENTRY="\xe2\x9b\x94"
520 LOCK="\xf0\x9f\x94\x92"
521fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700522
David Bainbridge712afb82019-08-14 19:55:58 +0000523duration() {
David Bainbridged18f4942020-04-14 16:46:13 -0700524 local h m s t
525 h="$(($1 / 3600))"
526 m="$(($1 % 3600 / 60))"
527 s="$(($1 % 60))"
528 t=""
David Bainbridgee87067b2019-08-12 22:00:12 +0000529
David Bainbridged18f4942020-04-14 16:46:13 -0700530 if [ "$h" -gt 0 ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +0000531 t="$t${h}h"
532 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700533 if [ "$m" -gt 0 ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +0000534 t="$t${m}m"
535 fi
David Bainbridge712afb82019-08-14 19:55:58 +0000536 echo "$t${s}s"
537}
538
539printtime() {
David Bainbridged18f4942020-04-14 16:46:13 -0700540 local INDENT
David Bainbridge712afb82019-08-14 19:55:58 +0000541 if [ "$1" == "-" ]; then
542 INDENT=" "
543 shift
544 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700545 echo -e "$INDENT $CLOCK $(duration "$1")"
David Bainbridgee87067b2019-08-12 22:00:12 +0000546}
547
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700548bspin() {
Test Userd87942b2019-07-03 07:20:24 +0000549 IDX=1
David Bainbridged18f4942020-04-14 16:46:13 -0700550 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700551 if [ "$1" == "-" ]; then
552 INDENT=" "
553 shift
554 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700555 if [ "$FANCY" -eq 0 ]; then
556 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000557 if [ "$LINE X" == " X" ]; then
558 return
559 fi
560 echo -e "$CIVIS$INDENT$*"
561 else
562 echo -en "$CIVIS$INDENT $*"
563 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700564}
565
566sspin() {
David Bainbridged18f4942020-04-14 16:46:13 -0700567 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700568 if [ "$1" == "-" ]; then
569 INDENT=" "
570 shift
571 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700572 if [ "$FANCY" -eq 0 ]; then
573 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000574 if [ "$LINE X" == " X" ]; then
575 return
576 fi
577 echo -e "$INDENT$*"
578 else
David Bainbridged18f4942020-04-14 16:46:13 -0700579 C="$(echo "$SPIN_PARTS" | cut '-d ' -f "$IDX")"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000580 echo -en "\r$INDENT$C $*"
David Bainbridged18f4942020-04-14 16:46:13 -0700581 IDX="$((IDX + 1))"
582 if [ "$IDX" -gt 8 ]; then
David Bainbridge38dc1e82019-08-12 15:18:45 +0000583 IDX=1
584 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700585 fi
586}
587
588espin() {
David Bainbridged18f4942020-04-14 16:46:13 -0700589 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700590 if [ "$1" == "-" ]; then
591 INDENT=" "
592 shift
593 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700594 if [ "$FANCY" -eq 0 ]; then
595 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000596 if [ "$LINE X" == " X" ]; then
597 return
598 fi
599 echo -e "$INDENT$*"
600 else
601 echo -e "\r$INDENT$*$CNORM"
602 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700603}
604
David Bainbridged18f4942020-04-14 16:46:13 -0700605if [ "$1" == "get" ] && [ "$2" == "voltconfig" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000606 echo "$HOME/.volt/config-$NAME"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000607 exit
608fi
609
David Bainbridgee4d11ca2020-05-08 10:21:10 -0700610if [ $# -ne 1 ] || ! is_in "$1" "up,down,dump,clean"; then
David Bainbridgeac7f8072019-08-01 22:15:33 +0000611 >&2 echo "What wouild you like to do today:"
612 >&2 echo " up - bring up voltha"
613 >&2 echo " down - tear down voltha"
614 >&2 echo " dump - create a debug dump of running system"
615 exit 1
616fi
617
David Bainbridge4f1b5562019-08-19 04:46:52 +0000618push_onos_config() {
David Bainbridged18f4942020-04-14 16:46:13 -0700619 local TYPE MSG RESOURCE DATA CMD_ECHO CMD_OUTPUT SC_OUTPUT WAIT_START NOW
620 TYPE=$1
621 MSG=$2
622 RESOURCE=$3
623 DATA=$4
David Bainbridge4f1b5562019-08-19 04:46:52 +0000624
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800625 # Thanks to the latest version of ONOS using the return code 207 this gets a
626 # whole lot nastier. Can't thank them enough for doing this. So in order to
627 # capture the command and the output in the log file as well as capture the
628 # status code to verify it is 200 and not 207 mutltiple files and a bit of
629 # hackery must be used. Thanks again ONOS.
David Bainbridged18f4942020-04-14 16:46:13 -0700630 CMD_ECHO="$(mktemp -u)"
631 CMD_OUTPUT="$(mktemp -u)"
632 SC_OUTPUT="$(mktemp -u)"
633 WAIT_START="$(date +%s)"
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800634
David Bainbridge4f1b5562019-08-19 04:46:52 +0000635 bspin - "$MSG $GEAR"
636 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700637 NOW="$(date +%s)"
638 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700639 espin - "$THEX"
David Bainbridged18f4942020-04-14 16:46:13 -0700640 rm -f "$CMD_ECHO" "$CMD_OUTPUT" "$SC_OUTPUT"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700641 doTimeout "waiting for ONOS config push on $RESOURCE"
642 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700643 if [ "$TYPE" == "file" ]; then
644 (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 -0700645 RESULT=$?
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800646 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700647 if [ "$TYPE" == "json" ]; then
648 (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 -0700649 RESULT=$?
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800650 fi
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800651 # Dump everything to the log
David Bainbridged18f4942020-04-14 16:46:13 -0700652 cat "$CMD_ECHO" >> "$LOG"
653 test -r "$CMD_OUTPUT" && cat "$CMD_OUTPUT" >> "$LOG"
654 SC="$(cat "$SC_OUTPUT")"
655 echo "RESPONSE CODE: $SC" >> "$LOG"
656 echo "ERROR CODE: $RESULT" >> "$LOG"
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800657
658 # clean up temp files
David Bainbridged18f4942020-04-14 16:46:13 -0700659 rm -f "$CMD_ECHO" "$CMD_OUTPUT" "$SC_OUTPUT"
660 if [ "$RESULT" -eq 0 ] && [ "$SC" == "200" ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000661 break
662 fi
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800663 sleep 1
David Bainbridge4f1b5562019-08-19 04:46:52 +0000664 sspin -
665 done
David Bainbridged18f4942020-04-14 16:46:13 -0700666 espin - "$VERIFIED"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000667}
668
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800669check_onos_app_active() {
David Bainbridged18f4942020-04-14 16:46:13 -0700670 local APP_ID WAIT_START RESULT NOW
671 APP_ID=$1
672 WAIT_START="$(date +%s)"
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800673
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700674 bspin - "Checking that $APP_ID is active $CLOCK"
675 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700676 NOW="$(date +%s)"
677 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700678 espin - "$THEX"
679 doTimeout "waiting for ONOS application activation '$APP_ID'"
680 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700681 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 -0700682 break
683 fi
684 sleep 1
685 sspin -
686 done
687 sleep 5 # OSGI components take a little longer that the app to activate
David Bainbridged18f4942020-04-14 16:46:13 -0700688 espin - "$VERIFIED"
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800689}
690
David Bainbridge4f1b5562019-08-19 04:46:52 +0000691override_onos_app() {
David Bainbridged18f4942020-04-14 16:46:13 -0700692 local APP NAME WAIT_START NOW
693 APP=$1
694 NAME="$(basename "$APP" | sed -e 's/^[0-9][0-9]*-//g' -e 's/-.*$//g')"
695 WAIT_START="$(date +%s)"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700696
David Bainbridge4f1b5562019-08-19 04:46:52 +0000697 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700698 NOW="$(date +%s)"
699 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700700 espin - "$THEX"
701 doTimeout "waiting to overwrite ONOS application '$APP'"
702 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +0000703 sspin -
704 # Attempt to delete old version (if it exists)
David Bainbridged18f4942020-04-14 16:46:13 -0700705 (set -x; curl --fail -sSL --user karaf:karaf -X DELETE "http://$_ONOS_API_EP/onos/v1/applications/$NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
706 RESULT=$?
David Bainbridge4f1b5562019-08-19 04:46:52 +0000707 sspin -
David Bainbridged18f4942020-04-14 16:46:13 -0700708 if [ $RESULT -ne 0 ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000709 continue
710 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700711 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 +0000712 break
713 fi
714 sleep .2
715 done
716}
717
718activate_onos_app() {
David Bainbridged18f4942020-04-14 16:46:13 -0700719 local MSG APP WAIT_START NOW
720 MSG="$1"
721 APP=$2
722 WAIT_START="$(date +%s)"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000723
724 bspin - "$MSG $GO"
725 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700726 NOW="$(date +%s)"
727 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700728 espin - "$THEX"
729 doTimeout "waiting to activate ONOS application '$APP'"
730 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +0000731 sspin -
David Bainbridged18f4942020-04-14 16:46:13 -0700732 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 +0000733 break
734 fi
735 sleep .2
736 done
737 espin - "$VERIFIED"
738}
739
740count_pods() {
David Bainbridged18f4942020-04-14 16:46:13 -0700741 local NAMESPACE STATES LABELS CMD PODS
742 NAMESPACE=$1; shift
David Bainbridge4f1b5562019-08-19 04:46:52 +0000743 if [ "$NAMESPACE" == "all-namespaces" ]; then
744 NAMESPACE="--all-namespaces"
745 else
746 NAMESPACE="-n $NAMESPACE"
747 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700748 STATES=$1; shift
749 LABELS=$1; shift
750 CMD=("kubectl get $NAMESPACE $LABELS pod")
751 PODS=$(${CMD[*]} -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}")
David Bainbridge4f1b5562019-08-19 04:46:52 +0000752 local COUNT=0
753 local PATTERNS="$*"
754 for POD in $PODS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700755 local NAME STATE CONTAINERS TOTAL FOUND
756 NAME="$(echo "$POD" | cut -d/ -f 1)"
757 STATE="$(echo "$POD" | cut -d/ -f 2)"
758 CONTAINERS="$(echo "$POD" | cut -d/ -f 3 | sed -e 's/_/ /g')"
759 if [ "$STATES" == "*" ] || [ "$(echo "$STATES" | grep -c ":$STATE:")" -ne 0 ]; then
760 TOTAL="$(echo "$CONTAINERS" | wc -w)"
761 FOUND="$(echo "$CONTAINERS" | grep -o true | wc -l)"
762 if [ "$TOTAL" -eq "$FOUND" ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000763 for PATTERN in $PATTERNS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700764 if [[ "$NAME" =~ $PATTERN ]]; then
765 COUNT="$((COUNT + 1))"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000766 break
767 fi
768 done
769 fi
770 fi
771 done
David Bainbridge4f1b5562019-08-19 04:46:52 +0000772 echo $COUNT
773}
774
775wait_for_pods() {
David Bainbridged18f4942020-04-14 16:46:13 -0700776 local INDENT NAMESPACE EXPECT TYPE MESSAGE LABELS PATTERNS STATES HAVE ALL WAIT_START NOW
David Bainbridge4f1b5562019-08-19 04:46:52 +0000777 if [ "$1" == "-" ]; then
778 INDENT=$1; shift
779 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700780 NAMESPACE=$1; shift
781 EXPECT=$1; shift
782 TYPE=$1; shift
783 MESSAGE=$1; shift
784 LABELS=$1; shift
785 PATTERNS=("$*")
786 STATES=":Running:"
David Bainbridge99ac7a22019-08-31 02:26:43 +0000787 if [ "$TYPE" == "not" ]; then
788 STATES="*"
789 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700790 HAVE="$(count_pods "$NAMESPACE" "$STATES" "$LABELS" "${PATTERNS[@]}")"
791 ALL=$HAVE
David Bainbridge4f1b5562019-08-19 04:46:52 +0000792 if [ "$TYPE" == "only" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -0700793 ALL="$(count_pods "all-namespaces" "*" ".*")"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000794 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700795 COUNT="$((300 / 15))"
796 WAIT_START="$(date +%s)"
797 bspin "$INDENT" "$MESSAGE"
798 sspin "$INDENT"
799 if [ "$HAVE" -ne "$EXPECT" ] || [ "$ALL" -ne "$HAVE" ]; then
800 while [ "$HAVE" -ne "$EXPECT" ] || [ "$ALL" -ne "$HAVE" ]; do
801 NOW="$(date +%s)"
802 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
803 espin "$INDENT" "$THEX"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700804 doTimeout "waiting for PODs to start"
805 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700806 sspin "$INDENT"
807 COUNT="$((COUNT - 1))"
808 if [ "$COUNT" -eq 0 ]; then
809 HAVE="$(count_pods "$NAMESPACE" "$STATES" "$LABELS" "${PATTERNS[@]}")"
810 ALL="$HAVE"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000811 if [ "$TYPE" == "only" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -0700812 ALL="$(count_pods "all-namespaces" "*" ".*")"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000813 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700814 COUNT="$((300 / 15))"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000815 fi
816 sleep .15
817 done
818 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700819 espin "$INDENT" "$VERIFIED"
820 if [ "$HAVE" -ne "$EXPECT" ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000821 return 1
822 fi
823 return 0
824}
825
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800826port_forward() {
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700827 local NS=$1; shift
828 local SVC=$1; shift
829 local PORTS="$*"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800830 local TAG=$SVC-$NAME
831
David Bainbridge1d2c5842020-06-03 15:29:07 -0700832 (set -x; _TAG="$TAG" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n $NS service/$SVC $PORTS; done" >>"$PFLOG" 2>&1 &) >>"$PFLOG" 2>&1
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800833}
834
835kill_port_forward() {
David Bainbridge1d2c5842020-06-03 15:29:07 -0700836 local TAG P_IDS PARENTS KIDS UNKNOWN PP_ID PF
837
838 while [ $# -gt 0 ]; do
839 PF=$1; shift
840 TAG=
841 if [ "$PF" != "__ALL__" ]; then
842 TAG="$PF-$NAME"
843 fi
844 PARENTS=
845 KIDS=
846 UNKNOWN=
847 # shellcheck disable=SC2009
848 P_IDS="$(ps e -ww -A | grep "_TAG=$TAG" | grep -v grep | awk '{print $1}')"
849 if [ -n "$P_IDS" ]; then
850 for P_ID in $P_IDS; do
851 PP_ID="$(ps -o ppid "$P_ID" | tail -n +2)"
852 if [ -n "$PP_ID" ]; then
853 if [ "$PP_ID" -eq 1 ]; then
854 PARENTS="$PARENTS $P_ID"
855 else
856 KIDS="$KIDS $P_ID"
857 fi
David Bainbridgec6871d22019-11-13 17:10:31 +0000858 else
David Bainbridge1d2c5842020-06-03 15:29:07 -0700859 UNKNOWN="$UNKNOWN $P_ID"
David Bainbridgec6871d22019-11-13 17:10:31 +0000860 fi
David Bainbridge1d2c5842020-06-03 15:29:07 -0700861 done
862 if [ -n "$PARENTS" ]; then
863 # shellcheck disable=SC2086
864 while ps -h $PARENTS >/dev/null 2>&1; do
865 (set -x; eval "kill -9 $PARENTS" >>"$LOG" 2>&1) >>"$LOG" 2>&1
866 done
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800867 fi
David Bainbridge1d2c5842020-06-03 15:29:07 -0700868 if [ -n "$KIDS" ]; then
869 # shellcheck disable=SC2086
870 while ps -h $KIDS >/dev/null 2>&1; do
871 (set -x; eval "kill -9 $KIDS" >>"$LOG" 2>&1) >>"$LOG" 2>&1
872 done
873 fi
874 if [ -n "$UNKNOWN" ]; then
875 # shellcheck disable=SC2086
876 while ps -h $UNKNOWN >/dev/null 2>&1; do
877 (set -x; eval "kill -9 $UNKNOWN" >>"$LOG" 2>&1) >>"$LOG" 2>&1
878 done
879 fi
880 fi
881 done
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800882}
883
David Bainbridgecf546362020-04-21 23:18:50 -0700884resolve_chart_version() {
885 [ "$2" != "latest" ] && echo "$2" && return
886 helm inspect chart "$1" | grep "^version:" | awk '{print $2}'
887}
888
Jonathan Hart6a91e6c2020-04-16 14:28:33 -0700889# Compares two semver-formatted version strings (e.g. 2.4.3)
890# Returns 0 if $1 == $2, returns 1 if $1 > $2 and returns 2 if $1 < $2
891compare_versions() {
892 [ "$1" == "$2" ] && return 0
Jonathan Hart6a91e6c2020-04-16 14:28:33 -0700893 local lowest
894 lowest=$(echo -e "$1\n$2" | sort -V | head -1)
895 [ "$lowest" == "$1" ] && return 2
896 return 1
897}
898
David Bainbridgeac7f8072019-08-01 22:15:33 +0000899if [ "$1" == "down" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000900 echo "Tearing down voltha cluster $NAME"
901 LOG="down-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -0700902 date -u +"%Y%m%dT%H%M%SZ" >"$LOG"
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700903 if is_in "$WITH_ONOS" "yes,legacy,classic"; then
David Bainbridge696bc632020-04-05 21:49:37 -0700904 bspin "Remove port-forwards: onos-ui-$NAME"
905 kill_port_forward onos-ui
906 sspin "Remove port-forwards: onos-ssh-$NAME$CEOL"
907 kill_port_forward onos-ssh
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700908 bspin "Remove port-forwards: onos-onos-classic-hs-$NAME$CEOL"
909 kill_port_forward onos-onos-classic-hs
David Bainbridge696bc632020-04-05 21:49:37 -0700910 fi
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800911 sspin "Remove port-forwards: voltha-api-$NAME$CEOL"
David Bainbridge1d2c5842020-06-03 15:29:07 -0700912 kill_port_forward voltha-api voltha-voltha-api
David Bainbridgec7220622020-05-28 12:31:47 -0700913 if is_in "$WITH_ETCD" "yes,external"; then
914 sspin "Remove port-forwards: etcd-$NAME$CEOL"
915 kill_port_forward "etcd"
David Bainbridge696bc632020-04-05 21:49:37 -0700916 fi
David Bainbridgec7220622020-05-28 12:31:47 -0700917 if is_in "$WITH_KAFKA" "yes,external"; then
918 sspin "Remove port-forwards: kafka-$NAME$CEOL"
919 kill_port_forward "kafka"
David Bainbridge696bc632020-04-05 21:49:37 -0700920 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -0700921
922 if [ "$WITH_PPROF" == "yes" ]; then
David Bainbridgec7220622020-05-28 12:31:47 -0700923 sspin "Remove port-forwards: *-profiler$CEOL"
David Bainbridge1d2c5842020-06-03 15:29:07 -0700924 kill_port_forward voltha-rw-core-profiler voltha-voltha-rw-core-profiler
925 kill_port_forward voltha-of-agent-profiler voltha-voltha-of-agent-profiler
David Bainbridgec7220622020-05-28 12:31:47 -0700926 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
David Bainbridge1d2c5842020-06-03 15:29:07 -0700927 kill_port_forward adapter-open-olt-profiler open-olt-adapter-open-olt-profiler
David Bainbridgec7220622020-05-28 12:31:47 -0700928 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -0700929 fi
930
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800931 espin "$VERIFIED Remove port-forwards$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -0700932 if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridgeac7f8072019-08-01 22:15:33 +0000933 if [ -x ./bin/kind ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000934 bspin "Delete Kubernetes Kind Cluster"
David Bainbridged18f4942020-04-14 16:46:13 -0700935 (set -x; ./bin/kind delete cluster --name "voltha-$NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
936 espin "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000937 else
David Bainbridge0774b232019-08-02 06:37:19 +0000938 espin "$NO_ENTRY Delete Kubernetes Kind Cluster: kind command not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000939 fi
940 else
David Bainbridge309099c2020-05-05 08:47:29 -0700941 if [ "$CONFIG_SADIS" == "external" ]; then
942 bspin "Remove configmap for BBSIM SADIS server"
943 (set -x; kubectl -n "$BBSIM_NS" delete --ignore-not-found configmap kube-config >>"$LOG" 2>&1) >>"$LOG" 2>&1
944 espin "$VERIFIED"
945 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700946 EXISTS="$(helm list -q)"
David Bainbridge76afd812020-04-06 09:53:52 -0700947 EXPECT="voltha"
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700948 if is_in "$WITH_ONOS" "yes,legacy,classic"; then
David Bainbridge696bc632020-04-05 21:49:37 -0700949 EXPECT+=" onos"
950 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700951 if [ "$WITH_RADIUS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700952 EXPECT+=" radius"
953 fi
David Bainbridge309099c2020-05-05 08:47:29 -0700954 if [ "$CONFIG_SADIS" == "external" ]; then
955 EXPECT+=" bbsim-sadis-server"
956 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700957 if [ "$WITH_BBSIM" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700958 EXPECT+=" bbsim"
959 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700960 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700961 EXPECT+=" open-olt open-onu"
962 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700963 if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700964 EXPECT+=" sim"
965 fi
David Bainbridgec7220622020-05-28 12:31:47 -0700966 if is_in "$WITH_ETCD" "yes,external"; then
967 EXPECT+=" etcd"
David Bainbridge76afd812020-04-06 09:53:52 -0700968 fi
David Bainbridgec7220622020-05-28 12:31:47 -0700969 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -0700970 EXPECT+=" kafka"
971 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000972 bspin "Remove Helm Deployments"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000973 for i in $EXISTS; do
David K. Bainbridge43422402020-03-06 07:41:22 -0800974 for j in $EXPECT; do
David Bainbridged18f4942020-04-14 16:46:13 -0700975 if [[ "$i" =~ $j ]]; then
David K. Bainbridge43422402020-03-06 07:41:22 -0800976 sspin "Remove Helm Deployments: $i$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -0700977 (set -x; ./bin/helm delete --no-hooks --purge "$i" >>"$LOG" 2>&1) >>"$LOG" 2>&1
David K. Bainbridge43422402020-03-06 07:41:22 -0800978 fi
979 done
uottrembb16d3982020-02-28 08:34:36 +0100980 done
David Bainbridge0774b232019-08-02 06:37:19 +0000981 espin "$VERIFIED Remove Helm Deployments$CEOL"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000982 if [ "$WAIT_ON_DOWN" == "yes" ]; then
Matteo Scandoloe93c9eb2020-06-03 12:08:51 -0700983 PODS="voltha-ofagent.* voltha-rw-core.*"
David Bainbridge76afd812020-04-06 09:53:52 -0700984 INFRA_PODS=
985 ADAPT_PODS=
986 SIM_PODS=
David Bainbridged18f4942020-04-14 16:46:13 -0700987 if [ "$WITH_RADIUS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700988 PODS+=" radius.*"
989 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700990 if [ "$WITH_BBSIM" == "yes" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700991 SIM_PODS+=" bbsim.*"
David Bainbridge696bc632020-04-05 21:49:37 -0700992 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700993 if [ "$WITH_OPEN_ADAPTERS" ] || [ "$WITH_SIM_ADAPTERS" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700994 ADAPT_PODS+=" adapter-*"
David Bainbridge696bc632020-04-05 21:49:37 -0700995 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700996 if is_in "$WITH_ONOS" "yes,legacy,classic"; then
David Bainbridge76afd812020-04-06 09:53:52 -0700997 INFRA_PODS+=" onos-.*"
998 fi
David Bainbridgec7220622020-05-28 12:31:47 -0700999 if is_in "$WITH_ETCD" "yes,external"; then
1000 INFRA_PODS+=" etcd.*"
David Bainbridge76afd812020-04-06 09:53:52 -07001001 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001002 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -07001003 INFRA_PODS+=" kafka.*"
1004 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001005 if [ -n "$SIM_PODS" ]; then
1006 wait_for_pods "$BBSIM_NS" 0 "not" "Waiting for BBSIM PODs to terminate" "$BBSIM_LABEL" "$SIM_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -07001007 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001008 if [ -n "$INFRA_PODS" ]; then
1009 wait_for_pods "$INFRA_NS" 0 "not" "Waiting for infrastructure PODs to terminate" "$NO_LABEL" "$INFRA_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -07001010 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001011 if [ -n "$ADAPT_PODS" ]; then
1012 wait_for_pods "$ADAPTER_NS" 0 "not" "Waiting for adapter PODs to terminate" "$NO_LABEL" "$ADAPT_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -07001013 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001014 wait_for_pods "$VOLTHA_NS" 0 "not" "Waiting for VOLTHA PODs to terminate" "$NO_LABEL" "$PODS"
David Bainbridge4f1b5562019-08-19 04:46:52 +00001015 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +00001016 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001017 exit
David Bainbridgeac7f8072019-08-01 22:15:33 +00001018fi
1019
1020if [ "$1" == "dump" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001021 LOG="dump-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -07001022 TS="$(date -u +"%Y%m%dT%H%M%SZ")"
1023 if [ -n "$DUMP_FROM" ]; then
1024 TS=${DUMP_FROM//[:-]}
David Bainbridge76514a02019-10-08 01:50:35 +00001025 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001026 WORK="$(mktemp -u -d)"
David Bainbridge0774b232019-08-02 06:37:19 +00001027 DATA=$WORK/voltha-debug-dump-$NAME-$TS
David Bainbridged18f4942020-04-14 16:46:13 -07001028 mkdir -p "$DATA"
1029 echo "$TS" > "$LOG"
David Bainbridge0774b232019-08-02 06:37:19 +00001030 echo -e "Capturing debug dump to voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001031 bspin - "Copy install log"
David Bainbridged18f4942020-04-14 16:46:13 -07001032 if [ -f "install-$NAME.log" ]; then
1033 (set -x; cp "install-$NAME.log" "$DATA/install-$NAME.log") >>"$LOG" 2>&1
1034 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001035 else
David Bainbridge0774b232019-08-02 06:37:19 +00001036 espin - "$NO_ENTRY Copy install log: install-$NAME.log not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001037 fi
1038 bspin - "Dumping Kubernetes PODs"
David Bainbridged18f4942020-04-14 16:46:13 -07001039 (set -x; kubectl get --all-namespaces pods >> "$DATA/all-pods.txt" 2>&1) >>"$LOG" 2>&1
1040 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001041 bspin - "Dumping Kubernetes SERVICEs"
David Bainbridged18f4942020-04-14 16:46:13 -07001042 (set -x; kubectl get --all-namespaces svc >> "$DATA/all-services.txt" 2>&1) >>"$LOG" 2>&1
1043 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001044 bspin - "Dumping Kubernetes EVENTs"
David Bainbridged18f4942020-04-14 16:46:13 -07001045 (set -x; kubectl get --all-namespaces events >> "$DATA/all-events.txt" 2>&1) >>"$LOG" 2>&1
1046 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001047 bspin - "Dumping VOLTHA POD details"
David Bainbridged18f4942020-04-14 16:46:13 -07001048 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 +00001049 SINCE=
David Bainbridged18f4942020-04-14 16:46:13 -07001050 if [ -n "$DUMP_FROM" ]; then
David Bainbridgecfd7ca12019-10-06 03:31:41 +00001051 SINCE="--since-time=$DUMP_FROM"
1052 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +00001053 for POD in $PODS; do
David Bainbridged18f4942020-04-14 16:46:13 -07001054 NS="$(echo "$POD" | cut -d: -f1)"
1055 POD="$(echo "$POD" | cut -d: -f2)"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001056 sspin - "Dumping VOLTHA POD details: $POD$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -07001057 mkdir -p "$DATA/$POD"
1058 (set -x; kubectl describe -n "$NS" "$POD" >> "$DATA/$POD/describe.txt" 2>&1) >>"$LOG" 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +00001059 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridged18f4942020-04-14 16:46:13 -07001060 (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 +00001061 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridged18f4942020-04-14 16:46:13 -07001062 (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 +00001063 sspin - "Dumping VOLTHA POD details: $POD"
1064 done
1065 espin - "$VERIFIED Dumping VOLTHA POD details$CEOL"
1066 bspin - "Dumping ETCD"
David Bainbridged18f4942020-04-14 16:46:13 -07001067 if [ -n "$(command -v etcdctl)" ]; then
1068 (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
1069 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001070 else
1071 espin - "$NO_ENTRY Dumping ETCD: etcdctl command not available"
1072 fi
David Bainbridge0774b232019-08-02 06:37:19 +00001073 bspin - "Creating compressed TAR: voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridged18f4942020-04-14 16:46:13 -07001074 (set -x; tar -C "$WORK" -zcf "voltha-debug-dump-$NAME-$TS.tgz" "./voltha-debug-dump-$NAME-$TS") >>"$LOG" 2>&1
1075 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001076 bspin - "Cleanup"
David Bainbridged18f4942020-04-14 16:46:13 -07001077 (set -x; rm -rf "$WORK") >>"$LOG" 2>&1
1078 espin - "$VERIFIED"
1079 bspin - "$(ls -l "voltha-debug-dump-$NAME-$TS.tgz")"
1080 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001081 exit
1082fi
1083
David Bainbridge0774b232019-08-02 06:37:19 +00001084LOG="install-$NAME.log"
David Bainbridge1d2c5842020-06-03 15:29:07 -07001085PFLOG="port-forward-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -07001086date > "$LOG"
1087echo "PORTS=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT" >> "$LOG"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001088
1089# Output install options to log
David Bainbridged18f4942020-04-14 16:46:13 -07001090echo "OPTIONS" >> "$LOG"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001091for O in $ALL_OPTIONS; do
David Bainbridged18f4942020-04-14 16:46:13 -07001092 VAL="$(eval echo "\$$O")"
1093 if [ -n "$VAL" ]; then
1094 printf " %-30s = %s\n" "$O" "$VAL" >> "$LOG"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001095 fi
1096done
1097
David Bainbridgee4d11ca2020-05-08 10:21:10 -07001098# Force remove any existing k8s port-forward processes. This will
1099# remove them for all kind clusters.
David Bainbridgee4d11ca2020-05-08 10:21:10 -07001100if [ "$1" == "clean" ]; then
1101 kill_port_forward __ALL__
1102 exit
1103fi
1104
David Bainbridgefad50732020-05-01 17:00:12 -07001105helm_values() {
1106 local NAMESPACE=$1; shift
1107 local INAME=$1; shift
1108 local CHART=$1; shift
1109 local CHART_VERSION=$1; shift
1110
1111 if [ "$CHART_VERSION X" != " X" ] && [ "$CHART_VERSION" != "latest" ]; then
1112 CHART_VERSION="--version $CHART_VERSION"
1113 else
1114 CHART_VERSION=
1115 fi
1116
1117 local CHART_ARGS=
1118 if [ -r "${INAME}-values.yaml" ]; then
1119 CHART_ARGS="-f ${INAME}-values.yaml"
1120 fi
1121
1122 if [ "$HELM_USE_UPGRADE" == "yes" ]; then
1123 _HELM_COMMAND="upgrade --install"
1124 _HELM_ARGS="xxxdryrunxxx"
1125 else
1126 _HELM_COMMAND="install"
1127 _HELM_ARGS="--name xxxdryrunxxx"
1128 fi
1129 CMD=("helm $_HELM_COMMAND --debug --dry-run -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")
1130 ${CMD[*]} 2>/dev/null | awk 'PRINT==1 {print}; /^USER-SUPPLIED VALUES:/ {PRINT = 1}; /^$/ {PRINT = 0}'
1131}
1132
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001133helm_install() {
David Bainbridgec7220622020-05-28 12:31:47 -07001134 local INDENT NOW VALUES_FILE PPROF_ARG
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001135 if [ "$1" == "-" ]; then
1136 INDENT=$1; shift
1137 fi
1138 local NAMESPACE=$1; shift
David Bainbridge0774b232019-08-02 06:37:19 +00001139 local INAME=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001140 local CHART=$1; shift
David Bainbridge90fd8e32019-08-21 23:32:47 +00001141 local CHART_VERSION=$1; shift
David Bainbridgec7220622020-05-28 12:31:47 -07001142 local FILTER=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001143 local MESSAGE=$*
1144
David Bainbridged18f4942020-04-14 16:46:13 -07001145 if [ "$CHART_VERSION X" != " X" ] && [ "$CHART_VERSION" != "latest" ]; then
David Bainbridge90fd8e32019-08-21 23:32:47 +00001146 CHART_VERSION="--version $CHART_VERSION"
1147 else
1148 CHART_VERSION=
1149 fi
1150
David Bainbridge99ac7a22019-08-31 02:26:43 +00001151 local CHART_ARGS=
1152 if [ -r "${INAME}-values.yaml" ]; then
1153 CHART_ARGS="-f ${INAME}-values.yaml"
1154 fi
1155
David Bainbridged18f4942020-04-14 16:46:13 -07001156 local WAIT_START CMD
1157 WAIT_START="$(date +%s)"
1158 COUNT="$((300 / 15))"
1159 bspin "$INDENT" "$MESSAGE"
1160 if [ "$HELM_USE_UPGRADE" == "yes" ]; then
David Bainbridge7f8bf992020-04-08 21:53:22 -07001161 _HELM_COMMAND="upgrade --install"
1162 _HELM_ARGS="$INAME"
1163 else
1164 _HELM_COMMAND="install"
1165 _HELM_ARGS="--name $INAME"
1166 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001167
1168 VALUES_FILE="$(mktemp)"
1169 if [ "$FILTER" == "-" ]; then
1170 cp "$NAME-values.yaml" "$VALUES_FILE"
David Bainbridgea965ca22020-06-09 17:45:04 -07001171 elif [ "${FILTER:0:1}" == "+" ]; then
1172 cp "$NAME-values.yaml" "$VALUES_FILE"
1173 yq r - "${FILTER:1}" <"$NAME-values.yaml" >>"$VALUES_FILE"
David Bainbridge33e56c72020-06-11 11:39:56 -07001174 cat "$VALUES_FILE" >>"$LOG"
David Bainbridgec7220622020-05-28 12:31:47 -07001175 else
David Bainbridge43f2df52020-06-02 15:30:54 -07001176 yq r - "$FILTER" <"$NAME-values.yaml" >"$VALUES_FILE"
David Bainbridgec7220622020-05-28 12:31:47 -07001177 fi
1178 if [ "$WITH_PPROF" == "yes" ]; then
1179 PPROF_ARG="--set profiler.enabled=true"
1180 fi
1181 CMD=("helm $_HELM_COMMAND -f $VALUES_FILE $CHART_ARGS $PPROF_ARG $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")
David Bainbridged18f4942020-04-14 16:46:13 -07001182 (set -x; ${CMD[*]} >>"$LOG" 2>&1) >>"$LOG" 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001183 SUCCESS=$?
David Bainbridged18f4942020-04-14 16:46:13 -07001184 while [ "$SUCCESS" -ne 0 ]; do
1185 NOW="$(date +%s)"
1186 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -07001187 espin "$THEX"
David Bainbridgec7220622020-05-28 12:31:47 -07001188 rm -f "$VALUES_FILE"
David Bainbridge52e6e9d2020-03-23 13:48:27 -07001189 doTimeout "waiting for helm install $CHART"
1190 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001191 sspin "$INDENT"
1192 COUNT="$((COUNT - 1))"
1193 if [ "$COUNT" -eq 0 ]; then
1194 if [ "$HELM_USE_UPGRADE" == "no" ]; then
1195 (set -x; helm delete --purge "$INAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
David Bainbridge7f8bf992020-04-08 21:53:22 -07001196 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001197 (set -x; ${CMD[*]} >>"$LOG" 2>&1) >>"$LOG" 2>&1
Andy Baviere22ff252019-12-19 11:40:31 -07001198 SUCCESS=$?
David Bainbridged18f4942020-04-14 16:46:13 -07001199 COUNT="$((300 / 15))"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001200 fi
1201 sleep .15
1202 done
David Bainbridgec7220622020-05-28 12:31:47 -07001203 rm -f "$VALUES_FILE"
David Bainbridged18f4942020-04-14 16:46:13 -07001204 espin "$INDENT" "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001205}
1206
David Bainbridged18f4942020-04-14 16:46:13 -07001207echo "INSTALL TYPE: $TYPE" >> "$LOG"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001208
1209bspin "Verify GOPATH"
David Bainbridged18f4942020-04-14 16:46:13 -07001210GOPATH="$(pwd)"; export GOPATH
1211mkdir -p "$GOPATH/bin"
1212espin "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001213
David Bainbridged18f4942020-04-14 16:46:13 -07001214STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001215if [ "$INSTALL_KUBECTL" == "no" ]; then
1216 bspin "Skip kubectl install"
1217 espin $NO_ENTRY
Test Userc13bdc92019-07-03 20:57:49 +00001218else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001219 bspin "Verify kubectl $HELM"
David Bainbridged18f4942020-04-14 16:46:13 -07001220 if [ -x "$GOPATH/bin/kubectl" ]; then
1221 espin "$VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001222 else
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001223 ERR_OUT="$(mktemp)"
David Bainbridged18f4942020-04-14 16:46:13 -07001224 espin "$NOT_VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001225 bspin - "Download and install Kubernetes/kubectl $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001226 (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
1227 RESULT=$?
1228 if [ "$RESULT" -ne 0 ]; then
1229 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001230 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download kubectl: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001231 cat "$ERR_OUT" >> "$LOG"
Zack Williamsded60cb2020-04-13 10:02:20 -07001232 rm -rf "$ERR_OUT" "$GOPATH/bin/kubectl"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001233 exit 1
1234 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001235 (set -x; chmod 755 "$GOPATH/bin/kubectl" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1236 espin - "$VERIFIED"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001237 rm -rf "$ERR_OUT"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001238 fi
Test Userc13bdc92019-07-03 20:57:49 +00001239fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001240if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001241 NOW="$(date +%s)"
1242 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001243fi
Test Userc13bdc92019-07-03 20:57:49 +00001244
David Bainbridged18f4942020-04-14 16:46:13 -07001245STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001246if [ "$DEPLOY_K8S" == "no" ]; then
1247 bspin "Skip Kubernetes/Kind Deployment"
1248 espin $NO_ENTRY
1249else
Test Userba1e7e72019-07-10 22:27:54 +00001250 bspin "Verify Kubernetes/Kind $HELM"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001251 IS_INSTALLED=0
1252 OP_TYPE="install"
David Bainbridged18f4942020-04-14 16:46:13 -07001253 if [ -x "$GOPATH/bin/kind" ]; then
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001254 OP_TYPE="upgrade"
David Bainbridged18f4942020-04-14 16:46:13 -07001255 if [ "$("$GOPATH/bin/kind" --version | grep -c "$KIND_VERSION")" -eq 1 ]; then
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001256 IS_INSTALLED=1
David Bainbridged18f4942020-04-14 16:46:13 -07001257 espin "$VERIFIED"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001258 fi
1259 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001260 if [ "$IS_INSTALLED" -eq 0 ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001261 ERR_OUT="$(mktemp)"
David Bainbridged18f4942020-04-14 16:46:13 -07001262 espin "$NOT_VERIFIED"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001263 bspin - "Download and $OP_TYPE Kubernetes/kind $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001264 (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
1265 RESULT=$?
1266 if [ $RESULT -ne 0 ]; then
1267 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001268 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download kind: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001269 cat "$ERR_OUT" >> "$LOG"
Zack Williamsded60cb2020-04-13 10:02:20 -07001270 rm -rf "$ERR_OUT" "$GOPATH/bin/kind"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001271 exit 1
1272 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001273 (set -x; chmod 755 "$GOPATH/bin/kind" >>"$LOG" 2>&1) >>"$LOG" 2>&1
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001274 rm -rf "$ERR_OUT"
David Bainbridged18f4942020-04-14 16:46:13 -07001275 espin - "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001276 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001277fi
1278
David Bainbridgee87067b2019-08-12 22:00:12 +00001279if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001280 NOW="$(date +%s)"
1281 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001282fi
1283
David Bainbridged18f4942020-04-14 16:46:13 -07001284STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001285if [ "$INSTALL_HELM" == "no" ]; then
1286 bspin "Skip Helm Install"
1287 espin $NO_ENTRY
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001288else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001289 bspin "Verify Helm $HELM"
David Bainbridgea34993d2020-04-01 09:15:42 -07001290 HELM_UPGRADE=0
1291 HELM_UPGRADE_DESC="install"
David Bainbridged18f4942020-04-14 16:46:13 -07001292 if [ -x "$GOPATH/bin/helm" ]; then
1293 HAVE_VER="$("$GOPATH/bin/helm" version -c --template '{{.Client.SemVer}}')"
1294 HELM_UP_DOWN="$(echo -e "$HAVE_VER\n$HELM_VERSION" | sort -V | head -1)"
1295 if [ "$HAVE_VER" != "$HELM_VERSION" ]; then
1296 if [ "$HELM_UP_DOWN" == "$HELM_VERSION" ]; then
David Bainbridgea34993d2020-04-01 09:15:42 -07001297 HELM_UPGRADE_DESC="downgrade"
1298 else
1299 HELM_UPGRADE_DESC="upgrade"
1300 fi
1301 HELM_UPGRADE=1
1302 else
David Bainbridged18f4942020-04-14 16:46:13 -07001303 espin "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001304 fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001305 else
David Bainbridgea34993d2020-04-01 09:15:42 -07001306 HELM_UPGRADE=1
1307 fi
1308
David Bainbridged18f4942020-04-14 16:46:13 -07001309 if [ "$HELM_UPGRADE" -ne 0 ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001310 ERR_OUT="$(mktemp)"
1311 INSTALL_HELM_BIN=$(mktemp)
David Bainbridged18f4942020-04-14 16:46:13 -07001312 espin "$NOT_VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001313 bspin - "Download and $HELM_UPGRADE_DESC Helm $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001314 (set -x; curl -o "$INSTALL_HELM_BIN" --fail -sSL https://git.io/get_helm.sh >>"$LOG" 2>"$ERR_OUT") >>"$LOG" 2>&1
1315 RESULT=$?
1316 if [ $RESULT -ne 0 ]; then
1317 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001318 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download helm installer: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001319 cat "$ERR_OUT" >> "$LOG"
1320 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT" "$GOPATH/bin/helm" "$GOPATH/bin/tiller"
1321 exit 1
1322 fi
1323 rm -rf "$ERR_OUT"
1324 chmod +x "$INSTALL_HELM_BIN"
1325 (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
1326 RESULT=$?
1327 if [ $RESULT -ne 0 ]; then
1328 espin - "$THEX"
1329 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to install helm, see install log for details${NORMAL}"
1330 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT" "$GOPATH/bin/helm" "$GOPATH/bin/tiller"
1331 exit 1
1332 fi
1333 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT"
David Bainbridged18f4942020-04-14 16:46:13 -07001334 espin - "$VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001335 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001336fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001337if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001338 NOW="$(date +%s)"
1339 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001340fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001341
David Bainbridged18f4942020-04-14 16:46:13 -07001342STIME="$(date +%s)"
Test Userb5712372019-07-03 21:52:17 +00001343bspin "Verify voltctl $HIGH_VOLTAGE"
David Bainbridged2811972019-12-14 01:14:09 +00001344VOK=0
1345VMESSAGE="install"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001346ERR_OUT=$(mktemp)
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001347export VC_VERSION="$VOLTCTL_VERSION"
1348if [ "$VC_VERSION" == "latest" ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001349 set -o pipefail # TODO: would be nice to run all in pipefail mode
1350 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')"
1351 RESULT=$?
1352 set +o pipefail
1353 if [ "$RESULT" -ne 0 ]; then
1354 espin - "$THEX"
1355 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to determine released version of voltctl: $(cat "$ERR_OUT")${NORMAL}"
1356 rm -rf "$ERR_OUT" "$GOPATH/bin/voltctl"
1357 exit 1
1358 fi
1359 export VC_VERSION
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001360fi
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001361
David Bainbridged18f4942020-04-14 16:46:13 -07001362if [ -x "$GOPATH/bin/voltctl" ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001363 VHAVE="$("$GOPATH/bin/voltctl" version --clientonly -o json 2>/dev/null | jq -r .version)"
David Bainbridged18f4942020-04-14 16:46:13 -07001364 RESULT=$?
1365 if [ $RESULT -eq 0 ] && [ "$VHAVE" == "$VC_VERSION" ]; then
David Bainbridged2811972019-12-14 01:14:09 +00001366 VOK=1
David Bainbridged18f4942020-04-14 16:46:13 -07001367 espin "$VERIFIED"
David Bainbridge1ba64f12019-12-18 00:40:13 +00001368 else
David Bainbridged18f4942020-04-14 16:46:13 -07001369 VCHECK="$(echo -e "$VHAVE\n$VC_VERSION" | sort -V | head -1)"
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001370 if [ "$VCHECK" == "$VHAVE" ]; then
1371 VMESSAGE="upgrade"
1372 else
1373 VMESSAGE="downgrade"
1374 fi
David Bainbridged2811972019-12-14 01:14:09 +00001375 fi
1376fi
1377
David Bainbridged18f4942020-04-14 16:46:13 -07001378if [ "$VOK" -eq 0 ]; then
1379 espin "$NOT_VERIFIED"
David Bainbridged2811972019-12-14 01:14:09 +00001380 bspin - "Download and $VMESSAGE voltctl $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001381 (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
1382 RESULT=$?
1383 if [ $RESULT -ne 0 ]; then
1384 espin - "$THEX"
1385 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download voltctl (version $VC_VERSION): $(cat "$ERR_OUT")${NORMAL}"
1386 rm -rf "$ERR_OUT" "$GOPATH/bin/voltctl"
1387 exit 1
1388 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001389 (set -x; chmod 755 "$GOPATH/bin/voltctl" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1390 espin - "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001391fi
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001392rm -rf "$ERR_OUT"
David Bainbridgee87067b2019-08-12 22:00:12 +00001393if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001394 NOW="$(date +%s)"
1395 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001396fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001397
1398bspin "Verify command PATH"
Test Userba1e7e72019-07-10 22:27:54 +00001399export PATH=$GOPATH/bin:$PATH
David Bainbridged18f4942020-04-14 16:46:13 -07001400espin "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001401
David Bainbridged18f4942020-04-14 16:46:13 -07001402STIME="$(date +%s)"
Test Userba1e7e72019-07-10 22:27:54 +00001403if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001404 HAVE="$(kind get clusters | grep -c "voltha-$NAME")"
Test Userba1e7e72019-07-10 22:27:54 +00001405 bspin "Verify Kubernetes/Kind Cluster"
1406 sspin
David Bainbridged18f4942020-04-14 16:46:13 -07001407 if [ "$HAVE" -eq 0 ]; then
1408 espin "$NOT_VERIFIED"
David Bainbridge491b1bd2019-07-11 17:53:11 +00001409 bspin - "Verify cluster configuration"
David Bainbridged18f4942020-04-14 16:46:13 -07001410 if [ ! -r "./$NAME-cluster.cfg" ]; then
1411 espin - "$NOT_VERIFIED"
David K. Bainbridge43422402020-03-06 07:41:22 -08001412 bspin - "Download cluster configuration: $TYPE-cluster.cfg to $NAME-cluster.cfg $DOWNLOAD"
David Bainbridged18f4942020-04-14 16:46:13 -07001413 ERR_OUT="$(mktemp)"
serkant.uluderya4d315132020-04-15 16:25:54 -07001414 if ! (set -x; curl --fail -o "./$NAME-cluster.cfg" -sSL "https://raw.githubusercontent.com/opencord/kind-voltha/$VK_RELEASE/$TYPE-cluster.cfg" >>"$LOG" 2>>"$ERR_OUT") >>"$LOG" 2>&1; then
David Bainbridged18f4942020-04-14 16:46:13 -07001415 espin - "$THEX"
1416 echo -e "${RED}${BOLD}${ERROR}ERROR: $NAME-cluster.cfg${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1417 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
1418 rm -rf "$ERR_OUT" "./$NAME-cluster.cfg"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001419 exit 1
1420 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001421 rm -rf "$ERR_OUT"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001422 else
David Bainbridged18f4942020-04-14 16:46:13 -07001423 espin - "$VERIFIED"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001424 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001425 kind create cluster --name "voltha-$NAME" --config "$NAME-cluster.cfg"
David Bainbridge491b1bd2019-07-11 17:53:11 +00001426 else
David Bainbridged18f4942020-04-14 16:46:13 -07001427 espin "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001428 fi
1429
David Bainbridge1d2c5842020-06-03 15:29:07 -07001430 export KUBECONFIG="./kube-config-$NAME"
1431 kind get kubeconfig --name="voltha-$NAME" >"$KUBECONFIG"
1432 # For backward compatibility also copy to old location
David Bainbridgedee3f022020-06-05 07:45:13 -07001433 mkdir -p "$HOME/.kube"
David Bainbridge7b3c1632020-06-05 10:04:14 -07001434 cp "$KUBECONFIG" "$HOME/.kube/kind-config-voltha-$NAME"
David Bainbridge1d2c5842020-06-03 15:29:07 -07001435
Test Userba1e7e72019-07-10 22:27:54 +00001436 P="coredns-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001437 etcd-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +00001438 kindnet-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001439 kube-apiserver-voltha-$NAME-control-plane \
1440 kube-controller-manager-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +00001441 kube-proxy-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001442 kube-scheduler-voltha-$NAME-control-plane"
Test Userba1e7e72019-07-10 22:27:54 +00001443
David Bainbridged18f4942020-04-14 16:46:13 -07001444 EXPECT="$(test "$TYPE" == "minimal" && echo "12" || echo "14")"
1445 wait_for_pods - "kube-system" "$EXPECT" "includes" "Waiting for system PODs to start" "$NO_LABEL" "$P"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001446fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001447if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001448 NOW="$(date +%s)"
1449 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001450fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001451
David Bainbridgee4d11ca2020-05-08 10:21:10 -07001452if [ "$SCHEDULE_ON_CONTROL_NODES" == "yes" ]; then
1453 bspin "Untaint control nodes to allow scheduling $LOCK"
1454 for MNODE in $(kubectl get node --selector='node-role.kubernetes.io/master' -o json | jq -r '.items[].metadata.name'); do
1455 (set -x; kubectl taint node "$MNODE" node-role.kubernetes.io/master:NoSchedule- >>"$LOG" 2>&1) >>"$LOG" 2>&1
1456 sspin
1457 done
1458 espin "$VERIFIED"
1459fi
1460
David Bainbridged18f4942020-04-14 16:46:13 -07001461STIME="$(date +%s)"
1462COUNT="$(count_pods "kube-system" ":Running:" "$NO_LABEL" "tiller-deploy-.*")"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001463bspin "Verify Helm"
David Bainbridged18f4942020-04-14 16:46:13 -07001464if [ "$COUNT" -ne 1 ]; then
1465 espin "$NOT_VERIFIED"
Test Userb5712372019-07-03 21:52:17 +00001466 echo -e "Configuring Helm $GEAR"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001467 if [ "$INSTALL_HELM" == "no" ]; then
1468 bspin - "Skip Helm/Tiller Initialization"
1469 espin - $NO_ENTRY
1470 else
1471 bspin - "Initialize Helm"
David Bainbridged18f4942020-04-14 16:46:13 -07001472 (set -x; helm init --upgrade >>"$LOG" 2>&1) >>"$LOG" 2>&1
1473 espin - "$VERIFIED"
1474 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 -07001475 fi
Test Userb5712372019-07-03 21:52:17 +00001476 bspin - "Add Google Incubator repository to Helm"
David Bainbridged18f4942020-04-14 16:46:13 -07001477 (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>"$LOG" 2>&1) >>"$LOG" 2>&1
1478 espin - "$VERIFIED"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001479
Test Userba1e7e72019-07-10 22:27:54 +00001480 # HACK (sort-of) - the config for tiller is about to be patched, which will
1481 # cause the tiller pod to be recreated. This can sometimes cause a timing
1482 # issue with the "wait_for_pods" call on tiller as it may incorrectly
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001483 # identify the running/ready tiller pod that is soon to be terminated as
Test Userba1e7e72019-07-10 22:27:54 +00001484 # what it is waiting for. To avoid this issue we do a clean scale down and
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001485 # scale up of the pod so the script controlls when it should be expecting
Test Userba1e7e72019-07-10 22:27:54 +00001486 # things
David Bainbridged18f4942020-04-14 16:46:13 -07001487 (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 -07001488
Test Userb5712372019-07-03 21:52:17 +00001489 bspin - "Add Google Stable repository to Helm"
David Bainbridged18f4942020-04-14 16:46:13 -07001490 (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>"$LOG" 2>&1) >>"$LOG" 2>&1
1491 espin - "$VERIFIED"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001492 bspin - "Add ONF VOLTHA repository to Helm"
David Bainbridged18f4942020-04-14 16:46:13 -07001493 (set -x; helm repo add onf https://charts.opencord.org >>"$LOG" 2>&1) >>"$LOG" 2>&1
1494 espin - "$VERIFIED"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001495 bspin - "Add ONF ONOS repository to Helm"
1496 (set -x; helm repo add onos https://charts.onosproject.org >>"$LOG" 2>&1) >>"$LOG" 2>&1
1497 espin - "$VERIFIED"
1498 bspin - "Add ONF Atomix repository to Helm"
1499 (set -x; helm repo add atomix https://charts.atomix.io >>"$LOG" 2>&1) >>"$LOG" 2>&1
1500 espin - "$VERIFIED"
David Bainbridge309099c2020-05-05 08:47:29 -07001501 bspin - "Add Custom BBSIM SADIS Server repository to Helm"
1502 (set -x; helm repo add bbsim-sadis https://ciena.github.io/bbsim-sadis-server/charts >>"$LOG" 2>&1) >>"$LOG" 2>&1
1503 espin - "$VERIFIED"
Test Userb5712372019-07-03 21:52:17 +00001504 bspin - "Update Helm repository cache"
David Bainbridged18f4942020-04-14 16:46:13 -07001505 (set -x; helm repo update >>"$LOG" 2>&1) >>"$LOG" 2>&1
1506 espin - "$VERIFIED"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001507
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001508 # Create and k8s service account so that Helm can create pods
Test Userb5712372019-07-03 21:52:17 +00001509 bspin - "Create Tiller ServiceAccount"
David Bainbridged18f4942020-04-14 16:46:13 -07001510 (set -x; kubectl create serviceaccount --namespace kube-system tiller >>"$LOG" 2>&1) >>"$LOG" 2>&1
1511 espin - "$VERIFIED"
Test Userb5712372019-07-03 21:52:17 +00001512 bspin - "Create Tiller ClusterRoleBinding"
David Bainbridged18f4942020-04-14 16:46:13 -07001513 (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>"$LOG" 2>&1) >>"$LOG" 2>&1
1514 espin - "$VERIFIED"
Test Userb5712372019-07-03 21:52:17 +00001515 bspin - "Update Tiller Manifest"
David Bainbridged18f4942020-04-14 16:46:13 -07001516 (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 +00001517
1518 # HACK (sort-of) - part to, spin it back up
David Bainbridged18f4942020-04-14 16:46:13 -07001519 (set -x; kubectl -n kube-system scale deploy tiller-deploy --replicas=1 >>"$LOG" 2>&1) >>"$LOG" 2>&1
1520 espin - "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001521else
David Bainbridged18f4942020-04-14 16:46:13 -07001522 if [ "$(helm version -s --template '{{.Server.SemVer}}')" != "$HELM_VERSION" ]; then
1523 espin "$NOT_VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001524 bspin - "Sync Tiller server version with helm client"
David Bainbridged18f4942020-04-14 16:46:13 -07001525 (set -x; helm init --upgrade --force-upgrade --wait >>"$LOG" 2>&1) >>"$LOG" 2>&1
1526 espin - "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001527 else
David Bainbridged18f4942020-04-14 16:46:13 -07001528 espin "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001529 fi
1530
David Bainbridge46505fb2019-10-01 21:13:20 +00001531 if [ "$UPDATE_HELM_REPOS" == "yes" ]; then
1532 bspin - "Update Helm repository cache"
David Bainbridged18f4942020-04-14 16:46:13 -07001533 (set -x; helm repo update >>"$LOG" 2>&1) >>"$LOG" 2>&1
1534 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00001535 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001536fi
David Bainbridged18f4942020-04-14 16:46:13 -07001537wait_for_pods - "kube-system" 1 "includes" "Waiting for Tiller POD to start" "$NO_LABEL" "tiller-deploy-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001538if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001539 NOW="$(date +%s)"
1540 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001541fi
David Bainbridgecf546362020-04-21 23:18:50 -07001542# Resolve chart versions and log them for debug/support
1543RESOLVED_VOLTHA_CHART_VERSION=$(resolve_chart_version "$VOLTHA_CHART" "$VOLTHA_CHART_VERSION")
1544RESOLVED_VOLTHA_BBSIM_CHART_VERSION=$(resolve_chart_version "$VOLTHA_BBSIM_CHART" "$VOLTHA_BBSIM_CHART_VERSION")
1545RESOLVED_VOLTHA_ADAPTER_SIM_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_SIM_CHART" "$VOLTHA_ADAPTER_SIM_CHART_VERSION")
1546RESOLVED_VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_OPEN_OLT_CHART" "$VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION")
1547RESOLVED_VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_OPEN_ONU_CHART" "$VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION")
1548RESOLVED_ONOS_CHART_VERSION=$(resolve_chart_version "$ONOS_CHART" "$ONOS_CHART_VERSION")
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001549RESOLVED_ONOS_CLASSIC_CHART_VERSION=$(resolve_chart_version "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION")
David Bainbridgecf546362020-04-21 23:18:50 -07001550RESOLVED_KAFKA_CHART_VERSION=$(resolve_chart_version "$KAFKA_CHART" "$KAFKA_CHART_VERSION")
1551cat <<EOV >>"$LOG"
1552Resolved helm charts and versions:
1553 $VOLTHA_CHART:$RESOLVED_VOLTHA_CHART_VERSION
1554 $VOLTHA_BBSIM_CHART:$RESOLVED_VOLTHA_BBSIM_CHART_VERSION
1555 $VOLTHA_ADAPTER_SIM_CHART:$RESOLVED_VOLTHA_ADAPTER_SIM_CHART_VERSION
1556 $VOLTHA_ADAPTER_OPEN_OLT_CHART:$RESOLVED_VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION
1557 $VOLTHA_ADAPTER_OPEN_ONU_CHART:$RESOLVED_VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION
1558 $ONOS_CHART:$RESOLVED_ONOS_CHART_VERSION
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001559 $ONOS_CLASSIC_CHART:$RESOLVED_ONOS_CLASSIC_CHART_VERSION
David Bainbridgecf546362020-04-21 23:18:50 -07001560 $KAFKA_CHART:$RESOLVED_KAFKA_CHART_VERSION
1561EOV
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001562
David Bainbridged18f4942020-04-14 16:46:13 -07001563STIME="$(date +%s)"
David Bainbridge0774b232019-08-02 06:37:19 +00001564bspin "Verify Helm values file: $NAME-values.yaml"
1565if [ ! -r "./$NAME-values.yaml" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001566 espin "$NOT_VERIFIED"
David Bainbridge0774b232019-08-02 06:37:19 +00001567 bspin - "Download Helm values file: $TYPE-values.yaml to $NAME-values.yaml $DOWNLOAD"
David Bainbridged18f4942020-04-14 16:46:13 -07001568 ERR_OUT="$(mktemp)"
serkant.uluderya4d315132020-04-15 16:25:54 -07001569 if ! (set -x; curl --fail -o "./$NAME-values.yaml" -sSL "https://raw.githubusercontent.com/opencord/kind-voltha/$VK_RELEASE/$TYPE-values.yaml" >>"$LOG" 2>"$ERR_OUT") >>"$LOG" 2>&1; then
David Bainbridged18f4942020-04-14 16:46:13 -07001570 espin - "$THEX"
1571 echo -e "${RED}${BOLD}${ERROR}ERROR: $NAME-values.yaml${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1572 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
1573 rm -rf "$ERR_OUT" "./$NAME-values.yaml"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001574 exit 1
1575 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001576 rm -rf "$ERR_OUT"
1577 espin - "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001578else
David Bainbridged18f4942020-04-14 16:46:13 -07001579 espin "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001580fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001581if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001582 NOW="$(date +%s)"
1583 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001584fi
Test Userba1e7e72019-07-10 22:27:54 +00001585
David Bainbridged18f4942020-04-14 16:46:13 -07001586STIME="$(date +%s)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001587bspin "Verify or download chart specific values files $DOWNLOAD"
1588VALUES_FILES="monkey-values.yaml"
David Bainbridged18f4942020-04-14 16:46:13 -07001589ERR_OUT="$(mktemp)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001590for i in $VALUES_FILES; do
1591 if [ ! -r ./$i ]; then
serkant.uluderya4d315132020-04-15 16:25:54 -07001592 if ! (set -x; curl --fail -o "./$i" -sSL "https://raw.githubusercontent.com/opencord/kind-voltha/$VK_RELEASE/$i" >>"$LOG" 2>"$ERR_OUT") >>"$LOG" 2>&1; then
David Bainbridged18f4942020-04-14 16:46:13 -07001593 espin "$THEX"
1594 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1595 echo "ERROR: $i - $(cat "$ERR_OUT")" >>"$LOG"
1596 rm -rf "$ERR_OUT" "./$i"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001597 exit 1
1598 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001599 rm -rf "$ERR_OUT"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001600 fi
1601done
David Bainbridged18f4942020-04-14 16:46:13 -07001602rm -rf "$ERR_OUT"
1603espin "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001604if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001605 NOW="$(date +%s)"
1606 printtime $((NOW - STIME))
David Bainbridge99ac7a22019-08-31 02:26:43 +00001607fi
1608
1609if [ "$WITH_CHAOS" == "yes" ]; then
1610 bspin "Verify or clone kube-monkey helm chart $DOWNLOAD"
1611 if [ -r ./kube-monkey ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001612 espin "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001613 else
David Bainbridged18f4942020-04-14 16:46:13 -07001614 espin "$NOT_VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001615 bspin - "GIT clone kube-monkey"
David Bainbridged18f4942020-04-14 16:46:13 -07001616 (set -x; git clone https://github.com/asobti/kube-monkey kube-monkey >>"$LOG" 2>&1) >>"$LOG" 2>&1
1617 espin - "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001618 fi
1619fi
1620
Test Userba1e7e72019-07-10 22:27:54 +00001621if [ "$JUST_K8S" == "yes" ]; then
1622 echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye."
1623 echo ""
David Bainbridged18f4942020-04-14 16:46:13 -07001624 echo "Please issue the following commands in your terminal to ensure that you" | tee -a "$LOG"
1625 echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a "$LOG"
1626 echo "tools required by VOLTHA in your command path. " | tee -a "$LOG"
1627 echo "" | tee -a "$LOG"
1628 echo -en "$BOLD"
1629 if [ "$DEPLOY_K8S" == "yes" ]; then
1630 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00001631 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001632 echo "export PATH=$GOPATH/bin:\$PATH" | tee -a "$LOG"
1633 echo -en "$NORMAL"
1634 echo "" | tee -a "$LOG"
1635 echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00001636 exit 0
1637fi
1638
David Bainbridged18f4942020-04-14 16:46:13 -07001639STIME="$(date +%s)"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001640if is_in "$WITH_ONOS" "yes,legacy,classic"; then
1641 if is_in "$WITH_ONOS" "legacy"; then
1642 bspin "Verify ONOS LEGACY installed $BIRD"
1643 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^onos\$" | wc -l)" -ne 1 ]; then
1644 espin "$NOT_VERIFIED"
David Bainbridge33e56c72020-06-11 11:39:56 -07001645 INTERNAL_EXTRA_HELM_INSTALL_ARGS="$SET_TAG $EXTRA_HELM_FLAGS" helm_install - "$INFRA_NS" onos "$ONOS_CHART" "$ONOS_CHART_VERSION" "+onos" "$_HELM_DESC ONOS LEGACY"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001646 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
1647 else
1648 espin "$VERIFIED"
1649 fi
1650 wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for ONOS to start" "$NO_LABEL" "onos-.*"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001651
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001652 if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
1653 bspin - "Forward ONOS API port $FORWARD"
1654 kill_port_forward onos-ui
1655 port_forward "$INFRA_NS" onos-ui "$ONOS_API_PORT:8181"
1656 espin - "$VERIFIED"
1657 bspin - "Forward ONOS SSH port $FORWARD"
1658 kill_port_forward onos-ssh
1659 port_forward "$INFRA_NS" onos-ssh "$ONOS_SSH_PORT:8101"
1660 espin - "$VERIFIED"
1661 _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT"
1662 else
1663 _ONOS_API_EP="$(get_service_ep "$INFRA_NS" onos-ui)"
1664 fi
1665 elif is_in "$WITH_ONOS" "yes,classic"; then
1666 bspin "Verify ONOS CLASSIC installed $BIRD"
1667 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^onos\$" | wc -l)" -ne 1 ]; then
1668 espin "$NOT_VERIFIED"
Matteo Scandoloe0829b52020-05-08 14:23:56 -07001669 # ONOS CLASSIC identifies its image repo/tag/pullPolicy differently, so yq is used to grab the values from the
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001670 # values value
David Bainbridgefad50732020-05-01 17:00:12 -07001671 YAML_VALUES=$(INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set replicas=$NUM_OF_ONOS --set atomix.replicas=$NUM_OF_ATOMIX" \
1672 helm_values "$INFRA_NS" onos "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION")
1673 _ONOS_REPO="$(echo "$YAML_VALUES" | yq read - images.onos.repository)"
David Bainbridgedee3f022020-06-05 07:45:13 -07001674 if [ -z "$_ONOS_REPO" ]; then
1675 _ONOS_REPO="voltha/voltha-onos"
1676 fi
David Bainbridgefad50732020-05-01 17:00:12 -07001677 _ONOS_TAG="$(echo "$YAML_VALUES" | yq read - images.onos.tag)"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001678 if [ -z "$_ONOS_TAG" ]; then
David Bainbridgedee3f022020-06-05 07:45:13 -07001679 _ONOS_TAG="$(echo "$YAML_VALUES" | yq read - defaults.image_tag)"
1680 fi
1681 if [ -z "$_ONOS_TAG" ]; then
1682 _ONOS_TAG="master"
1683 fi
1684 _ONOS_PULL_POLICY="$(echo "$YAML_VALUES" | yq read - images.onos.pullPolicy)"
1685 if [ -z "$_ONOS_PULL_POLICY" ]; then
1686 _ONOS_PULL_POLICY="$(echo "$YAML_VALUES" | yq read - defaults.image_pullPolicy)"
1687 fi
1688 if [ -z "$_ONOS_PULL_POLICY" ]; then
1689 _ONOS_PULL_POLICY="Always"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001690 fi
David Bainbridgefad50732020-05-01 17:00:12 -07001691
Matteo Scandoloe0829b52020-05-08 14:23:56 -07001692 INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set image.pullPolicy=$_ONOS_PULL_POLICY,image.repository=$_ONOS_REPO,image.tag=$_ONOS_TAG,replicas=$NUM_OF_ONOS,atomix.replicas=$NUM_OF_ATOMIX" \
David Bainbridge33e56c72020-06-11 11:39:56 -07001693 helm_install - "$INFRA_NS" onos "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION" "+onos" "$_HELM_DESC ONOS CLASSIC"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001694 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
1695 else
1696 espin "$VERIFIED"
1697 fi
1698 wait_for_pods - "$INFRA_NS" $((NUM_OF_ONOS + NUM_OF_ATOMIX)) "includes" "Waiting for ONOS CLASSIC to start" "$NO_LABEL" "onos-.*"
1699 if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
1700 bspin - "Forward ONOS API port $FORWARD"
1701 kill_port_forward onos-onos-classic-hs
1702 port_forward "$INFRA_NS" onos-onos-classic-hs "$ONOS_API_PORT:8181" "$ONOS_SSH_PORT:8101"
1703 espin - "$VERIFIED"
1704 _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT"
1705 else
1706 _ONOS_API_EP="$(get_service_ep "$INFRA_NS" onos-onos-classic-hs)"
1707 fi
1708 elif [ "$WITH_ONOS" == "micro" ]; then
1709 bspin "Verify micro-ONOS installed $BIRD"
1710 # We should never get here
1711 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Micro ONOS not currently supported${NORMAL}"
1712 exit 1
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001713 fi
David Bainbridged31d6122019-08-13 19:37:59 +00001714 bspin - "Verify or download ONOS configuration support files $DOWNLOAD"
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001715 ONOS_FILES="olt-onos-enableExtraneousRules.json onos-aaa.json \
David Bainbridge696bc632020-04-05 21:49:37 -07001716 onos-dhcpl2relay.json onos-sadis-sample.json"
David Bainbridged18f4942020-04-14 16:46:13 -07001717 (set -x; mkdir -p ./onos-files >>"$LOG" 2>&1) >>"$LOG" 2>&1
1718 ERR_OUT="$(mktemp)"
David Bainbridge2b19e832019-08-16 02:40:53 +00001719 for i in $ONOS_FILES; do
David Bainbridged18f4942020-04-14 16:46:13 -07001720 if [ ! -r "./onos-files/$i" ]; then
serkant.uluderya4d315132020-04-15 16:25:54 -07001721 if ! (set -x; curl --fail -o "./onos-files/$i" -sSL "https://raw.githubusercontent.com/opencord/kind-voltha/$VK_RELEASE/onos-files/$i" >>"$LOG" 2>"$ERR_OUT") >>"$LOG" 2>&1; then
David Bainbridged18f4942020-04-14 16:46:13 -07001722 espin - "$THEX"
1723 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1724 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
1725 rm -rf "$ERR_OUT" "./onos-files/$i"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001726 exit 1
1727 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001728 rm -rf "$ERR_OUT"
David Bainbridged31d6122019-08-13 19:37:59 +00001729 fi
1730 done
David Bainbridged18f4942020-04-14 16:46:13 -07001731 rm -rf "$ERR_OUT"
1732 espin - "$VERIFIED"
David Bainbridge27790d62019-08-13 22:43:19 +00001733
David Bainbridged18f4942020-04-14 16:46:13 -07001734 if [ "$INSTALL_ONOS_APPS" == "yes" ]; then
David Bainbridge27790d62019-08-13 22:43:19 +00001735 bspin - "Installing custom ONOS applications"
David Bainbridged18f4942020-04-14 16:46:13 -07001736 if [ -x onos-files/onos-apps ] && [ "$(find onos-files/onos-apps -name "*.oar" 2>/dev/null | wc -l)" -gt 0 ]; then
1737 for OAR in onos-files/onos-apps/*.oar; do
David Bainbridge27790d62019-08-13 22:43:19 +00001738 sspin - "Installing custom ONOS applications - $OAR$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -07001739 override_onos_app "$OAR"
David Bainbridge27790d62019-08-13 22:43:19 +00001740 done
1741 espin - "$VERIFIED Installing custom ONOS applications$CEOL"
1742 else
1743 espin - "$NOT_VERIFIED Installing custom ONOS applications - None Found"
1744 fi
1745 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001746
David Bainbridged18f4942020-04-14 16:46:13 -07001747 if [ "$WITH_KAFKA" != "no" ]; then
David Bainbridge837e8bd2020-04-06 13:17:14 -07001748 check_onos_app_active org.opencord.kafka
David Bainbridge879439b2020-06-12 15:59:35 -07001749 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridgec7220622020-05-28 12:31:47 -07001750 _HOST=kafka.$INFRA_NS.svc
David Bainbridge76afd812020-04-06 09:53:52 -07001751 _PORT=9092
David Bainbridge879439b2020-06-12 15:59:35 -07001752 elif [ "$WITH_KAFKA" != "no" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001753 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
1754 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge837e8bd2020-04-06 13:17:14 -07001755 _PORT=${_PORT:-9092}
1756 fi
1757 push_onos_config "json" "Push ONOS Kafka Configuration" "network/configuration/apps/org.opencord.kafka" \
David Bainbridged18f4942020-04-14 16:46:13 -07001758 "$(cat <<EOJ | tr -d '[:space:]'
David Bainbridge696bc632020-04-05 21:49:37 -07001759{
1760 "kafka": {
1761 "bootstrapServers": "$_HOST:$_PORT"
1762 }
1763}
1764EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07001765)"
David Bainbridge837e8bd2020-04-06 13:17:14 -07001766 fi
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001767 check_onos_app_active org.opencord.dhcpl2relay
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001768 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 -08001769 check_onos_app_active org.opencord.olt
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001770 # FIXME use WITH_DHCP and WITH_EAPOL flags to configre OLT App
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001771 # Default value for "enableEapol" is true in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07001772 if [ "$WITH_EAPOL" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001773 push_onos_config "json" "Enable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":true}'
David Bainbridged18f4942020-04-14 16:46:13 -07001774 elif [ "$WITH_EAPOL" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001775 push_onos_config "json" "Disable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001776 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001777 # Default value for "enableDhcpOnProvisioning" is false and for "enableDhcpV4" is true in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07001778 if [ "$WITH_DHCP" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001779 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 -07001780 elif [ "$WITH_DHCP" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001781 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 -08001782 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001783 # Default value for "enableIgmpOnProvisioning" is false in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07001784 if [ "$WITH_IGMP" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001785 push_onos_config "json" "Enable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":true}'
David Bainbridged18f4942020-04-14 16:46:13 -07001786 elif [ "$WITH_IGMP" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001787 push_onos_config "json" "Disable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001788 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001789 if [ "$ENABLE_ONOS_EXTRANEOUS_RULES" == "yes" ]; then
David K. Bainbridge484d80c2020-03-05 21:44:34 -08001790 push_onos_config "file" "Enabling extraneous rules for ONOS" "configuration/org.onosproject.net.flow.impl.FlowRuleManager" "onos-files/olt-onos-enableExtraneousRules.json"
1791 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001792 if is_in "$CONFIG_SADIS" "yes,file"; then
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001793 check_onos_app_active org.opencord.sadis
Hardik Windlassb3147602020-03-09 16:59:15 +05301794 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 -07001795 elif [ "$CONFIG_SADIS" == "bbsim" ]; then
1796 push_onos_config "json" \
1797 "[optional] Push ONOS configuration for BBSIM SADIS servers" \
1798 "network/configuration/apps/org.opencord.sadis" \
David Bainbridged18f4942020-04-14 16:46:13 -07001799 "$(cat <<EOJ | tr -d '[:space:]'
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001800{
1801 "sadis": {
1802 "integration": {
David Bainbridgec7220622020-05-28 12:31:47 -07001803 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:50074/v2/subscribers/%s",
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001804 "cache": {
1805 "enabled": true,
1806 "maxsize": 50,
1807 "ttl": "PT1m"
1808 }
1809 }
1810 },
1811 "bandwidthprofile": {
1812 "integration": {
David Bainbridgec7220622020-05-28 12:31:47 -07001813 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:50074/v2/bandwidthprofiles/%s",
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001814 "cache": {
1815 "enabled": true,
1816 "maxsize": 50,
1817 "ttl": "PT1m"
1818 }
1819 }
1820 }
1821}
1822EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07001823)"
David Bainbridge309099c2020-05-05 08:47:29 -07001824 elif [ "$CONFIG_SADIS" == "external" ]; then
David Bainbridge879439b2020-06-12 15:59:35 -07001825 if kubectl get -n "$BBSIM_NS" svc/bbsim-sadis-server-bbsim-sadis-server >/dev/null 2>&1; then
1826 BBSIM_SADIS_SVC="bbsim-sadis-server-bbsim-sadis-server"
1827 else
1828 BBSIM_SADIS_SVC="bbsim-sadis-server"
1829 fi
David Bainbridge309099c2020-05-05 08:47:29 -07001830 push_onos_config "json" \
1831 "[optional] Push ONOS configuration for custom SADIS and Bandwidth Profile servers" \
1832 "network/configuration/apps/org.opencord.sadis" \
1833 "$(cat <<EOJ | tr -d '[:space:]'
1834{
1835 "sadis": {
1836 "integration": {
David Bainbridge879439b2020-06-12 15:59:35 -07001837 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:58080/subscribers/%s",
David Bainbridge309099c2020-05-05 08:47:29 -07001838 "cache": {
1839 "enabled": true,
1840 "maxsize": 50,
1841 "ttl": "PT1m"
1842 }
1843 }
1844 },
1845 "bandwidthprofile": {
1846 "integration": {
David Bainbridge879439b2020-06-12 15:59:35 -07001847 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:58080/profiles/%s",
David Bainbridge309099c2020-05-05 08:47:29 -07001848 "cache": {
1849 "enabled": true,
1850 "maxsize": 50,
1851 "ttl": "PT1m"
1852 }
1853 }
1854 }
1855}
1856EOJ
1857)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001858 elif [ "$CONFIG_SADIS" == "url" ]; then
1859 push_onos_config "json" \
1860 "[optional] Push ONOS configuration for custom SADIS and Bandwidth Profile servers" \
1861 "network/configuration/apps/org.opencord.sadis" \
David Bainbridged18f4942020-04-14 16:46:13 -07001862 "$(cat <<EOJ | tr -d '[:space:]'
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001863{
1864 "sadis": {
1865 "integration": {
1866 "url": "$SADIS_SUBSCRIBERS",
1867 "cache": {
1868 "enabled": true,
1869 "maxsize": 50,
1870 "ttl": "PT1m"
1871 }
1872 }
1873 },
1874 "bandwidthprofile": {
1875 "integration": {
1876 "url": "$SADIS_BANDWIDTH_PROFILES",
1877 "cache": {
1878 "enabled": true,
1879 "maxsize": 50,
1880 "ttl": "PT1m"
1881 }
1882 }
1883 }
1884}
1885EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07001886)"
David Bainbridge2b19e832019-08-16 02:40:53 +00001887 fi
Test Userba1e7e72019-07-10 22:27:54 +00001888fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001889if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001890 NOW="$(date +%s)"
1891 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001892fi
Test Userba1e7e72019-07-10 22:27:54 +00001893
David Bainbridgec7220622020-05-28 12:31:47 -07001894if is_in "$WITH_ETCD" "yes,external"; then
David Bainbridged18f4942020-04-14 16:46:13 -07001895 STIME="$(date +%s)"
David Bainbridge76afd812020-04-06 09:53:52 -07001896 bspin "Verify external ETCD cluster $OLD_KEY"
David Bainbridge43f2df52020-06-02 15:30:54 -07001897 EXPECT="$(yq r - "etcd.replicas" <"$NAME-values.yaml")"
David Bainbridgec7220622020-05-28 12:31:47 -07001898 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^etcd\$" | wc -l)" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001899 espin "$NOT_VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07001900 helm_install - "$INFRA_NS" etcd "$ETCD_CHART" "$ETCD_CHART_VERSION" etcd "$_HELM_DESC external ETCD cluster"
David Bainbridge76afd812020-04-06 09:53:52 -07001901 else
David Bainbridged18f4942020-04-14 16:46:13 -07001902 espin "$VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07001903 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001904 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for ETCD cluster to start" "$NO_LABEL" "etcd-.*"
David Bainbridge76afd812020-04-06 09:53:52 -07001905 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001906 NOW="$(date +%s)"
1907 printtime $((NOW - STIME))
David Bainbridge76afd812020-04-06 09:53:52 -07001908 fi
1909fi
1910
David Bainbridgec7220622020-05-28 12:31:47 -07001911if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridged18f4942020-04-14 16:46:13 -07001912 _TMP="$(mktemp -u)"
1913 _COUNT="$(test "$TYPE" == "minimal" && echo "1" || echo "3")"
1914 cat << EOC > "$_TMP"
David Bainbridge76afd812020-04-06 09:53:52 -07001915configurationOverrides:
1916 "default.replication.factor": $_COUNT
1917 "offsets.topic.replication.factor": $_COUNT
1918 "log.retention.hours": 4
1919 "log.message.timestamp.type": "LogAppendTime"
1920persistence:
1921 enabled: false
1922zookeeper:
1923 replicaCount: 1
1924 persistence:
1925 enabled: false
1926replicas: $_COUNT
1927EOC
David Bainbridged18f4942020-04-14 16:46:13 -07001928 STIME="$(date +%s)"
David Bainbridge76afd812020-04-06 09:53:52 -07001929 bspin "Verify external Kafka cluster $OLD_KEY"
David Bainbridged18f4942020-04-14 16:46:13 -07001930 EXPECT="$(test "$TYPE" == "minimal" && echo "2" || echo "4")"
1931 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^kafka\$" | wc -l)" -ne 1 ]; then
1932 espin "$NOT_VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07001933 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" -f $_TMP"
David Bainbridgec7220622020-05-28 12:31:47 -07001934 helm_install - "$INFRA_NS" kafka "$KAFKA_CHART" "$KAFKA_CHART_VERSION" kafka "$_HELM_DESC external Kafka cluster"
David Bainbridge76afd812020-04-06 09:53:52 -07001935 else
David Bainbridged18f4942020-04-14 16:46:13 -07001936 espin "$VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07001937 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001938 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for Kafka cluster to start" "$NO_LABEL" "kafka-.*"
David Bainbridge76afd812020-04-06 09:53:52 -07001939 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001940 NOW="$(date +%s)"
1941 printtime $((NOW - STIME))
David Bainbridge76afd812020-04-06 09:53:52 -07001942 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001943 rm -rf "$_TMP"
David Bainbridge76afd812020-04-06 09:53:52 -07001944fi
1945
David Bainbridged18f4942020-04-14 16:46:13 -07001946STIME="$(date +%s)"
David Bainbridgeed476572020-06-02 14:05:45 -07001947EXPECT=2
1948# therecanbeonlyone set hardcoded to true for backward compatibility
1949INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set therecanbeonlyone=true"
Matteo Scandolo67335f02020-04-09 11:19:53 -07001950case $WITH_ETCD in
David Bainbridge76afd812020-04-06 09:53:52 -07001951 no)
David Bainbridge76afd812020-04-06 09:53:52 -07001952 ;;
David Bainbridgec7220622020-05-28 12:31:47 -07001953 yes|external)
1954 _HOST="etcd.$INFRA_NS.svc"
David Bainbridge76afd812020-04-06 09:53:52 -07001955 _PORT=2379
1956 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridge76afd812020-04-06 09:53:52 -07001957 ;;
1958 *)
David Bainbridged18f4942020-04-14 16:46:13 -07001959 _HOST="$(echo "$WITH_ETCD" | cut -d: -f1)"
1960 _PORT="$(echo "$WITH_ETCD" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07001961 _PORT=${_PORT:-2379}
David Bainbridgec7220622020-05-28 12:31:47 -07001962 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridge76afd812020-04-06 09:53:52 -07001963 ;;
1964esac
1965case $WITH_KAFKA in
1966 no)
David Bainbridge76afd812020-04-06 09:53:52 -07001967 ;;
David Bainbridgec7220622020-05-28 12:31:47 -07001968 yes|external)
1969 _HOST=kafka.$INFRA_NS.svc
David Bainbridge76afd812020-04-06 09:53:52 -07001970 _PORT=9092
1971 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 Bainbridge76afd812020-04-06 09:53:52 -07001972 ;;
1973 *)
David Bainbridged18f4942020-04-14 16:46:13 -07001974 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
1975 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07001976 _PORT=${_PORT:-9092}
David Bainbridgec7220622020-05-28 12:31:47 -07001977 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 Bainbridge76afd812020-04-06 09:53:52 -07001978 ;;
1979esac
1980
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001981if is_in "$WITH_ONOS" "legacy"; then
David Bainbridgec7220622020-05-28 12:31:47 -07001982 _HOST=onos-openflow.$INFRA_NS.svc
David Bainbridge76afd812020-04-06 09:53:52 -07001983 _PORT=6653
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001984elif is_in "$WITH_ONOS" "yes,classic"; then
David Bainbridgec7220622020-05-28 12:31:47 -07001985 _HOST=onos-onos-classic-hs.$INFRA_NS.svc
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001986 _PORT=6653
David Bainbridged18f4942020-04-14 16:46:13 -07001987elif [ "$WITH_ONOS" != "no" ]; then
1988 _HOST="$(echo "$WITH_ONOS" | cut -d: -f1)"
1989 _PORT="$(echo "$WITH_ONOS" | cut -s -d: -f2)"
David Bainbridge76afd812020-04-06 09:53:52 -07001990 _PORT=${_PORT:-6653}
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07001991fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001992
David Bainbridgecf546362020-04-21 23:18:50 -07001993compare_versions "$RESOLVED_VOLTHA_CHART_VERSION" 2.4.2
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07001994if [ "$?" == "1" ]; then
1995 # voltha chart > 2.4.2 uses list of controllers
David Bainbridgee4d11ca2020-05-08 10:21:10 -07001996 for NUM in $(seq 0 $((NUM_OF_ONOS-1))); do
David Bainbridgec7220622020-05-28 12:31:47 -07001997 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.controller[$NUM].service=onos-onos-classic-$NUM.onos-onos-classic-hs.$INFRA_NS.svc --set services.controller[$NUM].port=6653"
David Bainbridgee4d11ca2020-05-08 10:21:10 -07001998 done
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07001999else
2000 # voltha chart <= 2.4.2 uses single controller
David Bainbridge76afd812020-04-06 09:53:52 -07002001 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.controller.service=$_HOST --set services.controller.port=$_PORT"
David Bainbridge696bc632020-04-05 21:49:37 -07002002fi
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002003
Test Userb5712372019-07-03 21:52:17 +00002004bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
David Bainbridged18f4942020-04-14 16:46:13 -07002005if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$VOLTHA_NS" "^voltha\$" | wc -l)" -ne 1 ]; then
2006 espin "$NOT_VERIFIED"
David Bainbridgea965ca22020-06-09 17:45:04 -07002007 helm_install - "$VOLTHA_NS" voltha "$VOLTHA_CHART" "$VOLTHA_CHART_VERSION" "+voltha" "$_HELM_DESC VOLTHA Core"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002008else
David Bainbridged18f4942020-04-14 16:46:13 -07002009 espin "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002010fi
David Bainbridge696bc632020-04-05 21:49:37 -07002011INTERNAL_EXTRA_HELM_INSTALL_ARGS=
Test Userba1e7e72019-07-10 22:27:54 +00002012
David Bainbridge90fd8e32019-08-21 23:32:47 +00002013VOLTHA="voltha-ofagent-.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002014 rw-core.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002015 voltha-zookeeper-.*"
David Bainbridged18f4942020-04-14 16:46:13 -07002016wait_for_pods - "$VOLTHA_NS" "$EXPECT" "includes" "Waiting for VOLTHA Core to start" "$NO_LABEL" "$VOLTHA"
David Bainbridgee87067b2019-08-12 22:00:12 +00002017if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002018 NOW="$(date +%s)"
2019 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002020fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002021
David Bainbridge46505fb2019-10-01 21:13:20 +00002022if [ "$WITH_ADAPTERS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002023 STIME="$(date +%s)"
David Bainbridge46505fb2019-10-01 21:13:20 +00002024 EXPECT=0
David Bainbridgec7220622020-05-28 12:31:47 -07002025 if is_in "$WITH_ETCD" "yes,external"; then
2026 _HOST=etcd.$INFRA_NS.svc
David Bainbridge3517f6c2020-04-08 12:14:08 -07002027 _PORT=2379
2028 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridged18f4942020-04-14 16:46:13 -07002029 elif [ "$WITH_ETCD" != "no" ]; then
2030 _HOST="$(echo "$WITH_ETCD" | cut -d: -f1)"
2031 _PORT="$(echo "$WITH_ETCD" | cut -s -d: -f2)"
David Bainbridge3517f6c2020-04-08 12:14:08 -07002032 _PORT=${_PORT:-2379}
2033 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridge696bc632020-04-05 21:49:37 -07002034 fi
David Bainbridgec7220622020-05-28 12:31:47 -07002035 if is_in "$WITH_KAFKA" "yes,external"; then
2036 _HOST=kafka.$INFRA_NS.svc
David Bainbridge3517f6c2020-04-08 12:14:08 -07002037 _PORT=9092
2038 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 -07002039 elif [ "$WITH_KAFKA" != "no" ]; then
2040 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
2041 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge3517f6c2020-04-08 12:14:08 -07002042 _PORT=${_PORT:-9092}
2043 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 -07002044 fi
David Bainbridge46505fb2019-10-01 21:13:20 +00002045 echo -e "Verify Adapters $PLUG"
2046 if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then
2047 bspin - "Verify Simulated Adapters installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002048 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$ADAPTER_NS" "^sim\$" | wc -l)" -ne 1 ]; then
2049 espin - "$NOT_VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002050 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 +00002051 else
David Bainbridged18f4942020-04-14 16:46:13 -07002052 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00002053 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002054 EXPECT="$((EXPECT + 2))"
David Bainbridge46505fb2019-10-01 21:13:20 +00002055 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07002056
David Bainbridge46505fb2019-10-01 21:13:20 +00002057 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
2058 bspin - "Verify OpenOLT Adapter installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002059 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$ADAPTER_NS" "^open-olt\$" | wc -l)" -ne 1 ]; then
2060 espin - "$NOT_VERIFIED"
David Bainbridgea965ca22020-06-09 17:45:04 -07002061 helm_install - "$ADAPTER_NS" open-olt "$VOLTHA_ADAPTER_OPEN_OLT_CHART" "$VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION" "+open-olt" "$_HELM_DESC OpenOLT Adapter"
David Bainbridge46505fb2019-10-01 21:13:20 +00002062 else
David Bainbridged18f4942020-04-14 16:46:13 -07002063 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00002064 fi
Matteo Scandolo67335f02020-04-09 11:19:53 -07002065 EXPECT="$((EXPECT + 1))"
David Bainbridge46505fb2019-10-01 21:13:20 +00002066 bspin - "Verify OpenONU Adapter installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002067 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 -07002068 _ORIGINAL_EXTRA_HELM_INSTALL_ARGS="$INTERNAL_EXTRA_HELM_INSTALL_ARGS"
2069 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set replicas.adapter_open_onu=$NUM_OF_OPENONU"
Girish Gowdra4cc5d8b2020-06-11 17:12:00 -07002070 if [ "$WITH_INCREMENTAL_EVTO_UPDATE" == "yes" ]; then
2071 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set adapter_open_onu.incremental_evto_update=true"
2072 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002073 espin - "$NOT_VERIFIED"
David Bainbridgea965ca22020-06-09 17:45:04 -07002074 helm_install - "$ADAPTER_NS" open-onu "$VOLTHA_ADAPTER_OPEN_ONU_CHART" "$VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION" "+open-onu" "$_HELM_DESC OpenONU Adapter"
Matteo Scandolo67335f02020-04-09 11:19:53 -07002075 INTERNAL_EXTRA_HELM_INSTALL_ARGS="$_ORIGINAL_EXTRA_HELM_INSTALL_ARGS"
David Bainbridge46505fb2019-10-01 21:13:20 +00002076 else
David Bainbridged18f4942020-04-14 16:46:13 -07002077 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00002078 fi
Matteo Scandolo67335f02020-04-09 11:19:53 -07002079 EXPECT=$((EXPECT + NUM_OF_OPENONU))
David Bainbridge46505fb2019-10-01 21:13:20 +00002080 fi
David Bainbridge696bc632020-04-05 21:49:37 -07002081 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07002082
David Bainbridge46505fb2019-10-01 21:13:20 +00002083 ADAPTERS="adapter-.*"
David Bainbridged18f4942020-04-14 16:46:13 -07002084 wait_for_pods - "$ADAPTER_NS" "$EXPECT" "includes" "Waiting for adapters to start" "$NO_LABEL" "$ADAPTERS"
David Bainbridge46505fb2019-10-01 21:13:20 +00002085 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002086 NOW="$(date +%s)"
2087 printtime $((NOW - STIME))
David Bainbridge46505fb2019-10-01 21:13:20 +00002088 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00002089fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002090
David Bainbridged18f4942020-04-14 16:46:13 -07002091if [ "$WITH_BBSIM" == "yes" ]; then
2092 STIME="$(date +%s)"
Test User7d866122019-07-09 17:52:35 +00002093 echo -e "Verify BBSIM $PLUG"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002094 bspin - "Verify BBSIM Installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002095 for instance in $(seq 0 $((NUM_OF_BBSIM-1))); do
Matteo Scandoloc2eb0672020-05-01 14:43:15 -07002096
2097 if [ "$LEGACY_BBSIM_INDEX" == "yes" ]; then
2098 if [ "$instance" -eq 0 ]; then
2099 instance_num=""
2100 else
2101 instance_num=$instance
2102 fi
David K. Bainbridge43422402020-03-06 07:41:22 -08002103 else
2104 instance_num=$instance
2105 fi
Matteo Scandoloc2eb0672020-05-01 14:43:15 -07002106
2107
David Bainbridged18f4942020-04-14 16:46:13 -07002108 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$BBSIM_NS" "^bbsim${instance_num}\$" | wc -l)" -ne 1 ]; then
2109 espin - "$NOT_VERIFIED"
2110 S_TAG="$((900+instance))"
Matteo Scandolo5a149572020-04-01 10:14:57 -07002111 INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set olt_id=$instance,s_tag=$S_TAG"
David Bainbridged9329af2020-05-01 11:58:52 -07002112 if [ "$WITH_EAPOL" == "yes" ]; then
2113 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set auth=true"
2114 else
2115 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set auth=false"
2116 fi
2117 if [ "$WITH_DHCP" == "yes" ]; then
2118 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set dhcp=true"
2119 else
2120 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set dhcp=false"
2121 fi
David Bainbridge33e56c72020-06-11 11:39:56 -07002122 if is_in "$WITH_KAFKA" "yes,external"; then
2123 _HOST=kafka.$INFRA_NS.svc
2124 _PORT=9092
2125 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafkaAddress=$_HOST:$_PORT"
2126 elif [ "$WITH_KAFKA" != "no" ]; then
2127 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
2128 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
2129 _PORT=${_PORT:-9092}
2130 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafkaAddress=$_HOST:$_PORT"
2131 fi
2132 helm_install - "$BBSIM_NS" "bbsim${instance_num}" "$VOLTHA_BBSIM_CHART" "$VOLTHA_BBSIM_CHART_VERSION" "+bbsim" "$_HELM_DESC BBSIM${instance_num}"
David Bainbridge2eaf2cf2020-03-18 12:54:08 -07002133 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
David K. Bainbridge43422402020-03-06 07:41:22 -08002134 else
David Bainbridged18f4942020-04-14 16:46:13 -07002135 espin - "$VERIFIED"
David K. Bainbridge43422402020-03-06 07:41:22 -08002136 fi
2137 done
David Bainbridged18f4942020-04-14 16:46:13 -07002138 wait_for_pods - "$BBSIM_NS" "$NUM_OF_BBSIM" "includes" "Waiting for BBSIM to start" "$BBSIM_LABEL" "bbsim*"
David Bainbridgee87067b2019-08-12 22:00:12 +00002139 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002140 NOW="$(date +%s)"
2141 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002142 fi
Test User7d866122019-07-09 17:52:35 +00002143fi
2144
David Bainbridge309099c2020-05-05 08:47:29 -07002145if [ "$CONFIG_SADIS" == "external" ]; then
2146 STIME="$(date +%s)"
2147 echo -e "Verify BBSIM SADIS Service $PLUG"
2148 bspin - "Verify required configmap"
2149 (set -x; kubectl -n "$BBSIM_NS" delete --ignore-not-found configmap kube-config >>"$LOG" 2>&1) >>"$LOG" 2>&1
2150 (set -x; kubectl -n "$BBSIM_NS" create configmap kube-config "--from-file=kube_config=$KUBECONFIG" >>"$LOG" 2>&1) >>"$LOG" 2>&1
2151 espin - "$VERIFIED"
2152 bspin - "Verify BBSIM SADIS Service Installed"
2153 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$BBSIM_NS" "^bbsim-sadis-servier\$" | wc -l)" -ne 1 ]; then
2154 espin - "$NOT_VERIFIED"
David Bainbridge879439b2020-06-12 15:59:35 -07002155 helm_install - "$BBSIM_NS" bbsim-sadis-server "$BBSIM_SADIS_SERVER_CHART" "$BBSIM_SADIS_SERVER_CHART_VERSION" "+sadis" "$_HELM_DESC BBSIM SADIS Server"
David Bainbridge309099c2020-05-05 08:47:29 -07002156 else
2157 espin - "$VERIFIED"
2158 fi
2159 wait_for_pods - "$BBSIM_NS" 1 "includes" "Waiting for BBSIM SADIS Server to start" "$NO_LABEL" "bbsim-sadis-server-.*"
2160 if [ "$WITH_TIMINGS" == "yes" ]; then
2161 NOW="$(date +%s)"
2162 printtime $((NOW - STIME))
2163 fi
2164fi
2165
David Bainbridged18f4942020-04-14 16:46:13 -07002166if [ "$WITH_RADIUS" == "yes" ]; then
2167 STIME="$(date +%s)"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002168 echo -e "Verify RADIUS $LOCK"
2169 bspin - "Verify RADIUS Installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002170 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^radius\$" | wc -l)" -ne 1 ]; then
2171 espin - "$NOT_VERIFIED"
David Bainbridge879439b2020-06-12 15:59:35 -07002172 helm_install - "$INFRA_NS" radius "$RADIUS_CHART" "$RADIUS_CHART_VERSION" "+radius" "$_HELM_DESC RADIUS"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002173 else
David Bainbridged18f4942020-04-14 16:46:13 -07002174 espin - "$VERIFIED"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002175 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002176 wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for RADIUS to start" "$NO_LABEL" "radius-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00002177 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002178 NOW="$(date +%s)"
2179 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002180 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002181fi
2182
David Bainbridged18f4942020-04-14 16:46:13 -07002183if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
2184 STIME="$(date +%s)"
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002185 bspin - "Forward VOLTHA API port $FORWARD"
David Bainbridge1d2c5842020-06-03 15:29:07 -07002186 kill_port_forward voltha-api voltha-voltha-api
2187 VOLTHA_PREFIX=
2188 if kubectl get -n "$VOLTHA_NS" "svc/voltha-voltha-api" >/dev/null 2>&1; then
2189 VOLTHA_PREFIX="voltha-"
2190 fi
2191
2192 port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-api" "$VOLTHA_API_PORT:55555"
David Bainbridged18f4942020-04-14 16:46:13 -07002193 espin - "$VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002194 if is_in "$WITH_ETCD" "yes,external"; then
David Bainbridge696bc632020-04-05 21:49:37 -07002195 bspin - "Forward VOLTHA ETCD port $FORWARD"
David Bainbridgec7220622020-05-28 12:31:47 -07002196 kill_port_forward "etcd"
2197 port_forward "$INFRA_NS" "etcd" "$VOLTHA_ETCD_PORT:2379"
David Bainbridged18f4942020-04-14 16:46:13 -07002198 espin - "$VERIFIED"
David Bainbridge696bc632020-04-05 21:49:37 -07002199 fi
David Bainbridgec7220622020-05-28 12:31:47 -07002200 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridge696bc632020-04-05 21:49:37 -07002201 bspin - "Forward VOLTHA Kafka port $FORWARD"
David Bainbridgec7220622020-05-28 12:31:47 -07002202 kill_port_forward "kafka"
2203 port_forward "$INFRA_NS" kafka "$VOLTHA_KAFKA_PORT:9092"
David Bainbridged18f4942020-04-14 16:46:13 -07002204 espin - "$VERIFIED"
David Bainbridge696bc632020-04-05 21:49:37 -07002205 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -07002206 if [ "$WITH_PPROF" == "yes" ]; then
David Bainbridge1d2c5842020-06-03 15:29:07 -07002207 VOLTHA_OPENOLT_PREFIX=
2208 if kubectl get -n "$ADAPTER_NS" "svc/open-olt-adapter-open-olt-profiler" >/dev/null 2>&1; then
2209 VOLTHA_OPENOLT_PREFIX="open-olt-"
2210 fi
David Bainbridge879439b2020-06-12 15:59:35 -07002211 bspin - "Forward PProf ports port $FORWARD"
2212 kill_port_forward voltha-rw-core-profiler voltha-voltha-rw-core-profiler
2213 kill_port_forward adapter-open-olt-profiler open-olt-adapter-open-olt-profiler
2214 kill_port_forward voltha-of-agent-profiler voltha-voltha-of-agent-profiler
2215 port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-rw-core-profiler" "$VOLTHA_PPROF_PORT:6060"
2216 port_forward "$ADAPTER_NS" "${VOLTHA_OPENOLT_PREFIX}adapter-open-olt-profiler" "$OPENOLT_PPROF_PORT:6060"
2217 port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-of-agent-profiler" "$OFAGENT_PPROF_PORT:6060"
2218 espin - "$VERIFIED"
Matteo Scandoloefee0432020-05-05 13:56:20 -07002219 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002220 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002221 NOW="$(date +%s)"
2222 printtime $((NOW - STIME))
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002223 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00002224fi
Test User3d7ad8e2019-07-03 06:15:44 +00002225
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002226if is_in "$WITH_ONOS" "yes,legacy,classic" && [ "$WITH_RADIUS" != "no" ]; then
David Bainbridge879439b2020-06-12 15:59:35 -07002227 SVC_NAME=radius
2228 if kubectl get -n "$INFRA_NS" "svc/radius-freeradius" >/dev/null 2>&1; then
2229 SVC_NAME="radius-freeradius"
2230 fi
2231 _HOST="$SVC_NAME.$INFRA_NS.svc"
David Bainbridge696bc632020-04-05 21:49:37 -07002232 _PORT=1812
David Bainbridged18f4942020-04-14 16:46:13 -07002233 if [ "$WITH_RADIUS" != "yes" ]; then
2234 _HOST="$(echo "$WITH_RADIUS" | cut -d: -f1)"
2235 _PORT="$(echo "$WITH_RADIUS" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07002236 _PORT=${_PORT:-1812}
2237 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002238 bspin "Configure ONOS RADIUS Connection $GEAR"
David Bainbridged18f4942020-04-14 16:46:13 -07002239 (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
2240 espin "$VERIFIED"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002241fi
2242
David Bainbridge99ac7a22019-08-31 02:26:43 +00002243if [ "$WITH_CHAOS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002244 STIME="$(date +%s)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002245 echo -e "Verify kube-monkey $LOCK"
2246 bspin - "Verify kube-monkey Installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002247 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace kube-monkey "^monkey\$" | wc -l)" -ne 1 ]; then
2248 espin - "$NOT_VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002249 helm_install - kube-monkey monkey ./kube-monkey/helm/kubemonkey latest - "$_HELM_DESC Chaos Monkey"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002250 else
David Bainbridged18f4942020-04-14 16:46:13 -07002251 espin - "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002252 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002253 wait_for_pods - "kube-monkey" 1 "includes" "Waiting for Chaos to start" "$NO_LABEL" "monkey-.*"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002254 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002255 NOW="$(date +%s)"
2256 printtime $((NOW - STIME))
David Bainbridge99ac7a22019-08-31 02:26:43 +00002257 fi
2258fi
2259
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002260bspin "Create voltctl configuration file"
David Bainbridged18f4942020-04-14 16:46:13 -07002261(set -x; mkdir -p "$HOME/.volt" >>"$LOG" 2>&1) >>"$LOG" 2>&1
2262MIN_VC_VERSION="$(echo -e "1.0.15\n$VC_VERSION" | sort -V | head -1)"
2263if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002264 KAFKA_FLAG="-k localhost:$VOLTHA_KAFKA_PORT"
2265 SERVER_FLAG="-s localhost:$VOLTHA_API_PORT"
2266 ETCD_FLAG=
2267 if [ "$MIN_VC_VERSION" == "1.0.15" ]; then
2268 ETCD_FLAG="-e localhost:$VOLTHA_ETCD_PORT"
2269 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002270else
David Bainbridgec7220622020-05-28 12:31:47 -07002271 KAFKA_FLAG="-k $(get_service_ep "$INFRA_NS" kafka)"
David Bainbridged18f4942020-04-14 16:46:13 -07002272 SERVER_FLAG="-s $(get_service_ep "$VOLTHA_NS" voltha-api)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002273 ETCD_FLAG=
2274 if [ "$MIN_VC_VERSION" == "1.0.15" ]; then
David Bainbridgec7220622020-05-28 12:31:47 -07002275 ETCD_FLAG="-e $(get_service_ep "$INFRA_NS" etcd)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002276 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002277fi
David Bainbridgea965ca22020-06-09 17:45:04 -07002278CMD=("voltctl $KAFKA_FLAG $SERVER_FLAG $ETCD_FLAG config")
David Bainbridged18f4942020-04-14 16:46:13 -07002279(set -x; ${CMD[*]} > "$HOME/.volt/config-$NAME" 2>>"$LOG") >>"$LOG" 2>&1
David Bainbridgea965ca22020-06-09 17:45:04 -07002280#(set -x; voltctl "$KAFKA_FLAG" "$SERVER_FLAG" "$ETCD_FLAG" config > "$HOME/.volt/config-$NAME" 2>>"$LOG") >>"$LOG" 2>&1
David Bainbridged18f4942020-04-14 16:46:13 -07002281espin "$VERIFIED"
Test User08ebbd92019-07-03 17:15:39 +00002282
David Bainbridge0774b232019-08-02 06:37:19 +00002283if [ ! -f "$NAME-env.sh" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002284 touch "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002285fi
2286
David Bainbridge596f30d2019-07-30 17:07:59 +00002287for O in $ALL_OPTIONS; do
David Bainbridged18f4942020-04-14 16:46:13 -07002288 VAL="$(eval echo "\$$O")"
2289 if [ -n "$VAL" ] && [ "$(grep -c "^export $O=" "$NAME-env.sh")" -eq 0 ]; then
2290 echo "export $O=\"$(eval echo "\$$O")\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002291 fi
2292done
2293
David Bainbridged18f4942020-04-14 16:46:13 -07002294if [ "$DEPLOY_K8S" == "yes" ] && [ "$(grep -c "^export KUBECONFIG=" "$NAME-env.sh")" -eq 0 ]; then
2295 echo "export KUBECONFIG=\"$(./bin/kind get kubeconfig-path "--name=voltha-$NAME")\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002296fi
2297
David Bainbridged18f4942020-04-14 16:46:13 -07002298if [ "$(grep -c "^export VOLTCONFIG=" "$NAME-env.sh")" -eq 0 ]; then
2299 echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002300fi
2301
David Bainbridged18f4942020-04-14 16:46:13 -07002302if [ "$(grep -c "^export PATH=" "$NAME-env.sh")" -eq 0 ]; then
2303 echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002304fi
2305
Test User7d866122019-07-09 17:52:35 +00002306echo ""
David Bainbridged18f4942020-04-14 16:46:13 -07002307echo "Please issue the following commands in your terminal to ensure that you" | tee -a "$LOG"
2308echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a "$LOG"
2309echo "tools required by VOLTHA in your command path. " | tee -a "$LOG"
2310echo "" | tee -a "$LOG"
2311echo -en "$BOLD"
2312if [ "$DEPLOY_K8S" == "yes" ]; then
2313 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00002314fi
David Bainbridged18f4942020-04-14 16:46:13 -07002315echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" | tee -a "$LOG"
2316echo "export PATH=$GOPATH/bin:\$PATH" | tee -a "$LOG"
2317echo -en "$NORMAL"
2318echo "" | tee -a "$LOG"
2319echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a "$LOG"
Test User08ebbd92019-07-03 17:15:39 +00002320
David Bainbridge712afb82019-08-14 19:55:58 +00002321if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002322 NOW="$(date +%s)"
2323 echo -e "$CLOCK ${BOLD}TOTAL: $(duration $((NOW - TOTAL_START_TIME)))${NORMAL}"
David Bainbridge712afb82019-08-14 19:55:58 +00002324fi