blob: c83e1ad07f5e343064e83d275c7682bd563db7fa [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 Bainbridge05cd8822019-11-19 17:43:53 +000090ONLY_ONE=${ONLY_ONE:-yes}
David Bainbridgee4d11ca2020-05-08 10:21:10 -070091SCHEDULE_ON_CONTROL_NODES=${SCHEDULE_ON_CONTROL_NODES:-no}
David Bainbridge309099c2020-05-05 08:47:29 -070092CONFIG_SADIS=${CONFIG_SADIS:-no} # yes | no | file | bbsim | external | URL
David Bainbridge76afd812020-04-06 09:53:52 -070093SADIS_SUBSCRIBERS=${SADIS_SUBSCRIBERS:-http://bbsim.$VOLTHA_NS.svc:50074/v2/subscribers/%s}
94SADIS_BANDWIDTH_PROFILES=${SADIS_BANDWIDTH_PROFILES:-http://bbsim.$VOLTHA_NS.svc:50074/v2/bandwidthprofiles/%s}
Hardik Windlassb3147602020-03-09 16:59:15 +053095SADIS_CFG=${SADIS_CFG:-onos-files/onos-sadis-sample.json}
David Bainbridge27790d62019-08-13 22:43:19 +000096INSTALL_ONOS_APPS=${INSTALL_ONOS_APPS:-no}
Test Userba1e7e72019-07-10 22:27:54 +000097JUST_K8S=${JUST_K8S:-no}
98DEPLOY_K8S=${DEPLOY_K8S:-yes}
David K. Bainbridge0e89cb92019-07-17 11:30:10 -070099INSTALL_KUBECTL=${INSTALL_KUBECTL:-yes}
100INSTALL_HELM=${INSTALL_HELM:-yes}
David Bainbridge7f8bf992020-04-08 21:53:22 -0700101HELM_USE_UPGRADE=${HELM_USE_UPGRADE:-no}
David Bainbridge46505fb2019-10-01 21:13:20 +0000102UPDATE_HELM_REPOS=${UPDATE_HELM_REPOS:-yes}
Matteo Scandolofab98622020-01-28 15:17:20 -0800103WAIT_ON_DOWN=${WAIT_ON_DOWN:-yes}
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700104WAIT_TIMEOUT=${WAIT_TIMEOUT:-30m}
105VOLTHA_DOWN_ON_TIMEOUT=${VOLTHA_DOWN_ON_TIMEOUT:-no}
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000106VOLTHA_LOG_LEVEL=${VOLTHA_LOG_LEVEL:-WARN}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000107VOLTHA_CHART=${VOLTHA_CHART:-onf/voltha}
108VOLTHA_CHART_VERSION=${VOLTHA_CHART_VERSION:-latest}
109VOLTHA_BBSIM_CHART=${VOLTHA_BBSIM_CHART:-onf/bbsim}
Matteo Scandolodcd29f52019-10-07 15:42:42 -0700110VOLTHA_BBSIM_CHART_VERSION=${VOLTHA_BBSIM_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000111VOLTHA_ADAPTER_SIM_CHART=${VOLTHA_ADAPTER_SIM_CHART:-onf/voltha-adapter-simulated}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000112VOLTHA_ADAPTER_SIM_CHART_VERSION=${VOLTHA_ADAPTER_SIM_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000113VOLTHA_ADAPTER_OPEN_OLT_CHART=${VOLTHA_ADAPTER_OPEN_OLT_CHART:-onf/voltha-adapter-openolt}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000114VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION=${VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000115VOLTHA_ADAPTER_OPEN_ONU_CHART=${VOLTHA_ADAPTER_OPEN_ONU_CHART:-onf/voltha-adapter-openonu}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000116VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION=${VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION:-latest}
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800117ONOS_CHART=${ONOS_CHART:-onf/onos}
Andrea Campanella21323292019-12-18 11:44:19 -0800118ONOS_CHART_VERSION=${ONOS_CHART_VERSION:-latest}
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700119ONOS_CLASSIC_CHART=${ONOS_CLASSIC_CHART:-onos/onos-classic}
120ONOS_CLASSIC_CHART_VERSION=${ONOS_CHART_VERSION:-latest}
David Bainbridgecf546362020-04-21 23:18:50 -0700121KAFKA_CHART=${KAFKA_CHART:-incubator/kafka}
David Bainbridgeb9093522020-04-15 14:32:44 -0700122KAFKA_CHART_VERSION=${KAFKA_CHART_VERSION:=0.15.3}
David Bainbridge309099c2020-05-05 08:47:29 -0700123BBSIM_SADIS_SERVER_CHART=${BBSIM_SADIS_SERVER_CHART:-bbsim-sadis/bbsim-sadis-server}
124BBSIM_SADIS_SERVER_CHART_VERSION=${BBSIM_SADIS_SERVER_CHART_VERSION:-latest}
David Bainbridge2eaf2cf2020-03-18 12:54:08 -0700125EXTRA_HELM_INSTALL_ARGS=${EXTRA_HELM_INSTALL_ARGS:-}
126INTERNAL_EXTRA_HELM_INSTALL_ARGS=
uottrembb16d3982020-02-28 08:34:36 +0100127NUM_OF_BBSIM=${NUM_OF_BBSIM:-1}
Matteo Scandolo67335f02020-04-09 11:19:53 -0700128NUM_OF_OPENONU=${NUM_OF_OPENONU:-1}
uottrembb16d3982020-02-28 08:34:36 +0100129MAX_NUM_OF_BBSIM=10
Matteo Scandolo67335f02020-04-09 11:19:53 -0700130MAX_NUM_OF_OPENONU=10
Matteo Scandoloc2eb0672020-05-01 14:43:15 -0700131LEGACY_BBSIM_INDEX=${LEGACY_BBSIM_INDEX:-no}
Test Userba1e7e72019-07-10 22:27:54 +0000132
David Bainbridged18f4942020-04-14 16:46:13 -0700133HOSTOS="$(uname -s | tr "[:upper:]" "[:lower:"])"
134HOSTARCH="$(uname -m | tr "[:upper:]" "[:lower:"])"
135if [ "$HOSTARCH" == "x86_64" ]; then
Test Userba1e7e72019-07-10 22:27:54 +0000136 HOSTARCH="amd64"
137fi
David Bainbridge7db44002020-04-09 12:54:29 -0700138BBSIM_LABEL="-l app=bbsim"
David Bainbridged18f4942020-04-14 16:46:13 -0700139NO_LABEL=
Test User7d866122019-07-09 17:52:35 +0000140
uottrembb16d3982020-02-28 08:34:36 +0100141# check number (range) of bbsim, max bbsim must not exceed 10 instances!
142# note: instances will be numbered from 0 to 9
143if [ "$1" == "up" ]; then
David K. Bainbridge43422402020-03-06 07:41:22 -0800144 if [ "$NUM_OF_BBSIM" -lt 1 ]; then
Matteo Scandolo67335f02020-04-09 11:19:53 -0700145 >&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 -0800146 exit 1
147 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700148 if [ "$NUM_OF_BBSIM" -gt "$MAX_NUM_OF_BBSIM" ]; then
Matteo Scandolo67335f02020-04-09 11:19:53 -0700149 >&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}"
150 exit 1
151 fi
152
153 if [ "$NUM_OF_OPENONU" -lt 1 ]; then
154 >&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}"
155 exit 1
156 fi
157 if [ "$NUM_OF_OPENONU" -gt "$MAX_NUM_OF_OPENONU" ]; then
158 >&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 -0800159 exit 1
160 fi
uottrembb16d3982020-02-28 08:34:36 +0100161fi
Test User7d866122019-07-09 17:52:35 +0000162# Verify TYPE setting
David Bainbridged18f4942020-04-14 16:46:13 -0700163if [ "$(echo ":minimal:full:" | grep -ic ":$TYPE:")" -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700164 >&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 +0000165 exit 1
166fi
167
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700168# checks to see if a given WORD is in the given LIST of words
169function is_in() {
170 local WORD LIST
171 WORD="$1"; shift
172 LIST="$*"
173 LIST=${LIST//+([[:space:],|])/:}
174
175 [ "$(echo ":$LIST:" | grep -ic ":$WORD:")" -ne 0 ]
176}
177
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700178function parseDuration() {
David Bainbridged18f4942020-04-14 16:46:13 -0700179 local DUR RESULT TERM TERMS VALUE UNIT
180 DUR=$1
181 RESULT=0
182 TERMS="$(echo "$DUR" | sed -Ee 's/([sSmMhHdD])/\1 /g' -e 's/,$//g')"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700183 for TERM in $TERMS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700184 VALUE="$(echo "$TERM" | sed -Ee 's/([0-9]+)[sSmMhHdD]/\1/')"
185 UNIT="$(echo "$TERM" | sed -Ee 's/[0-9]+([sSmMhHdD])/\1/')"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700186 case $UNIT in
187 s|S)
David Bainbridged18f4942020-04-14 16:46:13 -0700188 RESULT=$((RESULT + VALUE)) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700189 m|M)
David Bainbridged18f4942020-04-14 16:46:13 -0700190 RESULT=$((RESULT + (VALUE * 60))) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700191 h|H)
David Bainbridged18f4942020-04-14 16:46:13 -0700192 RESULT=$((RESULT + (VALUE * 3600))) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700193 d|D)
David Bainbridged18f4942020-04-14 16:46:13 -0700194 RESULT=$((RESULT + (VALUE * 86400))) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700195 *) ;;
196 esac
197 done
198 echo $RESULT
199}
200
201function doTimeout() {
202 local MSG=$1
203 2>&1 echo -e "\n${RED}${BOLD}${ERROR}TIMEOUT:${NORMAL}${RED} Operation timed out after '$WAIT_TIMEOUT': $MSG"
204 exit 125
205}
206
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800207function get_service_ep() {
208 local NS=$1
209 local NAME=$2
David Bainbridged18f4942020-04-14 16:46:13 -0700210 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 -0800211}
212
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000213# Used to verify configuration values are set to "yes" or "no" value or convert
214# equivalents to "yes" or "no"
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700215YES="y,yes,t,true,1"
216NO="n,no,f,false,0"
217YES_OR_NO="$YES,$NO"
218
219# If the given VAR matches a truth value then normalize that
220# value, else return original value
221function normalize_yes_no() {
222 local VAR VAL
223 VAR=$1
224 VAL="$(eval echo "\$$VAR")"
225 if ! is_in "$VAL" "$YES_OR_NO"; then
226 echo "$VAL"
227 return 1
228 fi
229 if is_in "$VAL" "$YES"; then
230 echo "yes"
231 else
232 echo "no"
233 fi
234 return 0
235}
236
237# If the given VAR matches a truth value then normalize that
238# value, else display an error
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000239function verify_yes_no() {
David Bainbridged18f4942020-04-14 16:46:13 -0700240 local VAR VAL
241 VAR=$1
242 VAL="$(eval echo "\$$VAR")"
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700243 if ! is_in "$VAL" "$YES_OR_NO"; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000244 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid '$VAR' value of '$VAL'. Should be 'yes' or 'no'${NORMAL}"
245 echo "INVALID"
246 return 1
247 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700248 if is_in "$VAL" "$YES"; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000249 echo "yes"
250 else
251 echo "no"
252 fi
253 return 0
254}
Test User7d866122019-07-09 17:52:35 +0000255
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000256ALL_YES_NO="\
David K. Bainbridge484d80c2020-03-05 21:44:34 -0800257 ENABLE_ONOS_EXTRANEOUS_RULES \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000258 WITH_TIMINGS \
259 WITH_BBSIM \
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800260 WITH_EAPOL \
261 WITH_DHCP \
262 WITH_IGMP \
David Bainbridge99ac7a22019-08-31 02:26:43 +0000263 WITH_CHAOS \
David Bainbridge46505fb2019-10-01 21:13:20 +0000264 WITH_ADAPTERS \
265 WITH_SIM_ADAPTERS \
266 WITH_OPEN_ADAPTERS \
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800267 WITH_PORT_FORWARDS \
Matteo Scandoloefee0432020-05-05 13:56:20 -0700268 WITH_PPROF \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000269 JUST_K8S \
270 DEPLOY_K8S \
271 INSTALL_ONOS_APPS \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000272 INSTALL_KUBECTL \
273 INSTALL_HELM \
David Bainbridge7f8bf992020-04-08 21:53:22 -0700274 HELM_USE_UPGRADE \
David Bainbridge46505fb2019-10-01 21:13:20 +0000275 UPDATE_HELM_REPOS \
David Bainbridge4f1b5562019-08-19 04:46:52 +0000276 WAIT_ON_DOWN \
David Bainbridge70c0ea82019-11-14 23:25:26 +0000277 ONLY_ONE \
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700278 VOLTHA_DOWN_ON_TIMEOUT \
Matteo Scandoloc2eb0672020-05-01 14:43:15 -0700279 LEGACY_BBSIM_INDEX \
David Bainbridgee4d11ca2020-05-08 10:21:10 -0700280 SCHEDULE_ON_CONTROL_NODES \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000281 "
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000282
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700283OPT_YES_NO="\
284 CONFIG_SADIS \
285 WITH_KAFKA \
286 WITH_RADIUS \
287 WITH_ETCD \
288 WITH_ONOS \
289 "
290
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000291ALL_OPTIONS="\
292 NAME \
293 TYPE \
294 $ALL_YES_NO \
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700295 $OPT_YES_NO \
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700296 WAIT_TIMEOUT \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000297 VOLTHA_LOG_LEVEL \
298 VOLTHA_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000299 VOLTHA_CHART_VERSION \
300 VOLTHA_BBSIM_CHART \
301 VOLTHA_BBSIM_CHART_VERSION \
uottrembd5a20572020-03-06 09:15:01 +0100302 NUM_OF_BBSIM \
Matteo Scandolo67335f02020-04-09 11:19:53 -0700303 NUM_OF_OPENONU \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000304 VOLTHA_ADAPTER_SIM_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000305 VOLTHA_ADAPTER_SIM_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000306 VOLTHA_ADAPTER_OPEN_OLT_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000307 VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000308 VOLTHA_ADAPTER_OPEN_ONU_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000309 VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION \
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800310 ONOS_CHART \
Andrea Campanella21323292019-12-18 11:44:19 -0800311 ONOS_CHART_VERSION \
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700312 ONOS_CLASSIC_CHART \
313 ONOS_CLASSIC_CHART_VERSION \
David Bainbridgecf546362020-04-21 23:18:50 -0700314 KAFKA_CHART \
David Bainbridgeb9093522020-04-15 14:32:44 -0700315 KAFKA_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000316 ONOS_API_PORT \
317 ONOS_SSH_PORT \
Hardik Windlassb3147602020-03-09 16:59:15 +0530318 SADIS_CFG \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000319 VOLTHA_API_PORT \
320 VOLTHA_SSH_PORT \
321 VOLTHA_ETCD_PORT \
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800322 VOLTHA_KAFKA_PORT \
Matteo Scandoloefee0432020-05-05 13:56:20 -0700323 VOLTHA_PPROF_PORT \
324 OPENOLT_PPROF_PORT \
Matteo Scandolo65c35192020-05-13 10:41:21 -0700325 OFAGENT_PPROF_PORT \
David K. Bainbridge8f7f30b2020-01-08 13:06:16 -0800326 VK_RELEASE \
327 KIND_VERSION \
328 VOLTCTL_VERSION \
David Bainbridgea34993d2020-04-01 09:15:42 -0700329 HELM_VERSION \
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700330 NUM_OF_ONOS \
331 NUM_OF_ATOMIX \
David Bainbridge6ca40102020-04-08 11:30:40 -0700332 VOLTHA_NS \
333 ADAPTER_NS \
334 INFRA_NS \
335 BBSIM_NS \
David Bainbridge7db44002020-04-09 12:54:29 -0700336 SADIS_BANDWIDTH_PROFILES \
337 SADIS_SUBSCRIBERS \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000338 "
David Bainbridge01294952019-07-30 19:33:45 +0000339
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000340# Iterate over yes/no configuration options and validate
341for VAR in $ALL_YES_NO; do
David Bainbridged18f4942020-04-14 16:46:13 -0700342 eval "$VAR"="$(verify_yes_no "$VAR")"
343 if [ "$(eval echo "\$$VAR")" == "INVALID" ]; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000344 exit 1;
345 fi
346done
David Bainbridgeb270c202019-07-26 01:44:42 +0000347
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700348# Iterate over optional yes/no configuration options and
349# normalize values if they are truth values
350for VAR in $OPT_YES_NO; do
351 eval "$VAR"="$(normalize_yes_no "$VAR")"
352done
David Bainbridge15f6f232020-03-30 09:15:43 -0700353
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700354# normalize non-truth value options
355if is_in "$WITH_KAFKA" "e,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -0700356 WITH_KAFKA="external"
357fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700358if is_in "$WITH_ETCD" "e,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -0700359 WITH_ETCD="external"
360fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700361if is_in "$WITH_ONOS" "l,legacy"; then
362 WITH_ONOS="legacy"
363elif is_in "$WITH_ONOS" "c,classic"; then
364 WITH_ONOS="classic"
365elif is_in "$WITH_ONOS" "u,m,micro"; then
366 WITH_ONOS="micro"
David Bainbridge29c31cb2020-04-06 09:45:50 -0700367fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700368
369if [ "$WITH_ONOS" == "micro" ]; then
370 >&2 echo -e "${YELLOW}${BOLD}${ERROR}WARNING:${NORMAL}${YELLOW} The value specified as WITH_ONOS, '$WITH_ONOS', is not valid.${NORMAL}"
371 exit 1
David Bainbridge29c31cb2020-04-06 09:45:50 -0700372fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700373
374if is_in "$WITH_ONOS" "yes,classic"; then
375 # there is an extra utility required if we are using ONOS CLASSIC as
376 # the chart for classic specifies images differently
377 EXTRA_TOOLS+=" yq"
David Bainbridge76afd812020-04-06 09:53:52 -0700378fi
David Bainbridge696bc632020-04-05 21:49:37 -0700379
David Bainbridged18f4942020-04-14 16:46:13 -0700380if [ "$HELM_USE_UPGRADE" == "yes" ]; then
David Bainbridge7f8bf992020-04-08 21:53:22 -0700381 _HELM_DESC="Upgrade/Install"
382else
383 _HELM_DESC="Install"
384fi
385
David Bainbridged18f4942020-04-14 16:46:13 -0700386ETCD_PREFIX=
387KAFKA_PREFIX=
388if [ "$WITH_ETCD" == "yes" ]; then
389 ETCD_PREFIX="voltha-"
390fi
391if [ "$WITH_KAFKA" == "yes" ]; then
392 KAFKA_PREFIX="voltha-"
393fi
394
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800395# Check for prerequiste tools
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700396TOOLS="curl sed jq $EXTRA_TOOLS"
David Bainbridged18f4942020-04-14 16:46:13 -0700397if [ "$DEPLOY_K8S" == "yes" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800398 TOOLS+=" docker"
399fi
400NOT_FOUND=""
401for T in $TOOLS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700402 if [ -z "$(command -v "$T")" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800403 NOT_FOUND+=" $T"
404 fi
405done
406
David Bainbridged18f4942020-04-14 16:46:13 -0700407if [ -n "$NOT_FOUND" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800408 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} The following required tools where not found, please install them:$NOT_FOUND"
409 exit 1
410fi
411
David Bainbridged18f4942020-04-14 16:46:13 -0700412TIMEOUT_SECONDS="$(parseDuration "$WAIT_TIMEOUT")"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700413
David Bainbridge0774b232019-08-02 06:37:19 +0000414mkdir -p .voltha
415touch .voltha/ports
David Bainbridged18f4942020-04-14 16:46:13 -0700416HAVE="$(grep "$NAME" .voltha/ports)"
David Bainbridge0774b232019-08-02 06:37:19 +0000417if [ "$HAVE X" == " X" ]; then
418 # Find free port prefix
419 START=81
420 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700421 if [ "$(grep -c $START .voltha/ports)" -eq 0 ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000422 break
423 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700424 START="$((START + 1))"
David Bainbridge0774b232019-08-02 06:37:19 +0000425 done
David Bainbridged18f4942020-04-14 16:46:13 -0700426 DELTA="$((START - 81))"
David Bainbridgea2595422019-10-22 03:54:28 +0000427 ONOS_API_PORT=${ONOS_API_PORT:-${START}81}
428 ONOS_SSH_PORT=${ONOS_SSH_PORT:-${START}01}
David Bainbridged18f4942020-04-14 16:46:13 -0700429 VOLTHA_API_PORT=${VOLTHA_API_PORT:-5$((55 + DELTA))55}
430 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$((50 + DELTA))22}
431 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$((23 + DELTA))79}
432 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$((90 + DELTA))92}
Matteo Scandoloefee0432020-05-05 13:56:20 -0700433 VOLTHA_PPROF_PORT=${VOLTHA_PPROF_PORT:-$((60 + DELTA))60}
434 OPENOLT_PPROF_PORT=${OPENOLT_PPROF_PORT:-$((60 + DELTA))61}
Matteo Scandolo65c35192020-05-13 10:41:21 -0700435 OFAGENT_PPROF_PORT=${OFAGENT_PPROF_PORT:-$((60 + DELTA))62}
Test User01ed0642019-07-03 20:17:06 +0000436else
David Bainbridged18f4942020-04-14 16:46:13 -0700437 VALUES="$(echo "$HAVE" | sed -e 's/\s//g' | cut -d= -f2)"
438 ONOS_API_PORT=${ONOS_API_PORT:-$(echo "$VALUES" | cut -d, -f1)}
439 ONOS_SSH_PORT=${ONOS_SSH_PORT:-$(echo "$VALUES" | cut -d, -f2)}
440 VOLTHA_API_PORT=${VOLTHA_API_PORT:-$(echo "$VALUES" | cut -d, -f3)}
441 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$(echo "$VALUES" | cut -d, -f4)}
442 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$(echo "$VALUES" | cut -d, -f5)}
443 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(echo "$VALUES" | cut -d, -f6)}
Matteo Scandoloefee0432020-05-05 13:56:20 -0700444 VOLTHA_PPROF_PORT=${VOLTHA_PPROF_PORT:-$(echo "$VALUES" | cut -d, -f7)}
445 OPENOLT_PPROF_PORT=${OPENOLT_PPROF_PORT:-$(echo "$VALUES" | cut -d, -f8)}
Matteo Scandolo65c35192020-05-13 10:41:21 -0700446 OFAGENT_PPROF_PORT=${OFAGENT_PPROF_PORT:-$(echo "$VALUES" | cut -d, -f9)}
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800447
Matteo Scandoloefee0432020-05-05 13:56:20 -0700448 # Some ports were added after the .voltha/ports files was created.
449 # Calculate the original DELTA from the VOLTHA_SSH_PORT so that it can
450 # be used to set up newer port-forwards.
451 DELTA="$((VOLTHA_SSH_PORT/100-50))"
452
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800453 if [ -z "$VOLTHA_KAFKA_PORT" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -0700454 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$((90 + DELTA))92}
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800455 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -0700456
457 if [ -z "$VOLTHA_PPROF_PORT" ]; then
458 VOLTHA_PPROF_PORT=${VOLTHA_PPROF_PORT:-$((60 + DELTA))60}
459 fi
460 if [ -z "$OPENOLT_PPROF_PORT" ]; then
461 OPENOLT_PPROF_PORT=${OPENOLT_PPROF_PORT:-$((60 + DELTA))61}
462 fi
Matteo Scandolo65c35192020-05-13 10:41:21 -0700463 if [ -z "$OFAGENT_PPROF_PORT" ]; then
464 OFAGENT_PPROF_PORT=${OFAGENT_PPROF_PORT:-$((60 + DELTA))62}
465 fi
Test User01ed0642019-07-03 20:17:06 +0000466fi
467
David Bainbridged18f4942020-04-14 16:46:13 -0700468PORTTMP="$(mktemp -u)"
469grep -v "$NAME" .voltha/ports > "$PORTTMP"
Matteo Scandolo65c35192020-05-13 10:41:21 -0700470echo "$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 -0700471cp "$PORTTMP" .voltha/ports
472rm -f "$PORTTMP"
David Bainbridge0774b232019-08-02 06:37:19 +0000473
David Bainbridge27790d62019-08-13 22:43:19 +0000474export ONOS_API_PORT ONOS_SSH_PORT
David Bainbridge01294952019-07-30 19:33:45 +0000475
Test Userd87942b2019-07-03 07:20:24 +0000476IDX=1
David Bainbridgee87067b2019-08-12 22:00:12 +0000477CLOCK="TIME:"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000478SPIN_PARTS=
479NOT_VERIFIED=
David Bainbridgef858a022019-08-14 21:25:11 +0000480THEX=
481BUILD=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000482VERIFIED=
483HELM=
484OLD_KEY=
485BIRD=
486HIGH_VOLTAGE=
487PLUG=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000488FORWARD=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000489GO=
490DOWNLOAD=
491GEAR=
492NO_ENTRY=
493LOCK=
494
David Bainbridged18f4942020-04-14 16:46:13 -0700495if [ "$FANCY" -eq 1 ]; then
496 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 +0000497 CLOCK="\xe2\x8f\xb1"
David Bainbridgef858a022019-08-14 21:25:11 +0000498 THEX="${RED}${BOLD}\xe2\x9c\x97\x20${NORMAL}"
David Bainbridgef858a022019-08-14 21:25:11 +0000499 BUILD="${YELLOW}${BOLD}\xf0\x9f\x8f\x97${NORMAL}"
500 NOT_VERIFIED="$BUILD"
501 VERIFIED="${GREEN}${BOLD}\xe2\x9c\x93\x20${NORMAL}"
502 HELM="${BLUE}${BOLD}\xE2\x8E\x88${NORMAL}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000503 OLD_KEY="\xF0\x9F\x97\x9D"
504 BIRD="\xF0\x9F\x90\xA6"
505 HIGH_VOLTAGE="\xE2\x9A\xA1"
506 PLUG="\xF0\x9F\xa7\xa9"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000507 FORWARD="\xE2\x87\xA8"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000508 GO="\xf0\x9f\x9a\x80"
509 DOWNLOAD="\xf0\x9f\x93\xa5"
510 GEAR="\xe2\x9a\x99"
511 NO_ENTRY="\xe2\x9b\x94"
512 LOCK="\xf0\x9f\x94\x92"
513fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700514
David Bainbridge712afb82019-08-14 19:55:58 +0000515duration() {
David Bainbridged18f4942020-04-14 16:46:13 -0700516 local h m s t
517 h="$(($1 / 3600))"
518 m="$(($1 % 3600 / 60))"
519 s="$(($1 % 60))"
520 t=""
David Bainbridgee87067b2019-08-12 22:00:12 +0000521
David Bainbridged18f4942020-04-14 16:46:13 -0700522 if [ "$h" -gt 0 ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +0000523 t="$t${h}h"
524 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700525 if [ "$m" -gt 0 ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +0000526 t="$t${m}m"
527 fi
David Bainbridge712afb82019-08-14 19:55:58 +0000528 echo "$t${s}s"
529}
530
531printtime() {
David Bainbridged18f4942020-04-14 16:46:13 -0700532 local INDENT
David Bainbridge712afb82019-08-14 19:55:58 +0000533 if [ "$1" == "-" ]; then
534 INDENT=" "
535 shift
536 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700537 echo -e "$INDENT $CLOCK $(duration "$1")"
David Bainbridgee87067b2019-08-12 22:00:12 +0000538}
539
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700540bspin() {
Test Userd87942b2019-07-03 07:20:24 +0000541 IDX=1
David Bainbridged18f4942020-04-14 16:46:13 -0700542 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700543 if [ "$1" == "-" ]; then
544 INDENT=" "
545 shift
546 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700547 if [ "$FANCY" -eq 0 ]; then
548 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000549 if [ "$LINE X" == " X" ]; then
550 return
551 fi
552 echo -e "$CIVIS$INDENT$*"
553 else
554 echo -en "$CIVIS$INDENT $*"
555 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700556}
557
558sspin() {
David Bainbridged18f4942020-04-14 16:46:13 -0700559 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700560 if [ "$1" == "-" ]; then
561 INDENT=" "
562 shift
563 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700564 if [ "$FANCY" -eq 0 ]; then
565 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000566 if [ "$LINE X" == " X" ]; then
567 return
568 fi
569 echo -e "$INDENT$*"
570 else
David Bainbridged18f4942020-04-14 16:46:13 -0700571 C="$(echo "$SPIN_PARTS" | cut '-d ' -f "$IDX")"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000572 echo -en "\r$INDENT$C $*"
David Bainbridged18f4942020-04-14 16:46:13 -0700573 IDX="$((IDX + 1))"
574 if [ "$IDX" -gt 8 ]; then
David Bainbridge38dc1e82019-08-12 15:18:45 +0000575 IDX=1
576 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700577 fi
578}
579
580espin() {
David Bainbridged18f4942020-04-14 16:46:13 -0700581 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700582 if [ "$1" == "-" ]; then
583 INDENT=" "
584 shift
585 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700586 if [ "$FANCY" -eq 0 ]; then
587 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000588 if [ "$LINE X" == " X" ]; then
589 return
590 fi
591 echo -e "$INDENT$*"
592 else
593 echo -e "\r$INDENT$*$CNORM"
594 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700595}
596
David Bainbridged18f4942020-04-14 16:46:13 -0700597if [ "$1" == "get" ] && [ "$2" == "voltconfig" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000598 echo "$HOME/.volt/config-$NAME"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000599 exit
600fi
601
David Bainbridgee4d11ca2020-05-08 10:21:10 -0700602if [ $# -ne 1 ] || ! is_in "$1" "up,down,dump,clean"; then
David Bainbridgeac7f8072019-08-01 22:15:33 +0000603 >&2 echo "What wouild you like to do today:"
604 >&2 echo " up - bring up voltha"
605 >&2 echo " down - tear down voltha"
606 >&2 echo " dump - create a debug dump of running system"
607 exit 1
608fi
609
David Bainbridge4f1b5562019-08-19 04:46:52 +0000610push_onos_config() {
David Bainbridged18f4942020-04-14 16:46:13 -0700611 local TYPE MSG RESOURCE DATA CMD_ECHO CMD_OUTPUT SC_OUTPUT WAIT_START NOW
612 TYPE=$1
613 MSG=$2
614 RESOURCE=$3
615 DATA=$4
David Bainbridge4f1b5562019-08-19 04:46:52 +0000616
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800617 # Thanks to the latest version of ONOS using the return code 207 this gets a
618 # whole lot nastier. Can't thank them enough for doing this. So in order to
619 # capture the command and the output in the log file as well as capture the
620 # status code to verify it is 200 and not 207 mutltiple files and a bit of
621 # hackery must be used. Thanks again ONOS.
David Bainbridged18f4942020-04-14 16:46:13 -0700622 CMD_ECHO="$(mktemp -u)"
623 CMD_OUTPUT="$(mktemp -u)"
624 SC_OUTPUT="$(mktemp -u)"
625 WAIT_START="$(date +%s)"
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800626
David Bainbridge4f1b5562019-08-19 04:46:52 +0000627 bspin - "$MSG $GEAR"
628 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700629 NOW="$(date +%s)"
630 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700631 espin - "$THEX"
David Bainbridged18f4942020-04-14 16:46:13 -0700632 rm -f "$CMD_ECHO" "$CMD_OUTPUT" "$SC_OUTPUT"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700633 doTimeout "waiting for ONOS config push on $RESOURCE"
634 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700635 if [ "$TYPE" == "file" ]; then
636 (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 -0700637 RESULT=$?
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800638 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700639 if [ "$TYPE" == "json" ]; then
640 (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 -0700641 RESULT=$?
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800642 fi
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800643 # Dump everything to the log
David Bainbridged18f4942020-04-14 16:46:13 -0700644 cat "$CMD_ECHO" >> "$LOG"
645 test -r "$CMD_OUTPUT" && cat "$CMD_OUTPUT" >> "$LOG"
646 SC="$(cat "$SC_OUTPUT")"
647 echo "RESPONSE CODE: $SC" >> "$LOG"
648 echo "ERROR CODE: $RESULT" >> "$LOG"
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800649
650 # clean up temp files
David Bainbridged18f4942020-04-14 16:46:13 -0700651 rm -f "$CMD_ECHO" "$CMD_OUTPUT" "$SC_OUTPUT"
652 if [ "$RESULT" -eq 0 ] && [ "$SC" == "200" ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000653 break
654 fi
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800655 sleep 1
David Bainbridge4f1b5562019-08-19 04:46:52 +0000656 sspin -
657 done
David Bainbridged18f4942020-04-14 16:46:13 -0700658 espin - "$VERIFIED"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000659}
660
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800661check_onos_app_active() {
David Bainbridged18f4942020-04-14 16:46:13 -0700662 local APP_ID WAIT_START RESULT NOW
663 APP_ID=$1
664 WAIT_START="$(date +%s)"
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800665
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700666 bspin - "Checking that $APP_ID is active $CLOCK"
667 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700668 NOW="$(date +%s)"
669 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700670 espin - "$THEX"
671 doTimeout "waiting for ONOS application activation '$APP_ID'"
672 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700673 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 -0700674 break
675 fi
676 sleep 1
677 sspin -
678 done
679 sleep 5 # OSGI components take a little longer that the app to activate
David Bainbridged18f4942020-04-14 16:46:13 -0700680 espin - "$VERIFIED"
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800681}
682
David Bainbridge4f1b5562019-08-19 04:46:52 +0000683override_onos_app() {
David Bainbridged18f4942020-04-14 16:46:13 -0700684 local APP NAME WAIT_START NOW
685 APP=$1
686 NAME="$(basename "$APP" | sed -e 's/^[0-9][0-9]*-//g' -e 's/-.*$//g')"
687 WAIT_START="$(date +%s)"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700688
David Bainbridge4f1b5562019-08-19 04:46:52 +0000689 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700690 NOW="$(date +%s)"
691 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700692 espin - "$THEX"
693 doTimeout "waiting to overwrite ONOS application '$APP'"
694 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +0000695 sspin -
696 # Attempt to delete old version (if it exists)
David Bainbridged18f4942020-04-14 16:46:13 -0700697 (set -x; curl --fail -sSL --user karaf:karaf -X DELETE "http://$_ONOS_API_EP/onos/v1/applications/$NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
698 RESULT=$?
David Bainbridge4f1b5562019-08-19 04:46:52 +0000699 sspin -
David Bainbridged18f4942020-04-14 16:46:13 -0700700 if [ $RESULT -ne 0 ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000701 continue
702 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700703 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 +0000704 break
705 fi
706 sleep .2
707 done
708}
709
710activate_onos_app() {
David Bainbridged18f4942020-04-14 16:46:13 -0700711 local MSG APP WAIT_START NOW
712 MSG="$1"
713 APP=$2
714 WAIT_START="$(date +%s)"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000715
716 bspin - "$MSG $GO"
717 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700718 NOW="$(date +%s)"
719 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700720 espin - "$THEX"
721 doTimeout "waiting to activate ONOS application '$APP'"
722 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +0000723 sspin -
David Bainbridged18f4942020-04-14 16:46:13 -0700724 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 +0000725 break
726 fi
727 sleep .2
728 done
729 espin - "$VERIFIED"
730}
731
732count_pods() {
David Bainbridged18f4942020-04-14 16:46:13 -0700733 local NAMESPACE STATES LABELS CMD PODS
734 NAMESPACE=$1; shift
David Bainbridge4f1b5562019-08-19 04:46:52 +0000735 if [ "$NAMESPACE" == "all-namespaces" ]; then
736 NAMESPACE="--all-namespaces"
737 else
738 NAMESPACE="-n $NAMESPACE"
739 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700740 STATES=$1; shift
741 LABELS=$1; shift
742 CMD=("kubectl get $NAMESPACE $LABELS pod")
743 PODS=$(${CMD[*]} -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}")
David Bainbridge4f1b5562019-08-19 04:46:52 +0000744 local COUNT=0
745 local PATTERNS="$*"
746 for POD in $PODS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700747 local NAME STATE CONTAINERS TOTAL FOUND
748 NAME="$(echo "$POD" | cut -d/ -f 1)"
749 STATE="$(echo "$POD" | cut -d/ -f 2)"
750 CONTAINERS="$(echo "$POD" | cut -d/ -f 3 | sed -e 's/_/ /g')"
751 if [ "$STATES" == "*" ] || [ "$(echo "$STATES" | grep -c ":$STATE:")" -ne 0 ]; then
752 TOTAL="$(echo "$CONTAINERS" | wc -w)"
753 FOUND="$(echo "$CONTAINERS" | grep -o true | wc -l)"
754 if [ "$TOTAL" -eq "$FOUND" ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000755 for PATTERN in $PATTERNS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700756 if [[ "$NAME" =~ $PATTERN ]]; then
757 COUNT="$((COUNT + 1))"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000758 break
759 fi
760 done
761 fi
762 fi
763 done
David Bainbridge4f1b5562019-08-19 04:46:52 +0000764 echo $COUNT
765}
766
767wait_for_pods() {
David Bainbridged18f4942020-04-14 16:46:13 -0700768 local INDENT NAMESPACE EXPECT TYPE MESSAGE LABELS PATTERNS STATES HAVE ALL WAIT_START NOW
David Bainbridge4f1b5562019-08-19 04:46:52 +0000769 if [ "$1" == "-" ]; then
770 INDENT=$1; shift
771 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700772 NAMESPACE=$1; shift
773 EXPECT=$1; shift
774 TYPE=$1; shift
775 MESSAGE=$1; shift
776 LABELS=$1; shift
777 PATTERNS=("$*")
778 STATES=":Running:"
David Bainbridge99ac7a22019-08-31 02:26:43 +0000779 if [ "$TYPE" == "not" ]; then
780 STATES="*"
781 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700782 HAVE="$(count_pods "$NAMESPACE" "$STATES" "$LABELS" "${PATTERNS[@]}")"
783 ALL=$HAVE
David Bainbridge4f1b5562019-08-19 04:46:52 +0000784 if [ "$TYPE" == "only" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -0700785 ALL="$(count_pods "all-namespaces" "*" ".*")"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000786 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700787 COUNT="$((300 / 15))"
788 WAIT_START="$(date +%s)"
789 bspin "$INDENT" "$MESSAGE"
790 sspin "$INDENT"
791 if [ "$HAVE" -ne "$EXPECT" ] || [ "$ALL" -ne "$HAVE" ]; then
792 while [ "$HAVE" -ne "$EXPECT" ] || [ "$ALL" -ne "$HAVE" ]; do
793 NOW="$(date +%s)"
794 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
795 espin "$INDENT" "$THEX"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700796 doTimeout "waiting for PODs to start"
797 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700798 sspin "$INDENT"
799 COUNT="$((COUNT - 1))"
800 if [ "$COUNT" -eq 0 ]; then
801 HAVE="$(count_pods "$NAMESPACE" "$STATES" "$LABELS" "${PATTERNS[@]}")"
802 ALL="$HAVE"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000803 if [ "$TYPE" == "only" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -0700804 ALL="$(count_pods "all-namespaces" "*" ".*")"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000805 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700806 COUNT="$((300 / 15))"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000807 fi
808 sleep .15
809 done
810 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700811 espin "$INDENT" "$VERIFIED"
812 if [ "$HAVE" -ne "$EXPECT" ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000813 return 1
814 fi
815 return 0
816}
817
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800818port_forward() {
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700819 local NS=$1; shift
820 local SVC=$1; shift
821 local PORTS="$*"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800822 local TAG=$SVC-$NAME
823
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700824 (set -x; _TAG="$TAG" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n $NS service/$SVC $PORTS; done" >>"$LOG" 2>&1 &) >>"$LOG" 2>&1
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800825}
826
827kill_port_forward() {
David Bainbridged18f4942020-04-14 16:46:13 -0700828 local TAG P_IDS PARENTS KIDS UNKNOWN PP_ID
David Bainbridgee4d11ca2020-05-08 10:21:10 -0700829 TAG=
830 if [ "$1" != "__ALL__" ]; then
831 TAG="$1-$NAME"
832 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700833 # shellcheck disable=SC2009
834 P_IDS="$(ps e -ww -A | grep "_TAG=$TAG" | grep -v grep | awk '{print $1}')"
835 if [ -n "$P_IDS" ]; then
David Bainbridgec6871d22019-11-13 17:10:31 +0000836 for P_ID in $P_IDS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700837 PP_ID="$(ps -o ppid "$P_ID" | tail -n +2)"
838 if [ -n "$PP_ID" ]; then
839 if [ "$PP_ID" -eq 1 ]; then
David Bainbridgec6871d22019-11-13 17:10:31 +0000840 PARENTS="$PARENTS $P_ID"
841 else
842 KIDS="$KIDS $P_ID"
843 fi
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800844 else
David Bainbridgec6871d22019-11-13 17:10:31 +0000845 UNKNOWN="$UNKNOWN $P_ID"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800846 fi
847 done
David Bainbridgee4d11ca2020-05-08 10:21:10 -0700848 (set -x; eval "kill -9 $PARENTS $KIDS $UNKNOWN" >>"$LOG" 2>&1) >>"$LOG" 2>&1
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800849 fi
850}
851
David Bainbridgecf546362020-04-21 23:18:50 -0700852resolve_chart_version() {
853 [ "$2" != "latest" ] && echo "$2" && return
854 helm inspect chart "$1" | grep "^version:" | awk '{print $2}'
855}
856
Jonathan Hart6a91e6c2020-04-16 14:28:33 -0700857# Compares two semver-formatted version strings (e.g. 2.4.3)
858# Returns 0 if $1 == $2, returns 1 if $1 > $2 and returns 2 if $1 < $2
859compare_versions() {
860 [ "$1" == "$2" ] && return 0
Jonathan Hart6a91e6c2020-04-16 14:28:33 -0700861 local lowest
862 lowest=$(echo -e "$1\n$2" | sort -V | head -1)
863 [ "$lowest" == "$1" ] && return 2
864 return 1
865}
866
David Bainbridgeac7f8072019-08-01 22:15:33 +0000867if [ "$1" == "down" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000868 echo "Tearing down voltha cluster $NAME"
869 LOG="down-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -0700870 date -u +"%Y%m%dT%H%M%SZ" >"$LOG"
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700871 if is_in "$WITH_ONOS" "yes,legacy,classic"; then
David Bainbridge696bc632020-04-05 21:49:37 -0700872 bspin "Remove port-forwards: onos-ui-$NAME"
873 kill_port_forward onos-ui
874 sspin "Remove port-forwards: onos-ssh-$NAME$CEOL"
875 kill_port_forward onos-ssh
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700876 bspin "Remove port-forwards: onos-onos-classic-hs-$NAME$CEOL"
877 kill_port_forward onos-onos-classic-hs
David Bainbridge696bc632020-04-05 21:49:37 -0700878 fi
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800879 sspin "Remove port-forwards: voltha-api-$NAME$CEOL"
880 kill_port_forward voltha-api
David Bainbridged18f4942020-04-14 16:46:13 -0700881 if [ "$WITH_ETCD" == "yes" ] || [ "$WITH_ETCD" == "external" ]; then
882 sspin "Remove port-forwards: ${ETCD_PREFIX}etcd-$NAME$CEOL"
883 kill_port_forward "${ETCD_PREFIX}etcd-cluster-client"
David Bainbridge696bc632020-04-05 21:49:37 -0700884 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700885 if [ "$WITH_KAFKA" == "yes" ] || [ "$WITH_KAFKA" == "external" ]; then
886 sspin "Remove port-forwards: ${KAFKA_PREFIX}kafka-$NAME$CEOL"
887 kill_port_forward "${KAFKA_PREFIX}kafka"
David Bainbridge696bc632020-04-05 21:49:37 -0700888 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -0700889
890 if [ "$WITH_PPROF" == "yes" ]; then
891 sspin "Remove port-forwards: *-profiler$CEOL"
892 kill_port_forward voltha-rw-core-profiler
893 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
894 kill_port_forward adapter-open-olt-profiler
895 fi
896 fi
897
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800898 espin "$VERIFIED Remove port-forwards$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -0700899 if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridgeac7f8072019-08-01 22:15:33 +0000900 if [ -x ./bin/kind ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000901 bspin "Delete Kubernetes Kind Cluster"
David Bainbridged18f4942020-04-14 16:46:13 -0700902 (set -x; ./bin/kind delete cluster --name "voltha-$NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
903 espin "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000904 else
David Bainbridge0774b232019-08-02 06:37:19 +0000905 espin "$NO_ENTRY Delete Kubernetes Kind Cluster: kind command not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000906 fi
907 else
David Bainbridge309099c2020-05-05 08:47:29 -0700908 if [ "$CONFIG_SADIS" == "external" ]; then
909 bspin "Remove configmap for BBSIM SADIS server"
910 (set -x; kubectl -n "$BBSIM_NS" delete --ignore-not-found configmap kube-config >>"$LOG" 2>&1) >>"$LOG" 2>&1
911 espin "$VERIFIED"
912 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700913 EXISTS="$(helm list -q)"
David Bainbridge76afd812020-04-06 09:53:52 -0700914 EXPECT="voltha"
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700915 if is_in "$WITH_ONOS" "yes,legacy,classic"; then
David Bainbridge696bc632020-04-05 21:49:37 -0700916 EXPECT+=" onos"
917 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700918 if [ "$WITH_RADIUS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700919 EXPECT+=" radius"
920 fi
David Bainbridge309099c2020-05-05 08:47:29 -0700921 if [ "$CONFIG_SADIS" == "external" ]; then
922 EXPECT+=" bbsim-sadis-server"
923 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700924 if [ "$WITH_BBSIM" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700925 EXPECT+=" bbsim"
926 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700927 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700928 EXPECT+=" open-olt open-onu"
929 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700930 if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700931 EXPECT+=" sim"
932 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700933 if [ "$WITH_ETCD" == "external" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700934 EXPECT+=" etcd-operator etcd-cluster"
David Bainbridged18f4942020-04-14 16:46:13 -0700935 elif [ "$WITH_ETCD" == "yes" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700936 EXPECT+=" etcd-operator"
937 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700938 if [ "$WITH_KAFKA" == "external" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700939 EXPECT+=" kafka"
940 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000941 bspin "Remove Helm Deployments"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000942 for i in $EXISTS; do
David K. Bainbridge43422402020-03-06 07:41:22 -0800943 for j in $EXPECT; do
David Bainbridged18f4942020-04-14 16:46:13 -0700944 if [[ "$i" =~ $j ]]; then
David K. Bainbridge43422402020-03-06 07:41:22 -0800945 sspin "Remove Helm Deployments: $i$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -0700946 (set -x; ./bin/helm delete --no-hooks --purge "$i" >>"$LOG" 2>&1) >>"$LOG" 2>&1
David K. Bainbridge43422402020-03-06 07:41:22 -0800947 fi
948 done
uottrembb16d3982020-02-28 08:34:36 +0100949 done
David Bainbridge0774b232019-08-02 06:37:19 +0000950 espin "$VERIFIED Remove Helm Deployments$CEOL"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000951 if [ "$WAIT_ON_DOWN" == "yes" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700952 PODS="voltha-kafka.* voltha-ofagent.* voltha-rw-core.* voltha-etcd.*"
953 INFRA_PODS=
954 ADAPT_PODS=
955 SIM_PODS=
David Bainbridged18f4942020-04-14 16:46:13 -0700956 if [ "$WITH_RADIUS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700957 PODS+=" radius.*"
958 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700959 if [ "$WITH_BBSIM" == "yes" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700960 SIM_PODS+=" bbsim.*"
David Bainbridge696bc632020-04-05 21:49:37 -0700961 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700962 if [ "$WITH_OPEN_ADAPTERS" ] || [ "$WITH_SIM_ADAPTERS" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700963 ADAPT_PODS+=" adapter-*"
David Bainbridge696bc632020-04-05 21:49:37 -0700964 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700965 if is_in "$WITH_ONOS" "yes,legacy,classic"; then
David Bainbridge76afd812020-04-06 09:53:52 -0700966 INFRA_PODS+=" onos-.*"
967 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700968 if [ "$WITH_ETCD" == "external" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700969 INFRA_PODS+=" etcd-operator.* etcd-cluster.*"
David Bainbridged18f4942020-04-14 16:46:13 -0700970 elif [ "$WITH_ETCD" == "yes" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700971 PODS+=" etcd-operator.*"
972 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700973 if [ "$WITH_KAFKA" == "external" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700974 INFRA_PODS+=" kafka.*"
975 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700976 if [ -n "$SIM_PODS" ]; then
977 wait_for_pods "$BBSIM_NS" 0 "not" "Waiting for BBSIM PODs to terminate" "$BBSIM_LABEL" "$SIM_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -0700978 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700979 if [ -n "$INFRA_PODS" ]; then
980 wait_for_pods "$INFRA_NS" 0 "not" "Waiting for infrastructure PODs to terminate" "$NO_LABEL" "$INFRA_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -0700981 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700982 if [ -n "$ADAPT_PODS" ]; then
983 wait_for_pods "$ADAPTER_NS" 0 "not" "Waiting for adapter PODs to terminate" "$NO_LABEL" "$ADAPT_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -0700984 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700985 wait_for_pods "$VOLTHA_NS" 0 "not" "Waiting for VOLTHA PODs to terminate" "$NO_LABEL" "$PODS"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000986 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +0000987 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -0700988 exit
David Bainbridgeac7f8072019-08-01 22:15:33 +0000989fi
990
991if [ "$1" == "dump" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000992 LOG="dump-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -0700993 TS="$(date -u +"%Y%m%dT%H%M%SZ")"
994 if [ -n "$DUMP_FROM" ]; then
995 TS=${DUMP_FROM//[:-]}
David Bainbridge76514a02019-10-08 01:50:35 +0000996 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700997 WORK="$(mktemp -u -d)"
David Bainbridge0774b232019-08-02 06:37:19 +0000998 DATA=$WORK/voltha-debug-dump-$NAME-$TS
David Bainbridged18f4942020-04-14 16:46:13 -0700999 mkdir -p "$DATA"
1000 echo "$TS" > "$LOG"
David Bainbridge0774b232019-08-02 06:37:19 +00001001 echo -e "Capturing debug dump to voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001002 bspin - "Copy install log"
David Bainbridged18f4942020-04-14 16:46:13 -07001003 if [ -f "install-$NAME.log" ]; then
1004 (set -x; cp "install-$NAME.log" "$DATA/install-$NAME.log") >>"$LOG" 2>&1
1005 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001006 else
David Bainbridge0774b232019-08-02 06:37:19 +00001007 espin - "$NO_ENTRY Copy install log: install-$NAME.log not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001008 fi
1009 bspin - "Dumping Kubernetes PODs"
David Bainbridged18f4942020-04-14 16:46:13 -07001010 (set -x; kubectl get --all-namespaces pods >> "$DATA/all-pods.txt" 2>&1) >>"$LOG" 2>&1
1011 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001012 bspin - "Dumping Kubernetes SERVICEs"
David Bainbridged18f4942020-04-14 16:46:13 -07001013 (set -x; kubectl get --all-namespaces svc >> "$DATA/all-services.txt" 2>&1) >>"$LOG" 2>&1
1014 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001015 bspin - "Dumping Kubernetes EVENTs"
David Bainbridged18f4942020-04-14 16:46:13 -07001016 (set -x; kubectl get --all-namespaces events >> "$DATA/all-events.txt" 2>&1) >>"$LOG" 2>&1
1017 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001018 bspin - "Dumping VOLTHA POD details"
David Bainbridged18f4942020-04-14 16:46:13 -07001019 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 +00001020 SINCE=
David Bainbridged18f4942020-04-14 16:46:13 -07001021 if [ -n "$DUMP_FROM" ]; then
David Bainbridgecfd7ca12019-10-06 03:31:41 +00001022 SINCE="--since-time=$DUMP_FROM"
1023 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +00001024 for POD in $PODS; do
David Bainbridged18f4942020-04-14 16:46:13 -07001025 NS="$(echo "$POD" | cut -d: -f1)"
1026 POD="$(echo "$POD" | cut -d: -f2)"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001027 sspin - "Dumping VOLTHA POD details: $POD$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -07001028 mkdir -p "$DATA/$POD"
1029 (set -x; kubectl describe -n "$NS" "$POD" >> "$DATA/$POD/describe.txt" 2>&1) >>"$LOG" 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +00001030 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridged18f4942020-04-14 16:46:13 -07001031 (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 +00001032 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridged18f4942020-04-14 16:46:13 -07001033 (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 +00001034 sspin - "Dumping VOLTHA POD details: $POD"
1035 done
1036 espin - "$VERIFIED Dumping VOLTHA POD details$CEOL"
1037 bspin - "Dumping ETCD"
David Bainbridged18f4942020-04-14 16:46:13 -07001038 if [ -n "$(command -v etcdctl)" ]; then
1039 (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
1040 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001041 else
1042 espin - "$NO_ENTRY Dumping ETCD: etcdctl command not available"
1043 fi
David Bainbridge0774b232019-08-02 06:37:19 +00001044 bspin - "Creating compressed TAR: voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridged18f4942020-04-14 16:46:13 -07001045 (set -x; tar -C "$WORK" -zcf "voltha-debug-dump-$NAME-$TS.tgz" "./voltha-debug-dump-$NAME-$TS") >>"$LOG" 2>&1
1046 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001047 bspin - "Cleanup"
David Bainbridged18f4942020-04-14 16:46:13 -07001048 (set -x; rm -rf "$WORK") >>"$LOG" 2>&1
1049 espin - "$VERIFIED"
1050 bspin - "$(ls -l "voltha-debug-dump-$NAME-$TS.tgz")"
1051 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001052 exit
1053fi
1054
David Bainbridge0774b232019-08-02 06:37:19 +00001055LOG="install-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -07001056date > "$LOG"
1057echo "PORTS=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT" >> "$LOG"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001058
1059# Output install options to log
David Bainbridged18f4942020-04-14 16:46:13 -07001060echo "OPTIONS" >> "$LOG"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001061for O in $ALL_OPTIONS; do
David Bainbridged18f4942020-04-14 16:46:13 -07001062 VAL="$(eval echo "\$$O")"
1063 if [ -n "$VAL" ]; then
1064 printf " %-30s = %s\n" "$O" "$VAL" >> "$LOG"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001065 fi
1066done
1067
David Bainbridgee4d11ca2020-05-08 10:21:10 -07001068# Force remove any existing k8s port-forward processes. This will
1069# remove them for all kind clusters.
1070# DKB
1071if [ "$1" == "clean" ]; then
1072 kill_port_forward __ALL__
1073 exit
1074fi
1075
David Bainbridgefad50732020-05-01 17:00:12 -07001076helm_values() {
1077 local NAMESPACE=$1; shift
1078 local INAME=$1; shift
1079 local CHART=$1; shift
1080 local CHART_VERSION=$1; shift
1081
1082 if [ "$CHART_VERSION X" != " X" ] && [ "$CHART_VERSION" != "latest" ]; then
1083 CHART_VERSION="--version $CHART_VERSION"
1084 else
1085 CHART_VERSION=
1086 fi
1087
1088 local CHART_ARGS=
1089 if [ -r "${INAME}-values.yaml" ]; then
1090 CHART_ARGS="-f ${INAME}-values.yaml"
1091 fi
1092
1093 if [ "$HELM_USE_UPGRADE" == "yes" ]; then
1094 _HELM_COMMAND="upgrade --install"
1095 _HELM_ARGS="xxxdryrunxxx"
1096 else
1097 _HELM_COMMAND="install"
1098 _HELM_ARGS="--name xxxdryrunxxx"
1099 fi
1100 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")
1101 ${CMD[*]} 2>/dev/null | awk 'PRINT==1 {print}; /^USER-SUPPLIED VALUES:/ {PRINT = 1}; /^$/ {PRINT = 0}'
1102}
1103
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001104helm_install() {
David Bainbridged18f4942020-04-14 16:46:13 -07001105 local INDENT NOW
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001106 if [ "$1" == "-" ]; then
1107 INDENT=$1; shift
1108 fi
1109 local NAMESPACE=$1; shift
David Bainbridge0774b232019-08-02 06:37:19 +00001110 local INAME=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001111 local CHART=$1; shift
David Bainbridge90fd8e32019-08-21 23:32:47 +00001112 local CHART_VERSION=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001113 local MESSAGE=$*
1114
David Bainbridged18f4942020-04-14 16:46:13 -07001115 if [ "$CHART_VERSION X" != " X" ] && [ "$CHART_VERSION" != "latest" ]; then
David Bainbridge90fd8e32019-08-21 23:32:47 +00001116 CHART_VERSION="--version $CHART_VERSION"
1117 else
1118 CHART_VERSION=
1119 fi
1120
David Bainbridge99ac7a22019-08-31 02:26:43 +00001121 local CHART_ARGS=
1122 if [ -r "${INAME}-values.yaml" ]; then
1123 CHART_ARGS="-f ${INAME}-values.yaml"
1124 fi
1125
David Bainbridged18f4942020-04-14 16:46:13 -07001126 local WAIT_START CMD
1127 WAIT_START="$(date +%s)"
1128 COUNT="$((300 / 15))"
1129 bspin "$INDENT" "$MESSAGE"
1130 if [ "$HELM_USE_UPGRADE" == "yes" ]; then
David Bainbridge7f8bf992020-04-08 21:53:22 -07001131 _HELM_COMMAND="upgrade --install"
1132 _HELM_ARGS="$INAME"
1133 else
1134 _HELM_COMMAND="install"
1135 _HELM_ARGS="--name $INAME"
1136 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001137 CMD=("helm $_HELM_COMMAND -f $NAME-values.yaml $CHART_ARGS $INTERNAL_EXTRA_HELM_INSTALL_ARGS $EXTRA_HELM_INSTALL_ARGS --set defaults.log_level=$VOLTHA_LOG_LEVEL --namespace $NAMESPACE $_HELM_ARGS $CHART_VERSION $EXTRA_HELM_FLAGS $CHART")
1138 (set -x; ${CMD[*]} >>"$LOG" 2>&1) >>"$LOG" 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001139 SUCCESS=$?
David Bainbridged18f4942020-04-14 16:46:13 -07001140 while [ "$SUCCESS" -ne 0 ]; do
1141 NOW="$(date +%s)"
1142 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -07001143 espin "$THEX"
1144 doTimeout "waiting for helm install $CHART"
1145 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001146 sspin "$INDENT"
1147 COUNT="$((COUNT - 1))"
1148 if [ "$COUNT" -eq 0 ]; then
1149 if [ "$HELM_USE_UPGRADE" == "no" ]; then
1150 (set -x; helm delete --purge "$INAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
David Bainbridge7f8bf992020-04-08 21:53:22 -07001151 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001152 (set -x; ${CMD[*]} >>"$LOG" 2>&1) >>"$LOG" 2>&1
Andy Baviere22ff252019-12-19 11:40:31 -07001153 SUCCESS=$?
David Bainbridged18f4942020-04-14 16:46:13 -07001154 COUNT="$((300 / 15))"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001155 fi
1156 sleep .15
1157 done
David Bainbridged18f4942020-04-14 16:46:13 -07001158 espin "$INDENT" "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001159}
1160
David Bainbridged18f4942020-04-14 16:46:13 -07001161echo "INSTALL TYPE: $TYPE" >> "$LOG"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001162
1163bspin "Verify GOPATH"
David Bainbridged18f4942020-04-14 16:46:13 -07001164GOPATH="$(pwd)"; export GOPATH
1165mkdir -p "$GOPATH/bin"
1166espin "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001167
David Bainbridged18f4942020-04-14 16:46:13 -07001168STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001169if [ "$INSTALL_KUBECTL" == "no" ]; then
1170 bspin "Skip kubectl install"
1171 espin $NO_ENTRY
Test Userc13bdc92019-07-03 20:57:49 +00001172else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001173 bspin "Verify kubectl $HELM"
David Bainbridged18f4942020-04-14 16:46:13 -07001174 if [ -x "$GOPATH/bin/kubectl" ]; then
1175 espin "$VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001176 else
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001177 ERR_OUT="$(mktemp)"
David Bainbridged18f4942020-04-14 16:46:13 -07001178 espin "$NOT_VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001179 bspin - "Download and install Kubernetes/kubectl $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001180 (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
1181 RESULT=$?
1182 if [ "$RESULT" -ne 0 ]; then
1183 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001184 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download kubectl: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001185 cat "$ERR_OUT" >> "$LOG"
Zack Williamsded60cb2020-04-13 10:02:20 -07001186 rm -rf "$ERR_OUT" "$GOPATH/bin/kubectl"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001187 exit 1
1188 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001189 (set -x; chmod 755 "$GOPATH/bin/kubectl" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1190 espin - "$VERIFIED"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001191 rm -rf "$ERR_OUT"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001192 fi
Test Userc13bdc92019-07-03 20:57:49 +00001193fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001194if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001195 NOW="$(date +%s)"
1196 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001197fi
Test Userc13bdc92019-07-03 20:57:49 +00001198
David Bainbridged18f4942020-04-14 16:46:13 -07001199STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001200if [ "$DEPLOY_K8S" == "no" ]; then
1201 bspin "Skip Kubernetes/Kind Deployment"
1202 espin $NO_ENTRY
1203else
Test Userba1e7e72019-07-10 22:27:54 +00001204 bspin "Verify Kubernetes/Kind $HELM"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001205 IS_INSTALLED=0
1206 OP_TYPE="install"
David Bainbridged18f4942020-04-14 16:46:13 -07001207 if [ -x "$GOPATH/bin/kind" ]; then
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001208 OP_TYPE="upgrade"
David Bainbridged18f4942020-04-14 16:46:13 -07001209 if [ "$("$GOPATH/bin/kind" --version | grep -c "$KIND_VERSION")" -eq 1 ]; then
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001210 IS_INSTALLED=1
David Bainbridged18f4942020-04-14 16:46:13 -07001211 espin "$VERIFIED"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001212 fi
1213 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001214 if [ "$IS_INSTALLED" -eq 0 ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001215 ERR_OUT="$(mktemp)"
David Bainbridged18f4942020-04-14 16:46:13 -07001216 espin "$NOT_VERIFIED"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001217 bspin - "Download and $OP_TYPE Kubernetes/kind $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001218 (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
1219 RESULT=$?
1220 if [ $RESULT -ne 0 ]; then
1221 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001222 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download kind: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001223 cat "$ERR_OUT" >> "$LOG"
Zack Williamsded60cb2020-04-13 10:02:20 -07001224 rm -rf "$ERR_OUT" "$GOPATH/bin/kind"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001225 exit 1
1226 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001227 (set -x; chmod 755 "$GOPATH/bin/kind" >>"$LOG" 2>&1) >>"$LOG" 2>&1
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001228 rm -rf "$ERR_OUT"
David Bainbridged18f4942020-04-14 16:46:13 -07001229 espin - "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001230 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001231fi
1232
David Bainbridgee87067b2019-08-12 22:00:12 +00001233if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001234 NOW="$(date +%s)"
1235 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001236fi
1237
David Bainbridged18f4942020-04-14 16:46:13 -07001238STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001239if [ "$INSTALL_HELM" == "no" ]; then
1240 bspin "Skip Helm Install"
1241 espin $NO_ENTRY
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001242else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001243 bspin "Verify Helm $HELM"
David Bainbridgea34993d2020-04-01 09:15:42 -07001244 HELM_UPGRADE=0
1245 HELM_UPGRADE_DESC="install"
David Bainbridged18f4942020-04-14 16:46:13 -07001246 if [ -x "$GOPATH/bin/helm" ]; then
1247 HAVE_VER="$("$GOPATH/bin/helm" version -c --template '{{.Client.SemVer}}')"
1248 HELM_UP_DOWN="$(echo -e "$HAVE_VER\n$HELM_VERSION" | sort -V | head -1)"
1249 if [ "$HAVE_VER" != "$HELM_VERSION" ]; then
1250 if [ "$HELM_UP_DOWN" == "$HELM_VERSION" ]; then
David Bainbridgea34993d2020-04-01 09:15:42 -07001251 HELM_UPGRADE_DESC="downgrade"
1252 else
1253 HELM_UPGRADE_DESC="upgrade"
1254 fi
1255 HELM_UPGRADE=1
1256 else
David Bainbridged18f4942020-04-14 16:46:13 -07001257 espin "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001258 fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001259 else
David Bainbridgea34993d2020-04-01 09:15:42 -07001260 HELM_UPGRADE=1
1261 fi
1262
David Bainbridged18f4942020-04-14 16:46:13 -07001263 if [ "$HELM_UPGRADE" -ne 0 ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001264 ERR_OUT="$(mktemp)"
1265 INSTALL_HELM_BIN=$(mktemp)
David Bainbridged18f4942020-04-14 16:46:13 -07001266 espin "$NOT_VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001267 bspin - "Download and $HELM_UPGRADE_DESC Helm $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001268 (set -x; curl -o "$INSTALL_HELM_BIN" --fail -sSL https://git.io/get_helm.sh >>"$LOG" 2>"$ERR_OUT") >>"$LOG" 2>&1
1269 RESULT=$?
1270 if [ $RESULT -ne 0 ]; then
1271 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001272 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download helm installer: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001273 cat "$ERR_OUT" >> "$LOG"
1274 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT" "$GOPATH/bin/helm" "$GOPATH/bin/tiller"
1275 exit 1
1276 fi
1277 rm -rf "$ERR_OUT"
1278 chmod +x "$INSTALL_HELM_BIN"
1279 (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
1280 RESULT=$?
1281 if [ $RESULT -ne 0 ]; then
1282 espin - "$THEX"
1283 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to install helm, see install log for details${NORMAL}"
1284 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT" "$GOPATH/bin/helm" "$GOPATH/bin/tiller"
1285 exit 1
1286 fi
1287 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT"
David Bainbridged18f4942020-04-14 16:46:13 -07001288 espin - "$VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001289 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001290fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001291if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001292 NOW="$(date +%s)"
1293 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001294fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001295
David Bainbridged18f4942020-04-14 16:46:13 -07001296STIME="$(date +%s)"
Test Userb5712372019-07-03 21:52:17 +00001297bspin "Verify voltctl $HIGH_VOLTAGE"
David Bainbridged2811972019-12-14 01:14:09 +00001298VOK=0
1299VMESSAGE="install"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001300ERR_OUT=$(mktemp)
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001301export VC_VERSION="$VOLTCTL_VERSION"
1302if [ "$VC_VERSION" == "latest" ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001303 set -o pipefail # TODO: would be nice to run all in pipefail mode
1304 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')"
1305 RESULT=$?
1306 set +o pipefail
1307 if [ "$RESULT" -ne 0 ]; then
1308 espin - "$THEX"
1309 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to determine released version of voltctl: $(cat "$ERR_OUT")${NORMAL}"
1310 rm -rf "$ERR_OUT" "$GOPATH/bin/voltctl"
1311 exit 1
1312 fi
1313 export VC_VERSION
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001314fi
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001315
David Bainbridged18f4942020-04-14 16:46:13 -07001316if [ -x "$GOPATH/bin/voltctl" ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001317 VHAVE="$("$GOPATH/bin/voltctl" version --clientonly -o json 2>/dev/null | jq -r .version)"
David Bainbridged18f4942020-04-14 16:46:13 -07001318 RESULT=$?
1319 if [ $RESULT -eq 0 ] && [ "$VHAVE" == "$VC_VERSION" ]; then
David Bainbridged2811972019-12-14 01:14:09 +00001320 VOK=1
David Bainbridged18f4942020-04-14 16:46:13 -07001321 espin "$VERIFIED"
David Bainbridge1ba64f12019-12-18 00:40:13 +00001322 else
David Bainbridged18f4942020-04-14 16:46:13 -07001323 VCHECK="$(echo -e "$VHAVE\n$VC_VERSION" | sort -V | head -1)"
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001324 if [ "$VCHECK" == "$VHAVE" ]; then
1325 VMESSAGE="upgrade"
1326 else
1327 VMESSAGE="downgrade"
1328 fi
David Bainbridged2811972019-12-14 01:14:09 +00001329 fi
1330fi
1331
David Bainbridged18f4942020-04-14 16:46:13 -07001332if [ "$VOK" -eq 0 ]; then
1333 espin "$NOT_VERIFIED"
David Bainbridged2811972019-12-14 01:14:09 +00001334 bspin - "Download and $VMESSAGE voltctl $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001335 (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
1336 RESULT=$?
1337 if [ $RESULT -ne 0 ]; then
1338 espin - "$THEX"
1339 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download voltctl (version $VC_VERSION): $(cat "$ERR_OUT")${NORMAL}"
1340 rm -rf "$ERR_OUT" "$GOPATH/bin/voltctl"
1341 exit 1
1342 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001343 (set -x; chmod 755 "$GOPATH/bin/voltctl" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1344 espin - "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001345fi
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001346rm -rf "$ERR_OUT"
David Bainbridgee87067b2019-08-12 22:00:12 +00001347if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001348 NOW="$(date +%s)"
1349 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001350fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001351
1352bspin "Verify command PATH"
Test Userba1e7e72019-07-10 22:27:54 +00001353export PATH=$GOPATH/bin:$PATH
David Bainbridged18f4942020-04-14 16:46:13 -07001354espin "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001355
David Bainbridged18f4942020-04-14 16:46:13 -07001356STIME="$(date +%s)"
Test Userba1e7e72019-07-10 22:27:54 +00001357if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001358 HAVE="$(kind get clusters | grep -c "voltha-$NAME")"
Test Userba1e7e72019-07-10 22:27:54 +00001359 bspin "Verify Kubernetes/Kind Cluster"
1360 sspin
David Bainbridged18f4942020-04-14 16:46:13 -07001361 if [ "$HAVE" -eq 0 ]; then
1362 espin "$NOT_VERIFIED"
David Bainbridge491b1bd2019-07-11 17:53:11 +00001363 bspin - "Verify cluster configuration"
David Bainbridged18f4942020-04-14 16:46:13 -07001364 if [ ! -r "./$NAME-cluster.cfg" ]; then
1365 espin - "$NOT_VERIFIED"
David K. Bainbridge43422402020-03-06 07:41:22 -08001366 bspin - "Download cluster configuration: $TYPE-cluster.cfg to $NAME-cluster.cfg $DOWNLOAD"
David Bainbridged18f4942020-04-14 16:46:13 -07001367 ERR_OUT="$(mktemp)"
serkant.uluderya4d315132020-04-15 16:25:54 -07001368 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 -07001369 espin - "$THEX"
1370 echo -e "${RED}${BOLD}${ERROR}ERROR: $NAME-cluster.cfg${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1371 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
1372 rm -rf "$ERR_OUT" "./$NAME-cluster.cfg"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001373 exit 1
1374 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001375 rm -rf "$ERR_OUT"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001376 else
David Bainbridged18f4942020-04-14 16:46:13 -07001377 espin - "$VERIFIED"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001378 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001379 kind create cluster --name "voltha-$NAME" --config "$NAME-cluster.cfg"
David Bainbridge491b1bd2019-07-11 17:53:11 +00001380 else
David Bainbridged18f4942020-04-14 16:46:13 -07001381 espin "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001382 fi
1383
David Bainbridged18f4942020-04-14 16:46:13 -07001384 KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$NAME")"; export KUBECONFIG
Test Userba1e7e72019-07-10 22:27:54 +00001385 P="coredns-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001386 etcd-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +00001387 kindnet-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001388 kube-apiserver-voltha-$NAME-control-plane \
1389 kube-controller-manager-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +00001390 kube-proxy-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001391 kube-scheduler-voltha-$NAME-control-plane"
Test Userba1e7e72019-07-10 22:27:54 +00001392
David Bainbridged18f4942020-04-14 16:46:13 -07001393 EXPECT="$(test "$TYPE" == "minimal" && echo "12" || echo "14")"
1394 wait_for_pods - "kube-system" "$EXPECT" "includes" "Waiting for system PODs to start" "$NO_LABEL" "$P"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001395fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001396if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001397 NOW="$(date +%s)"
1398 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001399fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001400
David Bainbridgee4d11ca2020-05-08 10:21:10 -07001401if [ "$SCHEDULE_ON_CONTROL_NODES" == "yes" ]; then
1402 bspin "Untaint control nodes to allow scheduling $LOCK"
1403 for MNODE in $(kubectl get node --selector='node-role.kubernetes.io/master' -o json | jq -r '.items[].metadata.name'); do
1404 (set -x; kubectl taint node "$MNODE" node-role.kubernetes.io/master:NoSchedule- >>"$LOG" 2>&1) >>"$LOG" 2>&1
1405 sspin
1406 done
1407 espin "$VERIFIED"
1408fi
1409
David Bainbridged18f4942020-04-14 16:46:13 -07001410STIME="$(date +%s)"
1411COUNT="$(count_pods "kube-system" ":Running:" "$NO_LABEL" "tiller-deploy-.*")"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001412bspin "Verify Helm"
David Bainbridged18f4942020-04-14 16:46:13 -07001413if [ "$COUNT" -ne 1 ]; then
1414 espin "$NOT_VERIFIED"
Test Userb5712372019-07-03 21:52:17 +00001415 echo -e "Configuring Helm $GEAR"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001416 if [ "$INSTALL_HELM" == "no" ]; then
1417 bspin - "Skip Helm/Tiller Initialization"
1418 espin - $NO_ENTRY
1419 else
1420 bspin - "Initialize Helm"
David Bainbridged18f4942020-04-14 16:46:13 -07001421 (set -x; helm init --upgrade >>"$LOG" 2>&1) >>"$LOG" 2>&1
1422 espin - "$VERIFIED"
1423 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 -07001424 fi
Test Userb5712372019-07-03 21:52:17 +00001425 bspin - "Add Google Incubator repository to Helm"
David Bainbridged18f4942020-04-14 16:46:13 -07001426 (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>"$LOG" 2>&1) >>"$LOG" 2>&1
1427 espin - "$VERIFIED"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001428
Test Userba1e7e72019-07-10 22:27:54 +00001429 # HACK (sort-of) - the config for tiller is about to be patched, which will
1430 # cause the tiller pod to be recreated. This can sometimes cause a timing
1431 # issue with the "wait_for_pods" call on tiller as it may incorrectly
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001432 # identify the running/ready tiller pod that is soon to be terminated as
Test Userba1e7e72019-07-10 22:27:54 +00001433 # what it is waiting for. To avoid this issue we do a clean scale down and
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001434 # scale up of the pod so the script controlls when it should be expecting
Test Userba1e7e72019-07-10 22:27:54 +00001435 # things
David Bainbridged18f4942020-04-14 16:46:13 -07001436 (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 -07001437
Test Userb5712372019-07-03 21:52:17 +00001438 bspin - "Add Google Stable repository to Helm"
David Bainbridged18f4942020-04-14 16:46:13 -07001439 (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>"$LOG" 2>&1) >>"$LOG" 2>&1
1440 espin - "$VERIFIED"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001441 bspin - "Add ONF VOLTHA repository to Helm"
David Bainbridged18f4942020-04-14 16:46:13 -07001442 (set -x; helm repo add onf https://charts.opencord.org >>"$LOG" 2>&1) >>"$LOG" 2>&1
1443 espin - "$VERIFIED"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001444 bspin - "Add ONF ONOS repository to Helm"
1445 (set -x; helm repo add onos https://charts.onosproject.org >>"$LOG" 2>&1) >>"$LOG" 2>&1
1446 espin - "$VERIFIED"
1447 bspin - "Add ONF Atomix repository to Helm"
1448 (set -x; helm repo add atomix https://charts.atomix.io >>"$LOG" 2>&1) >>"$LOG" 2>&1
1449 espin - "$VERIFIED"
David Bainbridge309099c2020-05-05 08:47:29 -07001450 bspin - "Add Custom BBSIM SADIS Server repository to Helm"
1451 (set -x; helm repo add bbsim-sadis https://ciena.github.io/bbsim-sadis-server/charts >>"$LOG" 2>&1) >>"$LOG" 2>&1
1452 espin - "$VERIFIED"
Test Userb5712372019-07-03 21:52:17 +00001453 bspin - "Update Helm repository cache"
David Bainbridged18f4942020-04-14 16:46:13 -07001454 (set -x; helm repo update >>"$LOG" 2>&1) >>"$LOG" 2>&1
1455 espin - "$VERIFIED"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001456
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001457 # Create and k8s service account so that Helm can create pods
Test Userb5712372019-07-03 21:52:17 +00001458 bspin - "Create Tiller ServiceAccount"
David Bainbridged18f4942020-04-14 16:46:13 -07001459 (set -x; kubectl create serviceaccount --namespace kube-system tiller >>"$LOG" 2>&1) >>"$LOG" 2>&1
1460 espin - "$VERIFIED"
Test Userb5712372019-07-03 21:52:17 +00001461 bspin - "Create Tiller ClusterRoleBinding"
David Bainbridged18f4942020-04-14 16:46:13 -07001462 (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>"$LOG" 2>&1) >>"$LOG" 2>&1
1463 espin - "$VERIFIED"
Test Userb5712372019-07-03 21:52:17 +00001464 bspin - "Update Tiller Manifest"
David Bainbridged18f4942020-04-14 16:46:13 -07001465 (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 +00001466
1467 # HACK (sort-of) - part to, spin it back up
David Bainbridged18f4942020-04-14 16:46:13 -07001468 (set -x; kubectl -n kube-system scale deploy tiller-deploy --replicas=1 >>"$LOG" 2>&1) >>"$LOG" 2>&1
1469 espin - "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001470else
David Bainbridged18f4942020-04-14 16:46:13 -07001471 if [ "$(helm version -s --template '{{.Server.SemVer}}')" != "$HELM_VERSION" ]; then
1472 espin "$NOT_VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001473 bspin - "Sync Tiller server version with helm client"
David Bainbridged18f4942020-04-14 16:46:13 -07001474 (set -x; helm init --upgrade --force-upgrade --wait >>"$LOG" 2>&1) >>"$LOG" 2>&1
1475 espin - "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001476 else
David Bainbridged18f4942020-04-14 16:46:13 -07001477 espin "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001478 fi
1479
David Bainbridge46505fb2019-10-01 21:13:20 +00001480 if [ "$UPDATE_HELM_REPOS" == "yes" ]; then
1481 bspin - "Update Helm repository cache"
David Bainbridged18f4942020-04-14 16:46:13 -07001482 (set -x; helm repo update >>"$LOG" 2>&1) >>"$LOG" 2>&1
1483 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00001484 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001485fi
David Bainbridged18f4942020-04-14 16:46:13 -07001486wait_for_pods - "kube-system" 1 "includes" "Waiting for Tiller POD to start" "$NO_LABEL" "tiller-deploy-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001487if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001488 NOW="$(date +%s)"
1489 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001490fi
David Bainbridgecf546362020-04-21 23:18:50 -07001491# Resolve chart versions and log them for debug/support
1492RESOLVED_VOLTHA_CHART_VERSION=$(resolve_chart_version "$VOLTHA_CHART" "$VOLTHA_CHART_VERSION")
1493RESOLVED_VOLTHA_BBSIM_CHART_VERSION=$(resolve_chart_version "$VOLTHA_BBSIM_CHART" "$VOLTHA_BBSIM_CHART_VERSION")
1494RESOLVED_VOLTHA_ADAPTER_SIM_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_SIM_CHART" "$VOLTHA_ADAPTER_SIM_CHART_VERSION")
1495RESOLVED_VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_OPEN_OLT_CHART" "$VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION")
1496RESOLVED_VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_OPEN_ONU_CHART" "$VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION")
1497RESOLVED_ONOS_CHART_VERSION=$(resolve_chart_version "$ONOS_CHART" "$ONOS_CHART_VERSION")
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001498RESOLVED_ONOS_CLASSIC_CHART_VERSION=$(resolve_chart_version "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION")
David Bainbridgecf546362020-04-21 23:18:50 -07001499RESOLVED_KAFKA_CHART_VERSION=$(resolve_chart_version "$KAFKA_CHART" "$KAFKA_CHART_VERSION")
1500cat <<EOV >>"$LOG"
1501Resolved helm charts and versions:
1502 $VOLTHA_CHART:$RESOLVED_VOLTHA_CHART_VERSION
1503 $VOLTHA_BBSIM_CHART:$RESOLVED_VOLTHA_BBSIM_CHART_VERSION
1504 $VOLTHA_ADAPTER_SIM_CHART:$RESOLVED_VOLTHA_ADAPTER_SIM_CHART_VERSION
1505 $VOLTHA_ADAPTER_OPEN_OLT_CHART:$RESOLVED_VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION
1506 $VOLTHA_ADAPTER_OPEN_ONU_CHART:$RESOLVED_VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION
1507 $ONOS_CHART:$RESOLVED_ONOS_CHART_VERSION
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001508 $ONOS_CLASSIC_CHART:$RESOLVED_ONOS_CLASSIC_CHART_VERSION
David Bainbridgecf546362020-04-21 23:18:50 -07001509 $KAFKA_CHART:$RESOLVED_KAFKA_CHART_VERSION
1510EOV
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001511
David Bainbridged18f4942020-04-14 16:46:13 -07001512STIME="$(date +%s)"
David Bainbridge0774b232019-08-02 06:37:19 +00001513bspin "Verify Helm values file: $NAME-values.yaml"
1514if [ ! -r "./$NAME-values.yaml" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001515 espin "$NOT_VERIFIED"
David Bainbridge0774b232019-08-02 06:37:19 +00001516 bspin - "Download Helm values file: $TYPE-values.yaml to $NAME-values.yaml $DOWNLOAD"
David Bainbridged18f4942020-04-14 16:46:13 -07001517 ERR_OUT="$(mktemp)"
serkant.uluderya4d315132020-04-15 16:25:54 -07001518 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 -07001519 espin - "$THEX"
1520 echo -e "${RED}${BOLD}${ERROR}ERROR: $NAME-values.yaml${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1521 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
1522 rm -rf "$ERR_OUT" "./$NAME-values.yaml"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001523 exit 1
1524 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001525 rm -rf "$ERR_OUT"
1526 espin - "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001527else
David Bainbridged18f4942020-04-14 16:46:13 -07001528 espin "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001529fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001530if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001531 NOW="$(date +%s)"
1532 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001533fi
Test Userba1e7e72019-07-10 22:27:54 +00001534
David Bainbridged18f4942020-04-14 16:46:13 -07001535STIME="$(date +%s)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001536bspin "Verify or download chart specific values files $DOWNLOAD"
1537VALUES_FILES="monkey-values.yaml"
David Bainbridged18f4942020-04-14 16:46:13 -07001538ERR_OUT="$(mktemp)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001539for i in $VALUES_FILES; do
1540 if [ ! -r ./$i ]; then
serkant.uluderya4d315132020-04-15 16:25:54 -07001541 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 -07001542 espin "$THEX"
1543 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1544 echo "ERROR: $i - $(cat "$ERR_OUT")" >>"$LOG"
1545 rm -rf "$ERR_OUT" "./$i"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001546 exit 1
1547 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001548 rm -rf "$ERR_OUT"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001549 fi
1550done
David Bainbridged18f4942020-04-14 16:46:13 -07001551rm -rf "$ERR_OUT"
1552espin "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001553if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001554 NOW="$(date +%s)"
1555 printtime $((NOW - STIME))
David Bainbridge99ac7a22019-08-31 02:26:43 +00001556fi
1557
1558if [ "$WITH_CHAOS" == "yes" ]; then
1559 bspin "Verify or clone kube-monkey helm chart $DOWNLOAD"
1560 if [ -r ./kube-monkey ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001561 espin "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001562 else
David Bainbridged18f4942020-04-14 16:46:13 -07001563 espin "$NOT_VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001564 bspin - "GIT clone kube-monkey"
David Bainbridged18f4942020-04-14 16:46:13 -07001565 (set -x; git clone https://github.com/asobti/kube-monkey kube-monkey >>"$LOG" 2>&1) >>"$LOG" 2>&1
1566 espin - "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001567 fi
1568fi
1569
Test Userba1e7e72019-07-10 22:27:54 +00001570if [ "$JUST_K8S" == "yes" ]; then
1571 echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye."
1572 echo ""
David Bainbridged18f4942020-04-14 16:46:13 -07001573 echo "Please issue the following commands in your terminal to ensure that you" | tee -a "$LOG"
1574 echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a "$LOG"
1575 echo "tools required by VOLTHA in your command path. " | tee -a "$LOG"
1576 echo "" | tee -a "$LOG"
1577 echo -en "$BOLD"
1578 if [ "$DEPLOY_K8S" == "yes" ]; then
1579 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00001580 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001581 echo "export PATH=$GOPATH/bin:\$PATH" | tee -a "$LOG"
1582 echo -en "$NORMAL"
1583 echo "" | tee -a "$LOG"
1584 echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00001585 exit 0
1586fi
1587
David Bainbridged18f4942020-04-14 16:46:13 -07001588if [ "$WITH_ETCD" != "yes" ] && [ "$WITH_ETCD" != "external" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001589 bspin "Skip ETCD Operator Deployment"
1590 espin $NO_ENTRY
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001591else
David Bainbridged18f4942020-04-14 16:46:13 -07001592 STIME="$(date +%s)"
David Bainbridge76afd812020-04-06 09:53:52 -07001593 NS=$VOLTHA_NS
David Bainbridged18f4942020-04-14 16:46:13 -07001594 if [ "$WITH_ETCD" == "external" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -07001595 NS=$INFRA_NS
1596 fi
David Bainbridge696bc632020-04-05 21:49:37 -07001597 bspin "Verify ETCD Operator $OLD_KEY"
David Bainbridged18f4942020-04-14 16:46:13 -07001598 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$NS" "^etcd-operator\$" | wc -l)" -ne 1 ]; then
1599 espin "$NOT_VERIFIED"
1600 helm_install - "$NS" etcd-operator stable/etcd-operator latest "$_HELM_DESC ETCD Operator"
David Bainbridge696bc632020-04-05 21:49:37 -07001601 else
David Bainbridged18f4942020-04-14 16:46:13 -07001602 espin "$VERIFIED"
David Bainbridge696bc632020-04-05 21:49:37 -07001603 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001604 EXPECT="$(test "$TYPE" == "minimal" && echo "1" || echo "3")"
1605 wait_for_pods - "$NS" "$EXPECT" "includes" "Waiting for ETCD Operator to start" "$NO_LABEL" "etcd-operator-.*"
David Bainbridge696bc632020-04-05 21:49:37 -07001606 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001607 NOW="$(date +%s)"
1608 printtime $((NOW - STIME))
David Bainbridge696bc632020-04-05 21:49:37 -07001609 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001610fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001611
David Bainbridged18f4942020-04-14 16:46:13 -07001612STIME="$(date +%s)"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001613if is_in "$WITH_ONOS" "yes,legacy,classic"; then
1614 if is_in "$WITH_ONOS" "legacy"; then
1615 bspin "Verify ONOS LEGACY installed $BIRD"
1616 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^onos\$" | wc -l)" -ne 1 ]; then
1617 espin "$NOT_VERIFIED"
1618 INTERNAL_EXTRA_HELM_INSTALL_ARGS="$SET_TAG $EXTRA_HELM_FLAGS" helm_install - "$INFRA_NS" onos "$ONOS_CHART" "$ONOS_CHART_VERSION" "$_HELM_DESC ONOS LEGACY"
1619 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
1620 else
1621 espin "$VERIFIED"
1622 fi
1623 wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for ONOS to start" "$NO_LABEL" "onos-.*"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001624
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001625 if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
1626 bspin - "Forward ONOS API port $FORWARD"
1627 kill_port_forward onos-ui
1628 port_forward "$INFRA_NS" onos-ui "$ONOS_API_PORT:8181"
1629 espin - "$VERIFIED"
1630 bspin - "Forward ONOS SSH port $FORWARD"
1631 kill_port_forward onos-ssh
1632 port_forward "$INFRA_NS" onos-ssh "$ONOS_SSH_PORT:8101"
1633 espin - "$VERIFIED"
1634 _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT"
1635 else
1636 _ONOS_API_EP="$(get_service_ep "$INFRA_NS" onos-ui)"
1637 fi
1638 elif is_in "$WITH_ONOS" "yes,classic"; then
1639 bspin "Verify ONOS CLASSIC installed $BIRD"
1640 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^onos\$" | wc -l)" -ne 1 ]; then
1641 espin "$NOT_VERIFIED"
1642 # ONOS CLASSIC identifies its image repo/tag differently, so yq is used to grab the values from the
1643 # values value
David Bainbridgefad50732020-05-01 17:00:12 -07001644 YAML_VALUES=$(INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set replicas=$NUM_OF_ONOS --set atomix.replicas=$NUM_OF_ATOMIX" \
1645 helm_values "$INFRA_NS" onos "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION")
1646 _ONOS_REPO="$(echo "$YAML_VALUES" | yq read - images.onos.repository)"
1647 _ONOS_TAG="$(echo "$YAML_VALUES" | yq read - images.onos.tag)"
1648 _TAG_DEFAULT="$(echo "$YAML_VALUES" | yq read - defaults.image_tag)"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001649 if [ -z "$_ONOS_TAG" ]; then
1650 _ONOS_TAG="$_TAG_DEFAULT"
1651 fi
David Bainbridgefad50732020-05-01 17:00:12 -07001652
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001653 INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set image.repository=$_ONOS_REPO --set image.tag=$_ONOS_TAG --set replicas=$NUM_OF_ONOS --set atomix.replicas=$NUM_OF_ATOMIX" \
1654 helm_install - "$INFRA_NS" onos "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION" "$_HELM_DESC ONOS CLASSIC"
1655 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
1656 else
1657 espin "$VERIFIED"
1658 fi
1659 wait_for_pods - "$INFRA_NS" $((NUM_OF_ONOS + NUM_OF_ATOMIX)) "includes" "Waiting for ONOS CLASSIC to start" "$NO_LABEL" "onos-.*"
1660 if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
1661 bspin - "Forward ONOS API port $FORWARD"
1662 kill_port_forward onos-onos-classic-hs
1663 port_forward "$INFRA_NS" onos-onos-classic-hs "$ONOS_API_PORT:8181" "$ONOS_SSH_PORT:8101"
1664 espin - "$VERIFIED"
1665 _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT"
1666 else
1667 _ONOS_API_EP="$(get_service_ep "$INFRA_NS" onos-onos-classic-hs)"
1668 fi
1669 elif [ "$WITH_ONOS" == "micro" ]; then
1670 bspin "Verify micro-ONOS installed $BIRD"
1671 # We should never get here
1672 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Micro ONOS not currently supported${NORMAL}"
1673 exit 1
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001674 fi
David Bainbridged31d6122019-08-13 19:37:59 +00001675 bspin - "Verify or download ONOS configuration support files $DOWNLOAD"
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001676 ONOS_FILES="olt-onos-enableExtraneousRules.json onos-aaa.json \
David Bainbridge696bc632020-04-05 21:49:37 -07001677 onos-dhcpl2relay.json onos-sadis-sample.json"
David Bainbridged18f4942020-04-14 16:46:13 -07001678 (set -x; mkdir -p ./onos-files >>"$LOG" 2>&1) >>"$LOG" 2>&1
1679 ERR_OUT="$(mktemp)"
David Bainbridge2b19e832019-08-16 02:40:53 +00001680 for i in $ONOS_FILES; do
David Bainbridged18f4942020-04-14 16:46:13 -07001681 if [ ! -r "./onos-files/$i" ]; then
serkant.uluderya4d315132020-04-15 16:25:54 -07001682 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 -07001683 espin - "$THEX"
1684 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1685 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
1686 rm -rf "$ERR_OUT" "./onos-files/$i"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001687 exit 1
1688 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001689 rm -rf "$ERR_OUT"
David Bainbridged31d6122019-08-13 19:37:59 +00001690 fi
1691 done
David Bainbridged18f4942020-04-14 16:46:13 -07001692 rm -rf "$ERR_OUT"
1693 espin - "$VERIFIED"
David Bainbridge27790d62019-08-13 22:43:19 +00001694
David Bainbridged18f4942020-04-14 16:46:13 -07001695 if [ "$INSTALL_ONOS_APPS" == "yes" ]; then
David Bainbridge27790d62019-08-13 22:43:19 +00001696 bspin - "Installing custom ONOS applications"
David Bainbridged18f4942020-04-14 16:46:13 -07001697 if [ -x onos-files/onos-apps ] && [ "$(find onos-files/onos-apps -name "*.oar" 2>/dev/null | wc -l)" -gt 0 ]; then
1698 for OAR in onos-files/onos-apps/*.oar; do
David Bainbridge27790d62019-08-13 22:43:19 +00001699 sspin - "Installing custom ONOS applications - $OAR$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -07001700 override_onos_app "$OAR"
David Bainbridge27790d62019-08-13 22:43:19 +00001701 done
1702 espin - "$VERIFIED Installing custom ONOS applications$CEOL"
1703 else
1704 espin - "$NOT_VERIFIED Installing custom ONOS applications - None Found"
1705 fi
1706 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001707
David Bainbridged18f4942020-04-14 16:46:13 -07001708 if [ "$WITH_KAFKA" != "no" ]; then
David Bainbridge837e8bd2020-04-06 13:17:14 -07001709 check_onos_app_active org.opencord.kafka
David Bainbridge76afd812020-04-06 09:53:52 -07001710 _HOST=voltha-kafka.$INFRA_NS.svc.cluster.local
David Bainbridge837e8bd2020-04-06 13:17:14 -07001711 _PORT=9092
David Bainbridged18f4942020-04-14 16:46:13 -07001712 if [ "$WITH_KAFKA" == "yes" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -07001713 _HOST=voltha-kafka.$VOLTHA_NS.svc.cluster.local
1714 _PORT=9092
David Bainbridged18f4942020-04-14 16:46:13 -07001715 elif [ "$WITH_KAFKA" == "external" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -07001716 _HOST=kafka.$INFRA_NS.svc.cluster.local
1717 _PORT=9092
1718 else
David Bainbridged18f4942020-04-14 16:46:13 -07001719 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
1720 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge837e8bd2020-04-06 13:17:14 -07001721 _PORT=${_PORT:-9092}
1722 fi
1723 push_onos_config "json" "Push ONOS Kafka Configuration" "network/configuration/apps/org.opencord.kafka" \
David Bainbridged18f4942020-04-14 16:46:13 -07001724 "$(cat <<EOJ | tr -d '[:space:]'
David Bainbridge696bc632020-04-05 21:49:37 -07001725{
1726 "kafka": {
1727 "bootstrapServers": "$_HOST:$_PORT"
1728 }
1729}
1730EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07001731)"
David Bainbridge837e8bd2020-04-06 13:17:14 -07001732 fi
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001733 check_onos_app_active org.opencord.dhcpl2relay
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001734 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 -08001735 check_onos_app_active org.opencord.olt
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001736 # FIXME use WITH_DHCP and WITH_EAPOL flags to configre OLT App
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001737 # Default value for "enableEapol" is true in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07001738 if [ "$WITH_EAPOL" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001739 push_onos_config "json" "Enable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":true}'
David Bainbridged18f4942020-04-14 16:46:13 -07001740 elif [ "$WITH_EAPOL" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001741 push_onos_config "json" "Disable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001742 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001743 # Default value for "enableDhcpOnProvisioning" is false and for "enableDhcpV4" is true in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07001744 if [ "$WITH_DHCP" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001745 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 -07001746 elif [ "$WITH_DHCP" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001747 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 -08001748 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001749 # Default value for "enableIgmpOnProvisioning" is false in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07001750 if [ "$WITH_IGMP" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001751 push_onos_config "json" "Enable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":true}'
David Bainbridged18f4942020-04-14 16:46:13 -07001752 elif [ "$WITH_IGMP" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001753 push_onos_config "json" "Disable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001754 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001755 if [ "$ENABLE_ONOS_EXTRANEOUS_RULES" == "yes" ]; then
David K. Bainbridge484d80c2020-03-05 21:44:34 -08001756 push_onos_config "file" "Enabling extraneous rules for ONOS" "configuration/org.onosproject.net.flow.impl.FlowRuleManager" "onos-files/olt-onos-enableExtraneousRules.json"
1757 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001758 if is_in "$CONFIG_SADIS" "yes,file"; then
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001759 check_onos_app_active org.opencord.sadis
Hardik Windlassb3147602020-03-09 16:59:15 +05301760 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 -07001761 elif [ "$CONFIG_SADIS" == "bbsim" ]; then
1762 push_onos_config "json" \
1763 "[optional] Push ONOS configuration for BBSIM SADIS servers" \
1764 "network/configuration/apps/org.opencord.sadis" \
David Bainbridged18f4942020-04-14 16:46:13 -07001765 "$(cat <<EOJ | tr -d '[:space:]'
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001766{
1767 "sadis": {
1768 "integration": {
David Bainbridge76afd812020-04-06 09:53:52 -07001769 "url": "http://bbsim.$BBSIM_NS.svc.cluster.local:50074/v2/subscribers/%s",
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001770 "cache": {
1771 "enabled": true,
1772 "maxsize": 50,
1773 "ttl": "PT1m"
1774 }
1775 }
1776 },
1777 "bandwidthprofile": {
1778 "integration": {
David Bainbridge76afd812020-04-06 09:53:52 -07001779 "url": "http://bbsim.$BBSIM_NS.svc.cluster.local:50074/v2/bandwidthprofiles/%s",
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001780 "cache": {
1781 "enabled": true,
1782 "maxsize": 50,
1783 "ttl": "PT1m"
1784 }
1785 }
1786 }
1787}
1788EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07001789)"
David Bainbridge309099c2020-05-05 08:47:29 -07001790 elif [ "$CONFIG_SADIS" == "external" ]; then
1791 push_onos_config "json" \
1792 "[optional] Push ONOS configuration for custom SADIS and Bandwidth Profile servers" \
1793 "network/configuration/apps/org.opencord.sadis" \
1794 "$(cat <<EOJ | tr -d '[:space:]'
1795{
1796 "sadis": {
1797 "integration": {
1798 "url": "http://bbsim-sadis-server.$BBSIM_NS.svc:58080/subscribers/%s",
1799 "cache": {
1800 "enabled": true,
1801 "maxsize": 50,
1802 "ttl": "PT1m"
1803 }
1804 }
1805 },
1806 "bandwidthprofile": {
1807 "integration": {
1808 "url": "http://bbsim-sadis-server.$BBSIM_NS.svc:58080/profiles/%s",
1809 "cache": {
1810 "enabled": true,
1811 "maxsize": 50,
1812 "ttl": "PT1m"
1813 }
1814 }
1815 }
1816}
1817EOJ
1818)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001819 elif [ "$CONFIG_SADIS" == "url" ]; 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" \
David Bainbridged18f4942020-04-14 16:46:13 -07001823 "$(cat <<EOJ | tr -d '[:space:]'
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001824{
1825 "sadis": {
1826 "integration": {
1827 "url": "$SADIS_SUBSCRIBERS",
1828 "cache": {
1829 "enabled": true,
1830 "maxsize": 50,
1831 "ttl": "PT1m"
1832 }
1833 }
1834 },
1835 "bandwidthprofile": {
1836 "integration": {
1837 "url": "$SADIS_BANDWIDTH_PROFILES",
1838 "cache": {
1839 "enabled": true,
1840 "maxsize": 50,
1841 "ttl": "PT1m"
1842 }
1843 }
1844 }
1845}
1846EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07001847)"
David Bainbridge2b19e832019-08-16 02:40:53 +00001848 fi
Test Userba1e7e72019-07-10 22:27:54 +00001849fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001850if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001851 NOW="$(date +%s)"
1852 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001853fi
Test Userba1e7e72019-07-10 22:27:54 +00001854
David Bainbridged18f4942020-04-14 16:46:13 -07001855if [ "$WITH_ETCD" == "external" ]; then
1856 STIME="$(date +%s)"
David Bainbridge76afd812020-04-06 09:53:52 -07001857 bspin "Verify external ETCD cluster $OLD_KEY"
David Bainbridged18f4942020-04-14 16:46:13 -07001858 EXPECT="$(test "$TYPE" == "minimal" && echo "1" || echo "3")"
1859 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^etcd-cluster\$" | wc -l)" -ne 1 ]; then
1860 espin "$NOT_VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07001861 INTERNAL_EXTRA_HELM_INSTALL_ARGS+="--set clusterName=etcd-cluster --set autoCompactionRetention=1 --set clusterSize=$EXPECT"
David Bainbridged18f4942020-04-14 16:46:13 -07001862 helm_install - "$INFRA_NS" etcd-cluster onf/voltha-etcd-cluster latest "$_HELM_DESC external ETCD cluster"
David Bainbridge76afd812020-04-06 09:53:52 -07001863 else
David Bainbridged18f4942020-04-14 16:46:13 -07001864 espin "$VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07001865 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001866 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for ETCD cluster to start" "$NO_LABEL" "etcd-cluster-.*"
David Bainbridge76afd812020-04-06 09:53:52 -07001867 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001868 NOW="$(date +%s)"
1869 printtime $((NOW - STIME))
David Bainbridge76afd812020-04-06 09:53:52 -07001870 fi
1871fi
1872
David Bainbridged18f4942020-04-14 16:46:13 -07001873if [ "$WITH_KAFKA" == "external" ]; then
1874 _TMP="$(mktemp -u)"
1875 _COUNT="$(test "$TYPE" == "minimal" && echo "1" || echo "3")"
1876 cat << EOC > "$_TMP"
David Bainbridge76afd812020-04-06 09:53:52 -07001877configurationOverrides:
1878 "default.replication.factor": $_COUNT
1879 "offsets.topic.replication.factor": $_COUNT
1880 "log.retention.hours": 4
1881 "log.message.timestamp.type": "LogAppendTime"
1882persistence:
1883 enabled: false
1884zookeeper:
1885 replicaCount: 1
1886 persistence:
1887 enabled: false
1888replicas: $_COUNT
1889EOC
David Bainbridged18f4942020-04-14 16:46:13 -07001890 STIME="$(date +%s)"
David Bainbridge76afd812020-04-06 09:53:52 -07001891 bspin "Verify external Kafka cluster $OLD_KEY"
David Bainbridged18f4942020-04-14 16:46:13 -07001892 EXPECT="$(test "$TYPE" == "minimal" && echo "2" || echo "4")"
1893 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^kafka\$" | wc -l)" -ne 1 ]; then
1894 espin "$NOT_VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07001895 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" -f $_TMP"
David Bainbridgecf546362020-04-21 23:18:50 -07001896 helm_install - "$INFRA_NS" kafka "$KAFKA_CHART" "$KAFKA_CHART_VERSION" "$_HELM_DESC external Kafka cluster"
David Bainbridge76afd812020-04-06 09:53:52 -07001897 else
David Bainbridged18f4942020-04-14 16:46:13 -07001898 espin "$VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07001899 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001900 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for Kafka cluster to start" "$NO_LABEL" "kafka-.*"
David Bainbridge76afd812020-04-06 09:53:52 -07001901 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001902 NOW="$(date +%s)"
1903 printtime $((NOW - STIME))
David Bainbridge76afd812020-04-06 09:53:52 -07001904 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001905 rm -rf "$_TMP"
David Bainbridge76afd812020-04-06 09:53:52 -07001906fi
1907
David Bainbridged18f4942020-04-14 16:46:13 -07001908STIME="$(date +%s)"
David Bainbridge696bc632020-04-05 21:49:37 -07001909EXPECT=1
1910if [ "$ONLY_ONE" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001911 EXPECT="$((EXPECT+1))"
David Bainbridge696bc632020-04-05 21:49:37 -07001912 INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set therecanbeonlyone=true"
1913else
David Bainbridged18f4942020-04-14 16:46:13 -07001914 EXPECT="$((EXPECT+2))"
David Bainbridge696bc632020-04-05 21:49:37 -07001915fi
Matteo Scandolo67335f02020-04-09 11:19:53 -07001916case $WITH_ETCD in
David Bainbridge76afd812020-04-06 09:53:52 -07001917 no)
1918 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set private_etcd_cluster=false"
1919 ;;
1920 yes)
1921 _HOST="voltha-etcd-cluster-client.$VOLTHA_NS.svc.cluster.local"
1922 _PORT=2379
1923 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridged18f4942020-04-14 16:46:13 -07001924 EXPECT="$((EXPECT+$(test "$TYPE" == "minimal" && echo "1" || echo "3")))"
David Bainbridge76afd812020-04-06 09:53:52 -07001925 ;;
1926 external)
1927 _HOST="etcd-cluster-client.$INFRA_NS.svc.cluster.local"
1928 _PORT=2379
1929 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set private_etcd_cluster=false --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
1930 ;;
1931 *)
David Bainbridged18f4942020-04-14 16:46:13 -07001932 _HOST="$(echo "$WITH_ETCD" | cut -d: -f1)"
1933 _PORT="$(echo "$WITH_ETCD" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07001934 _PORT=${_PORT:-2379}
David Bainbridge76afd812020-04-06 09:53:52 -07001935 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set private_etcd_cluster=false --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
1936 ;;
1937esac
1938case $WITH_KAFKA in
1939 no)
1940 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set private_kafka_cluster=false"
1941 ;;
1942 yes)
1943 _HOST=voltha-kafka.$VOLTHA_NS.svc.cluster.local
1944 _PORT=9092
1945 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 -07001946 EXPECT="$((EXPECT+$(test "$TYPE" == "minimal" && echo "2" || echo "4")))"
David Bainbridge76afd812020-04-06 09:53:52 -07001947 ;;
1948 external)
1949 _HOST=kafka.$INFRA_NS.svc.cluster.local
1950 _PORT=9092
1951 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set private_kafka_cluster=false --set kafka_broker=$_HOST:$_PORT --set services.kafka.adapter.service=$_HOST --set services.kafka.adapter.port=$_PORT --set services.kafka.cluster.service=$_HOST --set services.kafka.cluster.port=$_PORT"
1952 ;;
1953 *)
David Bainbridged18f4942020-04-14 16:46:13 -07001954 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
1955 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07001956 _PORT=${_PORT:-9092}
David Bainbridge76afd812020-04-06 09:53:52 -07001957 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set private_kafka_cluster=false --set kafka_broker=$_HOST:$_PORT --set services.kafka.adapter.service=$_HOST --set services.kafka.adapter.port=$_PORT --set services.kafka.cluster.service=$_HOST --set services.kafka.cluster.port=$_PORT"
1958 ;;
1959esac
1960
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001961if is_in "$WITH_ONOS" "legacy"; then
David Bainbridge76afd812020-04-06 09:53:52 -07001962 _HOST=onos-openflow.$INFRA_NS.svc.cluster.local
1963 _PORT=6653
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001964elif is_in "$WITH_ONOS" "yes,classic"; then
1965 _HOST=onos-onos-classic-hs.$INFRA_NS.svc.cluster.local
1966 _PORT=6653
David Bainbridged18f4942020-04-14 16:46:13 -07001967elif [ "$WITH_ONOS" != "no" ]; then
1968 _HOST="$(echo "$WITH_ONOS" | cut -d: -f1)"
1969 _PORT="$(echo "$WITH_ONOS" | cut -s -d: -f2)"
David Bainbridge76afd812020-04-06 09:53:52 -07001970 _PORT=${_PORT:-6653}
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07001971fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001972
David Bainbridgecf546362020-04-21 23:18:50 -07001973compare_versions "$RESOLVED_VOLTHA_CHART_VERSION" 2.4.2
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07001974if [ "$?" == "1" ]; then
1975 # voltha chart > 2.4.2 uses list of controllers
David Bainbridgee4d11ca2020-05-08 10:21:10 -07001976 for NUM in $(seq 0 $((NUM_OF_ONOS-1))); do
1977 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.controller[$NUM].service=onos-onos-classic-$NUM.onos-onos-classic-hs.$INFRA_NS.svc.cluster.local --set services.controller[$NUM].port=6653"
1978 done
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07001979else
1980 # voltha chart <= 2.4.2 uses single controller
David Bainbridge76afd812020-04-06 09:53:52 -07001981 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.controller.service=$_HOST --set services.controller.port=$_PORT"
David Bainbridge696bc632020-04-05 21:49:37 -07001982fi
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07001983
Test Userb5712372019-07-03 21:52:17 +00001984bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
David Bainbridged18f4942020-04-14 16:46:13 -07001985if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$VOLTHA_NS" "^voltha\$" | wc -l)" -ne 1 ]; then
1986 espin "$NOT_VERIFIED"
1987 helm_install - "$VOLTHA_NS" voltha "$VOLTHA_CHART" "$VOLTHA_CHART_VERSION" "$_HELM_DESC VOLTHA Core"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001988else
David Bainbridged18f4942020-04-14 16:46:13 -07001989 espin "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001990fi
David Bainbridge696bc632020-04-05 21:49:37 -07001991INTERNAL_EXTRA_HELM_INSTALL_ARGS=
Test Userba1e7e72019-07-10 22:27:54 +00001992
David Bainbridge90fd8e32019-08-21 23:32:47 +00001993VOLTHA="voltha-ofagent-.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001994 rw-core.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001995 voltha-etcd-cluster-.* \
1996 voltha-kafka-.* \
1997 voltha-zookeeper-.*"
David Bainbridged18f4942020-04-14 16:46:13 -07001998wait_for_pods - "$VOLTHA_NS" "$EXPECT" "includes" "Waiting for VOLTHA Core to start" "$NO_LABEL" "$VOLTHA"
David Bainbridgee87067b2019-08-12 22:00:12 +00001999if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002000 NOW="$(date +%s)"
2001 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002002fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002003
David Bainbridge46505fb2019-10-01 21:13:20 +00002004if [ "$WITH_ADAPTERS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002005 STIME="$(date +%s)"
David Bainbridge46505fb2019-10-01 21:13:20 +00002006 EXPECT=0
David Bainbridged18f4942020-04-14 16:46:13 -07002007 if [ "$WITH_ETCD" == "yes" ]; then
David Bainbridge3517f6c2020-04-08 12:14:08 -07002008 _HOST=voltha-etcd-cluster-client.$VOLTHA_NS.svc.cluster.local
2009 _PORT=2379
2010 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridged18f4942020-04-14 16:46:13 -07002011 elif [ "$WITH_ETCD" == "external" ]; then
David Bainbridge3517f6c2020-04-08 12:14:08 -07002012 _HOST=etcd-cluster-client.$INFRA_NS.svc.cluster.local
2013 _PORT=2379
2014 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridged18f4942020-04-14 16:46:13 -07002015 elif [ "$WITH_ETCD" != "no" ]; then
2016 _HOST="$(echo "$WITH_ETCD" | cut -d: -f1)"
2017 _PORT="$(echo "$WITH_ETCD" | cut -s -d: -f2)"
David Bainbridge3517f6c2020-04-08 12:14:08 -07002018 _PORT=${_PORT:-2379}
2019 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridge696bc632020-04-05 21:49:37 -07002020 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002021 if [ "$WITH_KAFKA" == "yes" ]; then
David Bainbridge3517f6c2020-04-08 12:14:08 -07002022 _HOST=voltha-kafka.$VOLTHA_NS.svc.cluster.local
2023 _PORT=9092
2024 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 -07002025 elif [ "$WITH_KAFKA" == "external" ]; then
David Bainbridge3517f6c2020-04-08 12:14:08 -07002026 _HOST=kafka.$INFRA_NS.svc.cluster.local
2027 _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"
2040 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"
2051 helm_install - "$ADAPTER_NS" open-olt "$VOLTHA_ADAPTER_OPEN_OLT_CHART" "$VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION" "$_HELM_DESC OpenOLT Adapter"
David Bainbridge46505fb2019-10-01 21:13:20 +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"
Matteo Scandolo67335f02020-04-09 11:19:53 -07002061 helm_install - "$ADAPTER_NS" open-onu "$VOLTHA_ADAPTER_OPEN_ONU_CHART" "$VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION" "$_HELM_DESC OpenONU Adapter"
2062 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 Bainbridged18f4942020-04-14 16:46:13 -07002109 helm_install - "$BBSIM_NS" "bbsim${instance_num}" "$VOLTHA_BBSIM_CHART" "$VOLTHA_BBSIM_CHART_VERSION" "$_HELM_DESC BBSIM${instance_num}"
David Bainbridge2eaf2cf2020-03-18 12:54:08 -07002110 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
David K. Bainbridge43422402020-03-06 07:41:22 -08002111 else
David Bainbridged18f4942020-04-14 16:46:13 -07002112 espin - "$VERIFIED"
David K. Bainbridge43422402020-03-06 07:41:22 -08002113 fi
2114 done
David Bainbridged18f4942020-04-14 16:46:13 -07002115 wait_for_pods - "$BBSIM_NS" "$NUM_OF_BBSIM" "includes" "Waiting for BBSIM to start" "$BBSIM_LABEL" "bbsim*"
David Bainbridgee87067b2019-08-12 22:00:12 +00002116 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002117 NOW="$(date +%s)"
2118 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002119 fi
Test User7d866122019-07-09 17:52:35 +00002120fi
2121
David Bainbridge309099c2020-05-05 08:47:29 -07002122if [ "$CONFIG_SADIS" == "external" ]; then
2123 STIME="$(date +%s)"
2124 echo -e "Verify BBSIM SADIS Service $PLUG"
2125 bspin - "Verify required configmap"
2126 (set -x; kubectl -n "$BBSIM_NS" delete --ignore-not-found configmap kube-config >>"$LOG" 2>&1) >>"$LOG" 2>&1
2127 (set -x; kubectl -n "$BBSIM_NS" create configmap kube-config "--from-file=kube_config=$KUBECONFIG" >>"$LOG" 2>&1) >>"$LOG" 2>&1
2128 espin - "$VERIFIED"
2129 bspin - "Verify BBSIM SADIS Service Installed"
2130 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$BBSIM_NS" "^bbsim-sadis-servier\$" | wc -l)" -ne 1 ]; then
2131 espin - "$NOT_VERIFIED"
2132 helm_install - "$BBSIM_NS" bbsim-sadis-server "$BBSIM_SADIS_SERVER_CHART" "$BBSIM_SADIS_SERVER_CHART_VERSION" "$_HELM_DESC BBSIM SADIS Server"
2133 else
2134 espin - "$VERIFIED"
2135 fi
2136 wait_for_pods - "$BBSIM_NS" 1 "includes" "Waiting for BBSIM SADIS Server to start" "$NO_LABEL" "bbsim-sadis-server-.*"
2137 if [ "$WITH_TIMINGS" == "yes" ]; then
2138 NOW="$(date +%s)"
2139 printtime $((NOW - STIME))
2140 fi
2141fi
2142
David Bainbridged18f4942020-04-14 16:46:13 -07002143if [ "$WITH_RADIUS" == "yes" ]; then
2144 STIME="$(date +%s)"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002145 echo -e "Verify RADIUS $LOCK"
2146 bspin - "Verify RADIUS Installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002147 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^radius\$" | wc -l)" -ne 1 ]; then
2148 espin - "$NOT_VERIFIED"
2149 helm_install - "$INFRA_NS" radius onf/freeradius latest "$_HELM_DESC RADIUS"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002150 else
David Bainbridged18f4942020-04-14 16:46:13 -07002151 espin - "$VERIFIED"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002152 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002153 wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for RADIUS to start" "$NO_LABEL" "radius-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00002154 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002155 NOW="$(date +%s)"
2156 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002157 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002158fi
2159
David Bainbridged18f4942020-04-14 16:46:13 -07002160if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
2161 STIME="$(date +%s)"
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002162 bspin - "Forward VOLTHA API port $FORWARD"
2163 kill_port_forward voltha-api
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002164 port_forward "$VOLTHA_NS" voltha-api "$VOLTHA_API_PORT:55555"
David Bainbridged18f4942020-04-14 16:46:13 -07002165 espin - "$VERIFIED"
2166 if [ "$WITH_ETCD" == "yes" ] || [ "$WITH_ETCD" == "external" ]; then
2167 _NS="$(test "$WITH_ETCD" == "yes" && echo "$VOLTHA_NS" || echo "$INFRA_NS")"
David Bainbridge696bc632020-04-05 21:49:37 -07002168 bspin - "Forward VOLTHA ETCD port $FORWARD"
David Bainbridged18f4942020-04-14 16:46:13 -07002169 kill_port_forward "${ETCD_PREFIX}etcd-cluster-client"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002170 port_forward "$_NS" "${ETCD_PREFIX}etcd-cluster-client" "$VOLTHA_ETCD_PORT:2379"
David Bainbridged18f4942020-04-14 16:46:13 -07002171 espin - "$VERIFIED"
David Bainbridge696bc632020-04-05 21:49:37 -07002172 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002173 if [ "$WITH_KAFKA" == "yes" ] || [ $WITH_KAFKA == "external" ]; then
2174 _NS="$(test "$WITH_ETCD" == "yes" && echo "$VOLTHA_NS" || echo "$INFRA_NS")"
David Bainbridge696bc632020-04-05 21:49:37 -07002175 bspin - "Forward VOLTHA Kafka port $FORWARD"
David Bainbridged18f4942020-04-14 16:46:13 -07002176 kill_port_forward "${KAFKA_PREFIX}kafka"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002177 port_forward "$_NS" ${KAFKA_PREFIX}kafka "$VOLTHA_KAFKA_PORT:9092"
David Bainbridged18f4942020-04-14 16:46:13 -07002178 espin - "$VERIFIED"
David Bainbridge696bc632020-04-05 21:49:37 -07002179 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -07002180 if [ "$WITH_PPROF" == "yes" ]; then
2181 bspin - "Forward PProf ports port $FORWARD"
2182 kill_port_forward voltha-rw-core-profiler
2183 kill_port_forward adapter-open-olt-profiler
Matteo Scandolo65c35192020-05-13 10:41:21 -07002184 kill_port_forward voltha-of-agent-profiler
Matteo Scandoloefee0432020-05-05 13:56:20 -07002185 port_forward "$VOLTHA_NS" voltha-rw-core-profiler "$VOLTHA_PPROF_PORT:6060"
2186 port_forward "$VOLTHA_NS" adapter-open-olt-profiler "$OPENOLT_PPROF_PORT:6060"
Matteo Scandolo65c35192020-05-13 10:41:21 -07002187 port_forward "$VOLTHA_NS" voltha-of-agent-profiler "$OFAGENT_PPROF_PORT:6060"
Matteo Scandoloefee0432020-05-05 13:56:20 -07002188 espin - "$VERIFIED"
2189 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002190 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002191 NOW="$(date +%s)"
2192 printtime $((NOW - STIME))
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002193 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00002194fi
Test User3d7ad8e2019-07-03 06:15:44 +00002195
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002196if is_in "$WITH_ONOS" "yes,legacy,classic" && [ "$WITH_RADIUS" != "no" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -07002197 _HOST=radius.$INFRA_NS.svc.cluster.local
David Bainbridge696bc632020-04-05 21:49:37 -07002198 _PORT=1812
David Bainbridged18f4942020-04-14 16:46:13 -07002199 if [ "$WITH_RADIUS" != "yes" ]; then
2200 _HOST="$(echo "$WITH_RADIUS" | cut -d: -f1)"
2201 _PORT="$(echo "$WITH_RADIUS" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07002202 _PORT=${_PORT:-1812}
2203 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002204 bspin "Configure ONOS RADIUS Connection $GEAR"
David Bainbridged18f4942020-04-14 16:46:13 -07002205 (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
2206 espin "$VERIFIED"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002207fi
2208
David Bainbridge99ac7a22019-08-31 02:26:43 +00002209if [ "$WITH_CHAOS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002210 STIME="$(date +%s)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002211 echo -e "Verify kube-monkey $LOCK"
2212 bspin - "Verify kube-monkey Installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002213 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace kube-monkey "^monkey\$" | wc -l)" -ne 1 ]; then
2214 espin - "$NOT_VERIFIED"
David Bainbridge7f8bf992020-04-08 21:53:22 -07002215 helm_install - kube-monkey monkey ./kube-monkey/helm/kubemonkey latest "$_HELM_DESC Chaos Monkey"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002216 else
David Bainbridged18f4942020-04-14 16:46:13 -07002217 espin - "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002218 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002219 wait_for_pods - "kube-monkey" 1 "includes" "Waiting for Chaos to start" "$NO_LABEL" "monkey-.*"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002220 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002221 NOW="$(date +%s)"
2222 printtime $((NOW - STIME))
David Bainbridge99ac7a22019-08-31 02:26:43 +00002223 fi
2224fi
2225
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002226bspin "Create voltctl configuration file"
David Bainbridged18f4942020-04-14 16:46:13 -07002227(set -x; mkdir -p "$HOME/.volt" >>"$LOG" 2>&1) >>"$LOG" 2>&1
2228MIN_VC_VERSION="$(echo -e "1.0.15\n$VC_VERSION" | sort -V | head -1)"
2229if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002230 KAFKA_FLAG="-k localhost:$VOLTHA_KAFKA_PORT"
2231 SERVER_FLAG="-s localhost:$VOLTHA_API_PORT"
2232 ETCD_FLAG=
2233 if [ "$MIN_VC_VERSION" == "1.0.15" ]; then
2234 ETCD_FLAG="-e localhost:$VOLTHA_ETCD_PORT"
2235 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002236else
David Bainbridged18f4942020-04-14 16:46:13 -07002237 KAFKA_FLAG="-k $(get_service_ep "$INFRA_NS" "${KAFKA_PREFIX}kafka")"
2238 SERVER_FLAG="-s $(get_service_ep "$VOLTHA_NS" voltha-api)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002239 ETCD_FLAG=
2240 if [ "$MIN_VC_VERSION" == "1.0.15" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002241 ETCD_FLAG="-e $(get_service_ep "$INFRA_NS" ${ETCD_PREFIX}etcd-client)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002242 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002243fi
David Bainbridged18f4942020-04-14 16:46:13 -07002244CMD=("voltctl -a v3 $KAFKA_FLAG $SERVER_FLAG $ETCD_FLAG config")
2245(set -x; ${CMD[*]} > "$HOME/.volt/config-$NAME" 2>>"$LOG") >>"$LOG" 2>&1
2246#(set -x; voltctl -a v3 "$KAFKA_FLAG" "$SERVER_FLAG" "$ETCD_FLAG" config > "$HOME/.volt/config-$NAME" 2>>"$LOG") >>"$LOG" 2>&1
2247espin "$VERIFIED"
Test User08ebbd92019-07-03 17:15:39 +00002248
David Bainbridge0774b232019-08-02 06:37:19 +00002249if [ ! -f "$NAME-env.sh" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002250 touch "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002251fi
2252
David Bainbridge596f30d2019-07-30 17:07:59 +00002253for O in $ALL_OPTIONS; do
David Bainbridged18f4942020-04-14 16:46:13 -07002254 VAL="$(eval echo "\$$O")"
2255 if [ -n "$VAL" ] && [ "$(grep -c "^export $O=" "$NAME-env.sh")" -eq 0 ]; then
2256 echo "export $O=\"$(eval echo "\$$O")\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002257 fi
2258done
2259
David Bainbridged18f4942020-04-14 16:46:13 -07002260if [ "$DEPLOY_K8S" == "yes" ] && [ "$(grep -c "^export KUBECONFIG=" "$NAME-env.sh")" -eq 0 ]; then
2261 echo "export KUBECONFIG=\"$(./bin/kind get kubeconfig-path "--name=voltha-$NAME")\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002262fi
2263
David Bainbridged18f4942020-04-14 16:46:13 -07002264if [ "$(grep -c "^export VOLTCONFIG=" "$NAME-env.sh")" -eq 0 ]; then
2265 echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002266fi
2267
David Bainbridged18f4942020-04-14 16:46:13 -07002268if [ "$(grep -c "^export PATH=" "$NAME-env.sh")" -eq 0 ]; then
2269 echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002270fi
2271
Test User7d866122019-07-09 17:52:35 +00002272echo ""
David Bainbridged18f4942020-04-14 16:46:13 -07002273echo "Please issue the following commands in your terminal to ensure that you" | tee -a "$LOG"
2274echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a "$LOG"
2275echo "tools required by VOLTHA in your command path. " | tee -a "$LOG"
2276echo "" | tee -a "$LOG"
2277echo -en "$BOLD"
2278if [ "$DEPLOY_K8S" == "yes" ]; then
2279 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00002280fi
David Bainbridged18f4942020-04-14 16:46:13 -07002281echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" | tee -a "$LOG"
2282echo "export PATH=$GOPATH/bin:\$PATH" | tee -a "$LOG"
2283echo -en "$NORMAL"
2284echo "" | tee -a "$LOG"
2285echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a "$LOG"
Test User08ebbd92019-07-03 17:15:39 +00002286
David Bainbridge712afb82019-08-14 19:55:58 +00002287if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002288 NOW="$(date +%s)"
2289 echo -e "$CLOCK ${BOLD}TOTAL: $(duration $((NOW - TOTAL_START_TIME)))${NORMAL}"
David Bainbridge712afb82019-08-14 19:55:58 +00002290fi