blob: 8bb10591811973c6cb28cca1cc4aefd0b65e4006 [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}
David Bainbridgee4d11ca2020-05-08 10:21:10 -070090SCHEDULE_ON_CONTROL_NODES=${SCHEDULE_ON_CONTROL_NODES:-no}
David Bainbridge309099c2020-05-05 08:47:29 -070091CONFIG_SADIS=${CONFIG_SADIS:-no} # yes | no | file | bbsim | external | URL
Hardik Windlassb3147602020-03-09 16:59:15 +053092SADIS_CFG=${SADIS_CFG:-onos-files/onos-sadis-sample.json}
David Bainbridge27790d62019-08-13 22:43:19 +000093INSTALL_ONOS_APPS=${INSTALL_ONOS_APPS:-no}
Test Userba1e7e72019-07-10 22:27:54 +000094JUST_K8S=${JUST_K8S:-no}
95DEPLOY_K8S=${DEPLOY_K8S:-yes}
David K. Bainbridge0e89cb92019-07-17 11:30:10 -070096INSTALL_KUBECTL=${INSTALL_KUBECTL:-yes}
97INSTALL_HELM=${INSTALL_HELM:-yes}
David Bainbridge7f8bf992020-04-08 21:53:22 -070098HELM_USE_UPGRADE=${HELM_USE_UPGRADE:-no}
David Bainbridge46505fb2019-10-01 21:13:20 +000099UPDATE_HELM_REPOS=${UPDATE_HELM_REPOS:-yes}
Matteo Scandolofab98622020-01-28 15:17:20 -0800100WAIT_ON_DOWN=${WAIT_ON_DOWN:-yes}
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700101WAIT_TIMEOUT=${WAIT_TIMEOUT:-30m}
102VOLTHA_DOWN_ON_TIMEOUT=${VOLTHA_DOWN_ON_TIMEOUT:-no}
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000103VOLTHA_LOG_LEVEL=${VOLTHA_LOG_LEVEL:-WARN}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000104VOLTHA_CHART=${VOLTHA_CHART:-onf/voltha}
105VOLTHA_CHART_VERSION=${VOLTHA_CHART_VERSION:-latest}
106VOLTHA_BBSIM_CHART=${VOLTHA_BBSIM_CHART:-onf/bbsim}
Matteo Scandolodcd29f52019-10-07 15:42:42 -0700107VOLTHA_BBSIM_CHART_VERSION=${VOLTHA_BBSIM_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000108VOLTHA_ADAPTER_SIM_CHART=${VOLTHA_ADAPTER_SIM_CHART:-onf/voltha-adapter-simulated}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000109VOLTHA_ADAPTER_SIM_CHART_VERSION=${VOLTHA_ADAPTER_SIM_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000110VOLTHA_ADAPTER_OPEN_OLT_CHART=${VOLTHA_ADAPTER_OPEN_OLT_CHART:-onf/voltha-adapter-openolt}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000111VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION=${VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000112VOLTHA_ADAPTER_OPEN_ONU_CHART=${VOLTHA_ADAPTER_OPEN_ONU_CHART:-onf/voltha-adapter-openonu}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000113VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION=${VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION:-latest}
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800114ONOS_CHART=${ONOS_CHART:-onf/onos}
Andrea Campanella21323292019-12-18 11:44:19 -0800115ONOS_CHART_VERSION=${ONOS_CHART_VERSION:-latest}
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700116ONOS_CLASSIC_CHART=${ONOS_CLASSIC_CHART:-onos/onos-classic}
117ONOS_CLASSIC_CHART_VERSION=${ONOS_CHART_VERSION:-latest}
David Bainbridgecf546362020-04-21 23:18:50 -0700118KAFKA_CHART=${KAFKA_CHART:-incubator/kafka}
David Bainbridgeb9093522020-04-15 14:32:44 -0700119KAFKA_CHART_VERSION=${KAFKA_CHART_VERSION:=0.15.3}
David Bainbridge309099c2020-05-05 08:47:29 -0700120BBSIM_SADIS_SERVER_CHART=${BBSIM_SADIS_SERVER_CHART:-bbsim-sadis/bbsim-sadis-server}
121BBSIM_SADIS_SERVER_CHART_VERSION=${BBSIM_SADIS_SERVER_CHART_VERSION:-latest}
David Bainbridgec7220622020-05-28 12:31:47 -0700122ETCD_CHART=${ETCD_CHART:-incubator/etcd}
123ETCD_CHART_VERSION=${ETCD_CHART_VERSION:-latest}
David Bainbridge2eaf2cf2020-03-18 12:54:08 -0700124EXTRA_HELM_INSTALL_ARGS=${EXTRA_HELM_INSTALL_ARGS:-}
125INTERNAL_EXTRA_HELM_INSTALL_ARGS=
uottrembb16d3982020-02-28 08:34:36 +0100126NUM_OF_BBSIM=${NUM_OF_BBSIM:-1}
Matteo Scandolo67335f02020-04-09 11:19:53 -0700127NUM_OF_OPENONU=${NUM_OF_OPENONU:-1}
uottrembb16d3982020-02-28 08:34:36 +0100128MAX_NUM_OF_BBSIM=10
Matteo Scandolo67335f02020-04-09 11:19:53 -0700129MAX_NUM_OF_OPENONU=10
Matteo Scandoloc2eb0672020-05-01 14:43:15 -0700130LEGACY_BBSIM_INDEX=${LEGACY_BBSIM_INDEX:-no}
Test Userba1e7e72019-07-10 22:27:54 +0000131
David Bainbridged18f4942020-04-14 16:46:13 -0700132HOSTOS="$(uname -s | tr "[:upper:]" "[:lower:"])"
133HOSTARCH="$(uname -m | tr "[:upper:]" "[:lower:"])"
134if [ "$HOSTARCH" == "x86_64" ]; then
Test Userba1e7e72019-07-10 22:27:54 +0000135 HOSTARCH="amd64"
136fi
David Bainbridge7db44002020-04-09 12:54:29 -0700137BBSIM_LABEL="-l app=bbsim"
David Bainbridged18f4942020-04-14 16:46:13 -0700138NO_LABEL=
Test User7d866122019-07-09 17:52:35 +0000139
uottrembb16d3982020-02-28 08:34:36 +0100140# check number (range) of bbsim, max bbsim must not exceed 10 instances!
141# note: instances will be numbered from 0 to 9
142if [ "$1" == "up" ]; then
David K. Bainbridge43422402020-03-06 07:41:22 -0800143 if [ "$NUM_OF_BBSIM" -lt 1 ]; then
Matteo Scandolo67335f02020-04-09 11:19:53 -0700144 >&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 -0800145 exit 1
146 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700147 if [ "$NUM_OF_BBSIM" -gt "$MAX_NUM_OF_BBSIM" ]; then
Matteo Scandolo67335f02020-04-09 11:19:53 -0700148 >&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}"
149 exit 1
150 fi
151
152 if [ "$NUM_OF_OPENONU" -lt 1 ]; then
153 >&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}"
154 exit 1
155 fi
156 if [ "$NUM_OF_OPENONU" -gt "$MAX_NUM_OF_OPENONU" ]; then
157 >&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 -0800158 exit 1
159 fi
uottrembb16d3982020-02-28 08:34:36 +0100160fi
Test User7d866122019-07-09 17:52:35 +0000161# Verify TYPE setting
David Bainbridged18f4942020-04-14 16:46:13 -0700162if [ "$(echo ":minimal:full:" | grep -ic ":$TYPE:")" -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700163 >&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 +0000164 exit 1
165fi
166
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700167# checks to see if a given WORD is in the given LIST of words
168function is_in() {
169 local WORD LIST
170 WORD="$1"; shift
171 LIST="$*"
172 LIST=${LIST//+([[:space:],|])/:}
173
174 [ "$(echo ":$LIST:" | grep -ic ":$WORD:")" -ne 0 ]
175}
176
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700177function parseDuration() {
David Bainbridged18f4942020-04-14 16:46:13 -0700178 local DUR RESULT TERM TERMS VALUE UNIT
179 DUR=$1
180 RESULT=0
181 TERMS="$(echo "$DUR" | sed -Ee 's/([sSmMhHdD])/\1 /g' -e 's/,$//g')"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700182 for TERM in $TERMS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700183 VALUE="$(echo "$TERM" | sed -Ee 's/([0-9]+)[sSmMhHdD]/\1/')"
184 UNIT="$(echo "$TERM" | sed -Ee 's/[0-9]+([sSmMhHdD])/\1/')"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700185 case $UNIT in
186 s|S)
David Bainbridged18f4942020-04-14 16:46:13 -0700187 RESULT=$((RESULT + VALUE)) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700188 m|M)
David Bainbridged18f4942020-04-14 16:46:13 -0700189 RESULT=$((RESULT + (VALUE * 60))) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700190 h|H)
David Bainbridged18f4942020-04-14 16:46:13 -0700191 RESULT=$((RESULT + (VALUE * 3600))) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700192 d|D)
David Bainbridged18f4942020-04-14 16:46:13 -0700193 RESULT=$((RESULT + (VALUE * 86400))) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700194 *) ;;
195 esac
196 done
197 echo $RESULT
198}
199
200function doTimeout() {
201 local MSG=$1
202 2>&1 echo -e "\n${RED}${BOLD}${ERROR}TIMEOUT:${NORMAL}${RED} Operation timed out after '$WAIT_TIMEOUT': $MSG"
203 exit 125
204}
205
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800206function get_service_ep() {
207 local NS=$1
208 local NAME=$2
David Bainbridged18f4942020-04-14 16:46:13 -0700209 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 -0800210}
211
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000212# Used to verify configuration values are set to "yes" or "no" value or convert
213# equivalents to "yes" or "no"
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700214YES="y,yes,t,true,1"
215NO="n,no,f,false,0"
216YES_OR_NO="$YES,$NO"
217
218# If the given VAR matches a truth value then normalize that
219# value, else return original value
220function normalize_yes_no() {
221 local VAR VAL
222 VAR=$1
223 VAL="$(eval echo "\$$VAR")"
224 if ! is_in "$VAL" "$YES_OR_NO"; then
225 echo "$VAL"
226 return 1
227 fi
228 if is_in "$VAL" "$YES"; then
229 echo "yes"
230 else
231 echo "no"
232 fi
233 return 0
234}
235
236# If the given VAR matches a truth value then normalize that
237# value, else display an error
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000238function verify_yes_no() {
David Bainbridged18f4942020-04-14 16:46:13 -0700239 local VAR VAL
240 VAR=$1
241 VAL="$(eval echo "\$$VAR")"
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700242 if ! is_in "$VAL" "$YES_OR_NO"; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000243 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid '$VAR' value of '$VAL'. Should be 'yes' or 'no'${NORMAL}"
244 echo "INVALID"
245 return 1
246 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700247 if is_in "$VAL" "$YES"; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000248 echo "yes"
249 else
250 echo "no"
251 fi
252 return 0
253}
Test User7d866122019-07-09 17:52:35 +0000254
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000255ALL_YES_NO="\
David K. Bainbridge484d80c2020-03-05 21:44:34 -0800256 ENABLE_ONOS_EXTRANEOUS_RULES \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000257 WITH_TIMINGS \
258 WITH_BBSIM \
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800259 WITH_EAPOL \
260 WITH_DHCP \
261 WITH_IGMP \
David Bainbridge99ac7a22019-08-31 02:26:43 +0000262 WITH_CHAOS \
David Bainbridge46505fb2019-10-01 21:13:20 +0000263 WITH_ADAPTERS \
264 WITH_SIM_ADAPTERS \
265 WITH_OPEN_ADAPTERS \
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800266 WITH_PORT_FORWARDS \
Matteo Scandoloefee0432020-05-05 13:56:20 -0700267 WITH_PPROF \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000268 JUST_K8S \
269 DEPLOY_K8S \
270 INSTALL_ONOS_APPS \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000271 INSTALL_KUBECTL \
272 INSTALL_HELM \
David Bainbridge7f8bf992020-04-08 21:53:22 -0700273 HELM_USE_UPGRADE \
David Bainbridge46505fb2019-10-01 21:13:20 +0000274 UPDATE_HELM_REPOS \
David Bainbridge4f1b5562019-08-19 04:46:52 +0000275 WAIT_ON_DOWN \
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700276 VOLTHA_DOWN_ON_TIMEOUT \
Matteo Scandoloc2eb0672020-05-01 14:43:15 -0700277 LEGACY_BBSIM_INDEX \
David Bainbridgee4d11ca2020-05-08 10:21:10 -0700278 SCHEDULE_ON_CONTROL_NODES \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000279 "
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000280
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700281OPT_YES_NO="\
282 CONFIG_SADIS \
283 WITH_KAFKA \
284 WITH_RADIUS \
285 WITH_ETCD \
286 WITH_ONOS \
287 "
288
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000289ALL_OPTIONS="\
290 NAME \
291 TYPE \
292 $ALL_YES_NO \
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700293 $OPT_YES_NO \
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700294 WAIT_TIMEOUT \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000295 VOLTHA_LOG_LEVEL \
296 VOLTHA_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000297 VOLTHA_CHART_VERSION \
298 VOLTHA_BBSIM_CHART \
299 VOLTHA_BBSIM_CHART_VERSION \
uottrembd5a20572020-03-06 09:15:01 +0100300 NUM_OF_BBSIM \
Matteo Scandolo67335f02020-04-09 11:19:53 -0700301 NUM_OF_OPENONU \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000302 VOLTHA_ADAPTER_SIM_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000303 VOLTHA_ADAPTER_SIM_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000304 VOLTHA_ADAPTER_OPEN_OLT_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000305 VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000306 VOLTHA_ADAPTER_OPEN_ONU_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000307 VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION \
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800308 ONOS_CHART \
Andrea Campanella21323292019-12-18 11:44:19 -0800309 ONOS_CHART_VERSION \
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700310 ONOS_CLASSIC_CHART \
311 ONOS_CLASSIC_CHART_VERSION \
David Bainbridgecf546362020-04-21 23:18:50 -0700312 KAFKA_CHART \
David Bainbridgeb9093522020-04-15 14:32:44 -0700313 KAFKA_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000314 ONOS_API_PORT \
315 ONOS_SSH_PORT \
Hardik Windlassb3147602020-03-09 16:59:15 +0530316 SADIS_CFG \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000317 VOLTHA_API_PORT \
318 VOLTHA_SSH_PORT \
319 VOLTHA_ETCD_PORT \
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800320 VOLTHA_KAFKA_PORT \
Matteo Scandoloefee0432020-05-05 13:56:20 -0700321 VOLTHA_PPROF_PORT \
322 OPENOLT_PPROF_PORT \
Matteo Scandolo65c35192020-05-13 10:41:21 -0700323 OFAGENT_PPROF_PORT \
David K. Bainbridge8f7f30b2020-01-08 13:06:16 -0800324 VK_RELEASE \
325 KIND_VERSION \
326 VOLTCTL_VERSION \
David Bainbridgea34993d2020-04-01 09:15:42 -0700327 HELM_VERSION \
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700328 NUM_OF_ONOS \
329 NUM_OF_ATOMIX \
David Bainbridge6ca40102020-04-08 11:30:40 -0700330 VOLTHA_NS \
331 ADAPTER_NS \
332 INFRA_NS \
333 BBSIM_NS \
David Bainbridge7db44002020-04-09 12:54:29 -0700334 SADIS_BANDWIDTH_PROFILES \
335 SADIS_SUBSCRIBERS \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000336 "
David Bainbridge01294952019-07-30 19:33:45 +0000337
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000338# Iterate over yes/no configuration options and validate
339for VAR in $ALL_YES_NO; do
David Bainbridged18f4942020-04-14 16:46:13 -0700340 eval "$VAR"="$(verify_yes_no "$VAR")"
341 if [ "$(eval echo "\$$VAR")" == "INVALID" ]; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000342 exit 1;
343 fi
344done
David Bainbridgeb270c202019-07-26 01:44:42 +0000345
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700346# Iterate over optional yes/no configuration options and
347# normalize values if they are truth values
348for VAR in $OPT_YES_NO; do
349 eval "$VAR"="$(normalize_yes_no "$VAR")"
350done
David Bainbridge15f6f232020-03-30 09:15:43 -0700351
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700352# normalize non-truth value options
353if is_in "$WITH_KAFKA" "e,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -0700354 WITH_KAFKA="external"
355fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700356if is_in "$WITH_ETCD" "e,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -0700357 WITH_ETCD="external"
358fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700359if is_in "$WITH_ONOS" "l,legacy"; then
360 WITH_ONOS="legacy"
361elif is_in "$WITH_ONOS" "c,classic"; then
362 WITH_ONOS="classic"
363elif is_in "$WITH_ONOS" "u,m,micro"; then
364 WITH_ONOS="micro"
David Bainbridge29c31cb2020-04-06 09:45:50 -0700365fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700366
367if [ "$WITH_ONOS" == "micro" ]; then
368 >&2 echo -e "${YELLOW}${BOLD}${ERROR}WARNING:${NORMAL}${YELLOW} The value specified as WITH_ONOS, '$WITH_ONOS', is not valid.${NORMAL}"
369 exit 1
David Bainbridge29c31cb2020-04-06 09:45:50 -0700370fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700371
372if is_in "$WITH_ONOS" "yes,classic"; then
373 # there is an extra utility required if we are using ONOS CLASSIC as
374 # the chart for classic specifies images differently
375 EXTRA_TOOLS+=" yq"
David Bainbridge76afd812020-04-06 09:53:52 -0700376fi
David Bainbridge696bc632020-04-05 21:49:37 -0700377
David Bainbridge22db5dd2020-05-26 12:21:21 -0700378if [ "$LEGACY_BBSIM_INDEX" == "no" ]; then
379 BBSIM_SADIS_SVC="bbsim0"
380else
381 BBSIM_SADIS_SVC="bbsim"
382fi
383
384SADIS_SUBSCRIBERS=${SADIS_SUBSCRIBERS:-http://$BBSIM_SADIS_SVC.$VOLTHA_NS.svc:50074/v2/subscribers/%s}
385SADIS_BANDWIDTH_PROFILES=${SADIS_BANDWIDTH_PROFILES:-http://$BBSIM_SADIS_SVC.$VOLTHA_NS.svc:50074/v2/bandwidthprofiles/%s}
386
David Bainbridged18f4942020-04-14 16:46:13 -0700387if [ "$HELM_USE_UPGRADE" == "yes" ]; then
David Bainbridge7f8bf992020-04-08 21:53:22 -0700388 _HELM_DESC="Upgrade/Install"
389else
390 _HELM_DESC="Install"
391fi
392
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800393# Check for prerequiste tools
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700394TOOLS="curl sed jq $EXTRA_TOOLS"
David Bainbridged18f4942020-04-14 16:46:13 -0700395if [ "$DEPLOY_K8S" == "yes" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800396 TOOLS+=" docker"
397fi
398NOT_FOUND=""
399for T in $TOOLS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700400 if [ -z "$(command -v "$T")" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800401 NOT_FOUND+=" $T"
402 fi
403done
404
David Bainbridged18f4942020-04-14 16:46:13 -0700405if [ -n "$NOT_FOUND" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800406 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} The following required tools where not found, please install them:$NOT_FOUND"
407 exit 1
408fi
409
David Bainbridged18f4942020-04-14 16:46:13 -0700410TIMEOUT_SECONDS="$(parseDuration "$WAIT_TIMEOUT")"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700411
David Bainbridge0774b232019-08-02 06:37:19 +0000412mkdir -p .voltha
413touch .voltha/ports
David Bainbridged18f4942020-04-14 16:46:13 -0700414HAVE="$(grep "$NAME" .voltha/ports)"
David Bainbridge0774b232019-08-02 06:37:19 +0000415if [ "$HAVE X" == " X" ]; then
416 # Find free port prefix
417 START=81
418 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700419 if [ "$(grep -c $START .voltha/ports)" -eq 0 ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000420 break
421 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700422 START="$((START + 1))"
David Bainbridge0774b232019-08-02 06:37:19 +0000423 done
David Bainbridged18f4942020-04-14 16:46:13 -0700424 DELTA="$((START - 81))"
David Bainbridgea2595422019-10-22 03:54:28 +0000425 ONOS_API_PORT=${ONOS_API_PORT:-${START}81}
426 ONOS_SSH_PORT=${ONOS_SSH_PORT:-${START}01}
David Bainbridged18f4942020-04-14 16:46:13 -0700427 VOLTHA_API_PORT=${VOLTHA_API_PORT:-5$((55 + DELTA))55}
428 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$((50 + DELTA))22}
429 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$((23 + DELTA))79}
430 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$((90 + DELTA))92}
Matteo Scandoloefee0432020-05-05 13:56:20 -0700431 VOLTHA_PPROF_PORT=${VOLTHA_PPROF_PORT:-$((60 + DELTA))60}
432 OPENOLT_PPROF_PORT=${OPENOLT_PPROF_PORT:-$((60 + DELTA))61}
Matteo Scandolo65c35192020-05-13 10:41:21 -0700433 OFAGENT_PPROF_PORT=${OFAGENT_PPROF_PORT:-$((60 + DELTA))62}
Test User01ed0642019-07-03 20:17:06 +0000434else
David Bainbridged18f4942020-04-14 16:46:13 -0700435 VALUES="$(echo "$HAVE" | sed -e 's/\s//g' | cut -d= -f2)"
436 ONOS_API_PORT=${ONOS_API_PORT:-$(echo "$VALUES" | cut -d, -f1)}
437 ONOS_SSH_PORT=${ONOS_SSH_PORT:-$(echo "$VALUES" | cut -d, -f2)}
438 VOLTHA_API_PORT=${VOLTHA_API_PORT:-$(echo "$VALUES" | cut -d, -f3)}
439 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$(echo "$VALUES" | cut -d, -f4)}
440 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$(echo "$VALUES" | cut -d, -f5)}
441 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(echo "$VALUES" | cut -d, -f6)}
Matteo Scandoloefee0432020-05-05 13:56:20 -0700442 VOLTHA_PPROF_PORT=${VOLTHA_PPROF_PORT:-$(echo "$VALUES" | cut -d, -f7)}
443 OPENOLT_PPROF_PORT=${OPENOLT_PPROF_PORT:-$(echo "$VALUES" | cut -d, -f8)}
Matteo Scandolo65c35192020-05-13 10:41:21 -0700444 OFAGENT_PPROF_PORT=${OFAGENT_PPROF_PORT:-$(echo "$VALUES" | cut -d, -f9)}
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800445
Matteo Scandoloefee0432020-05-05 13:56:20 -0700446 # Some ports were added after the .voltha/ports files was created.
447 # Calculate the original DELTA from the VOLTHA_SSH_PORT so that it can
448 # be used to set up newer port-forwards.
449 DELTA="$((VOLTHA_SSH_PORT/100-50))"
450
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800451 if [ -z "$VOLTHA_KAFKA_PORT" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -0700452 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$((90 + DELTA))92}
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800453 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -0700454
455 if [ -z "$VOLTHA_PPROF_PORT" ]; then
456 VOLTHA_PPROF_PORT=${VOLTHA_PPROF_PORT:-$((60 + DELTA))60}
457 fi
458 if [ -z "$OPENOLT_PPROF_PORT" ]; then
459 OPENOLT_PPROF_PORT=${OPENOLT_PPROF_PORT:-$((60 + DELTA))61}
460 fi
Matteo Scandolo65c35192020-05-13 10:41:21 -0700461 if [ -z "$OFAGENT_PPROF_PORT" ]; then
462 OFAGENT_PPROF_PORT=${OFAGENT_PPROF_PORT:-$((60 + DELTA))62}
463 fi
Test User01ed0642019-07-03 20:17:06 +0000464fi
465
David Bainbridged18f4942020-04-14 16:46:13 -0700466PORTTMP="$(mktemp -u)"
467grep -v "$NAME" .voltha/ports > "$PORTTMP"
Matteo Scandolo65c35192020-05-13 10:41:21 -0700468echo "$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 -0700469cp "$PORTTMP" .voltha/ports
470rm -f "$PORTTMP"
David Bainbridge0774b232019-08-02 06:37:19 +0000471
David Bainbridge27790d62019-08-13 22:43:19 +0000472export ONOS_API_PORT ONOS_SSH_PORT
David Bainbridge01294952019-07-30 19:33:45 +0000473
Test Userd87942b2019-07-03 07:20:24 +0000474IDX=1
David Bainbridgee87067b2019-08-12 22:00:12 +0000475CLOCK="TIME:"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000476SPIN_PARTS=
477NOT_VERIFIED=
David Bainbridgef858a022019-08-14 21:25:11 +0000478THEX=
479BUILD=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000480VERIFIED=
481HELM=
482OLD_KEY=
483BIRD=
484HIGH_VOLTAGE=
485PLUG=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000486FORWARD=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000487GO=
488DOWNLOAD=
489GEAR=
490NO_ENTRY=
491LOCK=
492
David Bainbridged18f4942020-04-14 16:46:13 -0700493if [ "$FANCY" -eq 1 ]; then
494 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 +0000495 CLOCK="\xe2\x8f\xb1"
David Bainbridgef858a022019-08-14 21:25:11 +0000496 THEX="${RED}${BOLD}\xe2\x9c\x97\x20${NORMAL}"
David Bainbridgef858a022019-08-14 21:25:11 +0000497 BUILD="${YELLOW}${BOLD}\xf0\x9f\x8f\x97${NORMAL}"
498 NOT_VERIFIED="$BUILD"
499 VERIFIED="${GREEN}${BOLD}\xe2\x9c\x93\x20${NORMAL}"
500 HELM="${BLUE}${BOLD}\xE2\x8E\x88${NORMAL}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000501 OLD_KEY="\xF0\x9F\x97\x9D"
502 BIRD="\xF0\x9F\x90\xA6"
503 HIGH_VOLTAGE="\xE2\x9A\xA1"
504 PLUG="\xF0\x9F\xa7\xa9"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000505 FORWARD="\xE2\x87\xA8"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000506 GO="\xf0\x9f\x9a\x80"
507 DOWNLOAD="\xf0\x9f\x93\xa5"
508 GEAR="\xe2\x9a\x99"
509 NO_ENTRY="\xe2\x9b\x94"
510 LOCK="\xf0\x9f\x94\x92"
511fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700512
David Bainbridge712afb82019-08-14 19:55:58 +0000513duration() {
David Bainbridged18f4942020-04-14 16:46:13 -0700514 local h m s t
515 h="$(($1 / 3600))"
516 m="$(($1 % 3600 / 60))"
517 s="$(($1 % 60))"
518 t=""
David Bainbridgee87067b2019-08-12 22:00:12 +0000519
David Bainbridged18f4942020-04-14 16:46:13 -0700520 if [ "$h" -gt 0 ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +0000521 t="$t${h}h"
522 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700523 if [ "$m" -gt 0 ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +0000524 t="$t${m}m"
525 fi
David Bainbridge712afb82019-08-14 19:55:58 +0000526 echo "$t${s}s"
527}
528
529printtime() {
David Bainbridged18f4942020-04-14 16:46:13 -0700530 local INDENT
David Bainbridge712afb82019-08-14 19:55:58 +0000531 if [ "$1" == "-" ]; then
532 INDENT=" "
533 shift
534 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700535 echo -e "$INDENT $CLOCK $(duration "$1")"
David Bainbridgee87067b2019-08-12 22:00:12 +0000536}
537
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700538bspin() {
Test Userd87942b2019-07-03 07:20:24 +0000539 IDX=1
David Bainbridged18f4942020-04-14 16:46:13 -0700540 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700541 if [ "$1" == "-" ]; then
542 INDENT=" "
543 shift
544 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700545 if [ "$FANCY" -eq 0 ]; then
546 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000547 if [ "$LINE X" == " X" ]; then
548 return
549 fi
550 echo -e "$CIVIS$INDENT$*"
551 else
552 echo -en "$CIVIS$INDENT $*"
553 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700554}
555
556sspin() {
David Bainbridged18f4942020-04-14 16:46:13 -0700557 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700558 if [ "$1" == "-" ]; then
559 INDENT=" "
560 shift
561 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700562 if [ "$FANCY" -eq 0 ]; then
563 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000564 if [ "$LINE X" == " X" ]; then
565 return
566 fi
567 echo -e "$INDENT$*"
568 else
David Bainbridged18f4942020-04-14 16:46:13 -0700569 C="$(echo "$SPIN_PARTS" | cut '-d ' -f "$IDX")"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000570 echo -en "\r$INDENT$C $*"
David Bainbridged18f4942020-04-14 16:46:13 -0700571 IDX="$((IDX + 1))"
572 if [ "$IDX" -gt 8 ]; then
David Bainbridge38dc1e82019-08-12 15:18:45 +0000573 IDX=1
574 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700575 fi
576}
577
578espin() {
David Bainbridged18f4942020-04-14 16:46:13 -0700579 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700580 if [ "$1" == "-" ]; then
581 INDENT=" "
582 shift
583 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700584 if [ "$FANCY" -eq 0 ]; then
585 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000586 if [ "$LINE X" == " X" ]; then
587 return
588 fi
589 echo -e "$INDENT$*"
590 else
591 echo -e "\r$INDENT$*$CNORM"
592 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700593}
594
David Bainbridged18f4942020-04-14 16:46:13 -0700595if [ "$1" == "get" ] && [ "$2" == "voltconfig" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000596 echo "$HOME/.volt/config-$NAME"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000597 exit
598fi
599
David Bainbridgee4d11ca2020-05-08 10:21:10 -0700600if [ $# -ne 1 ] || ! is_in "$1" "up,down,dump,clean"; then
David Bainbridgeac7f8072019-08-01 22:15:33 +0000601 >&2 echo "What wouild you like to do today:"
602 >&2 echo " up - bring up voltha"
603 >&2 echo " down - tear down voltha"
604 >&2 echo " dump - create a debug dump of running system"
605 exit 1
606fi
607
David Bainbridge4f1b5562019-08-19 04:46:52 +0000608push_onos_config() {
David Bainbridged18f4942020-04-14 16:46:13 -0700609 local TYPE MSG RESOURCE DATA CMD_ECHO CMD_OUTPUT SC_OUTPUT WAIT_START NOW
610 TYPE=$1
611 MSG=$2
612 RESOURCE=$3
613 DATA=$4
David Bainbridge4f1b5562019-08-19 04:46:52 +0000614
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800615 # Thanks to the latest version of ONOS using the return code 207 this gets a
616 # whole lot nastier. Can't thank them enough for doing this. So in order to
617 # capture the command and the output in the log file as well as capture the
618 # status code to verify it is 200 and not 207 mutltiple files and a bit of
619 # hackery must be used. Thanks again ONOS.
David Bainbridged18f4942020-04-14 16:46:13 -0700620 CMD_ECHO="$(mktemp -u)"
621 CMD_OUTPUT="$(mktemp -u)"
622 SC_OUTPUT="$(mktemp -u)"
623 WAIT_START="$(date +%s)"
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800624
David Bainbridge4f1b5562019-08-19 04:46:52 +0000625 bspin - "$MSG $GEAR"
626 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700627 NOW="$(date +%s)"
628 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700629 espin - "$THEX"
David Bainbridged18f4942020-04-14 16:46:13 -0700630 rm -f "$CMD_ECHO" "$CMD_OUTPUT" "$SC_OUTPUT"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700631 doTimeout "waiting for ONOS config push on $RESOURCE"
632 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700633 if [ "$TYPE" == "file" ]; then
634 (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 -0700635 RESULT=$?
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800636 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700637 if [ "$TYPE" == "json" ]; then
638 (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 -0700639 RESULT=$?
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800640 fi
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800641 # Dump everything to the log
David Bainbridged18f4942020-04-14 16:46:13 -0700642 cat "$CMD_ECHO" >> "$LOG"
643 test -r "$CMD_OUTPUT" && cat "$CMD_OUTPUT" >> "$LOG"
644 SC="$(cat "$SC_OUTPUT")"
645 echo "RESPONSE CODE: $SC" >> "$LOG"
646 echo "ERROR CODE: $RESULT" >> "$LOG"
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800647
648 # clean up temp files
David Bainbridged18f4942020-04-14 16:46:13 -0700649 rm -f "$CMD_ECHO" "$CMD_OUTPUT" "$SC_OUTPUT"
650 if [ "$RESULT" -eq 0 ] && [ "$SC" == "200" ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000651 break
652 fi
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800653 sleep 1
David Bainbridge4f1b5562019-08-19 04:46:52 +0000654 sspin -
655 done
David Bainbridged18f4942020-04-14 16:46:13 -0700656 espin - "$VERIFIED"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000657}
658
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800659check_onos_app_active() {
David Bainbridged18f4942020-04-14 16:46:13 -0700660 local APP_ID WAIT_START RESULT NOW
661 APP_ID=$1
662 WAIT_START="$(date +%s)"
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800663
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700664 bspin - "Checking that $APP_ID is active $CLOCK"
665 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700666 NOW="$(date +%s)"
667 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700668 espin - "$THEX"
669 doTimeout "waiting for ONOS application activation '$APP_ID'"
670 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700671 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 -0700672 break
673 fi
674 sleep 1
675 sspin -
676 done
677 sleep 5 # OSGI components take a little longer that the app to activate
David Bainbridged18f4942020-04-14 16:46:13 -0700678 espin - "$VERIFIED"
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800679}
680
David Bainbridge4f1b5562019-08-19 04:46:52 +0000681override_onos_app() {
David Bainbridged18f4942020-04-14 16:46:13 -0700682 local APP NAME WAIT_START NOW
683 APP=$1
684 NAME="$(basename "$APP" | sed -e 's/^[0-9][0-9]*-//g' -e 's/-.*$//g')"
685 WAIT_START="$(date +%s)"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700686
David Bainbridge4f1b5562019-08-19 04:46:52 +0000687 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700688 NOW="$(date +%s)"
689 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700690 espin - "$THEX"
691 doTimeout "waiting to overwrite ONOS application '$APP'"
692 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +0000693 sspin -
694 # Attempt to delete old version (if it exists)
David Bainbridged18f4942020-04-14 16:46:13 -0700695 (set -x; curl --fail -sSL --user karaf:karaf -X DELETE "http://$_ONOS_API_EP/onos/v1/applications/$NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
696 RESULT=$?
David Bainbridge4f1b5562019-08-19 04:46:52 +0000697 sspin -
David Bainbridged18f4942020-04-14 16:46:13 -0700698 if [ $RESULT -ne 0 ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000699 continue
700 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700701 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 +0000702 break
703 fi
704 sleep .2
705 done
706}
707
708activate_onos_app() {
David Bainbridged18f4942020-04-14 16:46:13 -0700709 local MSG APP WAIT_START NOW
710 MSG="$1"
711 APP=$2
712 WAIT_START="$(date +%s)"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000713
714 bspin - "$MSG $GO"
715 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700716 NOW="$(date +%s)"
717 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700718 espin - "$THEX"
719 doTimeout "waiting to activate ONOS application '$APP'"
720 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +0000721 sspin -
David Bainbridged18f4942020-04-14 16:46:13 -0700722 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 +0000723 break
724 fi
725 sleep .2
726 done
727 espin - "$VERIFIED"
728}
729
730count_pods() {
David Bainbridged18f4942020-04-14 16:46:13 -0700731 local NAMESPACE STATES LABELS CMD PODS
732 NAMESPACE=$1; shift
David Bainbridge4f1b5562019-08-19 04:46:52 +0000733 if [ "$NAMESPACE" == "all-namespaces" ]; then
734 NAMESPACE="--all-namespaces"
735 else
736 NAMESPACE="-n $NAMESPACE"
737 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700738 STATES=$1; shift
739 LABELS=$1; shift
740 CMD=("kubectl get $NAMESPACE $LABELS pod")
741 PODS=$(${CMD[*]} -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}")
David Bainbridge4f1b5562019-08-19 04:46:52 +0000742 local COUNT=0
743 local PATTERNS="$*"
744 for POD in $PODS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700745 local NAME STATE CONTAINERS TOTAL FOUND
746 NAME="$(echo "$POD" | cut -d/ -f 1)"
747 STATE="$(echo "$POD" | cut -d/ -f 2)"
748 CONTAINERS="$(echo "$POD" | cut -d/ -f 3 | sed -e 's/_/ /g')"
749 if [ "$STATES" == "*" ] || [ "$(echo "$STATES" | grep -c ":$STATE:")" -ne 0 ]; then
750 TOTAL="$(echo "$CONTAINERS" | wc -w)"
751 FOUND="$(echo "$CONTAINERS" | grep -o true | wc -l)"
752 if [ "$TOTAL" -eq "$FOUND" ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000753 for PATTERN in $PATTERNS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700754 if [[ "$NAME" =~ $PATTERN ]]; then
755 COUNT="$((COUNT + 1))"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000756 break
757 fi
758 done
759 fi
760 fi
761 done
David Bainbridge4f1b5562019-08-19 04:46:52 +0000762 echo $COUNT
763}
764
765wait_for_pods() {
David Bainbridged18f4942020-04-14 16:46:13 -0700766 local INDENT NAMESPACE EXPECT TYPE MESSAGE LABELS PATTERNS STATES HAVE ALL WAIT_START NOW
David Bainbridge4f1b5562019-08-19 04:46:52 +0000767 if [ "$1" == "-" ]; then
768 INDENT=$1; shift
769 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700770 NAMESPACE=$1; shift
771 EXPECT=$1; shift
772 TYPE=$1; shift
773 MESSAGE=$1; shift
774 LABELS=$1; shift
775 PATTERNS=("$*")
776 STATES=":Running:"
David Bainbridge99ac7a22019-08-31 02:26:43 +0000777 if [ "$TYPE" == "not" ]; then
778 STATES="*"
779 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700780 HAVE="$(count_pods "$NAMESPACE" "$STATES" "$LABELS" "${PATTERNS[@]}")"
781 ALL=$HAVE
David Bainbridge4f1b5562019-08-19 04:46:52 +0000782 if [ "$TYPE" == "only" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -0700783 ALL="$(count_pods "all-namespaces" "*" ".*")"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000784 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700785 COUNT="$((300 / 15))"
786 WAIT_START="$(date +%s)"
787 bspin "$INDENT" "$MESSAGE"
788 sspin "$INDENT"
789 if [ "$HAVE" -ne "$EXPECT" ] || [ "$ALL" -ne "$HAVE" ]; then
790 while [ "$HAVE" -ne "$EXPECT" ] || [ "$ALL" -ne "$HAVE" ]; do
791 NOW="$(date +%s)"
792 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
793 espin "$INDENT" "$THEX"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700794 doTimeout "waiting for PODs to start"
795 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700796 sspin "$INDENT"
797 COUNT="$((COUNT - 1))"
798 if [ "$COUNT" -eq 0 ]; then
799 HAVE="$(count_pods "$NAMESPACE" "$STATES" "$LABELS" "${PATTERNS[@]}")"
800 ALL="$HAVE"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000801 if [ "$TYPE" == "only" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -0700802 ALL="$(count_pods "all-namespaces" "*" ".*")"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000803 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700804 COUNT="$((300 / 15))"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000805 fi
806 sleep .15
807 done
808 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700809 espin "$INDENT" "$VERIFIED"
810 if [ "$HAVE" -ne "$EXPECT" ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000811 return 1
812 fi
813 return 0
814}
815
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800816port_forward() {
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700817 local NS=$1; shift
818 local SVC=$1; shift
819 local PORTS="$*"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800820 local TAG=$SVC-$NAME
821
David Bainbridge1d2c5842020-06-03 15:29:07 -0700822 (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 -0800823}
824
825kill_port_forward() {
David Bainbridge1d2c5842020-06-03 15:29:07 -0700826 local TAG P_IDS PARENTS KIDS UNKNOWN PP_ID PF
827
828 while [ $# -gt 0 ]; do
829 PF=$1; shift
830 TAG=
831 if [ "$PF" != "__ALL__" ]; then
832 TAG="$PF-$NAME"
833 fi
834 PARENTS=
835 KIDS=
836 UNKNOWN=
837 # shellcheck disable=SC2009
838 P_IDS="$(ps e -ww -A | grep "_TAG=$TAG" | grep -v grep | awk '{print $1}')"
839 if [ -n "$P_IDS" ]; then
840 for P_ID in $P_IDS; do
841 PP_ID="$(ps -o ppid "$P_ID" | tail -n +2)"
842 if [ -n "$PP_ID" ]; then
843 if [ "$PP_ID" -eq 1 ]; then
844 PARENTS="$PARENTS $P_ID"
845 else
846 KIDS="$KIDS $P_ID"
847 fi
David Bainbridgec6871d22019-11-13 17:10:31 +0000848 else
David Bainbridge1d2c5842020-06-03 15:29:07 -0700849 UNKNOWN="$UNKNOWN $P_ID"
David Bainbridgec6871d22019-11-13 17:10:31 +0000850 fi
David Bainbridge1d2c5842020-06-03 15:29:07 -0700851 done
852 if [ -n "$PARENTS" ]; then
853 # shellcheck disable=SC2086
854 while ps -h $PARENTS >/dev/null 2>&1; do
855 (set -x; eval "kill -9 $PARENTS" >>"$LOG" 2>&1) >>"$LOG" 2>&1
856 done
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800857 fi
David Bainbridge1d2c5842020-06-03 15:29:07 -0700858 if [ -n "$KIDS" ]; then
859 # shellcheck disable=SC2086
860 while ps -h $KIDS >/dev/null 2>&1; do
861 (set -x; eval "kill -9 $KIDS" >>"$LOG" 2>&1) >>"$LOG" 2>&1
862 done
863 fi
864 if [ -n "$UNKNOWN" ]; then
865 # shellcheck disable=SC2086
866 while ps -h $UNKNOWN >/dev/null 2>&1; do
867 (set -x; eval "kill -9 $UNKNOWN" >>"$LOG" 2>&1) >>"$LOG" 2>&1
868 done
869 fi
870 fi
871 done
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800872}
873
David Bainbridgecf546362020-04-21 23:18:50 -0700874resolve_chart_version() {
875 [ "$2" != "latest" ] && echo "$2" && return
876 helm inspect chart "$1" | grep "^version:" | awk '{print $2}'
877}
878
Jonathan Hart6a91e6c2020-04-16 14:28:33 -0700879# Compares two semver-formatted version strings (e.g. 2.4.3)
880# Returns 0 if $1 == $2, returns 1 if $1 > $2 and returns 2 if $1 < $2
881compare_versions() {
882 [ "$1" == "$2" ] && return 0
Jonathan Hart6a91e6c2020-04-16 14:28:33 -0700883 local lowest
884 lowest=$(echo -e "$1\n$2" | sort -V | head -1)
885 [ "$lowest" == "$1" ] && return 2
886 return 1
887}
888
David Bainbridgeac7f8072019-08-01 22:15:33 +0000889if [ "$1" == "down" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000890 echo "Tearing down voltha cluster $NAME"
891 LOG="down-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -0700892 date -u +"%Y%m%dT%H%M%SZ" >"$LOG"
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700893 if is_in "$WITH_ONOS" "yes,legacy,classic"; then
David Bainbridge696bc632020-04-05 21:49:37 -0700894 bspin "Remove port-forwards: onos-ui-$NAME"
895 kill_port_forward onos-ui
896 sspin "Remove port-forwards: onos-ssh-$NAME$CEOL"
897 kill_port_forward onos-ssh
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700898 bspin "Remove port-forwards: onos-onos-classic-hs-$NAME$CEOL"
899 kill_port_forward onos-onos-classic-hs
David Bainbridge696bc632020-04-05 21:49:37 -0700900 fi
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800901 sspin "Remove port-forwards: voltha-api-$NAME$CEOL"
David Bainbridge1d2c5842020-06-03 15:29:07 -0700902 kill_port_forward voltha-api voltha-voltha-api
David Bainbridgec7220622020-05-28 12:31:47 -0700903 if is_in "$WITH_ETCD" "yes,external"; then
904 sspin "Remove port-forwards: etcd-$NAME$CEOL"
905 kill_port_forward "etcd"
David Bainbridge696bc632020-04-05 21:49:37 -0700906 fi
David Bainbridgec7220622020-05-28 12:31:47 -0700907 if is_in "$WITH_KAFKA" "yes,external"; then
908 sspin "Remove port-forwards: kafka-$NAME$CEOL"
909 kill_port_forward "kafka"
David Bainbridge696bc632020-04-05 21:49:37 -0700910 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -0700911
912 if [ "$WITH_PPROF" == "yes" ]; then
David Bainbridgec7220622020-05-28 12:31:47 -0700913 sspin "Remove port-forwards: *-profiler$CEOL"
David Bainbridge1d2c5842020-06-03 15:29:07 -0700914 kill_port_forward voltha-rw-core-profiler voltha-voltha-rw-core-profiler
915 kill_port_forward voltha-of-agent-profiler voltha-voltha-of-agent-profiler
David Bainbridgec7220622020-05-28 12:31:47 -0700916 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
David Bainbridge1d2c5842020-06-03 15:29:07 -0700917 kill_port_forward adapter-open-olt-profiler open-olt-adapter-open-olt-profiler
David Bainbridgec7220622020-05-28 12:31:47 -0700918 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -0700919 fi
920
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800921 espin "$VERIFIED Remove port-forwards$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -0700922 if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridgeac7f8072019-08-01 22:15:33 +0000923 if [ -x ./bin/kind ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000924 bspin "Delete Kubernetes Kind Cluster"
David Bainbridged18f4942020-04-14 16:46:13 -0700925 (set -x; ./bin/kind delete cluster --name "voltha-$NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
926 espin "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000927 else
David Bainbridge0774b232019-08-02 06:37:19 +0000928 espin "$NO_ENTRY Delete Kubernetes Kind Cluster: kind command not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000929 fi
930 else
David Bainbridge309099c2020-05-05 08:47:29 -0700931 if [ "$CONFIG_SADIS" == "external" ]; then
932 bspin "Remove configmap for BBSIM SADIS server"
933 (set -x; kubectl -n "$BBSIM_NS" delete --ignore-not-found configmap kube-config >>"$LOG" 2>&1) >>"$LOG" 2>&1
934 espin "$VERIFIED"
935 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700936 EXISTS="$(helm list -q)"
David Bainbridge76afd812020-04-06 09:53:52 -0700937 EXPECT="voltha"
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700938 if is_in "$WITH_ONOS" "yes,legacy,classic"; then
David Bainbridge696bc632020-04-05 21:49:37 -0700939 EXPECT+=" onos"
940 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700941 if [ "$WITH_RADIUS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700942 EXPECT+=" radius"
943 fi
David Bainbridge309099c2020-05-05 08:47:29 -0700944 if [ "$CONFIG_SADIS" == "external" ]; then
945 EXPECT+=" bbsim-sadis-server"
946 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700947 if [ "$WITH_BBSIM" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700948 EXPECT+=" bbsim"
949 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700950 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700951 EXPECT+=" open-olt open-onu"
952 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700953 if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700954 EXPECT+=" sim"
955 fi
David Bainbridgec7220622020-05-28 12:31:47 -0700956 if is_in "$WITH_ETCD" "yes,external"; then
957 EXPECT+=" etcd"
David Bainbridge76afd812020-04-06 09:53:52 -0700958 fi
David Bainbridgec7220622020-05-28 12:31:47 -0700959 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -0700960 EXPECT+=" kafka"
961 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000962 bspin "Remove Helm Deployments"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000963 for i in $EXISTS; do
David K. Bainbridge43422402020-03-06 07:41:22 -0800964 for j in $EXPECT; do
David Bainbridged18f4942020-04-14 16:46:13 -0700965 if [[ "$i" =~ $j ]]; then
David K. Bainbridge43422402020-03-06 07:41:22 -0800966 sspin "Remove Helm Deployments: $i$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -0700967 (set -x; ./bin/helm delete --no-hooks --purge "$i" >>"$LOG" 2>&1) >>"$LOG" 2>&1
David K. Bainbridge43422402020-03-06 07:41:22 -0800968 fi
969 done
uottrembb16d3982020-02-28 08:34:36 +0100970 done
David Bainbridge0774b232019-08-02 06:37:19 +0000971 espin "$VERIFIED Remove Helm Deployments$CEOL"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000972 if [ "$WAIT_ON_DOWN" == "yes" ]; then
Matteo Scandoloe93c9eb2020-06-03 12:08:51 -0700973 PODS="voltha-ofagent.* voltha-rw-core.*"
David Bainbridge76afd812020-04-06 09:53:52 -0700974 INFRA_PODS=
975 ADAPT_PODS=
976 SIM_PODS=
David Bainbridged18f4942020-04-14 16:46:13 -0700977 if [ "$WITH_RADIUS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700978 PODS+=" radius.*"
979 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700980 if [ "$WITH_BBSIM" == "yes" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700981 SIM_PODS+=" bbsim.*"
David Bainbridge696bc632020-04-05 21:49:37 -0700982 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700983 if [ "$WITH_OPEN_ADAPTERS" ] || [ "$WITH_SIM_ADAPTERS" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700984 ADAPT_PODS+=" adapter-*"
David Bainbridge696bc632020-04-05 21:49:37 -0700985 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700986 if is_in "$WITH_ONOS" "yes,legacy,classic"; then
David Bainbridge76afd812020-04-06 09:53:52 -0700987 INFRA_PODS+=" onos-.*"
988 fi
David Bainbridgec7220622020-05-28 12:31:47 -0700989 if is_in "$WITH_ETCD" "yes,external"; then
990 INFRA_PODS+=" etcd.*"
David Bainbridge76afd812020-04-06 09:53:52 -0700991 fi
David Bainbridgec7220622020-05-28 12:31:47 -0700992 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -0700993 INFRA_PODS+=" kafka.*"
994 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700995 if [ -n "$SIM_PODS" ]; then
996 wait_for_pods "$BBSIM_NS" 0 "not" "Waiting for BBSIM PODs to terminate" "$BBSIM_LABEL" "$SIM_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -0700997 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700998 if [ -n "$INFRA_PODS" ]; then
999 wait_for_pods "$INFRA_NS" 0 "not" "Waiting for infrastructure PODs to terminate" "$NO_LABEL" "$INFRA_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -07001000 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001001 if [ -n "$ADAPT_PODS" ]; then
1002 wait_for_pods "$ADAPTER_NS" 0 "not" "Waiting for adapter PODs to terminate" "$NO_LABEL" "$ADAPT_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -07001003 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001004 wait_for_pods "$VOLTHA_NS" 0 "not" "Waiting for VOLTHA PODs to terminate" "$NO_LABEL" "$PODS"
David Bainbridge4f1b5562019-08-19 04:46:52 +00001005 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +00001006 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001007 exit
David Bainbridgeac7f8072019-08-01 22:15:33 +00001008fi
1009
1010if [ "$1" == "dump" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001011 LOG="dump-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -07001012 TS="$(date -u +"%Y%m%dT%H%M%SZ")"
1013 if [ -n "$DUMP_FROM" ]; then
1014 TS=${DUMP_FROM//[:-]}
David Bainbridge76514a02019-10-08 01:50:35 +00001015 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001016 WORK="$(mktemp -u -d)"
David Bainbridge0774b232019-08-02 06:37:19 +00001017 DATA=$WORK/voltha-debug-dump-$NAME-$TS
David Bainbridged18f4942020-04-14 16:46:13 -07001018 mkdir -p "$DATA"
1019 echo "$TS" > "$LOG"
David Bainbridge0774b232019-08-02 06:37:19 +00001020 echo -e "Capturing debug dump to voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001021 bspin - "Copy install log"
David Bainbridged18f4942020-04-14 16:46:13 -07001022 if [ -f "install-$NAME.log" ]; then
1023 (set -x; cp "install-$NAME.log" "$DATA/install-$NAME.log") >>"$LOG" 2>&1
1024 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001025 else
David Bainbridge0774b232019-08-02 06:37:19 +00001026 espin - "$NO_ENTRY Copy install log: install-$NAME.log not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001027 fi
1028 bspin - "Dumping Kubernetes PODs"
David Bainbridged18f4942020-04-14 16:46:13 -07001029 (set -x; kubectl get --all-namespaces pods >> "$DATA/all-pods.txt" 2>&1) >>"$LOG" 2>&1
1030 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001031 bspin - "Dumping Kubernetes SERVICEs"
David Bainbridged18f4942020-04-14 16:46:13 -07001032 (set -x; kubectl get --all-namespaces svc >> "$DATA/all-services.txt" 2>&1) >>"$LOG" 2>&1
1033 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001034 bspin - "Dumping Kubernetes EVENTs"
David Bainbridged18f4942020-04-14 16:46:13 -07001035 (set -x; kubectl get --all-namespaces events >> "$DATA/all-events.txt" 2>&1) >>"$LOG" 2>&1
1036 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001037 bspin - "Dumping VOLTHA POD details"
David Bainbridged18f4942020-04-14 16:46:13 -07001038 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 +00001039 SINCE=
David Bainbridged18f4942020-04-14 16:46:13 -07001040 if [ -n "$DUMP_FROM" ]; then
David Bainbridgecfd7ca12019-10-06 03:31:41 +00001041 SINCE="--since-time=$DUMP_FROM"
1042 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +00001043 for POD in $PODS; do
David Bainbridged18f4942020-04-14 16:46:13 -07001044 NS="$(echo "$POD" | cut -d: -f1)"
1045 POD="$(echo "$POD" | cut -d: -f2)"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001046 sspin - "Dumping VOLTHA POD details: $POD$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -07001047 mkdir -p "$DATA/$POD"
1048 (set -x; kubectl describe -n "$NS" "$POD" >> "$DATA/$POD/describe.txt" 2>&1) >>"$LOG" 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +00001049 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridged18f4942020-04-14 16:46:13 -07001050 (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 +00001051 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridged18f4942020-04-14 16:46:13 -07001052 (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 +00001053 sspin - "Dumping VOLTHA POD details: $POD"
1054 done
1055 espin - "$VERIFIED Dumping VOLTHA POD details$CEOL"
1056 bspin - "Dumping ETCD"
David Bainbridged18f4942020-04-14 16:46:13 -07001057 if [ -n "$(command -v etcdctl)" ]; then
1058 (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
1059 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001060 else
1061 espin - "$NO_ENTRY Dumping ETCD: etcdctl command not available"
1062 fi
David Bainbridge0774b232019-08-02 06:37:19 +00001063 bspin - "Creating compressed TAR: voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridged18f4942020-04-14 16:46:13 -07001064 (set -x; tar -C "$WORK" -zcf "voltha-debug-dump-$NAME-$TS.tgz" "./voltha-debug-dump-$NAME-$TS") >>"$LOG" 2>&1
1065 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001066 bspin - "Cleanup"
David Bainbridged18f4942020-04-14 16:46:13 -07001067 (set -x; rm -rf "$WORK") >>"$LOG" 2>&1
1068 espin - "$VERIFIED"
1069 bspin - "$(ls -l "voltha-debug-dump-$NAME-$TS.tgz")"
1070 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001071 exit
1072fi
1073
David Bainbridge0774b232019-08-02 06:37:19 +00001074LOG="install-$NAME.log"
David Bainbridge1d2c5842020-06-03 15:29:07 -07001075PFLOG="port-forward-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -07001076date > "$LOG"
1077echo "PORTS=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT" >> "$LOG"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001078
1079# Output install options to log
David Bainbridged18f4942020-04-14 16:46:13 -07001080echo "OPTIONS" >> "$LOG"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001081for O in $ALL_OPTIONS; do
David Bainbridged18f4942020-04-14 16:46:13 -07001082 VAL="$(eval echo "\$$O")"
1083 if [ -n "$VAL" ]; then
1084 printf " %-30s = %s\n" "$O" "$VAL" >> "$LOG"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001085 fi
1086done
1087
David Bainbridgee4d11ca2020-05-08 10:21:10 -07001088# Force remove any existing k8s port-forward processes. This will
1089# remove them for all kind clusters.
David Bainbridgee4d11ca2020-05-08 10:21:10 -07001090if [ "$1" == "clean" ]; then
1091 kill_port_forward __ALL__
1092 exit
1093fi
1094
David Bainbridgefad50732020-05-01 17:00:12 -07001095helm_values() {
1096 local NAMESPACE=$1; shift
1097 local INAME=$1; shift
1098 local CHART=$1; shift
1099 local CHART_VERSION=$1; shift
1100
1101 if [ "$CHART_VERSION X" != " X" ] && [ "$CHART_VERSION" != "latest" ]; then
1102 CHART_VERSION="--version $CHART_VERSION"
1103 else
1104 CHART_VERSION=
1105 fi
1106
1107 local CHART_ARGS=
1108 if [ -r "${INAME}-values.yaml" ]; then
1109 CHART_ARGS="-f ${INAME}-values.yaml"
1110 fi
1111
1112 if [ "$HELM_USE_UPGRADE" == "yes" ]; then
1113 _HELM_COMMAND="upgrade --install"
1114 _HELM_ARGS="xxxdryrunxxx"
1115 else
1116 _HELM_COMMAND="install"
1117 _HELM_ARGS="--name xxxdryrunxxx"
1118 fi
1119 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")
1120 ${CMD[*]} 2>/dev/null | awk 'PRINT==1 {print}; /^USER-SUPPLIED VALUES:/ {PRINT = 1}; /^$/ {PRINT = 0}'
1121}
1122
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001123helm_install() {
David Bainbridgec7220622020-05-28 12:31:47 -07001124 local INDENT NOW VALUES_FILE PPROF_ARG
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001125 if [ "$1" == "-" ]; then
1126 INDENT=$1; shift
1127 fi
1128 local NAMESPACE=$1; shift
David Bainbridge0774b232019-08-02 06:37:19 +00001129 local INAME=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001130 local CHART=$1; shift
David Bainbridge90fd8e32019-08-21 23:32:47 +00001131 local CHART_VERSION=$1; shift
David Bainbridgec7220622020-05-28 12:31:47 -07001132 local FILTER=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001133 local MESSAGE=$*
1134
David Bainbridged18f4942020-04-14 16:46:13 -07001135 if [ "$CHART_VERSION X" != " X" ] && [ "$CHART_VERSION" != "latest" ]; then
David Bainbridge90fd8e32019-08-21 23:32:47 +00001136 CHART_VERSION="--version $CHART_VERSION"
1137 else
1138 CHART_VERSION=
1139 fi
1140
David Bainbridge99ac7a22019-08-31 02:26:43 +00001141 local CHART_ARGS=
1142 if [ -r "${INAME}-values.yaml" ]; then
1143 CHART_ARGS="-f ${INAME}-values.yaml"
1144 fi
1145
David Bainbridged18f4942020-04-14 16:46:13 -07001146 local WAIT_START CMD
1147 WAIT_START="$(date +%s)"
1148 COUNT="$((300 / 15))"
1149 bspin "$INDENT" "$MESSAGE"
1150 if [ "$HELM_USE_UPGRADE" == "yes" ]; then
David Bainbridge7f8bf992020-04-08 21:53:22 -07001151 _HELM_COMMAND="upgrade --install"
1152 _HELM_ARGS="$INAME"
1153 else
1154 _HELM_COMMAND="install"
1155 _HELM_ARGS="--name $INAME"
1156 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001157
1158 VALUES_FILE="$(mktemp)"
1159 if [ "$FILTER" == "-" ]; then
1160 cp "$NAME-values.yaml" "$VALUES_FILE"
David Bainbridgea965ca22020-06-09 17:45:04 -07001161 elif [ "${FILTER:0:1}" == "+" ]; then
1162 cp "$NAME-values.yaml" "$VALUES_FILE"
1163 yq r - "${FILTER:1}" <"$NAME-values.yaml" >>"$VALUES_FILE"
David Bainbridge33e56c72020-06-11 11:39:56 -07001164 cat "$VALUES_FILE" >>"$LOG"
David Bainbridgec7220622020-05-28 12:31:47 -07001165 else
David Bainbridge43f2df52020-06-02 15:30:54 -07001166 yq r - "$FILTER" <"$NAME-values.yaml" >"$VALUES_FILE"
David Bainbridgec7220622020-05-28 12:31:47 -07001167 fi
1168 if [ "$WITH_PPROF" == "yes" ]; then
1169 PPROF_ARG="--set profiler.enabled=true"
1170 fi
1171 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 -07001172 (set -x; ${CMD[*]} >>"$LOG" 2>&1) >>"$LOG" 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001173 SUCCESS=$?
David Bainbridged18f4942020-04-14 16:46:13 -07001174 while [ "$SUCCESS" -ne 0 ]; do
1175 NOW="$(date +%s)"
1176 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -07001177 espin "$THEX"
David Bainbridgec7220622020-05-28 12:31:47 -07001178 rm -f "$VALUES_FILE"
David Bainbridge52e6e9d2020-03-23 13:48:27 -07001179 doTimeout "waiting for helm install $CHART"
1180 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001181 sspin "$INDENT"
1182 COUNT="$((COUNT - 1))"
1183 if [ "$COUNT" -eq 0 ]; then
1184 if [ "$HELM_USE_UPGRADE" == "no" ]; then
1185 (set -x; helm delete --purge "$INAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
David Bainbridge7f8bf992020-04-08 21:53:22 -07001186 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001187 (set -x; ${CMD[*]} >>"$LOG" 2>&1) >>"$LOG" 2>&1
Andy Baviere22ff252019-12-19 11:40:31 -07001188 SUCCESS=$?
David Bainbridged18f4942020-04-14 16:46:13 -07001189 COUNT="$((300 / 15))"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001190 fi
1191 sleep .15
1192 done
David Bainbridgec7220622020-05-28 12:31:47 -07001193 rm -f "$VALUES_FILE"
David Bainbridged18f4942020-04-14 16:46:13 -07001194 espin "$INDENT" "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001195}
1196
David Bainbridged18f4942020-04-14 16:46:13 -07001197echo "INSTALL TYPE: $TYPE" >> "$LOG"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001198
1199bspin "Verify GOPATH"
David Bainbridged18f4942020-04-14 16:46:13 -07001200GOPATH="$(pwd)"; export GOPATH
1201mkdir -p "$GOPATH/bin"
1202espin "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001203
David Bainbridged18f4942020-04-14 16:46:13 -07001204STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001205if [ "$INSTALL_KUBECTL" == "no" ]; then
1206 bspin "Skip kubectl install"
1207 espin $NO_ENTRY
Test Userc13bdc92019-07-03 20:57:49 +00001208else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001209 bspin "Verify kubectl $HELM"
David Bainbridged18f4942020-04-14 16:46:13 -07001210 if [ -x "$GOPATH/bin/kubectl" ]; then
1211 espin "$VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001212 else
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001213 ERR_OUT="$(mktemp)"
David Bainbridged18f4942020-04-14 16:46:13 -07001214 espin "$NOT_VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001215 bspin - "Download and install Kubernetes/kubectl $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001216 (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
1217 RESULT=$?
1218 if [ "$RESULT" -ne 0 ]; then
1219 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001220 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download kubectl: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001221 cat "$ERR_OUT" >> "$LOG"
Zack Williamsded60cb2020-04-13 10:02:20 -07001222 rm -rf "$ERR_OUT" "$GOPATH/bin/kubectl"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001223 exit 1
1224 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001225 (set -x; chmod 755 "$GOPATH/bin/kubectl" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1226 espin - "$VERIFIED"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001227 rm -rf "$ERR_OUT"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001228 fi
Test Userc13bdc92019-07-03 20:57:49 +00001229fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001230if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001231 NOW="$(date +%s)"
1232 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001233fi
Test Userc13bdc92019-07-03 20:57:49 +00001234
David Bainbridged18f4942020-04-14 16:46:13 -07001235STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001236if [ "$DEPLOY_K8S" == "no" ]; then
1237 bspin "Skip Kubernetes/Kind Deployment"
1238 espin $NO_ENTRY
1239else
Test Userba1e7e72019-07-10 22:27:54 +00001240 bspin "Verify Kubernetes/Kind $HELM"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001241 IS_INSTALLED=0
1242 OP_TYPE="install"
David Bainbridged18f4942020-04-14 16:46:13 -07001243 if [ -x "$GOPATH/bin/kind" ]; then
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001244 OP_TYPE="upgrade"
David Bainbridged18f4942020-04-14 16:46:13 -07001245 if [ "$("$GOPATH/bin/kind" --version | grep -c "$KIND_VERSION")" -eq 1 ]; then
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001246 IS_INSTALLED=1
David Bainbridged18f4942020-04-14 16:46:13 -07001247 espin "$VERIFIED"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001248 fi
1249 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001250 if [ "$IS_INSTALLED" -eq 0 ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001251 ERR_OUT="$(mktemp)"
David Bainbridged18f4942020-04-14 16:46:13 -07001252 espin "$NOT_VERIFIED"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001253 bspin - "Download and $OP_TYPE Kubernetes/kind $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001254 (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
1255 RESULT=$?
1256 if [ $RESULT -ne 0 ]; then
1257 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001258 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download kind: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001259 cat "$ERR_OUT" >> "$LOG"
Zack Williamsded60cb2020-04-13 10:02:20 -07001260 rm -rf "$ERR_OUT" "$GOPATH/bin/kind"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001261 exit 1
1262 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001263 (set -x; chmod 755 "$GOPATH/bin/kind" >>"$LOG" 2>&1) >>"$LOG" 2>&1
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001264 rm -rf "$ERR_OUT"
David Bainbridged18f4942020-04-14 16:46:13 -07001265 espin - "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001266 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001267fi
1268
David Bainbridgee87067b2019-08-12 22:00:12 +00001269if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001270 NOW="$(date +%s)"
1271 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001272fi
1273
David Bainbridged18f4942020-04-14 16:46:13 -07001274STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001275if [ "$INSTALL_HELM" == "no" ]; then
1276 bspin "Skip Helm Install"
1277 espin $NO_ENTRY
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001278else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001279 bspin "Verify Helm $HELM"
David Bainbridgea34993d2020-04-01 09:15:42 -07001280 HELM_UPGRADE=0
1281 HELM_UPGRADE_DESC="install"
David Bainbridged18f4942020-04-14 16:46:13 -07001282 if [ -x "$GOPATH/bin/helm" ]; then
1283 HAVE_VER="$("$GOPATH/bin/helm" version -c --template '{{.Client.SemVer}}')"
1284 HELM_UP_DOWN="$(echo -e "$HAVE_VER\n$HELM_VERSION" | sort -V | head -1)"
1285 if [ "$HAVE_VER" != "$HELM_VERSION" ]; then
1286 if [ "$HELM_UP_DOWN" == "$HELM_VERSION" ]; then
David Bainbridgea34993d2020-04-01 09:15:42 -07001287 HELM_UPGRADE_DESC="downgrade"
1288 else
1289 HELM_UPGRADE_DESC="upgrade"
1290 fi
1291 HELM_UPGRADE=1
1292 else
David Bainbridged18f4942020-04-14 16:46:13 -07001293 espin "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001294 fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001295 else
David Bainbridgea34993d2020-04-01 09:15:42 -07001296 HELM_UPGRADE=1
1297 fi
1298
David Bainbridged18f4942020-04-14 16:46:13 -07001299 if [ "$HELM_UPGRADE" -ne 0 ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001300 ERR_OUT="$(mktemp)"
1301 INSTALL_HELM_BIN=$(mktemp)
David Bainbridged18f4942020-04-14 16:46:13 -07001302 espin "$NOT_VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001303 bspin - "Download and $HELM_UPGRADE_DESC Helm $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001304 (set -x; curl -o "$INSTALL_HELM_BIN" --fail -sSL https://git.io/get_helm.sh >>"$LOG" 2>"$ERR_OUT") >>"$LOG" 2>&1
1305 RESULT=$?
1306 if [ $RESULT -ne 0 ]; then
1307 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001308 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download helm installer: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001309 cat "$ERR_OUT" >> "$LOG"
1310 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT" "$GOPATH/bin/helm" "$GOPATH/bin/tiller"
1311 exit 1
1312 fi
1313 rm -rf "$ERR_OUT"
1314 chmod +x "$INSTALL_HELM_BIN"
1315 (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
1316 RESULT=$?
1317 if [ $RESULT -ne 0 ]; then
1318 espin - "$THEX"
1319 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to install helm, see install log for details${NORMAL}"
1320 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT" "$GOPATH/bin/helm" "$GOPATH/bin/tiller"
1321 exit 1
1322 fi
1323 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT"
David Bainbridged18f4942020-04-14 16:46:13 -07001324 espin - "$VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001325 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001326fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001327if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001328 NOW="$(date +%s)"
1329 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001330fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001331
David Bainbridged18f4942020-04-14 16:46:13 -07001332STIME="$(date +%s)"
Test Userb5712372019-07-03 21:52:17 +00001333bspin "Verify voltctl $HIGH_VOLTAGE"
David Bainbridged2811972019-12-14 01:14:09 +00001334VOK=0
1335VMESSAGE="install"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001336ERR_OUT=$(mktemp)
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001337export VC_VERSION="$VOLTCTL_VERSION"
1338if [ "$VC_VERSION" == "latest" ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001339 set -o pipefail # TODO: would be nice to run all in pipefail mode
1340 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')"
1341 RESULT=$?
1342 set +o pipefail
1343 if [ "$RESULT" -ne 0 ]; then
1344 espin - "$THEX"
1345 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to determine released version of voltctl: $(cat "$ERR_OUT")${NORMAL}"
1346 rm -rf "$ERR_OUT" "$GOPATH/bin/voltctl"
1347 exit 1
1348 fi
1349 export VC_VERSION
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001350fi
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001351
David Bainbridged18f4942020-04-14 16:46:13 -07001352if [ -x "$GOPATH/bin/voltctl" ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001353 VHAVE="$("$GOPATH/bin/voltctl" version --clientonly -o json 2>/dev/null | jq -r .version)"
David Bainbridged18f4942020-04-14 16:46:13 -07001354 RESULT=$?
1355 if [ $RESULT -eq 0 ] && [ "$VHAVE" == "$VC_VERSION" ]; then
David Bainbridged2811972019-12-14 01:14:09 +00001356 VOK=1
David Bainbridged18f4942020-04-14 16:46:13 -07001357 espin "$VERIFIED"
David Bainbridge1ba64f12019-12-18 00:40:13 +00001358 else
David Bainbridged18f4942020-04-14 16:46:13 -07001359 VCHECK="$(echo -e "$VHAVE\n$VC_VERSION" | sort -V | head -1)"
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001360 if [ "$VCHECK" == "$VHAVE" ]; then
1361 VMESSAGE="upgrade"
1362 else
1363 VMESSAGE="downgrade"
1364 fi
David Bainbridged2811972019-12-14 01:14:09 +00001365 fi
1366fi
1367
David Bainbridged18f4942020-04-14 16:46:13 -07001368if [ "$VOK" -eq 0 ]; then
1369 espin "$NOT_VERIFIED"
David Bainbridged2811972019-12-14 01:14:09 +00001370 bspin - "Download and $VMESSAGE voltctl $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001371 (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
1372 RESULT=$?
1373 if [ $RESULT -ne 0 ]; then
1374 espin - "$THEX"
1375 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download voltctl (version $VC_VERSION): $(cat "$ERR_OUT")${NORMAL}"
1376 rm -rf "$ERR_OUT" "$GOPATH/bin/voltctl"
1377 exit 1
1378 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001379 (set -x; chmod 755 "$GOPATH/bin/voltctl" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1380 espin - "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001381fi
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001382rm -rf "$ERR_OUT"
David Bainbridgee87067b2019-08-12 22:00:12 +00001383if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001384 NOW="$(date +%s)"
1385 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001386fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001387
1388bspin "Verify command PATH"
Test Userba1e7e72019-07-10 22:27:54 +00001389export PATH=$GOPATH/bin:$PATH
David Bainbridged18f4942020-04-14 16:46:13 -07001390espin "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001391
David Bainbridged18f4942020-04-14 16:46:13 -07001392STIME="$(date +%s)"
Test Userba1e7e72019-07-10 22:27:54 +00001393if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001394 HAVE="$(kind get clusters | grep -c "voltha-$NAME")"
Test Userba1e7e72019-07-10 22:27:54 +00001395 bspin "Verify Kubernetes/Kind Cluster"
1396 sspin
David Bainbridged18f4942020-04-14 16:46:13 -07001397 if [ "$HAVE" -eq 0 ]; then
1398 espin "$NOT_VERIFIED"
David Bainbridge491b1bd2019-07-11 17:53:11 +00001399 bspin - "Verify cluster configuration"
David Bainbridged18f4942020-04-14 16:46:13 -07001400 if [ ! -r "./$NAME-cluster.cfg" ]; then
1401 espin - "$NOT_VERIFIED"
David K. Bainbridge43422402020-03-06 07:41:22 -08001402 bspin - "Download cluster configuration: $TYPE-cluster.cfg to $NAME-cluster.cfg $DOWNLOAD"
David Bainbridged18f4942020-04-14 16:46:13 -07001403 ERR_OUT="$(mktemp)"
serkant.uluderya4d315132020-04-15 16:25:54 -07001404 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 -07001405 espin - "$THEX"
1406 echo -e "${RED}${BOLD}${ERROR}ERROR: $NAME-cluster.cfg${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1407 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
1408 rm -rf "$ERR_OUT" "./$NAME-cluster.cfg"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001409 exit 1
1410 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001411 rm -rf "$ERR_OUT"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001412 else
David Bainbridged18f4942020-04-14 16:46:13 -07001413 espin - "$VERIFIED"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001414 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001415 kind create cluster --name "voltha-$NAME" --config "$NAME-cluster.cfg"
David Bainbridge491b1bd2019-07-11 17:53:11 +00001416 else
David Bainbridged18f4942020-04-14 16:46:13 -07001417 espin "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001418 fi
1419
David Bainbridge1d2c5842020-06-03 15:29:07 -07001420 export KUBECONFIG="./kube-config-$NAME"
1421 kind get kubeconfig --name="voltha-$NAME" >"$KUBECONFIG"
1422 # For backward compatibility also copy to old location
David Bainbridgedee3f022020-06-05 07:45:13 -07001423 mkdir -p "$HOME/.kube"
David Bainbridge7b3c1632020-06-05 10:04:14 -07001424 cp "$KUBECONFIG" "$HOME/.kube/kind-config-voltha-$NAME"
David Bainbridge1d2c5842020-06-03 15:29:07 -07001425
Test Userba1e7e72019-07-10 22:27:54 +00001426 P="coredns-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001427 etcd-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +00001428 kindnet-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001429 kube-apiserver-voltha-$NAME-control-plane \
1430 kube-controller-manager-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +00001431 kube-proxy-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001432 kube-scheduler-voltha-$NAME-control-plane"
Test Userba1e7e72019-07-10 22:27:54 +00001433
David Bainbridged18f4942020-04-14 16:46:13 -07001434 EXPECT="$(test "$TYPE" == "minimal" && echo "12" || echo "14")"
1435 wait_for_pods - "kube-system" "$EXPECT" "includes" "Waiting for system PODs to start" "$NO_LABEL" "$P"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001436fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001437if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001438 NOW="$(date +%s)"
1439 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001440fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001441
David Bainbridgee4d11ca2020-05-08 10:21:10 -07001442if [ "$SCHEDULE_ON_CONTROL_NODES" == "yes" ]; then
1443 bspin "Untaint control nodes to allow scheduling $LOCK"
1444 for MNODE in $(kubectl get node --selector='node-role.kubernetes.io/master' -o json | jq -r '.items[].metadata.name'); do
1445 (set -x; kubectl taint node "$MNODE" node-role.kubernetes.io/master:NoSchedule- >>"$LOG" 2>&1) >>"$LOG" 2>&1
1446 sspin
1447 done
1448 espin "$VERIFIED"
1449fi
1450
David Bainbridged18f4942020-04-14 16:46:13 -07001451STIME="$(date +%s)"
1452COUNT="$(count_pods "kube-system" ":Running:" "$NO_LABEL" "tiller-deploy-.*")"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001453bspin "Verify Helm"
David Bainbridged18f4942020-04-14 16:46:13 -07001454if [ "$COUNT" -ne 1 ]; then
1455 espin "$NOT_VERIFIED"
Test Userb5712372019-07-03 21:52:17 +00001456 echo -e "Configuring Helm $GEAR"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001457 if [ "$INSTALL_HELM" == "no" ]; then
1458 bspin - "Skip Helm/Tiller Initialization"
1459 espin - $NO_ENTRY
1460 else
1461 bspin - "Initialize Helm"
David Bainbridged18f4942020-04-14 16:46:13 -07001462 (set -x; helm init --upgrade >>"$LOG" 2>&1) >>"$LOG" 2>&1
1463 espin - "$VERIFIED"
1464 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 -07001465 fi
Test Userb5712372019-07-03 21:52:17 +00001466 bspin - "Add Google Incubator repository to Helm"
David Bainbridged18f4942020-04-14 16:46:13 -07001467 (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>"$LOG" 2>&1) >>"$LOG" 2>&1
1468 espin - "$VERIFIED"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001469
Test Userba1e7e72019-07-10 22:27:54 +00001470 # HACK (sort-of) - the config for tiller is about to be patched, which will
1471 # cause the tiller pod to be recreated. This can sometimes cause a timing
1472 # issue with the "wait_for_pods" call on tiller as it may incorrectly
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001473 # identify the running/ready tiller pod that is soon to be terminated as
Test Userba1e7e72019-07-10 22:27:54 +00001474 # what it is waiting for. To avoid this issue we do a clean scale down and
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001475 # scale up of the pod so the script controlls when it should be expecting
Test Userba1e7e72019-07-10 22:27:54 +00001476 # things
David Bainbridged18f4942020-04-14 16:46:13 -07001477 (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 -07001478
Test Userb5712372019-07-03 21:52:17 +00001479 bspin - "Add Google Stable repository to Helm"
David Bainbridged18f4942020-04-14 16:46:13 -07001480 (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>"$LOG" 2>&1) >>"$LOG" 2>&1
1481 espin - "$VERIFIED"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001482 bspin - "Add ONF VOLTHA repository to Helm"
David Bainbridged18f4942020-04-14 16:46:13 -07001483 (set -x; helm repo add onf https://charts.opencord.org >>"$LOG" 2>&1) >>"$LOG" 2>&1
1484 espin - "$VERIFIED"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001485 bspin - "Add ONF ONOS repository to Helm"
1486 (set -x; helm repo add onos https://charts.onosproject.org >>"$LOG" 2>&1) >>"$LOG" 2>&1
1487 espin - "$VERIFIED"
1488 bspin - "Add ONF Atomix repository to Helm"
1489 (set -x; helm repo add atomix https://charts.atomix.io >>"$LOG" 2>&1) >>"$LOG" 2>&1
1490 espin - "$VERIFIED"
David Bainbridge309099c2020-05-05 08:47:29 -07001491 bspin - "Add Custom BBSIM SADIS Server repository to Helm"
1492 (set -x; helm repo add bbsim-sadis https://ciena.github.io/bbsim-sadis-server/charts >>"$LOG" 2>&1) >>"$LOG" 2>&1
1493 espin - "$VERIFIED"
Test Userb5712372019-07-03 21:52:17 +00001494 bspin - "Update Helm repository cache"
David Bainbridged18f4942020-04-14 16:46:13 -07001495 (set -x; helm repo update >>"$LOG" 2>&1) >>"$LOG" 2>&1
1496 espin - "$VERIFIED"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001497
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001498 # Create and k8s service account so that Helm can create pods
Test Userb5712372019-07-03 21:52:17 +00001499 bspin - "Create Tiller ServiceAccount"
David Bainbridged18f4942020-04-14 16:46:13 -07001500 (set -x; kubectl create serviceaccount --namespace kube-system tiller >>"$LOG" 2>&1) >>"$LOG" 2>&1
1501 espin - "$VERIFIED"
Test Userb5712372019-07-03 21:52:17 +00001502 bspin - "Create Tiller ClusterRoleBinding"
David Bainbridged18f4942020-04-14 16:46:13 -07001503 (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>"$LOG" 2>&1) >>"$LOG" 2>&1
1504 espin - "$VERIFIED"
Test Userb5712372019-07-03 21:52:17 +00001505 bspin - "Update Tiller Manifest"
David Bainbridged18f4942020-04-14 16:46:13 -07001506 (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 +00001507
1508 # HACK (sort-of) - part to, spin it back up
David Bainbridged18f4942020-04-14 16:46:13 -07001509 (set -x; kubectl -n kube-system scale deploy tiller-deploy --replicas=1 >>"$LOG" 2>&1) >>"$LOG" 2>&1
1510 espin - "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001511else
David Bainbridged18f4942020-04-14 16:46:13 -07001512 if [ "$(helm version -s --template '{{.Server.SemVer}}')" != "$HELM_VERSION" ]; then
1513 espin "$NOT_VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001514 bspin - "Sync Tiller server version with helm client"
David Bainbridged18f4942020-04-14 16:46:13 -07001515 (set -x; helm init --upgrade --force-upgrade --wait >>"$LOG" 2>&1) >>"$LOG" 2>&1
1516 espin - "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001517 else
David Bainbridged18f4942020-04-14 16:46:13 -07001518 espin "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001519 fi
1520
David Bainbridge46505fb2019-10-01 21:13:20 +00001521 if [ "$UPDATE_HELM_REPOS" == "yes" ]; then
1522 bspin - "Update Helm repository cache"
David Bainbridged18f4942020-04-14 16:46:13 -07001523 (set -x; helm repo update >>"$LOG" 2>&1) >>"$LOG" 2>&1
1524 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00001525 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001526fi
David Bainbridged18f4942020-04-14 16:46:13 -07001527wait_for_pods - "kube-system" 1 "includes" "Waiting for Tiller POD to start" "$NO_LABEL" "tiller-deploy-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001528if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001529 NOW="$(date +%s)"
1530 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001531fi
David Bainbridgecf546362020-04-21 23:18:50 -07001532# Resolve chart versions and log them for debug/support
1533RESOLVED_VOLTHA_CHART_VERSION=$(resolve_chart_version "$VOLTHA_CHART" "$VOLTHA_CHART_VERSION")
1534RESOLVED_VOLTHA_BBSIM_CHART_VERSION=$(resolve_chart_version "$VOLTHA_BBSIM_CHART" "$VOLTHA_BBSIM_CHART_VERSION")
1535RESOLVED_VOLTHA_ADAPTER_SIM_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_SIM_CHART" "$VOLTHA_ADAPTER_SIM_CHART_VERSION")
1536RESOLVED_VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_OPEN_OLT_CHART" "$VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION")
1537RESOLVED_VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_OPEN_ONU_CHART" "$VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION")
1538RESOLVED_ONOS_CHART_VERSION=$(resolve_chart_version "$ONOS_CHART" "$ONOS_CHART_VERSION")
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001539RESOLVED_ONOS_CLASSIC_CHART_VERSION=$(resolve_chart_version "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION")
David Bainbridgecf546362020-04-21 23:18:50 -07001540RESOLVED_KAFKA_CHART_VERSION=$(resolve_chart_version "$KAFKA_CHART" "$KAFKA_CHART_VERSION")
1541cat <<EOV >>"$LOG"
1542Resolved helm charts and versions:
1543 $VOLTHA_CHART:$RESOLVED_VOLTHA_CHART_VERSION
1544 $VOLTHA_BBSIM_CHART:$RESOLVED_VOLTHA_BBSIM_CHART_VERSION
1545 $VOLTHA_ADAPTER_SIM_CHART:$RESOLVED_VOLTHA_ADAPTER_SIM_CHART_VERSION
1546 $VOLTHA_ADAPTER_OPEN_OLT_CHART:$RESOLVED_VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION
1547 $VOLTHA_ADAPTER_OPEN_ONU_CHART:$RESOLVED_VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION
1548 $ONOS_CHART:$RESOLVED_ONOS_CHART_VERSION
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001549 $ONOS_CLASSIC_CHART:$RESOLVED_ONOS_CLASSIC_CHART_VERSION
David Bainbridgecf546362020-04-21 23:18:50 -07001550 $KAFKA_CHART:$RESOLVED_KAFKA_CHART_VERSION
1551EOV
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001552
David Bainbridged18f4942020-04-14 16:46:13 -07001553STIME="$(date +%s)"
David Bainbridge0774b232019-08-02 06:37:19 +00001554bspin "Verify Helm values file: $NAME-values.yaml"
1555if [ ! -r "./$NAME-values.yaml" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001556 espin "$NOT_VERIFIED"
David Bainbridge0774b232019-08-02 06:37:19 +00001557 bspin - "Download Helm values file: $TYPE-values.yaml to $NAME-values.yaml $DOWNLOAD"
David Bainbridged18f4942020-04-14 16:46:13 -07001558 ERR_OUT="$(mktemp)"
serkant.uluderya4d315132020-04-15 16:25:54 -07001559 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 -07001560 espin - "$THEX"
1561 echo -e "${RED}${BOLD}${ERROR}ERROR: $NAME-values.yaml${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1562 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
1563 rm -rf "$ERR_OUT" "./$NAME-values.yaml"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001564 exit 1
1565 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001566 rm -rf "$ERR_OUT"
1567 espin - "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001568else
David Bainbridged18f4942020-04-14 16:46:13 -07001569 espin "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001570fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001571if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001572 NOW="$(date +%s)"
1573 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001574fi
Test Userba1e7e72019-07-10 22:27:54 +00001575
David Bainbridged18f4942020-04-14 16:46:13 -07001576STIME="$(date +%s)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001577bspin "Verify or download chart specific values files $DOWNLOAD"
1578VALUES_FILES="monkey-values.yaml"
David Bainbridged18f4942020-04-14 16:46:13 -07001579ERR_OUT="$(mktemp)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001580for i in $VALUES_FILES; do
1581 if [ ! -r ./$i ]; then
serkant.uluderya4d315132020-04-15 16:25:54 -07001582 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 -07001583 espin "$THEX"
1584 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1585 echo "ERROR: $i - $(cat "$ERR_OUT")" >>"$LOG"
1586 rm -rf "$ERR_OUT" "./$i"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001587 exit 1
1588 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001589 rm -rf "$ERR_OUT"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001590 fi
1591done
David Bainbridged18f4942020-04-14 16:46:13 -07001592rm -rf "$ERR_OUT"
1593espin "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001594if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001595 NOW="$(date +%s)"
1596 printtime $((NOW - STIME))
David Bainbridge99ac7a22019-08-31 02:26:43 +00001597fi
1598
1599if [ "$WITH_CHAOS" == "yes" ]; then
1600 bspin "Verify or clone kube-monkey helm chart $DOWNLOAD"
1601 if [ -r ./kube-monkey ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001602 espin "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001603 else
David Bainbridged18f4942020-04-14 16:46:13 -07001604 espin "$NOT_VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001605 bspin - "GIT clone kube-monkey"
David Bainbridged18f4942020-04-14 16:46:13 -07001606 (set -x; git clone https://github.com/asobti/kube-monkey kube-monkey >>"$LOG" 2>&1) >>"$LOG" 2>&1
1607 espin - "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001608 fi
1609fi
1610
Test Userba1e7e72019-07-10 22:27:54 +00001611if [ "$JUST_K8S" == "yes" ]; then
1612 echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye."
1613 echo ""
David Bainbridged18f4942020-04-14 16:46:13 -07001614 echo "Please issue the following commands in your terminal to ensure that you" | tee -a "$LOG"
1615 echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a "$LOG"
1616 echo "tools required by VOLTHA in your command path. " | tee -a "$LOG"
1617 echo "" | tee -a "$LOG"
1618 echo -en "$BOLD"
1619 if [ "$DEPLOY_K8S" == "yes" ]; then
1620 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00001621 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001622 echo "export PATH=$GOPATH/bin:\$PATH" | tee -a "$LOG"
1623 echo -en "$NORMAL"
1624 echo "" | tee -a "$LOG"
1625 echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00001626 exit 0
1627fi
1628
David Bainbridged18f4942020-04-14 16:46:13 -07001629STIME="$(date +%s)"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001630if is_in "$WITH_ONOS" "yes,legacy,classic"; then
1631 if is_in "$WITH_ONOS" "legacy"; then
1632 bspin "Verify ONOS LEGACY installed $BIRD"
1633 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^onos\$" | wc -l)" -ne 1 ]; then
1634 espin "$NOT_VERIFIED"
David Bainbridge33e56c72020-06-11 11:39:56 -07001635 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 -07001636 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
1637 else
1638 espin "$VERIFIED"
1639 fi
1640 wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for ONOS to start" "$NO_LABEL" "onos-.*"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001641
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001642 if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
1643 bspin - "Forward ONOS API port $FORWARD"
1644 kill_port_forward onos-ui
1645 port_forward "$INFRA_NS" onos-ui "$ONOS_API_PORT:8181"
1646 espin - "$VERIFIED"
1647 bspin - "Forward ONOS SSH port $FORWARD"
1648 kill_port_forward onos-ssh
1649 port_forward "$INFRA_NS" onos-ssh "$ONOS_SSH_PORT:8101"
1650 espin - "$VERIFIED"
1651 _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT"
1652 else
1653 _ONOS_API_EP="$(get_service_ep "$INFRA_NS" onos-ui)"
1654 fi
1655 elif is_in "$WITH_ONOS" "yes,classic"; then
1656 bspin "Verify ONOS CLASSIC installed $BIRD"
1657 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^onos\$" | wc -l)" -ne 1 ]; then
1658 espin "$NOT_VERIFIED"
Matteo Scandoloe0829b52020-05-08 14:23:56 -07001659 # 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 -07001660 # values value
David Bainbridgefad50732020-05-01 17:00:12 -07001661 YAML_VALUES=$(INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set replicas=$NUM_OF_ONOS --set atomix.replicas=$NUM_OF_ATOMIX" \
1662 helm_values "$INFRA_NS" onos "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION")
1663 _ONOS_REPO="$(echo "$YAML_VALUES" | yq read - images.onos.repository)"
David Bainbridgedee3f022020-06-05 07:45:13 -07001664 if [ -z "$_ONOS_REPO" ]; then
1665 _ONOS_REPO="voltha/voltha-onos"
1666 fi
David Bainbridgefad50732020-05-01 17:00:12 -07001667 _ONOS_TAG="$(echo "$YAML_VALUES" | yq read - images.onos.tag)"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001668 if [ -z "$_ONOS_TAG" ]; then
David Bainbridgedee3f022020-06-05 07:45:13 -07001669 _ONOS_TAG="$(echo "$YAML_VALUES" | yq read - defaults.image_tag)"
1670 fi
1671 if [ -z "$_ONOS_TAG" ]; then
1672 _ONOS_TAG="master"
1673 fi
1674 _ONOS_PULL_POLICY="$(echo "$YAML_VALUES" | yq read - images.onos.pullPolicy)"
1675 if [ -z "$_ONOS_PULL_POLICY" ]; then
1676 _ONOS_PULL_POLICY="$(echo "$YAML_VALUES" | yq read - defaults.image_pullPolicy)"
1677 fi
1678 if [ -z "$_ONOS_PULL_POLICY" ]; then
1679 _ONOS_PULL_POLICY="Always"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001680 fi
David Bainbridgefad50732020-05-01 17:00:12 -07001681
Matteo Scandoloe0829b52020-05-08 14:23:56 -07001682 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 -07001683 helm_install - "$INFRA_NS" onos "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION" "+onos" "$_HELM_DESC ONOS CLASSIC"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001684 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
1685 else
1686 espin "$VERIFIED"
1687 fi
1688 wait_for_pods - "$INFRA_NS" $((NUM_OF_ONOS + NUM_OF_ATOMIX)) "includes" "Waiting for ONOS CLASSIC to start" "$NO_LABEL" "onos-.*"
1689 if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
1690 bspin - "Forward ONOS API port $FORWARD"
1691 kill_port_forward onos-onos-classic-hs
1692 port_forward "$INFRA_NS" onos-onos-classic-hs "$ONOS_API_PORT:8181" "$ONOS_SSH_PORT:8101"
1693 espin - "$VERIFIED"
1694 _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT"
1695 else
1696 _ONOS_API_EP="$(get_service_ep "$INFRA_NS" onos-onos-classic-hs)"
1697 fi
1698 elif [ "$WITH_ONOS" == "micro" ]; then
1699 bspin "Verify micro-ONOS installed $BIRD"
1700 # We should never get here
1701 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Micro ONOS not currently supported${NORMAL}"
1702 exit 1
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001703 fi
David Bainbridged31d6122019-08-13 19:37:59 +00001704 bspin - "Verify or download ONOS configuration support files $DOWNLOAD"
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001705 ONOS_FILES="olt-onos-enableExtraneousRules.json onos-aaa.json \
David Bainbridge696bc632020-04-05 21:49:37 -07001706 onos-dhcpl2relay.json onos-sadis-sample.json"
David Bainbridged18f4942020-04-14 16:46:13 -07001707 (set -x; mkdir -p ./onos-files >>"$LOG" 2>&1) >>"$LOG" 2>&1
1708 ERR_OUT="$(mktemp)"
David Bainbridge2b19e832019-08-16 02:40:53 +00001709 for i in $ONOS_FILES; do
David Bainbridged18f4942020-04-14 16:46:13 -07001710 if [ ! -r "./onos-files/$i" ]; then
serkant.uluderya4d315132020-04-15 16:25:54 -07001711 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 -07001712 espin - "$THEX"
1713 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1714 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
1715 rm -rf "$ERR_OUT" "./onos-files/$i"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001716 exit 1
1717 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001718 rm -rf "$ERR_OUT"
David Bainbridged31d6122019-08-13 19:37:59 +00001719 fi
1720 done
David Bainbridged18f4942020-04-14 16:46:13 -07001721 rm -rf "$ERR_OUT"
1722 espin - "$VERIFIED"
David Bainbridge27790d62019-08-13 22:43:19 +00001723
David Bainbridged18f4942020-04-14 16:46:13 -07001724 if [ "$INSTALL_ONOS_APPS" == "yes" ]; then
David Bainbridge27790d62019-08-13 22:43:19 +00001725 bspin - "Installing custom ONOS applications"
David Bainbridged18f4942020-04-14 16:46:13 -07001726 if [ -x onos-files/onos-apps ] && [ "$(find onos-files/onos-apps -name "*.oar" 2>/dev/null | wc -l)" -gt 0 ]; then
1727 for OAR in onos-files/onos-apps/*.oar; do
David Bainbridge27790d62019-08-13 22:43:19 +00001728 sspin - "Installing custom ONOS applications - $OAR$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -07001729 override_onos_app "$OAR"
David Bainbridge27790d62019-08-13 22:43:19 +00001730 done
1731 espin - "$VERIFIED Installing custom ONOS applications$CEOL"
1732 else
1733 espin - "$NOT_VERIFIED Installing custom ONOS applications - None Found"
1734 fi
1735 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001736
David Bainbridged18f4942020-04-14 16:46:13 -07001737 if [ "$WITH_KAFKA" != "no" ]; then
David Bainbridge837e8bd2020-04-06 13:17:14 -07001738 check_onos_app_active org.opencord.kafka
David Bainbridgec7220622020-05-28 12:31:47 -07001739 _HOST=voltha-kafka.$INFRA_NS.svc
David Bainbridge837e8bd2020-04-06 13:17:14 -07001740 _PORT=9092
David Bainbridged18f4942020-04-14 16:46:13 -07001741 if [ "$WITH_KAFKA" == "yes" ]; then
David Bainbridgec7220622020-05-28 12:31:47 -07001742 _HOST=voltha-kafka.$VOLTHA_NS.svc
David Bainbridge76afd812020-04-06 09:53:52 -07001743 _PORT=9092
David Bainbridged18f4942020-04-14 16:46:13 -07001744 elif [ "$WITH_KAFKA" == "external" ]; then
David Bainbridgec7220622020-05-28 12:31:47 -07001745 _HOST=kafka.$INFRA_NS.svc
David Bainbridge76afd812020-04-06 09:53:52 -07001746 _PORT=9092
1747 else
David Bainbridged18f4942020-04-14 16:46:13 -07001748 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
1749 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge837e8bd2020-04-06 13:17:14 -07001750 _PORT=${_PORT:-9092}
1751 fi
1752 push_onos_config "json" "Push ONOS Kafka Configuration" "network/configuration/apps/org.opencord.kafka" \
David Bainbridged18f4942020-04-14 16:46:13 -07001753 "$(cat <<EOJ | tr -d '[:space:]'
David Bainbridge696bc632020-04-05 21:49:37 -07001754{
1755 "kafka": {
1756 "bootstrapServers": "$_HOST:$_PORT"
1757 }
1758}
1759EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07001760)"
David Bainbridge837e8bd2020-04-06 13:17:14 -07001761 fi
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001762 check_onos_app_active org.opencord.dhcpl2relay
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001763 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 -08001764 check_onos_app_active org.opencord.olt
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001765 # FIXME use WITH_DHCP and WITH_EAPOL flags to configre OLT App
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001766 # Default value for "enableEapol" is true in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07001767 if [ "$WITH_EAPOL" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001768 push_onos_config "json" "Enable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":true}'
David Bainbridged18f4942020-04-14 16:46:13 -07001769 elif [ "$WITH_EAPOL" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001770 push_onos_config "json" "Disable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001771 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001772 # Default value for "enableDhcpOnProvisioning" is false and for "enableDhcpV4" is true in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07001773 if [ "$WITH_DHCP" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001774 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 -07001775 elif [ "$WITH_DHCP" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001776 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 -08001777 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001778 # Default value for "enableIgmpOnProvisioning" is false in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07001779 if [ "$WITH_IGMP" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001780 push_onos_config "json" "Enable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":true}'
David Bainbridged18f4942020-04-14 16:46:13 -07001781 elif [ "$WITH_IGMP" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001782 push_onos_config "json" "Disable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001783 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001784 if [ "$ENABLE_ONOS_EXTRANEOUS_RULES" == "yes" ]; then
David K. Bainbridge484d80c2020-03-05 21:44:34 -08001785 push_onos_config "file" "Enabling extraneous rules for ONOS" "configuration/org.onosproject.net.flow.impl.FlowRuleManager" "onos-files/olt-onos-enableExtraneousRules.json"
1786 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001787 if is_in "$CONFIG_SADIS" "yes,file"; then
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001788 check_onos_app_active org.opencord.sadis
Hardik Windlassb3147602020-03-09 16:59:15 +05301789 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 -07001790 elif [ "$CONFIG_SADIS" == "bbsim" ]; then
1791 push_onos_config "json" \
1792 "[optional] Push ONOS configuration for BBSIM SADIS servers" \
1793 "network/configuration/apps/org.opencord.sadis" \
David Bainbridged18f4942020-04-14 16:46:13 -07001794 "$(cat <<EOJ | tr -d '[:space:]'
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001795{
1796 "sadis": {
1797 "integration": {
David Bainbridgec7220622020-05-28 12:31:47 -07001798 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:50074/v2/subscribers/%s",
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001799 "cache": {
1800 "enabled": true,
1801 "maxsize": 50,
1802 "ttl": "PT1m"
1803 }
1804 }
1805 },
1806 "bandwidthprofile": {
1807 "integration": {
David Bainbridgec7220622020-05-28 12:31:47 -07001808 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:50074/v2/bandwidthprofiles/%s",
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001809 "cache": {
1810 "enabled": true,
1811 "maxsize": 50,
1812 "ttl": "PT1m"
1813 }
1814 }
1815 }
1816}
1817EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07001818)"
David Bainbridge309099c2020-05-05 08:47:29 -07001819 elif [ "$CONFIG_SADIS" == "external" ]; then
1820 push_onos_config "json" \
1821 "[optional] Push ONOS configuration for custom SADIS and Bandwidth Profile servers" \
1822 "network/configuration/apps/org.opencord.sadis" \
1823 "$(cat <<EOJ | tr -d '[:space:]'
1824{
1825 "sadis": {
1826 "integration": {
1827 "url": "http://bbsim-sadis-server.$BBSIM_NS.svc:58080/subscribers/%s",
1828 "cache": {
1829 "enabled": true,
1830 "maxsize": 50,
1831 "ttl": "PT1m"
1832 }
1833 }
1834 },
1835 "bandwidthprofile": {
1836 "integration": {
1837 "url": "http://bbsim-sadis-server.$BBSIM_NS.svc:58080/profiles/%s",
1838 "cache": {
1839 "enabled": true,
1840 "maxsize": 50,
1841 "ttl": "PT1m"
1842 }
1843 }
1844 }
1845}
1846EOJ
1847)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001848 elif [ "$CONFIG_SADIS" == "url" ]; then
1849 push_onos_config "json" \
1850 "[optional] Push ONOS configuration for custom SADIS and Bandwidth Profile servers" \
1851 "network/configuration/apps/org.opencord.sadis" \
David Bainbridged18f4942020-04-14 16:46:13 -07001852 "$(cat <<EOJ | tr -d '[:space:]'
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001853{
1854 "sadis": {
1855 "integration": {
1856 "url": "$SADIS_SUBSCRIBERS",
1857 "cache": {
1858 "enabled": true,
1859 "maxsize": 50,
1860 "ttl": "PT1m"
1861 }
1862 }
1863 },
1864 "bandwidthprofile": {
1865 "integration": {
1866 "url": "$SADIS_BANDWIDTH_PROFILES",
1867 "cache": {
1868 "enabled": true,
1869 "maxsize": 50,
1870 "ttl": "PT1m"
1871 }
1872 }
1873 }
1874}
1875EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07001876)"
David Bainbridge2b19e832019-08-16 02:40:53 +00001877 fi
Test Userba1e7e72019-07-10 22:27:54 +00001878fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001879if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001880 NOW="$(date +%s)"
1881 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001882fi
Test Userba1e7e72019-07-10 22:27:54 +00001883
David Bainbridgec7220622020-05-28 12:31:47 -07001884if is_in "$WITH_ETCD" "yes,external"; then
David Bainbridged18f4942020-04-14 16:46:13 -07001885 STIME="$(date +%s)"
David Bainbridge76afd812020-04-06 09:53:52 -07001886 bspin "Verify external ETCD cluster $OLD_KEY"
David Bainbridge43f2df52020-06-02 15:30:54 -07001887 EXPECT="$(yq r - "etcd.replicas" <"$NAME-values.yaml")"
David Bainbridgec7220622020-05-28 12:31:47 -07001888 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 -07001889 espin "$NOT_VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07001890 helm_install - "$INFRA_NS" etcd "$ETCD_CHART" "$ETCD_CHART_VERSION" etcd "$_HELM_DESC external ETCD cluster"
David Bainbridge76afd812020-04-06 09:53:52 -07001891 else
David Bainbridged18f4942020-04-14 16:46:13 -07001892 espin "$VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07001893 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001894 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for ETCD cluster to start" "$NO_LABEL" "etcd-.*"
David Bainbridge76afd812020-04-06 09:53:52 -07001895 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001896 NOW="$(date +%s)"
1897 printtime $((NOW - STIME))
David Bainbridge76afd812020-04-06 09:53:52 -07001898 fi
1899fi
1900
David Bainbridgec7220622020-05-28 12:31:47 -07001901if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridged18f4942020-04-14 16:46:13 -07001902 _TMP="$(mktemp -u)"
1903 _COUNT="$(test "$TYPE" == "minimal" && echo "1" || echo "3")"
1904 cat << EOC > "$_TMP"
David Bainbridge76afd812020-04-06 09:53:52 -07001905configurationOverrides:
1906 "default.replication.factor": $_COUNT
1907 "offsets.topic.replication.factor": $_COUNT
1908 "log.retention.hours": 4
1909 "log.message.timestamp.type": "LogAppendTime"
1910persistence:
1911 enabled: false
1912zookeeper:
1913 replicaCount: 1
1914 persistence:
1915 enabled: false
1916replicas: $_COUNT
1917EOC
David Bainbridged18f4942020-04-14 16:46:13 -07001918 STIME="$(date +%s)"
David Bainbridge76afd812020-04-06 09:53:52 -07001919 bspin "Verify external Kafka cluster $OLD_KEY"
David Bainbridged18f4942020-04-14 16:46:13 -07001920 EXPECT="$(test "$TYPE" == "minimal" && echo "2" || echo "4")"
1921 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^kafka\$" | wc -l)" -ne 1 ]; then
1922 espin "$NOT_VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07001923 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" -f $_TMP"
David Bainbridgec7220622020-05-28 12:31:47 -07001924 helm_install - "$INFRA_NS" kafka "$KAFKA_CHART" "$KAFKA_CHART_VERSION" kafka "$_HELM_DESC external Kafka cluster"
David Bainbridge76afd812020-04-06 09:53:52 -07001925 else
David Bainbridged18f4942020-04-14 16:46:13 -07001926 espin "$VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07001927 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001928 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for Kafka cluster to start" "$NO_LABEL" "kafka-.*"
David Bainbridge76afd812020-04-06 09:53:52 -07001929 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001930 NOW="$(date +%s)"
1931 printtime $((NOW - STIME))
David Bainbridge76afd812020-04-06 09:53:52 -07001932 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001933 rm -rf "$_TMP"
David Bainbridge76afd812020-04-06 09:53:52 -07001934fi
1935
David Bainbridged18f4942020-04-14 16:46:13 -07001936STIME="$(date +%s)"
David Bainbridgeed476572020-06-02 14:05:45 -07001937EXPECT=2
1938# therecanbeonlyone set hardcoded to true for backward compatibility
1939INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set therecanbeonlyone=true"
Matteo Scandolo67335f02020-04-09 11:19:53 -07001940case $WITH_ETCD in
David Bainbridge76afd812020-04-06 09:53:52 -07001941 no)
David Bainbridge76afd812020-04-06 09:53:52 -07001942 ;;
David Bainbridgec7220622020-05-28 12:31:47 -07001943 yes|external)
1944 _HOST="etcd.$INFRA_NS.svc"
David Bainbridge76afd812020-04-06 09:53:52 -07001945 _PORT=2379
1946 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridge76afd812020-04-06 09:53:52 -07001947 ;;
1948 *)
David Bainbridged18f4942020-04-14 16:46:13 -07001949 _HOST="$(echo "$WITH_ETCD" | cut -d: -f1)"
1950 _PORT="$(echo "$WITH_ETCD" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07001951 _PORT=${_PORT:-2379}
David Bainbridgec7220622020-05-28 12:31:47 -07001952 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridge76afd812020-04-06 09:53:52 -07001953 ;;
1954esac
1955case $WITH_KAFKA in
1956 no)
David Bainbridge76afd812020-04-06 09:53:52 -07001957 ;;
David Bainbridgec7220622020-05-28 12:31:47 -07001958 yes|external)
1959 _HOST=kafka.$INFRA_NS.svc
David Bainbridge76afd812020-04-06 09:53:52 -07001960 _PORT=9092
1961 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 -07001962 ;;
1963 *)
David Bainbridged18f4942020-04-14 16:46:13 -07001964 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
1965 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07001966 _PORT=${_PORT:-9092}
David Bainbridgec7220622020-05-28 12:31:47 -07001967 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 -07001968 ;;
1969esac
1970
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001971if is_in "$WITH_ONOS" "legacy"; then
David Bainbridgec7220622020-05-28 12:31:47 -07001972 _HOST=onos-openflow.$INFRA_NS.svc
David Bainbridge76afd812020-04-06 09:53:52 -07001973 _PORT=6653
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001974elif is_in "$WITH_ONOS" "yes,classic"; then
David Bainbridgec7220622020-05-28 12:31:47 -07001975 _HOST=onos-onos-classic-hs.$INFRA_NS.svc
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001976 _PORT=6653
David Bainbridged18f4942020-04-14 16:46:13 -07001977elif [ "$WITH_ONOS" != "no" ]; then
1978 _HOST="$(echo "$WITH_ONOS" | cut -d: -f1)"
1979 _PORT="$(echo "$WITH_ONOS" | cut -s -d: -f2)"
David Bainbridge76afd812020-04-06 09:53:52 -07001980 _PORT=${_PORT:-6653}
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07001981fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001982
David Bainbridgecf546362020-04-21 23:18:50 -07001983compare_versions "$RESOLVED_VOLTHA_CHART_VERSION" 2.4.2
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07001984if [ "$?" == "1" ]; then
1985 # voltha chart > 2.4.2 uses list of controllers
David Bainbridgee4d11ca2020-05-08 10:21:10 -07001986 for NUM in $(seq 0 $((NUM_OF_ONOS-1))); do
David Bainbridgec7220622020-05-28 12:31:47 -07001987 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 -07001988 done
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07001989else
1990 # voltha chart <= 2.4.2 uses single controller
David Bainbridge76afd812020-04-06 09:53:52 -07001991 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.controller.service=$_HOST --set services.controller.port=$_PORT"
David Bainbridge696bc632020-04-05 21:49:37 -07001992fi
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07001993
Test Userb5712372019-07-03 21:52:17 +00001994bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
David Bainbridged18f4942020-04-14 16:46:13 -07001995if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$VOLTHA_NS" "^voltha\$" | wc -l)" -ne 1 ]; then
1996 espin "$NOT_VERIFIED"
David Bainbridgea965ca22020-06-09 17:45:04 -07001997 helm_install - "$VOLTHA_NS" voltha "$VOLTHA_CHART" "$VOLTHA_CHART_VERSION" "+voltha" "$_HELM_DESC VOLTHA Core"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001998else
David Bainbridged18f4942020-04-14 16:46:13 -07001999 espin "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002000fi
David Bainbridge696bc632020-04-05 21:49:37 -07002001INTERNAL_EXTRA_HELM_INSTALL_ARGS=
Test Userba1e7e72019-07-10 22:27:54 +00002002
David Bainbridge90fd8e32019-08-21 23:32:47 +00002003VOLTHA="voltha-ofagent-.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002004 rw-core.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002005 voltha-zookeeper-.*"
David Bainbridged18f4942020-04-14 16:46:13 -07002006wait_for_pods - "$VOLTHA_NS" "$EXPECT" "includes" "Waiting for VOLTHA Core to start" "$NO_LABEL" "$VOLTHA"
David Bainbridgee87067b2019-08-12 22:00:12 +00002007if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002008 NOW="$(date +%s)"
2009 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002010fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002011
David Bainbridge46505fb2019-10-01 21:13:20 +00002012if [ "$WITH_ADAPTERS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002013 STIME="$(date +%s)"
David Bainbridge46505fb2019-10-01 21:13:20 +00002014 EXPECT=0
David Bainbridgec7220622020-05-28 12:31:47 -07002015 if is_in "$WITH_ETCD" "yes,external"; then
2016 _HOST=etcd.$INFRA_NS.svc
David Bainbridge3517f6c2020-04-08 12:14:08 -07002017 _PORT=2379
2018 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridged18f4942020-04-14 16:46:13 -07002019 elif [ "$WITH_ETCD" != "no" ]; then
2020 _HOST="$(echo "$WITH_ETCD" | cut -d: -f1)"
2021 _PORT="$(echo "$WITH_ETCD" | cut -s -d: -f2)"
David Bainbridge3517f6c2020-04-08 12:14:08 -07002022 _PORT=${_PORT:-2379}
2023 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridge696bc632020-04-05 21:49:37 -07002024 fi
David Bainbridgec7220622020-05-28 12:31:47 -07002025 if is_in "$WITH_KAFKA" "yes,external"; then
2026 _HOST=kafka.$INFRA_NS.svc
David Bainbridge3517f6c2020-04-08 12:14:08 -07002027 _PORT=9092
2028 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 -07002029 elif [ "$WITH_KAFKA" != "no" ]; then
2030 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
2031 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge3517f6c2020-04-08 12:14:08 -07002032 _PORT=${_PORT:-9092}
2033 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 -07002034 fi
David Bainbridge46505fb2019-10-01 21:13:20 +00002035 echo -e "Verify Adapters $PLUG"
2036 if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then
2037 bspin - "Verify Simulated Adapters installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002038 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$ADAPTER_NS" "^sim\$" | wc -l)" -ne 1 ]; then
2039 espin - "$NOT_VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002040 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 +00002041 else
David Bainbridged18f4942020-04-14 16:46:13 -07002042 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00002043 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002044 EXPECT="$((EXPECT + 2))"
David Bainbridge46505fb2019-10-01 21:13:20 +00002045 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07002046
David Bainbridge46505fb2019-10-01 21:13:20 +00002047 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
2048 bspin - "Verify OpenOLT Adapter installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002049 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$ADAPTER_NS" "^open-olt\$" | wc -l)" -ne 1 ]; then
2050 espin - "$NOT_VERIFIED"
David Bainbridgea965ca22020-06-09 17:45:04 -07002051 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 +00002052 else
David Bainbridged18f4942020-04-14 16:46:13 -07002053 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00002054 fi
Matteo Scandolo67335f02020-04-09 11:19:53 -07002055 EXPECT="$((EXPECT + 1))"
David Bainbridge46505fb2019-10-01 21:13:20 +00002056 bspin - "Verify OpenONU Adapter installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002057 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 -07002058 _ORIGINAL_EXTRA_HELM_INSTALL_ARGS="$INTERNAL_EXTRA_HELM_INSTALL_ARGS"
2059 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set replicas.adapter_open_onu=$NUM_OF_OPENONU"
David Bainbridged18f4942020-04-14 16:46:13 -07002060 espin - "$NOT_VERIFIED"
David Bainbridgea965ca22020-06-09 17:45:04 -07002061 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 -07002062 INTERNAL_EXTRA_HELM_INSTALL_ARGS="$_ORIGINAL_EXTRA_HELM_INSTALL_ARGS"
David Bainbridge46505fb2019-10-01 21:13:20 +00002063 else
David Bainbridged18f4942020-04-14 16:46:13 -07002064 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00002065 fi
Matteo Scandolo67335f02020-04-09 11:19:53 -07002066 EXPECT=$((EXPECT + NUM_OF_OPENONU))
David Bainbridge46505fb2019-10-01 21:13:20 +00002067 fi
David Bainbridge696bc632020-04-05 21:49:37 -07002068 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07002069
David Bainbridge46505fb2019-10-01 21:13:20 +00002070 ADAPTERS="adapter-.*"
David Bainbridged18f4942020-04-14 16:46:13 -07002071 wait_for_pods - "$ADAPTER_NS" "$EXPECT" "includes" "Waiting for adapters to start" "$NO_LABEL" "$ADAPTERS"
David Bainbridge46505fb2019-10-01 21:13:20 +00002072 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002073 NOW="$(date +%s)"
2074 printtime $((NOW - STIME))
David Bainbridge46505fb2019-10-01 21:13:20 +00002075 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00002076fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002077
David Bainbridged18f4942020-04-14 16:46:13 -07002078if [ "$WITH_BBSIM" == "yes" ]; then
2079 STIME="$(date +%s)"
Test User7d866122019-07-09 17:52:35 +00002080 echo -e "Verify BBSIM $PLUG"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002081 bspin - "Verify BBSIM Installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002082 for instance in $(seq 0 $((NUM_OF_BBSIM-1))); do
Matteo Scandoloc2eb0672020-05-01 14:43:15 -07002083
2084 if [ "$LEGACY_BBSIM_INDEX" == "yes" ]; then
2085 if [ "$instance" -eq 0 ]; then
2086 instance_num=""
2087 else
2088 instance_num=$instance
2089 fi
David K. Bainbridge43422402020-03-06 07:41:22 -08002090 else
2091 instance_num=$instance
2092 fi
Matteo Scandoloc2eb0672020-05-01 14:43:15 -07002093
2094
David Bainbridged18f4942020-04-14 16:46:13 -07002095 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$BBSIM_NS" "^bbsim${instance_num}\$" | wc -l)" -ne 1 ]; then
2096 espin - "$NOT_VERIFIED"
2097 S_TAG="$((900+instance))"
Matteo Scandolo5a149572020-04-01 10:14:57 -07002098 INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set olt_id=$instance,s_tag=$S_TAG"
David Bainbridged9329af2020-05-01 11:58:52 -07002099 if [ "$WITH_EAPOL" == "yes" ]; then
2100 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set auth=true"
2101 else
2102 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set auth=false"
2103 fi
2104 if [ "$WITH_DHCP" == "yes" ]; then
2105 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set dhcp=true"
2106 else
2107 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set dhcp=false"
2108 fi
David Bainbridge33e56c72020-06-11 11:39:56 -07002109 if is_in "$WITH_KAFKA" "yes,external"; then
2110 _HOST=kafka.$INFRA_NS.svc
2111 _PORT=9092
2112 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafkaAddress=$_HOST:$_PORT"
2113 elif [ "$WITH_KAFKA" != "no" ]; then
2114 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
2115 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
2116 _PORT=${_PORT:-9092}
2117 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafkaAddress=$_HOST:$_PORT"
2118 fi
2119 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 -07002120 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
David K. Bainbridge43422402020-03-06 07:41:22 -08002121 else
David Bainbridged18f4942020-04-14 16:46:13 -07002122 espin - "$VERIFIED"
David K. Bainbridge43422402020-03-06 07:41:22 -08002123 fi
2124 done
David Bainbridged18f4942020-04-14 16:46:13 -07002125 wait_for_pods - "$BBSIM_NS" "$NUM_OF_BBSIM" "includes" "Waiting for BBSIM to start" "$BBSIM_LABEL" "bbsim*"
David Bainbridgee87067b2019-08-12 22:00:12 +00002126 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002127 NOW="$(date +%s)"
2128 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002129 fi
Test User7d866122019-07-09 17:52:35 +00002130fi
2131
David Bainbridge309099c2020-05-05 08:47:29 -07002132if [ "$CONFIG_SADIS" == "external" ]; then
2133 STIME="$(date +%s)"
2134 echo -e "Verify BBSIM SADIS Service $PLUG"
2135 bspin - "Verify required configmap"
2136 (set -x; kubectl -n "$BBSIM_NS" delete --ignore-not-found configmap kube-config >>"$LOG" 2>&1) >>"$LOG" 2>&1
2137 (set -x; kubectl -n "$BBSIM_NS" create configmap kube-config "--from-file=kube_config=$KUBECONFIG" >>"$LOG" 2>&1) >>"$LOG" 2>&1
2138 espin - "$VERIFIED"
2139 bspin - "Verify BBSIM SADIS Service Installed"
2140 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$BBSIM_NS" "^bbsim-sadis-servier\$" | wc -l)" -ne 1 ]; then
2141 espin - "$NOT_VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002142 helm_install - "$BBSIM_NS" bbsim-sadis-server "$BBSIM_SADIS_SERVER_CHART" "$BBSIM_SADIS_SERVER_CHART_VERSION" - "$_HELM_DESC BBSIM SADIS Server"
David Bainbridge309099c2020-05-05 08:47:29 -07002143 else
2144 espin - "$VERIFIED"
2145 fi
2146 wait_for_pods - "$BBSIM_NS" 1 "includes" "Waiting for BBSIM SADIS Server to start" "$NO_LABEL" "bbsim-sadis-server-.*"
2147 if [ "$WITH_TIMINGS" == "yes" ]; then
2148 NOW="$(date +%s)"
2149 printtime $((NOW - STIME))
2150 fi
2151fi
2152
David Bainbridged18f4942020-04-14 16:46:13 -07002153if [ "$WITH_RADIUS" == "yes" ]; then
2154 STIME="$(date +%s)"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002155 echo -e "Verify RADIUS $LOCK"
2156 bspin - "Verify RADIUS Installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002157 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^radius\$" | wc -l)" -ne 1 ]; then
2158 espin - "$NOT_VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002159 helm_install - "$INFRA_NS" radius onf/freeradius latest - "$_HELM_DESC RADIUS"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002160 else
David Bainbridged18f4942020-04-14 16:46:13 -07002161 espin - "$VERIFIED"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002162 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002163 wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for RADIUS to start" "$NO_LABEL" "radius-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00002164 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002165 NOW="$(date +%s)"
2166 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002167 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002168fi
2169
David Bainbridged18f4942020-04-14 16:46:13 -07002170if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
2171 STIME="$(date +%s)"
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002172 bspin - "Forward VOLTHA API port $FORWARD"
David Bainbridge1d2c5842020-06-03 15:29:07 -07002173 kill_port_forward voltha-api voltha-voltha-api
2174 VOLTHA_PREFIX=
2175 if kubectl get -n "$VOLTHA_NS" "svc/voltha-voltha-api" >/dev/null 2>&1; then
2176 VOLTHA_PREFIX="voltha-"
2177 fi
2178
2179 port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-api" "$VOLTHA_API_PORT:55555"
David Bainbridged18f4942020-04-14 16:46:13 -07002180 espin - "$VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002181 if is_in "$WITH_ETCD" "yes,external"; then
David Bainbridge696bc632020-04-05 21:49:37 -07002182 bspin - "Forward VOLTHA ETCD port $FORWARD"
David Bainbridgec7220622020-05-28 12:31:47 -07002183 kill_port_forward "etcd"
2184 port_forward "$INFRA_NS" "etcd" "$VOLTHA_ETCD_PORT:2379"
David Bainbridged18f4942020-04-14 16:46:13 -07002185 espin - "$VERIFIED"
David Bainbridge696bc632020-04-05 21:49:37 -07002186 fi
David Bainbridgec7220622020-05-28 12:31:47 -07002187 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridge696bc632020-04-05 21:49:37 -07002188 bspin - "Forward VOLTHA Kafka port $FORWARD"
David Bainbridgec7220622020-05-28 12:31:47 -07002189 kill_port_forward "kafka"
2190 port_forward "$INFRA_NS" kafka "$VOLTHA_KAFKA_PORT:9092"
David Bainbridged18f4942020-04-14 16:46:13 -07002191 espin - "$VERIFIED"
David Bainbridge696bc632020-04-05 21:49:37 -07002192 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -07002193 if [ "$WITH_PPROF" == "yes" ]; then
David Bainbridge1d2c5842020-06-03 15:29:07 -07002194 VOLTHA_OPENOLT_PREFIX=
2195 if kubectl get -n "$ADAPTER_NS" "svc/open-olt-adapter-open-olt-profiler" >/dev/null 2>&1; then
2196 VOLTHA_OPENOLT_PREFIX="open-olt-"
2197 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -07002198 bspin - "Forward PProf ports port $FORWARD"
David Bainbridge1d2c5842020-06-03 15:29:07 -07002199 kill_port_forward voltha-rw-core-profiler voltha-voltha-rw-core-profiler
2200 kill_port_forward adapter-open-olt-profiler open-olt-adapter-open-olt-profiler
2201 kill_port_forward voltha-of-agent-profiler voltha-voltha-of-agent-profiler
2202 port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-rw-core-profiler" "$VOLTHA_PPROF_PORT:6060"
2203 port_forward "$ADAPTER_NS" "${VOLTHA_OPENOLT_PREFIX}adapter-open-olt-profiler" "$OPENOLT_PPROF_PORT:6060"
2204 port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-of-agent-profiler" "$OFAGENT_PPROF_PORT:6060"
Matteo Scandoloefee0432020-05-05 13:56:20 -07002205 espin - "$VERIFIED"
2206 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002207 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002208 NOW="$(date +%s)"
2209 printtime $((NOW - STIME))
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002210 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00002211fi
Test User3d7ad8e2019-07-03 06:15:44 +00002212
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002213if is_in "$WITH_ONOS" "yes,legacy,classic" && [ "$WITH_RADIUS" != "no" ]; then
David Bainbridgec7220622020-05-28 12:31:47 -07002214 _HOST=radius.$INFRA_NS.svc
David Bainbridge696bc632020-04-05 21:49:37 -07002215 _PORT=1812
David Bainbridged18f4942020-04-14 16:46:13 -07002216 if [ "$WITH_RADIUS" != "yes" ]; then
2217 _HOST="$(echo "$WITH_RADIUS" | cut -d: -f1)"
2218 _PORT="$(echo "$WITH_RADIUS" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07002219 _PORT=${_PORT:-1812}
2220 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002221 bspin "Configure ONOS RADIUS Connection $GEAR"
David Bainbridged18f4942020-04-14 16:46:13 -07002222 (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
2223 espin "$VERIFIED"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002224fi
2225
David Bainbridge99ac7a22019-08-31 02:26:43 +00002226if [ "$WITH_CHAOS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002227 STIME="$(date +%s)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002228 echo -e "Verify kube-monkey $LOCK"
2229 bspin - "Verify kube-monkey Installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002230 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace kube-monkey "^monkey\$" | wc -l)" -ne 1 ]; then
2231 espin - "$NOT_VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002232 helm_install - kube-monkey monkey ./kube-monkey/helm/kubemonkey latest - "$_HELM_DESC Chaos Monkey"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002233 else
David Bainbridged18f4942020-04-14 16:46:13 -07002234 espin - "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002235 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002236 wait_for_pods - "kube-monkey" 1 "includes" "Waiting for Chaos to start" "$NO_LABEL" "monkey-.*"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002237 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002238 NOW="$(date +%s)"
2239 printtime $((NOW - STIME))
David Bainbridge99ac7a22019-08-31 02:26:43 +00002240 fi
2241fi
2242
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002243bspin "Create voltctl configuration file"
David Bainbridged18f4942020-04-14 16:46:13 -07002244(set -x; mkdir -p "$HOME/.volt" >>"$LOG" 2>&1) >>"$LOG" 2>&1
2245MIN_VC_VERSION="$(echo -e "1.0.15\n$VC_VERSION" | sort -V | head -1)"
2246if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002247 KAFKA_FLAG="-k localhost:$VOLTHA_KAFKA_PORT"
2248 SERVER_FLAG="-s localhost:$VOLTHA_API_PORT"
2249 ETCD_FLAG=
2250 if [ "$MIN_VC_VERSION" == "1.0.15" ]; then
2251 ETCD_FLAG="-e localhost:$VOLTHA_ETCD_PORT"
2252 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002253else
David Bainbridgec7220622020-05-28 12:31:47 -07002254 KAFKA_FLAG="-k $(get_service_ep "$INFRA_NS" kafka)"
David Bainbridged18f4942020-04-14 16:46:13 -07002255 SERVER_FLAG="-s $(get_service_ep "$VOLTHA_NS" voltha-api)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002256 ETCD_FLAG=
2257 if [ "$MIN_VC_VERSION" == "1.0.15" ]; then
David Bainbridgec7220622020-05-28 12:31:47 -07002258 ETCD_FLAG="-e $(get_service_ep "$INFRA_NS" etcd)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002259 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002260fi
David Bainbridgea965ca22020-06-09 17:45:04 -07002261CMD=("voltctl $KAFKA_FLAG $SERVER_FLAG $ETCD_FLAG config")
David Bainbridged18f4942020-04-14 16:46:13 -07002262(set -x; ${CMD[*]} > "$HOME/.volt/config-$NAME" 2>>"$LOG") >>"$LOG" 2>&1
David Bainbridgea965ca22020-06-09 17:45:04 -07002263#(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 -07002264espin "$VERIFIED"
Test User08ebbd92019-07-03 17:15:39 +00002265
David Bainbridge0774b232019-08-02 06:37:19 +00002266if [ ! -f "$NAME-env.sh" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002267 touch "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002268fi
2269
David Bainbridge596f30d2019-07-30 17:07:59 +00002270for O in $ALL_OPTIONS; do
David Bainbridged18f4942020-04-14 16:46:13 -07002271 VAL="$(eval echo "\$$O")"
2272 if [ -n "$VAL" ] && [ "$(grep -c "^export $O=" "$NAME-env.sh")" -eq 0 ]; then
2273 echo "export $O=\"$(eval echo "\$$O")\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002274 fi
2275done
2276
David Bainbridged18f4942020-04-14 16:46:13 -07002277if [ "$DEPLOY_K8S" == "yes" ] && [ "$(grep -c "^export KUBECONFIG=" "$NAME-env.sh")" -eq 0 ]; then
2278 echo "export KUBECONFIG=\"$(./bin/kind get kubeconfig-path "--name=voltha-$NAME")\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002279fi
2280
David Bainbridged18f4942020-04-14 16:46:13 -07002281if [ "$(grep -c "^export VOLTCONFIG=" "$NAME-env.sh")" -eq 0 ]; then
2282 echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002283fi
2284
David Bainbridged18f4942020-04-14 16:46:13 -07002285if [ "$(grep -c "^export PATH=" "$NAME-env.sh")" -eq 0 ]; then
2286 echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002287fi
2288
Test User7d866122019-07-09 17:52:35 +00002289echo ""
David Bainbridged18f4942020-04-14 16:46:13 -07002290echo "Please issue the following commands in your terminal to ensure that you" | tee -a "$LOG"
2291echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a "$LOG"
2292echo "tools required by VOLTHA in your command path. " | tee -a "$LOG"
2293echo "" | tee -a "$LOG"
2294echo -en "$BOLD"
2295if [ "$DEPLOY_K8S" == "yes" ]; then
2296 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00002297fi
David Bainbridged18f4942020-04-14 16:46:13 -07002298echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" | tee -a "$LOG"
2299echo "export PATH=$GOPATH/bin:\$PATH" | tee -a "$LOG"
2300echo -en "$NORMAL"
2301echo "" | tee -a "$LOG"
2302echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a "$LOG"
Test User08ebbd92019-07-03 17:15:39 +00002303
David Bainbridge712afb82019-08-14 19:55:58 +00002304if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002305 NOW="$(date +%s)"
2306 echo -e "$CLOCK ${BOLD}TOTAL: $(duration $((NOW - TOTAL_START_TIME)))${NORMAL}"
David Bainbridge712afb82019-08-14 19:55:58 +00002307fi