blob: 7c3c8f37775ed71c520b17e3ae0fa54720ffe505 [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}
David Bainbridge05cd8822019-11-19 17:43:53 +000089ONLY_ONE=${ONLY_ONE:-yes}
David K. Bainbridgeb859e912020-03-13 14:07:52 -070090CONFIG_SADIS=${CONFIG_SADIS:-no} # yes | no | file | bbsim | URL
David Bainbridge76afd812020-04-06 09:53:52 -070091SADIS_SUBSCRIBERS=${SADIS_SUBSCRIBERS:-http://bbsim.$VOLTHA_NS.svc:50074/v2/subscribers/%s}
92SADIS_BANDWIDTH_PROFILES=${SADIS_BANDWIDTH_PROFILES:-http://bbsim.$VOLTHA_NS.svc:50074/v2/bandwidthprofiles/%s}
Hardik Windlassb3147602020-03-09 16:59:15 +053093SADIS_CFG=${SADIS_CFG:-onos-files/onos-sadis-sample.json}
David Bainbridge27790d62019-08-13 22:43:19 +000094INSTALL_ONOS_APPS=${INSTALL_ONOS_APPS:-no}
Test Userba1e7e72019-07-10 22:27:54 +000095JUST_K8S=${JUST_K8S:-no}
96DEPLOY_K8S=${DEPLOY_K8S:-yes}
David K. Bainbridge0e89cb92019-07-17 11:30:10 -070097INSTALL_KUBECTL=${INSTALL_KUBECTL:-yes}
98INSTALL_HELM=${INSTALL_HELM:-yes}
David Bainbridge7f8bf992020-04-08 21:53:22 -070099HELM_USE_UPGRADE=${HELM_USE_UPGRADE:-no}
David Bainbridge46505fb2019-10-01 21:13:20 +0000100UPDATE_HELM_REPOS=${UPDATE_HELM_REPOS:-yes}
Matteo Scandolofab98622020-01-28 15:17:20 -0800101WAIT_ON_DOWN=${WAIT_ON_DOWN:-yes}
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700102WAIT_TIMEOUT=${WAIT_TIMEOUT:-30m}
103VOLTHA_DOWN_ON_TIMEOUT=${VOLTHA_DOWN_ON_TIMEOUT:-no}
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000104VOLTHA_LOG_LEVEL=${VOLTHA_LOG_LEVEL:-WARN}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000105VOLTHA_CHART=${VOLTHA_CHART:-onf/voltha}
106VOLTHA_CHART_VERSION=${VOLTHA_CHART_VERSION:-latest}
107VOLTHA_BBSIM_CHART=${VOLTHA_BBSIM_CHART:-onf/bbsim}
Matteo Scandolodcd29f52019-10-07 15:42:42 -0700108VOLTHA_BBSIM_CHART_VERSION=${VOLTHA_BBSIM_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000109VOLTHA_ADAPTER_SIM_CHART=${VOLTHA_ADAPTER_SIM_CHART:-onf/voltha-adapter-simulated}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000110VOLTHA_ADAPTER_SIM_CHART_VERSION=${VOLTHA_ADAPTER_SIM_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000111VOLTHA_ADAPTER_OPEN_OLT_CHART=${VOLTHA_ADAPTER_OPEN_OLT_CHART:-onf/voltha-adapter-openolt}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000112VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION=${VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000113VOLTHA_ADAPTER_OPEN_ONU_CHART=${VOLTHA_ADAPTER_OPEN_ONU_CHART:-onf/voltha-adapter-openonu}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000114VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION=${VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION:-latest}
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800115ONOS_CHART=${ONOS_CHART:-onf/onos}
Andrea Campanella21323292019-12-18 11:44:19 -0800116ONOS_CHART_VERSION=${ONOS_CHART_VERSION:-latest}
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700117ONOS_CLASSIC_CHART=${ONOS_CLASSIC_CHART:-onos/onos-classic}
118ONOS_CLASSIC_CHART_VERSION=${ONOS_CHART_VERSION:-latest}
David Bainbridgecf546362020-04-21 23:18:50 -0700119KAFKA_CHART=${KAFKA_CHART:-incubator/kafka}
David Bainbridgeb9093522020-04-15 14:32:44 -0700120KAFKA_CHART_VERSION=${KAFKA_CHART_VERSION:=0.15.3}
David Bainbridge2eaf2cf2020-03-18 12:54:08 -0700121EXTRA_HELM_INSTALL_ARGS=${EXTRA_HELM_INSTALL_ARGS:-}
122INTERNAL_EXTRA_HELM_INSTALL_ARGS=
uottrembb16d3982020-02-28 08:34:36 +0100123NUM_OF_BBSIM=${NUM_OF_BBSIM:-1}
Matteo Scandolo67335f02020-04-09 11:19:53 -0700124NUM_OF_OPENONU=${NUM_OF_OPENONU:-1}
uottrembb16d3982020-02-28 08:34:36 +0100125MAX_NUM_OF_BBSIM=10
Matteo Scandolo67335f02020-04-09 11:19:53 -0700126MAX_NUM_OF_OPENONU=10
Test Userba1e7e72019-07-10 22:27:54 +0000127
David Bainbridged18f4942020-04-14 16:46:13 -0700128HOSTOS="$(uname -s | tr "[:upper:]" "[:lower:"])"
129HOSTARCH="$(uname -m | tr "[:upper:]" "[:lower:"])"
130if [ "$HOSTARCH" == "x86_64" ]; then
Test Userba1e7e72019-07-10 22:27:54 +0000131 HOSTARCH="amd64"
132fi
David Bainbridge7db44002020-04-09 12:54:29 -0700133BBSIM_LABEL="-l app=bbsim"
David Bainbridged18f4942020-04-14 16:46:13 -0700134NO_LABEL=
Test User7d866122019-07-09 17:52:35 +0000135
uottrembb16d3982020-02-28 08:34:36 +0100136# check number (range) of bbsim, max bbsim must not exceed 10 instances!
137# note: instances will be numbered from 0 to 9
138if [ "$1" == "up" ]; then
David K. Bainbridge43422402020-03-06 07:41:22 -0800139 if [ "$NUM_OF_BBSIM" -lt 1 ]; then
Matteo Scandolo67335f02020-04-09 11:19:53 -0700140 >&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 -0800141 exit 1
142 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700143 if [ "$NUM_OF_BBSIM" -gt "$MAX_NUM_OF_BBSIM" ]; then
Matteo Scandolo67335f02020-04-09 11:19:53 -0700144 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid setting of BBSIM instances. NUM_OF_BBSIM (${NUM_OF_BBSIM}) is greater than $MAX_NUM_OF_BBSIM${NORMAL}"
145 exit 1
146 fi
147
148 if [ "$NUM_OF_OPENONU" -lt 1 ]; then
149 >&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}"
150 exit 1
151 fi
152 if [ "$NUM_OF_OPENONU" -gt "$MAX_NUM_OF_OPENONU" ]; then
153 >&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 -0800154 exit 1
155 fi
uottrembb16d3982020-02-28 08:34:36 +0100156fi
Test User7d866122019-07-09 17:52:35 +0000157# Verify TYPE setting
David Bainbridged18f4942020-04-14 16:46:13 -0700158if [ "$(echo ":minimal:full:" | grep -ic ":$TYPE:")" -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700159 >&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 +0000160 exit 1
161fi
162
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700163# checks to see if a given WORD is in the given LIST of words
164function is_in() {
165 local WORD LIST
166 WORD="$1"; shift
167 LIST="$*"
168 LIST=${LIST//+([[:space:],|])/:}
169
170 [ "$(echo ":$LIST:" | grep -ic ":$WORD:")" -ne 0 ]
171}
172
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700173function parseDuration() {
David Bainbridged18f4942020-04-14 16:46:13 -0700174 local DUR RESULT TERM TERMS VALUE UNIT
175 DUR=$1
176 RESULT=0
177 TERMS="$(echo "$DUR" | sed -Ee 's/([sSmMhHdD])/\1 /g' -e 's/,$//g')"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700178 for TERM in $TERMS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700179 VALUE="$(echo "$TERM" | sed -Ee 's/([0-9]+)[sSmMhHdD]/\1/')"
180 UNIT="$(echo "$TERM" | sed -Ee 's/[0-9]+([sSmMhHdD])/\1/')"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700181 case $UNIT in
182 s|S)
David Bainbridged18f4942020-04-14 16:46:13 -0700183 RESULT=$((RESULT + VALUE)) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700184 m|M)
David Bainbridged18f4942020-04-14 16:46:13 -0700185 RESULT=$((RESULT + (VALUE * 60))) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700186 h|H)
David Bainbridged18f4942020-04-14 16:46:13 -0700187 RESULT=$((RESULT + (VALUE * 3600))) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700188 d|D)
David Bainbridged18f4942020-04-14 16:46:13 -0700189 RESULT=$((RESULT + (VALUE * 86400))) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700190 *) ;;
191 esac
192 done
193 echo $RESULT
194}
195
196function doTimeout() {
197 local MSG=$1
198 2>&1 echo -e "\n${RED}${BOLD}${ERROR}TIMEOUT:${NORMAL}${RED} Operation timed out after '$WAIT_TIMEOUT': $MSG"
199 exit 125
200}
201
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800202function get_service_ep() {
203 local NS=$1
204 local NAME=$2
David Bainbridged18f4942020-04-14 16:46:13 -0700205 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 -0800206}
207
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000208# Used to verify configuration values are set to "yes" or "no" value or convert
209# equivalents to "yes" or "no"
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700210YES="y,yes,t,true,1"
211NO="n,no,f,false,0"
212YES_OR_NO="$YES,$NO"
213
214# If the given VAR matches a truth value then normalize that
215# value, else return original value
216function normalize_yes_no() {
217 local VAR VAL
218 VAR=$1
219 VAL="$(eval echo "\$$VAR")"
220 if ! is_in "$VAL" "$YES_OR_NO"; then
221 echo "$VAL"
222 return 1
223 fi
224 if is_in "$VAL" "$YES"; then
225 echo "yes"
226 else
227 echo "no"
228 fi
229 return 0
230}
231
232# If the given VAR matches a truth value then normalize that
233# value, else display an error
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000234function verify_yes_no() {
David Bainbridged18f4942020-04-14 16:46:13 -0700235 local VAR VAL
236 VAR=$1
237 VAL="$(eval echo "\$$VAR")"
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700238 if ! is_in "$VAL" "$YES_OR_NO"; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000239 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid '$VAR' value of '$VAL'. Should be 'yes' or 'no'${NORMAL}"
240 echo "INVALID"
241 return 1
242 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700243 if is_in "$VAL" "$YES"; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000244 echo "yes"
245 else
246 echo "no"
247 fi
248 return 0
249}
Test User7d866122019-07-09 17:52:35 +0000250
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000251ALL_YES_NO="\
David K. Bainbridge484d80c2020-03-05 21:44:34 -0800252 ENABLE_ONOS_EXTRANEOUS_RULES \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000253 WITH_TIMINGS \
254 WITH_BBSIM \
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800255 WITH_EAPOL \
256 WITH_DHCP \
257 WITH_IGMP \
David Bainbridge99ac7a22019-08-31 02:26:43 +0000258 WITH_CHAOS \
David Bainbridge46505fb2019-10-01 21:13:20 +0000259 WITH_ADAPTERS \
260 WITH_SIM_ADAPTERS \
261 WITH_OPEN_ADAPTERS \
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800262 WITH_PORT_FORWARDS \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000263 JUST_K8S \
264 DEPLOY_K8S \
265 INSTALL_ONOS_APPS \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000266 INSTALL_KUBECTL \
267 INSTALL_HELM \
David Bainbridge7f8bf992020-04-08 21:53:22 -0700268 HELM_USE_UPGRADE \
David Bainbridge46505fb2019-10-01 21:13:20 +0000269 UPDATE_HELM_REPOS \
David Bainbridge4f1b5562019-08-19 04:46:52 +0000270 WAIT_ON_DOWN \
David Bainbridge70c0ea82019-11-14 23:25:26 +0000271 ONLY_ONE \
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700272 VOLTHA_DOWN_ON_TIMEOUT \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000273 "
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000274
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700275OPT_YES_NO="\
276 CONFIG_SADIS \
277 WITH_KAFKA \
278 WITH_RADIUS \
279 WITH_ETCD \
280 WITH_ONOS \
281 "
282
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000283ALL_OPTIONS="\
284 NAME \
285 TYPE \
286 $ALL_YES_NO \
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700287 $OPT_YES_NO \
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700288 WAIT_TIMEOUT \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000289 VOLTHA_LOG_LEVEL \
290 VOLTHA_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000291 VOLTHA_CHART_VERSION \
292 VOLTHA_BBSIM_CHART \
293 VOLTHA_BBSIM_CHART_VERSION \
uottrembd5a20572020-03-06 09:15:01 +0100294 NUM_OF_BBSIM \
Matteo Scandolo67335f02020-04-09 11:19:53 -0700295 NUM_OF_OPENONU \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000296 VOLTHA_ADAPTER_SIM_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000297 VOLTHA_ADAPTER_SIM_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000298 VOLTHA_ADAPTER_OPEN_OLT_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000299 VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000300 VOLTHA_ADAPTER_OPEN_ONU_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000301 VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION \
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800302 ONOS_CHART \
Andrea Campanella21323292019-12-18 11:44:19 -0800303 ONOS_CHART_VERSION \
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700304 ONOS_CLASSIC_CHART \
305 ONOS_CLASSIC_CHART_VERSION \
David Bainbridgecf546362020-04-21 23:18:50 -0700306 KAFKA_CHART \
David Bainbridgeb9093522020-04-15 14:32:44 -0700307 KAFKA_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000308 ONOS_API_PORT \
309 ONOS_SSH_PORT \
Hardik Windlassb3147602020-03-09 16:59:15 +0530310 SADIS_CFG \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000311 VOLTHA_API_PORT \
312 VOLTHA_SSH_PORT \
313 VOLTHA_ETCD_PORT \
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800314 VOLTHA_KAFKA_PORT \
David K. Bainbridge8f7f30b2020-01-08 13:06:16 -0800315 VK_RELEASE \
316 KIND_VERSION \
317 VOLTCTL_VERSION \
David Bainbridgea34993d2020-04-01 09:15:42 -0700318 HELM_VERSION \
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700319 NUM_OF_ONOS \
320 NUM_OF_ATOMIX \
David Bainbridge6ca40102020-04-08 11:30:40 -0700321 VOLTHA_NS \
322 ADAPTER_NS \
323 INFRA_NS \
324 BBSIM_NS \
David Bainbridge7db44002020-04-09 12:54:29 -0700325 SADIS_BANDWIDTH_PROFILES \
326 SADIS_SUBSCRIBERS \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000327 "
David Bainbridge01294952019-07-30 19:33:45 +0000328
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000329# Iterate over yes/no configuration options and validate
330for VAR in $ALL_YES_NO; do
David Bainbridged18f4942020-04-14 16:46:13 -0700331 eval "$VAR"="$(verify_yes_no "$VAR")"
332 if [ "$(eval echo "\$$VAR")" == "INVALID" ]; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000333 exit 1;
334 fi
335done
David Bainbridgeb270c202019-07-26 01:44:42 +0000336
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700337# Iterate over optional yes/no configuration options and
338# normalize values if they are truth values
339for VAR in $OPT_YES_NO; do
340 eval "$VAR"="$(normalize_yes_no "$VAR")"
341done
David Bainbridge15f6f232020-03-30 09:15:43 -0700342
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700343# normalize non-truth value options
344if is_in "$WITH_KAFKA" "e,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -0700345 WITH_KAFKA="external"
346fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700347if is_in "$WITH_ETCD" "e,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -0700348 WITH_ETCD="external"
349fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700350if is_in "$WITH_ONOS" "l,legacy"; then
351 WITH_ONOS="legacy"
352elif is_in "$WITH_ONOS" "c,classic"; then
353 WITH_ONOS="classic"
354elif is_in "$WITH_ONOS" "u,m,micro"; then
355 WITH_ONOS="micro"
David Bainbridge29c31cb2020-04-06 09:45:50 -0700356fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700357
358if [ "$WITH_ONOS" == "micro" ]; then
359 >&2 echo -e "${YELLOW}${BOLD}${ERROR}WARNING:${NORMAL}${YELLOW} The value specified as WITH_ONOS, '$WITH_ONOS', is not valid.${NORMAL}"
360 exit 1
David Bainbridge29c31cb2020-04-06 09:45:50 -0700361fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700362
363if is_in "$WITH_ONOS" "yes,classic"; then
364 # there is an extra utility required if we are using ONOS CLASSIC as
365 # the chart for classic specifies images differently
366 EXTRA_TOOLS+=" yq"
David Bainbridge76afd812020-04-06 09:53:52 -0700367fi
David Bainbridge696bc632020-04-05 21:49:37 -0700368
David Bainbridged18f4942020-04-14 16:46:13 -0700369if [ "$HELM_USE_UPGRADE" == "yes" ]; then
David Bainbridge7f8bf992020-04-08 21:53:22 -0700370 _HELM_DESC="Upgrade/Install"
371else
372 _HELM_DESC="Install"
373fi
374
David Bainbridged18f4942020-04-14 16:46:13 -0700375ETCD_PREFIX=
376KAFKA_PREFIX=
377if [ "$WITH_ETCD" == "yes" ]; then
378 ETCD_PREFIX="voltha-"
379fi
380if [ "$WITH_KAFKA" == "yes" ]; then
381 KAFKA_PREFIX="voltha-"
382fi
383
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800384# Check for prerequiste tools
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700385TOOLS="curl sed jq $EXTRA_TOOLS"
David Bainbridged18f4942020-04-14 16:46:13 -0700386if [ "$DEPLOY_K8S" == "yes" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800387 TOOLS+=" docker"
388fi
389NOT_FOUND=""
390for T in $TOOLS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700391 if [ -z "$(command -v "$T")" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800392 NOT_FOUND+=" $T"
393 fi
394done
395
David Bainbridged18f4942020-04-14 16:46:13 -0700396if [ -n "$NOT_FOUND" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800397 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} The following required tools where not found, please install them:$NOT_FOUND"
398 exit 1
399fi
400
David Bainbridged18f4942020-04-14 16:46:13 -0700401TIMEOUT_SECONDS="$(parseDuration "$WAIT_TIMEOUT")"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700402
David Bainbridge0774b232019-08-02 06:37:19 +0000403mkdir -p .voltha
404touch .voltha/ports
David Bainbridged18f4942020-04-14 16:46:13 -0700405HAVE="$(grep "$NAME" .voltha/ports)"
David Bainbridge0774b232019-08-02 06:37:19 +0000406if [ "$HAVE X" == " X" ]; then
407 # Find free port prefix
408 START=81
409 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700410 if [ "$(grep -c $START .voltha/ports)" -eq 0 ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000411 break
412 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700413 START="$((START + 1))"
David Bainbridge0774b232019-08-02 06:37:19 +0000414 done
David Bainbridged18f4942020-04-14 16:46:13 -0700415 DELTA="$((START - 81))"
David Bainbridgea2595422019-10-22 03:54:28 +0000416 ONOS_API_PORT=${ONOS_API_PORT:-${START}81}
417 ONOS_SSH_PORT=${ONOS_SSH_PORT:-${START}01}
David Bainbridged18f4942020-04-14 16:46:13 -0700418 VOLTHA_API_PORT=${VOLTHA_API_PORT:-5$((55 + DELTA))55}
419 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$((50 + DELTA))22}
420 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$((23 + DELTA))79}
421 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$((90 + DELTA))92}
Test User01ed0642019-07-03 20:17:06 +0000422else
David Bainbridged18f4942020-04-14 16:46:13 -0700423 VALUES="$(echo "$HAVE" | sed -e 's/\s//g' | cut -d= -f2)"
424 ONOS_API_PORT=${ONOS_API_PORT:-$(echo "$VALUES" | cut -d, -f1)}
425 ONOS_SSH_PORT=${ONOS_SSH_PORT:-$(echo "$VALUES" | cut -d, -f2)}
426 VOLTHA_API_PORT=${VOLTHA_API_PORT:-$(echo "$VALUES" | cut -d, -f3)}
427 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$(echo "$VALUES" | cut -d, -f4)}
428 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$(echo "$VALUES" | cut -d, -f5)}
429 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(echo "$VALUES" | cut -d, -f6)}
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800430
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800431 # A bit of a hueristic required here as the KAFKA port forward was
432 # added after the .voltha/ports files was created. Basically, if
433 # the VOLTHA_KAFKA_PORT isn't in the file then calculate the original
434 # DELTA from the VOLTHA_SSH_PORT and apply it to the VOLTHA_KAFKA_PORT
435 if [ -z "$VOLTHA_KAFKA_PORT" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -0700436 DELTA="$((VOLTHA_SSH_PORT/100-50))"
437 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$((90 + DELTA))92}
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800438 fi
Test User01ed0642019-07-03 20:17:06 +0000439fi
440
David Bainbridged18f4942020-04-14 16:46:13 -0700441PORTTMP="$(mktemp -u)"
442grep -v "$NAME" .voltha/ports > "$PORTTMP"
443echo "$NAME=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT,$VOLTHA_KAFKA_PORT" >> "$PORTTMP"
444cp "$PORTTMP" .voltha/ports
445rm -f "$PORTTMP"
David Bainbridge0774b232019-08-02 06:37:19 +0000446
David Bainbridge27790d62019-08-13 22:43:19 +0000447export ONOS_API_PORT ONOS_SSH_PORT
David Bainbridge01294952019-07-30 19:33:45 +0000448
Test Userd87942b2019-07-03 07:20:24 +0000449IDX=1
David Bainbridgee87067b2019-08-12 22:00:12 +0000450CLOCK="TIME:"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000451SPIN_PARTS=
452NOT_VERIFIED=
David Bainbridgef858a022019-08-14 21:25:11 +0000453THEX=
454BUILD=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000455VERIFIED=
456HELM=
457OLD_KEY=
458BIRD=
459HIGH_VOLTAGE=
460PLUG=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000461FORWARD=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000462GO=
463DOWNLOAD=
464GEAR=
465NO_ENTRY=
466LOCK=
467
David Bainbridged18f4942020-04-14 16:46:13 -0700468if [ "$FANCY" -eq 1 ]; then
469 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 +0000470 CLOCK="\xe2\x8f\xb1"
David Bainbridgef858a022019-08-14 21:25:11 +0000471 THEX="${RED}${BOLD}\xe2\x9c\x97\x20${NORMAL}"
David Bainbridgef858a022019-08-14 21:25:11 +0000472 BUILD="${YELLOW}${BOLD}\xf0\x9f\x8f\x97${NORMAL}"
473 NOT_VERIFIED="$BUILD"
474 VERIFIED="${GREEN}${BOLD}\xe2\x9c\x93\x20${NORMAL}"
475 HELM="${BLUE}${BOLD}\xE2\x8E\x88${NORMAL}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000476 OLD_KEY="\xF0\x9F\x97\x9D"
477 BIRD="\xF0\x9F\x90\xA6"
478 HIGH_VOLTAGE="\xE2\x9A\xA1"
479 PLUG="\xF0\x9F\xa7\xa9"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000480 FORWARD="\xE2\x87\xA8"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000481 GO="\xf0\x9f\x9a\x80"
482 DOWNLOAD="\xf0\x9f\x93\xa5"
483 GEAR="\xe2\x9a\x99"
484 NO_ENTRY="\xe2\x9b\x94"
485 LOCK="\xf0\x9f\x94\x92"
486fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700487
David Bainbridge712afb82019-08-14 19:55:58 +0000488duration() {
David Bainbridged18f4942020-04-14 16:46:13 -0700489 local h m s t
490 h="$(($1 / 3600))"
491 m="$(($1 % 3600 / 60))"
492 s="$(($1 % 60))"
493 t=""
David Bainbridgee87067b2019-08-12 22:00:12 +0000494
David Bainbridged18f4942020-04-14 16:46:13 -0700495 if [ "$h" -gt 0 ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +0000496 t="$t${h}h"
497 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700498 if [ "$m" -gt 0 ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +0000499 t="$t${m}m"
500 fi
David Bainbridge712afb82019-08-14 19:55:58 +0000501 echo "$t${s}s"
502}
503
504printtime() {
David Bainbridged18f4942020-04-14 16:46:13 -0700505 local INDENT
David Bainbridge712afb82019-08-14 19:55:58 +0000506 if [ "$1" == "-" ]; then
507 INDENT=" "
508 shift
509 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700510 echo -e "$INDENT $CLOCK $(duration "$1")"
David Bainbridgee87067b2019-08-12 22:00:12 +0000511}
512
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700513bspin() {
Test Userd87942b2019-07-03 07:20:24 +0000514 IDX=1
David Bainbridged18f4942020-04-14 16:46:13 -0700515 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700516 if [ "$1" == "-" ]; then
517 INDENT=" "
518 shift
519 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700520 if [ "$FANCY" -eq 0 ]; then
521 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000522 if [ "$LINE X" == " X" ]; then
523 return
524 fi
525 echo -e "$CIVIS$INDENT$*"
526 else
527 echo -en "$CIVIS$INDENT $*"
528 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700529}
530
531sspin() {
David Bainbridged18f4942020-04-14 16:46:13 -0700532 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700533 if [ "$1" == "-" ]; then
534 INDENT=" "
535 shift
536 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700537 if [ "$FANCY" -eq 0 ]; then
538 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000539 if [ "$LINE X" == " X" ]; then
540 return
541 fi
542 echo -e "$INDENT$*"
543 else
David Bainbridged18f4942020-04-14 16:46:13 -0700544 C="$(echo "$SPIN_PARTS" | cut '-d ' -f "$IDX")"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000545 echo -en "\r$INDENT$C $*"
David Bainbridged18f4942020-04-14 16:46:13 -0700546 IDX="$((IDX + 1))"
547 if [ "$IDX" -gt 8 ]; then
David Bainbridge38dc1e82019-08-12 15:18:45 +0000548 IDX=1
549 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700550 fi
551}
552
553espin() {
David Bainbridged18f4942020-04-14 16:46:13 -0700554 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700555 if [ "$1" == "-" ]; then
556 INDENT=" "
557 shift
558 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700559 if [ "$FANCY" -eq 0 ]; then
560 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000561 if [ "$LINE X" == " X" ]; then
562 return
563 fi
564 echo -e "$INDENT$*"
565 else
566 echo -e "\r$INDENT$*$CNORM"
567 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700568}
569
David Bainbridged18f4942020-04-14 16:46:13 -0700570if [ "$1" == "get" ] && [ "$2" == "voltconfig" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000571 echo "$HOME/.volt/config-$NAME"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000572 exit
573fi
574
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700575if [ $# -ne 1 ] || ! is_in "$1" "up,down,dump"; then
David Bainbridgeac7f8072019-08-01 22:15:33 +0000576 >&2 echo "What wouild you like to do today:"
577 >&2 echo " up - bring up voltha"
578 >&2 echo " down - tear down voltha"
579 >&2 echo " dump - create a debug dump of running system"
580 exit 1
581fi
582
David Bainbridge4f1b5562019-08-19 04:46:52 +0000583push_onos_config() {
David Bainbridged18f4942020-04-14 16:46:13 -0700584 local TYPE MSG RESOURCE DATA CMD_ECHO CMD_OUTPUT SC_OUTPUT WAIT_START NOW
585 TYPE=$1
586 MSG=$2
587 RESOURCE=$3
588 DATA=$4
David Bainbridge4f1b5562019-08-19 04:46:52 +0000589
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800590 # Thanks to the latest version of ONOS using the return code 207 this gets a
591 # whole lot nastier. Can't thank them enough for doing this. So in order to
592 # capture the command and the output in the log file as well as capture the
593 # status code to verify it is 200 and not 207 mutltiple files and a bit of
594 # hackery must be used. Thanks again ONOS.
David Bainbridged18f4942020-04-14 16:46:13 -0700595 CMD_ECHO="$(mktemp -u)"
596 CMD_OUTPUT="$(mktemp -u)"
597 SC_OUTPUT="$(mktemp -u)"
598 WAIT_START="$(date +%s)"
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800599
David Bainbridge4f1b5562019-08-19 04:46:52 +0000600 bspin - "$MSG $GEAR"
601 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700602 NOW="$(date +%s)"
603 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700604 espin - "$THEX"
David Bainbridged18f4942020-04-14 16:46:13 -0700605 rm -f "$CMD_ECHO" "$CMD_OUTPUT" "$SC_OUTPUT"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700606 doTimeout "waiting for ONOS config push on $RESOURCE"
607 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700608 if [ "$TYPE" == "file" ]; then
609 (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 -0700610 RESULT=$?
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800611 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700612 if [ "$TYPE" == "json" ]; then
613 (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 -0700614 RESULT=$?
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800615 fi
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800616 # Dump everything to the log
David Bainbridged18f4942020-04-14 16:46:13 -0700617 cat "$CMD_ECHO" >> "$LOG"
618 test -r "$CMD_OUTPUT" && cat "$CMD_OUTPUT" >> "$LOG"
619 SC="$(cat "$SC_OUTPUT")"
620 echo "RESPONSE CODE: $SC" >> "$LOG"
621 echo "ERROR CODE: $RESULT" >> "$LOG"
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800622
623 # clean up temp files
David Bainbridged18f4942020-04-14 16:46:13 -0700624 rm -f "$CMD_ECHO" "$CMD_OUTPUT" "$SC_OUTPUT"
625 if [ "$RESULT" -eq 0 ] && [ "$SC" == "200" ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000626 break
627 fi
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800628 sleep 1
David Bainbridge4f1b5562019-08-19 04:46:52 +0000629 sspin -
630 done
David Bainbridged18f4942020-04-14 16:46:13 -0700631 espin - "$VERIFIED"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000632}
633
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800634check_onos_app_active() {
David Bainbridged18f4942020-04-14 16:46:13 -0700635 local APP_ID WAIT_START RESULT NOW
636 APP_ID=$1
637 WAIT_START="$(date +%s)"
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800638
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700639 bspin - "Checking that $APP_ID is active $CLOCK"
640 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700641 NOW="$(date +%s)"
642 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700643 espin - "$THEX"
644 doTimeout "waiting for ONOS application activation '$APP_ID'"
645 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700646 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 -0700647 break
648 fi
649 sleep 1
650 sspin -
651 done
652 sleep 5 # OSGI components take a little longer that the app to activate
David Bainbridged18f4942020-04-14 16:46:13 -0700653 espin - "$VERIFIED"
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800654}
655
David Bainbridge4f1b5562019-08-19 04:46:52 +0000656override_onos_app() {
David Bainbridged18f4942020-04-14 16:46:13 -0700657 local APP NAME WAIT_START NOW
658 APP=$1
659 NAME="$(basename "$APP" | sed -e 's/^[0-9][0-9]*-//g' -e 's/-.*$//g')"
660 WAIT_START="$(date +%s)"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700661
David Bainbridge4f1b5562019-08-19 04:46:52 +0000662 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700663 NOW="$(date +%s)"
664 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700665 espin - "$THEX"
666 doTimeout "waiting to overwrite ONOS application '$APP'"
667 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +0000668 sspin -
669 # Attempt to delete old version (if it exists)
David Bainbridged18f4942020-04-14 16:46:13 -0700670 (set -x; curl --fail -sSL --user karaf:karaf -X DELETE "http://$_ONOS_API_EP/onos/v1/applications/$NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
671 RESULT=$?
David Bainbridge4f1b5562019-08-19 04:46:52 +0000672 sspin -
David Bainbridged18f4942020-04-14 16:46:13 -0700673 if [ $RESULT -ne 0 ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000674 continue
675 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700676 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 +0000677 break
678 fi
679 sleep .2
680 done
681}
682
683activate_onos_app() {
David Bainbridged18f4942020-04-14 16:46:13 -0700684 local MSG APP WAIT_START NOW
685 MSG="$1"
686 APP=$2
687 WAIT_START="$(date +%s)"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000688
689 bspin - "$MSG $GO"
690 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700691 NOW="$(date +%s)"
692 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700693 espin - "$THEX"
694 doTimeout "waiting to activate ONOS application '$APP'"
695 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +0000696 sspin -
David Bainbridged18f4942020-04-14 16:46:13 -0700697 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 +0000698 break
699 fi
700 sleep .2
701 done
702 espin - "$VERIFIED"
703}
704
705count_pods() {
David Bainbridged18f4942020-04-14 16:46:13 -0700706 local NAMESPACE STATES LABELS CMD PODS
707 NAMESPACE=$1; shift
David Bainbridge4f1b5562019-08-19 04:46:52 +0000708 if [ "$NAMESPACE" == "all-namespaces" ]; then
709 NAMESPACE="--all-namespaces"
710 else
711 NAMESPACE="-n $NAMESPACE"
712 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700713 STATES=$1; shift
714 LABELS=$1; shift
715 CMD=("kubectl get $NAMESPACE $LABELS pod")
716 PODS=$(${CMD[*]} -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}")
David Bainbridge4f1b5562019-08-19 04:46:52 +0000717 local COUNT=0
718 local PATTERNS="$*"
719 for POD in $PODS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700720 local NAME STATE CONTAINERS TOTAL FOUND
721 NAME="$(echo "$POD" | cut -d/ -f 1)"
722 STATE="$(echo "$POD" | cut -d/ -f 2)"
723 CONTAINERS="$(echo "$POD" | cut -d/ -f 3 | sed -e 's/_/ /g')"
724 if [ "$STATES" == "*" ] || [ "$(echo "$STATES" | grep -c ":$STATE:")" -ne 0 ]; then
725 TOTAL="$(echo "$CONTAINERS" | wc -w)"
726 FOUND="$(echo "$CONTAINERS" | grep -o true | wc -l)"
727 if [ "$TOTAL" -eq "$FOUND" ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000728 for PATTERN in $PATTERNS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700729 if [[ "$NAME" =~ $PATTERN ]]; then
730 COUNT="$((COUNT + 1))"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000731 break
732 fi
733 done
734 fi
735 fi
736 done
David Bainbridge4f1b5562019-08-19 04:46:52 +0000737 echo $COUNT
738}
739
740wait_for_pods() {
David Bainbridged18f4942020-04-14 16:46:13 -0700741 local INDENT NAMESPACE EXPECT TYPE MESSAGE LABELS PATTERNS STATES HAVE ALL WAIT_START NOW
David Bainbridge4f1b5562019-08-19 04:46:52 +0000742 if [ "$1" == "-" ]; then
743 INDENT=$1; shift
744 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700745 NAMESPACE=$1; shift
746 EXPECT=$1; shift
747 TYPE=$1; shift
748 MESSAGE=$1; shift
749 LABELS=$1; shift
750 PATTERNS=("$*")
751 STATES=":Running:"
David Bainbridge99ac7a22019-08-31 02:26:43 +0000752 if [ "$TYPE" == "not" ]; then
753 STATES="*"
754 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700755 HAVE="$(count_pods "$NAMESPACE" "$STATES" "$LABELS" "${PATTERNS[@]}")"
756 ALL=$HAVE
David Bainbridge4f1b5562019-08-19 04:46:52 +0000757 if [ "$TYPE" == "only" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -0700758 ALL="$(count_pods "all-namespaces" "*" ".*")"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000759 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700760 COUNT="$((300 / 15))"
761 WAIT_START="$(date +%s)"
762 bspin "$INDENT" "$MESSAGE"
763 sspin "$INDENT"
764 if [ "$HAVE" -ne "$EXPECT" ] || [ "$ALL" -ne "$HAVE" ]; then
765 while [ "$HAVE" -ne "$EXPECT" ] || [ "$ALL" -ne "$HAVE" ]; do
766 NOW="$(date +%s)"
767 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
768 espin "$INDENT" "$THEX"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700769 doTimeout "waiting for PODs to start"
770 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700771 sspin "$INDENT"
772 COUNT="$((COUNT - 1))"
773 if [ "$COUNT" -eq 0 ]; then
774 HAVE="$(count_pods "$NAMESPACE" "$STATES" "$LABELS" "${PATTERNS[@]}")"
775 ALL="$HAVE"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000776 if [ "$TYPE" == "only" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -0700777 ALL="$(count_pods "all-namespaces" "*" ".*")"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000778 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700779 COUNT="$((300 / 15))"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000780 fi
781 sleep .15
782 done
783 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700784 espin "$INDENT" "$VERIFIED"
785 if [ "$HAVE" -ne "$EXPECT" ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000786 return 1
787 fi
788 return 0
789}
790
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800791port_forward() {
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700792 local NS=$1; shift
793 local SVC=$1; shift
794 local PORTS="$*"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800795 local TAG=$SVC-$NAME
796
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700797 (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 -0800798}
799
800kill_port_forward() {
David Bainbridged18f4942020-04-14 16:46:13 -0700801 local TAG P_IDS PARENTS KIDS UNKNOWN PP_ID
802 TAG="$1-$NAME"
803 # shellcheck disable=SC2009
804 P_IDS="$(ps e -ww -A | grep "_TAG=$TAG" | grep -v grep | awk '{print $1}')"
805 if [ -n "$P_IDS" ]; then
David Bainbridgec6871d22019-11-13 17:10:31 +0000806 for P_ID in $P_IDS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700807 PP_ID="$(ps -o ppid "$P_ID" | tail -n +2)"
808 if [ -n "$PP_ID" ]; then
809 if [ "$PP_ID" -eq 1 ]; then
David Bainbridgec6871d22019-11-13 17:10:31 +0000810 PARENTS="$PARENTS $P_ID"
811 else
812 KIDS="$KIDS $P_ID"
813 fi
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800814 else
David Bainbridgec6871d22019-11-13 17:10:31 +0000815 UNKNOWN="$UNKNOWN $P_ID"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800816 fi
817 done
David Bainbridged18f4942020-04-14 16:46:13 -0700818 (set -x; kill -9 "$PARENTS" "$KIDS" "$UNKNOWN" >>"$LOG" 2>&1) >>"$LOG" 2>&1
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800819 fi
820}
821
David Bainbridgecf546362020-04-21 23:18:50 -0700822resolve_chart_version() {
823 [ "$2" != "latest" ] && echo "$2" && return
824 helm inspect chart "$1" | grep "^version:" | awk '{print $2}'
825}
826
Jonathan Hart6a91e6c2020-04-16 14:28:33 -0700827# Compares two semver-formatted version strings (e.g. 2.4.3)
828# Returns 0 if $1 == $2, returns 1 if $1 > $2 and returns 2 if $1 < $2
829compare_versions() {
830 [ "$1" == "$2" ] && return 0
Jonathan Hart6a91e6c2020-04-16 14:28:33 -0700831 local lowest
832 lowest=$(echo -e "$1\n$2" | sort -V | head -1)
833 [ "$lowest" == "$1" ] && return 2
834 return 1
835}
836
David Bainbridgeac7f8072019-08-01 22:15:33 +0000837if [ "$1" == "down" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000838 echo "Tearing down voltha cluster $NAME"
839 LOG="down-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -0700840 date -u +"%Y%m%dT%H%M%SZ" >"$LOG"
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700841 if is_in "$WITH_ONOS" "yes,legacy,classic"; then
David Bainbridge696bc632020-04-05 21:49:37 -0700842 bspin "Remove port-forwards: onos-ui-$NAME"
843 kill_port_forward onos-ui
844 sspin "Remove port-forwards: onos-ssh-$NAME$CEOL"
845 kill_port_forward onos-ssh
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700846 bspin "Remove port-forwards: onos-onos-classic-hs-$NAME$CEOL"
847 kill_port_forward onos-onos-classic-hs
David Bainbridge696bc632020-04-05 21:49:37 -0700848 fi
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800849 sspin "Remove port-forwards: voltha-api-$NAME$CEOL"
850 kill_port_forward voltha-api
David Bainbridged18f4942020-04-14 16:46:13 -0700851 if [ "$WITH_ETCD" == "yes" ] || [ "$WITH_ETCD" == "external" ]; then
852 sspin "Remove port-forwards: ${ETCD_PREFIX}etcd-$NAME$CEOL"
853 kill_port_forward "${ETCD_PREFIX}etcd-cluster-client"
David Bainbridge696bc632020-04-05 21:49:37 -0700854 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700855 if [ "$WITH_KAFKA" == "yes" ] || [ "$WITH_KAFKA" == "external" ]; then
856 sspin "Remove port-forwards: ${KAFKA_PREFIX}kafka-$NAME$CEOL"
857 kill_port_forward "${KAFKA_PREFIX}kafka"
David Bainbridge696bc632020-04-05 21:49:37 -0700858 fi
859
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800860 espin "$VERIFIED Remove port-forwards$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -0700861 if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridgeac7f8072019-08-01 22:15:33 +0000862 if [ -x ./bin/kind ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000863 bspin "Delete Kubernetes Kind Cluster"
David Bainbridged18f4942020-04-14 16:46:13 -0700864 (set -x; ./bin/kind delete cluster --name "voltha-$NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
865 espin "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000866 else
David Bainbridge0774b232019-08-02 06:37:19 +0000867 espin "$NO_ENTRY Delete Kubernetes Kind Cluster: kind command not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000868 fi
869 else
David Bainbridged18f4942020-04-14 16:46:13 -0700870 EXISTS="$(helm list -q)"
David Bainbridge76afd812020-04-06 09:53:52 -0700871 EXPECT="voltha"
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700872 if is_in "$WITH_ONOS" "yes,legacy,classic"; then
David Bainbridge696bc632020-04-05 21:49:37 -0700873 EXPECT+=" onos"
874 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700875 if [ "$WITH_RADIUS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700876 EXPECT+=" radius"
877 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700878 if [ "$WITH_BBSIM" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700879 EXPECT+=" bbsim"
880 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700881 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700882 EXPECT+=" open-olt open-onu"
883 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700884 if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700885 EXPECT+=" sim"
886 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700887 if [ "$WITH_ETCD" == "external" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700888 EXPECT+=" etcd-operator etcd-cluster"
David Bainbridged18f4942020-04-14 16:46:13 -0700889 elif [ "$WITH_ETCD" == "yes" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700890 EXPECT+=" etcd-operator"
891 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700892 if [ "$WITH_KAFKA" == "external" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700893 EXPECT+=" kafka"
894 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000895 bspin "Remove Helm Deployments"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000896 for i in $EXISTS; do
David K. Bainbridge43422402020-03-06 07:41:22 -0800897 for j in $EXPECT; do
David Bainbridged18f4942020-04-14 16:46:13 -0700898 if [[ "$i" =~ $j ]]; then
David K. Bainbridge43422402020-03-06 07:41:22 -0800899 sspin "Remove Helm Deployments: $i$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -0700900 (set -x; ./bin/helm delete --no-hooks --purge "$i" >>"$LOG" 2>&1) >>"$LOG" 2>&1
David K. Bainbridge43422402020-03-06 07:41:22 -0800901 fi
902 done
uottrembb16d3982020-02-28 08:34:36 +0100903 done
David Bainbridge0774b232019-08-02 06:37:19 +0000904 espin "$VERIFIED Remove Helm Deployments$CEOL"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000905 if [ "$WAIT_ON_DOWN" == "yes" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700906 PODS="voltha-kafka.* voltha-ofagent.* voltha-rw-core.* voltha-etcd.*"
907 INFRA_PODS=
908 ADAPT_PODS=
909 SIM_PODS=
David Bainbridged18f4942020-04-14 16:46:13 -0700910 if [ "$WITH_RADIUS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700911 PODS+=" radius.*"
912 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700913 if [ "$WITH_BBSIM" == "yes" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700914 SIM_PODS+=" bbsim.*"
David Bainbridge696bc632020-04-05 21:49:37 -0700915 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700916 if [ "$WITH_OPEN_ADAPTERS" ] || [ "$WITH_SIM_ADAPTERS" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700917 ADAPT_PODS+=" adapter-*"
David Bainbridge696bc632020-04-05 21:49:37 -0700918 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700919 if is_in "$WITH_ONOS" "yes,legacy,classic"; then
David Bainbridge76afd812020-04-06 09:53:52 -0700920 INFRA_PODS+=" onos-.*"
921 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700922 if [ "$WITH_ETCD" == "external" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700923 INFRA_PODS+=" etcd-operator.* etcd-cluster.*"
David Bainbridged18f4942020-04-14 16:46:13 -0700924 elif [ "$WITH_ETCD" == "yes" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700925 PODS+=" etcd-operator.*"
926 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700927 if [ "$WITH_KAFKA" == "external" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -0700928 INFRA_PODS+=" kafka.*"
929 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700930 if [ -n "$SIM_PODS" ]; then
931 wait_for_pods "$BBSIM_NS" 0 "not" "Waiting for BBSIM PODs to terminate" "$BBSIM_LABEL" "$SIM_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -0700932 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700933 if [ -n "$INFRA_PODS" ]; then
934 wait_for_pods "$INFRA_NS" 0 "not" "Waiting for infrastructure PODs to terminate" "$NO_LABEL" "$INFRA_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -0700935 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700936 if [ -n "$ADAPT_PODS" ]; then
937 wait_for_pods "$ADAPTER_NS" 0 "not" "Waiting for adapter PODs to terminate" "$NO_LABEL" "$ADAPT_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -0700938 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700939 wait_for_pods "$VOLTHA_NS" 0 "not" "Waiting for VOLTHA PODs to terminate" "$NO_LABEL" "$PODS"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000940 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +0000941 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -0700942 exit
David Bainbridgeac7f8072019-08-01 22:15:33 +0000943fi
944
945if [ "$1" == "dump" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000946 LOG="dump-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -0700947 TS="$(date -u +"%Y%m%dT%H%M%SZ")"
948 if [ -n "$DUMP_FROM" ]; then
949 TS=${DUMP_FROM//[:-]}
David Bainbridge76514a02019-10-08 01:50:35 +0000950 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700951 WORK="$(mktemp -u -d)"
David Bainbridge0774b232019-08-02 06:37:19 +0000952 DATA=$WORK/voltha-debug-dump-$NAME-$TS
David Bainbridged18f4942020-04-14 16:46:13 -0700953 mkdir -p "$DATA"
954 echo "$TS" > "$LOG"
David Bainbridge0774b232019-08-02 06:37:19 +0000955 echo -e "Capturing debug dump to voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000956 bspin - "Copy install log"
David Bainbridged18f4942020-04-14 16:46:13 -0700957 if [ -f "install-$NAME.log" ]; then
958 (set -x; cp "install-$NAME.log" "$DATA/install-$NAME.log") >>"$LOG" 2>&1
959 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000960 else
David Bainbridge0774b232019-08-02 06:37:19 +0000961 espin - "$NO_ENTRY Copy install log: install-$NAME.log not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000962 fi
963 bspin - "Dumping Kubernetes PODs"
David Bainbridged18f4942020-04-14 16:46:13 -0700964 (set -x; kubectl get --all-namespaces pods >> "$DATA/all-pods.txt" 2>&1) >>"$LOG" 2>&1
965 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000966 bspin - "Dumping Kubernetes SERVICEs"
David Bainbridged18f4942020-04-14 16:46:13 -0700967 (set -x; kubectl get --all-namespaces svc >> "$DATA/all-services.txt" 2>&1) >>"$LOG" 2>&1
968 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000969 bspin - "Dumping Kubernetes EVENTs"
David Bainbridged18f4942020-04-14 16:46:13 -0700970 (set -x; kubectl get --all-namespaces events >> "$DATA/all-events.txt" 2>&1) >>"$LOG" 2>&1
971 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000972 bspin - "Dumping VOLTHA POD details"
David Bainbridged18f4942020-04-14 16:46:13 -0700973 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 +0000974 SINCE=
David Bainbridged18f4942020-04-14 16:46:13 -0700975 if [ -n "$DUMP_FROM" ]; then
David Bainbridgecfd7ca12019-10-06 03:31:41 +0000976 SINCE="--since-time=$DUMP_FROM"
977 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +0000978 for POD in $PODS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700979 NS="$(echo "$POD" | cut -d: -f1)"
980 POD="$(echo "$POD" | cut -d: -f2)"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000981 sspin - "Dumping VOLTHA POD details: $POD$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -0700982 mkdir -p "$DATA/$POD"
983 (set -x; kubectl describe -n "$NS" "$POD" >> "$DATA/$POD/describe.txt" 2>&1) >>"$LOG" 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000984 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridged18f4942020-04-14 16:46:13 -0700985 (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 +0000986 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridged18f4942020-04-14 16:46:13 -0700987 (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 +0000988 sspin - "Dumping VOLTHA POD details: $POD"
989 done
990 espin - "$VERIFIED Dumping VOLTHA POD details$CEOL"
991 bspin - "Dumping ETCD"
David Bainbridged18f4942020-04-14 16:46:13 -0700992 if [ -n "$(command -v etcdctl)" ]; then
993 (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
994 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000995 else
996 espin - "$NO_ENTRY Dumping ETCD: etcdctl command not available"
997 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000998 bspin - "Creating compressed TAR: voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridged18f4942020-04-14 16:46:13 -0700999 (set -x; tar -C "$WORK" -zcf "voltha-debug-dump-$NAME-$TS.tgz" "./voltha-debug-dump-$NAME-$TS") >>"$LOG" 2>&1
1000 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001001 bspin - "Cleanup"
David Bainbridged18f4942020-04-14 16:46:13 -07001002 (set -x; rm -rf "$WORK") >>"$LOG" 2>&1
1003 espin - "$VERIFIED"
1004 bspin - "$(ls -l "voltha-debug-dump-$NAME-$TS.tgz")"
1005 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001006 exit
1007fi
1008
David Bainbridge0774b232019-08-02 06:37:19 +00001009LOG="install-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -07001010date > "$LOG"
1011echo "PORTS=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT" >> "$LOG"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001012
1013# Output install options to log
David Bainbridged18f4942020-04-14 16:46:13 -07001014echo "OPTIONS" >> "$LOG"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001015for O in $ALL_OPTIONS; do
David Bainbridged18f4942020-04-14 16:46:13 -07001016 VAL="$(eval echo "\$$O")"
1017 if [ -n "$VAL" ]; then
1018 printf " %-30s = %s\n" "$O" "$VAL" >> "$LOG"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001019 fi
1020done
1021
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001022helm_install() {
David Bainbridged18f4942020-04-14 16:46:13 -07001023 local INDENT NOW
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001024 if [ "$1" == "-" ]; then
1025 INDENT=$1; shift
1026 fi
1027 local NAMESPACE=$1; shift
David Bainbridge0774b232019-08-02 06:37:19 +00001028 local INAME=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001029 local CHART=$1; shift
David Bainbridge90fd8e32019-08-21 23:32:47 +00001030 local CHART_VERSION=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001031 local MESSAGE=$*
1032
David Bainbridged18f4942020-04-14 16:46:13 -07001033 if [ "$CHART_VERSION X" != " X" ] && [ "$CHART_VERSION" != "latest" ]; then
David Bainbridge90fd8e32019-08-21 23:32:47 +00001034 CHART_VERSION="--version $CHART_VERSION"
1035 else
1036 CHART_VERSION=
1037 fi
1038
David Bainbridge99ac7a22019-08-31 02:26:43 +00001039 local CHART_ARGS=
1040 if [ -r "${INAME}-values.yaml" ]; then
1041 CHART_ARGS="-f ${INAME}-values.yaml"
1042 fi
1043
David Bainbridged18f4942020-04-14 16:46:13 -07001044 local WAIT_START CMD
1045 WAIT_START="$(date +%s)"
1046 COUNT="$((300 / 15))"
1047 bspin "$INDENT" "$MESSAGE"
1048 if [ "$HELM_USE_UPGRADE" == "yes" ]; then
David Bainbridge7f8bf992020-04-08 21:53:22 -07001049 _HELM_COMMAND="upgrade --install"
1050 _HELM_ARGS="$INAME"
1051 else
1052 _HELM_COMMAND="install"
1053 _HELM_ARGS="--name $INAME"
1054 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001055 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")
1056 (set -x; ${CMD[*]} >>"$LOG" 2>&1) >>"$LOG" 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001057 SUCCESS=$?
David Bainbridged18f4942020-04-14 16:46:13 -07001058 while [ "$SUCCESS" -ne 0 ]; do
1059 NOW="$(date +%s)"
1060 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -07001061 espin "$THEX"
1062 doTimeout "waiting for helm install $CHART"
1063 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001064 sspin "$INDENT"
1065 COUNT="$((COUNT - 1))"
1066 if [ "$COUNT" -eq 0 ]; then
1067 if [ "$HELM_USE_UPGRADE" == "no" ]; then
1068 (set -x; helm delete --purge "$INAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
David Bainbridge7f8bf992020-04-08 21:53:22 -07001069 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001070 (set -x; ${CMD[*]} >>"$LOG" 2>&1) >>"$LOG" 2>&1
Andy Baviere22ff252019-12-19 11:40:31 -07001071 SUCCESS=$?
David Bainbridged18f4942020-04-14 16:46:13 -07001072 COUNT="$((300 / 15))"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001073 fi
1074 sleep .15
1075 done
David Bainbridged18f4942020-04-14 16:46:13 -07001076 espin "$INDENT" "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001077}
1078
David Bainbridged18f4942020-04-14 16:46:13 -07001079echo "INSTALL TYPE: $TYPE" >> "$LOG"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001080
1081bspin "Verify GOPATH"
David Bainbridged18f4942020-04-14 16:46:13 -07001082GOPATH="$(pwd)"; export GOPATH
1083mkdir -p "$GOPATH/bin"
1084espin "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001085
David Bainbridged18f4942020-04-14 16:46:13 -07001086STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001087if [ "$INSTALL_KUBECTL" == "no" ]; then
1088 bspin "Skip kubectl install"
1089 espin $NO_ENTRY
Test Userc13bdc92019-07-03 20:57:49 +00001090else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001091 bspin "Verify kubectl $HELM"
David Bainbridged18f4942020-04-14 16:46:13 -07001092 if [ -x "$GOPATH/bin/kubectl" ]; then
1093 espin "$VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001094 else
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001095 ERR_OUT="$(mktemp)"
David Bainbridged18f4942020-04-14 16:46:13 -07001096 espin "$NOT_VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001097 bspin - "Download and install Kubernetes/kubectl $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001098 (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
1099 RESULT=$?
1100 if [ "$RESULT" -ne 0 ]; then
1101 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001102 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download kubectl: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001103 cat "$ERR_OUT" >> "$LOG"
Zack Williamsded60cb2020-04-13 10:02:20 -07001104 rm -rf "$ERR_OUT" "$GOPATH/bin/kubectl"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001105 exit 1
1106 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001107 (set -x; chmod 755 "$GOPATH/bin/kubectl" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1108 espin - "$VERIFIED"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001109 rm -rf "$ERR_OUT"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001110 fi
Test Userc13bdc92019-07-03 20:57:49 +00001111fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001112if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001113 NOW="$(date +%s)"
1114 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001115fi
Test Userc13bdc92019-07-03 20:57:49 +00001116
David Bainbridged18f4942020-04-14 16:46:13 -07001117STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001118if [ "$DEPLOY_K8S" == "no" ]; then
1119 bspin "Skip Kubernetes/Kind Deployment"
1120 espin $NO_ENTRY
1121else
Test Userba1e7e72019-07-10 22:27:54 +00001122 bspin "Verify Kubernetes/Kind $HELM"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001123 IS_INSTALLED=0
1124 OP_TYPE="install"
David Bainbridged18f4942020-04-14 16:46:13 -07001125 if [ -x "$GOPATH/bin/kind" ]; then
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001126 OP_TYPE="upgrade"
David Bainbridged18f4942020-04-14 16:46:13 -07001127 if [ "$("$GOPATH/bin/kind" --version | grep -c "$KIND_VERSION")" -eq 1 ]; then
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001128 IS_INSTALLED=1
David Bainbridged18f4942020-04-14 16:46:13 -07001129 espin "$VERIFIED"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001130 fi
1131 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001132 if [ "$IS_INSTALLED" -eq 0 ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001133 ERR_OUT="$(mktemp)"
David Bainbridged18f4942020-04-14 16:46:13 -07001134 espin "$NOT_VERIFIED"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001135 bspin - "Download and $OP_TYPE Kubernetes/kind $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001136 (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
1137 RESULT=$?
1138 if [ $RESULT -ne 0 ]; then
1139 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001140 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download kind: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001141 cat "$ERR_OUT" >> "$LOG"
Zack Williamsded60cb2020-04-13 10:02:20 -07001142 rm -rf "$ERR_OUT" "$GOPATH/bin/kind"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001143 exit 1
1144 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001145 (set -x; chmod 755 "$GOPATH/bin/kind" >>"$LOG" 2>&1) >>"$LOG" 2>&1
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001146 rm -rf "$ERR_OUT"
David Bainbridged18f4942020-04-14 16:46:13 -07001147 espin - "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001148 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001149fi
1150
David Bainbridgee87067b2019-08-12 22:00:12 +00001151if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001152 NOW="$(date +%s)"
1153 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001154fi
1155
David Bainbridged18f4942020-04-14 16:46:13 -07001156STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001157if [ "$INSTALL_HELM" == "no" ]; then
1158 bspin "Skip Helm Install"
1159 espin $NO_ENTRY
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001160else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001161 bspin "Verify Helm $HELM"
David Bainbridgea34993d2020-04-01 09:15:42 -07001162 HELM_UPGRADE=0
1163 HELM_UPGRADE_DESC="install"
David Bainbridged18f4942020-04-14 16:46:13 -07001164 if [ -x "$GOPATH/bin/helm" ]; then
1165 HAVE_VER="$("$GOPATH/bin/helm" version -c --template '{{.Client.SemVer}}')"
1166 HELM_UP_DOWN="$(echo -e "$HAVE_VER\n$HELM_VERSION" | sort -V | head -1)"
1167 if [ "$HAVE_VER" != "$HELM_VERSION" ]; then
1168 if [ "$HELM_UP_DOWN" == "$HELM_VERSION" ]; then
David Bainbridgea34993d2020-04-01 09:15:42 -07001169 HELM_UPGRADE_DESC="downgrade"
1170 else
1171 HELM_UPGRADE_DESC="upgrade"
1172 fi
1173 HELM_UPGRADE=1
1174 else
David Bainbridged18f4942020-04-14 16:46:13 -07001175 espin "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001176 fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001177 else
David Bainbridgea34993d2020-04-01 09:15:42 -07001178 HELM_UPGRADE=1
1179 fi
1180
David Bainbridged18f4942020-04-14 16:46:13 -07001181 if [ "$HELM_UPGRADE" -ne 0 ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001182 ERR_OUT="$(mktemp)"
1183 INSTALL_HELM_BIN=$(mktemp)
David Bainbridged18f4942020-04-14 16:46:13 -07001184 espin "$NOT_VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001185 bspin - "Download and $HELM_UPGRADE_DESC Helm $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001186 (set -x; curl -o "$INSTALL_HELM_BIN" --fail -sSL https://git.io/get_helm.sh >>"$LOG" 2>"$ERR_OUT") >>"$LOG" 2>&1
1187 RESULT=$?
1188 if [ $RESULT -ne 0 ]; then
1189 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001190 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download helm installer: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001191 cat "$ERR_OUT" >> "$LOG"
1192 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT" "$GOPATH/bin/helm" "$GOPATH/bin/tiller"
1193 exit 1
1194 fi
1195 rm -rf "$ERR_OUT"
1196 chmod +x "$INSTALL_HELM_BIN"
1197 (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
1198 RESULT=$?
1199 if [ $RESULT -ne 0 ]; then
1200 espin - "$THEX"
1201 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to install helm, see install log for details${NORMAL}"
1202 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT" "$GOPATH/bin/helm" "$GOPATH/bin/tiller"
1203 exit 1
1204 fi
1205 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT"
David Bainbridged18f4942020-04-14 16:46:13 -07001206 espin - "$VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001207 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001208fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001209if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001210 NOW="$(date +%s)"
1211 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001212fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001213
David Bainbridged18f4942020-04-14 16:46:13 -07001214STIME="$(date +%s)"
Test Userb5712372019-07-03 21:52:17 +00001215bspin "Verify voltctl $HIGH_VOLTAGE"
David Bainbridged2811972019-12-14 01:14:09 +00001216VOK=0
1217VMESSAGE="install"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001218ERR_OUT=$(mktemp)
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001219export VC_VERSION="$VOLTCTL_VERSION"
1220if [ "$VC_VERSION" == "latest" ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001221 set -o pipefail # TODO: would be nice to run all in pipefail mode
1222 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')"
1223 RESULT=$?
1224 set +o pipefail
1225 if [ "$RESULT" -ne 0 ]; then
1226 espin - "$THEX"
1227 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to determine released version of voltctl: $(cat "$ERR_OUT")${NORMAL}"
1228 rm -rf "$ERR_OUT" "$GOPATH/bin/voltctl"
1229 exit 1
1230 fi
1231 export VC_VERSION
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001232fi
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001233
David Bainbridged18f4942020-04-14 16:46:13 -07001234if [ -x "$GOPATH/bin/voltctl" ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001235 VHAVE="$("$GOPATH/bin/voltctl" version --clientonly -o json 2>/dev/null | jq -r .version)"
David Bainbridged18f4942020-04-14 16:46:13 -07001236 RESULT=$?
1237 if [ $RESULT -eq 0 ] && [ "$VHAVE" == "$VC_VERSION" ]; then
David Bainbridged2811972019-12-14 01:14:09 +00001238 VOK=1
David Bainbridged18f4942020-04-14 16:46:13 -07001239 espin "$VERIFIED"
David Bainbridge1ba64f12019-12-18 00:40:13 +00001240 else
David Bainbridged18f4942020-04-14 16:46:13 -07001241 VCHECK="$(echo -e "$VHAVE\n$VC_VERSION" | sort -V | head -1)"
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001242 if [ "$VCHECK" == "$VHAVE" ]; then
1243 VMESSAGE="upgrade"
1244 else
1245 VMESSAGE="downgrade"
1246 fi
David Bainbridged2811972019-12-14 01:14:09 +00001247 fi
1248fi
1249
David Bainbridged18f4942020-04-14 16:46:13 -07001250if [ "$VOK" -eq 0 ]; then
1251 espin "$NOT_VERIFIED"
David Bainbridged2811972019-12-14 01:14:09 +00001252 bspin - "Download and $VMESSAGE voltctl $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001253 (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
1254 RESULT=$?
1255 if [ $RESULT -ne 0 ]; then
1256 espin - "$THEX"
1257 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download voltctl (version $VC_VERSION): $(cat "$ERR_OUT")${NORMAL}"
1258 rm -rf "$ERR_OUT" "$GOPATH/bin/voltctl"
1259 exit 1
1260 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001261 (set -x; chmod 755 "$GOPATH/bin/voltctl" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1262 espin - "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001263fi
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001264rm -rf "$ERR_OUT"
David Bainbridgee87067b2019-08-12 22:00:12 +00001265if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001266 NOW="$(date +%s)"
1267 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001268fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001269
1270bspin "Verify command PATH"
Test Userba1e7e72019-07-10 22:27:54 +00001271export PATH=$GOPATH/bin:$PATH
David Bainbridged18f4942020-04-14 16:46:13 -07001272espin "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001273
David Bainbridged18f4942020-04-14 16:46:13 -07001274STIME="$(date +%s)"
Test Userba1e7e72019-07-10 22:27:54 +00001275if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001276 HAVE="$(kind get clusters | grep -c "voltha-$NAME")"
Test Userba1e7e72019-07-10 22:27:54 +00001277 bspin "Verify Kubernetes/Kind Cluster"
1278 sspin
David Bainbridged18f4942020-04-14 16:46:13 -07001279 if [ "$HAVE" -eq 0 ]; then
1280 espin "$NOT_VERIFIED"
David Bainbridge491b1bd2019-07-11 17:53:11 +00001281 bspin - "Verify cluster configuration"
David Bainbridged18f4942020-04-14 16:46:13 -07001282 if [ ! -r "./$NAME-cluster.cfg" ]; then
1283 espin - "$NOT_VERIFIED"
David K. Bainbridge43422402020-03-06 07:41:22 -08001284 bspin - "Download cluster configuration: $TYPE-cluster.cfg to $NAME-cluster.cfg $DOWNLOAD"
David Bainbridged18f4942020-04-14 16:46:13 -07001285 ERR_OUT="$(mktemp)"
serkant.uluderya4d315132020-04-15 16:25:54 -07001286 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 -07001287 espin - "$THEX"
1288 echo -e "${RED}${BOLD}${ERROR}ERROR: $NAME-cluster.cfg${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1289 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
1290 rm -rf "$ERR_OUT" "./$NAME-cluster.cfg"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001291 exit 1
1292 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001293 rm -rf "$ERR_OUT"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001294 else
David Bainbridged18f4942020-04-14 16:46:13 -07001295 espin - "$VERIFIED"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001296 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001297 kind create cluster --name "voltha-$NAME" --config "$NAME-cluster.cfg"
David Bainbridge491b1bd2019-07-11 17:53:11 +00001298 else
David Bainbridged18f4942020-04-14 16:46:13 -07001299 espin "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001300 fi
1301
David Bainbridged18f4942020-04-14 16:46:13 -07001302 KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$NAME")"; export KUBECONFIG
Test Userba1e7e72019-07-10 22:27:54 +00001303 P="coredns-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001304 etcd-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +00001305 kindnet-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001306 kube-apiserver-voltha-$NAME-control-plane \
1307 kube-controller-manager-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +00001308 kube-proxy-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001309 kube-scheduler-voltha-$NAME-control-plane"
Test Userba1e7e72019-07-10 22:27:54 +00001310
David Bainbridged18f4942020-04-14 16:46:13 -07001311 EXPECT="$(test "$TYPE" == "minimal" && echo "12" || echo "14")"
1312 wait_for_pods - "kube-system" "$EXPECT" "includes" "Waiting for system PODs to start" "$NO_LABEL" "$P"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001313fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001314if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001315 NOW="$(date +%s)"
1316 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001317fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001318
David Bainbridged18f4942020-04-14 16:46:13 -07001319STIME="$(date +%s)"
1320COUNT="$(count_pods "kube-system" ":Running:" "$NO_LABEL" "tiller-deploy-.*")"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001321bspin "Verify Helm"
David Bainbridged18f4942020-04-14 16:46:13 -07001322if [ "$COUNT" -ne 1 ]; then
1323 espin "$NOT_VERIFIED"
Test Userb5712372019-07-03 21:52:17 +00001324 echo -e "Configuring Helm $GEAR"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001325 if [ "$INSTALL_HELM" == "no" ]; then
1326 bspin - "Skip Helm/Tiller Initialization"
1327 espin - $NO_ENTRY
1328 else
1329 bspin - "Initialize Helm"
David Bainbridged18f4942020-04-14 16:46:13 -07001330 (set -x; helm init --upgrade >>"$LOG" 2>&1) >>"$LOG" 2>&1
1331 espin - "$VERIFIED"
1332 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 -07001333 fi
Test Userb5712372019-07-03 21:52:17 +00001334 bspin - "Add Google Incubator repository to Helm"
David Bainbridged18f4942020-04-14 16:46:13 -07001335 (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>"$LOG" 2>&1) >>"$LOG" 2>&1
1336 espin - "$VERIFIED"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001337
Test Userba1e7e72019-07-10 22:27:54 +00001338 # HACK (sort-of) - the config for tiller is about to be patched, which will
1339 # cause the tiller pod to be recreated. This can sometimes cause a timing
1340 # issue with the "wait_for_pods" call on tiller as it may incorrectly
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001341 # identify the running/ready tiller pod that is soon to be terminated as
Test Userba1e7e72019-07-10 22:27:54 +00001342 # what it is waiting for. To avoid this issue we do a clean scale down and
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001343 # scale up of the pod so the script controlls when it should be expecting
Test Userba1e7e72019-07-10 22:27:54 +00001344 # things
David Bainbridged18f4942020-04-14 16:46:13 -07001345 (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 -07001346
Test Userb5712372019-07-03 21:52:17 +00001347 bspin - "Add Google Stable repository to Helm"
David Bainbridged18f4942020-04-14 16:46:13 -07001348 (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>"$LOG" 2>&1) >>"$LOG" 2>&1
1349 espin - "$VERIFIED"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001350 bspin - "Add ONF VOLTHA repository to Helm"
David Bainbridged18f4942020-04-14 16:46:13 -07001351 (set -x; helm repo add onf https://charts.opencord.org >>"$LOG" 2>&1) >>"$LOG" 2>&1
1352 espin - "$VERIFIED"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001353 bspin - "Add ONF ONOS repository to Helm"
1354 (set -x; helm repo add onos https://charts.onosproject.org >>"$LOG" 2>&1) >>"$LOG" 2>&1
1355 espin - "$VERIFIED"
1356 bspin - "Add ONF Atomix repository to Helm"
1357 (set -x; helm repo add atomix https://charts.atomix.io >>"$LOG" 2>&1) >>"$LOG" 2>&1
1358 espin - "$VERIFIED"
Test Userb5712372019-07-03 21:52:17 +00001359 bspin - "Update Helm repository cache"
David Bainbridged18f4942020-04-14 16:46:13 -07001360 (set -x; helm repo update >>"$LOG" 2>&1) >>"$LOG" 2>&1
1361 espin - "$VERIFIED"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001362
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001363 # Create and k8s service account so that Helm can create pods
Test Userb5712372019-07-03 21:52:17 +00001364 bspin - "Create Tiller ServiceAccount"
David Bainbridged18f4942020-04-14 16:46:13 -07001365 (set -x; kubectl create serviceaccount --namespace kube-system tiller >>"$LOG" 2>&1) >>"$LOG" 2>&1
1366 espin - "$VERIFIED"
Test Userb5712372019-07-03 21:52:17 +00001367 bspin - "Create Tiller ClusterRoleBinding"
David Bainbridged18f4942020-04-14 16:46:13 -07001368 (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>"$LOG" 2>&1) >>"$LOG" 2>&1
1369 espin - "$VERIFIED"
Test Userb5712372019-07-03 21:52:17 +00001370 bspin - "Update Tiller Manifest"
David Bainbridged18f4942020-04-14 16:46:13 -07001371 (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 +00001372
1373 # HACK (sort-of) - part to, spin it back up
David Bainbridged18f4942020-04-14 16:46:13 -07001374 (set -x; kubectl -n kube-system scale deploy tiller-deploy --replicas=1 >>"$LOG" 2>&1) >>"$LOG" 2>&1
1375 espin - "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001376else
David Bainbridged18f4942020-04-14 16:46:13 -07001377 if [ "$(helm version -s --template '{{.Server.SemVer}}')" != "$HELM_VERSION" ]; then
1378 espin "$NOT_VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001379 bspin - "Sync Tiller server version with helm client"
David Bainbridged18f4942020-04-14 16:46:13 -07001380 (set -x; helm init --upgrade --force-upgrade --wait >>"$LOG" 2>&1) >>"$LOG" 2>&1
1381 espin - "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001382 else
David Bainbridged18f4942020-04-14 16:46:13 -07001383 espin "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001384 fi
1385
David Bainbridge46505fb2019-10-01 21:13:20 +00001386 if [ "$UPDATE_HELM_REPOS" == "yes" ]; then
1387 bspin - "Update Helm repository cache"
David Bainbridged18f4942020-04-14 16:46:13 -07001388 (set -x; helm repo update >>"$LOG" 2>&1) >>"$LOG" 2>&1
1389 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00001390 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001391fi
David Bainbridged18f4942020-04-14 16:46:13 -07001392wait_for_pods - "kube-system" 1 "includes" "Waiting for Tiller POD to start" "$NO_LABEL" "tiller-deploy-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001393if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001394 NOW="$(date +%s)"
1395 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001396fi
David Bainbridgecf546362020-04-21 23:18:50 -07001397# Resolve chart versions and log them for debug/support
1398RESOLVED_VOLTHA_CHART_VERSION=$(resolve_chart_version "$VOLTHA_CHART" "$VOLTHA_CHART_VERSION")
1399RESOLVED_VOLTHA_BBSIM_CHART_VERSION=$(resolve_chart_version "$VOLTHA_BBSIM_CHART" "$VOLTHA_BBSIM_CHART_VERSION")
1400RESOLVED_VOLTHA_ADAPTER_SIM_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_SIM_CHART" "$VOLTHA_ADAPTER_SIM_CHART_VERSION")
1401RESOLVED_VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_OPEN_OLT_CHART" "$VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION")
1402RESOLVED_VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_OPEN_ONU_CHART" "$VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION")
1403RESOLVED_ONOS_CHART_VERSION=$(resolve_chart_version "$ONOS_CHART" "$ONOS_CHART_VERSION")
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001404RESOLVED_ONOS_CLASSIC_CHART_VERSION=$(resolve_chart_version "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION")
David Bainbridgecf546362020-04-21 23:18:50 -07001405RESOLVED_KAFKA_CHART_VERSION=$(resolve_chart_version "$KAFKA_CHART" "$KAFKA_CHART_VERSION")
1406cat <<EOV >>"$LOG"
1407Resolved helm charts and versions:
1408 $VOLTHA_CHART:$RESOLVED_VOLTHA_CHART_VERSION
1409 $VOLTHA_BBSIM_CHART:$RESOLVED_VOLTHA_BBSIM_CHART_VERSION
1410 $VOLTHA_ADAPTER_SIM_CHART:$RESOLVED_VOLTHA_ADAPTER_SIM_CHART_VERSION
1411 $VOLTHA_ADAPTER_OPEN_OLT_CHART:$RESOLVED_VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION
1412 $VOLTHA_ADAPTER_OPEN_ONU_CHART:$RESOLVED_VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION
1413 $ONOS_CHART:$RESOLVED_ONOS_CHART_VERSION
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001414 $ONOS_CLASSIC_CHART:$RESOLVED_ONOS_CLASSIC_CHART_VERSION
David Bainbridgecf546362020-04-21 23:18:50 -07001415 $KAFKA_CHART:$RESOLVED_KAFKA_CHART_VERSION
1416EOV
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001417
David Bainbridged18f4942020-04-14 16:46:13 -07001418STIME="$(date +%s)"
David Bainbridge0774b232019-08-02 06:37:19 +00001419bspin "Verify Helm values file: $NAME-values.yaml"
1420if [ ! -r "./$NAME-values.yaml" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001421 espin "$NOT_VERIFIED"
David Bainbridge0774b232019-08-02 06:37:19 +00001422 bspin - "Download Helm values file: $TYPE-values.yaml to $NAME-values.yaml $DOWNLOAD"
David Bainbridged18f4942020-04-14 16:46:13 -07001423 ERR_OUT="$(mktemp)"
serkant.uluderya4d315132020-04-15 16:25:54 -07001424 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 -07001425 espin - "$THEX"
1426 echo -e "${RED}${BOLD}${ERROR}ERROR: $NAME-values.yaml${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1427 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
1428 rm -rf "$ERR_OUT" "./$NAME-values.yaml"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001429 exit 1
1430 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001431 rm -rf "$ERR_OUT"
1432 espin - "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001433else
David Bainbridged18f4942020-04-14 16:46:13 -07001434 espin "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001435fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001436if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001437 NOW="$(date +%s)"
1438 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001439fi
Test Userba1e7e72019-07-10 22:27:54 +00001440
David Bainbridged18f4942020-04-14 16:46:13 -07001441STIME="$(date +%s)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001442bspin "Verify or download chart specific values files $DOWNLOAD"
1443VALUES_FILES="monkey-values.yaml"
David Bainbridged18f4942020-04-14 16:46:13 -07001444ERR_OUT="$(mktemp)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001445for i in $VALUES_FILES; do
1446 if [ ! -r ./$i ]; then
serkant.uluderya4d315132020-04-15 16:25:54 -07001447 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 -07001448 espin "$THEX"
1449 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1450 echo "ERROR: $i - $(cat "$ERR_OUT")" >>"$LOG"
1451 rm -rf "$ERR_OUT" "./$i"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001452 exit 1
1453 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001454 rm -rf "$ERR_OUT"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001455 fi
1456done
David Bainbridged18f4942020-04-14 16:46:13 -07001457rm -rf "$ERR_OUT"
1458espin "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001459if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001460 NOW="$(date +%s)"
1461 printtime $((NOW - STIME))
David Bainbridge99ac7a22019-08-31 02:26:43 +00001462fi
1463
1464if [ "$WITH_CHAOS" == "yes" ]; then
1465 bspin "Verify or clone kube-monkey helm chart $DOWNLOAD"
1466 if [ -r ./kube-monkey ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001467 espin "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001468 else
David Bainbridged18f4942020-04-14 16:46:13 -07001469 espin "$NOT_VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001470 bspin - "GIT clone kube-monkey"
David Bainbridged18f4942020-04-14 16:46:13 -07001471 (set -x; git clone https://github.com/asobti/kube-monkey kube-monkey >>"$LOG" 2>&1) >>"$LOG" 2>&1
1472 espin - "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001473 fi
1474fi
1475
Test Userba1e7e72019-07-10 22:27:54 +00001476if [ "$JUST_K8S" == "yes" ]; then
1477 echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye."
1478 echo ""
David Bainbridged18f4942020-04-14 16:46:13 -07001479 echo "Please issue the following commands in your terminal to ensure that you" | tee -a "$LOG"
1480 echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a "$LOG"
1481 echo "tools required by VOLTHA in your command path. " | tee -a "$LOG"
1482 echo "" | tee -a "$LOG"
1483 echo -en "$BOLD"
1484 if [ "$DEPLOY_K8S" == "yes" ]; then
1485 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00001486 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001487 echo "export PATH=$GOPATH/bin:\$PATH" | tee -a "$LOG"
1488 echo -en "$NORMAL"
1489 echo "" | tee -a "$LOG"
1490 echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00001491 exit 0
1492fi
1493
David Bainbridged18f4942020-04-14 16:46:13 -07001494if [ "$WITH_ETCD" != "yes" ] && [ "$WITH_ETCD" != "external" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001495 bspin "Skip ETCD Operator Deployment"
1496 espin $NO_ENTRY
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001497else
David Bainbridged18f4942020-04-14 16:46:13 -07001498 STIME="$(date +%s)"
David Bainbridge76afd812020-04-06 09:53:52 -07001499 NS=$VOLTHA_NS
David Bainbridged18f4942020-04-14 16:46:13 -07001500 if [ "$WITH_ETCD" == "external" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -07001501 NS=$INFRA_NS
1502 fi
David Bainbridge696bc632020-04-05 21:49:37 -07001503 bspin "Verify ETCD Operator $OLD_KEY"
David Bainbridged18f4942020-04-14 16:46:13 -07001504 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$NS" "^etcd-operator\$" | wc -l)" -ne 1 ]; then
1505 espin "$NOT_VERIFIED"
1506 helm_install - "$NS" etcd-operator stable/etcd-operator latest "$_HELM_DESC ETCD Operator"
David Bainbridge696bc632020-04-05 21:49:37 -07001507 else
David Bainbridged18f4942020-04-14 16:46:13 -07001508 espin "$VERIFIED"
David Bainbridge696bc632020-04-05 21:49:37 -07001509 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001510 EXPECT="$(test "$TYPE" == "minimal" && echo "1" || echo "3")"
1511 wait_for_pods - "$NS" "$EXPECT" "includes" "Waiting for ETCD Operator to start" "$NO_LABEL" "etcd-operator-.*"
David Bainbridge696bc632020-04-05 21:49:37 -07001512 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001513 NOW="$(date +%s)"
1514 printtime $((NOW - STIME))
David Bainbridge696bc632020-04-05 21:49:37 -07001515 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001516fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001517
David Bainbridged18f4942020-04-14 16:46:13 -07001518STIME="$(date +%s)"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001519if is_in "$WITH_ONOS" "yes,legacy,classic"; then
1520 if is_in "$WITH_ONOS" "legacy"; then
1521 bspin "Verify ONOS LEGACY installed $BIRD"
1522 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^onos\$" | wc -l)" -ne 1 ]; then
1523 espin "$NOT_VERIFIED"
1524 INTERNAL_EXTRA_HELM_INSTALL_ARGS="$SET_TAG $EXTRA_HELM_FLAGS" helm_install - "$INFRA_NS" onos "$ONOS_CHART" "$ONOS_CHART_VERSION" "$_HELM_DESC ONOS LEGACY"
1525 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
1526 else
1527 espin "$VERIFIED"
1528 fi
1529 wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for ONOS to start" "$NO_LABEL" "onos-.*"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001530
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001531 if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
1532 bspin - "Forward ONOS API port $FORWARD"
1533 kill_port_forward onos-ui
1534 port_forward "$INFRA_NS" onos-ui "$ONOS_API_PORT:8181"
1535 espin - "$VERIFIED"
1536 bspin - "Forward ONOS SSH port $FORWARD"
1537 kill_port_forward onos-ssh
1538 port_forward "$INFRA_NS" onos-ssh "$ONOS_SSH_PORT:8101"
1539 espin - "$VERIFIED"
1540 _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT"
1541 else
1542 _ONOS_API_EP="$(get_service_ep "$INFRA_NS" onos-ui)"
1543 fi
1544 elif is_in "$WITH_ONOS" "yes,classic"; then
1545 bspin "Verify ONOS CLASSIC installed $BIRD"
1546 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^onos\$" | wc -l)" -ne 1 ]; then
1547 espin "$NOT_VERIFIED"
1548 # ONOS CLASSIC identifies its image repo/tag differently, so yq is used to grab the values from the
1549 # values value
1550 _ONOS_REPO="$(cat onos-values.yaml "$NAME-values.yaml" 2>/dev/null | yq read - images.onos.repository)"
1551 _ONOS_TAG="$(cat onos-values.yaml "$NAME-values.yaml" 2>/dev/null | yq read - images.onos.tag)"
1552 _TAG_DEFAULT="$(cat onos-values.yaml "$NAME-values.yaml" 2>/dev/null | yq read - defaults.image_tag)"
1553 if [ -z "$_ONOS_TAG" ]; then
1554 _ONOS_TAG="$_TAG_DEFAULT"
1555 fi
1556 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" \
1557 helm_install - "$INFRA_NS" onos "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION" "$_HELM_DESC ONOS CLASSIC"
1558 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
1559 else
1560 espin "$VERIFIED"
1561 fi
1562 wait_for_pods - "$INFRA_NS" $((NUM_OF_ONOS + NUM_OF_ATOMIX)) "includes" "Waiting for ONOS CLASSIC to start" "$NO_LABEL" "onos-.*"
1563 if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
1564 bspin - "Forward ONOS API port $FORWARD"
1565 kill_port_forward onos-onos-classic-hs
1566 port_forward "$INFRA_NS" onos-onos-classic-hs "$ONOS_API_PORT:8181" "$ONOS_SSH_PORT:8101"
1567 espin - "$VERIFIED"
1568 _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT"
1569 else
1570 _ONOS_API_EP="$(get_service_ep "$INFRA_NS" onos-onos-classic-hs)"
1571 fi
1572 elif [ "$WITH_ONOS" == "micro" ]; then
1573 bspin "Verify micro-ONOS installed $BIRD"
1574 # We should never get here
1575 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Micro ONOS not currently supported${NORMAL}"
1576 exit 1
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001577 fi
David Bainbridged31d6122019-08-13 19:37:59 +00001578 bspin - "Verify or download ONOS configuration support files $DOWNLOAD"
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001579 ONOS_FILES="olt-onos-enableExtraneousRules.json onos-aaa.json \
David Bainbridge696bc632020-04-05 21:49:37 -07001580 onos-dhcpl2relay.json onos-sadis-sample.json"
David Bainbridged18f4942020-04-14 16:46:13 -07001581 (set -x; mkdir -p ./onos-files >>"$LOG" 2>&1) >>"$LOG" 2>&1
1582 ERR_OUT="$(mktemp)"
David Bainbridge2b19e832019-08-16 02:40:53 +00001583 for i in $ONOS_FILES; do
David Bainbridged18f4942020-04-14 16:46:13 -07001584 if [ ! -r "./onos-files/$i" ]; then
serkant.uluderya4d315132020-04-15 16:25:54 -07001585 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 -07001586 espin - "$THEX"
1587 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1588 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
1589 rm -rf "$ERR_OUT" "./onos-files/$i"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001590 exit 1
1591 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001592 rm -rf "$ERR_OUT"
David Bainbridged31d6122019-08-13 19:37:59 +00001593 fi
1594 done
David Bainbridged18f4942020-04-14 16:46:13 -07001595 rm -rf "$ERR_OUT"
1596 espin - "$VERIFIED"
David Bainbridge27790d62019-08-13 22:43:19 +00001597
David Bainbridged18f4942020-04-14 16:46:13 -07001598 if [ "$INSTALL_ONOS_APPS" == "yes" ]; then
David Bainbridge27790d62019-08-13 22:43:19 +00001599 bspin - "Installing custom ONOS applications"
David Bainbridged18f4942020-04-14 16:46:13 -07001600 if [ -x onos-files/onos-apps ] && [ "$(find onos-files/onos-apps -name "*.oar" 2>/dev/null | wc -l)" -gt 0 ]; then
1601 for OAR in onos-files/onos-apps/*.oar; do
David Bainbridge27790d62019-08-13 22:43:19 +00001602 sspin - "Installing custom ONOS applications - $OAR$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -07001603 override_onos_app "$OAR"
David Bainbridge27790d62019-08-13 22:43:19 +00001604 done
1605 espin - "$VERIFIED Installing custom ONOS applications$CEOL"
1606 else
1607 espin - "$NOT_VERIFIED Installing custom ONOS applications - None Found"
1608 fi
1609 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001610
David Bainbridged18f4942020-04-14 16:46:13 -07001611 if [ "$WITH_KAFKA" != "no" ]; then
David Bainbridge837e8bd2020-04-06 13:17:14 -07001612 check_onos_app_active org.opencord.kafka
David Bainbridge76afd812020-04-06 09:53:52 -07001613 _HOST=voltha-kafka.$INFRA_NS.svc.cluster.local
David Bainbridge837e8bd2020-04-06 13:17:14 -07001614 _PORT=9092
David Bainbridged18f4942020-04-14 16:46:13 -07001615 if [ "$WITH_KAFKA" == "yes" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -07001616 _HOST=voltha-kafka.$VOLTHA_NS.svc.cluster.local
1617 _PORT=9092
David Bainbridged18f4942020-04-14 16:46:13 -07001618 elif [ "$WITH_KAFKA" == "external" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -07001619 _HOST=kafka.$INFRA_NS.svc.cluster.local
1620 _PORT=9092
1621 else
David Bainbridged18f4942020-04-14 16:46:13 -07001622 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
1623 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge837e8bd2020-04-06 13:17:14 -07001624 _PORT=${_PORT:-9092}
1625 fi
1626 push_onos_config "json" "Push ONOS Kafka Configuration" "network/configuration/apps/org.opencord.kafka" \
David Bainbridged18f4942020-04-14 16:46:13 -07001627 "$(cat <<EOJ | tr -d '[:space:]'
David Bainbridge696bc632020-04-05 21:49:37 -07001628{
1629 "kafka": {
1630 "bootstrapServers": "$_HOST:$_PORT"
1631 }
1632}
1633EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07001634)"
David Bainbridge837e8bd2020-04-06 13:17:14 -07001635 fi
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001636 check_onos_app_active org.opencord.dhcpl2relay
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001637 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 -08001638 check_onos_app_active org.opencord.olt
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001639 # FIXME use WITH_DHCP and WITH_EAPOL flags to configre OLT App
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001640 # Default value for "enableEapol" is true in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07001641 if [ "$WITH_EAPOL" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001642 push_onos_config "json" "Enable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":true}'
David Bainbridged18f4942020-04-14 16:46:13 -07001643 elif [ "$WITH_EAPOL" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001644 push_onos_config "json" "Disable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001645 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001646 # Default value for "enableDhcpOnProvisioning" is false and for "enableDhcpV4" is true in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07001647 if [ "$WITH_DHCP" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001648 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 -07001649 elif [ "$WITH_DHCP" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001650 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 -08001651 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001652 # Default value for "enableIgmpOnProvisioning" is false in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07001653 if [ "$WITH_IGMP" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001654 push_onos_config "json" "Enable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":true}'
David Bainbridged18f4942020-04-14 16:46:13 -07001655 elif [ "$WITH_IGMP" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001656 push_onos_config "json" "Disable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001657 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001658 if [ "$ENABLE_ONOS_EXTRANEOUS_RULES" == "yes" ]; then
David K. Bainbridge484d80c2020-03-05 21:44:34 -08001659 push_onos_config "file" "Enabling extraneous rules for ONOS" "configuration/org.onosproject.net.flow.impl.FlowRuleManager" "onos-files/olt-onos-enableExtraneousRules.json"
1660 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001661 if is_in "$CONFIG_SADIS" "yes,file"; then
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001662 check_onos_app_active org.opencord.sadis
Hardik Windlassb3147602020-03-09 16:59:15 +05301663 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 -07001664 elif [ "$CONFIG_SADIS" == "bbsim" ]; then
1665 push_onos_config "json" \
1666 "[optional] Push ONOS configuration for BBSIM SADIS servers" \
1667 "network/configuration/apps/org.opencord.sadis" \
David Bainbridged18f4942020-04-14 16:46:13 -07001668 "$(cat <<EOJ | tr -d '[:space:]'
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001669{
1670 "sadis": {
1671 "integration": {
David Bainbridge76afd812020-04-06 09:53:52 -07001672 "url": "http://bbsim.$BBSIM_NS.svc.cluster.local:50074/v2/subscribers/%s",
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001673 "cache": {
1674 "enabled": true,
1675 "maxsize": 50,
1676 "ttl": "PT1m"
1677 }
1678 }
1679 },
1680 "bandwidthprofile": {
1681 "integration": {
David Bainbridge76afd812020-04-06 09:53:52 -07001682 "url": "http://bbsim.$BBSIM_NS.svc.cluster.local:50074/v2/bandwidthprofiles/%s",
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001683 "cache": {
1684 "enabled": true,
1685 "maxsize": 50,
1686 "ttl": "PT1m"
1687 }
1688 }
1689 }
1690}
1691EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07001692)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001693 elif [ "$CONFIG_SADIS" == "url" ]; then
1694 push_onos_config "json" \
1695 "[optional] Push ONOS configuration for custom SADIS and Bandwidth Profile servers" \
1696 "network/configuration/apps/org.opencord.sadis" \
David Bainbridged18f4942020-04-14 16:46:13 -07001697 "$(cat <<EOJ | tr -d '[:space:]'
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001698{
1699 "sadis": {
1700 "integration": {
1701 "url": "$SADIS_SUBSCRIBERS",
1702 "cache": {
1703 "enabled": true,
1704 "maxsize": 50,
1705 "ttl": "PT1m"
1706 }
1707 }
1708 },
1709 "bandwidthprofile": {
1710 "integration": {
1711 "url": "$SADIS_BANDWIDTH_PROFILES",
1712 "cache": {
1713 "enabled": true,
1714 "maxsize": 50,
1715 "ttl": "PT1m"
1716 }
1717 }
1718 }
1719}
1720EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07001721)"
David Bainbridge2b19e832019-08-16 02:40:53 +00001722 fi
Test Userba1e7e72019-07-10 22:27:54 +00001723fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001724if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001725 NOW="$(date +%s)"
1726 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001727fi
Test Userba1e7e72019-07-10 22:27:54 +00001728
David Bainbridged18f4942020-04-14 16:46:13 -07001729if [ "$WITH_ETCD" == "external" ]; then
1730 STIME="$(date +%s)"
David Bainbridge76afd812020-04-06 09:53:52 -07001731 bspin "Verify external ETCD cluster $OLD_KEY"
David Bainbridged18f4942020-04-14 16:46:13 -07001732 EXPECT="$(test "$TYPE" == "minimal" && echo "1" || echo "3")"
1733 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^etcd-cluster\$" | wc -l)" -ne 1 ]; then
1734 espin "$NOT_VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07001735 INTERNAL_EXTRA_HELM_INSTALL_ARGS+="--set clusterName=etcd-cluster --set autoCompactionRetention=1 --set clusterSize=$EXPECT"
David Bainbridged18f4942020-04-14 16:46:13 -07001736 helm_install - "$INFRA_NS" etcd-cluster onf/voltha-etcd-cluster latest "$_HELM_DESC external ETCD cluster"
David Bainbridge76afd812020-04-06 09:53:52 -07001737 else
David Bainbridged18f4942020-04-14 16:46:13 -07001738 espin "$VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07001739 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001740 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for ETCD cluster to start" "$NO_LABEL" "etcd-cluster-.*"
David Bainbridge76afd812020-04-06 09:53:52 -07001741 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001742 NOW="$(date +%s)"
1743 printtime $((NOW - STIME))
David Bainbridge76afd812020-04-06 09:53:52 -07001744 fi
1745fi
1746
David Bainbridged18f4942020-04-14 16:46:13 -07001747if [ "$WITH_KAFKA" == "external" ]; then
1748 _TMP="$(mktemp -u)"
1749 _COUNT="$(test "$TYPE" == "minimal" && echo "1" || echo "3")"
1750 cat << EOC > "$_TMP"
David Bainbridge76afd812020-04-06 09:53:52 -07001751configurationOverrides:
1752 "default.replication.factor": $_COUNT
1753 "offsets.topic.replication.factor": $_COUNT
1754 "log.retention.hours": 4
1755 "log.message.timestamp.type": "LogAppendTime"
1756persistence:
1757 enabled: false
1758zookeeper:
1759 replicaCount: 1
1760 persistence:
1761 enabled: false
1762replicas: $_COUNT
1763EOC
David Bainbridged18f4942020-04-14 16:46:13 -07001764 STIME="$(date +%s)"
David Bainbridge76afd812020-04-06 09:53:52 -07001765 bspin "Verify external Kafka cluster $OLD_KEY"
David Bainbridged18f4942020-04-14 16:46:13 -07001766 EXPECT="$(test "$TYPE" == "minimal" && echo "2" || echo "4")"
1767 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^kafka\$" | wc -l)" -ne 1 ]; then
1768 espin "$NOT_VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07001769 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" -f $_TMP"
David Bainbridgecf546362020-04-21 23:18:50 -07001770 helm_install - "$INFRA_NS" kafka "$KAFKA_CHART" "$KAFKA_CHART_VERSION" "$_HELM_DESC external Kafka cluster"
David Bainbridge76afd812020-04-06 09:53:52 -07001771 else
David Bainbridged18f4942020-04-14 16:46:13 -07001772 espin "$VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07001773 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001774 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for Kafka cluster to start" "$NO_LABEL" "kafka-.*"
David Bainbridge76afd812020-04-06 09:53:52 -07001775 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001776 NOW="$(date +%s)"
1777 printtime $((NOW - STIME))
David Bainbridge76afd812020-04-06 09:53:52 -07001778 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001779 rm -rf "$_TMP"
David Bainbridge76afd812020-04-06 09:53:52 -07001780fi
1781
David Bainbridged18f4942020-04-14 16:46:13 -07001782STIME="$(date +%s)"
David Bainbridge696bc632020-04-05 21:49:37 -07001783EXPECT=1
1784if [ "$ONLY_ONE" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001785 EXPECT="$((EXPECT+1))"
David Bainbridge696bc632020-04-05 21:49:37 -07001786 INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set therecanbeonlyone=true"
1787else
David Bainbridged18f4942020-04-14 16:46:13 -07001788 EXPECT="$((EXPECT+2))"
David Bainbridge696bc632020-04-05 21:49:37 -07001789fi
Matteo Scandolo67335f02020-04-09 11:19:53 -07001790case $WITH_ETCD in
David Bainbridge76afd812020-04-06 09:53:52 -07001791 no)
1792 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set private_etcd_cluster=false"
1793 ;;
1794 yes)
1795 _HOST="voltha-etcd-cluster-client.$VOLTHA_NS.svc.cluster.local"
1796 _PORT=2379
1797 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridged18f4942020-04-14 16:46:13 -07001798 EXPECT="$((EXPECT+$(test "$TYPE" == "minimal" && echo "1" || echo "3")))"
David Bainbridge76afd812020-04-06 09:53:52 -07001799 ;;
1800 external)
1801 _HOST="etcd-cluster-client.$INFRA_NS.svc.cluster.local"
1802 _PORT=2379
1803 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set private_etcd_cluster=false --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
1804 ;;
1805 *)
David Bainbridged18f4942020-04-14 16:46:13 -07001806 _HOST="$(echo "$WITH_ETCD" | cut -d: -f1)"
1807 _PORT="$(echo "$WITH_ETCD" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07001808 _PORT=${_PORT:-2379}
David Bainbridge76afd812020-04-06 09:53:52 -07001809 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set private_etcd_cluster=false --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
1810 ;;
1811esac
1812case $WITH_KAFKA in
1813 no)
1814 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set private_kafka_cluster=false"
1815 ;;
1816 yes)
1817 _HOST=voltha-kafka.$VOLTHA_NS.svc.cluster.local
1818 _PORT=9092
1819 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 -07001820 EXPECT="$((EXPECT+$(test "$TYPE" == "minimal" && echo "2" || echo "4")))"
David Bainbridge76afd812020-04-06 09:53:52 -07001821 ;;
1822 external)
1823 _HOST=kafka.$INFRA_NS.svc.cluster.local
1824 _PORT=9092
1825 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"
1826 ;;
1827 *)
David Bainbridged18f4942020-04-14 16:46:13 -07001828 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
1829 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07001830 _PORT=${_PORT:-9092}
David Bainbridge76afd812020-04-06 09:53:52 -07001831 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"
1832 ;;
1833esac
1834
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001835if is_in "$WITH_ONOS" "legacy"; then
David Bainbridge76afd812020-04-06 09:53:52 -07001836 _HOST=onos-openflow.$INFRA_NS.svc.cluster.local
1837 _PORT=6653
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001838elif is_in "$WITH_ONOS" "yes,classic"; then
1839 _HOST=onos-onos-classic-hs.$INFRA_NS.svc.cluster.local
1840 _PORT=6653
David Bainbridged18f4942020-04-14 16:46:13 -07001841elif [ "$WITH_ONOS" != "no" ]; then
1842 _HOST="$(echo "$WITH_ONOS" | cut -d: -f1)"
1843 _PORT="$(echo "$WITH_ONOS" | cut -s -d: -f2)"
David Bainbridge76afd812020-04-06 09:53:52 -07001844 _PORT=${_PORT:-6653}
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07001845fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001846
David Bainbridgecf546362020-04-21 23:18:50 -07001847compare_versions "$RESOLVED_VOLTHA_CHART_VERSION" 2.4.2
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07001848if [ "$?" == "1" ]; then
1849 # voltha chart > 2.4.2 uses list of controllers
1850 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.controller[0].service=$_HOST --set services.controller[0].port=$_PORT"
1851else
1852 # voltha chart <= 2.4.2 uses single controller
David Bainbridge76afd812020-04-06 09:53:52 -07001853 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.controller.service=$_HOST --set services.controller.port=$_PORT"
David Bainbridge696bc632020-04-05 21:49:37 -07001854fi
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07001855
Test Userb5712372019-07-03 21:52:17 +00001856bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
David Bainbridged18f4942020-04-14 16:46:13 -07001857if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$VOLTHA_NS" "^voltha\$" | wc -l)" -ne 1 ]; then
1858 espin "$NOT_VERIFIED"
1859 helm_install - "$VOLTHA_NS" voltha "$VOLTHA_CHART" "$VOLTHA_CHART_VERSION" "$_HELM_DESC VOLTHA Core"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001860else
David Bainbridged18f4942020-04-14 16:46:13 -07001861 espin "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001862fi
David Bainbridge696bc632020-04-05 21:49:37 -07001863INTERNAL_EXTRA_HELM_INSTALL_ARGS=
Test Userba1e7e72019-07-10 22:27:54 +00001864
David Bainbridge90fd8e32019-08-21 23:32:47 +00001865VOLTHA="voltha-ofagent-.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001866 rw-core.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001867 voltha-etcd-cluster-.* \
1868 voltha-kafka-.* \
1869 voltha-zookeeper-.*"
David Bainbridged18f4942020-04-14 16:46:13 -07001870wait_for_pods - "$VOLTHA_NS" "$EXPECT" "includes" "Waiting for VOLTHA Core to start" "$NO_LABEL" "$VOLTHA"
David Bainbridgee87067b2019-08-12 22:00:12 +00001871if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001872 NOW="$(date +%s)"
1873 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001874fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001875
David Bainbridge46505fb2019-10-01 21:13:20 +00001876if [ "$WITH_ADAPTERS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001877 STIME="$(date +%s)"
David Bainbridge46505fb2019-10-01 21:13:20 +00001878 EXPECT=0
David Bainbridged18f4942020-04-14 16:46:13 -07001879 if [ "$WITH_ETCD" == "yes" ]; then
David Bainbridge3517f6c2020-04-08 12:14:08 -07001880 _HOST=voltha-etcd-cluster-client.$VOLTHA_NS.svc.cluster.local
1881 _PORT=2379
1882 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridged18f4942020-04-14 16:46:13 -07001883 elif [ "$WITH_ETCD" == "external" ]; then
David Bainbridge3517f6c2020-04-08 12:14:08 -07001884 _HOST=etcd-cluster-client.$INFRA_NS.svc.cluster.local
1885 _PORT=2379
1886 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridged18f4942020-04-14 16:46:13 -07001887 elif [ "$WITH_ETCD" != "no" ]; then
1888 _HOST="$(echo "$WITH_ETCD" | cut -d: -f1)"
1889 _PORT="$(echo "$WITH_ETCD" | cut -s -d: -f2)"
David Bainbridge3517f6c2020-04-08 12:14:08 -07001890 _PORT=${_PORT:-2379}
1891 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridge696bc632020-04-05 21:49:37 -07001892 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001893 if [ "$WITH_KAFKA" == "yes" ]; then
David Bainbridge3517f6c2020-04-08 12:14:08 -07001894 _HOST=voltha-kafka.$VOLTHA_NS.svc.cluster.local
1895 _PORT=9092
1896 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 -07001897 elif [ "$WITH_KAFKA" == "external" ]; then
David Bainbridge3517f6c2020-04-08 12:14:08 -07001898 _HOST=kafka.$INFRA_NS.svc.cluster.local
1899 _PORT=9092
1900 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 -07001901 elif [ "$WITH_KAFKA" != "no" ]; then
1902 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
1903 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge3517f6c2020-04-08 12:14:08 -07001904 _PORT=${_PORT:-9092}
1905 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 -07001906 fi
David Bainbridge46505fb2019-10-01 21:13:20 +00001907 echo -e "Verify Adapters $PLUG"
1908 if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then
1909 bspin - "Verify Simulated Adapters installed"
David Bainbridged18f4942020-04-14 16:46:13 -07001910 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$ADAPTER_NS" "^sim\$" | wc -l)" -ne 1 ]; then
1911 espin - "$NOT_VERIFIED"
1912 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 +00001913 else
David Bainbridged18f4942020-04-14 16:46:13 -07001914 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00001915 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001916 EXPECT="$((EXPECT + 2))"
David Bainbridge46505fb2019-10-01 21:13:20 +00001917 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001918
David Bainbridge46505fb2019-10-01 21:13:20 +00001919 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
1920 bspin - "Verify OpenOLT Adapter installed"
David Bainbridged18f4942020-04-14 16:46:13 -07001921 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$ADAPTER_NS" "^open-olt\$" | wc -l)" -ne 1 ]; then
1922 espin - "$NOT_VERIFIED"
1923 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 +00001924 else
David Bainbridged18f4942020-04-14 16:46:13 -07001925 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00001926 fi
Matteo Scandolo67335f02020-04-09 11:19:53 -07001927 EXPECT="$((EXPECT + 1))"
David Bainbridge46505fb2019-10-01 21:13:20 +00001928 bspin - "Verify OpenONU Adapter installed"
David Bainbridged18f4942020-04-14 16:46:13 -07001929 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 -07001930 _ORIGINAL_EXTRA_HELM_INSTALL_ARGS="$INTERNAL_EXTRA_HELM_INSTALL_ARGS"
1931 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set replicas.adapter_open_onu=$NUM_OF_OPENONU"
David Bainbridged18f4942020-04-14 16:46:13 -07001932 espin - "$NOT_VERIFIED"
Matteo Scandolo67335f02020-04-09 11:19:53 -07001933 helm_install - "$ADAPTER_NS" open-onu "$VOLTHA_ADAPTER_OPEN_ONU_CHART" "$VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION" "$_HELM_DESC OpenONU Adapter"
1934 INTERNAL_EXTRA_HELM_INSTALL_ARGS="$_ORIGINAL_EXTRA_HELM_INSTALL_ARGS"
David Bainbridge46505fb2019-10-01 21:13:20 +00001935 else
David Bainbridged18f4942020-04-14 16:46:13 -07001936 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00001937 fi
Matteo Scandolo67335f02020-04-09 11:19:53 -07001938 EXPECT=$((EXPECT + NUM_OF_OPENONU))
David Bainbridge46505fb2019-10-01 21:13:20 +00001939 fi
David Bainbridge696bc632020-04-05 21:49:37 -07001940 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001941
David Bainbridge46505fb2019-10-01 21:13:20 +00001942 ADAPTERS="adapter-.*"
David Bainbridged18f4942020-04-14 16:46:13 -07001943 wait_for_pods - "$ADAPTER_NS" "$EXPECT" "includes" "Waiting for adapters to start" "$NO_LABEL" "$ADAPTERS"
David Bainbridge46505fb2019-10-01 21:13:20 +00001944 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001945 NOW="$(date +%s)"
1946 printtime $((NOW - STIME))
David Bainbridge46505fb2019-10-01 21:13:20 +00001947 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001948fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001949
David Bainbridged18f4942020-04-14 16:46:13 -07001950if [ "$WITH_BBSIM" == "yes" ]; then
1951 STIME="$(date +%s)"
Test User7d866122019-07-09 17:52:35 +00001952 echo -e "Verify BBSIM $PLUG"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001953 bspin - "Verify BBSIM Installed"
David Bainbridged18f4942020-04-14 16:46:13 -07001954 for instance in $(seq 0 $((NUM_OF_BBSIM-1))); do
1955 if [ "$instance" -eq 0 ]; then
David K. Bainbridge43422402020-03-06 07:41:22 -08001956 instance_num=""
1957 else
1958 instance_num=$instance
1959 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001960 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$BBSIM_NS" "^bbsim${instance_num}\$" | wc -l)" -ne 1 ]; then
1961 espin - "$NOT_VERIFIED"
1962 S_TAG="$((900+instance))"
Matteo Scandolo5a149572020-04-01 10:14:57 -07001963 INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set olt_id=$instance,s_tag=$S_TAG"
David Bainbridged9329af2020-05-01 11:58:52 -07001964 if [ "$WITH_EAPOL" == "yes" ]; then
1965 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set auth=true"
1966 else
1967 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set auth=false"
1968 fi
1969 if [ "$WITH_DHCP" == "yes" ]; then
1970 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set dhcp=true"
1971 else
1972 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set dhcp=false"
1973 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001974 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 -07001975 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
David K. Bainbridge43422402020-03-06 07:41:22 -08001976 else
David Bainbridged18f4942020-04-14 16:46:13 -07001977 espin - "$VERIFIED"
David K. Bainbridge43422402020-03-06 07:41:22 -08001978 fi
1979 done
David Bainbridged18f4942020-04-14 16:46:13 -07001980 wait_for_pods - "$BBSIM_NS" "$NUM_OF_BBSIM" "includes" "Waiting for BBSIM to start" "$BBSIM_LABEL" "bbsim*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001981 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001982 NOW="$(date +%s)"
1983 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001984 fi
Test User7d866122019-07-09 17:52:35 +00001985fi
1986
David Bainbridged18f4942020-04-14 16:46:13 -07001987if [ "$WITH_RADIUS" == "yes" ]; then
1988 STIME="$(date +%s)"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001989 echo -e "Verify RADIUS $LOCK"
1990 bspin - "Verify RADIUS Installed"
David Bainbridged18f4942020-04-14 16:46:13 -07001991 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^radius\$" | wc -l)" -ne 1 ]; then
1992 espin - "$NOT_VERIFIED"
1993 helm_install - "$INFRA_NS" radius onf/freeradius latest "$_HELM_DESC RADIUS"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001994 else
David Bainbridged18f4942020-04-14 16:46:13 -07001995 espin - "$VERIFIED"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001996 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001997 wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for RADIUS to start" "$NO_LABEL" "radius-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001998 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001999 NOW="$(date +%s)"
2000 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002001 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002002fi
2003
David Bainbridged18f4942020-04-14 16:46:13 -07002004if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
2005 STIME="$(date +%s)"
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002006 bspin - "Forward VOLTHA API port $FORWARD"
2007 kill_port_forward voltha-api
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002008 port_forward "$VOLTHA_NS" voltha-api "$VOLTHA_API_PORT:55555"
David Bainbridged18f4942020-04-14 16:46:13 -07002009 espin - "$VERIFIED"
2010 if [ "$WITH_ETCD" == "yes" ] || [ "$WITH_ETCD" == "external" ]; then
2011 _NS="$(test "$WITH_ETCD" == "yes" && echo "$VOLTHA_NS" || echo "$INFRA_NS")"
David Bainbridge696bc632020-04-05 21:49:37 -07002012 bspin - "Forward VOLTHA ETCD port $FORWARD"
David Bainbridged18f4942020-04-14 16:46:13 -07002013 kill_port_forward "${ETCD_PREFIX}etcd-cluster-client"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002014 port_forward "$_NS" "${ETCD_PREFIX}etcd-cluster-client" "$VOLTHA_ETCD_PORT:2379"
David Bainbridged18f4942020-04-14 16:46:13 -07002015 espin - "$VERIFIED"
David Bainbridge696bc632020-04-05 21:49:37 -07002016 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002017 if [ "$WITH_KAFKA" == "yes" ] || [ $WITH_KAFKA == "external" ]; then
2018 _NS="$(test "$WITH_ETCD" == "yes" && echo "$VOLTHA_NS" || echo "$INFRA_NS")"
David Bainbridge696bc632020-04-05 21:49:37 -07002019 bspin - "Forward VOLTHA Kafka port $FORWARD"
David Bainbridged18f4942020-04-14 16:46:13 -07002020 kill_port_forward "${KAFKA_PREFIX}kafka"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002021 port_forward "$_NS" ${KAFKA_PREFIX}kafka "$VOLTHA_KAFKA_PORT:9092"
David Bainbridged18f4942020-04-14 16:46:13 -07002022 espin - "$VERIFIED"
David Bainbridge696bc632020-04-05 21:49:37 -07002023 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002024 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002025 NOW="$(date +%s)"
2026 printtime $((NOW - STIME))
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002027 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00002028fi
Test User3d7ad8e2019-07-03 06:15:44 +00002029
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002030if is_in "$WITH_ONOS" "yes,legacy,classic" && [ "$WITH_RADIUS" != "no" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -07002031 _HOST=radius.$INFRA_NS.svc.cluster.local
David Bainbridge696bc632020-04-05 21:49:37 -07002032 _PORT=1812
David Bainbridged18f4942020-04-14 16:46:13 -07002033 if [ "$WITH_RADIUS" != "yes" ]; then
2034 _HOST="$(echo "$WITH_RADIUS" | cut -d: -f1)"
2035 _PORT="$(echo "$WITH_RADIUS" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07002036 _PORT=${_PORT:-1812}
2037 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002038 bspin "Configure ONOS RADIUS Connection $GEAR"
David Bainbridged18f4942020-04-14 16:46:13 -07002039 (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
2040 espin "$VERIFIED"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002041fi
2042
David Bainbridge99ac7a22019-08-31 02:26:43 +00002043if [ "$WITH_CHAOS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002044 STIME="$(date +%s)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002045 echo -e "Verify kube-monkey $LOCK"
2046 bspin - "Verify kube-monkey Installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002047 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace kube-monkey "^monkey\$" | wc -l)" -ne 1 ]; then
2048 espin - "$NOT_VERIFIED"
David Bainbridge7f8bf992020-04-08 21:53:22 -07002049 helm_install - kube-monkey monkey ./kube-monkey/helm/kubemonkey latest "$_HELM_DESC Chaos Monkey"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002050 else
David Bainbridged18f4942020-04-14 16:46:13 -07002051 espin - "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002052 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002053 wait_for_pods - "kube-monkey" 1 "includes" "Waiting for Chaos to start" "$NO_LABEL" "monkey-.*"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002054 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002055 NOW="$(date +%s)"
2056 printtime $((NOW - STIME))
David Bainbridge99ac7a22019-08-31 02:26:43 +00002057 fi
2058fi
2059
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002060bspin "Create voltctl configuration file"
David Bainbridged18f4942020-04-14 16:46:13 -07002061(set -x; mkdir -p "$HOME/.volt" >>"$LOG" 2>&1) >>"$LOG" 2>&1
2062MIN_VC_VERSION="$(echo -e "1.0.15\n$VC_VERSION" | sort -V | head -1)"
2063if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002064 KAFKA_FLAG="-k localhost:$VOLTHA_KAFKA_PORT"
2065 SERVER_FLAG="-s localhost:$VOLTHA_API_PORT"
2066 ETCD_FLAG=
2067 if [ "$MIN_VC_VERSION" == "1.0.15" ]; then
2068 ETCD_FLAG="-e localhost:$VOLTHA_ETCD_PORT"
2069 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002070else
David Bainbridged18f4942020-04-14 16:46:13 -07002071 KAFKA_FLAG="-k $(get_service_ep "$INFRA_NS" "${KAFKA_PREFIX}kafka")"
2072 SERVER_FLAG="-s $(get_service_ep "$VOLTHA_NS" voltha-api)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002073 ETCD_FLAG=
2074 if [ "$MIN_VC_VERSION" == "1.0.15" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002075 ETCD_FLAG="-e $(get_service_ep "$INFRA_NS" ${ETCD_PREFIX}etcd-client)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002076 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002077fi
David Bainbridged18f4942020-04-14 16:46:13 -07002078CMD=("voltctl -a v3 $KAFKA_FLAG $SERVER_FLAG $ETCD_FLAG config")
2079(set -x; ${CMD[*]} > "$HOME/.volt/config-$NAME" 2>>"$LOG") >>"$LOG" 2>&1
2080#(set -x; voltctl -a v3 "$KAFKA_FLAG" "$SERVER_FLAG" "$ETCD_FLAG" config > "$HOME/.volt/config-$NAME" 2>>"$LOG") >>"$LOG" 2>&1
2081espin "$VERIFIED"
Test User08ebbd92019-07-03 17:15:39 +00002082
David Bainbridge0774b232019-08-02 06:37:19 +00002083if [ ! -f "$NAME-env.sh" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002084 touch "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002085fi
2086
David Bainbridge596f30d2019-07-30 17:07:59 +00002087for O in $ALL_OPTIONS; do
David Bainbridged18f4942020-04-14 16:46:13 -07002088 VAL="$(eval echo "\$$O")"
2089 if [ -n "$VAL" ] && [ "$(grep -c "^export $O=" "$NAME-env.sh")" -eq 0 ]; then
2090 echo "export $O=\"$(eval echo "\$$O")\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002091 fi
2092done
2093
David Bainbridged18f4942020-04-14 16:46:13 -07002094if [ "$DEPLOY_K8S" == "yes" ] && [ "$(grep -c "^export KUBECONFIG=" "$NAME-env.sh")" -eq 0 ]; then
2095 echo "export KUBECONFIG=\"$(./bin/kind get kubeconfig-path "--name=voltha-$NAME")\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002096fi
2097
David Bainbridged18f4942020-04-14 16:46:13 -07002098if [ "$(grep -c "^export VOLTCONFIG=" "$NAME-env.sh")" -eq 0 ]; then
2099 echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002100fi
2101
David Bainbridged18f4942020-04-14 16:46:13 -07002102if [ "$(grep -c "^export PATH=" "$NAME-env.sh")" -eq 0 ]; then
2103 echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002104fi
2105
Test User7d866122019-07-09 17:52:35 +00002106echo ""
David Bainbridged18f4942020-04-14 16:46:13 -07002107echo "Please issue the following commands in your terminal to ensure that you" | tee -a "$LOG"
2108echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a "$LOG"
2109echo "tools required by VOLTHA in your command path. " | tee -a "$LOG"
2110echo "" | tee -a "$LOG"
2111echo -en "$BOLD"
2112if [ "$DEPLOY_K8S" == "yes" ]; then
2113 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00002114fi
David Bainbridged18f4942020-04-14 16:46:13 -07002115echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" | tee -a "$LOG"
2116echo "export PATH=$GOPATH/bin:\$PATH" | tee -a "$LOG"
2117echo -en "$NORMAL"
2118echo "" | tee -a "$LOG"
2119echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a "$LOG"
Test User08ebbd92019-07-03 17:15:39 +00002120
David Bainbridge712afb82019-08-14 19:55:58 +00002121if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002122 NOW="$(date +%s)"
2123 echo -e "$CLOCK ${BOLD}TOTAL: $(duration $((NOW - TOTAL_START_TIME)))${NORMAL}"
David Bainbridge712afb82019-08-14 19:55:58 +00002124fi