blob: 7f8d94c97207b4b2b50f757b5de390136aba8efe [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 Bainbridgeb4bbde12020-06-25 14:46:36 -070019mkdir -p "$(pwd)/bin"
20PATH="$(pwd)/bin:$PATH"; export PATH
21GOPATH="$(pwd)"; export GOPATH
David K. Bainbridgeb7285432019-07-02 22:05:24 -070022
David Bainbridge38dc1e82019-08-12 15:18:45 +000023FANCY=${FANCY:-1}
24if [ "$TERM X" == " X" ]; then
25 FANCY=0
26fi
27
David K. Bainbridgeb7285432019-07-02 22:05:24 -070028# trap ctrl-c and call ctrl_c()
29trap ctrl_c INT
30
31function ctrl_c() {
David Bainbridged18f4942020-04-14 16:46:13 -070032 echo -en "$CNORM"
David K. Bainbridgeb7285432019-07-02 22:05:24 -070033 echo ""
34 echo "ctrl-c trapped"
David Bainbridgec6a6eb62019-10-18 22:50:07 +000035 echo "Thank you for trying 'voltha up'"
David K. Bainbridgeb7285432019-07-02 22:05:24 -070036 exit
37}
38
Andrea Campanella40e48b72020-07-21 20:32:52 +020039HELM_VERSION=${HELM_VERSION:-v3.2.4}
David K. Bainbridgeebf38d92020-02-10 10:46:31 -080040VOLTCTL_VERSION=${VOLTCTL_VERSION:-latest}
David K. Bainbridge88a7a792020-07-27 17:01:14 +000041KIND_VERSION=${KIND_VERSION:-v0.8.1}
David K. Bainbridgeb3a99372020-01-08 14:39:06 -080042VK_RELEASE=${VK_RELEASE:-master}
David Bainbridge60ffc0f2020-04-27 22:13:22 -070043EXTRA_TOOLS=
Test User08ebbd92019-07-03 17:15:39 +000044
David Bainbridge38dc1e82019-08-12 15:18:45 +000045RED=
46GREEN=
47YELLOW=
48BLUE=
David Bainbridge38dc1e82019-08-12 15:18:45 +000049BOLD=
50NORMAL=
51ERROR=
52CEOL=
53CNORM=
54CIVIS=
David Bainbridged18f4942020-04-14 16:46:13 -070055if [ "$FANCY" -eq 1 ]; then
56 RED="$(tput setaf 1)"
57 GREEN="$(tput setaf 2)"
58 YELLOW="$(tput setaf 3)"
59 BLUE="$(tput setaf 4)"
60 BOLD="$(tput bold)"
61 NORMAL="$(tput sgr0)"
David Bainbridge38dc1e82019-08-12 15:18:45 +000062 ERROR="\xe2\x9c\x97\x20"
David Bainbridged18f4942020-04-14 16:46:13 -070063 CEOL="$(tput el)"
64 CNORM="$(tput cnorm)"
65 CIVIS="$(tput civis)"
David Bainbridge38dc1e82019-08-12 15:18:45 +000066fi
Test User7d866122019-07-09 17:52:35 +000067
Test User3d7ad8e2019-07-03 06:15:44 +000068TYPE=${TYPE:-minimal}
David Bainbridge0774b232019-08-02 06:37:19 +000069NAME=${NAME:-$TYPE}
David K. Bainbridge484d80c2020-03-05 21:44:34 -080070
71ENABLE_ONOS_EXTRANEOUS_RULES=${ENABLE_ONOS_EXTRANEOUS_RULES:-no}
David Bainbridge76afd812020-04-06 09:53:52 -070072INFRA_NS=${INFRA_NS:-default}
73VOLTHA_NS=${VOLTHA_NS:-voltha}
74BBSIM_NS=${BBSIM_NS:-voltha}
75ADAPTER_NS=${ADAPTER_NS:-voltha}
David Bainbridgee87067b2019-08-12 22:00:12 +000076WITH_TIMINGS=${WITH_TIMINGS:-no}
Test User7d866122019-07-09 17:52:35 +000077WITH_BBSIM=${WITH_BBSIM:-no}
divyadesai59f987a2020-05-27 12:11:33 +000078WITH_EFK=${WITH_EFK:-no}
David Bainbridge5b7b96b2019-07-25 20:29:13 +000079WITH_RADIUS=${WITH_RADIUS:-no}
Matteo Scandolo78dfee02020-02-13 16:18:03 -080080WITH_EAPOL=${WITH_EAPOL:-yes}
81WITH_DHCP=${WITH_DHCP:-yes}
82WITH_IGMP=${WITH_IGMP:-no}
David Bainbridgeb270c202019-07-26 01:44:42 +000083WITH_ONOS=${WITH_ONOS:-yes}
David Bainbridge60ffc0f2020-04-27 22:13:22 -070084NUM_OF_ONOS=${NUM_OF_ONOS:-1}
85NUM_OF_ATOMIX=${NUM_OF_ATOMIX:-0}
David Bainbridge99ac7a22019-08-31 02:26:43 +000086WITH_CHAOS=${WITH_CHAOS:-no}
David Bainbridge46505fb2019-10-01 21:13:20 +000087WITH_ADAPTERS=${WITH_ADAPTERS:-yes}
David K. Bainbridgeda33d652020-03-06 10:31:23 -080088WITH_SIM_ADAPTERS=${WITH_SIM_ADAPTERS:-no}
David Bainbridge46505fb2019-10-01 21:13:20 +000089WITH_OPEN_ADAPTERS=${WITH_OPEN_ADAPTERS:-yes}
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -080090WITH_PORT_FORWARDS=${WITH_PORT_FORWARDS:-yes}
David Bainbridge696bc632020-04-05 21:49:37 -070091WITH_KAFKA=${WITH_KAFKA:-yes}
92WITH_ETCD=${WITH_ETCD:-yes}
Matteo Scandoloefee0432020-05-05 13:56:20 -070093WITH_PPROF=${WITH_PPROF:-no}
Girish Gowdra4cc5d8b2020-06-11 17:12:00 -070094WITH_INCREMENTAL_EVTO_UPDATE=${WITH_INCREMENTAL_EVTO_UPDATE:-no}
David Bainbridgee4d11ca2020-05-08 10:21:10 -070095SCHEDULE_ON_CONTROL_NODES=${SCHEDULE_ON_CONTROL_NODES:-no}
David Bainbridge309099c2020-05-05 08:47:29 -070096CONFIG_SADIS=${CONFIG_SADIS:-no} # yes | no | file | bbsim | external | URL
Hardik Windlassb3147602020-03-09 16:59:15 +053097SADIS_CFG=${SADIS_CFG:-onos-files/onos-sadis-sample.json}
David Bainbridge27790d62019-08-13 22:43:19 +000098INSTALL_ONOS_APPS=${INSTALL_ONOS_APPS:-no}
Test Userba1e7e72019-07-10 22:27:54 +000099JUST_K8S=${JUST_K8S:-no}
100DEPLOY_K8S=${DEPLOY_K8S:-yes}
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700101INSTALL_KUBECTL=${INSTALL_KUBECTL:-yes}
102INSTALL_HELM=${INSTALL_HELM:-yes}
David Bainbridge7f8bf992020-04-08 21:53:22 -0700103HELM_USE_UPGRADE=${HELM_USE_UPGRADE:-no}
David Bainbridge46505fb2019-10-01 21:13:20 +0000104UPDATE_HELM_REPOS=${UPDATE_HELM_REPOS:-yes}
Matteo Scandolofab98622020-01-28 15:17:20 -0800105WAIT_ON_DOWN=${WAIT_ON_DOWN:-yes}
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700106WAIT_TIMEOUT=${WAIT_TIMEOUT:-30m}
107VOLTHA_DOWN_ON_TIMEOUT=${VOLTHA_DOWN_ON_TIMEOUT:-no}
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000108VOLTHA_LOG_LEVEL=${VOLTHA_LOG_LEVEL:-WARN}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000109VOLTHA_CHART=${VOLTHA_CHART:-onf/voltha}
110VOLTHA_CHART_VERSION=${VOLTHA_CHART_VERSION:-latest}
111VOLTHA_BBSIM_CHART=${VOLTHA_BBSIM_CHART:-onf/bbsim}
Matteo Scandolodcd29f52019-10-07 15:42:42 -0700112VOLTHA_BBSIM_CHART_VERSION=${VOLTHA_BBSIM_CHART_VERSION:-latest}
divyadesai59f987a2020-05-27 12:11:33 +0000113ELASTICSEARCH_CHART=${ELASTICSEARCH_CHART:-elastic/elasticsearch}
114ELASTICSEARCH_CHART_VERSION=${ELASTICSEARCH_CHART_VERSION:-latest}
115KIBANA_CHART=${KIBANA_CHART:-elastic/kibana}
116KIBANA_CHART_VERSION=${KIBANA_CHART_VERSION:-latest}
117FLUENTD_ELASTICSEARCH_CHART=${FLUENTD_ELASTICSEARCH_CHART:-kiwigrid/fluentd-elasticsearch}
118FLUENTD_ELASTICSEARCH_CHART_VERSION=${FLUENTD_ELASTICSEARCH_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000119VOLTHA_ADAPTER_SIM_CHART=${VOLTHA_ADAPTER_SIM_CHART:-onf/voltha-adapter-simulated}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000120VOLTHA_ADAPTER_SIM_CHART_VERSION=${VOLTHA_ADAPTER_SIM_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000121VOLTHA_ADAPTER_OPEN_OLT_CHART=${VOLTHA_ADAPTER_OPEN_OLT_CHART:-onf/voltha-adapter-openolt}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000122VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION=${VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000123VOLTHA_ADAPTER_OPEN_ONU_CHART=${VOLTHA_ADAPTER_OPEN_ONU_CHART:-onf/voltha-adapter-openonu}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000124VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION=${VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION:-latest}
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800125ONOS_CHART=${ONOS_CHART:-onf/onos}
Andrea Campanella21323292019-12-18 11:44:19 -0800126ONOS_CHART_VERSION=${ONOS_CHART_VERSION:-latest}
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700127ONOS_CLASSIC_CHART=${ONOS_CLASSIC_CHART:-onos/onos-classic}
Andrea Campanella655499f2020-07-16 09:57:35 +0200128ONOS_CLASSIC_CHART_VERSION=${ONOS_CLASSIC_CHART_VERSION:-0.1.1}
David Bainbridgecf546362020-04-21 23:18:50 -0700129KAFKA_CHART=${KAFKA_CHART:-incubator/kafka}
David Bainbridgeb4bbde12020-06-25 14:46:36 -0700130KAFKA_CHART_VERSION=${KAFKA_CHART_VERSION:=latest}
David Bainbridge309099c2020-05-05 08:47:29 -0700131BBSIM_SADIS_SERVER_CHART=${BBSIM_SADIS_SERVER_CHART:-bbsim-sadis/bbsim-sadis-server}
132BBSIM_SADIS_SERVER_CHART_VERSION=${BBSIM_SADIS_SERVER_CHART_VERSION:-latest}
David Bainbridgeb4bbde12020-06-25 14:46:36 -0700133ETCD_CHART=${ETCD_CHART:-etcd/etcd}
David Bainbridgec7220622020-05-28 12:31:47 -0700134ETCD_CHART_VERSION=${ETCD_CHART_VERSION:-latest}
David Bainbridge879439b2020-06-12 15:59:35 -0700135RADIUS_CHART=${RADIUS_CHART:-onf/freeradius}
136RADIUS_CHART_VERSION=${RADIUS_CHART_VERSION:-latest}
David Bainbridge2eaf2cf2020-03-18 12:54:08 -0700137EXTRA_HELM_INSTALL_ARGS=${EXTRA_HELM_INSTALL_ARGS:-}
138INTERNAL_EXTRA_HELM_INSTALL_ARGS=
uottrembb16d3982020-02-28 08:34:36 +0100139NUM_OF_BBSIM=${NUM_OF_BBSIM:-1}
Matteo Scandolo67335f02020-04-09 11:19:53 -0700140NUM_OF_OPENONU=${NUM_OF_OPENONU:-1}
uottrembb16d3982020-02-28 08:34:36 +0100141MAX_NUM_OF_BBSIM=10
Matteo Scandolo67335f02020-04-09 11:19:53 -0700142MAX_NUM_OF_OPENONU=10
Matteo Scandoloc2eb0672020-05-01 14:43:15 -0700143LEGACY_BBSIM_INDEX=${LEGACY_BBSIM_INDEX:-no}
David Bainbridgeb4bbde12020-06-25 14:46:36 -0700144PF_ADDRESS=${PF_ADDRESS:-0.0.0.0}
Test Userba1e7e72019-07-10 22:27:54 +0000145
David Bainbridged18f4942020-04-14 16:46:13 -0700146HOSTOS="$(uname -s | tr "[:upper:]" "[:lower:"])"
147HOSTARCH="$(uname -m | tr "[:upper:]" "[:lower:"])"
148if [ "$HOSTARCH" == "x86_64" ]; then
Test Userba1e7e72019-07-10 22:27:54 +0000149 HOSTARCH="amd64"
150fi
David Bainbridge7db44002020-04-09 12:54:29 -0700151BBSIM_LABEL="-l app=bbsim"
David Bainbridged18f4942020-04-14 16:46:13 -0700152NO_LABEL=
Test User7d866122019-07-09 17:52:35 +0000153
uottrembb16d3982020-02-28 08:34:36 +0100154# check number (range) of bbsim, max bbsim must not exceed 10 instances!
155# note: instances will be numbered from 0 to 9
156if [ "$1" == "up" ]; then
David K. Bainbridge43422402020-03-06 07:41:22 -0800157 if [ "$NUM_OF_BBSIM" -lt 1 ]; then
Matteo Scandolo67335f02020-04-09 11:19:53 -0700158 >&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 -0800159 exit 1
160 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700161 if [ "$NUM_OF_BBSIM" -gt "$MAX_NUM_OF_BBSIM" ]; then
Matteo Scandolo67335f02020-04-09 11:19:53 -0700162 >&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}"
163 exit 1
164 fi
165
166 if [ "$NUM_OF_OPENONU" -lt 1 ]; then
167 >&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}"
168 exit 1
169 fi
170 if [ "$NUM_OF_OPENONU" -gt "$MAX_NUM_OF_OPENONU" ]; then
171 >&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 -0800172 exit 1
173 fi
uottrembb16d3982020-02-28 08:34:36 +0100174fi
Test User7d866122019-07-09 17:52:35 +0000175# Verify TYPE setting
David Bainbridged18f4942020-04-14 16:46:13 -0700176if [ "$(echo ":minimal:full:" | grep -ic ":$TYPE:")" -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700177 >&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 +0000178 exit 1
179fi
180
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700181# checks to see if a given WORD is in the given LIST of words
182function is_in() {
183 local WORD LIST
184 WORD="$1"; shift
185 LIST="$*"
186 LIST=${LIST//+([[:space:],|])/:}
187
188 [ "$(echo ":$LIST:" | grep -ic ":$WORD:")" -ne 0 ]
189}
190
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700191function parseDuration() {
David Bainbridged18f4942020-04-14 16:46:13 -0700192 local DUR RESULT TERM TERMS VALUE UNIT
193 DUR=$1
194 RESULT=0
195 TERMS="$(echo "$DUR" | sed -Ee 's/([sSmMhHdD])/\1 /g' -e 's/,$//g')"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700196 for TERM in $TERMS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700197 VALUE="$(echo "$TERM" | sed -Ee 's/([0-9]+)[sSmMhHdD]/\1/')"
198 UNIT="$(echo "$TERM" | sed -Ee 's/[0-9]+([sSmMhHdD])/\1/')"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700199 case $UNIT in
200 s|S)
David Bainbridged18f4942020-04-14 16:46:13 -0700201 RESULT=$((RESULT + VALUE)) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700202 m|M)
David Bainbridged18f4942020-04-14 16:46:13 -0700203 RESULT=$((RESULT + (VALUE * 60))) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700204 h|H)
David Bainbridged18f4942020-04-14 16:46:13 -0700205 RESULT=$((RESULT + (VALUE * 3600))) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700206 d|D)
David Bainbridged18f4942020-04-14 16:46:13 -0700207 RESULT=$((RESULT + (VALUE * 86400))) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700208 *) ;;
209 esac
210 done
211 echo $RESULT
212}
213
214function doTimeout() {
215 local MSG=$1
216 2>&1 echo -e "\n${RED}${BOLD}${ERROR}TIMEOUT:${NORMAL}${RED} Operation timed out after '$WAIT_TIMEOUT': $MSG"
217 exit 125
218}
219
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800220function get_service_ep() {
221 local NS=$1
222 local NAME=$2
David Bainbridged18f4942020-04-14 16:46:13 -0700223 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 -0800224}
225
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000226# Used to verify configuration values are set to "yes" or "no" value or convert
227# equivalents to "yes" or "no"
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700228YES="y,yes,t,true,1"
229NO="n,no,f,false,0"
230YES_OR_NO="$YES,$NO"
231
232# If the given VAR matches a truth value then normalize that
233# value, else return original value
234function normalize_yes_no() {
235 local VAR VAL
236 VAR=$1
237 VAL="$(eval echo "\$$VAR")"
238 if ! is_in "$VAL" "$YES_OR_NO"; then
239 echo "$VAL"
240 return 1
241 fi
242 if is_in "$VAL" "$YES"; then
243 echo "yes"
244 else
245 echo "no"
246 fi
247 return 0
248}
249
250# If the given VAR matches a truth value then normalize that
251# value, else display an error
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000252function verify_yes_no() {
David Bainbridged18f4942020-04-14 16:46:13 -0700253 local VAR VAL
254 VAR=$1
255 VAL="$(eval echo "\$$VAR")"
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700256 if ! is_in "$VAL" "$YES_OR_NO"; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000257 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid '$VAR' value of '$VAL'. Should be 'yes' or 'no'${NORMAL}"
258 echo "INVALID"
259 return 1
260 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700261 if is_in "$VAL" "$YES"; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000262 echo "yes"
263 else
264 echo "no"
265 fi
266 return 0
267}
Test User7d866122019-07-09 17:52:35 +0000268
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000269ALL_YES_NO="\
David K. Bainbridge484d80c2020-03-05 21:44:34 -0800270 ENABLE_ONOS_EXTRANEOUS_RULES \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000271 WITH_TIMINGS \
272 WITH_BBSIM \
divyadesai59f987a2020-05-27 12:11:33 +0000273 WITH_EFK \
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800274 WITH_EAPOL \
275 WITH_DHCP \
276 WITH_IGMP \
David Bainbridge99ac7a22019-08-31 02:26:43 +0000277 WITH_CHAOS \
David Bainbridge46505fb2019-10-01 21:13:20 +0000278 WITH_ADAPTERS \
279 WITH_SIM_ADAPTERS \
280 WITH_OPEN_ADAPTERS \
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800281 WITH_PORT_FORWARDS \
Matteo Scandoloefee0432020-05-05 13:56:20 -0700282 WITH_PPROF \
Girish Gowdra4cc5d8b2020-06-11 17:12:00 -0700283 WITH_INCREMENTAL_EVTO_UPDATE \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000284 JUST_K8S \
285 DEPLOY_K8S \
286 INSTALL_ONOS_APPS \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000287 INSTALL_KUBECTL \
288 INSTALL_HELM \
David Bainbridge7f8bf992020-04-08 21:53:22 -0700289 HELM_USE_UPGRADE \
David Bainbridge46505fb2019-10-01 21:13:20 +0000290 UPDATE_HELM_REPOS \
David Bainbridge4f1b5562019-08-19 04:46:52 +0000291 WAIT_ON_DOWN \
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700292 VOLTHA_DOWN_ON_TIMEOUT \
Matteo Scandoloc2eb0672020-05-01 14:43:15 -0700293 LEGACY_BBSIM_INDEX \
David Bainbridgee4d11ca2020-05-08 10:21:10 -0700294 SCHEDULE_ON_CONTROL_NODES \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000295 "
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000296
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700297OPT_YES_NO="\
298 CONFIG_SADIS \
299 WITH_KAFKA \
300 WITH_RADIUS \
301 WITH_ETCD \
302 WITH_ONOS \
303 "
304
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000305ALL_OPTIONS="\
306 NAME \
307 TYPE \
308 $ALL_YES_NO \
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700309 $OPT_YES_NO \
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700310 WAIT_TIMEOUT \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000311 VOLTHA_LOG_LEVEL \
312 VOLTHA_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000313 VOLTHA_CHART_VERSION \
314 VOLTHA_BBSIM_CHART \
315 VOLTHA_BBSIM_CHART_VERSION \
David Bainbridge879439b2020-06-12 15:59:35 -0700316 BBSIM_SADIS_SERVER_CHART \
317 BBSIM_SADIS_SERVER_CHART_VERSION \
uottrembd5a20572020-03-06 09:15:01 +0100318 NUM_OF_BBSIM \
divyadesai59f987a2020-05-27 12:11:33 +0000319 ELASTICSEARCH_CHART \
320 ELASTICSEARCH_CHART_VERSION \
321 KIBANA_CHART \
322 KIBANA_CHART_VERSION \
323 FLUENTD_ELASTICSEARCH_CHART \
324 FLUENTD_ELASTICSEARCH_CHART_VERSION \
Matteo Scandolo67335f02020-04-09 11:19:53 -0700325 NUM_OF_OPENONU \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000326 VOLTHA_ADAPTER_SIM_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000327 VOLTHA_ADAPTER_SIM_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000328 VOLTHA_ADAPTER_OPEN_OLT_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000329 VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000330 VOLTHA_ADAPTER_OPEN_ONU_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000331 VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION \
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800332 ONOS_CHART \
Andrea Campanella21323292019-12-18 11:44:19 -0800333 ONOS_CHART_VERSION \
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700334 ONOS_CLASSIC_CHART \
335 ONOS_CLASSIC_CHART_VERSION \
David Bainbridgecf546362020-04-21 23:18:50 -0700336 KAFKA_CHART \
David Bainbridgeb9093522020-04-15 14:32:44 -0700337 KAFKA_CHART_VERSION \
David Bainbridge879439b2020-06-12 15:59:35 -0700338 ETCD_CHART \
339 ETCD_CHART_VERSION \
340 RADIUS_CHART \
341 RADIUS_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000342 ONOS_API_PORT \
343 ONOS_SSH_PORT \
Hardik Windlassb3147602020-03-09 16:59:15 +0530344 SADIS_CFG \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000345 VOLTHA_API_PORT \
346 VOLTHA_SSH_PORT \
347 VOLTHA_ETCD_PORT \
divyadesai59f987a2020-05-27 12:11:33 +0000348 ELASTICSEARCH_PORT \
349 KIBANA_PORT \
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800350 VOLTHA_KAFKA_PORT \
Matteo Scandoloefee0432020-05-05 13:56:20 -0700351 VOLTHA_PPROF_PORT \
352 OPENOLT_PPROF_PORT \
Matteo Scandolo65c35192020-05-13 10:41:21 -0700353 OFAGENT_PPROF_PORT \
David K. Bainbridge8f7f30b2020-01-08 13:06:16 -0800354 VK_RELEASE \
355 KIND_VERSION \
356 VOLTCTL_VERSION \
David Bainbridgea34993d2020-04-01 09:15:42 -0700357 HELM_VERSION \
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700358 NUM_OF_ONOS \
359 NUM_OF_ATOMIX \
David Bainbridge6ca40102020-04-08 11:30:40 -0700360 VOLTHA_NS \
361 ADAPTER_NS \
362 INFRA_NS \
363 BBSIM_NS \
David Bainbridge7db44002020-04-09 12:54:29 -0700364 SADIS_BANDWIDTH_PROFILES \
365 SADIS_SUBSCRIBERS \
David Bainbridgeb4bbde12020-06-25 14:46:36 -0700366 PF_ADDRESS \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000367 "
David Bainbridge01294952019-07-30 19:33:45 +0000368
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000369# Iterate over yes/no configuration options and validate
370for VAR in $ALL_YES_NO; do
David Bainbridged18f4942020-04-14 16:46:13 -0700371 eval "$VAR"="$(verify_yes_no "$VAR")"
372 if [ "$(eval echo "\$$VAR")" == "INVALID" ]; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000373 exit 1;
374 fi
375done
David Bainbridgeb270c202019-07-26 01:44:42 +0000376
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700377# Iterate over optional yes/no configuration options and
378# normalize values if they are truth values
379for VAR in $OPT_YES_NO; do
380 eval "$VAR"="$(normalize_yes_no "$VAR")"
381done
David Bainbridge15f6f232020-03-30 09:15:43 -0700382
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700383# normalize non-truth value options
384if is_in "$WITH_KAFKA" "e,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -0700385 WITH_KAFKA="external"
386fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700387if is_in "$WITH_ETCD" "e,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -0700388 WITH_ETCD="external"
389fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700390if is_in "$WITH_ONOS" "l,legacy"; then
391 WITH_ONOS="legacy"
392elif is_in "$WITH_ONOS" "c,classic"; then
393 WITH_ONOS="classic"
394elif is_in "$WITH_ONOS" "u,m,micro"; then
395 WITH_ONOS="micro"
David Bainbridge29c31cb2020-04-06 09:45:50 -0700396fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700397
398if [ "$WITH_ONOS" == "micro" ]; then
399 >&2 echo -e "${YELLOW}${BOLD}${ERROR}WARNING:${NORMAL}${YELLOW} The value specified as WITH_ONOS, '$WITH_ONOS', is not valid.${NORMAL}"
400 exit 1
David Bainbridge29c31cb2020-04-06 09:45:50 -0700401fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700402
403if is_in "$WITH_ONOS" "yes,classic"; then
404 # there is an extra utility required if we are using ONOS CLASSIC as
405 # the chart for classic specifies images differently
406 EXTRA_TOOLS+=" yq"
David Bainbridge76afd812020-04-06 09:53:52 -0700407fi
David Bainbridge696bc632020-04-05 21:49:37 -0700408
David Bainbridge22db5dd2020-05-26 12:21:21 -0700409if [ "$LEGACY_BBSIM_INDEX" == "no" ]; then
410 BBSIM_SADIS_SVC="bbsim0"
411else
412 BBSIM_SADIS_SVC="bbsim"
413fi
414
415SADIS_SUBSCRIBERS=${SADIS_SUBSCRIBERS:-http://$BBSIM_SADIS_SVC.$VOLTHA_NS.svc:50074/v2/subscribers/%s}
416SADIS_BANDWIDTH_PROFILES=${SADIS_BANDWIDTH_PROFILES:-http://$BBSIM_SADIS_SVC.$VOLTHA_NS.svc:50074/v2/bandwidthprofiles/%s}
417
David Bainbridged18f4942020-04-14 16:46:13 -0700418if [ "$HELM_USE_UPGRADE" == "yes" ]; then
David Bainbridge7f8bf992020-04-08 21:53:22 -0700419 _HELM_DESC="Upgrade/Install"
420else
421 _HELM_DESC="Install"
422fi
423
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800424# Check for prerequiste tools
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700425TOOLS="curl sed jq $EXTRA_TOOLS"
David Bainbridged18f4942020-04-14 16:46:13 -0700426if [ "$DEPLOY_K8S" == "yes" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800427 TOOLS+=" docker"
428fi
429NOT_FOUND=""
430for T in $TOOLS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700431 if [ -z "$(command -v "$T")" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800432 NOT_FOUND+=" $T"
433 fi
434done
435
David Bainbridged18f4942020-04-14 16:46:13 -0700436if [ -n "$NOT_FOUND" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800437 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} The following required tools where not found, please install them:$NOT_FOUND"
438 exit 1
439fi
440
David Bainbridged18f4942020-04-14 16:46:13 -0700441TIMEOUT_SECONDS="$(parseDuration "$WAIT_TIMEOUT")"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700442
David Bainbridge0774b232019-08-02 06:37:19 +0000443mkdir -p .voltha
444touch .voltha/ports
David Bainbridged18f4942020-04-14 16:46:13 -0700445HAVE="$(grep "$NAME" .voltha/ports)"
David Bainbridge0774b232019-08-02 06:37:19 +0000446if [ "$HAVE X" == " X" ]; then
447 # Find free port prefix
448 START=81
449 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700450 if [ "$(grep -c $START .voltha/ports)" -eq 0 ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000451 break
452 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700453 START="$((START + 1))"
David Bainbridge0774b232019-08-02 06:37:19 +0000454 done
David Bainbridged18f4942020-04-14 16:46:13 -0700455 DELTA="$((START - 81))"
David Bainbridgea2595422019-10-22 03:54:28 +0000456 ONOS_API_PORT=${ONOS_API_PORT:-${START}81}
457 ONOS_SSH_PORT=${ONOS_SSH_PORT:-${START}01}
David Bainbridged18f4942020-04-14 16:46:13 -0700458 VOLTHA_API_PORT=${VOLTHA_API_PORT:-5$((55 + DELTA))55}
459 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$((50 + DELTA))22}
460 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$((23 + DELTA))79}
461 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$((90 + DELTA))92}
Matteo Scandoloefee0432020-05-05 13:56:20 -0700462 VOLTHA_PPROF_PORT=${VOLTHA_PPROF_PORT:-$((60 + DELTA))60}
463 OPENOLT_PPROF_PORT=${OPENOLT_PPROF_PORT:-$((60 + DELTA))61}
Matteo Scandolo65c35192020-05-13 10:41:21 -0700464 OFAGENT_PPROF_PORT=${OFAGENT_PPROF_PORT:-$((60 + DELTA))62}
divyadesai59f987a2020-05-27 12:11:33 +0000465 ELASTICSEARCH_PORT=${ELASTICSEARCH_PORT:-$((92 + DELTA))00}
466 KIBANA_PORT=${KIBANA_PORT:-$((56 + DELTA))01}
Test User01ed0642019-07-03 20:17:06 +0000467else
David Bainbridged18f4942020-04-14 16:46:13 -0700468 VALUES="$(echo "$HAVE" | sed -e 's/\s//g' | cut -d= -f2)"
469 ONOS_API_PORT=${ONOS_API_PORT:-$(echo "$VALUES" | cut -d, -f1)}
470 ONOS_SSH_PORT=${ONOS_SSH_PORT:-$(echo "$VALUES" | cut -d, -f2)}
471 VOLTHA_API_PORT=${VOLTHA_API_PORT:-$(echo "$VALUES" | cut -d, -f3)}
472 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$(echo "$VALUES" | cut -d, -f4)}
473 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$(echo "$VALUES" | cut -d, -f5)}
474 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(echo "$VALUES" | cut -d, -f6)}
Matteo Scandoloefee0432020-05-05 13:56:20 -0700475 VOLTHA_PPROF_PORT=${VOLTHA_PPROF_PORT:-$(echo "$VALUES" | cut -d, -f7)}
476 OPENOLT_PPROF_PORT=${OPENOLT_PPROF_PORT:-$(echo "$VALUES" | cut -d, -f8)}
Matteo Scandolo65c35192020-05-13 10:41:21 -0700477 OFAGENT_PPROF_PORT=${OFAGENT_PPROF_PORT:-$(echo "$VALUES" | cut -d, -f9)}
divyadesai59f987a2020-05-27 12:11:33 +0000478 ELASTICSEARCH_PORT=${ELASTICSEARCH_PORT:-$(echo "$VALUES" | cut -d, -f10)}
479 KIBANA_PORT=${KIBANA_PORT:-$(echo "$VALUES" | cut -d, -f11)}
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800480
Matteo Scandoloefee0432020-05-05 13:56:20 -0700481 # Some ports were added after the .voltha/ports files was created.
482 # Calculate the original DELTA from the VOLTHA_SSH_PORT so that it can
483 # be used to set up newer port-forwards.
484 DELTA="$((VOLTHA_SSH_PORT/100-50))"
485
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800486 if [ -z "$VOLTHA_KAFKA_PORT" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -0700487 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$((90 + DELTA))92}
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800488 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -0700489
490 if [ -z "$VOLTHA_PPROF_PORT" ]; then
divyadesai59f987a2020-05-27 12:11:33 +0000491 VOLTHA_PPROF_PORT=${VOLTHA_PPROF_PORT:-$((60 + DELTA))60}
Matteo Scandoloefee0432020-05-05 13:56:20 -0700492 fi
493 if [ -z "$OPENOLT_PPROF_PORT" ]; then
divyadesai59f987a2020-05-27 12:11:33 +0000494 OPENOLT_PPROF_PORT=${OPENOLT_PPROF_PORT:-$((60 + DELTA))61}
Matteo Scandoloefee0432020-05-05 13:56:20 -0700495 fi
Matteo Scandolo65c35192020-05-13 10:41:21 -0700496 if [ -z "$OFAGENT_PPROF_PORT" ]; then
divyadesai59f987a2020-05-27 12:11:33 +0000497 OFAGENT_PPROF_PORT=${OFAGENT_PPROF_PORT:-$((60 + DELTA))62}
498 fi
499
500 if [ -z "$ELASTICSEARCH_PORT" ]; then
501 ELASTICSEARCH_PORT=${ELASTICSEARCH_PORT:-$((92 + DELTA))00}
502 fi
503
504 if [ -z "$KIBANA_PORT" ]; then
505 KIBANA_PORT=${KIBANA_PORT:-$((56 + DELTA))01}
Matteo Scandolo65c35192020-05-13 10:41:21 -0700506 fi
Test User01ed0642019-07-03 20:17:06 +0000507fi
508
David Bainbridged18f4942020-04-14 16:46:13 -0700509PORTTMP="$(mktemp -u)"
510grep -v "$NAME" .voltha/ports > "$PORTTMP"
divyadesai59f987a2020-05-27 12:11:33 +0000511echo "$NAME=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT,$VOLTHA_KAFKA_PORT,$VOLTHA_PPROF_PORT,$OPENOLT_PPROF_PORT,$OFAGENT_PPROF_PORT,$ELASTICSEARCH_PORT,$KIBANA_PORT" >> "$PORTTMP"
David Bainbridged18f4942020-04-14 16:46:13 -0700512cp "$PORTTMP" .voltha/ports
513rm -f "$PORTTMP"
David Bainbridge0774b232019-08-02 06:37:19 +0000514
David Bainbridge27790d62019-08-13 22:43:19 +0000515export ONOS_API_PORT ONOS_SSH_PORT
David Bainbridge01294952019-07-30 19:33:45 +0000516
Test Userd87942b2019-07-03 07:20:24 +0000517IDX=1
David Bainbridgee87067b2019-08-12 22:00:12 +0000518CLOCK="TIME:"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000519SPIN_PARTS=
520NOT_VERIFIED=
David Bainbridgef858a022019-08-14 21:25:11 +0000521THEX=
522BUILD=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000523VERIFIED=
524HELM=
525OLD_KEY=
526BIRD=
527HIGH_VOLTAGE=
528PLUG=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000529FORWARD=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000530GO=
531DOWNLOAD=
532GEAR=
533NO_ENTRY=
534LOCK=
535
David Bainbridged18f4942020-04-14 16:46:13 -0700536if [ "$FANCY" -eq 1 ]; then
537 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 +0000538 CLOCK="\xe2\x8f\xb1"
David Bainbridgef858a022019-08-14 21:25:11 +0000539 THEX="${RED}${BOLD}\xe2\x9c\x97\x20${NORMAL}"
David Bainbridgef858a022019-08-14 21:25:11 +0000540 BUILD="${YELLOW}${BOLD}\xf0\x9f\x8f\x97${NORMAL}"
541 NOT_VERIFIED="$BUILD"
542 VERIFIED="${GREEN}${BOLD}\xe2\x9c\x93\x20${NORMAL}"
543 HELM="${BLUE}${BOLD}\xE2\x8E\x88${NORMAL}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000544 OLD_KEY="\xF0\x9F\x97\x9D"
545 BIRD="\xF0\x9F\x90\xA6"
546 HIGH_VOLTAGE="\xE2\x9A\xA1"
547 PLUG="\xF0\x9F\xa7\xa9"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000548 FORWARD="\xE2\x87\xA8"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000549 GO="\xf0\x9f\x9a\x80"
550 DOWNLOAD="\xf0\x9f\x93\xa5"
551 GEAR="\xe2\x9a\x99"
552 NO_ENTRY="\xe2\x9b\x94"
553 LOCK="\xf0\x9f\x94\x92"
554fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700555
David Bainbridge712afb82019-08-14 19:55:58 +0000556duration() {
David Bainbridged18f4942020-04-14 16:46:13 -0700557 local h m s t
558 h="$(($1 / 3600))"
559 m="$(($1 % 3600 / 60))"
560 s="$(($1 % 60))"
561 t=""
David Bainbridgee87067b2019-08-12 22:00:12 +0000562
David Bainbridged18f4942020-04-14 16:46:13 -0700563 if [ "$h" -gt 0 ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +0000564 t="$t${h}h"
565 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700566 if [ "$m" -gt 0 ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +0000567 t="$t${m}m"
568 fi
David Bainbridge712afb82019-08-14 19:55:58 +0000569 echo "$t${s}s"
570}
571
572printtime() {
David Bainbridged18f4942020-04-14 16:46:13 -0700573 local INDENT
David Bainbridge712afb82019-08-14 19:55:58 +0000574 if [ "$1" == "-" ]; then
575 INDENT=" "
576 shift
577 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700578 echo -e "$INDENT $CLOCK $(duration "$1")"
David Bainbridgee87067b2019-08-12 22:00:12 +0000579}
580
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700581bspin() {
Test Userd87942b2019-07-03 07:20:24 +0000582 IDX=1
David Bainbridged18f4942020-04-14 16:46:13 -0700583 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700584 if [ "$1" == "-" ]; then
585 INDENT=" "
586 shift
587 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700588 if [ "$FANCY" -eq 0 ]; then
589 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000590 if [ "$LINE X" == " X" ]; then
591 return
592 fi
593 echo -e "$CIVIS$INDENT$*"
594 else
595 echo -en "$CIVIS$INDENT $*"
596 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700597}
598
599sspin() {
David Bainbridged18f4942020-04-14 16:46:13 -0700600 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700601 if [ "$1" == "-" ]; then
602 INDENT=" "
603 shift
604 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700605 if [ "$FANCY" -eq 0 ]; then
606 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000607 if [ "$LINE X" == " X" ]; then
608 return
609 fi
610 echo -e "$INDENT$*"
611 else
David Bainbridged18f4942020-04-14 16:46:13 -0700612 C="$(echo "$SPIN_PARTS" | cut '-d ' -f "$IDX")"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000613 echo -en "\r$INDENT$C $*"
David Bainbridged18f4942020-04-14 16:46:13 -0700614 IDX="$((IDX + 1))"
615 if [ "$IDX" -gt 8 ]; then
David Bainbridge38dc1e82019-08-12 15:18:45 +0000616 IDX=1
617 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700618 fi
619}
620
621espin() {
David Bainbridged18f4942020-04-14 16:46:13 -0700622 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700623 if [ "$1" == "-" ]; then
624 INDENT=" "
625 shift
626 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700627 if [ "$FANCY" -eq 0 ]; then
628 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000629 if [ "$LINE X" == " X" ]; then
630 return
631 fi
632 echo -e "$INDENT$*"
633 else
634 echo -e "\r$INDENT$*$CNORM"
635 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700636}
637
David Bainbridged18f4942020-04-14 16:46:13 -0700638if [ "$1" == "get" ] && [ "$2" == "voltconfig" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000639 echo "$HOME/.volt/config-$NAME"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000640 exit
641fi
642
David Bainbridgee4d11ca2020-05-08 10:21:10 -0700643if [ $# -ne 1 ] || ! is_in "$1" "up,down,dump,clean"; then
David Bainbridgeac7f8072019-08-01 22:15:33 +0000644 >&2 echo "What wouild you like to do today:"
645 >&2 echo " up - bring up voltha"
646 >&2 echo " down - tear down voltha"
647 >&2 echo " dump - create a debug dump of running system"
648 exit 1
649fi
650
divyadesai59f987a2020-05-27 12:11:33 +0000651do_curl() {
652 local DATA_ARGS CREDS CMD_ECHO CMD_OUTPUT SC_OUTPUT WAIT_START INDENTA EXTRAA NOW
653 local INDENT=$1
654 local OP=$2
655 local USER=$3
656 local PASS=$4
657 local URL=$5
658 local DATA_TYPE=$6
659 local DATA=$7
660 local MSG=$8
661 local VALID_RESULTS=$9
662 local EXTRA=${10}
663 local ICON=${11}
664
665 # Turn into an array for passing
666 INDENTA=()
667 if [ -n "$INDENT" ]; then
668 INDENTA=("$INDENT")
669 fi
670 IFS=' ' read -r -a EXTRAA <<< "$EXTRA"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000671
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800672 # Thanks to the latest version of ONOS using the return code 207 this gets a
673 # whole lot nastier. Can't thank them enough for doing this. So in order to
674 # capture the command and the output in the log file as well as capture the
675 # status code to verify it is 200 and not 207 mutltiple files and a bit of
676 # hackery must be used. Thanks again ONOS.
David Bainbridged18f4942020-04-14 16:46:13 -0700677 CMD_ECHO="$(mktemp -u)"
678 CMD_OUTPUT="$(mktemp -u)"
679 SC_OUTPUT="$(mktemp -u)"
680 WAIT_START="$(date +%s)"
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800681
divyadesai59f987a2020-05-27 12:11:33 +0000682 CREDS=()
683 if [ -n "$USER" ]; then
684 CREDS=("--user" "$USER:$PASS")
685 fi
686
687 DATA_ARGS=()
688 if [ -n "$DATA" ]; then
689 if [ "$DATA_TYPE" == "file" ]; then
690 DATA_ARGS=("--data" "@$DATA")
691 elif [ "$DATA_TYPE" == "json" ]; then
692 DATA_ARGS=("--data" "$DATA")
693 fi
694 fi
695
696 bspin "${INDENTA[@]}" "$MSG" "$ICON"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000697 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700698 NOW="$(date +%s)"
699 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
divyadesai59f987a2020-05-27 12:11:33 +0000700 espin "${INDENTA[@]}" "$THEX"
David Bainbridged18f4942020-04-14 16:46:13 -0700701 rm -f "$CMD_ECHO" "$CMD_OUTPUT" "$SC_OUTPUT"
divyadesai59f987a2020-05-27 12:11:33 +0000702 doTimeout "$MSG"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700703 fi
divyadesai59f987a2020-05-27 12:11:33 +0000704 (set -x; curl -sSL "${CREDS[@]}" -w "%{http_code}" -o "$CMD_OUTPUT" -X "$OP" "${EXTRAA[@]}" "$URL" "${DATA_ARGS[@]}" >"$SC_OUTPUT" 2>/dev/null) >>"$CMD_ECHO" 2>&1
705 RESULT=$?
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800706 # Dump everything to the log
David Bainbridged18f4942020-04-14 16:46:13 -0700707 cat "$CMD_ECHO" >> "$LOG"
708 test -r "$CMD_OUTPUT" && cat "$CMD_OUTPUT" >> "$LOG"
709 SC="$(cat "$SC_OUTPUT")"
710 echo "RESPONSE CODE: $SC" >> "$LOG"
711 echo "ERROR CODE: $RESULT" >> "$LOG"
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800712
713 # clean up temp files
David Bainbridged18f4942020-04-14 16:46:13 -0700714 rm -f "$CMD_ECHO" "$CMD_OUTPUT" "$SC_OUTPUT"
divyadesai59f987a2020-05-27 12:11:33 +0000715 if [ "$RESULT" -eq 0 ] && is_in "$SC" "$VALID_RESULTS"; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000716 break
717 fi
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800718 sleep 1
divyadesai59f987a2020-05-27 12:11:33 +0000719 sspin "${INDENTA[@]}"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000720 done
divyadesai59f987a2020-05-27 12:11:33 +0000721 espin "${INDENTA[@]}" "$VERIFIED"
722}
723
724push_onos_config() {
725 local DATA_TYPE=$1
726 local MSG=$2
727 local RESOURCE=$3
728 local DATA=$4
729
730 do_curl "-" "POST" "karaf" "karaf" "http://$_ONOS_API_EP/onos/v1/$RESOURCE" "$DATA_TYPE" "$DATA" "$MSG" "200" "--fail -H Content-Type:application/json" "$GEAR"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000731}
732
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800733check_onos_app_active() {
David Bainbridged18f4942020-04-14 16:46:13 -0700734 local APP_ID WAIT_START RESULT NOW
735 APP_ID=$1
736 WAIT_START="$(date +%s)"
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800737
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700738 bspin - "Checking that $APP_ID is active $CLOCK"
739 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700740 NOW="$(date +%s)"
741 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700742 espin - "$THEX"
743 doTimeout "waiting for ONOS application activation '$APP_ID'"
744 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700745 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 -0700746 break
747 fi
748 sleep 1
749 sspin -
750 done
751 sleep 5 # OSGI components take a little longer that the app to activate
David Bainbridged18f4942020-04-14 16:46:13 -0700752 espin - "$VERIFIED"
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800753}
754
David Bainbridge4f1b5562019-08-19 04:46:52 +0000755override_onos_app() {
David Bainbridged18f4942020-04-14 16:46:13 -0700756 local APP NAME WAIT_START NOW
757 APP=$1
758 NAME="$(basename "$APP" | sed -e 's/^[0-9][0-9]*-//g' -e 's/-.*$//g')"
759 WAIT_START="$(date +%s)"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700760
David Bainbridge4f1b5562019-08-19 04:46:52 +0000761 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700762 NOW="$(date +%s)"
763 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700764 espin - "$THEX"
765 doTimeout "waiting to overwrite ONOS application '$APP'"
766 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +0000767 sspin -
768 # Attempt to delete old version (if it exists)
David Bainbridged18f4942020-04-14 16:46:13 -0700769 (set -x; curl --fail -sSL --user karaf:karaf -X DELETE "http://$_ONOS_API_EP/onos/v1/applications/$NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
770 RESULT=$?
David Bainbridge4f1b5562019-08-19 04:46:52 +0000771 sspin -
David Bainbridged18f4942020-04-14 16:46:13 -0700772 if [ $RESULT -ne 0 ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000773 continue
774 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700775 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 +0000776 break
777 fi
778 sleep .2
779 done
780}
781
782activate_onos_app() {
David Bainbridged18f4942020-04-14 16:46:13 -0700783 local MSG APP WAIT_START NOW
784 MSG="$1"
785 APP=$2
786 WAIT_START="$(date +%s)"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000787
788 bspin - "$MSG $GO"
789 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700790 NOW="$(date +%s)"
791 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700792 espin - "$THEX"
793 doTimeout "waiting to activate ONOS application '$APP'"
794 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +0000795 sspin -
David Bainbridged18f4942020-04-14 16:46:13 -0700796 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 +0000797 break
798 fi
799 sleep .2
800 done
801 espin - "$VERIFIED"
802}
803
804count_pods() {
David Bainbridged18f4942020-04-14 16:46:13 -0700805 local NAMESPACE STATES LABELS CMD PODS
806 NAMESPACE=$1; shift
David Bainbridge4f1b5562019-08-19 04:46:52 +0000807 if [ "$NAMESPACE" == "all-namespaces" ]; then
808 NAMESPACE="--all-namespaces"
809 else
810 NAMESPACE="-n $NAMESPACE"
811 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700812 STATES=$1; shift
813 LABELS=$1; shift
814 CMD=("kubectl get $NAMESPACE $LABELS pod")
815 PODS=$(${CMD[*]} -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}")
David Bainbridge4f1b5562019-08-19 04:46:52 +0000816 local COUNT=0
817 local PATTERNS="$*"
818 for POD in $PODS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700819 local NAME STATE CONTAINERS TOTAL FOUND
820 NAME="$(echo "$POD" | cut -d/ -f 1)"
821 STATE="$(echo "$POD" | cut -d/ -f 2)"
822 CONTAINERS="$(echo "$POD" | cut -d/ -f 3 | sed -e 's/_/ /g')"
823 if [ "$STATES" == "*" ] || [ "$(echo "$STATES" | grep -c ":$STATE:")" -ne 0 ]; then
824 TOTAL="$(echo "$CONTAINERS" | wc -w)"
825 FOUND="$(echo "$CONTAINERS" | grep -o true | wc -l)"
826 if [ "$TOTAL" -eq "$FOUND" ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000827 for PATTERN in $PATTERNS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700828 if [[ "$NAME" =~ $PATTERN ]]; then
829 COUNT="$((COUNT + 1))"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000830 break
831 fi
832 done
833 fi
834 fi
835 done
David Bainbridge4f1b5562019-08-19 04:46:52 +0000836 echo $COUNT
837}
838
839wait_for_pods() {
David Bainbridged18f4942020-04-14 16:46:13 -0700840 local INDENT NAMESPACE EXPECT TYPE MESSAGE LABELS PATTERNS STATES HAVE ALL WAIT_START NOW
David Bainbridge4f1b5562019-08-19 04:46:52 +0000841 if [ "$1" == "-" ]; then
842 INDENT=$1; shift
843 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700844 NAMESPACE=$1; shift
845 EXPECT=$1; shift
846 TYPE=$1; shift
847 MESSAGE=$1; shift
848 LABELS=$1; shift
849 PATTERNS=("$*")
850 STATES=":Running:"
David Bainbridge99ac7a22019-08-31 02:26:43 +0000851 if [ "$TYPE" == "not" ]; then
852 STATES="*"
853 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700854 HAVE="$(count_pods "$NAMESPACE" "$STATES" "$LABELS" "${PATTERNS[@]}")"
855 ALL=$HAVE
David Bainbridge4f1b5562019-08-19 04:46:52 +0000856 if [ "$TYPE" == "only" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -0700857 ALL="$(count_pods "all-namespaces" "*" ".*")"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000858 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700859 COUNT="$((300 / 15))"
860 WAIT_START="$(date +%s)"
861 bspin "$INDENT" "$MESSAGE"
862 sspin "$INDENT"
863 if [ "$HAVE" -ne "$EXPECT" ] || [ "$ALL" -ne "$HAVE" ]; then
864 while [ "$HAVE" -ne "$EXPECT" ] || [ "$ALL" -ne "$HAVE" ]; do
865 NOW="$(date +%s)"
866 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
867 espin "$INDENT" "$THEX"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700868 doTimeout "waiting for PODs to start"
869 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700870 sspin "$INDENT"
871 COUNT="$((COUNT - 1))"
872 if [ "$COUNT" -eq 0 ]; then
873 HAVE="$(count_pods "$NAMESPACE" "$STATES" "$LABELS" "${PATTERNS[@]}")"
874 ALL="$HAVE"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000875 if [ "$TYPE" == "only" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -0700876 ALL="$(count_pods "all-namespaces" "*" ".*")"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000877 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700878 COUNT="$((300 / 15))"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000879 fi
880 sleep .15
881 done
882 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700883 espin "$INDENT" "$VERIFIED"
884 if [ "$HAVE" -ne "$EXPECT" ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000885 return 1
886 fi
887 return 0
888}
889
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800890port_forward() {
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700891 local NS=$1; shift
892 local SVC=$1; shift
893 local PORTS="$*"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800894 local TAG=$SVC-$NAME
895
David Bainbridgeb4bbde12020-06-25 14:46:36 -0700896 (set -x; _TAG="$TAG" bash -c "while true; do kubectl port-forward --address $PF_ADDRESS -n $NS service/$SVC $PORTS; done" >>"$PFLOG" 2>&1 &) >>"$PFLOG" 2>&1
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800897}
898
899kill_port_forward() {
David Bainbridge1d2c5842020-06-03 15:29:07 -0700900 local TAG P_IDS PARENTS KIDS UNKNOWN PP_ID PF
901
902 while [ $# -gt 0 ]; do
903 PF=$1; shift
904 TAG=
905 if [ "$PF" != "__ALL__" ]; then
906 TAG="$PF-$NAME"
907 fi
908 PARENTS=
909 KIDS=
910 UNKNOWN=
911 # shellcheck disable=SC2009
912 P_IDS="$(ps e -ww -A | grep "_TAG=$TAG" | grep -v grep | awk '{print $1}')"
913 if [ -n "$P_IDS" ]; then
914 for P_ID in $P_IDS; do
915 PP_ID="$(ps -o ppid "$P_ID" | tail -n +2)"
916 if [ -n "$PP_ID" ]; then
917 if [ "$PP_ID" -eq 1 ]; then
918 PARENTS="$PARENTS $P_ID"
919 else
920 KIDS="$KIDS $P_ID"
921 fi
David Bainbridgec6871d22019-11-13 17:10:31 +0000922 else
David Bainbridge1d2c5842020-06-03 15:29:07 -0700923 UNKNOWN="$UNKNOWN $P_ID"
David Bainbridgec6871d22019-11-13 17:10:31 +0000924 fi
David Bainbridge1d2c5842020-06-03 15:29:07 -0700925 done
926 if [ -n "$PARENTS" ]; then
927 # shellcheck disable=SC2086
928 while ps -h $PARENTS >/dev/null 2>&1; do
929 (set -x; eval "kill -9 $PARENTS" >>"$LOG" 2>&1) >>"$LOG" 2>&1
930 done
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800931 fi
David Bainbridge1d2c5842020-06-03 15:29:07 -0700932 if [ -n "$KIDS" ]; then
933 # shellcheck disable=SC2086
934 while ps -h $KIDS >/dev/null 2>&1; do
935 (set -x; eval "kill -9 $KIDS" >>"$LOG" 2>&1) >>"$LOG" 2>&1
936 done
937 fi
938 if [ -n "$UNKNOWN" ]; then
939 # shellcheck disable=SC2086
940 while ps -h $UNKNOWN >/dev/null 2>&1; do
941 (set -x; eval "kill -9 $UNKNOWN" >>"$LOG" 2>&1) >>"$LOG" 2>&1
942 done
943 fi
944 fi
945 done
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800946}
947
David Bainbridgecf546362020-04-21 23:18:50 -0700948resolve_chart_version() {
949 [ "$2" != "latest" ] && echo "$2" && return
950 helm inspect chart "$1" | grep "^version:" | awk '{print $2}'
951}
952
Jonathan Hart6a91e6c2020-04-16 14:28:33 -0700953# Compares two semver-formatted version strings (e.g. 2.4.3)
954# Returns 0 if $1 == $2, returns 1 if $1 > $2 and returns 2 if $1 < $2
955compare_versions() {
956 [ "$1" == "$2" ] && return 0
Jonathan Hart6a91e6c2020-04-16 14:28:33 -0700957 local lowest
958 lowest=$(echo -e "$1\n$2" | sort -V | head -1)
959 [ "$lowest" == "$1" ] && return 2
960 return 1
961}
962
David Bainbridgeac7f8072019-08-01 22:15:33 +0000963if [ "$1" == "down" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000964 echo "Tearing down voltha cluster $NAME"
965 LOG="down-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -0700966 date -u +"%Y%m%dT%H%M%SZ" >"$LOG"
David Bainbridgeb4bbde12020-06-25 14:46:36 -0700967 HELM_MAJOR=$(helm version --client --short | sed -E -e 's/^.*v([0-9]+)\.[0-9]+\.[0-9]+.*$/\1/')
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700968 if is_in "$WITH_ONOS" "yes,legacy,classic"; then
David Bainbridge696bc632020-04-05 21:49:37 -0700969 bspin "Remove port-forwards: onos-ui-$NAME"
970 kill_port_forward onos-ui
971 sspin "Remove port-forwards: onos-ssh-$NAME$CEOL"
972 kill_port_forward onos-ssh
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700973 bspin "Remove port-forwards: onos-onos-classic-hs-$NAME$CEOL"
974 kill_port_forward onos-onos-classic-hs
David Bainbridge696bc632020-04-05 21:49:37 -0700975 fi
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800976 sspin "Remove port-forwards: voltha-api-$NAME$CEOL"
David Bainbridge1d2c5842020-06-03 15:29:07 -0700977 kill_port_forward voltha-api voltha-voltha-api
David Bainbridgec7220622020-05-28 12:31:47 -0700978 if is_in "$WITH_ETCD" "yes,external"; then
979 sspin "Remove port-forwards: etcd-$NAME$CEOL"
980 kill_port_forward "etcd"
David Bainbridge696bc632020-04-05 21:49:37 -0700981 fi
David Bainbridgec7220622020-05-28 12:31:47 -0700982 if is_in "$WITH_KAFKA" "yes,external"; then
983 sspin "Remove port-forwards: kafka-$NAME$CEOL"
984 kill_port_forward "kafka"
David Bainbridge696bc632020-04-05 21:49:37 -0700985 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -0700986
987 if [ "$WITH_PPROF" == "yes" ]; then
David Bainbridgec7220622020-05-28 12:31:47 -0700988 sspin "Remove port-forwards: *-profiler$CEOL"
David Bainbridge1d2c5842020-06-03 15:29:07 -0700989 kill_port_forward voltha-rw-core-profiler voltha-voltha-rw-core-profiler
990 kill_port_forward voltha-of-agent-profiler voltha-voltha-of-agent-profiler
David Bainbridgec7220622020-05-28 12:31:47 -0700991 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
David Bainbridge1d2c5842020-06-03 15:29:07 -0700992 kill_port_forward adapter-open-olt-profiler open-olt-adapter-open-olt-profiler
David Bainbridgec7220622020-05-28 12:31:47 -0700993 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -0700994 fi
995
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800996 espin "$VERIFIED Remove port-forwards$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -0700997 if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridgeac7f8072019-08-01 22:15:33 +0000998 if [ -x ./bin/kind ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000999 bspin "Delete Kubernetes Kind Cluster"
David Bainbridged18f4942020-04-14 16:46:13 -07001000 (set -x; ./bin/kind delete cluster --name "voltha-$NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1001 espin "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001002 else
David Bainbridge0774b232019-08-02 06:37:19 +00001003 espin "$NO_ENTRY Delete Kubernetes Kind Cluster: kind command not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001004 fi
1005 else
David Bainbridge309099c2020-05-05 08:47:29 -07001006 if [ "$CONFIG_SADIS" == "external" ]; then
1007 bspin "Remove configmap for BBSIM SADIS server"
1008 (set -x; kubectl -n "$BBSIM_NS" delete --ignore-not-found configmap kube-config >>"$LOG" 2>&1) >>"$LOG" 2>&1
1009 espin "$VERIFIED"
1010 fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001011
1012 if [ "$HELM_MAJOR" -le 2 ]; then
1013 EXISTS=$(helm list --output json 2>/dev/null | jq -r '.Releases | .[] | .Name + "," + .Namespace')
1014 else
1015 EXISTS=$(helm list --all-namespaces --output json 2>/dev/null | jq -r '.[] | .name + "," + .namespace')
1016 fi
David Bainbridge76afd812020-04-06 09:53:52 -07001017 EXPECT="voltha"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001018 if is_in "$WITH_ONOS" "yes,legacy,classic"; then
David Bainbridge696bc632020-04-05 21:49:37 -07001019 EXPECT+=" onos"
1020 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001021 if [ "$WITH_RADIUS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001022 EXPECT+=" radius"
1023 fi
David Bainbridge309099c2020-05-05 08:47:29 -07001024 if [ "$CONFIG_SADIS" == "external" ]; then
1025 EXPECT+=" bbsim-sadis-server"
1026 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001027 if [ "$WITH_BBSIM" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001028 EXPECT+=" bbsim"
1029 fi
divyadesai59f987a2020-05-27 12:11:33 +00001030 if [ "$WITH_EFK" == "yes" ]; then
1031 EXPECT+=" elasticsearch kibana fluentd"
1032 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001033 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001034 EXPECT+=" open-olt open-onu"
1035 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001036 if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001037 EXPECT+=" sim"
1038 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001039 if is_in "$WITH_ETCD" "yes,external"; then
1040 EXPECT+=" etcd"
David Bainbridge76afd812020-04-06 09:53:52 -07001041 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001042 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -07001043 EXPECT+=" kafka"
1044 fi
David Bainbridge0774b232019-08-02 06:37:19 +00001045 bspin "Remove Helm Deployments"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001046 for i in $EXISTS; do
David K. Bainbridge43422402020-03-06 07:41:22 -08001047 for j in $EXPECT; do
David Bainbridged18f4942020-04-14 16:46:13 -07001048 if [[ "$i" =~ $j ]]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001049 __NAME=$(echo "$i" | cut -d, -f1)
1050 __NS=$(echo "$i" | cut -d, -f2)
1051 sspin "Remove Helm Deployments: $__NS:$__NAME$CEOL"
1052 if [ "$HELM_MAJOR" -le 2 ]; then
1053 (set -x; helm delete --no-hooks --purge "$__NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1054 else
1055 (set -x; helm uninstall --no-hooks --namespace "$__NS" "$__NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1056 fi
David K. Bainbridge43422402020-03-06 07:41:22 -08001057 fi
1058 done
uottrembb16d3982020-02-28 08:34:36 +01001059 done
David Bainbridge0774b232019-08-02 06:37:19 +00001060 espin "$VERIFIED Remove Helm Deployments$CEOL"
David Bainbridge4f1b5562019-08-19 04:46:52 +00001061 if [ "$WAIT_ON_DOWN" == "yes" ]; then
Matteo Scandoloe93c9eb2020-06-03 12:08:51 -07001062 PODS="voltha-ofagent.* voltha-rw-core.*"
David Bainbridge76afd812020-04-06 09:53:52 -07001063 INFRA_PODS=
1064 ADAPT_PODS=
1065 SIM_PODS=
divyadesai59f987a2020-05-27 12:11:33 +00001066 EFK_PODS=
David Bainbridged18f4942020-04-14 16:46:13 -07001067 if [ "$WITH_RADIUS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001068 PODS+=" radius.*"
1069 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001070 if [ "$WITH_BBSIM" == "yes" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -07001071 SIM_PODS+=" bbsim.*"
David Bainbridge696bc632020-04-05 21:49:37 -07001072 fi
divyadesai59f987a2020-05-27 12:11:33 +00001073 if [ "$WITH_EFK" == "yes" ]; then
1074 EFK_PODS+=" kibana-* elasticsearch-* fluentd-*"
1075 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001076 if [ "$WITH_OPEN_ADAPTERS" ] || [ "$WITH_SIM_ADAPTERS" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -07001077 ADAPT_PODS+=" adapter-*"
David Bainbridge696bc632020-04-05 21:49:37 -07001078 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001079 if is_in "$WITH_ONOS" "yes,legacy,classic"; then
David Bainbridge76afd812020-04-06 09:53:52 -07001080 INFRA_PODS+=" onos-.*"
1081 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001082 if is_in "$WITH_ETCD" "yes,external"; then
1083 INFRA_PODS+=" etcd.*"
David Bainbridge76afd812020-04-06 09:53:52 -07001084 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001085 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -07001086 INFRA_PODS+=" kafka.*"
1087 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001088 if [ -n "$SIM_PODS" ]; then
1089 wait_for_pods "$BBSIM_NS" 0 "not" "Waiting for BBSIM PODs to terminate" "$BBSIM_LABEL" "$SIM_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -07001090 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001091 if [ -n "$INFRA_PODS" ]; then
1092 wait_for_pods "$INFRA_NS" 0 "not" "Waiting for infrastructure PODs to terminate" "$NO_LABEL" "$INFRA_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -07001093 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001094 if [ -n "$ADAPT_PODS" ]; then
1095 wait_for_pods "$ADAPTER_NS" 0 "not" "Waiting for adapter PODs to terminate" "$NO_LABEL" "$ADAPT_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -07001096 fi
divyadesai59f987a2020-05-27 12:11:33 +00001097 if [ -n "$EFK_PODS" ]; then
1098 wait_for_pods "$INFRA_NS" 0 "not" "Waiting for EFK PODs to terminate" "$NO_LABEL" "$EFK_PODS"
1099 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001100 wait_for_pods "$VOLTHA_NS" 0 "not" "Waiting for VOLTHA PODs to terminate" "$NO_LABEL" "$PODS"
David Bainbridge4f1b5562019-08-19 04:46:52 +00001101 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +00001102 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001103 exit
David Bainbridgeac7f8072019-08-01 22:15:33 +00001104fi
1105
1106if [ "$1" == "dump" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001107 LOG="dump-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -07001108 TS="$(date -u +"%Y%m%dT%H%M%SZ")"
1109 if [ -n "$DUMP_FROM" ]; then
1110 TS=${DUMP_FROM//[:-]}
David Bainbridge76514a02019-10-08 01:50:35 +00001111 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001112 WORK="$(mktemp -u -d)"
David Bainbridge0774b232019-08-02 06:37:19 +00001113 DATA=$WORK/voltha-debug-dump-$NAME-$TS
David Bainbridged18f4942020-04-14 16:46:13 -07001114 mkdir -p "$DATA"
1115 echo "$TS" > "$LOG"
David Bainbridge0774b232019-08-02 06:37:19 +00001116 echo -e "Capturing debug dump to voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001117 bspin - "Copy install log"
David Bainbridged18f4942020-04-14 16:46:13 -07001118 if [ -f "install-$NAME.log" ]; then
1119 (set -x; cp "install-$NAME.log" "$DATA/install-$NAME.log") >>"$LOG" 2>&1
1120 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001121 else
David Bainbridge0774b232019-08-02 06:37:19 +00001122 espin - "$NO_ENTRY Copy install log: install-$NAME.log not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001123 fi
1124 bspin - "Dumping Kubernetes PODs"
David Bainbridged18f4942020-04-14 16:46:13 -07001125 (set -x; kubectl get --all-namespaces pods >> "$DATA/all-pods.txt" 2>&1) >>"$LOG" 2>&1
1126 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001127 bspin - "Dumping Kubernetes SERVICEs"
David Bainbridged18f4942020-04-14 16:46:13 -07001128 (set -x; kubectl get --all-namespaces svc >> "$DATA/all-services.txt" 2>&1) >>"$LOG" 2>&1
1129 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001130 bspin - "Dumping Kubernetes EVENTs"
David Bainbridged18f4942020-04-14 16:46:13 -07001131 (set -x; kubectl get --all-namespaces events >> "$DATA/all-events.txt" 2>&1) >>"$LOG" 2>&1
1132 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001133 bspin - "Dumping VOLTHA POD details"
David Bainbridged18f4942020-04-14 16:46:13 -07001134 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 +00001135 SINCE=
David Bainbridged18f4942020-04-14 16:46:13 -07001136 if [ -n "$DUMP_FROM" ]; then
David Bainbridgecfd7ca12019-10-06 03:31:41 +00001137 SINCE="--since-time=$DUMP_FROM"
1138 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +00001139 for POD in $PODS; do
David Bainbridged18f4942020-04-14 16:46:13 -07001140 NS="$(echo "$POD" | cut -d: -f1)"
1141 POD="$(echo "$POD" | cut -d: -f2)"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001142 sspin - "Dumping VOLTHA POD details: $POD$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -07001143 mkdir -p "$DATA/$POD"
1144 (set -x; kubectl describe -n "$NS" "$POD" >> "$DATA/$POD/describe.txt" 2>&1) >>"$LOG" 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +00001145 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridged18f4942020-04-14 16:46:13 -07001146 (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 +00001147 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridged18f4942020-04-14 16:46:13 -07001148 (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 +00001149 sspin - "Dumping VOLTHA POD details: $POD"
1150 done
1151 espin - "$VERIFIED Dumping VOLTHA POD details$CEOL"
1152 bspin - "Dumping ETCD"
David Bainbridged18f4942020-04-14 16:46:13 -07001153 if [ -n "$(command -v etcdctl)" ]; then
1154 (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
1155 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001156 else
1157 espin - "$NO_ENTRY Dumping ETCD: etcdctl command not available"
1158 fi
David Bainbridge0774b232019-08-02 06:37:19 +00001159 bspin - "Creating compressed TAR: voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridged18f4942020-04-14 16:46:13 -07001160 (set -x; tar -C "$WORK" -zcf "voltha-debug-dump-$NAME-$TS.tgz" "./voltha-debug-dump-$NAME-$TS") >>"$LOG" 2>&1
1161 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001162 bspin - "Cleanup"
David Bainbridged18f4942020-04-14 16:46:13 -07001163 (set -x; rm -rf "$WORK") >>"$LOG" 2>&1
1164 espin - "$VERIFIED"
1165 bspin - "$(ls -l "voltha-debug-dump-$NAME-$TS.tgz")"
1166 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001167 exit
1168fi
1169
David Bainbridge0774b232019-08-02 06:37:19 +00001170LOG="install-$NAME.log"
David Bainbridge1d2c5842020-06-03 15:29:07 -07001171PFLOG="port-forward-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -07001172date > "$LOG"
divyadesai59f987a2020-05-27 12:11:33 +00001173echo "PORTS=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT,$ELASTICSEARCH_PORT,$KIBANA_PORT" >> "$LOG"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001174
1175# Output install options to log
David Bainbridged18f4942020-04-14 16:46:13 -07001176echo "OPTIONS" >> "$LOG"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001177for O in $ALL_OPTIONS; do
David Bainbridged18f4942020-04-14 16:46:13 -07001178 VAL="$(eval echo "\$$O")"
1179 if [ -n "$VAL" ]; then
1180 printf " %-30s = %s\n" "$O" "$VAL" >> "$LOG"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001181 fi
1182done
1183
David Bainbridgee4d11ca2020-05-08 10:21:10 -07001184# Force remove any existing k8s port-forward processes. This will
1185# remove them for all kind clusters.
David Bainbridgee4d11ca2020-05-08 10:21:10 -07001186if [ "$1" == "clean" ]; then
1187 kill_port_forward __ALL__
1188 exit
1189fi
1190
David Bainbridgefad50732020-05-01 17:00:12 -07001191helm_values() {
1192 local NAMESPACE=$1; shift
1193 local INAME=$1; shift
1194 local CHART=$1; shift
1195 local CHART_VERSION=$1; shift
1196
1197 if [ "$CHART_VERSION X" != " X" ] && [ "$CHART_VERSION" != "latest" ]; then
1198 CHART_VERSION="--version $CHART_VERSION"
1199 else
1200 CHART_VERSION=
1201 fi
1202
1203 local CHART_ARGS=
1204 if [ -r "${INAME}-values.yaml" ]; then
1205 CHART_ARGS="-f ${INAME}-values.yaml"
1206 fi
1207
1208 if [ "$HELM_USE_UPGRADE" == "yes" ]; then
1209 _HELM_COMMAND="upgrade --install"
1210 _HELM_ARGS="xxxdryrunxxx"
1211 else
1212 _HELM_COMMAND="install"
Matteo Scandolof2d080b2020-07-23 13:59:29 -07001213 if [ "$HELM_MAJOR" -le 2 ]; then
1214 _HELM_NAME_ARG="--name xxxdryrunxxx"
1215 _HELM_ARGS=
1216 else
1217 _HELM_NAME_ARG="xxxdryrunxxx"
1218 _HELM_ARGS="--create-namespace"
1219 fi
David Bainbridgefad50732020-05-01 17:00:12 -07001220 fi
Matteo Scandolof2d080b2020-07-23 13:59:29 -07001221 CMD=("helm $_HELM_COMMAND --debug --dry-run -f $NAME-values.yaml $CHART_ARGS $INTERNAL_EXTRA_HELM_INSTALL_ARGS $EXTRA_HELM_INSTALL_ARGS --set defaults.log_level=$VOLTHA_LOG_LEVEL --namespace $NAMESPACE $_HELM_ARGS $CHART_VERSION $EXTRA_HELM_FLAGS $_HELM_NAME_ARG $CHART")
David Bainbridgefad50732020-05-01 17:00:12 -07001222 ${CMD[*]} 2>/dev/null | awk 'PRINT==1 {print}; /^USER-SUPPLIED VALUES:/ {PRINT = 1}; /^$/ {PRINT = 0}'
1223}
1224
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001225helm_is_deployed() {
1226 local NAMESPACE=$1; shift
1227 local NAME=$1; shift
1228
1229 if [ "$HELM_MAJOR" -le 2 ]; then
1230 helm list --deployed --short --namespace "$NAMESPACE" "$NAME" 2>/dev/null | wc -l
1231 else
1232 helm list --deployed --short --namespace "$NAMESPACE" --filter "$NAME" 2>/dev/null | wc -l
1233 fi
1234}
1235
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001236helm_install() {
David Bainbridgec7220622020-05-28 12:31:47 -07001237 local INDENT NOW VALUES_FILE PPROF_ARG
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001238 if [ "$1" == "-" ]; then
1239 INDENT=$1; shift
1240 fi
1241 local NAMESPACE=$1; shift
David Bainbridge0774b232019-08-02 06:37:19 +00001242 local INAME=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001243 local CHART=$1; shift
David Bainbridge90fd8e32019-08-21 23:32:47 +00001244 local CHART_VERSION=$1; shift
David Bainbridgec7220622020-05-28 12:31:47 -07001245 local FILTER=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001246 local MESSAGE=$*
1247
David Bainbridged18f4942020-04-14 16:46:13 -07001248 if [ "$CHART_VERSION X" != " X" ] && [ "$CHART_VERSION" != "latest" ]; then
David Bainbridge90fd8e32019-08-21 23:32:47 +00001249 CHART_VERSION="--version $CHART_VERSION"
1250 else
1251 CHART_VERSION=
1252 fi
1253
David Bainbridge99ac7a22019-08-31 02:26:43 +00001254 local CHART_ARGS=
1255 if [ -r "${INAME}-values.yaml" ]; then
1256 CHART_ARGS="-f ${INAME}-values.yaml"
1257 fi
1258
David Bainbridged18f4942020-04-14 16:46:13 -07001259 local WAIT_START CMD
1260 WAIT_START="$(date +%s)"
1261 COUNT="$((300 / 15))"
1262 bspin "$INDENT" "$MESSAGE"
1263 if [ "$HELM_USE_UPGRADE" == "yes" ]; then
David Bainbridge7f8bf992020-04-08 21:53:22 -07001264 _HELM_COMMAND="upgrade --install"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001265 _HELM_NAME_ARG="$INAME"
David Bainbridge7f8bf992020-04-08 21:53:22 -07001266 else
1267 _HELM_COMMAND="install"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001268 if [ "$HELM_MAJOR" -le 2 ]; then
1269 _HELM_NAME_ARG="--name $INAME"
1270 _HELM_ARGS=
1271 else
1272 _HELM_NAME_ARG="$INAME"
1273 _HELM_ARGS="--create-namespace"
1274 fi
David Bainbridge7f8bf992020-04-08 21:53:22 -07001275 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001276
1277 VALUES_FILE="$(mktemp)"
1278 if [ "$FILTER" == "-" ]; then
1279 cp "$NAME-values.yaml" "$VALUES_FILE"
David Bainbridgea965ca22020-06-09 17:45:04 -07001280 elif [ "${FILTER:0:1}" == "+" ]; then
1281 cp "$NAME-values.yaml" "$VALUES_FILE"
1282 yq r - "${FILTER:1}" <"$NAME-values.yaml" >>"$VALUES_FILE"
David Bainbridge33e56c72020-06-11 11:39:56 -07001283 cat "$VALUES_FILE" >>"$LOG"
David Bainbridgec7220622020-05-28 12:31:47 -07001284 else
David Bainbridge43f2df52020-06-02 15:30:54 -07001285 yq r - "$FILTER" <"$NAME-values.yaml" >"$VALUES_FILE"
David Bainbridgec7220622020-05-28 12:31:47 -07001286 fi
1287 if [ "$WITH_PPROF" == "yes" ]; then
1288 PPROF_ARG="--set profiler.enabled=true"
1289 fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001290 CMD=("helm $_HELM_COMMAND -f $VALUES_FILE $_HELM_ARGS $CHART_ARGS $PPROF_ARG $INTERNAL_EXTRA_HELM_INSTALL_ARGS $EXTRA_HELM_INSTALL_ARGS --set defaults.log_level=$VOLTHA_LOG_LEVEL --namespace $NAMESPACE $CHART_VERSION $EXTRA_HELM_FLAGS $_HELM_NAME_ARG $CHART")
David Bainbridged18f4942020-04-14 16:46:13 -07001291 (set -x; ${CMD[*]} >>"$LOG" 2>&1) >>"$LOG" 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001292 SUCCESS=$?
David Bainbridged18f4942020-04-14 16:46:13 -07001293 while [ "$SUCCESS" -ne 0 ]; do
1294 NOW="$(date +%s)"
1295 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -07001296 espin "$THEX"
David Bainbridgec7220622020-05-28 12:31:47 -07001297 rm -f "$VALUES_FILE"
David Bainbridge52e6e9d2020-03-23 13:48:27 -07001298 doTimeout "waiting for helm install $CHART"
1299 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001300 sspin "$INDENT"
1301 COUNT="$((COUNT - 1))"
1302 if [ "$COUNT" -eq 0 ]; then
1303 if [ "$HELM_USE_UPGRADE" == "no" ]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001304 if [ "$HELM_MAJOR" -le 2 ]; then
1305 (set -x; helm delete --purge "$INAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1306 else
1307 (set -x; helm uninstall "$INAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1308 fi
David Bainbridge7f8bf992020-04-08 21:53:22 -07001309 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001310 (set -x; ${CMD[*]} >>"$LOG" 2>&1) >>"$LOG" 2>&1
Andy Baviere22ff252019-12-19 11:40:31 -07001311 SUCCESS=$?
David Bainbridged18f4942020-04-14 16:46:13 -07001312 COUNT="$((300 / 15))"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001313 fi
1314 sleep .15
1315 done
David Bainbridgec7220622020-05-28 12:31:47 -07001316 rm -f "$VALUES_FILE"
David Bainbridged18f4942020-04-14 16:46:13 -07001317 espin "$INDENT" "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001318}
1319
David Bainbridged18f4942020-04-14 16:46:13 -07001320echo "INSTALL TYPE: $TYPE" >> "$LOG"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001321
David Bainbridged18f4942020-04-14 16:46:13 -07001322STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001323if [ "$INSTALL_KUBECTL" == "no" ]; then
1324 bspin "Skip kubectl install"
1325 espin $NO_ENTRY
Test Userc13bdc92019-07-03 20:57:49 +00001326else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001327 bspin "Verify kubectl $HELM"
David Bainbridged18f4942020-04-14 16:46:13 -07001328 if [ -x "$GOPATH/bin/kubectl" ]; then
1329 espin "$VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001330 else
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001331 ERR_OUT="$(mktemp)"
David Bainbridged18f4942020-04-14 16:46:13 -07001332 espin "$NOT_VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001333 bspin - "Download and install Kubernetes/kubectl $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001334 (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
1335 RESULT=$?
1336 if [ "$RESULT" -ne 0 ]; then
1337 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001338 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download kubectl: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001339 cat "$ERR_OUT" >> "$LOG"
Zack Williamsded60cb2020-04-13 10:02:20 -07001340 rm -rf "$ERR_OUT" "$GOPATH/bin/kubectl"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001341 exit 1
1342 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001343 (set -x; chmod 755 "$GOPATH/bin/kubectl" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1344 espin - "$VERIFIED"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001345 rm -rf "$ERR_OUT"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001346 fi
Test Userc13bdc92019-07-03 20:57:49 +00001347fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001348if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001349 NOW="$(date +%s)"
1350 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001351fi
Test Userc13bdc92019-07-03 20:57:49 +00001352
David Bainbridged18f4942020-04-14 16:46:13 -07001353STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001354if [ "$DEPLOY_K8S" == "no" ]; then
1355 bspin "Skip Kubernetes/Kind Deployment"
1356 espin $NO_ENTRY
1357else
Test Userba1e7e72019-07-10 22:27:54 +00001358 bspin "Verify Kubernetes/Kind $HELM"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001359 IS_INSTALLED=0
1360 OP_TYPE="install"
David Bainbridged18f4942020-04-14 16:46:13 -07001361 if [ -x "$GOPATH/bin/kind" ]; then
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001362 OP_TYPE="upgrade"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001363 if [ "$("$GOPATH/bin/kind" version | grep -c "$KIND_VERSION")" -eq 1 ]; then
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001364 IS_INSTALLED=1
David Bainbridged18f4942020-04-14 16:46:13 -07001365 espin "$VERIFIED"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001366 fi
1367 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001368 if [ "$IS_INSTALLED" -eq 0 ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001369 ERR_OUT="$(mktemp)"
David Bainbridged18f4942020-04-14 16:46:13 -07001370 espin "$NOT_VERIFIED"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001371 bspin - "Download and $OP_TYPE Kubernetes/kind $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001372 (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
1373 RESULT=$?
1374 if [ $RESULT -ne 0 ]; then
1375 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001376 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download kind: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001377 cat "$ERR_OUT" >> "$LOG"
Zack Williamsded60cb2020-04-13 10:02:20 -07001378 rm -rf "$ERR_OUT" "$GOPATH/bin/kind"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001379 exit 1
1380 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001381 (set -x; chmod 755 "$GOPATH/bin/kind" >>"$LOG" 2>&1) >>"$LOG" 2>&1
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001382 rm -rf "$ERR_OUT"
David Bainbridged18f4942020-04-14 16:46:13 -07001383 espin - "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001384 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001385fi
1386
David Bainbridgee87067b2019-08-12 22:00:12 +00001387if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001388 NOW="$(date +%s)"
1389 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001390fi
1391
David Bainbridged18f4942020-04-14 16:46:13 -07001392STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001393if [ "$INSTALL_HELM" == "no" ]; then
1394 bspin "Skip Helm Install"
1395 espin $NO_ENTRY
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001396else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001397 bspin "Verify Helm $HELM"
David Bainbridgea34993d2020-04-01 09:15:42 -07001398 HELM_UPGRADE=0
1399 HELM_UPGRADE_DESC="install"
David Bainbridged18f4942020-04-14 16:46:13 -07001400 if [ -x "$GOPATH/bin/helm" ]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001401 HAVE_VER=$(helm version --client --short | sed -E -e 's/^.*(v[0-9]+\.[0-9]+\.[0-9]+).*$/\1/')
David Bainbridged18f4942020-04-14 16:46:13 -07001402 HELM_UP_DOWN="$(echo -e "$HAVE_VER\n$HELM_VERSION" | sort -V | head -1)"
1403 if [ "$HAVE_VER" != "$HELM_VERSION" ]; then
1404 if [ "$HELM_UP_DOWN" == "$HELM_VERSION" ]; then
David Bainbridgea34993d2020-04-01 09:15:42 -07001405 HELM_UPGRADE_DESC="downgrade"
1406 else
1407 HELM_UPGRADE_DESC="upgrade"
1408 fi
1409 HELM_UPGRADE=1
1410 else
David Bainbridged18f4942020-04-14 16:46:13 -07001411 espin "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001412 fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001413 else
David Bainbridgea34993d2020-04-01 09:15:42 -07001414 HELM_UPGRADE=1
1415 fi
1416
David Bainbridged18f4942020-04-14 16:46:13 -07001417 if [ "$HELM_UPGRADE" -ne 0 ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001418 ERR_OUT="$(mktemp)"
1419 INSTALL_HELM_BIN=$(mktemp)
David Bainbridged18f4942020-04-14 16:46:13 -07001420 espin "$NOT_VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001421 bspin - "Download and $HELM_UPGRADE_DESC Helm $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001422 (set -x; curl -o "$INSTALL_HELM_BIN" --fail -sSL https://git.io/get_helm.sh >>"$LOG" 2>"$ERR_OUT") >>"$LOG" 2>&1
1423 RESULT=$?
1424 if [ $RESULT -ne 0 ]; then
1425 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001426 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download helm installer: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001427 cat "$ERR_OUT" >> "$LOG"
1428 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT" "$GOPATH/bin/helm" "$GOPATH/bin/tiller"
1429 exit 1
1430 fi
1431 rm -rf "$ERR_OUT"
1432 chmod +x "$INSTALL_HELM_BIN"
1433 (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
1434 RESULT=$?
1435 if [ $RESULT -ne 0 ]; then
1436 espin - "$THEX"
1437 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to install helm, see install log for details${NORMAL}"
1438 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT" "$GOPATH/bin/helm" "$GOPATH/bin/tiller"
1439 exit 1
1440 fi
1441 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT"
David Bainbridged18f4942020-04-14 16:46:13 -07001442 espin - "$VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001443 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001444fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001445if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001446 NOW="$(date +%s)"
1447 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001448fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001449HELM_MAJOR=$(helm version --client --short 2>/dev/null| sed -E -e 's/^.*v([0-9]+)\.[0-9]+\.[0-9]+.*$/\1/')
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001450
David Bainbridged18f4942020-04-14 16:46:13 -07001451STIME="$(date +%s)"
Test Userb5712372019-07-03 21:52:17 +00001452bspin "Verify voltctl $HIGH_VOLTAGE"
David Bainbridged2811972019-12-14 01:14:09 +00001453VOK=0
1454VMESSAGE="install"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001455ERR_OUT=$(mktemp)
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001456export VC_VERSION="$VOLTCTL_VERSION"
1457if [ "$VC_VERSION" == "latest" ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001458 set -o pipefail # TODO: would be nice to run all in pipefail mode
1459 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')"
1460 RESULT=$?
1461 set +o pipefail
1462 if [ "$RESULT" -ne 0 ]; then
1463 espin - "$THEX"
1464 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to determine released version of voltctl: $(cat "$ERR_OUT")${NORMAL}"
1465 rm -rf "$ERR_OUT" "$GOPATH/bin/voltctl"
1466 exit 1
1467 fi
1468 export VC_VERSION
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001469fi
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001470
David Bainbridged18f4942020-04-14 16:46:13 -07001471if [ -x "$GOPATH/bin/voltctl" ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001472 VHAVE="$("$GOPATH/bin/voltctl" version --clientonly -o json 2>/dev/null | jq -r .version)"
David Bainbridged18f4942020-04-14 16:46:13 -07001473 RESULT=$?
1474 if [ $RESULT -eq 0 ] && [ "$VHAVE" == "$VC_VERSION" ]; then
David Bainbridged2811972019-12-14 01:14:09 +00001475 VOK=1
David Bainbridged18f4942020-04-14 16:46:13 -07001476 espin "$VERIFIED"
David Bainbridge1ba64f12019-12-18 00:40:13 +00001477 else
David Bainbridged18f4942020-04-14 16:46:13 -07001478 VCHECK="$(echo -e "$VHAVE\n$VC_VERSION" | sort -V | head -1)"
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001479 if [ "$VCHECK" == "$VHAVE" ]; then
1480 VMESSAGE="upgrade"
1481 else
1482 VMESSAGE="downgrade"
1483 fi
David Bainbridged2811972019-12-14 01:14:09 +00001484 fi
1485fi
1486
David Bainbridged18f4942020-04-14 16:46:13 -07001487if [ "$VOK" -eq 0 ]; then
1488 espin "$NOT_VERIFIED"
David Bainbridged2811972019-12-14 01:14:09 +00001489 bspin - "Download and $VMESSAGE voltctl $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001490 (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
1491 RESULT=$?
1492 if [ $RESULT -ne 0 ]; then
1493 espin - "$THEX"
1494 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download voltctl (version $VC_VERSION): $(cat "$ERR_OUT")${NORMAL}"
1495 rm -rf "$ERR_OUT" "$GOPATH/bin/voltctl"
1496 exit 1
1497 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001498 (set -x; chmod 755 "$GOPATH/bin/voltctl" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1499 espin - "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001500fi
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001501rm -rf "$ERR_OUT"
David Bainbridgee87067b2019-08-12 22:00:12 +00001502if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001503 NOW="$(date +%s)"
1504 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001505fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001506
1507bspin "Verify command PATH"
David Bainbridged18f4942020-04-14 16:46:13 -07001508espin "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001509
David Bainbridged18f4942020-04-14 16:46:13 -07001510STIME="$(date +%s)"
Test Userba1e7e72019-07-10 22:27:54 +00001511if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001512 HAVE="$(kind get clusters 2>/dev/null | grep -c "voltha-$NAME")"
Test Userba1e7e72019-07-10 22:27:54 +00001513 bspin "Verify Kubernetes/Kind Cluster"
1514 sspin
David Bainbridged18f4942020-04-14 16:46:13 -07001515 if [ "$HAVE" -eq 0 ]; then
1516 espin "$NOT_VERIFIED"
David Bainbridge491b1bd2019-07-11 17:53:11 +00001517 bspin - "Verify cluster configuration"
David Bainbridged18f4942020-04-14 16:46:13 -07001518 if [ ! -r "./$NAME-cluster.cfg" ]; then
1519 espin - "$NOT_VERIFIED"
David K. Bainbridge43422402020-03-06 07:41:22 -08001520 bspin - "Download cluster configuration: $TYPE-cluster.cfg to $NAME-cluster.cfg $DOWNLOAD"
David Bainbridged18f4942020-04-14 16:46:13 -07001521 ERR_OUT="$(mktemp)"
serkant.uluderya4d315132020-04-15 16:25:54 -07001522 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 -07001523 espin - "$THEX"
1524 echo -e "${RED}${BOLD}${ERROR}ERROR: $NAME-cluster.cfg${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1525 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
1526 rm -rf "$ERR_OUT" "./$NAME-cluster.cfg"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001527 exit 1
1528 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001529 rm -rf "$ERR_OUT"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001530 else
David Bainbridged18f4942020-04-14 16:46:13 -07001531 espin - "$VERIFIED"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001532 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001533 kind create cluster --name "voltha-$NAME" --config "$NAME-cluster.cfg"
David Bainbridge491b1bd2019-07-11 17:53:11 +00001534 else
David Bainbridged18f4942020-04-14 16:46:13 -07001535 espin "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001536 fi
1537
David K. Bainbridgec0ec6492020-07-21 17:34:23 +00001538 KUBECONFIG_TMP=$(mktemp)
1539 kind get kubeconfig --name="voltha-$NAME" >"$KUBECONFIG_TMP"
1540 mkdir -p "$HOME/.kube"
1541 KUBECONFIG="$HOME/.kube/kind-config-voltha-$NAME"; export KUBECONFIG
1542 cp "$KUBECONFIG_TMP" "$KUBECONFIG"
1543 rm -rf "$KUBECONFIG_TMP"
David Bainbridge1d2c5842020-06-03 15:29:07 -07001544
Test Userba1e7e72019-07-10 22:27:54 +00001545 P="coredns-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001546 etcd-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +00001547 kindnet-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001548 kube-apiserver-voltha-$NAME-control-plane \
1549 kube-controller-manager-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +00001550 kube-proxy-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001551 kube-scheduler-voltha-$NAME-control-plane"
Test Userba1e7e72019-07-10 22:27:54 +00001552
David Bainbridged18f4942020-04-14 16:46:13 -07001553 EXPECT="$(test "$TYPE" == "minimal" && echo "12" || echo "14")"
1554 wait_for_pods - "kube-system" "$EXPECT" "includes" "Waiting for system PODs to start" "$NO_LABEL" "$P"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001555fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001556if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001557 NOW="$(date +%s)"
1558 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001559fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001560
David Bainbridgee4d11ca2020-05-08 10:21:10 -07001561if [ "$SCHEDULE_ON_CONTROL_NODES" == "yes" ]; then
1562 bspin "Untaint control nodes to allow scheduling $LOCK"
1563 for MNODE in $(kubectl get node --selector='node-role.kubernetes.io/master' -o json | jq -r '.items[].metadata.name'); do
1564 (set -x; kubectl taint node "$MNODE" node-role.kubernetes.io/master:NoSchedule- >>"$LOG" 2>&1) >>"$LOG" 2>&1
1565 sspin
1566 done
1567 espin "$VERIFIED"
1568fi
1569
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001570if [ "$HELM_MAJOR" -le 2 ]; then
1571 STIME="$(date +%s)"
1572 COUNT="$(count_pods "kube-system" ":Running:" "$NO_LABEL" "tiller-deploy-.*")"
1573 bspin "Verify Helm"
1574 if [ "$COUNT" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001575 espin "$NOT_VERIFIED"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001576 echo -e "Configuring Helm $GEAR"
1577 if [ "$INSTALL_HELM" == "no" ]; then
1578 bspin - "Skip Helm Initialization"
1579 espin - $NO_ENTRY
1580 else
1581 bspin - "Initialize Helm"
1582 (set -x; helm init --upgrade >>"$LOG" 2>&1) >>"$LOG" 2>&1
1583 espin - "$VERIFIED"
1584 wait_for_pods - "kube-system" 1 "includes" "Waiting for Tiller POD to start" "$NO_LABEL" "tiller-deploy-.*"
1585 fi
1586
1587 # HACK (sort-of) - the config for tiller is about to be patched, which will
1588 # cause the tiller pod to be recreated. This can sometimes cause a timing
1589 # issue with the "wait_for_pods" call on tiller as it may incorrectly
1590 # identify the running/ready tiller pod that is soon to be terminated as
1591 # what it is waiting for. To avoid this issue we do a clean scale down and
1592 # scale up of the pod so the script controlls when it should be expecting
1593 # things
1594 (set -x; kubectl -n kube-system scale deploy tiller-deploy --replicas=0 >>"$LOG" 2>&1) >>"$LOG" 2>&1
1595 wait_for_pods - "kube-system" 0 "not" "Waiting for Tiller POD to shutdown" "$NO_LABEL" "tiller-deploy-.*"
1596
1597 # Create and k8s service account so that Helm can create pods
1598 bspin - "Create Tiller ServiceAccount"
1599 (set -x; kubectl create serviceaccount --namespace kube-system tiller >>"$LOG" 2>&1) >>"$LOG" 2>&1
1600 espin - "$VERIFIED"
1601 bspin - "Create Tiller ClusterRoleBinding"
1602 (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>"$LOG" 2>&1) >>"$LOG" 2>&1
1603 espin - "$VERIFIED"
1604 bspin - "Update Tiller Manifest"
1605 (set -x; kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}' >>"$LOG" 2>&1) >>"$LOG" 2>&1
1606
1607 # HACK (sort-of) - part to, spin it back up
1608 (set -x; kubectl -n kube-system scale deploy tiller-deploy --replicas=1 >>"$LOG" 2>&1) >>"$LOG" 2>&1
David Bainbridged18f4942020-04-14 16:46:13 -07001609 espin - "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001610 else
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001611 if [ "$(helm version -s --template '{{.Server.SemVer}}')" != "$HELM_VERSION" ]; then
1612 espin "$NOT_VERIFIED"
1613 bspin - "Sync Tiller server version with helm client"
1614 (set -x; helm init --upgrade --force-upgrade --wait >>"$LOG" 2>&1) >>"$LOG" 2>&1
1615 espin - "$VERIFIED"
1616 else
1617 espin "$VERIFIED"
1618 fi
1619
David Bainbridgea34993d2020-04-01 09:15:42 -07001620 fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001621 wait_for_pods - "kube-system" 1 "includes" "Waiting for Tiller POD to start" "$NO_LABEL" "tiller-deploy-.*"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001622fi
David Bainbridgeddeab482020-06-24 12:43:40 -07001623
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001624# The `etcd` repo is temporary until `http://github.com/helm/charts/pull/22955` is
1625# merged into the incubator charts
David Bainbridgeddeab482020-06-24 12:43:40 -07001626REPOS="onf|https://charts.opencord.org|ONF_VOLTHA \
1627 stable|https://kubernetes-charts.storage.googleapis.com|Google_Stable \
Ubuntubaab12f2020-06-30 01:08:19 +00001628 incubator|https://kubernetes-charts-incubator.storage.googleapis.com|Google_Incubator \
1629 onos|https://charts.onosproject.org|ONF_ONOS \
1630 atomix|https://charts.atomix.io|ONF_Atomix \
1631 bbsim-sadis|https://ciena.github.io/bbsim-sadis-server/charts|Custom_BBSIM_SADIS_Server \
1632 elastic|https://helm.elastic.co|Elastic \
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001633 kiwigrid|https://kiwigrid.github.io|Fluentd-ElasticSearch \
1634 etcd|https://dbainbri-ciena.github.io/etcd-helm-chart"
David Bainbridgeddeab482020-06-24 12:43:40 -07001635
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001636REPO_UPDATE_REQ="no"
David Bainbridgeddeab482020-06-24 12:43:40 -07001637bspin - "Verify Helm Repository"
1638for REPO in $REPOS; do
1639 REPO_NAME="$(echo "$REPO" | cut -d\| -f1)"
1640 REPO_URL="$(echo "$REPO" | cut -d\| -f2)"
1641 REPO_LABEL="$(echo "$REPO" | cut -d\| -f3 | sed -e 's/_/ /g')"
1642
1643 sspin - "Verify Helm Repository: $REPO_LABEL$CEOL"
1644 if [ "$(helm repo list 2>/dev/null | grep -c "$REPO_NAME" 2>/dev/null)" -eq 0 ]; then
1645 sspin - "Add Helm Repository: $REPO_LABEL$CEOL"
1646 (set -x; helm repo add "$REPO_NAME" "$REPO_URL" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1647 REPO_UPDATE_REQ="yes"
1648 fi
1649done
1650sspin - "Verify Helm Repositories$CEOL"
1651espin - "$VERIFIED"
1652
1653if [ "$REPO_UPDATE_REQ" == "yes" ] || [ "$UPDATE_HELM_REPOS" == "yes" ]; then
1654 bspin - "Update Helm repository cache"
1655 (set -x; helm repo update >>"$LOG" 2>&1) >>"$LOG" 2>&1
1656 espin - "$VERIFIED"
1657fi
1658
David Bainbridgee87067b2019-08-12 22:00:12 +00001659if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001660 NOW="$(date +%s)"
1661 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001662fi
David Bainbridgecf546362020-04-21 23:18:50 -07001663# Resolve chart versions and log them for debug/support
1664RESOLVED_VOLTHA_CHART_VERSION=$(resolve_chart_version "$VOLTHA_CHART" "$VOLTHA_CHART_VERSION")
1665RESOLVED_VOLTHA_BBSIM_CHART_VERSION=$(resolve_chart_version "$VOLTHA_BBSIM_CHART" "$VOLTHA_BBSIM_CHART_VERSION")
1666RESOLVED_VOLTHA_ADAPTER_SIM_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_SIM_CHART" "$VOLTHA_ADAPTER_SIM_CHART_VERSION")
1667RESOLVED_VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_OPEN_OLT_CHART" "$VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION")
1668RESOLVED_VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_OPEN_ONU_CHART" "$VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION")
1669RESOLVED_ONOS_CHART_VERSION=$(resolve_chart_version "$ONOS_CHART" "$ONOS_CHART_VERSION")
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001670RESOLVED_ONOS_CLASSIC_CHART_VERSION=$(resolve_chart_version "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION")
David Bainbridgecf546362020-04-21 23:18:50 -07001671RESOLVED_KAFKA_CHART_VERSION=$(resolve_chart_version "$KAFKA_CHART" "$KAFKA_CHART_VERSION")
divyadesai59f987a2020-05-27 12:11:33 +00001672RESOLVED_ELASTICSEARCH_CHART_VERSION=$(resolve_chart_version "$ELASTICSEARCH_CHART" "$ELASTICSEARCH_CHART_VERSION")
1673RESOLVED_KIBANA_CHART_VERSION=$(resolve_chart_version "$KIBANA_CHART" "$KIBANA_CHART_VERSION")
1674RESOLVED_FLUENTD_ELASTICSEARCH_CHART_VERSION=$(resolve_chart_version "$FLUENTD_ELASTICSEARCH_CHART" "$FLUENTD_ELASTICSEARCH_CHART_VERSION")
David K. Bainbridge450c15c2020-06-29 10:12:06 -07001675RESOLVED_BBSIM_SADIS_SERVER_CHART_VERSION=$(resolve_chart_version "$BBSIM_SADIS_SERVER_CHART" "$BBSIM_SADIS_SERVER_CHART_VERSION")
1676RESOLVED_RADIUS_CHART_VERSION=$(resolve_chart_version "$RADIUS_CHART" "$RADIUS_CHART_VERSION")
David Bainbridgecf546362020-04-21 23:18:50 -07001677cat <<EOV >>"$LOG"
1678Resolved helm charts and versions:
1679 $VOLTHA_CHART:$RESOLVED_VOLTHA_CHART_VERSION
1680 $VOLTHA_BBSIM_CHART:$RESOLVED_VOLTHA_BBSIM_CHART_VERSION
1681 $VOLTHA_ADAPTER_SIM_CHART:$RESOLVED_VOLTHA_ADAPTER_SIM_CHART_VERSION
1682 $VOLTHA_ADAPTER_OPEN_OLT_CHART:$RESOLVED_VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION
1683 $VOLTHA_ADAPTER_OPEN_ONU_CHART:$RESOLVED_VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION
1684 $ONOS_CHART:$RESOLVED_ONOS_CHART_VERSION
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001685 $ONOS_CLASSIC_CHART:$RESOLVED_ONOS_CLASSIC_CHART_VERSION
David Bainbridgecf546362020-04-21 23:18:50 -07001686 $KAFKA_CHART:$RESOLVED_KAFKA_CHART_VERSION
divyadesai59f987a2020-05-27 12:11:33 +00001687 $ELASTICSEARCH_CHART:$RESOLVED_ELASTICSEARCH_CHART_VERSION
1688 $KIBANA_CHART:$RESOLVED_KIBANA_CHART_VERSION
1689 $FLUENTD_ELASTICSEARCH_CHART:$RESOLVED_FLUENTD_ELASTICSEARCH_CHART_VERSION
David K. Bainbridge450c15c2020-06-29 10:12:06 -07001690 $BBSIM_SADIS_SERVER_CHART:$RESOLVED_BBSIM_SADIS_SERVER_CHART_VERSION
1691 $RADIUS_CHART:$RESOLVED_RADIUS_CHART_VERSION
David Bainbridgecf546362020-04-21 23:18:50 -07001692EOV
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001693
David Bainbridged18f4942020-04-14 16:46:13 -07001694STIME="$(date +%s)"
David Bainbridge0774b232019-08-02 06:37:19 +00001695bspin "Verify Helm values file: $NAME-values.yaml"
1696if [ ! -r "./$NAME-values.yaml" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001697 espin "$NOT_VERIFIED"
David Bainbridge0774b232019-08-02 06:37:19 +00001698 bspin - "Download Helm values file: $TYPE-values.yaml to $NAME-values.yaml $DOWNLOAD"
David Bainbridged18f4942020-04-14 16:46:13 -07001699 ERR_OUT="$(mktemp)"
serkant.uluderya4d315132020-04-15 16:25:54 -07001700 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 -07001701 espin - "$THEX"
1702 echo -e "${RED}${BOLD}${ERROR}ERROR: $NAME-values.yaml${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1703 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
1704 rm -rf "$ERR_OUT" "./$NAME-values.yaml"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001705 exit 1
1706 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001707 rm -rf "$ERR_OUT"
1708 espin - "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001709else
David Bainbridged18f4942020-04-14 16:46:13 -07001710 espin "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001711fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001712if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001713 NOW="$(date +%s)"
1714 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001715fi
Test Userba1e7e72019-07-10 22:27:54 +00001716
David Bainbridged18f4942020-04-14 16:46:13 -07001717STIME="$(date +%s)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001718bspin "Verify or download chart specific values files $DOWNLOAD"
1719VALUES_FILES="monkey-values.yaml"
David Bainbridged18f4942020-04-14 16:46:13 -07001720ERR_OUT="$(mktemp)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001721for i in $VALUES_FILES; do
1722 if [ ! -r ./$i ]; then
serkant.uluderya4d315132020-04-15 16:25:54 -07001723 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 -07001724 espin "$THEX"
1725 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1726 echo "ERROR: $i - $(cat "$ERR_OUT")" >>"$LOG"
1727 rm -rf "$ERR_OUT" "./$i"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001728 exit 1
1729 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001730 rm -rf "$ERR_OUT"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001731 fi
1732done
David Bainbridged18f4942020-04-14 16:46:13 -07001733rm -rf "$ERR_OUT"
1734espin "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001735if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001736 NOW="$(date +%s)"
1737 printtime $((NOW - STIME))
David Bainbridge99ac7a22019-08-31 02:26:43 +00001738fi
1739
1740if [ "$WITH_CHAOS" == "yes" ]; then
1741 bspin "Verify or clone kube-monkey helm chart $DOWNLOAD"
1742 if [ -r ./kube-monkey ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001743 espin "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001744 else
David Bainbridged18f4942020-04-14 16:46:13 -07001745 espin "$NOT_VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001746 bspin - "GIT clone kube-monkey"
David Bainbridged18f4942020-04-14 16:46:13 -07001747 (set -x; git clone https://github.com/asobti/kube-monkey kube-monkey >>"$LOG" 2>&1) >>"$LOG" 2>&1
1748 espin - "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001749 fi
1750fi
1751
Test Userba1e7e72019-07-10 22:27:54 +00001752if [ "$JUST_K8S" == "yes" ]; then
1753 echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye."
1754 echo ""
David Bainbridged18f4942020-04-14 16:46:13 -07001755 echo "Please issue the following commands in your terminal to ensure that you" | tee -a "$LOG"
1756 echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a "$LOG"
1757 echo "tools required by VOLTHA in your command path. " | tee -a "$LOG"
1758 echo "" | tee -a "$LOG"
1759 echo -en "$BOLD"
1760 if [ "$DEPLOY_K8S" == "yes" ]; then
David K. Bainbridge02ae1f32020-07-21 13:25:13 -07001761 KUBECONFIG_TMP=$(mktemp)
1762 kind get kubeconfig --name="voltha-$NAME" >"$KUBECONFIG_TMP"
1763 mkdir -p "$HOME/.kube"
1764 KUBECONFIG="$HOME/.kube/kind-config-voltha-$NAME"; export KUBECONFIG
1765 cp "$KUBECONFIG_TMP" "$KUBECONFIG"
1766 rm -rf "$KUBECONFIG_TMP"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001767 echo "export KUBECONFIG=\"$KUBECONFIG\"" | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00001768 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001769 echo "export PATH=$GOPATH/bin:\$PATH" | tee -a "$LOG"
1770 echo -en "$NORMAL"
1771 echo "" | tee -a "$LOG"
1772 echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00001773 exit 0
1774fi
1775
David Bainbridged18f4942020-04-14 16:46:13 -07001776STIME="$(date +%s)"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001777if is_in "$WITH_ONOS" "yes,legacy,classic"; then
1778 if is_in "$WITH_ONOS" "legacy"; then
1779 bspin "Verify ONOS LEGACY installed $BIRD"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001780 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^onos\$")" -ne 1 ]; then
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001781 espin "$NOT_VERIFIED"
David Bainbridge33e56c72020-06-11 11:39:56 -07001782 INTERNAL_EXTRA_HELM_INSTALL_ARGS="$SET_TAG $EXTRA_HELM_FLAGS" helm_install - "$INFRA_NS" onos "$ONOS_CHART" "$ONOS_CHART_VERSION" "+onos" "$_HELM_DESC ONOS LEGACY"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001783 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
1784 else
1785 espin "$VERIFIED"
1786 fi
1787 wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for ONOS to start" "$NO_LABEL" "onos-.*"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001788
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001789 if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
1790 bspin - "Forward ONOS API port $FORWARD"
1791 kill_port_forward onos-ui
1792 port_forward "$INFRA_NS" onos-ui "$ONOS_API_PORT:8181"
1793 espin - "$VERIFIED"
1794 bspin - "Forward ONOS SSH port $FORWARD"
1795 kill_port_forward onos-ssh
1796 port_forward "$INFRA_NS" onos-ssh "$ONOS_SSH_PORT:8101"
1797 espin - "$VERIFIED"
1798 _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT"
1799 else
1800 _ONOS_API_EP="$(get_service_ep "$INFRA_NS" onos-ui)"
1801 fi
1802 elif is_in "$WITH_ONOS" "yes,classic"; then
1803 bspin "Verify ONOS CLASSIC installed $BIRD"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001804 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^onos\$")" -ne 1 ]; then
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001805 espin "$NOT_VERIFIED"
Matteo Scandoloe0829b52020-05-08 14:23:56 -07001806 # ONOS CLASSIC identifies its image repo/tag/pullPolicy differently, so yq is used to grab the values from the
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001807 # values value
David Bainbridgefad50732020-05-01 17:00:12 -07001808 YAML_VALUES=$(INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set replicas=$NUM_OF_ONOS --set atomix.replicas=$NUM_OF_ATOMIX" \
1809 helm_values "$INFRA_NS" onos "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION")
1810 _ONOS_REPO="$(echo "$YAML_VALUES" | yq read - images.onos.repository)"
David Bainbridgedee3f022020-06-05 07:45:13 -07001811 if [ -z "$_ONOS_REPO" ]; then
1812 _ONOS_REPO="voltha/voltha-onos"
1813 fi
David Bainbridgefad50732020-05-01 17:00:12 -07001814 _ONOS_TAG="$(echo "$YAML_VALUES" | yq read - images.onos.tag)"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001815 if [ -z "$_ONOS_TAG" ]; then
David Bainbridgedee3f022020-06-05 07:45:13 -07001816 _ONOS_TAG="$(echo "$YAML_VALUES" | yq read - defaults.image_tag)"
1817 fi
1818 if [ -z "$_ONOS_TAG" ]; then
1819 _ONOS_TAG="master"
1820 fi
1821 _ONOS_PULL_POLICY="$(echo "$YAML_VALUES" | yq read - images.onos.pullPolicy)"
1822 if [ -z "$_ONOS_PULL_POLICY" ]; then
1823 _ONOS_PULL_POLICY="$(echo "$YAML_VALUES" | yq read - defaults.image_pullPolicy)"
1824 fi
1825 if [ -z "$_ONOS_PULL_POLICY" ]; then
1826 _ONOS_PULL_POLICY="Always"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001827 fi
David Bainbridgefad50732020-05-01 17:00:12 -07001828
Matteo Scandoloe0829b52020-05-08 14:23:56 -07001829 INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set image.pullPolicy=$_ONOS_PULL_POLICY,image.repository=$_ONOS_REPO,image.tag=$_ONOS_TAG,replicas=$NUM_OF_ONOS,atomix.replicas=$NUM_OF_ATOMIX" \
David Bainbridge33e56c72020-06-11 11:39:56 -07001830 helm_install - "$INFRA_NS" onos "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION" "+onos" "$_HELM_DESC ONOS CLASSIC"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001831 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
1832 else
1833 espin "$VERIFIED"
1834 fi
1835 wait_for_pods - "$INFRA_NS" $((NUM_OF_ONOS + NUM_OF_ATOMIX)) "includes" "Waiting for ONOS CLASSIC to start" "$NO_LABEL" "onos-.*"
1836 if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
1837 bspin - "Forward ONOS API port $FORWARD"
1838 kill_port_forward onos-onos-classic-hs
1839 port_forward "$INFRA_NS" onos-onos-classic-hs "$ONOS_API_PORT:8181" "$ONOS_SSH_PORT:8101"
1840 espin - "$VERIFIED"
1841 _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT"
1842 else
1843 _ONOS_API_EP="$(get_service_ep "$INFRA_NS" onos-onos-classic-hs)"
1844 fi
1845 elif [ "$WITH_ONOS" == "micro" ]; then
1846 bspin "Verify micro-ONOS installed $BIRD"
1847 # We should never get here
1848 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Micro ONOS not currently supported${NORMAL}"
1849 exit 1
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001850 fi
David Bainbridged31d6122019-08-13 19:37:59 +00001851 bspin - "Verify or download ONOS configuration support files $DOWNLOAD"
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001852 ONOS_FILES="olt-onos-enableExtraneousRules.json onos-aaa.json \
David Bainbridge696bc632020-04-05 21:49:37 -07001853 onos-dhcpl2relay.json onos-sadis-sample.json"
David Bainbridged18f4942020-04-14 16:46:13 -07001854 (set -x; mkdir -p ./onos-files >>"$LOG" 2>&1) >>"$LOG" 2>&1
1855 ERR_OUT="$(mktemp)"
David Bainbridge2b19e832019-08-16 02:40:53 +00001856 for i in $ONOS_FILES; do
David Bainbridged18f4942020-04-14 16:46:13 -07001857 if [ ! -r "./onos-files/$i" ]; then
serkant.uluderya4d315132020-04-15 16:25:54 -07001858 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 -07001859 espin - "$THEX"
1860 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1861 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
1862 rm -rf "$ERR_OUT" "./onos-files/$i"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001863 exit 1
1864 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001865 rm -rf "$ERR_OUT"
David Bainbridged31d6122019-08-13 19:37:59 +00001866 fi
1867 done
David Bainbridged18f4942020-04-14 16:46:13 -07001868 rm -rf "$ERR_OUT"
1869 espin - "$VERIFIED"
David Bainbridge27790d62019-08-13 22:43:19 +00001870
David Bainbridged18f4942020-04-14 16:46:13 -07001871 if [ "$INSTALL_ONOS_APPS" == "yes" ]; then
David Bainbridge27790d62019-08-13 22:43:19 +00001872 bspin - "Installing custom ONOS applications"
David Bainbridged18f4942020-04-14 16:46:13 -07001873 if [ -x onos-files/onos-apps ] && [ "$(find onos-files/onos-apps -name "*.oar" 2>/dev/null | wc -l)" -gt 0 ]; then
1874 for OAR in onos-files/onos-apps/*.oar; do
David Bainbridge27790d62019-08-13 22:43:19 +00001875 sspin - "Installing custom ONOS applications - $OAR$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -07001876 override_onos_app "$OAR"
David Bainbridge27790d62019-08-13 22:43:19 +00001877 done
1878 espin - "$VERIFIED Installing custom ONOS applications$CEOL"
1879 else
1880 espin - "$NOT_VERIFIED Installing custom ONOS applications - None Found"
1881 fi
1882 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001883
David Bainbridged18f4942020-04-14 16:46:13 -07001884 if [ "$WITH_KAFKA" != "no" ]; then
David Bainbridge837e8bd2020-04-06 13:17:14 -07001885 check_onos_app_active org.opencord.kafka
David Bainbridge879439b2020-06-12 15:59:35 -07001886 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridgec7220622020-05-28 12:31:47 -07001887 _HOST=kafka.$INFRA_NS.svc
David Bainbridge76afd812020-04-06 09:53:52 -07001888 _PORT=9092
David Bainbridge879439b2020-06-12 15:59:35 -07001889 elif [ "$WITH_KAFKA" != "no" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001890 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
1891 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge837e8bd2020-04-06 13:17:14 -07001892 _PORT=${_PORT:-9092}
1893 fi
1894 push_onos_config "json" "Push ONOS Kafka Configuration" "network/configuration/apps/org.opencord.kafka" \
David Bainbridged18f4942020-04-14 16:46:13 -07001895 "$(cat <<EOJ | tr -d '[:space:]'
David Bainbridge696bc632020-04-05 21:49:37 -07001896{
1897 "kafka": {
1898 "bootstrapServers": "$_HOST:$_PORT"
1899 }
1900}
1901EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07001902)"
David Bainbridge837e8bd2020-04-06 13:17:14 -07001903 fi
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001904 check_onos_app_active org.opencord.dhcpl2relay
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001905 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 -08001906 check_onos_app_active org.opencord.olt
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001907 # FIXME use WITH_DHCP and WITH_EAPOL flags to configre OLT App
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001908 # Default value for "enableEapol" is true in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07001909 if [ "$WITH_EAPOL" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001910 push_onos_config "json" "Enable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":true}'
David Bainbridged18f4942020-04-14 16:46:13 -07001911 elif [ "$WITH_EAPOL" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001912 push_onos_config "json" "Disable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001913 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001914 # Default value for "enableDhcpOnProvisioning" is false and for "enableDhcpV4" is true in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07001915 if [ "$WITH_DHCP" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001916 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 -07001917 elif [ "$WITH_DHCP" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001918 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 -08001919 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001920 # Default value for "enableIgmpOnProvisioning" is false in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07001921 if [ "$WITH_IGMP" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001922 push_onos_config "json" "Enable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":true}'
David Bainbridged18f4942020-04-14 16:46:13 -07001923 elif [ "$WITH_IGMP" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001924 push_onos_config "json" "Disable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001925 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001926 if [ "$ENABLE_ONOS_EXTRANEOUS_RULES" == "yes" ]; then
David K. Bainbridge484d80c2020-03-05 21:44:34 -08001927 push_onos_config "file" "Enabling extraneous rules for ONOS" "configuration/org.onosproject.net.flow.impl.FlowRuleManager" "onos-files/olt-onos-enableExtraneousRules.json"
1928 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001929 if is_in "$CONFIG_SADIS" "yes,file"; then
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001930 check_onos_app_active org.opencord.sadis
Hardik Windlassb3147602020-03-09 16:59:15 +05301931 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 -07001932 elif [ "$CONFIG_SADIS" == "bbsim" ]; then
1933 push_onos_config "json" \
1934 "[optional] Push ONOS configuration for BBSIM SADIS servers" \
1935 "network/configuration/apps/org.opencord.sadis" \
David Bainbridged18f4942020-04-14 16:46:13 -07001936 "$(cat <<EOJ | tr -d '[:space:]'
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001937{
1938 "sadis": {
1939 "integration": {
David Bainbridgec7220622020-05-28 12:31:47 -07001940 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:50074/v2/subscribers/%s",
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001941 "cache": {
1942 "enabled": true,
1943 "maxsize": 50,
1944 "ttl": "PT1m"
1945 }
1946 }
1947 },
1948 "bandwidthprofile": {
1949 "integration": {
David Bainbridgec7220622020-05-28 12:31:47 -07001950 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:50074/v2/bandwidthprofiles/%s",
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001951 "cache": {
1952 "enabled": true,
1953 "maxsize": 50,
1954 "ttl": "PT1m"
1955 }
1956 }
1957 }
1958}
1959EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07001960)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001961 elif [ "$CONFIG_SADIS" == "url" ]; then
1962 push_onos_config "json" \
1963 "[optional] Push ONOS configuration for custom SADIS and Bandwidth Profile servers" \
1964 "network/configuration/apps/org.opencord.sadis" \
David Bainbridged18f4942020-04-14 16:46:13 -07001965 "$(cat <<EOJ | tr -d '[:space:]'
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001966{
1967 "sadis": {
1968 "integration": {
1969 "url": "$SADIS_SUBSCRIBERS",
1970 "cache": {
1971 "enabled": true,
1972 "maxsize": 50,
1973 "ttl": "PT1m"
1974 }
1975 }
1976 },
1977 "bandwidthprofile": {
1978 "integration": {
1979 "url": "$SADIS_BANDWIDTH_PROFILES",
1980 "cache": {
1981 "enabled": true,
1982 "maxsize": 50,
1983 "ttl": "PT1m"
1984 }
1985 }
1986 }
1987}
1988EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07001989)"
David Bainbridge2b19e832019-08-16 02:40:53 +00001990 fi
Test Userba1e7e72019-07-10 22:27:54 +00001991fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001992if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001993 NOW="$(date +%s)"
1994 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001995fi
Test Userba1e7e72019-07-10 22:27:54 +00001996
David Bainbridgec7220622020-05-28 12:31:47 -07001997if is_in "$WITH_ETCD" "yes,external"; then
David Bainbridged18f4942020-04-14 16:46:13 -07001998 STIME="$(date +%s)"
David Bainbridge76afd812020-04-06 09:53:52 -07001999 bspin "Verify external ETCD cluster $OLD_KEY"
David Bainbridge43f2df52020-06-02 15:30:54 -07002000 EXPECT="$(yq r - "etcd.replicas" <"$NAME-values.yaml")"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002001 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^etcd\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002002 espin "$NOT_VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002003 helm_install - "$INFRA_NS" etcd "$ETCD_CHART" "$ETCD_CHART_VERSION" etcd "$_HELM_DESC external ETCD cluster"
David Bainbridge76afd812020-04-06 09:53:52 -07002004 else
David Bainbridged18f4942020-04-14 16:46:13 -07002005 espin "$VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07002006 fi
David Bainbridgec7220622020-05-28 12:31:47 -07002007 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for ETCD cluster to start" "$NO_LABEL" "etcd-.*"
David Bainbridge76afd812020-04-06 09:53:52 -07002008 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002009 NOW="$(date +%s)"
2010 printtime $((NOW - STIME))
David Bainbridge76afd812020-04-06 09:53:52 -07002011 fi
2012fi
2013
David Bainbridgec7220622020-05-28 12:31:47 -07002014if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridged18f4942020-04-14 16:46:13 -07002015 _TMP="$(mktemp -u)"
2016 _COUNT="$(test "$TYPE" == "minimal" && echo "1" || echo "3")"
2017 cat << EOC > "$_TMP"
David Bainbridge76afd812020-04-06 09:53:52 -07002018configurationOverrides:
2019 "default.replication.factor": $_COUNT
2020 "offsets.topic.replication.factor": $_COUNT
2021 "log.retention.hours": 4
2022 "log.message.timestamp.type": "LogAppendTime"
2023persistence:
2024 enabled: false
2025zookeeper:
2026 replicaCount: 1
2027 persistence:
2028 enabled: false
2029replicas: $_COUNT
2030EOC
David Bainbridged18f4942020-04-14 16:46:13 -07002031 STIME="$(date +%s)"
David Bainbridge76afd812020-04-06 09:53:52 -07002032 bspin "Verify external Kafka cluster $OLD_KEY"
David Bainbridged18f4942020-04-14 16:46:13 -07002033 EXPECT="$(test "$TYPE" == "minimal" && echo "2" || echo "4")"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002034 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^kafka\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002035 espin "$NOT_VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07002036 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" -f $_TMP"
David Bainbridgec7220622020-05-28 12:31:47 -07002037 helm_install - "$INFRA_NS" kafka "$KAFKA_CHART" "$KAFKA_CHART_VERSION" kafka "$_HELM_DESC external Kafka cluster"
David Bainbridge76afd812020-04-06 09:53:52 -07002038 else
David Bainbridged18f4942020-04-14 16:46:13 -07002039 espin "$VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07002040 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002041 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for Kafka cluster to start" "$NO_LABEL" "kafka-.*"
David Bainbridge76afd812020-04-06 09:53:52 -07002042 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002043 NOW="$(date +%s)"
2044 printtime $((NOW - STIME))
David Bainbridge76afd812020-04-06 09:53:52 -07002045 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002046 rm -rf "$_TMP"
David Bainbridge76afd812020-04-06 09:53:52 -07002047fi
2048
David Bainbridged18f4942020-04-14 16:46:13 -07002049STIME="$(date +%s)"
David Bainbridgeed476572020-06-02 14:05:45 -07002050EXPECT=2
2051# therecanbeonlyone set hardcoded to true for backward compatibility
2052INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set therecanbeonlyone=true"
Matteo Scandolo67335f02020-04-09 11:19:53 -07002053case $WITH_ETCD in
David Bainbridge76afd812020-04-06 09:53:52 -07002054 no)
David Bainbridge76afd812020-04-06 09:53:52 -07002055 ;;
David Bainbridgec7220622020-05-28 12:31:47 -07002056 yes|external)
2057 _HOST="etcd.$INFRA_NS.svc"
David Bainbridge76afd812020-04-06 09:53:52 -07002058 _PORT=2379
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002059 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
Neha Sharmaa1c92ca2020-06-24 11:50:33 +00002060 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.address=$_HOST:$_PORT"
David Bainbridge76afd812020-04-06 09:53:52 -07002061 ;;
2062 *)
David Bainbridged18f4942020-04-14 16:46:13 -07002063 _HOST="$(echo "$WITH_ETCD" | cut -d: -f1)"
2064 _PORT="$(echo "$WITH_ETCD" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07002065 _PORT=${_PORT:-2379}
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002066 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
Neha Sharmaa1c92ca2020-06-24 11:50:33 +00002067 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.address=$_HOST:$_PORT"
David Bainbridge76afd812020-04-06 09:53:52 -07002068 ;;
2069esac
2070case $WITH_KAFKA in
2071 no)
David Bainbridge76afd812020-04-06 09:53:52 -07002072 ;;
David Bainbridgec7220622020-05-28 12:31:47 -07002073 yes|external)
2074 _HOST=kafka.$INFRA_NS.svc
David Bainbridge76afd812020-04-06 09:53:52 -07002075 _PORT=9092
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002076 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"
2077 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.kafka.adapter.address=$_HOST:$_PORT --set services.kafka.cluster.address=$_HOST:$_PORT"
David Bainbridge76afd812020-04-06 09:53:52 -07002078 ;;
2079 *)
David Bainbridged18f4942020-04-14 16:46:13 -07002080 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
2081 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07002082 _PORT=${_PORT:-9092}
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002083 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"
2084 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.kafka.adapter.address=$_HOST:$_PORT --set services.kafka.cluster.address=$_HOST:$_PORT"
David Bainbridge76afd812020-04-06 09:53:52 -07002085 ;;
2086esac
2087
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002088if is_in "$WITH_ONOS" "legacy"; then
David Bainbridgec7220622020-05-28 12:31:47 -07002089 _HOST=onos-openflow.$INFRA_NS.svc
David Bainbridge76afd812020-04-06 09:53:52 -07002090 _PORT=6653
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002091elif is_in "$WITH_ONOS" "yes,classic"; then
David Bainbridgec7220622020-05-28 12:31:47 -07002092 _HOST=onos-onos-classic-hs.$INFRA_NS.svc
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002093 _PORT=6653
David Bainbridged18f4942020-04-14 16:46:13 -07002094elif [ "$WITH_ONOS" != "no" ]; then
2095 _HOST="$(echo "$WITH_ONOS" | cut -d: -f1)"
2096 _PORT="$(echo "$WITH_ONOS" | cut -s -d: -f2)"
David Bainbridge76afd812020-04-06 09:53:52 -07002097 _PORT=${_PORT:-6653}
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002098fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002099
David Bainbridgecf546362020-04-21 23:18:50 -07002100compare_versions "$RESOLVED_VOLTHA_CHART_VERSION" 2.4.2
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002101if [ "$?" == "1" ]; then
2102 # voltha chart > 2.4.2 uses list of controllers
David Bainbridgee4d11ca2020-05-08 10:21:10 -07002103 for NUM in $(seq 0 $((NUM_OF_ONOS-1))); do
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002104 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.controller[$NUM].service=onos-onos-classic-$NUM.onos-onos-classic-hs.$INFRA_NS.svc --set services.controller[$NUM].port=6653"
Neha Sharmaa1c92ca2020-06-24 11:50:33 +00002105 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.controller[$NUM].address=onos-onos-classic-$NUM.onos-onos-classic-hs.$INFRA_NS.svc:6653"
David Bainbridgee4d11ca2020-05-08 10:21:10 -07002106 done
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002107else
2108 # voltha chart <= 2.4.2 uses single controller
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002109 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.controller.service=$_HOST --set services.controller.port=$_PORT"
Neha Sharmaa1c92ca2020-06-24 11:50:33 +00002110 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.controller.address=$_HOST:$_PORT"
David Bainbridge696bc632020-04-05 21:49:37 -07002111fi
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002112
Test Userb5712372019-07-03 21:52:17 +00002113bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002114if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$VOLTHA_NS" "^voltha\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002115 espin "$NOT_VERIFIED"
David Bainbridgea965ca22020-06-09 17:45:04 -07002116 helm_install - "$VOLTHA_NS" voltha "$VOLTHA_CHART" "$VOLTHA_CHART_VERSION" "+voltha" "$_HELM_DESC VOLTHA Core"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002117else
David Bainbridged18f4942020-04-14 16:46:13 -07002118 espin "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002119fi
David Bainbridge696bc632020-04-05 21:49:37 -07002120INTERNAL_EXTRA_HELM_INSTALL_ARGS=
Test Userba1e7e72019-07-10 22:27:54 +00002121
David Bainbridge90fd8e32019-08-21 23:32:47 +00002122VOLTHA="voltha-ofagent-.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002123 rw-core.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002124 voltha-zookeeper-.*"
David Bainbridged18f4942020-04-14 16:46:13 -07002125wait_for_pods - "$VOLTHA_NS" "$EXPECT" "includes" "Waiting for VOLTHA Core to start" "$NO_LABEL" "$VOLTHA"
David Bainbridgee87067b2019-08-12 22:00:12 +00002126if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002127 NOW="$(date +%s)"
2128 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002129fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002130
David Bainbridge46505fb2019-10-01 21:13:20 +00002131if [ "$WITH_ADAPTERS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002132 STIME="$(date +%s)"
David Bainbridge46505fb2019-10-01 21:13:20 +00002133 EXPECT=0
David Bainbridgec7220622020-05-28 12:31:47 -07002134 if is_in "$WITH_ETCD" "yes,external"; then
2135 _HOST=etcd.$INFRA_NS.svc
David Bainbridge3517f6c2020-04-08 12:14:08 -07002136 _PORT=2379
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002137 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
2138 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.address=$_HOST:$_PORT"
David Bainbridged18f4942020-04-14 16:46:13 -07002139 elif [ "$WITH_ETCD" != "no" ]; then
2140 _HOST="$(echo "$WITH_ETCD" | cut -d: -f1)"
2141 _PORT="$(echo "$WITH_ETCD" | cut -s -d: -f2)"
David Bainbridge3517f6c2020-04-08 12:14:08 -07002142 _PORT=${_PORT:-2379}
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002143 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
2144 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.address=$_HOST:$_PORT"
David Bainbridge696bc632020-04-05 21:49:37 -07002145 fi
David Bainbridgec7220622020-05-28 12:31:47 -07002146 if is_in "$WITH_KAFKA" "yes,external"; then
2147 _HOST=kafka.$INFRA_NS.svc
David Bainbridge3517f6c2020-04-08 12:14:08 -07002148 _PORT=9092
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002149 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"
2150 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.kafka.adapter.address=$_HOST:$_PORT --set services.kafka.cluster.address=$_HOST:$_PORT"
David Bainbridged18f4942020-04-14 16:46:13 -07002151 elif [ "$WITH_KAFKA" != "no" ]; then
2152 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
2153 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge3517f6c2020-04-08 12:14:08 -07002154 _PORT=${_PORT:-9092}
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002155 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"
2156 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.kafka.adapter.address=$_HOST:$_PORT --set services.kafka.cluster.address=$_HOST:$_PORT"
David Bainbridge696bc632020-04-05 21:49:37 -07002157 fi
David Bainbridge46505fb2019-10-01 21:13:20 +00002158 echo -e "Verify Adapters $PLUG"
2159 if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then
2160 bspin - "Verify Simulated Adapters installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002161 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$ADAPTER_NS" "^sim\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002162 espin - "$NOT_VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002163 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 +00002164 else
David Bainbridged18f4942020-04-14 16:46:13 -07002165 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00002166 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002167 EXPECT="$((EXPECT + 2))"
David Bainbridge46505fb2019-10-01 21:13:20 +00002168 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07002169
David Bainbridge46505fb2019-10-01 21:13:20 +00002170 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
2171 bspin - "Verify OpenOLT Adapter installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002172 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$ADAPTER_NS" "^open-olt\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002173 espin - "$NOT_VERIFIED"
David Bainbridgea965ca22020-06-09 17:45:04 -07002174 helm_install - "$ADAPTER_NS" open-olt "$VOLTHA_ADAPTER_OPEN_OLT_CHART" "$VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION" "+open-olt" "$_HELM_DESC OpenOLT Adapter"
David Bainbridge46505fb2019-10-01 21:13:20 +00002175 else
David Bainbridged18f4942020-04-14 16:46:13 -07002176 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00002177 fi
Matteo Scandolo67335f02020-04-09 11:19:53 -07002178 EXPECT="$((EXPECT + 1))"
David Bainbridge46505fb2019-10-01 21:13:20 +00002179 bspin - "Verify OpenONU Adapter installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002180 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$ADAPTER_NS" "^open-onu\$")" -ne 1 ]; then
Matteo Scandolo67335f02020-04-09 11:19:53 -07002181 _ORIGINAL_EXTRA_HELM_INSTALL_ARGS="$INTERNAL_EXTRA_HELM_INSTALL_ARGS"
2182 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set replicas.adapter_open_onu=$NUM_OF_OPENONU"
Girish Gowdra4cc5d8b2020-06-11 17:12:00 -07002183 if [ "$WITH_INCREMENTAL_EVTO_UPDATE" == "yes" ]; then
Girish Gowdra1c7ad4c2020-06-26 13:35:16 -07002184 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set defaults.incremental_evto_update=true"
Girish Gowdra4cc5d8b2020-06-11 17:12:00 -07002185 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002186 espin - "$NOT_VERIFIED"
David Bainbridgea965ca22020-06-09 17:45:04 -07002187 helm_install - "$ADAPTER_NS" open-onu "$VOLTHA_ADAPTER_OPEN_ONU_CHART" "$VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION" "+open-onu" "$_HELM_DESC OpenONU Adapter"
Matteo Scandolo67335f02020-04-09 11:19:53 -07002188 INTERNAL_EXTRA_HELM_INSTALL_ARGS="$_ORIGINAL_EXTRA_HELM_INSTALL_ARGS"
David Bainbridge46505fb2019-10-01 21:13:20 +00002189 else
David Bainbridged18f4942020-04-14 16:46:13 -07002190 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00002191 fi
Matteo Scandolo67335f02020-04-09 11:19:53 -07002192 EXPECT=$((EXPECT + NUM_OF_OPENONU))
David Bainbridge46505fb2019-10-01 21:13:20 +00002193 fi
David Bainbridge696bc632020-04-05 21:49:37 -07002194 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07002195
David Bainbridge46505fb2019-10-01 21:13:20 +00002196 ADAPTERS="adapter-.*"
David Bainbridged18f4942020-04-14 16:46:13 -07002197 wait_for_pods - "$ADAPTER_NS" "$EXPECT" "includes" "Waiting for adapters to start" "$NO_LABEL" "$ADAPTERS"
David Bainbridge46505fb2019-10-01 21:13:20 +00002198 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002199 NOW="$(date +%s)"
2200 printtime $((NOW - STIME))
David Bainbridge46505fb2019-10-01 21:13:20 +00002201 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00002202fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002203
David Bainbridged18f4942020-04-14 16:46:13 -07002204if [ "$WITH_BBSIM" == "yes" ]; then
2205 STIME="$(date +%s)"
Test User7d866122019-07-09 17:52:35 +00002206 echo -e "Verify BBSIM $PLUG"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002207 bspin - "Verify BBSIM Installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002208 for instance in $(seq 0 $((NUM_OF_BBSIM-1))); do
Matteo Scandoloc2eb0672020-05-01 14:43:15 -07002209
2210 if [ "$LEGACY_BBSIM_INDEX" == "yes" ]; then
2211 if [ "$instance" -eq 0 ]; then
2212 instance_num=""
2213 else
2214 instance_num=$instance
2215 fi
David K. Bainbridge43422402020-03-06 07:41:22 -08002216 else
2217 instance_num=$instance
2218 fi
Matteo Scandoloc2eb0672020-05-01 14:43:15 -07002219
2220
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002221 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$BBSIM_NS" "^bbsim${instance_num}\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002222 espin - "$NOT_VERIFIED"
2223 S_TAG="$((900+instance))"
Matteo Scandolo5a149572020-04-01 10:14:57 -07002224 INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set olt_id=$instance,s_tag=$S_TAG"
David Bainbridged9329af2020-05-01 11:58:52 -07002225 if [ "$WITH_EAPOL" == "yes" ]; then
2226 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set auth=true"
2227 else
2228 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set auth=false"
2229 fi
2230 if [ "$WITH_DHCP" == "yes" ]; then
2231 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set dhcp=true"
2232 else
2233 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set dhcp=false"
2234 fi
David Bainbridge33e56c72020-06-11 11:39:56 -07002235 if is_in "$WITH_KAFKA" "yes,external"; then
2236 _HOST=kafka.$INFRA_NS.svc
2237 _PORT=9092
2238 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafkaAddress=$_HOST:$_PORT"
2239 elif [ "$WITH_KAFKA" != "no" ]; then
2240 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
2241 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
2242 _PORT=${_PORT:-9092}
2243 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafkaAddress=$_HOST:$_PORT"
2244 fi
2245 helm_install - "$BBSIM_NS" "bbsim${instance_num}" "$VOLTHA_BBSIM_CHART" "$VOLTHA_BBSIM_CHART_VERSION" "+bbsim" "$_HELM_DESC BBSIM${instance_num}"
David Bainbridge2eaf2cf2020-03-18 12:54:08 -07002246 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
David K. Bainbridge43422402020-03-06 07:41:22 -08002247 else
David Bainbridged18f4942020-04-14 16:46:13 -07002248 espin - "$VERIFIED"
David K. Bainbridge43422402020-03-06 07:41:22 -08002249 fi
2250 done
David Bainbridged18f4942020-04-14 16:46:13 -07002251 wait_for_pods - "$BBSIM_NS" "$NUM_OF_BBSIM" "includes" "Waiting for BBSIM to start" "$BBSIM_LABEL" "bbsim*"
David Bainbridgee87067b2019-08-12 22:00:12 +00002252 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002253 NOW="$(date +%s)"
2254 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002255 fi
Test User7d866122019-07-09 17:52:35 +00002256fi
2257
divyadesai59f987a2020-05-27 12:11:33 +00002258if [ "$WITH_EFK" == "yes" ]; then
2259 STIME="$(date +%s)"
2260 echo -e "Verify EFK $PLUG"
2261 bspin - "Verify EFK Installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002262 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^elasticsearch\$")" -ne 1 ] || [ "$(helm_is_deployed "$INFRA_NS" "^kibana\$")" -ne 1 ] || [ "$(helm_is_deployed "$INFRA_NS" "^fluentd\$")" -ne 1 ]; then
divyadesai59f987a2020-05-27 12:11:33 +00002263 espin - "$NOT_VERIFIED"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002264 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^elasticsearch\$")" -ne 1 ]; then
divyadesai59f987a2020-05-27 12:11:33 +00002265 helm_install - "$INFRA_NS" elasticsearch "$ELASTICSEARCH_CHART" "$ELASTICSEARCH_CHART_VERSION" elasticsearch "$_HELM_DESC elasticsearch"
2266 fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002267 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^kibana\$")" -ne 1 ]; then
divyadesai59f987a2020-05-27 12:11:33 +00002268 helm_install - "$INFRA_NS" kibana "$KIBANA_CHART" "$KIBANA_CHART_VERSION" kibana "$_HELM_DESC kibana"
2269 fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002270 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^fluentd\$")" -ne 1 ]; then
divyadesai59f987a2020-05-27 12:11:33 +00002271 helm_install - "$INFRA_NS" fluentd "$FLUENTD_ELASTICSEARCH_CHART" "$FLUENTD_ELASTICSEARCH_CHART_VERSION" fluentd-elasticsearch "$_HELM_DESC fluentd-elasticsearch"
2272 fi
2273 else
2274 espin - "$VERIFIED"
2275 fi
2276 EXPECT=2 # for elastic and kibana
2277 if [ "$TYPE" == "minimal" ]; then
2278 EXPECT=$((EXPECT + 2)) # for fluentd on worker 2 worker nodes
2279 else
2280 EXPECT=$((EXPECT + 3)) # for fluentd on worker 3 worker nodes
2281 fi
2282 if [ "$SCHEDULE_ON_CONTROL_NODES" == "yes" ]; then
2283 EXPECT=$((EXPECT + 1)) # for fluentd on the control plan node
2284 fi
2285
2286 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for EFK to start" "$NO_LABEL" "fluentd-* elasticsearch-* kibana-*"
2287 if [ "$WITH_TIMINGS" == "yes" ]; then
2288 NOW="$(date +%s)"
2289 printtime $((NOW - STIME))
2290 fi
2291fi
2292
David Bainbridge309099c2020-05-05 08:47:29 -07002293if [ "$CONFIG_SADIS" == "external" ]; then
2294 STIME="$(date +%s)"
2295 echo -e "Verify BBSIM SADIS Service $PLUG"
2296 bspin - "Verify required configmap"
2297 (set -x; kubectl -n "$BBSIM_NS" delete --ignore-not-found configmap kube-config >>"$LOG" 2>&1) >>"$LOG" 2>&1
2298 (set -x; kubectl -n "$BBSIM_NS" create configmap kube-config "--from-file=kube_config=$KUBECONFIG" >>"$LOG" 2>&1) >>"$LOG" 2>&1
2299 espin - "$VERIFIED"
2300 bspin - "Verify BBSIM SADIS Service Installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002301 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$BBSIM_NS" "^bbsim-sadis-server\$")" -ne 1 ]; then
David Bainbridge309099c2020-05-05 08:47:29 -07002302 espin - "$NOT_VERIFIED"
Matteo Scandolo871fd982020-07-23 11:46:51 -07002303 INTERNAL_EXTRA_HELM_INSTALL_ARGS="$EXTRA_HELM_FLAGS" helm_install - "$BBSIM_NS" bbsim-sadis-server "$BBSIM_SADIS_SERVER_CHART" "$BBSIM_SADIS_SERVER_CHART_VERSION" "+sadis" "$_HELM_DESC BBSIM SADIS Server"
2304 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
David Bainbridge309099c2020-05-05 08:47:29 -07002305 else
2306 espin - "$VERIFIED"
2307 fi
2308 wait_for_pods - "$BBSIM_NS" 1 "includes" "Waiting for BBSIM SADIS Server to start" "$NO_LABEL" "bbsim-sadis-server-.*"
Ubuntu7135e6a2020-06-30 01:46:08 +00002309
Matteo Scandolo21660442020-07-17 11:05:21 -07002310 if is_in "$WITH_ONOS" "yes,classic,legacy"; then
Ubuntu7135e6a2020-06-30 01:46:08 +00002311 if kubectl get -n "$BBSIM_NS" svc/bbsim-sadis-server-bbsim-sadis-server >/dev/null 2>&1; then
2312 BBSIM_SADIS_SVC="bbsim-sadis-server-bbsim-sadis-server"
2313 else
2314 BBSIM_SADIS_SVC="bbsim-sadis-server"
2315 fi
2316 push_onos_config "json" \
2317 "[optional] Push ONOS configuration for custom SADIS and Bandwidth Profile servers" \
2318 "network/configuration/apps/org.opencord.sadis" \
2319 "$(cat <<EOJ | tr -d '[:space:]'
2320{
2321 "sadis": {
2322 "integration": {
2323 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:58080/subscribers/%s",
2324 "cache": {
2325 "enabled": true,
2326 "maxsize": 50,
2327 "ttl": "PT1m"
2328 }
2329 }
2330 },
2331 "bandwidthprofile": {
2332 "integration": {
2333 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:58080/profiles/%s",
2334 "cache": {
2335 "enabled": true,
2336 "maxsize": 50,
2337 "ttl": "PT1m"
2338 }
2339 }
2340 }
2341}
2342EOJ
2343)"
2344 fi
David Bainbridge309099c2020-05-05 08:47:29 -07002345 if [ "$WITH_TIMINGS" == "yes" ]; then
2346 NOW="$(date +%s)"
2347 printtime $((NOW - STIME))
2348 fi
2349fi
2350
David Bainbridged18f4942020-04-14 16:46:13 -07002351if [ "$WITH_RADIUS" == "yes" ]; then
2352 STIME="$(date +%s)"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002353 echo -e "Verify RADIUS $LOCK"
2354 bspin - "Verify RADIUS Installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002355 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^radius\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002356 espin - "$NOT_VERIFIED"
David Bainbridge879439b2020-06-12 15:59:35 -07002357 helm_install - "$INFRA_NS" radius "$RADIUS_CHART" "$RADIUS_CHART_VERSION" "+radius" "$_HELM_DESC RADIUS"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002358 else
David Bainbridged18f4942020-04-14 16:46:13 -07002359 espin - "$VERIFIED"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002360 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002361 wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for RADIUS to start" "$NO_LABEL" "radius-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00002362 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002363 NOW="$(date +%s)"
2364 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002365 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002366fi
2367
David Bainbridged18f4942020-04-14 16:46:13 -07002368if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
2369 STIME="$(date +%s)"
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002370 bspin - "Forward VOLTHA API port $FORWARD"
David Bainbridge1d2c5842020-06-03 15:29:07 -07002371 kill_port_forward voltha-api voltha-voltha-api
2372 VOLTHA_PREFIX=
2373 if kubectl get -n "$VOLTHA_NS" "svc/voltha-voltha-api" >/dev/null 2>&1; then
2374 VOLTHA_PREFIX="voltha-"
2375 fi
Matteo Scandolo21660442020-07-17 11:05:21 -07002376
David Bainbridge1d2c5842020-06-03 15:29:07 -07002377 port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-api" "$VOLTHA_API_PORT:55555"
David Bainbridged18f4942020-04-14 16:46:13 -07002378 espin - "$VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002379 if is_in "$WITH_ETCD" "yes,external"; then
David Bainbridge696bc632020-04-05 21:49:37 -07002380 bspin - "Forward VOLTHA ETCD port $FORWARD"
David Bainbridgec7220622020-05-28 12:31:47 -07002381 kill_port_forward "etcd"
2382 port_forward "$INFRA_NS" "etcd" "$VOLTHA_ETCD_PORT:2379"
David Bainbridged18f4942020-04-14 16:46:13 -07002383 espin - "$VERIFIED"
David Bainbridge696bc632020-04-05 21:49:37 -07002384 fi
David Bainbridgec7220622020-05-28 12:31:47 -07002385 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridge696bc632020-04-05 21:49:37 -07002386 bspin - "Forward VOLTHA Kafka port $FORWARD"
David Bainbridgec7220622020-05-28 12:31:47 -07002387 kill_port_forward "kafka"
2388 port_forward "$INFRA_NS" kafka "$VOLTHA_KAFKA_PORT:9092"
David Bainbridged18f4942020-04-14 16:46:13 -07002389 espin - "$VERIFIED"
David Bainbridge696bc632020-04-05 21:49:37 -07002390 fi
divyadesai59f987a2020-05-27 12:11:33 +00002391 if [ "$WITH_EFK" == "yes" ]; then
2392 bspin - "Forward EFK port $FORWARD"
2393 kill_port_forward elasticsearch-master
2394 kill_port_forward kibana-kibana
2395 port_forward "$INFRA_NS" elasticsearch-master "$ELASTICSEARCH_PORT:9200"
2396 port_forward "$INFRA_NS" kibana-kibana "$KIBANA_PORT:5601"
2397 espin - "$VERIFIED"
2398 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -07002399 if [ "$WITH_PPROF" == "yes" ]; then
David Bainbridge1d2c5842020-06-03 15:29:07 -07002400 VOLTHA_OPENOLT_PREFIX=
2401 if kubectl get -n "$ADAPTER_NS" "svc/open-olt-adapter-open-olt-profiler" >/dev/null 2>&1; then
2402 VOLTHA_OPENOLT_PREFIX="open-olt-"
2403 fi
David Bainbridge879439b2020-06-12 15:59:35 -07002404 bspin - "Forward PProf ports port $FORWARD"
2405 kill_port_forward voltha-rw-core-profiler voltha-voltha-rw-core-profiler
2406 kill_port_forward adapter-open-olt-profiler open-olt-adapter-open-olt-profiler
2407 kill_port_forward voltha-of-agent-profiler voltha-voltha-of-agent-profiler
2408 port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-rw-core-profiler" "$VOLTHA_PPROF_PORT:6060"
2409 port_forward "$ADAPTER_NS" "${VOLTHA_OPENOLT_PREFIX}adapter-open-olt-profiler" "$OPENOLT_PPROF_PORT:6060"
2410 port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-of-agent-profiler" "$OFAGENT_PPROF_PORT:6060"
2411 espin - "$VERIFIED"
Matteo Scandoloefee0432020-05-05 13:56:20 -07002412 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002413 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002414 NOW="$(date +%s)"
2415 printtime $((NOW - STIME))
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002416 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00002417fi
Test User3d7ad8e2019-07-03 06:15:44 +00002418
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002419if is_in "$WITH_ONOS" "yes,legacy,classic" && [ "$WITH_RADIUS" != "no" ]; then
David Bainbridge879439b2020-06-12 15:59:35 -07002420 SVC_NAME=radius
2421 if kubectl get -n "$INFRA_NS" "svc/radius-freeradius" >/dev/null 2>&1; then
2422 SVC_NAME="radius-freeradius"
2423 fi
2424 _HOST="$SVC_NAME.$INFRA_NS.svc"
David Bainbridge696bc632020-04-05 21:49:37 -07002425 _PORT=1812
David Bainbridged18f4942020-04-14 16:46:13 -07002426 if [ "$WITH_RADIUS" != "yes" ]; then
2427 _HOST="$(echo "$WITH_RADIUS" | cut -d: -f1)"
2428 _PORT="$(echo "$WITH_RADIUS" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07002429 _PORT=${_PORT:-1812}
2430 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002431 bspin "Configure ONOS RADIUS Connection $GEAR"
David Bainbridged18f4942020-04-14 16:46:13 -07002432 (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
2433 espin "$VERIFIED"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002434fi
2435
divyadesai59f987a2020-05-27 12:11:33 +00002436if [ "$WITH_EFK" == "yes" ]; then
2437 do_curl "" "POST" "" "" "http://localhost:$KIBANA_PORT/api/saved_objects/index-pattern/logst*" "json" '{"attributes":{"title":"logst*","timeFieldName":"@timestamp"}}' "Verify logging index in EFK" "409,200" "-H Content-type:application/json -H kbn-xsrf:true" "$GEAR"
2438# fi
2439fi
2440
David Bainbridge99ac7a22019-08-31 02:26:43 +00002441if [ "$WITH_CHAOS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002442 STIME="$(date +%s)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002443 echo -e "Verify kube-monkey $LOCK"
2444 bspin - "Verify kube-monkey Installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002445 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed kube-monkey "^monkey\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002446 espin - "$NOT_VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002447 helm_install - kube-monkey monkey ./kube-monkey/helm/kubemonkey latest - "$_HELM_DESC Chaos Monkey"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002448 else
David Bainbridged18f4942020-04-14 16:46:13 -07002449 espin - "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002450 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002451 wait_for_pods - "kube-monkey" 1 "includes" "Waiting for Chaos to start" "$NO_LABEL" "monkey-.*"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002452 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002453 NOW="$(date +%s)"
2454 printtime $((NOW - STIME))
David Bainbridge99ac7a22019-08-31 02:26:43 +00002455 fi
2456fi
2457
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002458bspin "Create voltctl configuration file"
David Bainbridged18f4942020-04-14 16:46:13 -07002459(set -x; mkdir -p "$HOME/.volt" >>"$LOG" 2>&1) >>"$LOG" 2>&1
2460MIN_VC_VERSION="$(echo -e "1.0.15\n$VC_VERSION" | sort -V | head -1)"
2461if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002462 KAFKA_FLAG="-k localhost:$VOLTHA_KAFKA_PORT"
2463 SERVER_FLAG="-s localhost:$VOLTHA_API_PORT"
2464 ETCD_FLAG=
2465 if [ "$MIN_VC_VERSION" == "1.0.15" ]; then
2466 ETCD_FLAG="-e localhost:$VOLTHA_ETCD_PORT"
2467 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002468else
David Bainbridgec7220622020-05-28 12:31:47 -07002469 KAFKA_FLAG="-k $(get_service_ep "$INFRA_NS" kafka)"
David Bainbridged18f4942020-04-14 16:46:13 -07002470 SERVER_FLAG="-s $(get_service_ep "$VOLTHA_NS" voltha-api)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002471 ETCD_FLAG=
2472 if [ "$MIN_VC_VERSION" == "1.0.15" ]; then
David Bainbridgec7220622020-05-28 12:31:47 -07002473 ETCD_FLAG="-e $(get_service_ep "$INFRA_NS" etcd)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002474 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002475fi
David Bainbridgea965ca22020-06-09 17:45:04 -07002476CMD=("voltctl $KAFKA_FLAG $SERVER_FLAG $ETCD_FLAG config")
David Bainbridged18f4942020-04-14 16:46:13 -07002477(set -x; ${CMD[*]} > "$HOME/.volt/config-$NAME" 2>>"$LOG") >>"$LOG" 2>&1
David Bainbridgea965ca22020-06-09 17:45:04 -07002478#(set -x; voltctl "$KAFKA_FLAG" "$SERVER_FLAG" "$ETCD_FLAG" config > "$HOME/.volt/config-$NAME" 2>>"$LOG") >>"$LOG" 2>&1
David Bainbridged18f4942020-04-14 16:46:13 -07002479espin "$VERIFIED"
Test User08ebbd92019-07-03 17:15:39 +00002480
David Bainbridge0774b232019-08-02 06:37:19 +00002481if [ ! -f "$NAME-env.sh" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002482 touch "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002483fi
2484
David Bainbridge596f30d2019-07-30 17:07:59 +00002485for O in $ALL_OPTIONS; do
David Bainbridged18f4942020-04-14 16:46:13 -07002486 VAL="$(eval echo "\$$O")"
2487 if [ -n "$VAL" ] && [ "$(grep -c "^export $O=" "$NAME-env.sh")" -eq 0 ]; then
2488 echo "export $O=\"$(eval echo "\$$O")\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002489 fi
2490done
2491
David Bainbridged18f4942020-04-14 16:46:13 -07002492if [ "$DEPLOY_K8S" == "yes" ] && [ "$(grep -c "^export KUBECONFIG=" "$NAME-env.sh")" -eq 0 ]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002493 echo "export KUBECONFIG=\"$HOME/.kube/kind-config-voltha-$NAME\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002494fi
2495
David Bainbridged18f4942020-04-14 16:46:13 -07002496if [ "$(grep -c "^export VOLTCONFIG=" "$NAME-env.sh")" -eq 0 ]; then
2497 echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002498fi
2499
David Bainbridged18f4942020-04-14 16:46:13 -07002500if [ "$(grep -c "^export PATH=" "$NAME-env.sh")" -eq 0 ]; then
2501 echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002502fi
2503
Test User7d866122019-07-09 17:52:35 +00002504echo ""
David Bainbridged18f4942020-04-14 16:46:13 -07002505echo "Please issue the following commands in your terminal to ensure that you" | tee -a "$LOG"
2506echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a "$LOG"
2507echo "tools required by VOLTHA in your command path. " | tee -a "$LOG"
2508echo "" | tee -a "$LOG"
2509echo -en "$BOLD"
2510if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002511 echo "export KUBECONFIG=\"$HOME/.kube/kind-config-voltha-$NAME\"" | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00002512fi
David Bainbridged18f4942020-04-14 16:46:13 -07002513echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" | tee -a "$LOG"
2514echo "export PATH=$GOPATH/bin:\$PATH" | tee -a "$LOG"
2515echo -en "$NORMAL"
2516echo "" | tee -a "$LOG"
2517echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a "$LOG"
Test User08ebbd92019-07-03 17:15:39 +00002518
David Bainbridge712afb82019-08-14 19:55:58 +00002519if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002520 NOW="$(date +%s)"
2521 echo -e "$CLOCK ${BOLD}TOTAL: $(duration $((NOW - TOTAL_START_TIME)))${NORMAL}"
David Bainbridge712afb82019-08-14 19:55:58 +00002522fi