blob: 41a8bc125e8eb631f7c1bd33b23b0701b1ca7b49 [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
Matteo Scandolo657e13c2020-07-28 11:41:42 -070068NAME=${NAME:-minimal}
David K. Bainbridge484d80c2020-03-05 21:44:34 -080069
70ENABLE_ONOS_EXTRANEOUS_RULES=${ENABLE_ONOS_EXTRANEOUS_RULES:-no}
David Bainbridge76afd812020-04-06 09:53:52 -070071INFRA_NS=${INFRA_NS:-default}
72VOLTHA_NS=${VOLTHA_NS:-voltha}
73BBSIM_NS=${BBSIM_NS:-voltha}
74ADAPTER_NS=${ADAPTER_NS:-voltha}
David Bainbridgee87067b2019-08-12 22:00:12 +000075WITH_TIMINGS=${WITH_TIMINGS:-no}
Test User7d866122019-07-09 17:52:35 +000076WITH_BBSIM=${WITH_BBSIM:-no}
divyadesai59f987a2020-05-27 12:11:33 +000077WITH_EFK=${WITH_EFK:-no}
David Bainbridge5b7b96b2019-07-25 20:29:13 +000078WITH_RADIUS=${WITH_RADIUS:-no}
Matteo Scandolo78dfee02020-02-13 16:18:03 -080079WITH_EAPOL=${WITH_EAPOL:-yes}
80WITH_DHCP=${WITH_DHCP:-yes}
81WITH_IGMP=${WITH_IGMP:-no}
David Bainbridgeb270c202019-07-26 01:44:42 +000082WITH_ONOS=${WITH_ONOS:-yes}
David Bainbridge60ffc0f2020-04-27 22:13:22 -070083NUM_OF_ONOS=${NUM_OF_ONOS:-1}
84NUM_OF_ATOMIX=${NUM_OF_ATOMIX:-0}
David Bainbridge99ac7a22019-08-31 02:26:43 +000085WITH_CHAOS=${WITH_CHAOS:-no}
David Bainbridge46505fb2019-10-01 21:13:20 +000086WITH_ADAPTERS=${WITH_ADAPTERS:-yes}
David K. Bainbridgeda33d652020-03-06 10:31:23 -080087WITH_SIM_ADAPTERS=${WITH_SIM_ADAPTERS:-no}
David Bainbridge46505fb2019-10-01 21:13:20 +000088WITH_OPEN_ADAPTERS=${WITH_OPEN_ADAPTERS:-yes}
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -080089WITH_PORT_FORWARDS=${WITH_PORT_FORWARDS:-yes}
David Bainbridge696bc632020-04-05 21:49:37 -070090WITH_KAFKA=${WITH_KAFKA:-yes}
91WITH_ETCD=${WITH_ETCD:-yes}
Matteo Scandoloefee0432020-05-05 13:56:20 -070092WITH_PPROF=${WITH_PPROF:-no}
Girish Gowdra4cc5d8b2020-06-11 17:12:00 -070093WITH_INCREMENTAL_EVTO_UPDATE=${WITH_INCREMENTAL_EVTO_UPDATE:-no}
David Bainbridgee4d11ca2020-05-08 10:21:10 -070094SCHEDULE_ON_CONTROL_NODES=${SCHEDULE_ON_CONTROL_NODES:-no}
David Bainbridge309099c2020-05-05 08:47:29 -070095CONFIG_SADIS=${CONFIG_SADIS:-no} # yes | no | file | bbsim | external | URL
Hardik Windlassb3147602020-03-09 16:59:15 +053096SADIS_CFG=${SADIS_CFG:-onos-files/onos-sadis-sample.json}
David Bainbridge27790d62019-08-13 22:43:19 +000097INSTALL_ONOS_APPS=${INSTALL_ONOS_APPS:-no}
Test Userba1e7e72019-07-10 22:27:54 +000098JUST_K8S=${JUST_K8S:-no}
99DEPLOY_K8S=${DEPLOY_K8S:-yes}
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700100INSTALL_KUBECTL=${INSTALL_KUBECTL:-yes}
101INSTALL_HELM=${INSTALL_HELM:-yes}
David Bainbridge7f8bf992020-04-08 21:53:22 -0700102HELM_USE_UPGRADE=${HELM_USE_UPGRADE:-no}
David Bainbridge46505fb2019-10-01 21:13:20 +0000103UPDATE_HELM_REPOS=${UPDATE_HELM_REPOS:-yes}
Matteo Scandolofab98622020-01-28 15:17:20 -0800104WAIT_ON_DOWN=${WAIT_ON_DOWN:-yes}
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700105WAIT_TIMEOUT=${WAIT_TIMEOUT:-30m}
106VOLTHA_DOWN_ON_TIMEOUT=${VOLTHA_DOWN_ON_TIMEOUT:-no}
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000107VOLTHA_LOG_LEVEL=${VOLTHA_LOG_LEVEL:-WARN}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000108VOLTHA_CHART=${VOLTHA_CHART:-onf/voltha}
109VOLTHA_CHART_VERSION=${VOLTHA_CHART_VERSION:-latest}
110VOLTHA_BBSIM_CHART=${VOLTHA_BBSIM_CHART:-onf/bbsim}
Matteo Scandolodcd29f52019-10-07 15:42:42 -0700111VOLTHA_BBSIM_CHART_VERSION=${VOLTHA_BBSIM_CHART_VERSION:-latest}
divyadesai59f987a2020-05-27 12:11:33 +0000112ELASTICSEARCH_CHART=${ELASTICSEARCH_CHART:-elastic/elasticsearch}
113ELASTICSEARCH_CHART_VERSION=${ELASTICSEARCH_CHART_VERSION:-latest}
114KIBANA_CHART=${KIBANA_CHART:-elastic/kibana}
115KIBANA_CHART_VERSION=${KIBANA_CHART_VERSION:-latest}
116FLUENTD_ELASTICSEARCH_CHART=${FLUENTD_ELASTICSEARCH_CHART:-kiwigrid/fluentd-elasticsearch}
117FLUENTD_ELASTICSEARCH_CHART_VERSION=${FLUENTD_ELASTICSEARCH_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000118VOLTHA_ADAPTER_SIM_CHART=${VOLTHA_ADAPTER_SIM_CHART:-onf/voltha-adapter-simulated}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000119VOLTHA_ADAPTER_SIM_CHART_VERSION=${VOLTHA_ADAPTER_SIM_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000120VOLTHA_ADAPTER_OPEN_OLT_CHART=${VOLTHA_ADAPTER_OPEN_OLT_CHART:-onf/voltha-adapter-openolt}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000121VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION=${VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000122VOLTHA_ADAPTER_OPEN_ONU_CHART=${VOLTHA_ADAPTER_OPEN_ONU_CHART:-onf/voltha-adapter-openonu}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000123VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION=${VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION:-latest}
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800124ONOS_CHART=${ONOS_CHART:-onf/onos}
Andrea Campanella21323292019-12-18 11:44:19 -0800125ONOS_CHART_VERSION=${ONOS_CHART_VERSION:-latest}
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700126ONOS_CLASSIC_CHART=${ONOS_CLASSIC_CHART:-onos/onos-classic}
Andrea Campanella5b801702020-07-30 10:16:22 +0200127ONOS_CLASSIC_CHART_VERSION=${ONOS_CLASSIC_CHART_VERSION:-latest}
David Bainbridgecf546362020-04-21 23:18:50 -0700128KAFKA_CHART=${KAFKA_CHART:-incubator/kafka}
David Bainbridgeb4bbde12020-06-25 14:46:36 -0700129KAFKA_CHART_VERSION=${KAFKA_CHART_VERSION:=latest}
David Bainbridge309099c2020-05-05 08:47:29 -0700130BBSIM_SADIS_SERVER_CHART=${BBSIM_SADIS_SERVER_CHART:-bbsim-sadis/bbsim-sadis-server}
131BBSIM_SADIS_SERVER_CHART_VERSION=${BBSIM_SADIS_SERVER_CHART_VERSION:-latest}
David Bainbridgeb4bbde12020-06-25 14:46:36 -0700132ETCD_CHART=${ETCD_CHART:-etcd/etcd}
David Bainbridgec7220622020-05-28 12:31:47 -0700133ETCD_CHART_VERSION=${ETCD_CHART_VERSION:-latest}
David Bainbridge879439b2020-06-12 15:59:35 -0700134RADIUS_CHART=${RADIUS_CHART:-onf/freeradius}
135RADIUS_CHART_VERSION=${RADIUS_CHART_VERSION:-latest}
David Bainbridge2eaf2cf2020-03-18 12:54:08 -0700136EXTRA_HELM_INSTALL_ARGS=${EXTRA_HELM_INSTALL_ARGS:-}
137INTERNAL_EXTRA_HELM_INSTALL_ARGS=
uottrembb16d3982020-02-28 08:34:36 +0100138NUM_OF_BBSIM=${NUM_OF_BBSIM:-1}
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700139NUM_OF_WORKER_NODES=${NUM_OF_WORKER_NODES:-2}
140NUM_OF_CONTROLLER_NODES=${NUM_OF_CONTROLLER_NODES:-1}
Matteo Scandolo67335f02020-04-09 11:19:53 -0700141NUM_OF_OPENONU=${NUM_OF_OPENONU:-1}
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700142NUM_OF_KAFKA=${NUM_OF_KAFKA:-1}
143NUM_OF_ETCD=${NUM_OF_ETCD:-1}
uottrembb16d3982020-02-28 08:34:36 +0100144MAX_NUM_OF_BBSIM=10
Matteo Scandolo67335f02020-04-09 11:19:53 -0700145MAX_NUM_OF_OPENONU=10
Matteo Scandoloc2eb0672020-05-01 14:43:15 -0700146LEGACY_BBSIM_INDEX=${LEGACY_BBSIM_INDEX:-no}
David Bainbridgeb4bbde12020-06-25 14:46:36 -0700147PF_ADDRESS=${PF_ADDRESS:-0.0.0.0}
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700148KIND_CFG_FILE=${KIND_CFG_FILE:-}
Test Userba1e7e72019-07-10 22:27:54 +0000149
David Bainbridged18f4942020-04-14 16:46:13 -0700150HOSTOS="$(uname -s | tr "[:upper:]" "[:lower:"])"
151HOSTARCH="$(uname -m | tr "[:upper:]" "[:lower:"])"
152if [ "$HOSTARCH" == "x86_64" ]; then
Test Userba1e7e72019-07-10 22:27:54 +0000153 HOSTARCH="amd64"
154fi
David Bainbridge7db44002020-04-09 12:54:29 -0700155BBSIM_LABEL="-l app=bbsim"
David Bainbridged18f4942020-04-14 16:46:13 -0700156NO_LABEL=
Test User7d866122019-07-09 17:52:35 +0000157
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700158# checks to see if a given WORD is in the given LIST of words
159function is_in() {
160 local WORD LIST
161 WORD="$1"; shift
162 LIST="$*"
163 LIST=${LIST//+([[:space:],|])/:}
164
165 [ "$(echo ":$LIST:" | grep -ic ":$WORD:")" -ne 0 ]
166}
167
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700168function parseDuration() {
David Bainbridged18f4942020-04-14 16:46:13 -0700169 local DUR RESULT TERM TERMS VALUE UNIT
170 DUR=$1
171 RESULT=0
172 TERMS="$(echo "$DUR" | sed -Ee 's/([sSmMhHdD])/\1 /g' -e 's/,$//g')"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700173 for TERM in $TERMS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700174 VALUE="$(echo "$TERM" | sed -Ee 's/([0-9]+)[sSmMhHdD]/\1/')"
175 UNIT="$(echo "$TERM" | sed -Ee 's/[0-9]+([sSmMhHdD])/\1/')"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700176 case $UNIT in
177 s|S)
David Bainbridged18f4942020-04-14 16:46:13 -0700178 RESULT=$((RESULT + VALUE)) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700179 m|M)
David Bainbridged18f4942020-04-14 16:46:13 -0700180 RESULT=$((RESULT + (VALUE * 60))) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700181 h|H)
David Bainbridged18f4942020-04-14 16:46:13 -0700182 RESULT=$((RESULT + (VALUE * 3600))) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700183 d|D)
David Bainbridged18f4942020-04-14 16:46:13 -0700184 RESULT=$((RESULT + (VALUE * 86400))) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700185 *) ;;
186 esac
187 done
188 echo $RESULT
189}
190
191function doTimeout() {
192 local MSG=$1
193 2>&1 echo -e "\n${RED}${BOLD}${ERROR}TIMEOUT:${NORMAL}${RED} Operation timed out after '$WAIT_TIMEOUT': $MSG"
194 exit 125
195}
196
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800197function get_service_ep() {
198 local NS=$1
199 local NAME=$2
David Bainbridged18f4942020-04-14 16:46:13 -0700200 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 -0800201}
202
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000203# Used to verify configuration values are set to "yes" or "no" value or convert
204# equivalents to "yes" or "no"
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700205YES="y,yes,t,true,1"
206NO="n,no,f,false,0"
207YES_OR_NO="$YES,$NO"
208
209# If the given VAR matches a truth value then normalize that
210# value, else return original value
211function normalize_yes_no() {
212 local VAR VAL
213 VAR=$1
214 VAL="$(eval echo "\$$VAR")"
215 if ! is_in "$VAL" "$YES_OR_NO"; then
216 echo "$VAL"
217 return 1
218 fi
219 if is_in "$VAL" "$YES"; then
220 echo "yes"
221 else
222 echo "no"
223 fi
224 return 0
225}
226
227# If the given VAR matches a truth value then normalize that
228# value, else display an error
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000229function verify_yes_no() {
David Bainbridged18f4942020-04-14 16:46:13 -0700230 local VAR VAL
231 VAR=$1
232 VAL="$(eval echo "\$$VAR")"
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700233 if ! is_in "$VAL" "$YES_OR_NO"; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000234 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid '$VAR' value of '$VAL'. Should be 'yes' or 'no'${NORMAL}"
235 echo "INVALID"
236 return 1
237 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700238 if is_in "$VAL" "$YES"; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000239 echo "yes"
240 else
241 echo "no"
242 fi
243 return 0
244}
Test User7d866122019-07-09 17:52:35 +0000245
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000246ALL_YES_NO="\
David K. Bainbridge484d80c2020-03-05 21:44:34 -0800247 ENABLE_ONOS_EXTRANEOUS_RULES \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000248 WITH_TIMINGS \
249 WITH_BBSIM \
divyadesai59f987a2020-05-27 12:11:33 +0000250 WITH_EFK \
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800251 WITH_EAPOL \
252 WITH_DHCP \
253 WITH_IGMP \
David Bainbridge99ac7a22019-08-31 02:26:43 +0000254 WITH_CHAOS \
David Bainbridge46505fb2019-10-01 21:13:20 +0000255 WITH_ADAPTERS \
256 WITH_SIM_ADAPTERS \
257 WITH_OPEN_ADAPTERS \
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800258 WITH_PORT_FORWARDS \
Matteo Scandoloefee0432020-05-05 13:56:20 -0700259 WITH_PPROF \
Girish Gowdra4cc5d8b2020-06-11 17:12:00 -0700260 WITH_INCREMENTAL_EVTO_UPDATE \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000261 JUST_K8S \
262 DEPLOY_K8S \
263 INSTALL_ONOS_APPS \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000264 INSTALL_KUBECTL \
265 INSTALL_HELM \
David Bainbridge7f8bf992020-04-08 21:53:22 -0700266 HELM_USE_UPGRADE \
David Bainbridge46505fb2019-10-01 21:13:20 +0000267 UPDATE_HELM_REPOS \
David Bainbridge4f1b5562019-08-19 04:46:52 +0000268 WAIT_ON_DOWN \
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700269 VOLTHA_DOWN_ON_TIMEOUT \
Matteo Scandoloc2eb0672020-05-01 14:43:15 -0700270 LEGACY_BBSIM_INDEX \
David Bainbridgee4d11ca2020-05-08 10:21:10 -0700271 SCHEDULE_ON_CONTROL_NODES \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000272 "
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000273
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700274OPT_YES_NO="\
275 CONFIG_SADIS \
276 WITH_KAFKA \
277 WITH_RADIUS \
278 WITH_ETCD \
279 WITH_ONOS \
280 "
281
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000282ALL_OPTIONS="\
283 NAME \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000284 $ALL_YES_NO \
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700285 $OPT_YES_NO \
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700286 WAIT_TIMEOUT \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000287 VOLTHA_LOG_LEVEL \
288 VOLTHA_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000289 VOLTHA_CHART_VERSION \
290 VOLTHA_BBSIM_CHART \
291 VOLTHA_BBSIM_CHART_VERSION \
David Bainbridge879439b2020-06-12 15:59:35 -0700292 BBSIM_SADIS_SERVER_CHART \
293 BBSIM_SADIS_SERVER_CHART_VERSION \
uottrembd5a20572020-03-06 09:15:01 +0100294 NUM_OF_BBSIM \
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700295 NUM_OF_WORKER_NODES \
296 NUM_OF_CONTROLLER_NODES \
297 NUM_OF_KAFKA \
298 NUM_OF_ETCD \
divyadesai59f987a2020-05-27 12:11:33 +0000299 ELASTICSEARCH_CHART \
300 ELASTICSEARCH_CHART_VERSION \
301 KIBANA_CHART \
302 KIBANA_CHART_VERSION \
303 FLUENTD_ELASTICSEARCH_CHART \
304 FLUENTD_ELASTICSEARCH_CHART_VERSION \
Matteo Scandolo67335f02020-04-09 11:19:53 -0700305 NUM_OF_OPENONU \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000306 VOLTHA_ADAPTER_SIM_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000307 VOLTHA_ADAPTER_SIM_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000308 VOLTHA_ADAPTER_OPEN_OLT_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000309 VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000310 VOLTHA_ADAPTER_OPEN_ONU_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000311 VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION \
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800312 ONOS_CHART \
Andrea Campanella21323292019-12-18 11:44:19 -0800313 ONOS_CHART_VERSION \
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700314 ONOS_CLASSIC_CHART \
315 ONOS_CLASSIC_CHART_VERSION \
David Bainbridgecf546362020-04-21 23:18:50 -0700316 KAFKA_CHART \
David Bainbridgeb9093522020-04-15 14:32:44 -0700317 KAFKA_CHART_VERSION \
David Bainbridge879439b2020-06-12 15:59:35 -0700318 ETCD_CHART \
319 ETCD_CHART_VERSION \
320 RADIUS_CHART \
321 RADIUS_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000322 ONOS_API_PORT \
323 ONOS_SSH_PORT \
Hardik Windlassb3147602020-03-09 16:59:15 +0530324 SADIS_CFG \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000325 VOLTHA_API_PORT \
326 VOLTHA_SSH_PORT \
327 VOLTHA_ETCD_PORT \
divyadesai59f987a2020-05-27 12:11:33 +0000328 ELASTICSEARCH_PORT \
329 KIBANA_PORT \
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800330 VOLTHA_KAFKA_PORT \
Matteo Scandoloefee0432020-05-05 13:56:20 -0700331 VOLTHA_PPROF_PORT \
332 OPENOLT_PPROF_PORT \
Matteo Scandolo65c35192020-05-13 10:41:21 -0700333 OFAGENT_PPROF_PORT \
David K. Bainbridge8f7f30b2020-01-08 13:06:16 -0800334 VK_RELEASE \
335 KIND_VERSION \
336 VOLTCTL_VERSION \
David Bainbridgea34993d2020-04-01 09:15:42 -0700337 HELM_VERSION \
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700338 NUM_OF_ONOS \
339 NUM_OF_ATOMIX \
David Bainbridge6ca40102020-04-08 11:30:40 -0700340 VOLTHA_NS \
341 ADAPTER_NS \
342 INFRA_NS \
343 BBSIM_NS \
David Bainbridge7db44002020-04-09 12:54:29 -0700344 SADIS_BANDWIDTH_PROFILES \
345 SADIS_SUBSCRIBERS \
David Bainbridgeb4bbde12020-06-25 14:46:36 -0700346 PF_ADDRESS \
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700347 KIND_CFG_FILE \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000348 "
David Bainbridge01294952019-07-30 19:33:45 +0000349
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000350# Iterate over yes/no configuration options and validate
351for VAR in $ALL_YES_NO; do
David Bainbridged18f4942020-04-14 16:46:13 -0700352 eval "$VAR"="$(verify_yes_no "$VAR")"
353 if [ "$(eval echo "\$$VAR")" == "INVALID" ]; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000354 exit 1;
355 fi
356done
David Bainbridgeb270c202019-07-26 01:44:42 +0000357
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700358# Iterate over optional yes/no configuration options and
359# normalize values if they are truth values
360for VAR in $OPT_YES_NO; do
361 eval "$VAR"="$(normalize_yes_no "$VAR")"
362done
David Bainbridge15f6f232020-03-30 09:15:43 -0700363
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700364# check number (range) of bbsim, max bbsim must not exceed 10 instances!
365# note: instances will be numbered from 0 to 9
366if [ "$1" == "up" ]; then
367 if [ "$NUM_OF_BBSIM" -lt 1 ]; then
368 >&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}"
369 exit 1
370 fi
371 if [ "$NUM_OF_BBSIM" -gt "$MAX_NUM_OF_BBSIM" ]; then
372 >&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}"
373 exit 1
374 fi
375
376 if [ "$NUM_OF_OPENONU" -lt 1 ]; then
377 >&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}"
378 exit 1
379 fi
380 if [ "$NUM_OF_OPENONU" -gt "$MAX_NUM_OF_OPENONU" ]; then
381 >&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}"
382 exit 1
383 fi
384
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700385 HAVE_CLUSTER="$(kind get clusters 2>/dev/null | grep -c "voltha-$NAME")"
386 if [ "$HAVE_CLUSTER" -eq 0 ]; then
387 # If the user has specified a kind cluster configuration file,
388 # 'KIND_CFG_FILE` then we need to gleem from that file the number
389 # of worker and controller nodes as this overrides any setting of
390 # these values
391 if [ -n "$KIND_CFG_FILE" ]; then
392 NUM_OF_WORKER_NODES="$(sed 's/ //g' "$KIND_CFG_FILE" | grep -c "^-role:worker$")"
393 NUM_OF_CONTROLLER_NODES="$(sed 's/ //g' "$KIND_CFG_FILE" | grep -c "^-role:control-plane$")"
394 fi
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700395
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700396 # check that NUM_OF_KAFKA, NUM_OF_ONOS, NUM_OF_ATOMIX, NUM_OF_ETCD is:
397 # <= NUM_OF_WORKER_NODES + 1 if SCHEDULE_ON_CONTROL_NODES == y
398 # <= NUM_OF_WORKER_NODES if SCHEDULE_ON_CONTROL_NODES == n
399 SCHEDULABLE_NODES=$NUM_OF_WORKER_NODES
400
401 if [ "$SCHEDULE_ON_CONTROL_NODES" == "yes" ]; then
402 SCHEDULABLE_NODES=$((NUM_OF_CONTROLLER_NODES+NUM_OF_WORKER_NODES))
403 fi
404 else
405 TOTAL_NODES=$(kubectl get --all-namespaces nodes -o name | wc -l)
406 NUM_OF_CONTROLLER_NODES=$(kubectl get --all-namespaces nodes -l node-role.kubernetes.io/master -o name | wc -l)
407 NUM_OF_WORKER_NODES=$((TOTAL_NODES - NUM_OF_CONTROLLER_NODES))
408 # shellcheck disable=SC2016
409 SCHEDULABLE_NODES=$(kubectl get no -o 'go-template={{range .items}}{{$taints:=""}}{{range .spec.taints}}{{if eq .effect "NoSchedule"}}{{$taints = print $taints .key ","}}{{end}}{{end}}{{if not $taints}}{{.metadata.name}}{{ "\n"}}{{end}}{{end}}' | wc -l | sed -e 's/ //g')
410 rm -f "$TMP_KUBECFG"
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700411 fi
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700412 NODES="SCHEDULE_ON_CONTROL_NODES: $SCHEDULE_ON_CONTROL_NODES, SCHEDULABLE_NODES: $SCHEDULABLE_NODES, NUM_OF_CONTROLLER_NODES: $NUM_OF_CONTROLLER_NODES, NUM_OF_WORKER_NODES: $NUM_OF_WORKER_NODES"
413
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700414 if is_in "$WITH_KAFKA" "yes,external" && [ ! "$NUM_OF_KAFKA" -le "$SCHEDULABLE_NODES" ]; then
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700415 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid setting of KAFKA replicas. NUM_OF_KAFKA (${NUM_OF_KAFKA}) is greater than the available nodes ($NODES)${NORMAL}"
416 exit 1
417 fi
418
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700419 if is_in "$WITH_ETCD" "yes,external" && [ ! "$NUM_OF_ETCD" -le "$SCHEDULABLE_NODES" ]; then
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700420 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid setting of ETCD replicas. NUM_OF_ETCD (${NUM_OF_ETCD}) is greater than the available nodes ($NODES)${NORMAL}"
421 exit 1
422 fi
423
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700424 if is_in "$WITH_ONOS" "yes,legacy,classic,micro"; then
425 if [ ! "$NUM_OF_ATOMIX" -le "$SCHEDULABLE_NODES" ]; then
426 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid setting of ATOMIX replicas. NUM_OF_ATOMIX (${NUM_OF_ATOMIX}) is greater than the available nodes ($NODES)${NORMAL}"
427 exit 1
428 fi
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700429
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700430 if [ ! "$NUM_OF_ONOS" -le "$SCHEDULABLE_NODES" ]; then
431 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid setting of ONOS replicas. NUM_OF_ONOS (${NUM_OF_ONOS}) is greater than the available nodes ($NODES)${NORMAL}"
432 exit 1
433 fi
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700434 fi
435fi
436
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700437# normalize non-truth value options
438if is_in "$WITH_KAFKA" "e,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -0700439 WITH_KAFKA="external"
440fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700441if is_in "$WITH_ETCD" "e,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -0700442 WITH_ETCD="external"
443fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700444if is_in "$WITH_ONOS" "l,legacy"; then
445 WITH_ONOS="legacy"
446elif is_in "$WITH_ONOS" "c,classic"; then
447 WITH_ONOS="classic"
448elif is_in "$WITH_ONOS" "u,m,micro"; then
449 WITH_ONOS="micro"
David Bainbridge29c31cb2020-04-06 09:45:50 -0700450fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700451
452if [ "$WITH_ONOS" == "micro" ]; then
453 >&2 echo -e "${YELLOW}${BOLD}${ERROR}WARNING:${NORMAL}${YELLOW} The value specified as WITH_ONOS, '$WITH_ONOS', is not valid.${NORMAL}"
454 exit 1
David Bainbridge29c31cb2020-04-06 09:45:50 -0700455fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700456
457if is_in "$WITH_ONOS" "yes,classic"; then
458 # there is an extra utility required if we are using ONOS CLASSIC as
459 # the chart for classic specifies images differently
460 EXTRA_TOOLS+=" yq"
David Bainbridge76afd812020-04-06 09:53:52 -0700461fi
David Bainbridge696bc632020-04-05 21:49:37 -0700462
David Bainbridge22db5dd2020-05-26 12:21:21 -0700463if [ "$LEGACY_BBSIM_INDEX" == "no" ]; then
464 BBSIM_SADIS_SVC="bbsim0"
465else
466 BBSIM_SADIS_SVC="bbsim"
467fi
468
469SADIS_SUBSCRIBERS=${SADIS_SUBSCRIBERS:-http://$BBSIM_SADIS_SVC.$VOLTHA_NS.svc:50074/v2/subscribers/%s}
470SADIS_BANDWIDTH_PROFILES=${SADIS_BANDWIDTH_PROFILES:-http://$BBSIM_SADIS_SVC.$VOLTHA_NS.svc:50074/v2/bandwidthprofiles/%s}
471
David Bainbridged18f4942020-04-14 16:46:13 -0700472if [ "$HELM_USE_UPGRADE" == "yes" ]; then
David Bainbridge7f8bf992020-04-08 21:53:22 -0700473 _HELM_DESC="Upgrade/Install"
474else
475 _HELM_DESC="Install"
476fi
477
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800478# Check for prerequiste tools
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700479TOOLS="curl sed jq $EXTRA_TOOLS"
David Bainbridged18f4942020-04-14 16:46:13 -0700480if [ "$DEPLOY_K8S" == "yes" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800481 TOOLS+=" docker"
482fi
483NOT_FOUND=""
484for T in $TOOLS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700485 if [ -z "$(command -v "$T")" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800486 NOT_FOUND+=" $T"
487 fi
488done
489
David Bainbridged18f4942020-04-14 16:46:13 -0700490if [ -n "$NOT_FOUND" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800491 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} The following required tools where not found, please install them:$NOT_FOUND"
492 exit 1
493fi
494
David Bainbridged18f4942020-04-14 16:46:13 -0700495TIMEOUT_SECONDS="$(parseDuration "$WAIT_TIMEOUT")"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700496
David Bainbridge0774b232019-08-02 06:37:19 +0000497mkdir -p .voltha
498touch .voltha/ports
David Bainbridged18f4942020-04-14 16:46:13 -0700499HAVE="$(grep "$NAME" .voltha/ports)"
David Bainbridge0774b232019-08-02 06:37:19 +0000500if [ "$HAVE X" == " X" ]; then
501 # Find free port prefix
502 START=81
503 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700504 if [ "$(grep -c $START .voltha/ports)" -eq 0 ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000505 break
506 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700507 START="$((START + 1))"
David Bainbridge0774b232019-08-02 06:37:19 +0000508 done
David Bainbridged18f4942020-04-14 16:46:13 -0700509 DELTA="$((START - 81))"
David Bainbridgea2595422019-10-22 03:54:28 +0000510 ONOS_API_PORT=${ONOS_API_PORT:-${START}81}
511 ONOS_SSH_PORT=${ONOS_SSH_PORT:-${START}01}
David Bainbridged18f4942020-04-14 16:46:13 -0700512 VOLTHA_API_PORT=${VOLTHA_API_PORT:-5$((55 + DELTA))55}
513 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$((50 + DELTA))22}
514 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$((23 + DELTA))79}
515 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$((90 + DELTA))92}
Matteo Scandoloefee0432020-05-05 13:56:20 -0700516 VOLTHA_PPROF_PORT=${VOLTHA_PPROF_PORT:-$((60 + DELTA))60}
517 OPENOLT_PPROF_PORT=${OPENOLT_PPROF_PORT:-$((60 + DELTA))61}
Matteo Scandolo65c35192020-05-13 10:41:21 -0700518 OFAGENT_PPROF_PORT=${OFAGENT_PPROF_PORT:-$((60 + DELTA))62}
divyadesai59f987a2020-05-27 12:11:33 +0000519 ELASTICSEARCH_PORT=${ELASTICSEARCH_PORT:-$((92 + DELTA))00}
520 KIBANA_PORT=${KIBANA_PORT:-$((56 + DELTA))01}
Test User01ed0642019-07-03 20:17:06 +0000521else
David Bainbridged18f4942020-04-14 16:46:13 -0700522 VALUES="$(echo "$HAVE" | sed -e 's/\s//g' | cut -d= -f2)"
523 ONOS_API_PORT=${ONOS_API_PORT:-$(echo "$VALUES" | cut -d, -f1)}
524 ONOS_SSH_PORT=${ONOS_SSH_PORT:-$(echo "$VALUES" | cut -d, -f2)}
525 VOLTHA_API_PORT=${VOLTHA_API_PORT:-$(echo "$VALUES" | cut -d, -f3)}
526 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$(echo "$VALUES" | cut -d, -f4)}
527 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$(echo "$VALUES" | cut -d, -f5)}
528 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(echo "$VALUES" | cut -d, -f6)}
Matteo Scandoloefee0432020-05-05 13:56:20 -0700529 VOLTHA_PPROF_PORT=${VOLTHA_PPROF_PORT:-$(echo "$VALUES" | cut -d, -f7)}
530 OPENOLT_PPROF_PORT=${OPENOLT_PPROF_PORT:-$(echo "$VALUES" | cut -d, -f8)}
Matteo Scandolo65c35192020-05-13 10:41:21 -0700531 OFAGENT_PPROF_PORT=${OFAGENT_PPROF_PORT:-$(echo "$VALUES" | cut -d, -f9)}
divyadesai59f987a2020-05-27 12:11:33 +0000532 ELASTICSEARCH_PORT=${ELASTICSEARCH_PORT:-$(echo "$VALUES" | cut -d, -f10)}
533 KIBANA_PORT=${KIBANA_PORT:-$(echo "$VALUES" | cut -d, -f11)}
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800534
Matteo Scandoloefee0432020-05-05 13:56:20 -0700535 # Some ports were added after the .voltha/ports files was created.
536 # Calculate the original DELTA from the VOLTHA_SSH_PORT so that it can
537 # be used to set up newer port-forwards.
538 DELTA="$((VOLTHA_SSH_PORT/100-50))"
539
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800540 if [ -z "$VOLTHA_KAFKA_PORT" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -0700541 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$((90 + DELTA))92}
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800542 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -0700543
544 if [ -z "$VOLTHA_PPROF_PORT" ]; then
divyadesai59f987a2020-05-27 12:11:33 +0000545 VOLTHA_PPROF_PORT=${VOLTHA_PPROF_PORT:-$((60 + DELTA))60}
Matteo Scandoloefee0432020-05-05 13:56:20 -0700546 fi
547 if [ -z "$OPENOLT_PPROF_PORT" ]; then
divyadesai59f987a2020-05-27 12:11:33 +0000548 OPENOLT_PPROF_PORT=${OPENOLT_PPROF_PORT:-$((60 + DELTA))61}
Matteo Scandoloefee0432020-05-05 13:56:20 -0700549 fi
Matteo Scandolo65c35192020-05-13 10:41:21 -0700550 if [ -z "$OFAGENT_PPROF_PORT" ]; then
divyadesai59f987a2020-05-27 12:11:33 +0000551 OFAGENT_PPROF_PORT=${OFAGENT_PPROF_PORT:-$((60 + DELTA))62}
552 fi
553
554 if [ -z "$ELASTICSEARCH_PORT" ]; then
555 ELASTICSEARCH_PORT=${ELASTICSEARCH_PORT:-$((92 + DELTA))00}
556 fi
557
558 if [ -z "$KIBANA_PORT" ]; then
559 KIBANA_PORT=${KIBANA_PORT:-$((56 + DELTA))01}
Matteo Scandolo65c35192020-05-13 10:41:21 -0700560 fi
Test User01ed0642019-07-03 20:17:06 +0000561fi
562
David Bainbridged18f4942020-04-14 16:46:13 -0700563PORTTMP="$(mktemp -u)"
564grep -v "$NAME" .voltha/ports > "$PORTTMP"
divyadesai59f987a2020-05-27 12:11:33 +0000565echo "$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 -0700566cp "$PORTTMP" .voltha/ports
567rm -f "$PORTTMP"
David Bainbridge0774b232019-08-02 06:37:19 +0000568
David Bainbridge27790d62019-08-13 22:43:19 +0000569export ONOS_API_PORT ONOS_SSH_PORT
David Bainbridge01294952019-07-30 19:33:45 +0000570
Test Userd87942b2019-07-03 07:20:24 +0000571IDX=1
David Bainbridgee87067b2019-08-12 22:00:12 +0000572CLOCK="TIME:"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000573SPIN_PARTS=
574NOT_VERIFIED=
David Bainbridgef858a022019-08-14 21:25:11 +0000575THEX=
576BUILD=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000577VERIFIED=
578HELM=
579OLD_KEY=
580BIRD=
581HIGH_VOLTAGE=
582PLUG=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000583FORWARD=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000584GO=
585DOWNLOAD=
586GEAR=
587NO_ENTRY=
588LOCK=
589
David Bainbridged18f4942020-04-14 16:46:13 -0700590if [ "$FANCY" -eq 1 ]; then
591 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 +0000592 CLOCK="\xe2\x8f\xb1"
David Bainbridgef858a022019-08-14 21:25:11 +0000593 THEX="${RED}${BOLD}\xe2\x9c\x97\x20${NORMAL}"
David Bainbridgef858a022019-08-14 21:25:11 +0000594 BUILD="${YELLOW}${BOLD}\xf0\x9f\x8f\x97${NORMAL}"
595 NOT_VERIFIED="$BUILD"
596 VERIFIED="${GREEN}${BOLD}\xe2\x9c\x93\x20${NORMAL}"
597 HELM="${BLUE}${BOLD}\xE2\x8E\x88${NORMAL}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000598 OLD_KEY="\xF0\x9F\x97\x9D"
599 BIRD="\xF0\x9F\x90\xA6"
600 HIGH_VOLTAGE="\xE2\x9A\xA1"
601 PLUG="\xF0\x9F\xa7\xa9"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000602 FORWARD="\xE2\x87\xA8"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000603 GO="\xf0\x9f\x9a\x80"
604 DOWNLOAD="\xf0\x9f\x93\xa5"
605 GEAR="\xe2\x9a\x99"
606 NO_ENTRY="\xe2\x9b\x94"
607 LOCK="\xf0\x9f\x94\x92"
608fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700609
David Bainbridge712afb82019-08-14 19:55:58 +0000610duration() {
David Bainbridged18f4942020-04-14 16:46:13 -0700611 local h m s t
612 h="$(($1 / 3600))"
613 m="$(($1 % 3600 / 60))"
614 s="$(($1 % 60))"
615 t=""
David Bainbridgee87067b2019-08-12 22:00:12 +0000616
David Bainbridged18f4942020-04-14 16:46:13 -0700617 if [ "$h" -gt 0 ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +0000618 t="$t${h}h"
619 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700620 if [ "$m" -gt 0 ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +0000621 t="$t${m}m"
622 fi
David Bainbridge712afb82019-08-14 19:55:58 +0000623 echo "$t${s}s"
624}
625
626printtime() {
David Bainbridged18f4942020-04-14 16:46:13 -0700627 local INDENT
David Bainbridge712afb82019-08-14 19:55:58 +0000628 if [ "$1" == "-" ]; then
629 INDENT=" "
630 shift
631 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700632 echo -e "$INDENT $CLOCK $(duration "$1")"
David Bainbridgee87067b2019-08-12 22:00:12 +0000633}
634
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700635bspin() {
Test Userd87942b2019-07-03 07:20:24 +0000636 IDX=1
David Bainbridged18f4942020-04-14 16:46:13 -0700637 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700638 if [ "$1" == "-" ]; then
639 INDENT=" "
640 shift
641 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700642 if [ "$FANCY" -eq 0 ]; then
643 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000644 if [ "$LINE X" == " X" ]; then
645 return
646 fi
647 echo -e "$CIVIS$INDENT$*"
648 else
649 echo -en "$CIVIS$INDENT $*"
650 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700651}
652
653sspin() {
David Bainbridged18f4942020-04-14 16:46:13 -0700654 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700655 if [ "$1" == "-" ]; then
656 INDENT=" "
657 shift
658 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700659 if [ "$FANCY" -eq 0 ]; then
660 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000661 if [ "$LINE X" == " X" ]; then
662 return
663 fi
664 echo -e "$INDENT$*"
665 else
David Bainbridged18f4942020-04-14 16:46:13 -0700666 C="$(echo "$SPIN_PARTS" | cut '-d ' -f "$IDX")"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000667 echo -en "\r$INDENT$C $*"
David Bainbridged18f4942020-04-14 16:46:13 -0700668 IDX="$((IDX + 1))"
669 if [ "$IDX" -gt 8 ]; then
David Bainbridge38dc1e82019-08-12 15:18:45 +0000670 IDX=1
671 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700672 fi
673}
674
675espin() {
David Bainbridged18f4942020-04-14 16:46:13 -0700676 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700677 if [ "$1" == "-" ]; then
678 INDENT=" "
679 shift
680 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700681 if [ "$FANCY" -eq 0 ]; then
682 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000683 if [ "$LINE X" == " X" ]; then
684 return
685 fi
686 echo -e "$INDENT$*"
687 else
688 echo -e "\r$INDENT$*$CNORM"
689 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700690}
691
David Bainbridged18f4942020-04-14 16:46:13 -0700692if [ "$1" == "get" ] && [ "$2" == "voltconfig" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000693 echo "$HOME/.volt/config-$NAME"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000694 exit
695fi
696
David Bainbridgee4d11ca2020-05-08 10:21:10 -0700697if [ $# -ne 1 ] || ! is_in "$1" "up,down,dump,clean"; then
David Bainbridgeac7f8072019-08-01 22:15:33 +0000698 >&2 echo "What wouild you like to do today:"
699 >&2 echo " up - bring up voltha"
700 >&2 echo " down - tear down voltha"
701 >&2 echo " dump - create a debug dump of running system"
702 exit 1
703fi
704
divyadesai59f987a2020-05-27 12:11:33 +0000705do_curl() {
706 local DATA_ARGS CREDS CMD_ECHO CMD_OUTPUT SC_OUTPUT WAIT_START INDENTA EXTRAA NOW
707 local INDENT=$1
708 local OP=$2
709 local USER=$3
710 local PASS=$4
711 local URL=$5
712 local DATA_TYPE=$6
713 local DATA=$7
714 local MSG=$8
715 local VALID_RESULTS=$9
716 local EXTRA=${10}
717 local ICON=${11}
718
719 # Turn into an array for passing
720 INDENTA=()
721 if [ -n "$INDENT" ]; then
722 INDENTA=("$INDENT")
723 fi
724 IFS=' ' read -r -a EXTRAA <<< "$EXTRA"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000725
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800726 # Thanks to the latest version of ONOS using the return code 207 this gets a
727 # whole lot nastier. Can't thank them enough for doing this. So in order to
728 # capture the command and the output in the log file as well as capture the
729 # status code to verify it is 200 and not 207 mutltiple files and a bit of
730 # hackery must be used. Thanks again ONOS.
David Bainbridged18f4942020-04-14 16:46:13 -0700731 CMD_ECHO="$(mktemp -u)"
732 CMD_OUTPUT="$(mktemp -u)"
733 SC_OUTPUT="$(mktemp -u)"
734 WAIT_START="$(date +%s)"
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800735
divyadesai59f987a2020-05-27 12:11:33 +0000736 CREDS=()
737 if [ -n "$USER" ]; then
738 CREDS=("--user" "$USER:$PASS")
739 fi
740
741 DATA_ARGS=()
742 if [ -n "$DATA" ]; then
743 if [ "$DATA_TYPE" == "file" ]; then
744 DATA_ARGS=("--data" "@$DATA")
745 elif [ "$DATA_TYPE" == "json" ]; then
746 DATA_ARGS=("--data" "$DATA")
747 fi
748 fi
749
750 bspin "${INDENTA[@]}" "$MSG" "$ICON"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000751 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700752 NOW="$(date +%s)"
753 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
divyadesai59f987a2020-05-27 12:11:33 +0000754 espin "${INDENTA[@]}" "$THEX"
David Bainbridged18f4942020-04-14 16:46:13 -0700755 rm -f "$CMD_ECHO" "$CMD_OUTPUT" "$SC_OUTPUT"
divyadesai59f987a2020-05-27 12:11:33 +0000756 doTimeout "$MSG"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700757 fi
divyadesai59f987a2020-05-27 12:11:33 +0000758 (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
759 RESULT=$?
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800760 # Dump everything to the log
David Bainbridged18f4942020-04-14 16:46:13 -0700761 cat "$CMD_ECHO" >> "$LOG"
762 test -r "$CMD_OUTPUT" && cat "$CMD_OUTPUT" >> "$LOG"
763 SC="$(cat "$SC_OUTPUT")"
764 echo "RESPONSE CODE: $SC" >> "$LOG"
765 echo "ERROR CODE: $RESULT" >> "$LOG"
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800766
767 # clean up temp files
David Bainbridged18f4942020-04-14 16:46:13 -0700768 rm -f "$CMD_ECHO" "$CMD_OUTPUT" "$SC_OUTPUT"
divyadesai59f987a2020-05-27 12:11:33 +0000769 if [ "$RESULT" -eq 0 ] && is_in "$SC" "$VALID_RESULTS"; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000770 break
771 fi
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800772 sleep 1
divyadesai59f987a2020-05-27 12:11:33 +0000773 sspin "${INDENTA[@]}"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000774 done
divyadesai59f987a2020-05-27 12:11:33 +0000775 espin "${INDENTA[@]}" "$VERIFIED"
776}
777
778push_onos_config() {
779 local DATA_TYPE=$1
780 local MSG=$2
781 local RESOURCE=$3
782 local DATA=$4
783
784 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 +0000785}
786
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800787check_onos_app_active() {
David Bainbridged18f4942020-04-14 16:46:13 -0700788 local APP_ID WAIT_START RESULT NOW
789 APP_ID=$1
790 WAIT_START="$(date +%s)"
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800791
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700792 bspin - "Checking that $APP_ID is active $CLOCK"
793 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700794 NOW="$(date +%s)"
795 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700796 espin - "$THEX"
797 doTimeout "waiting for ONOS application activation '$APP_ID'"
798 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700799 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 -0700800 break
801 fi
802 sleep 1
803 sspin -
804 done
805 sleep 5 # OSGI components take a little longer that the app to activate
David Bainbridged18f4942020-04-14 16:46:13 -0700806 espin - "$VERIFIED"
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800807}
808
David Bainbridge4f1b5562019-08-19 04:46:52 +0000809override_onos_app() {
David Bainbridged18f4942020-04-14 16:46:13 -0700810 local APP NAME WAIT_START NOW
811 APP=$1
812 NAME="$(basename "$APP" | sed -e 's/^[0-9][0-9]*-//g' -e 's/-.*$//g')"
813 WAIT_START="$(date +%s)"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700814
David Bainbridge4f1b5562019-08-19 04:46:52 +0000815 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700816 NOW="$(date +%s)"
817 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700818 espin - "$THEX"
819 doTimeout "waiting to overwrite ONOS application '$APP'"
820 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +0000821 sspin -
822 # Attempt to delete old version (if it exists)
David Bainbridged18f4942020-04-14 16:46:13 -0700823 (set -x; curl --fail -sSL --user karaf:karaf -X DELETE "http://$_ONOS_API_EP/onos/v1/applications/$NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
824 RESULT=$?
David Bainbridge4f1b5562019-08-19 04:46:52 +0000825 sspin -
David Bainbridged18f4942020-04-14 16:46:13 -0700826 if [ $RESULT -ne 0 ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000827 continue
828 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700829 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 +0000830 break
831 fi
832 sleep .2
833 done
834}
835
836activate_onos_app() {
David Bainbridged18f4942020-04-14 16:46:13 -0700837 local MSG APP WAIT_START NOW
838 MSG="$1"
839 APP=$2
840 WAIT_START="$(date +%s)"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000841
842 bspin - "$MSG $GO"
843 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700844 NOW="$(date +%s)"
845 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700846 espin - "$THEX"
847 doTimeout "waiting to activate ONOS application '$APP'"
848 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +0000849 sspin -
David Bainbridged18f4942020-04-14 16:46:13 -0700850 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 +0000851 break
852 fi
853 sleep .2
854 done
855 espin - "$VERIFIED"
856}
857
858count_pods() {
David Bainbridged18f4942020-04-14 16:46:13 -0700859 local NAMESPACE STATES LABELS CMD PODS
860 NAMESPACE=$1; shift
David Bainbridge4f1b5562019-08-19 04:46:52 +0000861 if [ "$NAMESPACE" == "all-namespaces" ]; then
862 NAMESPACE="--all-namespaces"
863 else
864 NAMESPACE="-n $NAMESPACE"
865 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700866 STATES=$1; shift
867 LABELS=$1; shift
868 CMD=("kubectl get $NAMESPACE $LABELS pod")
869 PODS=$(${CMD[*]} -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}")
David Bainbridge4f1b5562019-08-19 04:46:52 +0000870 local COUNT=0
871 local PATTERNS="$*"
872 for POD in $PODS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700873 local NAME STATE CONTAINERS TOTAL FOUND
874 NAME="$(echo "$POD" | cut -d/ -f 1)"
875 STATE="$(echo "$POD" | cut -d/ -f 2)"
876 CONTAINERS="$(echo "$POD" | cut -d/ -f 3 | sed -e 's/_/ /g')"
877 if [ "$STATES" == "*" ] || [ "$(echo "$STATES" | grep -c ":$STATE:")" -ne 0 ]; then
878 TOTAL="$(echo "$CONTAINERS" | wc -w)"
879 FOUND="$(echo "$CONTAINERS" | grep -o true | wc -l)"
880 if [ "$TOTAL" -eq "$FOUND" ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000881 for PATTERN in $PATTERNS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700882 if [[ "$NAME" =~ $PATTERN ]]; then
883 COUNT="$((COUNT + 1))"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000884 break
885 fi
886 done
887 fi
888 fi
889 done
David Bainbridge4f1b5562019-08-19 04:46:52 +0000890 echo $COUNT
891}
892
893wait_for_pods() {
David Bainbridged18f4942020-04-14 16:46:13 -0700894 local INDENT NAMESPACE EXPECT TYPE MESSAGE LABELS PATTERNS STATES HAVE ALL WAIT_START NOW
David Bainbridge4f1b5562019-08-19 04:46:52 +0000895 if [ "$1" == "-" ]; then
896 INDENT=$1; shift
897 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700898 NAMESPACE=$1; shift
899 EXPECT=$1; shift
900 TYPE=$1; shift
901 MESSAGE=$1; shift
902 LABELS=$1; shift
903 PATTERNS=("$*")
904 STATES=":Running:"
David Bainbridge99ac7a22019-08-31 02:26:43 +0000905 if [ "$TYPE" == "not" ]; then
906 STATES="*"
907 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700908 HAVE="$(count_pods "$NAMESPACE" "$STATES" "$LABELS" "${PATTERNS[@]}")"
909 ALL=$HAVE
David Bainbridge4f1b5562019-08-19 04:46:52 +0000910 if [ "$TYPE" == "only" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -0700911 ALL="$(count_pods "all-namespaces" "*" ".*")"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000912 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700913 COUNT="$((300 / 15))"
914 WAIT_START="$(date +%s)"
915 bspin "$INDENT" "$MESSAGE"
916 sspin "$INDENT"
917 if [ "$HAVE" -ne "$EXPECT" ] || [ "$ALL" -ne "$HAVE" ]; then
918 while [ "$HAVE" -ne "$EXPECT" ] || [ "$ALL" -ne "$HAVE" ]; do
919 NOW="$(date +%s)"
920 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
921 espin "$INDENT" "$THEX"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700922 doTimeout "waiting for PODs to start"
923 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700924 sspin "$INDENT"
925 COUNT="$((COUNT - 1))"
926 if [ "$COUNT" -eq 0 ]; then
927 HAVE="$(count_pods "$NAMESPACE" "$STATES" "$LABELS" "${PATTERNS[@]}")"
928 ALL="$HAVE"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000929 if [ "$TYPE" == "only" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -0700930 ALL="$(count_pods "all-namespaces" "*" ".*")"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000931 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700932 COUNT="$((300 / 15))"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000933 fi
934 sleep .15
935 done
936 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700937 espin "$INDENT" "$VERIFIED"
938 if [ "$HAVE" -ne "$EXPECT" ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000939 return 1
940 fi
941 return 0
942}
943
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800944port_forward() {
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700945 local NS=$1; shift
946 local SVC=$1; shift
947 local PORTS="$*"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800948 local TAG=$SVC-$NAME
949
David Bainbridgeb4bbde12020-06-25 14:46:36 -0700950 (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 -0800951}
952
953kill_port_forward() {
David Bainbridge1d2c5842020-06-03 15:29:07 -0700954 local TAG P_IDS PARENTS KIDS UNKNOWN PP_ID PF
955
956 while [ $# -gt 0 ]; do
957 PF=$1; shift
958 TAG=
959 if [ "$PF" != "__ALL__" ]; then
960 TAG="$PF-$NAME"
961 fi
962 PARENTS=
963 KIDS=
964 UNKNOWN=
965 # shellcheck disable=SC2009
966 P_IDS="$(ps e -ww -A | grep "_TAG=$TAG" | grep -v grep | awk '{print $1}')"
967 if [ -n "$P_IDS" ]; then
968 for P_ID in $P_IDS; do
969 PP_ID="$(ps -o ppid "$P_ID" | tail -n +2)"
970 if [ -n "$PP_ID" ]; then
971 if [ "$PP_ID" -eq 1 ]; then
972 PARENTS="$PARENTS $P_ID"
973 else
974 KIDS="$KIDS $P_ID"
975 fi
David Bainbridgec6871d22019-11-13 17:10:31 +0000976 else
David Bainbridge1d2c5842020-06-03 15:29:07 -0700977 UNKNOWN="$UNKNOWN $P_ID"
David Bainbridgec6871d22019-11-13 17:10:31 +0000978 fi
David Bainbridge1d2c5842020-06-03 15:29:07 -0700979 done
980 if [ -n "$PARENTS" ]; then
981 # shellcheck disable=SC2086
982 while ps -h $PARENTS >/dev/null 2>&1; do
983 (set -x; eval "kill -9 $PARENTS" >>"$LOG" 2>&1) >>"$LOG" 2>&1
984 done
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800985 fi
David Bainbridge1d2c5842020-06-03 15:29:07 -0700986 if [ -n "$KIDS" ]; then
987 # shellcheck disable=SC2086
988 while ps -h $KIDS >/dev/null 2>&1; do
989 (set -x; eval "kill -9 $KIDS" >>"$LOG" 2>&1) >>"$LOG" 2>&1
990 done
991 fi
992 if [ -n "$UNKNOWN" ]; then
993 # shellcheck disable=SC2086
994 while ps -h $UNKNOWN >/dev/null 2>&1; do
995 (set -x; eval "kill -9 $UNKNOWN" >>"$LOG" 2>&1) >>"$LOG" 2>&1
996 done
997 fi
998 fi
999 done
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001000}
1001
David Bainbridgecf546362020-04-21 23:18:50 -07001002resolve_chart_version() {
1003 [ "$2" != "latest" ] && echo "$2" && return
1004 helm inspect chart "$1" | grep "^version:" | awk '{print $2}'
1005}
1006
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07001007# Compares two semver-formatted version strings (e.g. 2.4.3)
1008# Returns 0 if $1 == $2, returns 1 if $1 > $2 and returns 2 if $1 < $2
1009compare_versions() {
1010 [ "$1" == "$2" ] && return 0
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07001011 local lowest
1012 lowest=$(echo -e "$1\n$2" | sort -V | head -1)
1013 [ "$lowest" == "$1" ] && return 2
1014 return 1
1015}
1016
David Bainbridgeac7f8072019-08-01 22:15:33 +00001017if [ "$1" == "down" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001018 echo "Tearing down voltha cluster $NAME"
1019 LOG="down-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -07001020 date -u +"%Y%m%dT%H%M%SZ" >"$LOG"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001021 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 -07001022 if is_in "$WITH_ONOS" "yes,legacy,classic"; then
David Bainbridge696bc632020-04-05 21:49:37 -07001023 bspin "Remove port-forwards: onos-ui-$NAME"
1024 kill_port_forward onos-ui
1025 sspin "Remove port-forwards: onos-ssh-$NAME$CEOL"
1026 kill_port_forward onos-ssh
David K. Bainbridge2aa08da2020-07-31 12:49:45 -07001027 sspin "Remove port-forwards: onos-onos-classic-hs-$NAME$CEOL"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001028 kill_port_forward onos-onos-classic-hs
David Bainbridge696bc632020-04-05 21:49:37 -07001029 fi
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001030 sspin "Remove port-forwards: voltha-api-$NAME$CEOL"
David Bainbridge1d2c5842020-06-03 15:29:07 -07001031 kill_port_forward voltha-api voltha-voltha-api
David Bainbridgec7220622020-05-28 12:31:47 -07001032 if is_in "$WITH_ETCD" "yes,external"; then
1033 sspin "Remove port-forwards: etcd-$NAME$CEOL"
1034 kill_port_forward "etcd"
David Bainbridge696bc632020-04-05 21:49:37 -07001035 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001036 if is_in "$WITH_KAFKA" "yes,external"; then
1037 sspin "Remove port-forwards: kafka-$NAME$CEOL"
1038 kill_port_forward "kafka"
David Bainbridge696bc632020-04-05 21:49:37 -07001039 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -07001040
1041 if [ "$WITH_PPROF" == "yes" ]; then
David Bainbridgec7220622020-05-28 12:31:47 -07001042 sspin "Remove port-forwards: *-profiler$CEOL"
David Bainbridge1d2c5842020-06-03 15:29:07 -07001043 kill_port_forward voltha-rw-core-profiler voltha-voltha-rw-core-profiler
1044 kill_port_forward voltha-of-agent-profiler voltha-voltha-of-agent-profiler
David Bainbridgec7220622020-05-28 12:31:47 -07001045 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
David Bainbridge1d2c5842020-06-03 15:29:07 -07001046 kill_port_forward adapter-open-olt-profiler open-olt-adapter-open-olt-profiler
David Bainbridgec7220622020-05-28 12:31:47 -07001047 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -07001048 fi
1049
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001050 espin "$VERIFIED Remove port-forwards$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -07001051 if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridgeac7f8072019-08-01 22:15:33 +00001052 if [ -x ./bin/kind ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001053 bspin "Delete Kubernetes Kind Cluster"
David Bainbridged18f4942020-04-14 16:46:13 -07001054 (set -x; ./bin/kind delete cluster --name "voltha-$NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1055 espin "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001056 else
David Bainbridge0774b232019-08-02 06:37:19 +00001057 espin "$NO_ENTRY Delete Kubernetes Kind Cluster: kind command not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001058 fi
1059 else
David Bainbridge309099c2020-05-05 08:47:29 -07001060 if [ "$CONFIG_SADIS" == "external" ]; then
1061 bspin "Remove configmap for BBSIM SADIS server"
1062 (set -x; kubectl -n "$BBSIM_NS" delete --ignore-not-found configmap kube-config >>"$LOG" 2>&1) >>"$LOG" 2>&1
1063 espin "$VERIFIED"
1064 fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001065
1066 if [ "$HELM_MAJOR" -le 2 ]; then
1067 EXISTS=$(helm list --output json 2>/dev/null | jq -r '.Releases | .[] | .Name + "," + .Namespace')
1068 else
1069 EXISTS=$(helm list --all-namespaces --output json 2>/dev/null | jq -r '.[] | .name + "," + .namespace')
1070 fi
David Bainbridge76afd812020-04-06 09:53:52 -07001071 EXPECT="voltha"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001072 if is_in "$WITH_ONOS" "yes,legacy,classic"; then
David Bainbridge696bc632020-04-05 21:49:37 -07001073 EXPECT+=" onos"
1074 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001075 if [ "$WITH_RADIUS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001076 EXPECT+=" radius"
1077 fi
David Bainbridge309099c2020-05-05 08:47:29 -07001078 if [ "$CONFIG_SADIS" == "external" ]; then
1079 EXPECT+=" bbsim-sadis-server"
1080 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001081 if [ "$WITH_BBSIM" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001082 EXPECT+=" bbsim"
1083 fi
divyadesai59f987a2020-05-27 12:11:33 +00001084 if [ "$WITH_EFK" == "yes" ]; then
1085 EXPECT+=" elasticsearch kibana fluentd"
1086 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001087 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001088 EXPECT+=" open-olt open-onu"
1089 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001090 if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001091 EXPECT+=" sim"
1092 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001093 if is_in "$WITH_ETCD" "yes,external"; then
1094 EXPECT+=" etcd"
David Bainbridge76afd812020-04-06 09:53:52 -07001095 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001096 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -07001097 EXPECT+=" kafka"
1098 fi
David Bainbridge0774b232019-08-02 06:37:19 +00001099 bspin "Remove Helm Deployments"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001100 for i in $EXISTS; do
David K. Bainbridge43422402020-03-06 07:41:22 -08001101 for j in $EXPECT; do
David Bainbridged18f4942020-04-14 16:46:13 -07001102 if [[ "$i" =~ $j ]]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001103 __NAME=$(echo "$i" | cut -d, -f1)
1104 __NS=$(echo "$i" | cut -d, -f2)
1105 sspin "Remove Helm Deployments: $__NS:$__NAME$CEOL"
1106 if [ "$HELM_MAJOR" -le 2 ]; then
1107 (set -x; helm delete --no-hooks --purge "$__NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1108 else
1109 (set -x; helm uninstall --no-hooks --namespace "$__NS" "$__NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1110 fi
David K. Bainbridge43422402020-03-06 07:41:22 -08001111 fi
1112 done
uottrembb16d3982020-02-28 08:34:36 +01001113 done
David Bainbridge0774b232019-08-02 06:37:19 +00001114 espin "$VERIFIED Remove Helm Deployments$CEOL"
David Bainbridge4f1b5562019-08-19 04:46:52 +00001115 if [ "$WAIT_ON_DOWN" == "yes" ]; then
Matteo Scandoloe93c9eb2020-06-03 12:08:51 -07001116 PODS="voltha-ofagent.* voltha-rw-core.*"
David Bainbridge76afd812020-04-06 09:53:52 -07001117 INFRA_PODS=
1118 ADAPT_PODS=
1119 SIM_PODS=
divyadesai59f987a2020-05-27 12:11:33 +00001120 EFK_PODS=
David Bainbridged18f4942020-04-14 16:46:13 -07001121 if [ "$WITH_RADIUS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001122 PODS+=" radius.*"
1123 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001124 if [ "$WITH_BBSIM" == "yes" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -07001125 SIM_PODS+=" bbsim.*"
David Bainbridge696bc632020-04-05 21:49:37 -07001126 fi
divyadesai59f987a2020-05-27 12:11:33 +00001127 if [ "$WITH_EFK" == "yes" ]; then
1128 EFK_PODS+=" kibana-* elasticsearch-* fluentd-*"
1129 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001130 if [ "$WITH_OPEN_ADAPTERS" ] || [ "$WITH_SIM_ADAPTERS" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -07001131 ADAPT_PODS+=" adapter-*"
David Bainbridge696bc632020-04-05 21:49:37 -07001132 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001133 if is_in "$WITH_ONOS" "yes,legacy,classic"; then
David Bainbridge76afd812020-04-06 09:53:52 -07001134 INFRA_PODS+=" onos-.*"
1135 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001136 if is_in "$WITH_ETCD" "yes,external"; then
1137 INFRA_PODS+=" etcd.*"
David Bainbridge76afd812020-04-06 09:53:52 -07001138 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001139 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -07001140 INFRA_PODS+=" kafka.*"
1141 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001142 if [ -n "$SIM_PODS" ]; then
1143 wait_for_pods "$BBSIM_NS" 0 "not" "Waiting for BBSIM PODs to terminate" "$BBSIM_LABEL" "$SIM_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -07001144 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001145 if [ -n "$INFRA_PODS" ]; then
1146 wait_for_pods "$INFRA_NS" 0 "not" "Waiting for infrastructure PODs to terminate" "$NO_LABEL" "$INFRA_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -07001147 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001148 if [ -n "$ADAPT_PODS" ]; then
1149 wait_for_pods "$ADAPTER_NS" 0 "not" "Waiting for adapter PODs to terminate" "$NO_LABEL" "$ADAPT_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -07001150 fi
divyadesai59f987a2020-05-27 12:11:33 +00001151 if [ -n "$EFK_PODS" ]; then
1152 wait_for_pods "$INFRA_NS" 0 "not" "Waiting for EFK PODs to terminate" "$NO_LABEL" "$EFK_PODS"
1153 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001154 wait_for_pods "$VOLTHA_NS" 0 "not" "Waiting for VOLTHA PODs to terminate" "$NO_LABEL" "$PODS"
David Bainbridge4f1b5562019-08-19 04:46:52 +00001155 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +00001156 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001157 exit
David Bainbridgeac7f8072019-08-01 22:15:33 +00001158fi
1159
1160if [ "$1" == "dump" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001161 LOG="dump-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -07001162 TS="$(date -u +"%Y%m%dT%H%M%SZ")"
1163 if [ -n "$DUMP_FROM" ]; then
1164 TS=${DUMP_FROM//[:-]}
David Bainbridge76514a02019-10-08 01:50:35 +00001165 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001166 WORK="$(mktemp -u -d)"
David Bainbridge0774b232019-08-02 06:37:19 +00001167 DATA=$WORK/voltha-debug-dump-$NAME-$TS
David Bainbridged18f4942020-04-14 16:46:13 -07001168 mkdir -p "$DATA"
1169 echo "$TS" > "$LOG"
David Bainbridge0774b232019-08-02 06:37:19 +00001170 echo -e "Capturing debug dump to voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001171 bspin - "Copy install log"
David Bainbridged18f4942020-04-14 16:46:13 -07001172 if [ -f "install-$NAME.log" ]; then
1173 (set -x; cp "install-$NAME.log" "$DATA/install-$NAME.log") >>"$LOG" 2>&1
1174 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001175 else
David Bainbridge0774b232019-08-02 06:37:19 +00001176 espin - "$NO_ENTRY Copy install log: install-$NAME.log not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001177 fi
1178 bspin - "Dumping Kubernetes PODs"
David Bainbridged18f4942020-04-14 16:46:13 -07001179 (set -x; kubectl get --all-namespaces pods >> "$DATA/all-pods.txt" 2>&1) >>"$LOG" 2>&1
1180 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001181 bspin - "Dumping Kubernetes SERVICEs"
David Bainbridged18f4942020-04-14 16:46:13 -07001182 (set -x; kubectl get --all-namespaces svc >> "$DATA/all-services.txt" 2>&1) >>"$LOG" 2>&1
1183 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001184 bspin - "Dumping Kubernetes EVENTs"
David Bainbridged18f4942020-04-14 16:46:13 -07001185 (set -x; kubectl get --all-namespaces events >> "$DATA/all-events.txt" 2>&1) >>"$LOG" 2>&1
1186 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001187 bspin - "Dumping VOLTHA POD details"
David Bainbridged18f4942020-04-14 16:46:13 -07001188 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 +00001189 SINCE=
David Bainbridged18f4942020-04-14 16:46:13 -07001190 if [ -n "$DUMP_FROM" ]; then
David Bainbridgecfd7ca12019-10-06 03:31:41 +00001191 SINCE="--since-time=$DUMP_FROM"
1192 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +00001193 for POD in $PODS; do
David Bainbridged18f4942020-04-14 16:46:13 -07001194 NS="$(echo "$POD" | cut -d: -f1)"
1195 POD="$(echo "$POD" | cut -d: -f2)"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001196 sspin - "Dumping VOLTHA POD details: $POD$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -07001197 mkdir -p "$DATA/$POD"
1198 (set -x; kubectl describe -n "$NS" "$POD" >> "$DATA/$POD/describe.txt" 2>&1) >>"$LOG" 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +00001199 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridged18f4942020-04-14 16:46:13 -07001200 (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 +00001201 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridged18f4942020-04-14 16:46:13 -07001202 (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 +00001203 sspin - "Dumping VOLTHA POD details: $POD"
1204 done
1205 espin - "$VERIFIED Dumping VOLTHA POD details$CEOL"
1206 bspin - "Dumping ETCD"
David Bainbridged18f4942020-04-14 16:46:13 -07001207 if [ -n "$(command -v etcdctl)" ]; then
1208 (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
1209 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001210 else
1211 espin - "$NO_ENTRY Dumping ETCD: etcdctl command not available"
1212 fi
David Bainbridge0774b232019-08-02 06:37:19 +00001213 bspin - "Creating compressed TAR: voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridged18f4942020-04-14 16:46:13 -07001214 (set -x; tar -C "$WORK" -zcf "voltha-debug-dump-$NAME-$TS.tgz" "./voltha-debug-dump-$NAME-$TS") >>"$LOG" 2>&1
1215 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001216 bspin - "Cleanup"
David Bainbridged18f4942020-04-14 16:46:13 -07001217 (set -x; rm -rf "$WORK") >>"$LOG" 2>&1
1218 espin - "$VERIFIED"
1219 bspin - "$(ls -l "voltha-debug-dump-$NAME-$TS.tgz")"
1220 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001221 exit
1222fi
1223
David Bainbridge0774b232019-08-02 06:37:19 +00001224LOG="install-$NAME.log"
David Bainbridge1d2c5842020-06-03 15:29:07 -07001225PFLOG="port-forward-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -07001226date > "$LOG"
divyadesai59f987a2020-05-27 12:11:33 +00001227echo "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 +00001228
1229# Output install options to log
David Bainbridged18f4942020-04-14 16:46:13 -07001230echo "OPTIONS" >> "$LOG"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001231for O in $ALL_OPTIONS; do
David Bainbridged18f4942020-04-14 16:46:13 -07001232 VAL="$(eval echo "\$$O")"
1233 if [ -n "$VAL" ]; then
1234 printf " %-30s = %s\n" "$O" "$VAL" >> "$LOG"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001235 fi
1236done
1237
David Bainbridgee4d11ca2020-05-08 10:21:10 -07001238# Force remove any existing k8s port-forward processes. This will
1239# remove them for all kind clusters.
David Bainbridgee4d11ca2020-05-08 10:21:10 -07001240if [ "$1" == "clean" ]; then
1241 kill_port_forward __ALL__
1242 exit
1243fi
1244
David Bainbridgefad50732020-05-01 17:00:12 -07001245helm_values() {
1246 local NAMESPACE=$1; shift
1247 local INAME=$1; shift
1248 local CHART=$1; shift
1249 local CHART_VERSION=$1; shift
1250
1251 if [ "$CHART_VERSION X" != " X" ] && [ "$CHART_VERSION" != "latest" ]; then
1252 CHART_VERSION="--version $CHART_VERSION"
1253 else
1254 CHART_VERSION=
1255 fi
1256
1257 local CHART_ARGS=
1258 if [ -r "${INAME}-values.yaml" ]; then
1259 CHART_ARGS="-f ${INAME}-values.yaml"
1260 fi
1261
1262 if [ "$HELM_USE_UPGRADE" == "yes" ]; then
1263 _HELM_COMMAND="upgrade --install"
1264 _HELM_ARGS="xxxdryrunxxx"
1265 else
1266 _HELM_COMMAND="install"
Matteo Scandolof2d080b2020-07-23 13:59:29 -07001267 if [ "$HELM_MAJOR" -le 2 ]; then
1268 _HELM_NAME_ARG="--name xxxdryrunxxx"
1269 _HELM_ARGS=
1270 else
1271 _HELM_NAME_ARG="xxxdryrunxxx"
1272 _HELM_ARGS="--create-namespace"
1273 fi
David Bainbridgefad50732020-05-01 17:00:12 -07001274 fi
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001275 CMD=("helm $_HELM_COMMAND --debug --dry-run -f 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 -07001276 ${CMD[*]} 2>/dev/null | awk 'PRINT==1 {print}; /^USER-SUPPLIED VALUES:/ {PRINT = 1}; /^$/ {PRINT = 0}'
1277}
1278
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001279helm_is_deployed() {
1280 local NAMESPACE=$1; shift
1281 local NAME=$1; shift
1282
1283 if [ "$HELM_MAJOR" -le 2 ]; then
1284 helm list --deployed --short --namespace "$NAMESPACE" "$NAME" 2>/dev/null | wc -l
1285 else
1286 helm list --deployed --short --namespace "$NAMESPACE" --filter "$NAME" 2>/dev/null | wc -l
1287 fi
1288}
1289
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001290helm_install() {
David Bainbridgec7220622020-05-28 12:31:47 -07001291 local INDENT NOW VALUES_FILE PPROF_ARG
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001292 if [ "$1" == "-" ]; then
1293 INDENT=$1; shift
1294 fi
1295 local NAMESPACE=$1; shift
David Bainbridge0774b232019-08-02 06:37:19 +00001296 local INAME=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001297 local CHART=$1; shift
David Bainbridge90fd8e32019-08-21 23:32:47 +00001298 local CHART_VERSION=$1; shift
David Bainbridgec7220622020-05-28 12:31:47 -07001299 local FILTER=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001300 local MESSAGE=$*
1301
David Bainbridged18f4942020-04-14 16:46:13 -07001302 if [ "$CHART_VERSION X" != " X" ] && [ "$CHART_VERSION" != "latest" ]; then
David Bainbridge90fd8e32019-08-21 23:32:47 +00001303 CHART_VERSION="--version $CHART_VERSION"
1304 else
1305 CHART_VERSION=
1306 fi
1307
David Bainbridge99ac7a22019-08-31 02:26:43 +00001308 local CHART_ARGS=
1309 if [ -r "${INAME}-values.yaml" ]; then
1310 CHART_ARGS="-f ${INAME}-values.yaml"
1311 fi
1312
David Bainbridged18f4942020-04-14 16:46:13 -07001313 local WAIT_START CMD
1314 WAIT_START="$(date +%s)"
1315 COUNT="$((300 / 15))"
1316 bspin "$INDENT" "$MESSAGE"
1317 if [ "$HELM_USE_UPGRADE" == "yes" ]; then
David Bainbridge7f8bf992020-04-08 21:53:22 -07001318 _HELM_COMMAND="upgrade --install"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001319 _HELM_NAME_ARG="$INAME"
David Bainbridge7f8bf992020-04-08 21:53:22 -07001320 else
1321 _HELM_COMMAND="install"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001322 if [ "$HELM_MAJOR" -le 2 ]; then
1323 _HELM_NAME_ARG="--name $INAME"
1324 _HELM_ARGS=
1325 else
1326 _HELM_NAME_ARG="$INAME"
1327 _HELM_ARGS="--create-namespace"
1328 fi
David Bainbridge7f8bf992020-04-08 21:53:22 -07001329 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001330
1331 VALUES_FILE="$(mktemp)"
1332 if [ "$FILTER" == "-" ]; then
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001333 cp "values.yaml" "$VALUES_FILE"
David Bainbridgea965ca22020-06-09 17:45:04 -07001334 elif [ "${FILTER:0:1}" == "+" ]; then
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001335 cp "values.yaml" "$VALUES_FILE"
1336 yq r - "${FILTER:1}" <"values.yaml" >>"$VALUES_FILE"
David Bainbridge33e56c72020-06-11 11:39:56 -07001337 cat "$VALUES_FILE" >>"$LOG"
David Bainbridgec7220622020-05-28 12:31:47 -07001338 else
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001339 yq r - "$FILTER" <"values.yaml" >"$VALUES_FILE"
David Bainbridgec7220622020-05-28 12:31:47 -07001340 fi
1341 if [ "$WITH_PPROF" == "yes" ]; then
1342 PPROF_ARG="--set profiler.enabled=true"
1343 fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001344 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 -07001345 (set -x; ${CMD[*]} >>"$LOG" 2>&1) >>"$LOG" 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001346 SUCCESS=$?
David Bainbridged18f4942020-04-14 16:46:13 -07001347 while [ "$SUCCESS" -ne 0 ]; do
1348 NOW="$(date +%s)"
1349 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -07001350 espin "$THEX"
David Bainbridgec7220622020-05-28 12:31:47 -07001351 rm -f "$VALUES_FILE"
David Bainbridge52e6e9d2020-03-23 13:48:27 -07001352 doTimeout "waiting for helm install $CHART"
1353 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001354 sspin "$INDENT"
1355 COUNT="$((COUNT - 1))"
1356 if [ "$COUNT" -eq 0 ]; then
1357 if [ "$HELM_USE_UPGRADE" == "no" ]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001358 if [ "$HELM_MAJOR" -le 2 ]; then
1359 (set -x; helm delete --purge "$INAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1360 else
1361 (set -x; helm uninstall "$INAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1362 fi
David Bainbridge7f8bf992020-04-08 21:53:22 -07001363 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001364 (set -x; ${CMD[*]} >>"$LOG" 2>&1) >>"$LOG" 2>&1
Andy Baviere22ff252019-12-19 11:40:31 -07001365 SUCCESS=$?
David Bainbridged18f4942020-04-14 16:46:13 -07001366 COUNT="$((300 / 15))"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001367 fi
1368 sleep .15
1369 done
David Bainbridgec7220622020-05-28 12:31:47 -07001370 rm -f "$VALUES_FILE"
David Bainbridged18f4942020-04-14 16:46:13 -07001371 espin "$INDENT" "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001372}
1373
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001374echo "INSTALL NAME: $NAME" >> "$LOG"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001375
David Bainbridged18f4942020-04-14 16:46:13 -07001376STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001377if [ "$INSTALL_KUBECTL" == "no" ]; then
1378 bspin "Skip kubectl install"
1379 espin $NO_ENTRY
Test Userc13bdc92019-07-03 20:57:49 +00001380else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001381 bspin "Verify kubectl $HELM"
David Bainbridged18f4942020-04-14 16:46:13 -07001382 if [ -x "$GOPATH/bin/kubectl" ]; then
1383 espin "$VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001384 else
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001385 ERR_OUT="$(mktemp)"
David Bainbridged18f4942020-04-14 16:46:13 -07001386 espin "$NOT_VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001387 bspin - "Download and install Kubernetes/kubectl $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001388 (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
1389 RESULT=$?
1390 if [ "$RESULT" -ne 0 ]; then
1391 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001392 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download kubectl: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001393 cat "$ERR_OUT" >> "$LOG"
Zack Williamsded60cb2020-04-13 10:02:20 -07001394 rm -rf "$ERR_OUT" "$GOPATH/bin/kubectl"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001395 exit 1
1396 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001397 (set -x; chmod 755 "$GOPATH/bin/kubectl" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1398 espin - "$VERIFIED"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001399 rm -rf "$ERR_OUT"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001400 fi
Test Userc13bdc92019-07-03 20:57:49 +00001401fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001402if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001403 NOW="$(date +%s)"
1404 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001405fi
Test Userc13bdc92019-07-03 20:57:49 +00001406
David Bainbridged18f4942020-04-14 16:46:13 -07001407STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001408if [ "$DEPLOY_K8S" == "no" ]; then
1409 bspin "Skip Kubernetes/Kind Deployment"
1410 espin $NO_ENTRY
1411else
Test Userba1e7e72019-07-10 22:27:54 +00001412 bspin "Verify Kubernetes/Kind $HELM"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001413 IS_INSTALLED=0
1414 OP_TYPE="install"
David Bainbridged18f4942020-04-14 16:46:13 -07001415 if [ -x "$GOPATH/bin/kind" ]; then
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001416 OP_TYPE="upgrade"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001417 if [ "$("$GOPATH/bin/kind" version | grep -c "$KIND_VERSION")" -eq 1 ]; then
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001418 IS_INSTALLED=1
David Bainbridged18f4942020-04-14 16:46:13 -07001419 espin "$VERIFIED"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001420 fi
1421 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001422 if [ "$IS_INSTALLED" -eq 0 ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001423 ERR_OUT="$(mktemp)"
David Bainbridged18f4942020-04-14 16:46:13 -07001424 espin "$NOT_VERIFIED"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001425 bspin - "Download and $OP_TYPE Kubernetes/kind $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001426 (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
1427 RESULT=$?
1428 if [ $RESULT -ne 0 ]; then
1429 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001430 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download kind: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001431 cat "$ERR_OUT" >> "$LOG"
Zack Williamsded60cb2020-04-13 10:02:20 -07001432 rm -rf "$ERR_OUT" "$GOPATH/bin/kind"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001433 exit 1
1434 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001435 (set -x; chmod 755 "$GOPATH/bin/kind" >>"$LOG" 2>&1) >>"$LOG" 2>&1
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001436 rm -rf "$ERR_OUT"
David Bainbridged18f4942020-04-14 16:46:13 -07001437 espin - "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001438 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001439fi
1440
David Bainbridgee87067b2019-08-12 22:00:12 +00001441if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001442 NOW="$(date +%s)"
1443 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001444fi
1445
David Bainbridged18f4942020-04-14 16:46:13 -07001446STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001447if [ "$INSTALL_HELM" == "no" ]; then
1448 bspin "Skip Helm Install"
1449 espin $NO_ENTRY
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001450else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001451 bspin "Verify Helm $HELM"
David Bainbridgea34993d2020-04-01 09:15:42 -07001452 HELM_UPGRADE=0
1453 HELM_UPGRADE_DESC="install"
David Bainbridged18f4942020-04-14 16:46:13 -07001454 if [ -x "$GOPATH/bin/helm" ]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001455 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 -07001456 HELM_UP_DOWN="$(echo -e "$HAVE_VER\n$HELM_VERSION" | sort -V | head -1)"
1457 if [ "$HAVE_VER" != "$HELM_VERSION" ]; then
1458 if [ "$HELM_UP_DOWN" == "$HELM_VERSION" ]; then
David Bainbridgea34993d2020-04-01 09:15:42 -07001459 HELM_UPGRADE_DESC="downgrade"
1460 else
1461 HELM_UPGRADE_DESC="upgrade"
1462 fi
1463 HELM_UPGRADE=1
1464 else
David Bainbridged18f4942020-04-14 16:46:13 -07001465 espin "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001466 fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001467 else
David Bainbridgea34993d2020-04-01 09:15:42 -07001468 HELM_UPGRADE=1
1469 fi
1470
David Bainbridged18f4942020-04-14 16:46:13 -07001471 if [ "$HELM_UPGRADE" -ne 0 ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001472 ERR_OUT="$(mktemp)"
1473 INSTALL_HELM_BIN=$(mktemp)
David Bainbridged18f4942020-04-14 16:46:13 -07001474 espin "$NOT_VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001475 bspin - "Download and $HELM_UPGRADE_DESC Helm $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001476 (set -x; curl -o "$INSTALL_HELM_BIN" --fail -sSL https://git.io/get_helm.sh >>"$LOG" 2>"$ERR_OUT") >>"$LOG" 2>&1
1477 RESULT=$?
1478 if [ $RESULT -ne 0 ]; then
1479 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001480 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download helm installer: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001481 cat "$ERR_OUT" >> "$LOG"
1482 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT" "$GOPATH/bin/helm" "$GOPATH/bin/tiller"
1483 exit 1
1484 fi
1485 rm -rf "$ERR_OUT"
1486 chmod +x "$INSTALL_HELM_BIN"
1487 (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
1488 RESULT=$?
1489 if [ $RESULT -ne 0 ]; then
1490 espin - "$THEX"
1491 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to install helm, see install log for details${NORMAL}"
1492 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT" "$GOPATH/bin/helm" "$GOPATH/bin/tiller"
1493 exit 1
1494 fi
1495 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT"
David Bainbridged18f4942020-04-14 16:46:13 -07001496 espin - "$VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001497 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001498fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001499if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001500 NOW="$(date +%s)"
1501 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001502fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001503HELM_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 -07001504
David Bainbridged18f4942020-04-14 16:46:13 -07001505STIME="$(date +%s)"
Test Userb5712372019-07-03 21:52:17 +00001506bspin "Verify voltctl $HIGH_VOLTAGE"
David Bainbridged2811972019-12-14 01:14:09 +00001507VOK=0
1508VMESSAGE="install"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001509ERR_OUT=$(mktemp)
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001510export VC_VERSION="$VOLTCTL_VERSION"
1511if [ "$VC_VERSION" == "latest" ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001512 set -o pipefail # TODO: would be nice to run all in pipefail mode
1513 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')"
1514 RESULT=$?
1515 set +o pipefail
1516 if [ "$RESULT" -ne 0 ]; then
1517 espin - "$THEX"
1518 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to determine released version of voltctl: $(cat "$ERR_OUT")${NORMAL}"
1519 rm -rf "$ERR_OUT" "$GOPATH/bin/voltctl"
1520 exit 1
1521 fi
1522 export VC_VERSION
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001523fi
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001524
David Bainbridged18f4942020-04-14 16:46:13 -07001525if [ -x "$GOPATH/bin/voltctl" ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001526 VHAVE="$("$GOPATH/bin/voltctl" version --clientonly -o json 2>/dev/null | jq -r .version)"
David Bainbridged18f4942020-04-14 16:46:13 -07001527 RESULT=$?
1528 if [ $RESULT -eq 0 ] && [ "$VHAVE" == "$VC_VERSION" ]; then
David Bainbridged2811972019-12-14 01:14:09 +00001529 VOK=1
David Bainbridged18f4942020-04-14 16:46:13 -07001530 espin "$VERIFIED"
David Bainbridge1ba64f12019-12-18 00:40:13 +00001531 else
David Bainbridged18f4942020-04-14 16:46:13 -07001532 VCHECK="$(echo -e "$VHAVE\n$VC_VERSION" | sort -V | head -1)"
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001533 if [ "$VCHECK" == "$VHAVE" ]; then
1534 VMESSAGE="upgrade"
1535 else
1536 VMESSAGE="downgrade"
1537 fi
David Bainbridged2811972019-12-14 01:14:09 +00001538 fi
1539fi
1540
David Bainbridged18f4942020-04-14 16:46:13 -07001541if [ "$VOK" -eq 0 ]; then
1542 espin "$NOT_VERIFIED"
David Bainbridged2811972019-12-14 01:14:09 +00001543 bspin - "Download and $VMESSAGE voltctl $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001544 (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
1545 RESULT=$?
1546 if [ $RESULT -ne 0 ]; then
1547 espin - "$THEX"
1548 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download voltctl (version $VC_VERSION): $(cat "$ERR_OUT")${NORMAL}"
1549 rm -rf "$ERR_OUT" "$GOPATH/bin/voltctl"
1550 exit 1
1551 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001552 (set -x; chmod 755 "$GOPATH/bin/voltctl" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1553 espin - "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001554fi
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001555rm -rf "$ERR_OUT"
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
1561bspin "Verify command PATH"
David Bainbridged18f4942020-04-14 16:46:13 -07001562espin "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001563
David Bainbridged18f4942020-04-14 16:46:13 -07001564STIME="$(date +%s)"
Test Userba1e7e72019-07-10 22:27:54 +00001565if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001566 HAVE="$(kind get clusters 2>/dev/null | grep -c "voltha-$NAME")"
Test Userba1e7e72019-07-10 22:27:54 +00001567 bspin "Verify Kubernetes/Kind Cluster"
1568 sspin
David Bainbridged18f4942020-04-14 16:46:13 -07001569 if [ "$HAVE" -eq 0 ]; then
1570 espin "$NOT_VERIFIED"
Andrea Campanella8a149192020-07-31 17:19:45 +02001571 FILE="$NAME-cluster.cfg"
David K. Bainbridge2aa08da2020-07-31 12:49:45 -07001572 if [ -n "$KIND_CFG_FILE" ]; then
1573 FILE="$KIND_CFG_FILE"
1574 else
1575 bspin - "Generating cluster configuration"
Andrea Campanelladd946472020-07-31 11:03:44 +02001576
David K. Bainbridge2aa08da2020-07-31 12:49:45 -07001577 if [ -f "$FILE" ] ; then
1578 rm "$FILE"
1579 fi
1580
1581 touch "$FILE"
1582
1583 yq w -i "$FILE" kind Cluster
1584 yq w -i "$FILE" apiVersion "kind.sigs.k8s.io/v1alpha3"
1585
1586 if [ ! "$NUM_OF_CONTROLLER_NODES" -eq 0 ]; then
1587 for instance in $(seq 1 "$NUM_OF_CONTROLLER_NODES"); do
1588 yq w -i "$FILE" "nodes[+].role" "control-plane"
1589 done
1590 fi
1591
1592 if [ ! "$NUM_OF_WORKER_NODES" -eq 0 ]; then
1593 for instance in $(seq 1 "$NUM_OF_WORKER_NODES"); do
1594 yq w -i "$FILE" "nodes[+].role" worker
1595 done
1596 fi
1597 espin - "$VERIFIED"
Andrea Campanelladd946472020-07-31 11:03:44 +02001598 fi
1599
Andrea Campanella8a149192020-07-31 17:19:45 +02001600 cat "$FILE" >> "$LOG" 2>&1
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001601
Andrea Campanella8a149192020-07-31 17:19:45 +02001602 kind create cluster --name "voltha-$NAME" --config "$FILE"
David Bainbridge491b1bd2019-07-11 17:53:11 +00001603 else
David Bainbridged18f4942020-04-14 16:46:13 -07001604 espin "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001605 fi
1606
David K. Bainbridgec0ec6492020-07-21 17:34:23 +00001607 KUBECONFIG_TMP=$(mktemp)
1608 kind get kubeconfig --name="voltha-$NAME" >"$KUBECONFIG_TMP"
1609 mkdir -p "$HOME/.kube"
1610 KUBECONFIG="$HOME/.kube/kind-config-voltha-$NAME"; export KUBECONFIG
1611 cp "$KUBECONFIG_TMP" "$KUBECONFIG"
1612 rm -rf "$KUBECONFIG_TMP"
David Bainbridge1d2c5842020-06-03 15:29:07 -07001613
Test Userba1e7e72019-07-10 22:27:54 +00001614 P="coredns-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001615 etcd-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +00001616 kindnet-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001617 kube-apiserver-voltha-$NAME-control-plane \
1618 kube-controller-manager-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +00001619 kube-proxy-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001620 kube-scheduler-voltha-$NAME-control-plane"
Test Userba1e7e72019-07-10 22:27:54 +00001621
David K. Bainbridge2aa08da2020-07-31 12:49:45 -07001622 EXPECT=2 # Always 2 DNS instances
1623 EXPECT=$((EXPECT + 4 * NUM_OF_CONTROLLER_NODES)) # etcd, apiserver, controller manager, scheduler
1624 EXPECT=$((EXPECT + 2 * (NUM_OF_CONTROLLER_NODES + NUM_OF_WORKER_NODES))) # kindnet, proxy
David Bainbridged18f4942020-04-14 16:46:13 -07001625 wait_for_pods - "kube-system" "$EXPECT" "includes" "Waiting for system PODs to start" "$NO_LABEL" "$P"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001626fi
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001627
David Bainbridgee87067b2019-08-12 22:00:12 +00001628if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001629 NOW="$(date +%s)"
1630 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001631fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001632
David Bainbridgee4d11ca2020-05-08 10:21:10 -07001633if [ "$SCHEDULE_ON_CONTROL_NODES" == "yes" ]; then
1634 bspin "Untaint control nodes to allow scheduling $LOCK"
1635 for MNODE in $(kubectl get node --selector='node-role.kubernetes.io/master' -o json | jq -r '.items[].metadata.name'); do
1636 (set -x; kubectl taint node "$MNODE" node-role.kubernetes.io/master:NoSchedule- >>"$LOG" 2>&1) >>"$LOG" 2>&1
1637 sspin
1638 done
1639 espin "$VERIFIED"
1640fi
1641
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001642if [ "$HELM_MAJOR" -le 2 ]; then
1643 STIME="$(date +%s)"
1644 COUNT="$(count_pods "kube-system" ":Running:" "$NO_LABEL" "tiller-deploy-.*")"
1645 bspin "Verify Helm"
1646 if [ "$COUNT" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001647 espin "$NOT_VERIFIED"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001648 echo -e "Configuring Helm $GEAR"
1649 if [ "$INSTALL_HELM" == "no" ]; then
1650 bspin - "Skip Helm Initialization"
1651 espin - $NO_ENTRY
1652 else
1653 bspin - "Initialize Helm"
1654 (set -x; helm init --upgrade >>"$LOG" 2>&1) >>"$LOG" 2>&1
1655 espin - "$VERIFIED"
1656 wait_for_pods - "kube-system" 1 "includes" "Waiting for Tiller POD to start" "$NO_LABEL" "tiller-deploy-.*"
1657 fi
1658
1659 # HACK (sort-of) - the config for tiller is about to be patched, which will
1660 # cause the tiller pod to be recreated. This can sometimes cause a timing
1661 # issue with the "wait_for_pods" call on tiller as it may incorrectly
1662 # identify the running/ready tiller pod that is soon to be terminated as
1663 # what it is waiting for. To avoid this issue we do a clean scale down and
1664 # scale up of the pod so the script controlls when it should be expecting
1665 # things
1666 (set -x; kubectl -n kube-system scale deploy tiller-deploy --replicas=0 >>"$LOG" 2>&1) >>"$LOG" 2>&1
1667 wait_for_pods - "kube-system" 0 "not" "Waiting for Tiller POD to shutdown" "$NO_LABEL" "tiller-deploy-.*"
1668
1669 # Create and k8s service account so that Helm can create pods
1670 bspin - "Create Tiller ServiceAccount"
1671 (set -x; kubectl create serviceaccount --namespace kube-system tiller >>"$LOG" 2>&1) >>"$LOG" 2>&1
1672 espin - "$VERIFIED"
1673 bspin - "Create Tiller ClusterRoleBinding"
1674 (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>"$LOG" 2>&1) >>"$LOG" 2>&1
1675 espin - "$VERIFIED"
1676 bspin - "Update Tiller Manifest"
1677 (set -x; kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}' >>"$LOG" 2>&1) >>"$LOG" 2>&1
1678
1679 # HACK (sort-of) - part to, spin it back up
1680 (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 -07001681 espin - "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001682 else
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001683 if [ "$(helm version -s --template '{{.Server.SemVer}}')" != "$HELM_VERSION" ]; then
1684 espin "$NOT_VERIFIED"
1685 bspin - "Sync Tiller server version with helm client"
1686 (set -x; helm init --upgrade --force-upgrade --wait >>"$LOG" 2>&1) >>"$LOG" 2>&1
1687 espin - "$VERIFIED"
1688 else
1689 espin "$VERIFIED"
1690 fi
1691
David Bainbridgea34993d2020-04-01 09:15:42 -07001692 fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001693 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 -07001694fi
David Bainbridgeddeab482020-06-24 12:43:40 -07001695
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001696# The `etcd` repo is temporary until `http://github.com/helm/charts/pull/22955` is
1697# merged into the incubator charts
David Bainbridgeddeab482020-06-24 12:43:40 -07001698REPOS="onf|https://charts.opencord.org|ONF_VOLTHA \
1699 stable|https://kubernetes-charts.storage.googleapis.com|Google_Stable \
Ubuntubaab12f2020-06-30 01:08:19 +00001700 incubator|https://kubernetes-charts-incubator.storage.googleapis.com|Google_Incubator \
1701 onos|https://charts.onosproject.org|ONF_ONOS \
1702 atomix|https://charts.atomix.io|ONF_Atomix \
1703 bbsim-sadis|https://ciena.github.io/bbsim-sadis-server/charts|Custom_BBSIM_SADIS_Server \
1704 elastic|https://helm.elastic.co|Elastic \
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001705 kiwigrid|https://kiwigrid.github.io|Fluentd-ElasticSearch \
1706 etcd|https://dbainbri-ciena.github.io/etcd-helm-chart"
David Bainbridgeddeab482020-06-24 12:43:40 -07001707
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001708REPO_UPDATE_REQ="no"
David Bainbridgeddeab482020-06-24 12:43:40 -07001709bspin - "Verify Helm Repository"
1710for REPO in $REPOS; do
1711 REPO_NAME="$(echo "$REPO" | cut -d\| -f1)"
1712 REPO_URL="$(echo "$REPO" | cut -d\| -f2)"
1713 REPO_LABEL="$(echo "$REPO" | cut -d\| -f3 | sed -e 's/_/ /g')"
1714
1715 sspin - "Verify Helm Repository: $REPO_LABEL$CEOL"
1716 if [ "$(helm repo list 2>/dev/null | grep -c "$REPO_NAME" 2>/dev/null)" -eq 0 ]; then
1717 sspin - "Add Helm Repository: $REPO_LABEL$CEOL"
1718 (set -x; helm repo add "$REPO_NAME" "$REPO_URL" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1719 REPO_UPDATE_REQ="yes"
1720 fi
1721done
1722sspin - "Verify Helm Repositories$CEOL"
1723espin - "$VERIFIED"
1724
1725if [ "$REPO_UPDATE_REQ" == "yes" ] || [ "$UPDATE_HELM_REPOS" == "yes" ]; then
1726 bspin - "Update Helm repository cache"
1727 (set -x; helm repo update >>"$LOG" 2>&1) >>"$LOG" 2>&1
1728 espin - "$VERIFIED"
1729fi
1730
David Bainbridgee87067b2019-08-12 22:00:12 +00001731if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001732 NOW="$(date +%s)"
1733 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001734fi
David Bainbridgecf546362020-04-21 23:18:50 -07001735# Resolve chart versions and log them for debug/support
1736RESOLVED_VOLTHA_CHART_VERSION=$(resolve_chart_version "$VOLTHA_CHART" "$VOLTHA_CHART_VERSION")
1737RESOLVED_VOLTHA_BBSIM_CHART_VERSION=$(resolve_chart_version "$VOLTHA_BBSIM_CHART" "$VOLTHA_BBSIM_CHART_VERSION")
1738RESOLVED_VOLTHA_ADAPTER_SIM_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_SIM_CHART" "$VOLTHA_ADAPTER_SIM_CHART_VERSION")
1739RESOLVED_VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_OPEN_OLT_CHART" "$VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION")
1740RESOLVED_VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_OPEN_ONU_CHART" "$VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION")
1741RESOLVED_ONOS_CHART_VERSION=$(resolve_chart_version "$ONOS_CHART" "$ONOS_CHART_VERSION")
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001742RESOLVED_ONOS_CLASSIC_CHART_VERSION=$(resolve_chart_version "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION")
David Bainbridgecf546362020-04-21 23:18:50 -07001743RESOLVED_KAFKA_CHART_VERSION=$(resolve_chart_version "$KAFKA_CHART" "$KAFKA_CHART_VERSION")
divyadesai59f987a2020-05-27 12:11:33 +00001744RESOLVED_ELASTICSEARCH_CHART_VERSION=$(resolve_chart_version "$ELASTICSEARCH_CHART" "$ELASTICSEARCH_CHART_VERSION")
1745RESOLVED_KIBANA_CHART_VERSION=$(resolve_chart_version "$KIBANA_CHART" "$KIBANA_CHART_VERSION")
1746RESOLVED_FLUENTD_ELASTICSEARCH_CHART_VERSION=$(resolve_chart_version "$FLUENTD_ELASTICSEARCH_CHART" "$FLUENTD_ELASTICSEARCH_CHART_VERSION")
David K. Bainbridge450c15c2020-06-29 10:12:06 -07001747RESOLVED_BBSIM_SADIS_SERVER_CHART_VERSION=$(resolve_chart_version "$BBSIM_SADIS_SERVER_CHART" "$BBSIM_SADIS_SERVER_CHART_VERSION")
1748RESOLVED_RADIUS_CHART_VERSION=$(resolve_chart_version "$RADIUS_CHART" "$RADIUS_CHART_VERSION")
David Bainbridgecf546362020-04-21 23:18:50 -07001749cat <<EOV >>"$LOG"
1750Resolved helm charts and versions:
1751 $VOLTHA_CHART:$RESOLVED_VOLTHA_CHART_VERSION
1752 $VOLTHA_BBSIM_CHART:$RESOLVED_VOLTHA_BBSIM_CHART_VERSION
1753 $VOLTHA_ADAPTER_SIM_CHART:$RESOLVED_VOLTHA_ADAPTER_SIM_CHART_VERSION
1754 $VOLTHA_ADAPTER_OPEN_OLT_CHART:$RESOLVED_VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION
1755 $VOLTHA_ADAPTER_OPEN_ONU_CHART:$RESOLVED_VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION
1756 $ONOS_CHART:$RESOLVED_ONOS_CHART_VERSION
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001757 $ONOS_CLASSIC_CHART:$RESOLVED_ONOS_CLASSIC_CHART_VERSION
David Bainbridgecf546362020-04-21 23:18:50 -07001758 $KAFKA_CHART:$RESOLVED_KAFKA_CHART_VERSION
divyadesai59f987a2020-05-27 12:11:33 +00001759 $ELASTICSEARCH_CHART:$RESOLVED_ELASTICSEARCH_CHART_VERSION
1760 $KIBANA_CHART:$RESOLVED_KIBANA_CHART_VERSION
1761 $FLUENTD_ELASTICSEARCH_CHART:$RESOLVED_FLUENTD_ELASTICSEARCH_CHART_VERSION
David K. Bainbridge450c15c2020-06-29 10:12:06 -07001762 $BBSIM_SADIS_SERVER_CHART:$RESOLVED_BBSIM_SADIS_SERVER_CHART_VERSION
1763 $RADIUS_CHART:$RESOLVED_RADIUS_CHART_VERSION
David Bainbridgecf546362020-04-21 23:18:50 -07001764EOV
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001765
David Bainbridged18f4942020-04-14 16:46:13 -07001766STIME="$(date +%s)"
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001767bspin "Verify Helm values file: values.yaml"
1768if [ ! -r "./values.yaml" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001769 espin "$NOT_VERIFIED"
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001770 bspin - "Download Helm values file: values.yaml to values.yaml $DOWNLOAD"
David Bainbridged18f4942020-04-14 16:46:13 -07001771 ERR_OUT="$(mktemp)"
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001772 if ! (set -x; curl --fail -o "./values.yaml" -sSL "https://raw.githubusercontent.com/opencord/kind-voltha/$VK_RELEASE/values.yaml" >>"$LOG" 2>"$ERR_OUT") >>"$LOG" 2>&1; then
David Bainbridged18f4942020-04-14 16:46:13 -07001773 espin - "$THEX"
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001774 echo -e "${RED}${BOLD}${ERROR}ERROR: values.yaml${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
David Bainbridged18f4942020-04-14 16:46:13 -07001775 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001776 rm -rf "$ERR_OUT" "./values.yaml"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001777 exit 1
1778 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001779 rm -rf "$ERR_OUT"
1780 espin - "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001781else
David Bainbridged18f4942020-04-14 16:46:13 -07001782 espin "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001783fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001784if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001785 NOW="$(date +%s)"
1786 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001787fi
Test Userba1e7e72019-07-10 22:27:54 +00001788
David Bainbridged18f4942020-04-14 16:46:13 -07001789STIME="$(date +%s)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001790bspin "Verify or download chart specific values files $DOWNLOAD"
1791VALUES_FILES="monkey-values.yaml"
David Bainbridged18f4942020-04-14 16:46:13 -07001792ERR_OUT="$(mktemp)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001793for i in $VALUES_FILES; do
1794 if [ ! -r ./$i ]; then
serkant.uluderya4d315132020-04-15 16:25:54 -07001795 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 -07001796 espin "$THEX"
1797 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1798 echo "ERROR: $i - $(cat "$ERR_OUT")" >>"$LOG"
1799 rm -rf "$ERR_OUT" "./$i"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001800 exit 1
1801 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001802 rm -rf "$ERR_OUT"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001803 fi
1804done
David Bainbridged18f4942020-04-14 16:46:13 -07001805rm -rf "$ERR_OUT"
1806espin "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001807if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001808 NOW="$(date +%s)"
1809 printtime $((NOW - STIME))
David Bainbridge99ac7a22019-08-31 02:26:43 +00001810fi
1811
1812if [ "$WITH_CHAOS" == "yes" ]; then
1813 bspin "Verify or clone kube-monkey helm chart $DOWNLOAD"
1814 if [ -r ./kube-monkey ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001815 espin "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001816 else
David Bainbridged18f4942020-04-14 16:46:13 -07001817 espin "$NOT_VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001818 bspin - "GIT clone kube-monkey"
David Bainbridged18f4942020-04-14 16:46:13 -07001819 (set -x; git clone https://github.com/asobti/kube-monkey kube-monkey >>"$LOG" 2>&1) >>"$LOG" 2>&1
1820 espin - "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001821 fi
1822fi
1823
Test Userba1e7e72019-07-10 22:27:54 +00001824if [ "$JUST_K8S" == "yes" ]; then
1825 echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye."
1826 echo ""
David Bainbridged18f4942020-04-14 16:46:13 -07001827 echo "Please issue the following commands in your terminal to ensure that you" | tee -a "$LOG"
1828 echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a "$LOG"
1829 echo "tools required by VOLTHA in your command path. " | tee -a "$LOG"
1830 echo "" | tee -a "$LOG"
1831 echo -en "$BOLD"
1832 if [ "$DEPLOY_K8S" == "yes" ]; then
David K. Bainbridge02ae1f32020-07-21 13:25:13 -07001833 KUBECONFIG_TMP=$(mktemp)
1834 kind get kubeconfig --name="voltha-$NAME" >"$KUBECONFIG_TMP"
1835 mkdir -p "$HOME/.kube"
1836 KUBECONFIG="$HOME/.kube/kind-config-voltha-$NAME"; export KUBECONFIG
1837 cp "$KUBECONFIG_TMP" "$KUBECONFIG"
1838 rm -rf "$KUBECONFIG_TMP"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001839 echo "export KUBECONFIG=\"$KUBECONFIG\"" | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00001840 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001841 echo "export PATH=$GOPATH/bin:\$PATH" | tee -a "$LOG"
1842 echo -en "$NORMAL"
1843 echo "" | tee -a "$LOG"
1844 echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00001845 exit 0
1846fi
1847
David Bainbridged18f4942020-04-14 16:46:13 -07001848STIME="$(date +%s)"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001849if is_in "$WITH_ONOS" "yes,legacy,classic"; then
1850 if is_in "$WITH_ONOS" "legacy"; then
1851 bspin "Verify ONOS LEGACY installed $BIRD"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001852 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^onos\$")" -ne 1 ]; then
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001853 espin "$NOT_VERIFIED"
David Bainbridge33e56c72020-06-11 11:39:56 -07001854 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 -07001855 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
1856 else
1857 espin "$VERIFIED"
1858 fi
1859 wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for ONOS to start" "$NO_LABEL" "onos-.*"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001860
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001861 if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
1862 bspin - "Forward ONOS API port $FORWARD"
1863 kill_port_forward onos-ui
1864 port_forward "$INFRA_NS" onos-ui "$ONOS_API_PORT:8181"
1865 espin - "$VERIFIED"
1866 bspin - "Forward ONOS SSH port $FORWARD"
1867 kill_port_forward onos-ssh
1868 port_forward "$INFRA_NS" onos-ssh "$ONOS_SSH_PORT:8101"
1869 espin - "$VERIFIED"
1870 _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT"
1871 else
1872 _ONOS_API_EP="$(get_service_ep "$INFRA_NS" onos-ui)"
1873 fi
1874 elif is_in "$WITH_ONOS" "yes,classic"; then
1875 bspin "Verify ONOS CLASSIC installed $BIRD"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001876 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^onos\$")" -ne 1 ]; then
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001877 espin "$NOT_VERIFIED"
Matteo Scandoloe0829b52020-05-08 14:23:56 -07001878 # 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 -07001879 # values value
David Bainbridgefad50732020-05-01 17:00:12 -07001880 YAML_VALUES=$(INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set replicas=$NUM_OF_ONOS --set atomix.replicas=$NUM_OF_ATOMIX" \
1881 helm_values "$INFRA_NS" onos "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION")
1882 _ONOS_REPO="$(echo "$YAML_VALUES" | yq read - images.onos.repository)"
David Bainbridgedee3f022020-06-05 07:45:13 -07001883 if [ -z "$_ONOS_REPO" ]; then
1884 _ONOS_REPO="voltha/voltha-onos"
1885 fi
David Bainbridgefad50732020-05-01 17:00:12 -07001886 _ONOS_TAG="$(echo "$YAML_VALUES" | yq read - images.onos.tag)"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001887 if [ -z "$_ONOS_TAG" ]; then
David Bainbridgedee3f022020-06-05 07:45:13 -07001888 _ONOS_TAG="$(echo "$YAML_VALUES" | yq read - defaults.image_tag)"
1889 fi
1890 if [ -z "$_ONOS_TAG" ]; then
1891 _ONOS_TAG="master"
1892 fi
1893 _ONOS_PULL_POLICY="$(echo "$YAML_VALUES" | yq read - images.onos.pullPolicy)"
1894 if [ -z "$_ONOS_PULL_POLICY" ]; then
1895 _ONOS_PULL_POLICY="$(echo "$YAML_VALUES" | yq read - defaults.image_pullPolicy)"
1896 fi
1897 if [ -z "$_ONOS_PULL_POLICY" ]; then
1898 _ONOS_PULL_POLICY="Always"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001899 fi
David Bainbridgefad50732020-05-01 17:00:12 -07001900
Matteo Scandoloe0829b52020-05-08 14:23:56 -07001901 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 -07001902 helm_install - "$INFRA_NS" onos "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION" "+onos" "$_HELM_DESC ONOS CLASSIC"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001903 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
1904 else
1905 espin "$VERIFIED"
1906 fi
1907 wait_for_pods - "$INFRA_NS" $((NUM_OF_ONOS + NUM_OF_ATOMIX)) "includes" "Waiting for ONOS CLASSIC to start" "$NO_LABEL" "onos-.*"
1908 if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
1909 bspin - "Forward ONOS API port $FORWARD"
1910 kill_port_forward onos-onos-classic-hs
1911 port_forward "$INFRA_NS" onos-onos-classic-hs "$ONOS_API_PORT:8181" "$ONOS_SSH_PORT:8101"
1912 espin - "$VERIFIED"
1913 _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT"
1914 else
1915 _ONOS_API_EP="$(get_service_ep "$INFRA_NS" onos-onos-classic-hs)"
1916 fi
1917 elif [ "$WITH_ONOS" == "micro" ]; then
1918 bspin "Verify micro-ONOS installed $BIRD"
1919 # We should never get here
1920 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Micro ONOS not currently supported${NORMAL}"
1921 exit 1
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001922 fi
David Bainbridged31d6122019-08-13 19:37:59 +00001923 bspin - "Verify or download ONOS configuration support files $DOWNLOAD"
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001924 ONOS_FILES="olt-onos-enableExtraneousRules.json onos-aaa.json \
David Bainbridge696bc632020-04-05 21:49:37 -07001925 onos-dhcpl2relay.json onos-sadis-sample.json"
David Bainbridged18f4942020-04-14 16:46:13 -07001926 (set -x; mkdir -p ./onos-files >>"$LOG" 2>&1) >>"$LOG" 2>&1
1927 ERR_OUT="$(mktemp)"
David Bainbridge2b19e832019-08-16 02:40:53 +00001928 for i in $ONOS_FILES; do
David Bainbridged18f4942020-04-14 16:46:13 -07001929 if [ ! -r "./onos-files/$i" ]; then
serkant.uluderya4d315132020-04-15 16:25:54 -07001930 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 -07001931 espin - "$THEX"
1932 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1933 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
1934 rm -rf "$ERR_OUT" "./onos-files/$i"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001935 exit 1
1936 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001937 rm -rf "$ERR_OUT"
David Bainbridged31d6122019-08-13 19:37:59 +00001938 fi
1939 done
David Bainbridged18f4942020-04-14 16:46:13 -07001940 rm -rf "$ERR_OUT"
1941 espin - "$VERIFIED"
David Bainbridge27790d62019-08-13 22:43:19 +00001942
David Bainbridged18f4942020-04-14 16:46:13 -07001943 if [ "$INSTALL_ONOS_APPS" == "yes" ]; then
David Bainbridge27790d62019-08-13 22:43:19 +00001944 bspin - "Installing custom ONOS applications"
David Bainbridged18f4942020-04-14 16:46:13 -07001945 if [ -x onos-files/onos-apps ] && [ "$(find onos-files/onos-apps -name "*.oar" 2>/dev/null | wc -l)" -gt 0 ]; then
1946 for OAR in onos-files/onos-apps/*.oar; do
David Bainbridge27790d62019-08-13 22:43:19 +00001947 sspin - "Installing custom ONOS applications - $OAR$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -07001948 override_onos_app "$OAR"
David Bainbridge27790d62019-08-13 22:43:19 +00001949 done
1950 espin - "$VERIFIED Installing custom ONOS applications$CEOL"
1951 else
1952 espin - "$NOT_VERIFIED Installing custom ONOS applications - None Found"
1953 fi
1954 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001955
David Bainbridged18f4942020-04-14 16:46:13 -07001956 if [ "$WITH_KAFKA" != "no" ]; then
David Bainbridge837e8bd2020-04-06 13:17:14 -07001957 check_onos_app_active org.opencord.kafka
David Bainbridge879439b2020-06-12 15:59:35 -07001958 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridgec7220622020-05-28 12:31:47 -07001959 _HOST=kafka.$INFRA_NS.svc
David Bainbridge76afd812020-04-06 09:53:52 -07001960 _PORT=9092
David Bainbridge879439b2020-06-12 15:59:35 -07001961 elif [ "$WITH_KAFKA" != "no" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001962 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
1963 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge837e8bd2020-04-06 13:17:14 -07001964 _PORT=${_PORT:-9092}
1965 fi
1966 push_onos_config "json" "Push ONOS Kafka Configuration" "network/configuration/apps/org.opencord.kafka" \
David Bainbridged18f4942020-04-14 16:46:13 -07001967 "$(cat <<EOJ | tr -d '[:space:]'
David Bainbridge696bc632020-04-05 21:49:37 -07001968{
1969 "kafka": {
1970 "bootstrapServers": "$_HOST:$_PORT"
1971 }
1972}
1973EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07001974)"
David Bainbridge837e8bd2020-04-06 13:17:14 -07001975 fi
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001976 check_onos_app_active org.opencord.dhcpl2relay
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001977 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 -08001978 check_onos_app_active org.opencord.olt
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001979 # FIXME use WITH_DHCP and WITH_EAPOL flags to configre OLT App
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001980 # Default value for "enableEapol" is true in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07001981 if [ "$WITH_EAPOL" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001982 push_onos_config "json" "Enable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":true}'
David Bainbridged18f4942020-04-14 16:46:13 -07001983 elif [ "$WITH_EAPOL" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001984 push_onos_config "json" "Disable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001985 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001986 # Default value for "enableDhcpOnProvisioning" is false and for "enableDhcpV4" is true in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07001987 if [ "$WITH_DHCP" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001988 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 -07001989 elif [ "$WITH_DHCP" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001990 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 -08001991 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001992 # Default value for "enableIgmpOnProvisioning" is false in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07001993 if [ "$WITH_IGMP" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001994 push_onos_config "json" "Enable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":true}'
David Bainbridged18f4942020-04-14 16:46:13 -07001995 elif [ "$WITH_IGMP" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001996 push_onos_config "json" "Disable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001997 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001998 if [ "$ENABLE_ONOS_EXTRANEOUS_RULES" == "yes" ]; then
David K. Bainbridge484d80c2020-03-05 21:44:34 -08001999 push_onos_config "file" "Enabling extraneous rules for ONOS" "configuration/org.onosproject.net.flow.impl.FlowRuleManager" "onos-files/olt-onos-enableExtraneousRules.json"
2000 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002001 if is_in "$CONFIG_SADIS" "yes,file"; then
Matteo Scandolo9a77a732020-01-09 14:24:12 -08002002 check_onos_app_active org.opencord.sadis
Hardik Windlassb3147602020-03-09 16:59:15 +05302003 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 -07002004 elif [ "$CONFIG_SADIS" == "bbsim" ]; then
2005 push_onos_config "json" \
2006 "[optional] Push ONOS configuration for BBSIM SADIS servers" \
2007 "network/configuration/apps/org.opencord.sadis" \
David Bainbridged18f4942020-04-14 16:46:13 -07002008 "$(cat <<EOJ | tr -d '[:space:]'
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002009{
2010 "sadis": {
2011 "integration": {
David Bainbridgec7220622020-05-28 12:31:47 -07002012 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:50074/v2/subscribers/%s",
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002013 "cache": {
2014 "enabled": true,
2015 "maxsize": 50,
2016 "ttl": "PT1m"
2017 }
2018 }
2019 },
2020 "bandwidthprofile": {
2021 "integration": {
David Bainbridgec7220622020-05-28 12:31:47 -07002022 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:50074/v2/bandwidthprofiles/%s",
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002023 "cache": {
2024 "enabled": true,
2025 "maxsize": 50,
2026 "ttl": "PT1m"
2027 }
2028 }
2029 }
2030}
2031EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07002032)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002033 elif [ "$CONFIG_SADIS" == "url" ]; then
2034 push_onos_config "json" \
2035 "[optional] Push ONOS configuration for custom SADIS and Bandwidth Profile servers" \
2036 "network/configuration/apps/org.opencord.sadis" \
David Bainbridged18f4942020-04-14 16:46:13 -07002037 "$(cat <<EOJ | tr -d '[:space:]'
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002038{
2039 "sadis": {
2040 "integration": {
2041 "url": "$SADIS_SUBSCRIBERS",
2042 "cache": {
2043 "enabled": true,
2044 "maxsize": 50,
2045 "ttl": "PT1m"
2046 }
2047 }
2048 },
2049 "bandwidthprofile": {
2050 "integration": {
2051 "url": "$SADIS_BANDWIDTH_PROFILES",
2052 "cache": {
2053 "enabled": true,
2054 "maxsize": 50,
2055 "ttl": "PT1m"
2056 }
2057 }
2058 }
2059}
2060EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07002061)"
David Bainbridge2b19e832019-08-16 02:40:53 +00002062 fi
Test Userba1e7e72019-07-10 22:27:54 +00002063fi
David Bainbridgee87067b2019-08-12 22:00:12 +00002064if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002065 NOW="$(date +%s)"
2066 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002067fi
Test Userba1e7e72019-07-10 22:27:54 +00002068
David Bainbridgec7220622020-05-28 12:31:47 -07002069if is_in "$WITH_ETCD" "yes,external"; then
David Bainbridged18f4942020-04-14 16:46:13 -07002070 STIME="$(date +%s)"
David Bainbridge76afd812020-04-06 09:53:52 -07002071 bspin "Verify external ETCD cluster $OLD_KEY"
Matteo Scandolo657e13c2020-07-28 11:41:42 -07002072 EXPECT=$NUM_OF_ETCD
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002073 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^etcd\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002074 espin "$NOT_VERIFIED"
Matteo Scandolo657e13c2020-07-28 11:41:42 -07002075 INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set replicas=$NUM_OF_ETCD" helm_install - "$INFRA_NS" etcd "$ETCD_CHART" "$ETCD_CHART_VERSION" etcd "$_HELM_DESC external ETCD cluster"
2076 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
David Bainbridge76afd812020-04-06 09:53:52 -07002077 else
David Bainbridged18f4942020-04-14 16:46:13 -07002078 espin "$VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07002079 fi
David Bainbridgec7220622020-05-28 12:31:47 -07002080 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for ETCD cluster to start" "$NO_LABEL" "etcd-.*"
David Bainbridge76afd812020-04-06 09:53:52 -07002081 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002082 NOW="$(date +%s)"
2083 printtime $((NOW - STIME))
David Bainbridge76afd812020-04-06 09:53:52 -07002084 fi
2085fi
2086
David Bainbridgec7220622020-05-28 12:31:47 -07002087if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridged18f4942020-04-14 16:46:13 -07002088 _TMP="$(mktemp -u)"
David Bainbridged18f4942020-04-14 16:46:13 -07002089 cat << EOC > "$_TMP"
David Bainbridge76afd812020-04-06 09:53:52 -07002090configurationOverrides:
Matteo Scandolo657e13c2020-07-28 11:41:42 -07002091 "default.replication.factor": $NUM_OF_KAFKA
2092 "offsets.topic.replication.factor": $NUM_OF_KAFKA
David Bainbridge76afd812020-04-06 09:53:52 -07002093 "log.retention.hours": 4
2094 "log.message.timestamp.type": "LogAppendTime"
2095persistence:
2096 enabled: false
2097zookeeper:
Matteo Scandolo657e13c2020-07-28 11:41:42 -07002098 replicaCount: $NUM_OF_KAFKA
David Bainbridge76afd812020-04-06 09:53:52 -07002099 persistence:
2100 enabled: false
Matteo Scandolo657e13c2020-07-28 11:41:42 -07002101replicas: $NUM_OF_KAFKA
David Bainbridge76afd812020-04-06 09:53:52 -07002102EOC
David Bainbridged18f4942020-04-14 16:46:13 -07002103 STIME="$(date +%s)"
David Bainbridge76afd812020-04-06 09:53:52 -07002104 bspin "Verify external Kafka cluster $OLD_KEY"
Matteo Scandolo657e13c2020-07-28 11:41:42 -07002105 EXPECT=$((NUM_OF_KAFKA*2))
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002106 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^kafka\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002107 espin "$NOT_VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07002108 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" -f $_TMP"
David Bainbridgec7220622020-05-28 12:31:47 -07002109 helm_install - "$INFRA_NS" kafka "$KAFKA_CHART" "$KAFKA_CHART_VERSION" kafka "$_HELM_DESC external Kafka cluster"
David Bainbridge76afd812020-04-06 09:53:52 -07002110 else
David Bainbridged18f4942020-04-14 16:46:13 -07002111 espin "$VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07002112 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002113 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for Kafka cluster to start" "$NO_LABEL" "kafka-.*"
David Bainbridge76afd812020-04-06 09:53:52 -07002114 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002115 NOW="$(date +%s)"
2116 printtime $((NOW - STIME))
David Bainbridge76afd812020-04-06 09:53:52 -07002117 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002118 rm -rf "$_TMP"
David Bainbridge76afd812020-04-06 09:53:52 -07002119fi
2120
David Bainbridged18f4942020-04-14 16:46:13 -07002121STIME="$(date +%s)"
David Bainbridgeed476572020-06-02 14:05:45 -07002122EXPECT=2
2123# therecanbeonlyone set hardcoded to true for backward compatibility
2124INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set therecanbeonlyone=true"
Matteo Scandolo67335f02020-04-09 11:19:53 -07002125case $WITH_ETCD in
David Bainbridge76afd812020-04-06 09:53:52 -07002126 no)
David Bainbridge76afd812020-04-06 09:53:52 -07002127 ;;
David Bainbridgec7220622020-05-28 12:31:47 -07002128 yes|external)
2129 _HOST="etcd.$INFRA_NS.svc"
David Bainbridge76afd812020-04-06 09:53:52 -07002130 _PORT=2379
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002131 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
Neha Sharmaa1c92ca2020-06-24 11:50:33 +00002132 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.address=$_HOST:$_PORT"
David Bainbridge76afd812020-04-06 09:53:52 -07002133 ;;
2134 *)
David Bainbridged18f4942020-04-14 16:46:13 -07002135 _HOST="$(echo "$WITH_ETCD" | cut -d: -f1)"
2136 _PORT="$(echo "$WITH_ETCD" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07002137 _PORT=${_PORT:-2379}
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002138 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
Neha Sharmaa1c92ca2020-06-24 11:50:33 +00002139 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.address=$_HOST:$_PORT"
David Bainbridge76afd812020-04-06 09:53:52 -07002140 ;;
2141esac
2142case $WITH_KAFKA in
2143 no)
David Bainbridge76afd812020-04-06 09:53:52 -07002144 ;;
David Bainbridgec7220622020-05-28 12:31:47 -07002145 yes|external)
2146 _HOST=kafka.$INFRA_NS.svc
David Bainbridge76afd812020-04-06 09:53:52 -07002147 _PORT=9092
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002148 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"
2149 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 -07002150 ;;
2151 *)
David Bainbridged18f4942020-04-14 16:46:13 -07002152 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
2153 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -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 Bainbridge76afd812020-04-06 09:53:52 -07002157 ;;
2158esac
2159
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002160if is_in "$WITH_ONOS" "legacy"; then
David Bainbridgec7220622020-05-28 12:31:47 -07002161 _HOST=onos-openflow.$INFRA_NS.svc
David Bainbridge76afd812020-04-06 09:53:52 -07002162 _PORT=6653
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002163elif is_in "$WITH_ONOS" "yes,classic"; then
David Bainbridgec7220622020-05-28 12:31:47 -07002164 _HOST=onos-onos-classic-hs.$INFRA_NS.svc
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002165 _PORT=6653
David Bainbridged18f4942020-04-14 16:46:13 -07002166elif [ "$WITH_ONOS" != "no" ]; then
2167 _HOST="$(echo "$WITH_ONOS" | cut -d: -f1)"
2168 _PORT="$(echo "$WITH_ONOS" | cut -s -d: -f2)"
David Bainbridge76afd812020-04-06 09:53:52 -07002169 _PORT=${_PORT:-6653}
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002170fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002171
David Bainbridgecf546362020-04-21 23:18:50 -07002172compare_versions "$RESOLVED_VOLTHA_CHART_VERSION" 2.4.2
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002173if [ "$?" == "1" ]; then
2174 # voltha chart > 2.4.2 uses list of controllers
David Bainbridgee4d11ca2020-05-08 10:21:10 -07002175 for NUM in $(seq 0 $((NUM_OF_ONOS-1))); do
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002176 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 +00002177 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 -07002178 done
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002179else
2180 # voltha chart <= 2.4.2 uses single controller
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002181 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.controller.service=$_HOST --set services.controller.port=$_PORT"
Neha Sharmaa1c92ca2020-06-24 11:50:33 +00002182 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.controller.address=$_HOST:$_PORT"
David Bainbridge696bc632020-04-05 21:49:37 -07002183fi
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002184
Test Userb5712372019-07-03 21:52:17 +00002185bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002186if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$VOLTHA_NS" "^voltha\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002187 espin "$NOT_VERIFIED"
David Bainbridgea965ca22020-06-09 17:45:04 -07002188 helm_install - "$VOLTHA_NS" voltha "$VOLTHA_CHART" "$VOLTHA_CHART_VERSION" "+voltha" "$_HELM_DESC VOLTHA Core"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002189else
David Bainbridged18f4942020-04-14 16:46:13 -07002190 espin "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002191fi
David Bainbridge696bc632020-04-05 21:49:37 -07002192INTERNAL_EXTRA_HELM_INSTALL_ARGS=
Test Userba1e7e72019-07-10 22:27:54 +00002193
David Bainbridge90fd8e32019-08-21 23:32:47 +00002194VOLTHA="voltha-ofagent-.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002195 rw-core.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002196 voltha-zookeeper-.*"
David Bainbridged18f4942020-04-14 16:46:13 -07002197wait_for_pods - "$VOLTHA_NS" "$EXPECT" "includes" "Waiting for VOLTHA Core to start" "$NO_LABEL" "$VOLTHA"
David Bainbridgee87067b2019-08-12 22:00:12 +00002198if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002199 NOW="$(date +%s)"
2200 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002201fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002202
David Bainbridge46505fb2019-10-01 21:13:20 +00002203if [ "$WITH_ADAPTERS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002204 STIME="$(date +%s)"
David Bainbridge46505fb2019-10-01 21:13:20 +00002205 EXPECT=0
David Bainbridgec7220622020-05-28 12:31:47 -07002206 if is_in "$WITH_ETCD" "yes,external"; then
2207 _HOST=etcd.$INFRA_NS.svc
David Bainbridge3517f6c2020-04-08 12:14:08 -07002208 _PORT=2379
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002209 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
2210 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.address=$_HOST:$_PORT"
David Bainbridged18f4942020-04-14 16:46:13 -07002211 elif [ "$WITH_ETCD" != "no" ]; then
2212 _HOST="$(echo "$WITH_ETCD" | cut -d: -f1)"
2213 _PORT="$(echo "$WITH_ETCD" | cut -s -d: -f2)"
David Bainbridge3517f6c2020-04-08 12:14:08 -07002214 _PORT=${_PORT:-2379}
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002215 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
2216 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.address=$_HOST:$_PORT"
David Bainbridge696bc632020-04-05 21:49:37 -07002217 fi
David Bainbridgec7220622020-05-28 12:31:47 -07002218 if is_in "$WITH_KAFKA" "yes,external"; then
2219 _HOST=kafka.$INFRA_NS.svc
David Bainbridge3517f6c2020-04-08 12:14:08 -07002220 _PORT=9092
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002221 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"
2222 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 -07002223 elif [ "$WITH_KAFKA" != "no" ]; then
2224 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
2225 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge3517f6c2020-04-08 12:14:08 -07002226 _PORT=${_PORT:-9092}
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002227 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"
2228 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 -07002229 fi
David Bainbridge46505fb2019-10-01 21:13:20 +00002230 echo -e "Verify Adapters $PLUG"
2231 if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then
2232 bspin - "Verify Simulated Adapters installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002233 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$ADAPTER_NS" "^sim\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002234 espin - "$NOT_VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002235 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 +00002236 else
David Bainbridged18f4942020-04-14 16:46:13 -07002237 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00002238 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002239 EXPECT="$((EXPECT + 2))"
David Bainbridge46505fb2019-10-01 21:13:20 +00002240 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07002241
David Bainbridge46505fb2019-10-01 21:13:20 +00002242 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
2243 bspin - "Verify OpenOLT Adapter installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002244 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$ADAPTER_NS" "^open-olt\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002245 espin - "$NOT_VERIFIED"
David Bainbridgea965ca22020-06-09 17:45:04 -07002246 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 +00002247 else
David Bainbridged18f4942020-04-14 16:46:13 -07002248 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00002249 fi
Matteo Scandolo67335f02020-04-09 11:19:53 -07002250 EXPECT="$((EXPECT + 1))"
David Bainbridge46505fb2019-10-01 21:13:20 +00002251 bspin - "Verify OpenONU Adapter installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002252 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$ADAPTER_NS" "^open-onu\$")" -ne 1 ]; then
Matteo Scandolo67335f02020-04-09 11:19:53 -07002253 _ORIGINAL_EXTRA_HELM_INSTALL_ARGS="$INTERNAL_EXTRA_HELM_INSTALL_ARGS"
2254 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set replicas.adapter_open_onu=$NUM_OF_OPENONU"
Girish Gowdra4cc5d8b2020-06-11 17:12:00 -07002255 if [ "$WITH_INCREMENTAL_EVTO_UPDATE" == "yes" ]; then
Girish Gowdra1c7ad4c2020-06-26 13:35:16 -07002256 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set defaults.incremental_evto_update=true"
Girish Gowdra4cc5d8b2020-06-11 17:12:00 -07002257 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002258 espin - "$NOT_VERIFIED"
David Bainbridgea965ca22020-06-09 17:45:04 -07002259 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 -07002260 INTERNAL_EXTRA_HELM_INSTALL_ARGS="$_ORIGINAL_EXTRA_HELM_INSTALL_ARGS"
David Bainbridge46505fb2019-10-01 21:13:20 +00002261 else
David Bainbridged18f4942020-04-14 16:46:13 -07002262 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00002263 fi
Matteo Scandolo67335f02020-04-09 11:19:53 -07002264 EXPECT=$((EXPECT + NUM_OF_OPENONU))
David Bainbridge46505fb2019-10-01 21:13:20 +00002265 fi
David Bainbridge696bc632020-04-05 21:49:37 -07002266 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07002267
David Bainbridge46505fb2019-10-01 21:13:20 +00002268 ADAPTERS="adapter-.*"
David Bainbridged18f4942020-04-14 16:46:13 -07002269 wait_for_pods - "$ADAPTER_NS" "$EXPECT" "includes" "Waiting for adapters to start" "$NO_LABEL" "$ADAPTERS"
David Bainbridge46505fb2019-10-01 21:13:20 +00002270 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002271 NOW="$(date +%s)"
2272 printtime $((NOW - STIME))
David Bainbridge46505fb2019-10-01 21:13:20 +00002273 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00002274fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002275
David Bainbridged18f4942020-04-14 16:46:13 -07002276if [ "$WITH_BBSIM" == "yes" ]; then
2277 STIME="$(date +%s)"
Test User7d866122019-07-09 17:52:35 +00002278 echo -e "Verify BBSIM $PLUG"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002279 bspin - "Verify BBSIM Installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002280 for instance in $(seq 0 $((NUM_OF_BBSIM-1))); do
Matteo Scandoloc2eb0672020-05-01 14:43:15 -07002281
2282 if [ "$LEGACY_BBSIM_INDEX" == "yes" ]; then
2283 if [ "$instance" -eq 0 ]; then
2284 instance_num=""
2285 else
2286 instance_num=$instance
2287 fi
David K. Bainbridge43422402020-03-06 07:41:22 -08002288 else
2289 instance_num=$instance
2290 fi
Matteo Scandoloc2eb0672020-05-01 14:43:15 -07002291
2292
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002293 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$BBSIM_NS" "^bbsim${instance_num}\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002294 espin - "$NOT_VERIFIED"
2295 S_TAG="$((900+instance))"
Matteo Scandolo5a149572020-04-01 10:14:57 -07002296 INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set olt_id=$instance,s_tag=$S_TAG"
David Bainbridged9329af2020-05-01 11:58:52 -07002297 if [ "$WITH_EAPOL" == "yes" ]; then
2298 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set auth=true"
2299 else
2300 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set auth=false"
2301 fi
2302 if [ "$WITH_DHCP" == "yes" ]; then
2303 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set dhcp=true"
2304 else
2305 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set dhcp=false"
2306 fi
David Bainbridge33e56c72020-06-11 11:39:56 -07002307 if is_in "$WITH_KAFKA" "yes,external"; then
2308 _HOST=kafka.$INFRA_NS.svc
2309 _PORT=9092
2310 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafkaAddress=$_HOST:$_PORT"
2311 elif [ "$WITH_KAFKA" != "no" ]; then
2312 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
2313 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
2314 _PORT=${_PORT:-9092}
2315 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafkaAddress=$_HOST:$_PORT"
2316 fi
2317 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 -07002318 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
David K. Bainbridge43422402020-03-06 07:41:22 -08002319 else
David Bainbridged18f4942020-04-14 16:46:13 -07002320 espin - "$VERIFIED"
David K. Bainbridge43422402020-03-06 07:41:22 -08002321 fi
2322 done
David Bainbridged18f4942020-04-14 16:46:13 -07002323 wait_for_pods - "$BBSIM_NS" "$NUM_OF_BBSIM" "includes" "Waiting for BBSIM to start" "$BBSIM_LABEL" "bbsim*"
David Bainbridgee87067b2019-08-12 22:00:12 +00002324 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002325 NOW="$(date +%s)"
2326 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002327 fi
Test User7d866122019-07-09 17:52:35 +00002328fi
2329
divyadesai59f987a2020-05-27 12:11:33 +00002330if [ "$WITH_EFK" == "yes" ]; then
2331 STIME="$(date +%s)"
2332 echo -e "Verify EFK $PLUG"
2333 bspin - "Verify EFK Installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002334 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 +00002335 espin - "$NOT_VERIFIED"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002336 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^elasticsearch\$")" -ne 1 ]; then
divyadesai59f987a2020-05-27 12:11:33 +00002337 helm_install - "$INFRA_NS" elasticsearch "$ELASTICSEARCH_CHART" "$ELASTICSEARCH_CHART_VERSION" elasticsearch "$_HELM_DESC elasticsearch"
2338 fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002339 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^kibana\$")" -ne 1 ]; then
divyadesai59f987a2020-05-27 12:11:33 +00002340 helm_install - "$INFRA_NS" kibana "$KIBANA_CHART" "$KIBANA_CHART_VERSION" kibana "$_HELM_DESC kibana"
2341 fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002342 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^fluentd\$")" -ne 1 ]; then
divyadesai59f987a2020-05-27 12:11:33 +00002343 helm_install - "$INFRA_NS" fluentd "$FLUENTD_ELASTICSEARCH_CHART" "$FLUENTD_ELASTICSEARCH_CHART_VERSION" fluentd-elasticsearch "$_HELM_DESC fluentd-elasticsearch"
2344 fi
2345 else
2346 espin - "$VERIFIED"
2347 fi
2348 EXPECT=2 # for elastic and kibana
2349 if [ "$TYPE" == "minimal" ]; then
2350 EXPECT=$((EXPECT + 2)) # for fluentd on worker 2 worker nodes
2351 else
2352 EXPECT=$((EXPECT + 3)) # for fluentd on worker 3 worker nodes
2353 fi
2354 if [ "$SCHEDULE_ON_CONTROL_NODES" == "yes" ]; then
2355 EXPECT=$((EXPECT + 1)) # for fluentd on the control plan node
2356 fi
2357
2358 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for EFK to start" "$NO_LABEL" "fluentd-* elasticsearch-* kibana-*"
2359 if [ "$WITH_TIMINGS" == "yes" ]; then
2360 NOW="$(date +%s)"
2361 printtime $((NOW - STIME))
2362 fi
2363fi
2364
David Bainbridge309099c2020-05-05 08:47:29 -07002365if [ "$CONFIG_SADIS" == "external" ]; then
2366 STIME="$(date +%s)"
2367 echo -e "Verify BBSIM SADIS Service $PLUG"
2368 bspin - "Verify required configmap"
2369 (set -x; kubectl -n "$BBSIM_NS" delete --ignore-not-found configmap kube-config >>"$LOG" 2>&1) >>"$LOG" 2>&1
2370 (set -x; kubectl -n "$BBSIM_NS" create configmap kube-config "--from-file=kube_config=$KUBECONFIG" >>"$LOG" 2>&1) >>"$LOG" 2>&1
2371 espin - "$VERIFIED"
2372 bspin - "Verify BBSIM SADIS Service Installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002373 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$BBSIM_NS" "^bbsim-sadis-server\$")" -ne 1 ]; then
David Bainbridge309099c2020-05-05 08:47:29 -07002374 espin - "$NOT_VERIFIED"
Matteo Scandolo871fd982020-07-23 11:46:51 -07002375 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"
2376 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
David Bainbridge309099c2020-05-05 08:47:29 -07002377 else
2378 espin - "$VERIFIED"
2379 fi
2380 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 +00002381
Matteo Scandolo21660442020-07-17 11:05:21 -07002382 if is_in "$WITH_ONOS" "yes,classic,legacy"; then
Ubuntu7135e6a2020-06-30 01:46:08 +00002383 if kubectl get -n "$BBSIM_NS" svc/bbsim-sadis-server-bbsim-sadis-server >/dev/null 2>&1; then
2384 BBSIM_SADIS_SVC="bbsim-sadis-server-bbsim-sadis-server"
2385 else
2386 BBSIM_SADIS_SVC="bbsim-sadis-server"
2387 fi
2388 push_onos_config "json" \
2389 "[optional] Push ONOS configuration for custom SADIS and Bandwidth Profile servers" \
2390 "network/configuration/apps/org.opencord.sadis" \
2391 "$(cat <<EOJ | tr -d '[:space:]'
2392{
2393 "sadis": {
2394 "integration": {
2395 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:58080/subscribers/%s",
2396 "cache": {
2397 "enabled": true,
2398 "maxsize": 50,
2399 "ttl": "PT1m"
2400 }
2401 }
2402 },
2403 "bandwidthprofile": {
2404 "integration": {
2405 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:58080/profiles/%s",
2406 "cache": {
2407 "enabled": true,
2408 "maxsize": 50,
2409 "ttl": "PT1m"
2410 }
2411 }
2412 }
2413}
2414EOJ
2415)"
2416 fi
David Bainbridge309099c2020-05-05 08:47:29 -07002417 if [ "$WITH_TIMINGS" == "yes" ]; then
2418 NOW="$(date +%s)"
2419 printtime $((NOW - STIME))
2420 fi
2421fi
2422
David Bainbridged18f4942020-04-14 16:46:13 -07002423if [ "$WITH_RADIUS" == "yes" ]; then
2424 STIME="$(date +%s)"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002425 echo -e "Verify RADIUS $LOCK"
2426 bspin - "Verify RADIUS Installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002427 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^radius\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002428 espin - "$NOT_VERIFIED"
David Bainbridge879439b2020-06-12 15:59:35 -07002429 helm_install - "$INFRA_NS" radius "$RADIUS_CHART" "$RADIUS_CHART_VERSION" "+radius" "$_HELM_DESC RADIUS"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002430 else
David Bainbridged18f4942020-04-14 16:46:13 -07002431 espin - "$VERIFIED"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002432 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002433 wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for RADIUS to start" "$NO_LABEL" "radius-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00002434 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002435 NOW="$(date +%s)"
2436 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002437 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002438fi
2439
David Bainbridged18f4942020-04-14 16:46:13 -07002440if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
2441 STIME="$(date +%s)"
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002442 bspin - "Forward VOLTHA API port $FORWARD"
David Bainbridge1d2c5842020-06-03 15:29:07 -07002443 kill_port_forward voltha-api voltha-voltha-api
2444 VOLTHA_PREFIX=
2445 if kubectl get -n "$VOLTHA_NS" "svc/voltha-voltha-api" >/dev/null 2>&1; then
2446 VOLTHA_PREFIX="voltha-"
2447 fi
Matteo Scandolo21660442020-07-17 11:05:21 -07002448
David Bainbridge1d2c5842020-06-03 15:29:07 -07002449 port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-api" "$VOLTHA_API_PORT:55555"
David Bainbridged18f4942020-04-14 16:46:13 -07002450 espin - "$VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002451 if is_in "$WITH_ETCD" "yes,external"; then
David Bainbridge696bc632020-04-05 21:49:37 -07002452 bspin - "Forward VOLTHA ETCD port $FORWARD"
David Bainbridgec7220622020-05-28 12:31:47 -07002453 kill_port_forward "etcd"
2454 port_forward "$INFRA_NS" "etcd" "$VOLTHA_ETCD_PORT:2379"
David Bainbridged18f4942020-04-14 16:46:13 -07002455 espin - "$VERIFIED"
David Bainbridge696bc632020-04-05 21:49:37 -07002456 fi
David Bainbridgec7220622020-05-28 12:31:47 -07002457 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridge696bc632020-04-05 21:49:37 -07002458 bspin - "Forward VOLTHA Kafka port $FORWARD"
David Bainbridgec7220622020-05-28 12:31:47 -07002459 kill_port_forward "kafka"
2460 port_forward "$INFRA_NS" kafka "$VOLTHA_KAFKA_PORT:9092"
David Bainbridged18f4942020-04-14 16:46:13 -07002461 espin - "$VERIFIED"
David Bainbridge696bc632020-04-05 21:49:37 -07002462 fi
divyadesai59f987a2020-05-27 12:11:33 +00002463 if [ "$WITH_EFK" == "yes" ]; then
2464 bspin - "Forward EFK port $FORWARD"
2465 kill_port_forward elasticsearch-master
2466 kill_port_forward kibana-kibana
2467 port_forward "$INFRA_NS" elasticsearch-master "$ELASTICSEARCH_PORT:9200"
2468 port_forward "$INFRA_NS" kibana-kibana "$KIBANA_PORT:5601"
2469 espin - "$VERIFIED"
2470 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -07002471 if [ "$WITH_PPROF" == "yes" ]; then
David Bainbridge1d2c5842020-06-03 15:29:07 -07002472 VOLTHA_OPENOLT_PREFIX=
2473 if kubectl get -n "$ADAPTER_NS" "svc/open-olt-adapter-open-olt-profiler" >/dev/null 2>&1; then
2474 VOLTHA_OPENOLT_PREFIX="open-olt-"
2475 fi
David Bainbridge879439b2020-06-12 15:59:35 -07002476 bspin - "Forward PProf ports port $FORWARD"
2477 kill_port_forward voltha-rw-core-profiler voltha-voltha-rw-core-profiler
2478 kill_port_forward adapter-open-olt-profiler open-olt-adapter-open-olt-profiler
2479 kill_port_forward voltha-of-agent-profiler voltha-voltha-of-agent-profiler
2480 port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-rw-core-profiler" "$VOLTHA_PPROF_PORT:6060"
2481 port_forward "$ADAPTER_NS" "${VOLTHA_OPENOLT_PREFIX}adapter-open-olt-profiler" "$OPENOLT_PPROF_PORT:6060"
2482 port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-of-agent-profiler" "$OFAGENT_PPROF_PORT:6060"
2483 espin - "$VERIFIED"
Matteo Scandoloefee0432020-05-05 13:56:20 -07002484 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002485 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002486 NOW="$(date +%s)"
2487 printtime $((NOW - STIME))
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002488 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00002489fi
Test User3d7ad8e2019-07-03 06:15:44 +00002490
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002491if is_in "$WITH_ONOS" "yes,legacy,classic" && [ "$WITH_RADIUS" != "no" ]; then
David Bainbridge879439b2020-06-12 15:59:35 -07002492 SVC_NAME=radius
2493 if kubectl get -n "$INFRA_NS" "svc/radius-freeradius" >/dev/null 2>&1; then
2494 SVC_NAME="radius-freeradius"
2495 fi
2496 _HOST="$SVC_NAME.$INFRA_NS.svc"
David Bainbridge696bc632020-04-05 21:49:37 -07002497 _PORT=1812
David Bainbridged18f4942020-04-14 16:46:13 -07002498 if [ "$WITH_RADIUS" != "yes" ]; then
2499 _HOST="$(echo "$WITH_RADIUS" | cut -d: -f1)"
2500 _PORT="$(echo "$WITH_RADIUS" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07002501 _PORT=${_PORT:-1812}
2502 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002503 bspin "Configure ONOS RADIUS Connection $GEAR"
David Bainbridged18f4942020-04-14 16:46:13 -07002504 (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
2505 espin "$VERIFIED"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002506fi
2507
divyadesai59f987a2020-05-27 12:11:33 +00002508if [ "$WITH_EFK" == "yes" ]; then
2509 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"
2510# fi
2511fi
2512
David Bainbridge99ac7a22019-08-31 02:26:43 +00002513if [ "$WITH_CHAOS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002514 STIME="$(date +%s)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002515 echo -e "Verify kube-monkey $LOCK"
2516 bspin - "Verify kube-monkey Installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002517 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed kube-monkey "^monkey\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002518 espin - "$NOT_VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002519 helm_install - kube-monkey monkey ./kube-monkey/helm/kubemonkey latest - "$_HELM_DESC Chaos Monkey"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002520 else
David Bainbridged18f4942020-04-14 16:46:13 -07002521 espin - "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002522 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002523 wait_for_pods - "kube-monkey" 1 "includes" "Waiting for Chaos to start" "$NO_LABEL" "monkey-.*"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002524 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002525 NOW="$(date +%s)"
2526 printtime $((NOW - STIME))
David Bainbridge99ac7a22019-08-31 02:26:43 +00002527 fi
2528fi
2529
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002530bspin "Create voltctl configuration file"
David Bainbridged18f4942020-04-14 16:46:13 -07002531(set -x; mkdir -p "$HOME/.volt" >>"$LOG" 2>&1) >>"$LOG" 2>&1
2532MIN_VC_VERSION="$(echo -e "1.0.15\n$VC_VERSION" | sort -V | head -1)"
2533if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002534 KAFKA_FLAG="-k localhost:$VOLTHA_KAFKA_PORT"
2535 SERVER_FLAG="-s localhost:$VOLTHA_API_PORT"
2536 ETCD_FLAG=
2537 if [ "$MIN_VC_VERSION" == "1.0.15" ]; then
2538 ETCD_FLAG="-e localhost:$VOLTHA_ETCD_PORT"
2539 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002540else
David Bainbridgec7220622020-05-28 12:31:47 -07002541 KAFKA_FLAG="-k $(get_service_ep "$INFRA_NS" kafka)"
David Bainbridged18f4942020-04-14 16:46:13 -07002542 SERVER_FLAG="-s $(get_service_ep "$VOLTHA_NS" voltha-api)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002543 ETCD_FLAG=
2544 if [ "$MIN_VC_VERSION" == "1.0.15" ]; then
David Bainbridgec7220622020-05-28 12:31:47 -07002545 ETCD_FLAG="-e $(get_service_ep "$INFRA_NS" etcd)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002546 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002547fi
David Bainbridgea965ca22020-06-09 17:45:04 -07002548CMD=("voltctl $KAFKA_FLAG $SERVER_FLAG $ETCD_FLAG config")
David Bainbridged18f4942020-04-14 16:46:13 -07002549(set -x; ${CMD[*]} > "$HOME/.volt/config-$NAME" 2>>"$LOG") >>"$LOG" 2>&1
David Bainbridgea965ca22020-06-09 17:45:04 -07002550#(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 -07002551espin "$VERIFIED"
Test User08ebbd92019-07-03 17:15:39 +00002552
David Bainbridge0774b232019-08-02 06:37:19 +00002553if [ ! -f "$NAME-env.sh" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002554 touch "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002555fi
2556
David Bainbridge596f30d2019-07-30 17:07:59 +00002557for O in $ALL_OPTIONS; do
David Bainbridged18f4942020-04-14 16:46:13 -07002558 VAL="$(eval echo "\$$O")"
2559 if [ -n "$VAL" ] && [ "$(grep -c "^export $O=" "$NAME-env.sh")" -eq 0 ]; then
2560 echo "export $O=\"$(eval echo "\$$O")\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002561 fi
2562done
2563
David Bainbridged18f4942020-04-14 16:46:13 -07002564if [ "$DEPLOY_K8S" == "yes" ] && [ "$(grep -c "^export KUBECONFIG=" "$NAME-env.sh")" -eq 0 ]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002565 echo "export KUBECONFIG=\"$HOME/.kube/kind-config-voltha-$NAME\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002566fi
2567
David Bainbridged18f4942020-04-14 16:46:13 -07002568if [ "$(grep -c "^export VOLTCONFIG=" "$NAME-env.sh")" -eq 0 ]; then
2569 echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002570fi
2571
David Bainbridged18f4942020-04-14 16:46:13 -07002572if [ "$(grep -c "^export PATH=" "$NAME-env.sh")" -eq 0 ]; then
2573 echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002574fi
2575
Test User7d866122019-07-09 17:52:35 +00002576echo ""
David Bainbridged18f4942020-04-14 16:46:13 -07002577echo "Please issue the following commands in your terminal to ensure that you" | tee -a "$LOG"
2578echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a "$LOG"
2579echo "tools required by VOLTHA in your command path. " | tee -a "$LOG"
2580echo "" | tee -a "$LOG"
2581echo -en "$BOLD"
2582if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002583 echo "export KUBECONFIG=\"$HOME/.kube/kind-config-voltha-$NAME\"" | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00002584fi
David Bainbridged18f4942020-04-14 16:46:13 -07002585echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" | tee -a "$LOG"
2586echo "export PATH=$GOPATH/bin:\$PATH" | tee -a "$LOG"
2587echo -en "$NORMAL"
2588echo "" | tee -a "$LOG"
2589echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a "$LOG"
Test User08ebbd92019-07-03 17:15:39 +00002590
David Bainbridge712afb82019-08-14 19:55:58 +00002591if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002592 NOW="$(date +%s)"
2593 echo -e "$CLOCK ${BOLD}TOTAL: $(duration $((NOW - TOTAL_START_TIME)))${NORMAL}"
David Bainbridge712afb82019-08-14 19:55:58 +00002594fi