blob: 52a45bf72bc9a5a980d6d9ff25ea6e6dd84b9ff7 [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}
Girish Kumarcc5f9172020-06-10 13:34:31 +000078WITH_TRACING=${WITH_TRACING:-no}
David Bainbridge5b7b96b2019-07-25 20:29:13 +000079WITH_RADIUS=${WITH_RADIUS:-no}
Matteo Scandolo78dfee02020-02-13 16:18:03 -080080WITH_EAPOL=${WITH_EAPOL:-yes}
81WITH_DHCP=${WITH_DHCP:-yes}
82WITH_IGMP=${WITH_IGMP:-no}
David Bainbridgeb270c202019-07-26 01:44:42 +000083WITH_ONOS=${WITH_ONOS:-yes}
David Bainbridge60ffc0f2020-04-27 22:13:22 -070084NUM_OF_ONOS=${NUM_OF_ONOS:-1}
85NUM_OF_ATOMIX=${NUM_OF_ATOMIX:-0}
David Bainbridge99ac7a22019-08-31 02:26:43 +000086WITH_CHAOS=${WITH_CHAOS:-no}
David Bainbridge46505fb2019-10-01 21:13:20 +000087WITH_ADAPTERS=${WITH_ADAPTERS:-yes}
David K. Bainbridgeda33d652020-03-06 10:31:23 -080088WITH_SIM_ADAPTERS=${WITH_SIM_ADAPTERS:-no}
David Bainbridge46505fb2019-10-01 21:13:20 +000089WITH_OPEN_ADAPTERS=${WITH_OPEN_ADAPTERS:-yes}
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -080090WITH_PORT_FORWARDS=${WITH_PORT_FORWARDS:-yes}
David Bainbridge696bc632020-04-05 21:49:37 -070091WITH_KAFKA=${WITH_KAFKA:-yes}
92WITH_ETCD=${WITH_ETCD:-yes}
Matteo Scandoloefee0432020-05-05 13:56:20 -070093WITH_PPROF=${WITH_PPROF:-no}
Girish Gowdra4cc5d8b2020-06-11 17:12:00 -070094WITH_INCREMENTAL_EVTO_UPDATE=${WITH_INCREMENTAL_EVTO_UPDATE:-no}
David Bainbridgee4d11ca2020-05-08 10:21:10 -070095SCHEDULE_ON_CONTROL_NODES=${SCHEDULE_ON_CONTROL_NODES:-no}
David Bainbridge309099c2020-05-05 08:47:29 -070096CONFIG_SADIS=${CONFIG_SADIS:-no} # yes | no | file | bbsim | external | URL
Hardik Windlassb3147602020-03-09 16:59:15 +053097SADIS_CFG=${SADIS_CFG:-onos-files/onos-sadis-sample.json}
David Bainbridge27790d62019-08-13 22:43:19 +000098INSTALL_ONOS_APPS=${INSTALL_ONOS_APPS:-no}
Test Userba1e7e72019-07-10 22:27:54 +000099JUST_K8S=${JUST_K8S:-no}
100DEPLOY_K8S=${DEPLOY_K8S:-yes}
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700101INSTALL_KUBECTL=${INSTALL_KUBECTL:-yes}
102INSTALL_HELM=${INSTALL_HELM:-yes}
David Bainbridge7f8bf992020-04-08 21:53:22 -0700103HELM_USE_UPGRADE=${HELM_USE_UPGRADE:-no}
David Bainbridge46505fb2019-10-01 21:13:20 +0000104UPDATE_HELM_REPOS=${UPDATE_HELM_REPOS:-yes}
Matteo Scandolofab98622020-01-28 15:17:20 -0800105WAIT_ON_DOWN=${WAIT_ON_DOWN:-yes}
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700106WAIT_TIMEOUT=${WAIT_TIMEOUT:-30m}
107VOLTHA_DOWN_ON_TIMEOUT=${VOLTHA_DOWN_ON_TIMEOUT:-no}
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000108VOLTHA_LOG_LEVEL=${VOLTHA_LOG_LEVEL:-WARN}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000109VOLTHA_CHART=${VOLTHA_CHART:-onf/voltha}
110VOLTHA_CHART_VERSION=${VOLTHA_CHART_VERSION:-latest}
111VOLTHA_BBSIM_CHART=${VOLTHA_BBSIM_CHART:-onf/bbsim}
Matteo Scandolodcd29f52019-10-07 15:42:42 -0700112VOLTHA_BBSIM_CHART_VERSION=${VOLTHA_BBSIM_CHART_VERSION:-latest}
divyadesai59f987a2020-05-27 12:11:33 +0000113ELASTICSEARCH_CHART=${ELASTICSEARCH_CHART:-elastic/elasticsearch}
114ELASTICSEARCH_CHART_VERSION=${ELASTICSEARCH_CHART_VERSION:-latest}
115KIBANA_CHART=${KIBANA_CHART:-elastic/kibana}
116KIBANA_CHART_VERSION=${KIBANA_CHART_VERSION:-latest}
117FLUENTD_ELASTICSEARCH_CHART=${FLUENTD_ELASTICSEARCH_CHART:-kiwigrid/fluentd-elasticsearch}
118FLUENTD_ELASTICSEARCH_CHART_VERSION=${FLUENTD_ELASTICSEARCH_CHART_VERSION:-latest}
Girish Kumarcc5f9172020-06-10 13:34:31 +0000119VOLTHA_TRACING_CHART=${VOLTHA_TRACING_CHART:-onf/voltha-tracing}
120VOLTHA_TRACING_CHART_VERSION=${VOLTHA_TRACING_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000121VOLTHA_ADAPTER_SIM_CHART=${VOLTHA_ADAPTER_SIM_CHART:-onf/voltha-adapter-simulated}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000122VOLTHA_ADAPTER_SIM_CHART_VERSION=${VOLTHA_ADAPTER_SIM_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000123VOLTHA_ADAPTER_OPEN_OLT_CHART=${VOLTHA_ADAPTER_OPEN_OLT_CHART:-onf/voltha-adapter-openolt}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000124VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION=${VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000125VOLTHA_ADAPTER_OPEN_ONU_CHART=${VOLTHA_ADAPTER_OPEN_ONU_CHART:-onf/voltha-adapter-openonu}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000126VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION=${VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION:-latest}
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800127ONOS_CHART=${ONOS_CHART:-onf/onos}
Andrea Campanella21323292019-12-18 11:44:19 -0800128ONOS_CHART_VERSION=${ONOS_CHART_VERSION:-latest}
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700129ONOS_CLASSIC_CHART=${ONOS_CLASSIC_CHART:-onos/onos-classic}
Andrea Campanella5b801702020-07-30 10:16:22 +0200130ONOS_CLASSIC_CHART_VERSION=${ONOS_CLASSIC_CHART_VERSION:-latest}
David Bainbridgecf546362020-04-21 23:18:50 -0700131KAFKA_CHART=${KAFKA_CHART:-incubator/kafka}
David Bainbridgeb4bbde12020-06-25 14:46:36 -0700132KAFKA_CHART_VERSION=${KAFKA_CHART_VERSION:=latest}
David Bainbridge309099c2020-05-05 08:47:29 -0700133BBSIM_SADIS_SERVER_CHART=${BBSIM_SADIS_SERVER_CHART:-bbsim-sadis/bbsim-sadis-server}
134BBSIM_SADIS_SERVER_CHART_VERSION=${BBSIM_SADIS_SERVER_CHART_VERSION:-latest}
David Bainbridgeb4bbde12020-06-25 14:46:36 -0700135ETCD_CHART=${ETCD_CHART:-etcd/etcd}
David Bainbridgec7220622020-05-28 12:31:47 -0700136ETCD_CHART_VERSION=${ETCD_CHART_VERSION:-latest}
David Bainbridge879439b2020-06-12 15:59:35 -0700137RADIUS_CHART=${RADIUS_CHART:-onf/freeradius}
138RADIUS_CHART_VERSION=${RADIUS_CHART_VERSION:-latest}
David Bainbridge2eaf2cf2020-03-18 12:54:08 -0700139EXTRA_HELM_INSTALL_ARGS=${EXTRA_HELM_INSTALL_ARGS:-}
140INTERNAL_EXTRA_HELM_INSTALL_ARGS=
uottrembb16d3982020-02-28 08:34:36 +0100141NUM_OF_BBSIM=${NUM_OF_BBSIM:-1}
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700142NUM_OF_WORKER_NODES=${NUM_OF_WORKER_NODES:-2}
143NUM_OF_CONTROLLER_NODES=${NUM_OF_CONTROLLER_NODES:-1}
Matteo Scandolo67335f02020-04-09 11:19:53 -0700144NUM_OF_OPENONU=${NUM_OF_OPENONU:-1}
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700145NUM_OF_KAFKA=${NUM_OF_KAFKA:-1}
146NUM_OF_ETCD=${NUM_OF_ETCD:-1}
uottrembb16d3982020-02-28 08:34:36 +0100147MAX_NUM_OF_BBSIM=10
Matteo Scandolo67335f02020-04-09 11:19:53 -0700148MAX_NUM_OF_OPENONU=10
Matteo Scandoloc2eb0672020-05-01 14:43:15 -0700149LEGACY_BBSIM_INDEX=${LEGACY_BBSIM_INDEX:-no}
David Bainbridgeb4bbde12020-06-25 14:46:36 -0700150PF_ADDRESS=${PF_ADDRESS:-0.0.0.0}
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700151KIND_CFG_FILE=${KIND_CFG_FILE:-}
Test Userba1e7e72019-07-10 22:27:54 +0000152
David Bainbridged18f4942020-04-14 16:46:13 -0700153HOSTOS="$(uname -s | tr "[:upper:]" "[:lower:"])"
154HOSTARCH="$(uname -m | tr "[:upper:]" "[:lower:"])"
155if [ "$HOSTARCH" == "x86_64" ]; then
Test Userba1e7e72019-07-10 22:27:54 +0000156 HOSTARCH="amd64"
157fi
David Bainbridge7db44002020-04-09 12:54:29 -0700158BBSIM_LABEL="-l app=bbsim"
David Bainbridged18f4942020-04-14 16:46:13 -0700159NO_LABEL=
Test User7d866122019-07-09 17:52:35 +0000160
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700161# checks to see if a given WORD is in the given LIST of words
162function is_in() {
163 local WORD LIST
164 WORD="$1"; shift
165 LIST="$*"
166 LIST=${LIST//+([[:space:],|])/:}
167
168 [ "$(echo ":$LIST:" | grep -ic ":$WORD:")" -ne 0 ]
169}
170
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700171function parseDuration() {
David Bainbridged18f4942020-04-14 16:46:13 -0700172 local DUR RESULT TERM TERMS VALUE UNIT
173 DUR=$1
174 RESULT=0
175 TERMS="$(echo "$DUR" | sed -Ee 's/([sSmMhHdD])/\1 /g' -e 's/,$//g')"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700176 for TERM in $TERMS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700177 VALUE="$(echo "$TERM" | sed -Ee 's/([0-9]+)[sSmMhHdD]/\1/')"
178 UNIT="$(echo "$TERM" | sed -Ee 's/[0-9]+([sSmMhHdD])/\1/')"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700179 case $UNIT in
180 s|S)
David Bainbridged18f4942020-04-14 16:46:13 -0700181 RESULT=$((RESULT + VALUE)) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700182 m|M)
David Bainbridged18f4942020-04-14 16:46:13 -0700183 RESULT=$((RESULT + (VALUE * 60))) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700184 h|H)
David Bainbridged18f4942020-04-14 16:46:13 -0700185 RESULT=$((RESULT + (VALUE * 3600))) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700186 d|D)
David Bainbridged18f4942020-04-14 16:46:13 -0700187 RESULT=$((RESULT + (VALUE * 86400))) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700188 *) ;;
189 esac
190 done
191 echo $RESULT
192}
193
194function doTimeout() {
195 local MSG=$1
196 2>&1 echo -e "\n${RED}${BOLD}${ERROR}TIMEOUT:${NORMAL}${RED} Operation timed out after '$WAIT_TIMEOUT': $MSG"
197 exit 125
198}
199
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800200function get_service_ep() {
201 local NS=$1
202 local NAME=$2
David Bainbridged18f4942020-04-14 16:46:13 -0700203 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 -0800204}
205
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000206# Used to verify configuration values are set to "yes" or "no" value or convert
207# equivalents to "yes" or "no"
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700208YES="y,yes,t,true,1"
209NO="n,no,f,false,0"
210YES_OR_NO="$YES,$NO"
211
212# If the given VAR matches a truth value then normalize that
213# value, else return original value
214function normalize_yes_no() {
215 local VAR VAL
216 VAR=$1
217 VAL="$(eval echo "\$$VAR")"
218 if ! is_in "$VAL" "$YES_OR_NO"; then
219 echo "$VAL"
220 return 1
221 fi
222 if is_in "$VAL" "$YES"; then
223 echo "yes"
224 else
225 echo "no"
226 fi
227 return 0
228}
229
230# If the given VAR matches a truth value then normalize that
231# value, else display an error
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000232function verify_yes_no() {
David Bainbridged18f4942020-04-14 16:46:13 -0700233 local VAR VAL
234 VAR=$1
235 VAL="$(eval echo "\$$VAR")"
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700236 if ! is_in "$VAL" "$YES_OR_NO"; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000237 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid '$VAR' value of '$VAL'. Should be 'yes' or 'no'${NORMAL}"
238 echo "INVALID"
239 return 1
240 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700241 if is_in "$VAL" "$YES"; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000242 echo "yes"
243 else
244 echo "no"
245 fi
246 return 0
247}
Test User7d866122019-07-09 17:52:35 +0000248
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000249ALL_YES_NO="\
David K. Bainbridge484d80c2020-03-05 21:44:34 -0800250 ENABLE_ONOS_EXTRANEOUS_RULES \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000251 WITH_TIMINGS \
252 WITH_BBSIM \
divyadesai59f987a2020-05-27 12:11:33 +0000253 WITH_EFK \
Girish Kumarcc5f9172020-06-10 13:34:31 +0000254 WITH_TRACING \
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800255 WITH_EAPOL \
256 WITH_DHCP \
257 WITH_IGMP \
David Bainbridge99ac7a22019-08-31 02:26:43 +0000258 WITH_CHAOS \
David Bainbridge46505fb2019-10-01 21:13:20 +0000259 WITH_ADAPTERS \
260 WITH_SIM_ADAPTERS \
261 WITH_OPEN_ADAPTERS \
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800262 WITH_PORT_FORWARDS \
Matteo Scandoloefee0432020-05-05 13:56:20 -0700263 WITH_PPROF \
Girish Gowdra4cc5d8b2020-06-11 17:12:00 -0700264 WITH_INCREMENTAL_EVTO_UPDATE \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000265 JUST_K8S \
266 DEPLOY_K8S \
267 INSTALL_ONOS_APPS \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000268 INSTALL_KUBECTL \
269 INSTALL_HELM \
David Bainbridge7f8bf992020-04-08 21:53:22 -0700270 HELM_USE_UPGRADE \
David Bainbridge46505fb2019-10-01 21:13:20 +0000271 UPDATE_HELM_REPOS \
David Bainbridge4f1b5562019-08-19 04:46:52 +0000272 WAIT_ON_DOWN \
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700273 VOLTHA_DOWN_ON_TIMEOUT \
Matteo Scandoloc2eb0672020-05-01 14:43:15 -0700274 LEGACY_BBSIM_INDEX \
David Bainbridgee4d11ca2020-05-08 10:21:10 -0700275 SCHEDULE_ON_CONTROL_NODES \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000276 "
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000277
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700278OPT_YES_NO="\
279 CONFIG_SADIS \
280 WITH_KAFKA \
281 WITH_RADIUS \
282 WITH_ETCD \
283 WITH_ONOS \
284 "
285
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000286ALL_OPTIONS="\
287 NAME \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000288 $ALL_YES_NO \
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700289 $OPT_YES_NO \
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700290 WAIT_TIMEOUT \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000291 VOLTHA_LOG_LEVEL \
292 VOLTHA_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000293 VOLTHA_CHART_VERSION \
294 VOLTHA_BBSIM_CHART \
295 VOLTHA_BBSIM_CHART_VERSION \
David Bainbridge879439b2020-06-12 15:59:35 -0700296 BBSIM_SADIS_SERVER_CHART \
297 BBSIM_SADIS_SERVER_CHART_VERSION \
Girish Kumarcc5f9172020-06-10 13:34:31 +0000298 VOLTHA_TRACING_CHART \
299 VOLTHA_TRACING_CHART_VERSION \
uottrembd5a20572020-03-06 09:15:01 +0100300 NUM_OF_BBSIM \
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700301 NUM_OF_WORKER_NODES \
302 NUM_OF_CONTROLLER_NODES \
303 NUM_OF_KAFKA \
304 NUM_OF_ETCD \
divyadesai59f987a2020-05-27 12:11:33 +0000305 ELASTICSEARCH_CHART \
306 ELASTICSEARCH_CHART_VERSION \
307 KIBANA_CHART \
308 KIBANA_CHART_VERSION \
309 FLUENTD_ELASTICSEARCH_CHART \
310 FLUENTD_ELASTICSEARCH_CHART_VERSION \
Matteo Scandolo67335f02020-04-09 11:19:53 -0700311 NUM_OF_OPENONU \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000312 VOLTHA_ADAPTER_SIM_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000313 VOLTHA_ADAPTER_SIM_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000314 VOLTHA_ADAPTER_OPEN_OLT_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000315 VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000316 VOLTHA_ADAPTER_OPEN_ONU_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000317 VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION \
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800318 ONOS_CHART \
Andrea Campanella21323292019-12-18 11:44:19 -0800319 ONOS_CHART_VERSION \
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700320 ONOS_CLASSIC_CHART \
321 ONOS_CLASSIC_CHART_VERSION \
David Bainbridgecf546362020-04-21 23:18:50 -0700322 KAFKA_CHART \
David Bainbridgeb9093522020-04-15 14:32:44 -0700323 KAFKA_CHART_VERSION \
David Bainbridge879439b2020-06-12 15:59:35 -0700324 ETCD_CHART \
325 ETCD_CHART_VERSION \
326 RADIUS_CHART \
327 RADIUS_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000328 ONOS_API_PORT \
329 ONOS_SSH_PORT \
Hardik Windlassb3147602020-03-09 16:59:15 +0530330 SADIS_CFG \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000331 VOLTHA_API_PORT \
332 VOLTHA_SSH_PORT \
333 VOLTHA_ETCD_PORT \
divyadesai59f987a2020-05-27 12:11:33 +0000334 ELASTICSEARCH_PORT \
335 KIBANA_PORT \
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800336 VOLTHA_KAFKA_PORT \
Matteo Scandoloefee0432020-05-05 13:56:20 -0700337 VOLTHA_PPROF_PORT \
338 OPENOLT_PPROF_PORT \
Matteo Scandolo65c35192020-05-13 10:41:21 -0700339 OFAGENT_PPROF_PORT \
Girish Kumarcc5f9172020-06-10 13:34:31 +0000340 TRACING_GUI_PORT \
David K. Bainbridge8f7f30b2020-01-08 13:06:16 -0800341 VK_RELEASE \
342 KIND_VERSION \
343 VOLTCTL_VERSION \
David Bainbridgea34993d2020-04-01 09:15:42 -0700344 HELM_VERSION \
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700345 NUM_OF_ONOS \
346 NUM_OF_ATOMIX \
David Bainbridge6ca40102020-04-08 11:30:40 -0700347 VOLTHA_NS \
348 ADAPTER_NS \
349 INFRA_NS \
350 BBSIM_NS \
David Bainbridge7db44002020-04-09 12:54:29 -0700351 SADIS_BANDWIDTH_PROFILES \
352 SADIS_SUBSCRIBERS \
David Bainbridgeb4bbde12020-06-25 14:46:36 -0700353 PF_ADDRESS \
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700354 KIND_CFG_FILE \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000355 "
David Bainbridge01294952019-07-30 19:33:45 +0000356
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000357# Iterate over yes/no configuration options and validate
358for VAR in $ALL_YES_NO; do
David Bainbridged18f4942020-04-14 16:46:13 -0700359 eval "$VAR"="$(verify_yes_no "$VAR")"
360 if [ "$(eval echo "\$$VAR")" == "INVALID" ]; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000361 exit 1;
362 fi
363done
David Bainbridgeb270c202019-07-26 01:44:42 +0000364
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700365# Iterate over optional yes/no configuration options and
366# normalize values if they are truth values
367for VAR in $OPT_YES_NO; do
368 eval "$VAR"="$(normalize_yes_no "$VAR")"
369done
David Bainbridge15f6f232020-03-30 09:15:43 -0700370
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700371# check number (range) of bbsim, max bbsim must not exceed 10 instances!
372# note: instances will be numbered from 0 to 9
373if [ "$1" == "up" ]; then
374 if [ "$NUM_OF_BBSIM" -lt 1 ]; then
375 >&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}"
376 exit 1
377 fi
378 if [ "$NUM_OF_BBSIM" -gt "$MAX_NUM_OF_BBSIM" ]; then
379 >&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}"
380 exit 1
381 fi
382
383 if [ "$NUM_OF_OPENONU" -lt 1 ]; then
384 >&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}"
385 exit 1
386 fi
387 if [ "$NUM_OF_OPENONU" -gt "$MAX_NUM_OF_OPENONU" ]; then
388 >&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}"
389 exit 1
390 fi
391
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700392 HAVE_CLUSTER="$(kind get clusters 2>/dev/null | grep -c "voltha-$NAME")"
393 if [ "$HAVE_CLUSTER" -eq 0 ]; then
394 # If the user has specified a kind cluster configuration file,
395 # 'KIND_CFG_FILE` then we need to gleem from that file the number
396 # of worker and controller nodes as this overrides any setting of
397 # these values
398 if [ -n "$KIND_CFG_FILE" ]; then
399 NUM_OF_WORKER_NODES="$(sed 's/ //g' "$KIND_CFG_FILE" | grep -c "^-role:worker$")"
400 NUM_OF_CONTROLLER_NODES="$(sed 's/ //g' "$KIND_CFG_FILE" | grep -c "^-role:control-plane$")"
401 fi
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700402
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700403 # check that NUM_OF_KAFKA, NUM_OF_ONOS, NUM_OF_ATOMIX, NUM_OF_ETCD is:
404 # <= NUM_OF_WORKER_NODES + 1 if SCHEDULE_ON_CONTROL_NODES == y
405 # <= NUM_OF_WORKER_NODES if SCHEDULE_ON_CONTROL_NODES == n
406 SCHEDULABLE_NODES=$NUM_OF_WORKER_NODES
407
408 if [ "$SCHEDULE_ON_CONTROL_NODES" == "yes" ]; then
409 SCHEDULABLE_NODES=$((NUM_OF_CONTROLLER_NODES+NUM_OF_WORKER_NODES))
410 fi
411 else
412 TOTAL_NODES=$(kubectl get --all-namespaces nodes -o name | wc -l)
413 NUM_OF_CONTROLLER_NODES=$(kubectl get --all-namespaces nodes -l node-role.kubernetes.io/master -o name | wc -l)
414 NUM_OF_WORKER_NODES=$((TOTAL_NODES - NUM_OF_CONTROLLER_NODES))
415 # shellcheck disable=SC2016
416 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')
417 rm -f "$TMP_KUBECFG"
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700418 fi
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700419 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"
420
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700421 if is_in "$WITH_KAFKA" "yes,external" && [ ! "$NUM_OF_KAFKA" -le "$SCHEDULABLE_NODES" ]; then
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700422 >&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}"
423 exit 1
424 fi
425
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700426 if is_in "$WITH_ETCD" "yes,external" && [ ! "$NUM_OF_ETCD" -le "$SCHEDULABLE_NODES" ]; then
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700427 >&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}"
428 exit 1
429 fi
430
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700431 if is_in "$WITH_ONOS" "yes,legacy,classic,micro"; then
432 if [ ! "$NUM_OF_ATOMIX" -le "$SCHEDULABLE_NODES" ]; then
433 >&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}"
434 exit 1
435 fi
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700436
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700437 if [ ! "$NUM_OF_ONOS" -le "$SCHEDULABLE_NODES" ]; then
438 >&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}"
439 exit 1
440 fi
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700441 fi
442fi
443
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700444# normalize non-truth value options
445if is_in "$WITH_KAFKA" "e,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -0700446 WITH_KAFKA="external"
447fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700448if is_in "$WITH_ETCD" "e,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -0700449 WITH_ETCD="external"
450fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700451if is_in "$WITH_ONOS" "l,legacy"; then
452 WITH_ONOS="legacy"
453elif is_in "$WITH_ONOS" "c,classic"; then
454 WITH_ONOS="classic"
455elif is_in "$WITH_ONOS" "u,m,micro"; then
456 WITH_ONOS="micro"
David Bainbridge29c31cb2020-04-06 09:45:50 -0700457fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700458
459if [ "$WITH_ONOS" == "micro" ]; then
460 >&2 echo -e "${YELLOW}${BOLD}${ERROR}WARNING:${NORMAL}${YELLOW} The value specified as WITH_ONOS, '$WITH_ONOS', is not valid.${NORMAL}"
461 exit 1
David Bainbridge29c31cb2020-04-06 09:45:50 -0700462fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700463
464if is_in "$WITH_ONOS" "yes,classic"; then
465 # there is an extra utility required if we are using ONOS CLASSIC as
466 # the chart for classic specifies images differently
467 EXTRA_TOOLS+=" yq"
David Bainbridge76afd812020-04-06 09:53:52 -0700468fi
David Bainbridge696bc632020-04-05 21:49:37 -0700469
David Bainbridge22db5dd2020-05-26 12:21:21 -0700470if [ "$LEGACY_BBSIM_INDEX" == "no" ]; then
471 BBSIM_SADIS_SVC="bbsim0"
472else
473 BBSIM_SADIS_SVC="bbsim"
474fi
475
476SADIS_SUBSCRIBERS=${SADIS_SUBSCRIBERS:-http://$BBSIM_SADIS_SVC.$VOLTHA_NS.svc:50074/v2/subscribers/%s}
477SADIS_BANDWIDTH_PROFILES=${SADIS_BANDWIDTH_PROFILES:-http://$BBSIM_SADIS_SVC.$VOLTHA_NS.svc:50074/v2/bandwidthprofiles/%s}
478
David Bainbridged18f4942020-04-14 16:46:13 -0700479if [ "$HELM_USE_UPGRADE" == "yes" ]; then
David Bainbridge7f8bf992020-04-08 21:53:22 -0700480 _HELM_DESC="Upgrade/Install"
481else
482 _HELM_DESC="Install"
483fi
484
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800485# Check for prerequiste tools
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700486TOOLS="curl sed jq $EXTRA_TOOLS"
David Bainbridged18f4942020-04-14 16:46:13 -0700487if [ "$DEPLOY_K8S" == "yes" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800488 TOOLS+=" docker"
489fi
490NOT_FOUND=""
491for T in $TOOLS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700492 if [ -z "$(command -v "$T")" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800493 NOT_FOUND+=" $T"
494 fi
495done
496
David Bainbridged18f4942020-04-14 16:46:13 -0700497if [ -n "$NOT_FOUND" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800498 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} The following required tools where not found, please install them:$NOT_FOUND"
499 exit 1
500fi
501
David Bainbridged18f4942020-04-14 16:46:13 -0700502TIMEOUT_SECONDS="$(parseDuration "$WAIT_TIMEOUT")"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700503
David Bainbridge0774b232019-08-02 06:37:19 +0000504mkdir -p .voltha
505touch .voltha/ports
David Bainbridged18f4942020-04-14 16:46:13 -0700506HAVE="$(grep "$NAME" .voltha/ports)"
David Bainbridge0774b232019-08-02 06:37:19 +0000507if [ "$HAVE X" == " X" ]; then
508 # Find free port prefix
509 START=81
510 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700511 if [ "$(grep -c $START .voltha/ports)" -eq 0 ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000512 break
513 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700514 START="$((START + 1))"
David Bainbridge0774b232019-08-02 06:37:19 +0000515 done
David Bainbridged18f4942020-04-14 16:46:13 -0700516 DELTA="$((START - 81))"
David Bainbridgea2595422019-10-22 03:54:28 +0000517 ONOS_API_PORT=${ONOS_API_PORT:-${START}81}
518 ONOS_SSH_PORT=${ONOS_SSH_PORT:-${START}01}
David Bainbridged18f4942020-04-14 16:46:13 -0700519 VOLTHA_API_PORT=${VOLTHA_API_PORT:-5$((55 + DELTA))55}
520 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$((50 + DELTA))22}
521 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$((23 + DELTA))79}
522 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$((90 + DELTA))92}
Matteo Scandoloefee0432020-05-05 13:56:20 -0700523 VOLTHA_PPROF_PORT=${VOLTHA_PPROF_PORT:-$((60 + DELTA))60}
524 OPENOLT_PPROF_PORT=${OPENOLT_PPROF_PORT:-$((60 + DELTA))61}
Matteo Scandolo65c35192020-05-13 10:41:21 -0700525 OFAGENT_PPROF_PORT=${OFAGENT_PPROF_PORT:-$((60 + DELTA))62}
divyadesai59f987a2020-05-27 12:11:33 +0000526 ELASTICSEARCH_PORT=${ELASTICSEARCH_PORT:-$((92 + DELTA))00}
527 KIBANA_PORT=${KIBANA_PORT:-$((56 + DELTA))01}
Girish Kumarcc5f9172020-06-10 13:34:31 +0000528 TRACING_GUI_PORT=${TRACING_GUI_PORT:-1$((66 + DELTA))86}
Test User01ed0642019-07-03 20:17:06 +0000529else
David Bainbridged18f4942020-04-14 16:46:13 -0700530 VALUES="$(echo "$HAVE" | sed -e 's/\s//g' | cut -d= -f2)"
531 ONOS_API_PORT=${ONOS_API_PORT:-$(echo "$VALUES" | cut -d, -f1)}
532 ONOS_SSH_PORT=${ONOS_SSH_PORT:-$(echo "$VALUES" | cut -d, -f2)}
533 VOLTHA_API_PORT=${VOLTHA_API_PORT:-$(echo "$VALUES" | cut -d, -f3)}
534 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$(echo "$VALUES" | cut -d, -f4)}
535 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$(echo "$VALUES" | cut -d, -f5)}
536 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(echo "$VALUES" | cut -d, -f6)}
Matteo Scandoloefee0432020-05-05 13:56:20 -0700537 VOLTHA_PPROF_PORT=${VOLTHA_PPROF_PORT:-$(echo "$VALUES" | cut -d, -f7)}
538 OPENOLT_PPROF_PORT=${OPENOLT_PPROF_PORT:-$(echo "$VALUES" | cut -d, -f8)}
Matteo Scandolo65c35192020-05-13 10:41:21 -0700539 OFAGENT_PPROF_PORT=${OFAGENT_PPROF_PORT:-$(echo "$VALUES" | cut -d, -f9)}
divyadesai59f987a2020-05-27 12:11:33 +0000540 ELASTICSEARCH_PORT=${ELASTICSEARCH_PORT:-$(echo "$VALUES" | cut -d, -f10)}
541 KIBANA_PORT=${KIBANA_PORT:-$(echo "$VALUES" | cut -d, -f11)}
Girish Kumarcc5f9172020-06-10 13:34:31 +0000542 TRACING_GUI_PORT=${TRACING_GUI_PORT:-$(echo "$VALUES" | cut -d, -f12)}
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800543
Matteo Scandoloefee0432020-05-05 13:56:20 -0700544 # Some ports were added after the .voltha/ports files was created.
545 # Calculate the original DELTA from the VOLTHA_SSH_PORT so that it can
546 # be used to set up newer port-forwards.
547 DELTA="$((VOLTHA_SSH_PORT/100-50))"
548
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800549 if [ -z "$VOLTHA_KAFKA_PORT" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -0700550 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$((90 + DELTA))92}
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800551 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -0700552
553 if [ -z "$VOLTHA_PPROF_PORT" ]; then
divyadesai59f987a2020-05-27 12:11:33 +0000554 VOLTHA_PPROF_PORT=${VOLTHA_PPROF_PORT:-$((60 + DELTA))60}
Matteo Scandoloefee0432020-05-05 13:56:20 -0700555 fi
556 if [ -z "$OPENOLT_PPROF_PORT" ]; then
divyadesai59f987a2020-05-27 12:11:33 +0000557 OPENOLT_PPROF_PORT=${OPENOLT_PPROF_PORT:-$((60 + DELTA))61}
Matteo Scandoloefee0432020-05-05 13:56:20 -0700558 fi
Matteo Scandolo65c35192020-05-13 10:41:21 -0700559 if [ -z "$OFAGENT_PPROF_PORT" ]; then
divyadesai59f987a2020-05-27 12:11:33 +0000560 OFAGENT_PPROF_PORT=${OFAGENT_PPROF_PORT:-$((60 + DELTA))62}
561 fi
562
563 if [ -z "$ELASTICSEARCH_PORT" ]; then
564 ELASTICSEARCH_PORT=${ELASTICSEARCH_PORT:-$((92 + DELTA))00}
565 fi
divyadesai59f987a2020-05-27 12:11:33 +0000566 if [ -z "$KIBANA_PORT" ]; then
567 KIBANA_PORT=${KIBANA_PORT:-$((56 + DELTA))01}
Matteo Scandolo65c35192020-05-13 10:41:21 -0700568 fi
Girish Kumarcc5f9172020-06-10 13:34:31 +0000569
570 if [ -z "$TRACING_GUI_PORT" ]; then
571 TRACING_GUI_PORT=${TRACING_GUI_PORT:-1$((66 + DELTA))86}
572 fi
Test User01ed0642019-07-03 20:17:06 +0000573fi
574
David Bainbridged18f4942020-04-14 16:46:13 -0700575PORTTMP="$(mktemp -u)"
576grep -v "$NAME" .voltha/ports > "$PORTTMP"
Girish Kumarcc5f9172020-06-10 13:34:31 +0000577echo "$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,$TRACING_GUI_PORT" >> "$PORTTMP"
David Bainbridged18f4942020-04-14 16:46:13 -0700578cp "$PORTTMP" .voltha/ports
579rm -f "$PORTTMP"
David Bainbridge0774b232019-08-02 06:37:19 +0000580
David Bainbridge27790d62019-08-13 22:43:19 +0000581export ONOS_API_PORT ONOS_SSH_PORT
David Bainbridge01294952019-07-30 19:33:45 +0000582
Test Userd87942b2019-07-03 07:20:24 +0000583IDX=1
David Bainbridgee87067b2019-08-12 22:00:12 +0000584CLOCK="TIME:"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000585SPIN_PARTS=
586NOT_VERIFIED=
David Bainbridgef858a022019-08-14 21:25:11 +0000587THEX=
588BUILD=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000589VERIFIED=
590HELM=
591OLD_KEY=
592BIRD=
593HIGH_VOLTAGE=
594PLUG=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000595FORWARD=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000596GO=
597DOWNLOAD=
598GEAR=
599NO_ENTRY=
600LOCK=
601
David Bainbridged18f4942020-04-14 16:46:13 -0700602if [ "$FANCY" -eq 1 ]; then
603 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 +0000604 CLOCK="\xe2\x8f\xb1"
David Bainbridgef858a022019-08-14 21:25:11 +0000605 THEX="${RED}${BOLD}\xe2\x9c\x97\x20${NORMAL}"
David Bainbridgef858a022019-08-14 21:25:11 +0000606 BUILD="${YELLOW}${BOLD}\xf0\x9f\x8f\x97${NORMAL}"
607 NOT_VERIFIED="$BUILD"
608 VERIFIED="${GREEN}${BOLD}\xe2\x9c\x93\x20${NORMAL}"
609 HELM="${BLUE}${BOLD}\xE2\x8E\x88${NORMAL}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000610 OLD_KEY="\xF0\x9F\x97\x9D"
611 BIRD="\xF0\x9F\x90\xA6"
612 HIGH_VOLTAGE="\xE2\x9A\xA1"
613 PLUG="\xF0\x9F\xa7\xa9"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000614 FORWARD="\xE2\x87\xA8"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000615 GO="\xf0\x9f\x9a\x80"
616 DOWNLOAD="\xf0\x9f\x93\xa5"
617 GEAR="\xe2\x9a\x99"
618 NO_ENTRY="\xe2\x9b\x94"
619 LOCK="\xf0\x9f\x94\x92"
620fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700621
David Bainbridge712afb82019-08-14 19:55:58 +0000622duration() {
David Bainbridged18f4942020-04-14 16:46:13 -0700623 local h m s t
624 h="$(($1 / 3600))"
625 m="$(($1 % 3600 / 60))"
626 s="$(($1 % 60))"
627 t=""
David Bainbridgee87067b2019-08-12 22:00:12 +0000628
David Bainbridged18f4942020-04-14 16:46:13 -0700629 if [ "$h" -gt 0 ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +0000630 t="$t${h}h"
631 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700632 if [ "$m" -gt 0 ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +0000633 t="$t${m}m"
634 fi
David Bainbridge712afb82019-08-14 19:55:58 +0000635 echo "$t${s}s"
636}
637
638printtime() {
David Bainbridged18f4942020-04-14 16:46:13 -0700639 local INDENT
David Bainbridge712afb82019-08-14 19:55:58 +0000640 if [ "$1" == "-" ]; then
641 INDENT=" "
642 shift
643 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700644 echo -e "$INDENT $CLOCK $(duration "$1")"
David Bainbridgee87067b2019-08-12 22:00:12 +0000645}
646
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700647bspin() {
Test Userd87942b2019-07-03 07:20:24 +0000648 IDX=1
David Bainbridged18f4942020-04-14 16:46:13 -0700649 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700650 if [ "$1" == "-" ]; then
651 INDENT=" "
652 shift
653 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700654 if [ "$FANCY" -eq 0 ]; then
655 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000656 if [ "$LINE X" == " X" ]; then
657 return
658 fi
659 echo -e "$CIVIS$INDENT$*"
660 else
661 echo -en "$CIVIS$INDENT $*"
662 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700663}
664
665sspin() {
David Bainbridged18f4942020-04-14 16:46:13 -0700666 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700667 if [ "$1" == "-" ]; then
668 INDENT=" "
669 shift
670 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700671 if [ "$FANCY" -eq 0 ]; then
672 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000673 if [ "$LINE X" == " X" ]; then
674 return
675 fi
676 echo -e "$INDENT$*"
677 else
David Bainbridged18f4942020-04-14 16:46:13 -0700678 C="$(echo "$SPIN_PARTS" | cut '-d ' -f "$IDX")"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000679 echo -en "\r$INDENT$C $*"
David Bainbridged18f4942020-04-14 16:46:13 -0700680 IDX="$((IDX + 1))"
681 if [ "$IDX" -gt 8 ]; then
David Bainbridge38dc1e82019-08-12 15:18:45 +0000682 IDX=1
683 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700684 fi
685}
686
687espin() {
David Bainbridged18f4942020-04-14 16:46:13 -0700688 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700689 if [ "$1" == "-" ]; then
690 INDENT=" "
691 shift
692 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700693 if [ "$FANCY" -eq 0 ]; then
694 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000695 if [ "$LINE X" == " X" ]; then
696 return
697 fi
698 echo -e "$INDENT$*"
699 else
700 echo -e "\r$INDENT$*$CNORM"
701 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700702}
703
David Bainbridged18f4942020-04-14 16:46:13 -0700704if [ "$1" == "get" ] && [ "$2" == "voltconfig" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000705 echo "$HOME/.volt/config-$NAME"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000706 exit
707fi
708
David Bainbridgee4d11ca2020-05-08 10:21:10 -0700709if [ $# -ne 1 ] || ! is_in "$1" "up,down,dump,clean"; then
David Bainbridgeac7f8072019-08-01 22:15:33 +0000710 >&2 echo "What wouild you like to do today:"
711 >&2 echo " up - bring up voltha"
712 >&2 echo " down - tear down voltha"
713 >&2 echo " dump - create a debug dump of running system"
714 exit 1
715fi
716
divyadesai59f987a2020-05-27 12:11:33 +0000717do_curl() {
718 local DATA_ARGS CREDS CMD_ECHO CMD_OUTPUT SC_OUTPUT WAIT_START INDENTA EXTRAA NOW
719 local INDENT=$1
720 local OP=$2
721 local USER=$3
722 local PASS=$4
723 local URL=$5
724 local DATA_TYPE=$6
725 local DATA=$7
726 local MSG=$8
727 local VALID_RESULTS=$9
728 local EXTRA=${10}
729 local ICON=${11}
730
731 # Turn into an array for passing
732 INDENTA=()
733 if [ -n "$INDENT" ]; then
734 INDENTA=("$INDENT")
735 fi
736 IFS=' ' read -r -a EXTRAA <<< "$EXTRA"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000737
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800738 # Thanks to the latest version of ONOS using the return code 207 this gets a
739 # whole lot nastier. Can't thank them enough for doing this. So in order to
740 # capture the command and the output in the log file as well as capture the
741 # status code to verify it is 200 and not 207 mutltiple files and a bit of
742 # hackery must be used. Thanks again ONOS.
David Bainbridged18f4942020-04-14 16:46:13 -0700743 CMD_ECHO="$(mktemp -u)"
744 CMD_OUTPUT="$(mktemp -u)"
745 SC_OUTPUT="$(mktemp -u)"
746 WAIT_START="$(date +%s)"
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800747
divyadesai59f987a2020-05-27 12:11:33 +0000748 CREDS=()
749 if [ -n "$USER" ]; then
750 CREDS=("--user" "$USER:$PASS")
751 fi
752
753 DATA_ARGS=()
754 if [ -n "$DATA" ]; then
755 if [ "$DATA_TYPE" == "file" ]; then
756 DATA_ARGS=("--data" "@$DATA")
757 elif [ "$DATA_TYPE" == "json" ]; then
758 DATA_ARGS=("--data" "$DATA")
759 fi
760 fi
761
762 bspin "${INDENTA[@]}" "$MSG" "$ICON"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000763 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700764 NOW="$(date +%s)"
765 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
divyadesai59f987a2020-05-27 12:11:33 +0000766 espin "${INDENTA[@]}" "$THEX"
David Bainbridged18f4942020-04-14 16:46:13 -0700767 rm -f "$CMD_ECHO" "$CMD_OUTPUT" "$SC_OUTPUT"
divyadesai59f987a2020-05-27 12:11:33 +0000768 doTimeout "$MSG"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700769 fi
divyadesai59f987a2020-05-27 12:11:33 +0000770 (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
771 RESULT=$?
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800772 # Dump everything to the log
David Bainbridged18f4942020-04-14 16:46:13 -0700773 cat "$CMD_ECHO" >> "$LOG"
774 test -r "$CMD_OUTPUT" && cat "$CMD_OUTPUT" >> "$LOG"
775 SC="$(cat "$SC_OUTPUT")"
776 echo "RESPONSE CODE: $SC" >> "$LOG"
777 echo "ERROR CODE: $RESULT" >> "$LOG"
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800778
779 # clean up temp files
David Bainbridged18f4942020-04-14 16:46:13 -0700780 rm -f "$CMD_ECHO" "$CMD_OUTPUT" "$SC_OUTPUT"
divyadesai59f987a2020-05-27 12:11:33 +0000781 if [ "$RESULT" -eq 0 ] && is_in "$SC" "$VALID_RESULTS"; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000782 break
783 fi
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800784 sleep 1
divyadesai59f987a2020-05-27 12:11:33 +0000785 sspin "${INDENTA[@]}"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000786 done
divyadesai59f987a2020-05-27 12:11:33 +0000787 espin "${INDENTA[@]}" "$VERIFIED"
788}
789
790push_onos_config() {
791 local DATA_TYPE=$1
792 local MSG=$2
793 local RESOURCE=$3
794 local DATA=$4
795
796 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 +0000797}
798
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800799check_onos_app_active() {
David Bainbridged18f4942020-04-14 16:46:13 -0700800 local APP_ID WAIT_START RESULT NOW
801 APP_ID=$1
802 WAIT_START="$(date +%s)"
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800803
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700804 bspin - "Checking that $APP_ID is active $CLOCK"
805 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700806 NOW="$(date +%s)"
807 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700808 espin - "$THEX"
809 doTimeout "waiting for ONOS application activation '$APP_ID'"
810 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700811 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 -0700812 break
813 fi
814 sleep 1
815 sspin -
816 done
817 sleep 5 # OSGI components take a little longer that the app to activate
David Bainbridged18f4942020-04-14 16:46:13 -0700818 espin - "$VERIFIED"
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800819}
820
David Bainbridge4f1b5562019-08-19 04:46:52 +0000821override_onos_app() {
David Bainbridged18f4942020-04-14 16:46:13 -0700822 local APP NAME WAIT_START NOW
823 APP=$1
824 NAME="$(basename "$APP" | sed -e 's/^[0-9][0-9]*-//g' -e 's/-.*$//g')"
825 WAIT_START="$(date +%s)"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700826
David Bainbridge4f1b5562019-08-19 04:46:52 +0000827 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700828 NOW="$(date +%s)"
829 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700830 espin - "$THEX"
831 doTimeout "waiting to overwrite ONOS application '$APP'"
832 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +0000833 sspin -
834 # Attempt to delete old version (if it exists)
David Bainbridged18f4942020-04-14 16:46:13 -0700835 (set -x; curl --fail -sSL --user karaf:karaf -X DELETE "http://$_ONOS_API_EP/onos/v1/applications/$NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
836 RESULT=$?
David Bainbridge4f1b5562019-08-19 04:46:52 +0000837 sspin -
David Bainbridged18f4942020-04-14 16:46:13 -0700838 if [ $RESULT -ne 0 ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000839 continue
840 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700841 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 +0000842 break
843 fi
844 sleep .2
845 done
846}
847
848activate_onos_app() {
David Bainbridged18f4942020-04-14 16:46:13 -0700849 local MSG APP WAIT_START NOW
850 MSG="$1"
851 APP=$2
852 WAIT_START="$(date +%s)"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000853
854 bspin - "$MSG $GO"
855 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700856 NOW="$(date +%s)"
857 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700858 espin - "$THEX"
859 doTimeout "waiting to activate ONOS application '$APP'"
860 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +0000861 sspin -
David Bainbridged18f4942020-04-14 16:46:13 -0700862 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 +0000863 break
864 fi
865 sleep .2
866 done
867 espin - "$VERIFIED"
868}
869
870count_pods() {
David Bainbridged18f4942020-04-14 16:46:13 -0700871 local NAMESPACE STATES LABELS CMD PODS
872 NAMESPACE=$1; shift
David Bainbridge4f1b5562019-08-19 04:46:52 +0000873 if [ "$NAMESPACE" == "all-namespaces" ]; then
874 NAMESPACE="--all-namespaces"
875 else
876 NAMESPACE="-n $NAMESPACE"
877 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700878 STATES=$1; shift
879 LABELS=$1; shift
880 CMD=("kubectl get $NAMESPACE $LABELS pod")
881 PODS=$(${CMD[*]} -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}")
David Bainbridge4f1b5562019-08-19 04:46:52 +0000882 local COUNT=0
883 local PATTERNS="$*"
884 for POD in $PODS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700885 local NAME STATE CONTAINERS TOTAL FOUND
886 NAME="$(echo "$POD" | cut -d/ -f 1)"
887 STATE="$(echo "$POD" | cut -d/ -f 2)"
888 CONTAINERS="$(echo "$POD" | cut -d/ -f 3 | sed -e 's/_/ /g')"
889 if [ "$STATES" == "*" ] || [ "$(echo "$STATES" | grep -c ":$STATE:")" -ne 0 ]; then
890 TOTAL="$(echo "$CONTAINERS" | wc -w)"
891 FOUND="$(echo "$CONTAINERS" | grep -o true | wc -l)"
892 if [ "$TOTAL" -eq "$FOUND" ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000893 for PATTERN in $PATTERNS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700894 if [[ "$NAME" =~ $PATTERN ]]; then
895 COUNT="$((COUNT + 1))"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000896 break
897 fi
898 done
899 fi
900 fi
901 done
David Bainbridge4f1b5562019-08-19 04:46:52 +0000902 echo $COUNT
903}
904
905wait_for_pods() {
David Bainbridged18f4942020-04-14 16:46:13 -0700906 local INDENT NAMESPACE EXPECT TYPE MESSAGE LABELS PATTERNS STATES HAVE ALL WAIT_START NOW
David Bainbridge4f1b5562019-08-19 04:46:52 +0000907 if [ "$1" == "-" ]; then
908 INDENT=$1; shift
909 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700910 NAMESPACE=$1; shift
911 EXPECT=$1; shift
912 TYPE=$1; shift
913 MESSAGE=$1; shift
914 LABELS=$1; shift
915 PATTERNS=("$*")
916 STATES=":Running:"
David Bainbridge99ac7a22019-08-31 02:26:43 +0000917 if [ "$TYPE" == "not" ]; then
918 STATES="*"
919 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700920 HAVE="$(count_pods "$NAMESPACE" "$STATES" "$LABELS" "${PATTERNS[@]}")"
921 ALL=$HAVE
David Bainbridge4f1b5562019-08-19 04:46:52 +0000922 if [ "$TYPE" == "only" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -0700923 ALL="$(count_pods "all-namespaces" "*" ".*")"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000924 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700925 COUNT="$((300 / 15))"
926 WAIT_START="$(date +%s)"
927 bspin "$INDENT" "$MESSAGE"
928 sspin "$INDENT"
929 if [ "$HAVE" -ne "$EXPECT" ] || [ "$ALL" -ne "$HAVE" ]; then
930 while [ "$HAVE" -ne "$EXPECT" ] || [ "$ALL" -ne "$HAVE" ]; do
931 NOW="$(date +%s)"
932 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
933 espin "$INDENT" "$THEX"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700934 doTimeout "waiting for PODs to start"
935 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700936 sspin "$INDENT"
937 COUNT="$((COUNT - 1))"
938 if [ "$COUNT" -eq 0 ]; then
939 HAVE="$(count_pods "$NAMESPACE" "$STATES" "$LABELS" "${PATTERNS[@]}")"
940 ALL="$HAVE"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000941 if [ "$TYPE" == "only" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -0700942 ALL="$(count_pods "all-namespaces" "*" ".*")"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000943 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700944 COUNT="$((300 / 15))"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000945 fi
946 sleep .15
947 done
948 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700949 espin "$INDENT" "$VERIFIED"
950 if [ "$HAVE" -ne "$EXPECT" ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000951 return 1
952 fi
953 return 0
954}
955
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800956port_forward() {
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700957 local NS=$1; shift
958 local SVC=$1; shift
959 local PORTS="$*"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800960 local TAG=$SVC-$NAME
961
David Bainbridgeb4bbde12020-06-25 14:46:36 -0700962 (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 -0800963}
964
965kill_port_forward() {
David Bainbridge1d2c5842020-06-03 15:29:07 -0700966 local TAG P_IDS PARENTS KIDS UNKNOWN PP_ID PF
967
968 while [ $# -gt 0 ]; do
969 PF=$1; shift
970 TAG=
971 if [ "$PF" != "__ALL__" ]; then
972 TAG="$PF-$NAME"
973 fi
974 PARENTS=
975 KIDS=
976 UNKNOWN=
977 # shellcheck disable=SC2009
978 P_IDS="$(ps e -ww -A | grep "_TAG=$TAG" | grep -v grep | awk '{print $1}')"
979 if [ -n "$P_IDS" ]; then
980 for P_ID in $P_IDS; do
981 PP_ID="$(ps -o ppid "$P_ID" | tail -n +2)"
982 if [ -n "$PP_ID" ]; then
983 if [ "$PP_ID" -eq 1 ]; then
984 PARENTS="$PARENTS $P_ID"
985 else
986 KIDS="$KIDS $P_ID"
987 fi
David Bainbridgec6871d22019-11-13 17:10:31 +0000988 else
David Bainbridge1d2c5842020-06-03 15:29:07 -0700989 UNKNOWN="$UNKNOWN $P_ID"
David Bainbridgec6871d22019-11-13 17:10:31 +0000990 fi
David Bainbridge1d2c5842020-06-03 15:29:07 -0700991 done
992 if [ -n "$PARENTS" ]; then
993 # shellcheck disable=SC2086
994 while ps -h $PARENTS >/dev/null 2>&1; do
995 (set -x; eval "kill -9 $PARENTS" >>"$LOG" 2>&1) >>"$LOG" 2>&1
996 done
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800997 fi
David Bainbridge1d2c5842020-06-03 15:29:07 -0700998 if [ -n "$KIDS" ]; then
999 # shellcheck disable=SC2086
1000 while ps -h $KIDS >/dev/null 2>&1; do
1001 (set -x; eval "kill -9 $KIDS" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1002 done
1003 fi
1004 if [ -n "$UNKNOWN" ]; then
1005 # shellcheck disable=SC2086
1006 while ps -h $UNKNOWN >/dev/null 2>&1; do
1007 (set -x; eval "kill -9 $UNKNOWN" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1008 done
1009 fi
1010 fi
1011 done
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001012}
1013
Girish Kumarcc5f9172020-06-10 13:34:31 +00001014resolve_chart_name() {
1015 helm inspect chart "$1" | grep "^name:" | awk '{print $2}'
1016}
1017
David Bainbridgecf546362020-04-21 23:18:50 -07001018resolve_chart_version() {
1019 [ "$2" != "latest" ] && echo "$2" && return
1020 helm inspect chart "$1" | grep "^version:" | awk '{print $2}'
1021}
1022
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07001023# Compares two semver-formatted version strings (e.g. 2.4.3)
1024# Returns 0 if $1 == $2, returns 1 if $1 > $2 and returns 2 if $1 < $2
1025compare_versions() {
1026 [ "$1" == "$2" ] && return 0
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07001027 local lowest
1028 lowest=$(echo -e "$1\n$2" | sort -V | head -1)
1029 [ "$lowest" == "$1" ] && return 2
1030 return 1
1031}
1032
David Bainbridgeac7f8072019-08-01 22:15:33 +00001033if [ "$1" == "down" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001034 echo "Tearing down voltha cluster $NAME"
1035 LOG="down-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -07001036 date -u +"%Y%m%dT%H%M%SZ" >"$LOG"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001037 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 -07001038 if is_in "$WITH_ONOS" "yes,legacy,classic"; then
David Bainbridge696bc632020-04-05 21:49:37 -07001039 bspin "Remove port-forwards: onos-ui-$NAME"
1040 kill_port_forward onos-ui
1041 sspin "Remove port-forwards: onos-ssh-$NAME$CEOL"
1042 kill_port_forward onos-ssh
David K. Bainbridge2aa08da2020-07-31 12:49:45 -07001043 sspin "Remove port-forwards: onos-onos-classic-hs-$NAME$CEOL"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001044 kill_port_forward onos-onos-classic-hs
David Bainbridge696bc632020-04-05 21:49:37 -07001045 fi
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001046 sspin "Remove port-forwards: voltha-api-$NAME$CEOL"
David Bainbridge1d2c5842020-06-03 15:29:07 -07001047 kill_port_forward voltha-api voltha-voltha-api
David Bainbridgec7220622020-05-28 12:31:47 -07001048 if is_in "$WITH_ETCD" "yes,external"; then
1049 sspin "Remove port-forwards: etcd-$NAME$CEOL"
1050 kill_port_forward "etcd"
David Bainbridge696bc632020-04-05 21:49:37 -07001051 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001052 if is_in "$WITH_KAFKA" "yes,external"; then
1053 sspin "Remove port-forwards: kafka-$NAME$CEOL"
1054 kill_port_forward "kafka"
David Bainbridge696bc632020-04-05 21:49:37 -07001055 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -07001056
1057 if [ "$WITH_PPROF" == "yes" ]; then
David Bainbridgec7220622020-05-28 12:31:47 -07001058 sspin "Remove port-forwards: *-profiler$CEOL"
David Bainbridge1d2c5842020-06-03 15:29:07 -07001059 kill_port_forward voltha-rw-core-profiler voltha-voltha-rw-core-profiler
1060 kill_port_forward voltha-of-agent-profiler voltha-voltha-of-agent-profiler
David Bainbridgec7220622020-05-28 12:31:47 -07001061 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
David Bainbridge1d2c5842020-06-03 15:29:07 -07001062 kill_port_forward adapter-open-olt-profiler open-olt-adapter-open-olt-profiler
David Bainbridgec7220622020-05-28 12:31:47 -07001063 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -07001064 fi
1065
Girish Kumarcc5f9172020-06-10 13:34:31 +00001066 if [ "$WITH_TRACING" == "yes" ]; then
1067 sspin "Remove port-forwards: tracing-$NAME$CEOL"
1068 VOLTHA_TRACING_CHART_NAME=$(resolve_chart_name "$VOLTHA_TRACING_CHART")
1069 kill_port_forward "tracing-${VOLTHA_TRACING_CHART_NAME}-jaeger-gui"
1070 fi
1071
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001072 espin "$VERIFIED Remove port-forwards$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -07001073 if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridgeac7f8072019-08-01 22:15:33 +00001074 if [ -x ./bin/kind ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001075 bspin "Delete Kubernetes Kind Cluster"
David Bainbridged18f4942020-04-14 16:46:13 -07001076 (set -x; ./bin/kind delete cluster --name "voltha-$NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1077 espin "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001078 else
David Bainbridge0774b232019-08-02 06:37:19 +00001079 espin "$NO_ENTRY Delete Kubernetes Kind Cluster: kind command not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001080 fi
1081 else
David Bainbridge309099c2020-05-05 08:47:29 -07001082 if [ "$CONFIG_SADIS" == "external" ]; then
1083 bspin "Remove configmap for BBSIM SADIS server"
1084 (set -x; kubectl -n "$BBSIM_NS" delete --ignore-not-found configmap kube-config >>"$LOG" 2>&1) >>"$LOG" 2>&1
1085 espin "$VERIFIED"
1086 fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001087
1088 if [ "$HELM_MAJOR" -le 2 ]; then
1089 EXISTS=$(helm list --output json 2>/dev/null | jq -r '.Releases | .[] | .Name + "," + .Namespace')
1090 else
1091 EXISTS=$(helm list --all-namespaces --output json 2>/dev/null | jq -r '.[] | .name + "," + .namespace')
1092 fi
David Bainbridge76afd812020-04-06 09:53:52 -07001093 EXPECT="voltha"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001094 if is_in "$WITH_ONOS" "yes,legacy,classic"; then
David Bainbridge696bc632020-04-05 21:49:37 -07001095 EXPECT+=" onos"
1096 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001097 if [ "$WITH_RADIUS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001098 EXPECT+=" radius"
1099 fi
David Bainbridge309099c2020-05-05 08:47:29 -07001100 if [ "$CONFIG_SADIS" == "external" ]; then
1101 EXPECT+=" bbsim-sadis-server"
1102 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001103 if [ "$WITH_BBSIM" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001104 EXPECT+=" bbsim"
1105 fi
divyadesai59f987a2020-05-27 12:11:33 +00001106 if [ "$WITH_EFK" == "yes" ]; then
1107 EXPECT+=" elasticsearch kibana fluentd"
1108 fi
Girish Kumarcc5f9172020-06-10 13:34:31 +00001109 if [ "$WITH_TRACING" == "yes" ]; then
1110 EXPECT+=" tracing"
1111 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001112 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001113 EXPECT+=" open-olt open-onu"
1114 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001115 if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001116 EXPECT+=" sim"
1117 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001118 if is_in "$WITH_ETCD" "yes,external"; then
1119 EXPECT+=" etcd"
David Bainbridge76afd812020-04-06 09:53:52 -07001120 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001121 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -07001122 EXPECT+=" kafka"
1123 fi
David Bainbridge0774b232019-08-02 06:37:19 +00001124 bspin "Remove Helm Deployments"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001125 for i in $EXISTS; do
David K. Bainbridge43422402020-03-06 07:41:22 -08001126 for j in $EXPECT; do
David Bainbridged18f4942020-04-14 16:46:13 -07001127 if [[ "$i" =~ $j ]]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001128 __NAME=$(echo "$i" | cut -d, -f1)
1129 __NS=$(echo "$i" | cut -d, -f2)
1130 sspin "Remove Helm Deployments: $__NS:$__NAME$CEOL"
1131 if [ "$HELM_MAJOR" -le 2 ]; then
1132 (set -x; helm delete --no-hooks --purge "$__NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1133 else
1134 (set -x; helm uninstall --no-hooks --namespace "$__NS" "$__NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1135 fi
David K. Bainbridge43422402020-03-06 07:41:22 -08001136 fi
1137 done
uottrembb16d3982020-02-28 08:34:36 +01001138 done
David Bainbridge0774b232019-08-02 06:37:19 +00001139 espin "$VERIFIED Remove Helm Deployments$CEOL"
David Bainbridge4f1b5562019-08-19 04:46:52 +00001140 if [ "$WAIT_ON_DOWN" == "yes" ]; then
Matteo Scandoloe93c9eb2020-06-03 12:08:51 -07001141 PODS="voltha-ofagent.* voltha-rw-core.*"
David Bainbridge76afd812020-04-06 09:53:52 -07001142 INFRA_PODS=
1143 ADAPT_PODS=
1144 SIM_PODS=
divyadesai59f987a2020-05-27 12:11:33 +00001145 EFK_PODS=
David Bainbridged18f4942020-04-14 16:46:13 -07001146 if [ "$WITH_RADIUS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001147 PODS+=" radius.*"
1148 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001149 if [ "$WITH_BBSIM" == "yes" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -07001150 SIM_PODS+=" bbsim.*"
David Bainbridge696bc632020-04-05 21:49:37 -07001151 fi
divyadesai59f987a2020-05-27 12:11:33 +00001152 if [ "$WITH_EFK" == "yes" ]; then
1153 EFK_PODS+=" kibana-* elasticsearch-* fluentd-*"
1154 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001155 if [ "$WITH_OPEN_ADAPTERS" ] || [ "$WITH_SIM_ADAPTERS" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -07001156 ADAPT_PODS+=" adapter-*"
David Bainbridge696bc632020-04-05 21:49:37 -07001157 fi
Girish Kumarcc5f9172020-06-10 13:34:31 +00001158 if [ "$WITH_TRACING" == "yes" ]; then
1159 INFRA_PODS+=" jaeger.*"
1160 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001161 if is_in "$WITH_ONOS" "yes,legacy,classic"; then
David Bainbridge76afd812020-04-06 09:53:52 -07001162 INFRA_PODS+=" onos-.*"
1163 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001164 if is_in "$WITH_ETCD" "yes,external"; then
1165 INFRA_PODS+=" etcd.*"
David Bainbridge76afd812020-04-06 09:53:52 -07001166 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001167 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -07001168 INFRA_PODS+=" kafka.*"
1169 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001170 if [ -n "$SIM_PODS" ]; then
1171 wait_for_pods "$BBSIM_NS" 0 "not" "Waiting for BBSIM PODs to terminate" "$BBSIM_LABEL" "$SIM_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -07001172 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001173 if [ -n "$INFRA_PODS" ]; then
1174 wait_for_pods "$INFRA_NS" 0 "not" "Waiting for infrastructure PODs to terminate" "$NO_LABEL" "$INFRA_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -07001175 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001176 if [ -n "$ADAPT_PODS" ]; then
1177 wait_for_pods "$ADAPTER_NS" 0 "not" "Waiting for adapter PODs to terminate" "$NO_LABEL" "$ADAPT_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -07001178 fi
divyadesai59f987a2020-05-27 12:11:33 +00001179 if [ -n "$EFK_PODS" ]; then
1180 wait_for_pods "$INFRA_NS" 0 "not" "Waiting for EFK PODs to terminate" "$NO_LABEL" "$EFK_PODS"
1181 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001182 wait_for_pods "$VOLTHA_NS" 0 "not" "Waiting for VOLTHA PODs to terminate" "$NO_LABEL" "$PODS"
David Bainbridge4f1b5562019-08-19 04:46:52 +00001183 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +00001184 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001185 exit
David Bainbridgeac7f8072019-08-01 22:15:33 +00001186fi
1187
1188if [ "$1" == "dump" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001189 LOG="dump-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -07001190 TS="$(date -u +"%Y%m%dT%H%M%SZ")"
1191 if [ -n "$DUMP_FROM" ]; then
1192 TS=${DUMP_FROM//[:-]}
David Bainbridge76514a02019-10-08 01:50:35 +00001193 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001194 WORK="$(mktemp -u -d)"
David Bainbridge0774b232019-08-02 06:37:19 +00001195 DATA=$WORK/voltha-debug-dump-$NAME-$TS
David Bainbridged18f4942020-04-14 16:46:13 -07001196 mkdir -p "$DATA"
1197 echo "$TS" > "$LOG"
David Bainbridge0774b232019-08-02 06:37:19 +00001198 echo -e "Capturing debug dump to voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001199 bspin - "Copy install log"
David Bainbridged18f4942020-04-14 16:46:13 -07001200 if [ -f "install-$NAME.log" ]; then
1201 (set -x; cp "install-$NAME.log" "$DATA/install-$NAME.log") >>"$LOG" 2>&1
1202 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001203 else
David Bainbridge0774b232019-08-02 06:37:19 +00001204 espin - "$NO_ENTRY Copy install log: install-$NAME.log not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001205 fi
1206 bspin - "Dumping Kubernetes PODs"
David Bainbridged18f4942020-04-14 16:46:13 -07001207 (set -x; kubectl get --all-namespaces pods >> "$DATA/all-pods.txt" 2>&1) >>"$LOG" 2>&1
1208 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001209 bspin - "Dumping Kubernetes SERVICEs"
David Bainbridged18f4942020-04-14 16:46:13 -07001210 (set -x; kubectl get --all-namespaces svc >> "$DATA/all-services.txt" 2>&1) >>"$LOG" 2>&1
1211 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001212 bspin - "Dumping Kubernetes EVENTs"
David Bainbridged18f4942020-04-14 16:46:13 -07001213 (set -x; kubectl get --all-namespaces events >> "$DATA/all-events.txt" 2>&1) >>"$LOG" 2>&1
1214 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001215 bspin - "Dumping VOLTHA POD details"
David Bainbridged18f4942020-04-14 16:46:13 -07001216 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 +00001217 SINCE=
David Bainbridged18f4942020-04-14 16:46:13 -07001218 if [ -n "$DUMP_FROM" ]; then
David Bainbridgecfd7ca12019-10-06 03:31:41 +00001219 SINCE="--since-time=$DUMP_FROM"
1220 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +00001221 for POD in $PODS; do
David Bainbridged18f4942020-04-14 16:46:13 -07001222 NS="$(echo "$POD" | cut -d: -f1)"
1223 POD="$(echo "$POD" | cut -d: -f2)"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001224 sspin - "Dumping VOLTHA POD details: $POD$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -07001225 mkdir -p "$DATA/$POD"
1226 (set -x; kubectl describe -n "$NS" "$POD" >> "$DATA/$POD/describe.txt" 2>&1) >>"$LOG" 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +00001227 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridged18f4942020-04-14 16:46:13 -07001228 (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 +00001229 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridged18f4942020-04-14 16:46:13 -07001230 (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 +00001231 sspin - "Dumping VOLTHA POD details: $POD"
1232 done
1233 espin - "$VERIFIED Dumping VOLTHA POD details$CEOL"
1234 bspin - "Dumping ETCD"
David Bainbridged18f4942020-04-14 16:46:13 -07001235 if [ -n "$(command -v etcdctl)" ]; then
1236 (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
1237 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001238 else
1239 espin - "$NO_ENTRY Dumping ETCD: etcdctl command not available"
1240 fi
David Bainbridge0774b232019-08-02 06:37:19 +00001241 bspin - "Creating compressed TAR: voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridged18f4942020-04-14 16:46:13 -07001242 (set -x; tar -C "$WORK" -zcf "voltha-debug-dump-$NAME-$TS.tgz" "./voltha-debug-dump-$NAME-$TS") >>"$LOG" 2>&1
1243 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001244 bspin - "Cleanup"
David Bainbridged18f4942020-04-14 16:46:13 -07001245 (set -x; rm -rf "$WORK") >>"$LOG" 2>&1
1246 espin - "$VERIFIED"
1247 bspin - "$(ls -l "voltha-debug-dump-$NAME-$TS.tgz")"
1248 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001249 exit
1250fi
1251
David Bainbridge0774b232019-08-02 06:37:19 +00001252LOG="install-$NAME.log"
David Bainbridge1d2c5842020-06-03 15:29:07 -07001253PFLOG="port-forward-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -07001254date > "$LOG"
Girish Kumarcc5f9172020-06-10 13:34:31 +00001255echo "PORTS=$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,$TRACING_GUI_PORT" >> "$LOG"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001256
1257# Output install options to log
David Bainbridged18f4942020-04-14 16:46:13 -07001258echo "OPTIONS" >> "$LOG"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001259for O in $ALL_OPTIONS; do
David Bainbridged18f4942020-04-14 16:46:13 -07001260 VAL="$(eval echo "\$$O")"
1261 if [ -n "$VAL" ]; then
1262 printf " %-30s = %s\n" "$O" "$VAL" >> "$LOG"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001263 fi
1264done
1265
David Bainbridgee4d11ca2020-05-08 10:21:10 -07001266# Force remove any existing k8s port-forward processes. This will
1267# remove them for all kind clusters.
David Bainbridgee4d11ca2020-05-08 10:21:10 -07001268if [ "$1" == "clean" ]; then
1269 kill_port_forward __ALL__
1270 exit
1271fi
1272
David Bainbridgefad50732020-05-01 17:00:12 -07001273helm_values() {
1274 local NAMESPACE=$1; shift
1275 local INAME=$1; shift
1276 local CHART=$1; shift
1277 local CHART_VERSION=$1; shift
1278
1279 if [ "$CHART_VERSION X" != " X" ] && [ "$CHART_VERSION" != "latest" ]; then
1280 CHART_VERSION="--version $CHART_VERSION"
1281 else
1282 CHART_VERSION=
1283 fi
1284
1285 local CHART_ARGS=
1286 if [ -r "${INAME}-values.yaml" ]; then
1287 CHART_ARGS="-f ${INAME}-values.yaml"
1288 fi
1289
1290 if [ "$HELM_USE_UPGRADE" == "yes" ]; then
1291 _HELM_COMMAND="upgrade --install"
1292 _HELM_ARGS="xxxdryrunxxx"
1293 else
1294 _HELM_COMMAND="install"
Matteo Scandolof2d080b2020-07-23 13:59:29 -07001295 if [ "$HELM_MAJOR" -le 2 ]; then
1296 _HELM_NAME_ARG="--name xxxdryrunxxx"
1297 _HELM_ARGS=
1298 else
1299 _HELM_NAME_ARG="xxxdryrunxxx"
1300 _HELM_ARGS="--create-namespace"
1301 fi
David Bainbridgefad50732020-05-01 17:00:12 -07001302 fi
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001303 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 -07001304 ${CMD[*]} 2>/dev/null | awk 'PRINT==1 {print}; /^USER-SUPPLIED VALUES:/ {PRINT = 1}; /^$/ {PRINT = 0}'
1305}
1306
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001307helm_is_deployed() {
1308 local NAMESPACE=$1; shift
1309 local NAME=$1; shift
1310
1311 if [ "$HELM_MAJOR" -le 2 ]; then
1312 helm list --deployed --short --namespace "$NAMESPACE" "$NAME" 2>/dev/null | wc -l
1313 else
1314 helm list --deployed --short --namespace "$NAMESPACE" --filter "$NAME" 2>/dev/null | wc -l
1315 fi
1316}
1317
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001318helm_install() {
David Bainbridgec7220622020-05-28 12:31:47 -07001319 local INDENT NOW VALUES_FILE PPROF_ARG
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001320 if [ "$1" == "-" ]; then
1321 INDENT=$1; shift
1322 fi
1323 local NAMESPACE=$1; shift
David Bainbridge0774b232019-08-02 06:37:19 +00001324 local INAME=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001325 local CHART=$1; shift
David Bainbridge90fd8e32019-08-21 23:32:47 +00001326 local CHART_VERSION=$1; shift
David Bainbridgec7220622020-05-28 12:31:47 -07001327 local FILTER=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001328 local MESSAGE=$*
1329
David Bainbridged18f4942020-04-14 16:46:13 -07001330 if [ "$CHART_VERSION X" != " X" ] && [ "$CHART_VERSION" != "latest" ]; then
David Bainbridge90fd8e32019-08-21 23:32:47 +00001331 CHART_VERSION="--version $CHART_VERSION"
1332 else
1333 CHART_VERSION=
1334 fi
1335
David Bainbridge99ac7a22019-08-31 02:26:43 +00001336 local CHART_ARGS=
1337 if [ -r "${INAME}-values.yaml" ]; then
1338 CHART_ARGS="-f ${INAME}-values.yaml"
1339 fi
1340
David Bainbridged18f4942020-04-14 16:46:13 -07001341 local WAIT_START CMD
1342 WAIT_START="$(date +%s)"
1343 COUNT="$((300 / 15))"
1344 bspin "$INDENT" "$MESSAGE"
1345 if [ "$HELM_USE_UPGRADE" == "yes" ]; then
David Bainbridge7f8bf992020-04-08 21:53:22 -07001346 _HELM_COMMAND="upgrade --install"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001347 _HELM_NAME_ARG="$INAME"
David Bainbridge7f8bf992020-04-08 21:53:22 -07001348 else
1349 _HELM_COMMAND="install"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001350 if [ "$HELM_MAJOR" -le 2 ]; then
1351 _HELM_NAME_ARG="--name $INAME"
1352 _HELM_ARGS=
1353 else
1354 _HELM_NAME_ARG="$INAME"
1355 _HELM_ARGS="--create-namespace"
1356 fi
David Bainbridge7f8bf992020-04-08 21:53:22 -07001357 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001358
1359 VALUES_FILE="$(mktemp)"
1360 if [ "$FILTER" == "-" ]; then
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001361 cp "values.yaml" "$VALUES_FILE"
David Bainbridgea965ca22020-06-09 17:45:04 -07001362 elif [ "${FILTER:0:1}" == "+" ]; then
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001363 cp "values.yaml" "$VALUES_FILE"
1364 yq r - "${FILTER:1}" <"values.yaml" >>"$VALUES_FILE"
David Bainbridge33e56c72020-06-11 11:39:56 -07001365 cat "$VALUES_FILE" >>"$LOG"
David Bainbridgec7220622020-05-28 12:31:47 -07001366 else
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001367 yq r - "$FILTER" <"values.yaml" >"$VALUES_FILE"
David Bainbridgec7220622020-05-28 12:31:47 -07001368 fi
1369 if [ "$WITH_PPROF" == "yes" ]; then
1370 PPROF_ARG="--set profiler.enabled=true"
1371 fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001372 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 -07001373 (set -x; ${CMD[*]} >>"$LOG" 2>&1) >>"$LOG" 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001374 SUCCESS=$?
David Bainbridged18f4942020-04-14 16:46:13 -07001375 while [ "$SUCCESS" -ne 0 ]; do
1376 NOW="$(date +%s)"
1377 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -07001378 espin "$THEX"
David Bainbridgec7220622020-05-28 12:31:47 -07001379 rm -f "$VALUES_FILE"
David Bainbridge52e6e9d2020-03-23 13:48:27 -07001380 doTimeout "waiting for helm install $CHART"
1381 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001382 sspin "$INDENT"
1383 COUNT="$((COUNT - 1))"
1384 if [ "$COUNT" -eq 0 ]; then
1385 if [ "$HELM_USE_UPGRADE" == "no" ]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001386 if [ "$HELM_MAJOR" -le 2 ]; then
1387 (set -x; helm delete --purge "$INAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1388 else
1389 (set -x; helm uninstall "$INAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1390 fi
David Bainbridge7f8bf992020-04-08 21:53:22 -07001391 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001392 (set -x; ${CMD[*]} >>"$LOG" 2>&1) >>"$LOG" 2>&1
Andy Baviere22ff252019-12-19 11:40:31 -07001393 SUCCESS=$?
David Bainbridged18f4942020-04-14 16:46:13 -07001394 COUNT="$((300 / 15))"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001395 fi
1396 sleep .15
1397 done
David Bainbridgec7220622020-05-28 12:31:47 -07001398 rm -f "$VALUES_FILE"
David Bainbridged18f4942020-04-14 16:46:13 -07001399 espin "$INDENT" "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001400}
1401
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001402echo "INSTALL NAME: $NAME" >> "$LOG"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001403
David Bainbridged18f4942020-04-14 16:46:13 -07001404STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001405if [ "$INSTALL_KUBECTL" == "no" ]; then
1406 bspin "Skip kubectl install"
1407 espin $NO_ENTRY
Test Userc13bdc92019-07-03 20:57:49 +00001408else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001409 bspin "Verify kubectl $HELM"
David Bainbridged18f4942020-04-14 16:46:13 -07001410 if [ -x "$GOPATH/bin/kubectl" ]; then
1411 espin "$VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001412 else
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001413 ERR_OUT="$(mktemp)"
David Bainbridged18f4942020-04-14 16:46:13 -07001414 espin "$NOT_VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001415 bspin - "Download and install Kubernetes/kubectl $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001416 (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
1417 RESULT=$?
1418 if [ "$RESULT" -ne 0 ]; then
1419 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001420 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download kubectl: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001421 cat "$ERR_OUT" >> "$LOG"
Zack Williamsded60cb2020-04-13 10:02:20 -07001422 rm -rf "$ERR_OUT" "$GOPATH/bin/kubectl"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001423 exit 1
1424 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001425 (set -x; chmod 755 "$GOPATH/bin/kubectl" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1426 espin - "$VERIFIED"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001427 rm -rf "$ERR_OUT"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001428 fi
Test Userc13bdc92019-07-03 20:57:49 +00001429fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001430if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001431 NOW="$(date +%s)"
1432 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001433fi
Test Userc13bdc92019-07-03 20:57:49 +00001434
David Bainbridged18f4942020-04-14 16:46:13 -07001435STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001436if [ "$DEPLOY_K8S" == "no" ]; then
1437 bspin "Skip Kubernetes/Kind Deployment"
1438 espin $NO_ENTRY
1439else
Test Userba1e7e72019-07-10 22:27:54 +00001440 bspin "Verify Kubernetes/Kind $HELM"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001441 IS_INSTALLED=0
1442 OP_TYPE="install"
David Bainbridged18f4942020-04-14 16:46:13 -07001443 if [ -x "$GOPATH/bin/kind" ]; then
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001444 OP_TYPE="upgrade"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001445 if [ "$("$GOPATH/bin/kind" version | grep -c "$KIND_VERSION")" -eq 1 ]; then
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001446 IS_INSTALLED=1
David Bainbridged18f4942020-04-14 16:46:13 -07001447 espin "$VERIFIED"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001448 fi
1449 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001450 if [ "$IS_INSTALLED" -eq 0 ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001451 ERR_OUT="$(mktemp)"
David Bainbridged18f4942020-04-14 16:46:13 -07001452 espin "$NOT_VERIFIED"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001453 bspin - "Download and $OP_TYPE Kubernetes/kind $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001454 (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
1455 RESULT=$?
1456 if [ $RESULT -ne 0 ]; then
1457 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001458 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download kind: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001459 cat "$ERR_OUT" >> "$LOG"
Zack Williamsded60cb2020-04-13 10:02:20 -07001460 rm -rf "$ERR_OUT" "$GOPATH/bin/kind"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001461 exit 1
1462 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001463 (set -x; chmod 755 "$GOPATH/bin/kind" >>"$LOG" 2>&1) >>"$LOG" 2>&1
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001464 rm -rf "$ERR_OUT"
David Bainbridged18f4942020-04-14 16:46:13 -07001465 espin - "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001466 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001467fi
1468
David Bainbridgee87067b2019-08-12 22:00:12 +00001469if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001470 NOW="$(date +%s)"
1471 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001472fi
1473
David Bainbridged18f4942020-04-14 16:46:13 -07001474STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001475if [ "$INSTALL_HELM" == "no" ]; then
1476 bspin "Skip Helm Install"
1477 espin $NO_ENTRY
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001478else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001479 bspin "Verify Helm $HELM"
David Bainbridgea34993d2020-04-01 09:15:42 -07001480 HELM_UPGRADE=0
1481 HELM_UPGRADE_DESC="install"
David Bainbridged18f4942020-04-14 16:46:13 -07001482 if [ -x "$GOPATH/bin/helm" ]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001483 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 -07001484 HELM_UP_DOWN="$(echo -e "$HAVE_VER\n$HELM_VERSION" | sort -V | head -1)"
1485 if [ "$HAVE_VER" != "$HELM_VERSION" ]; then
1486 if [ "$HELM_UP_DOWN" == "$HELM_VERSION" ]; then
David Bainbridgea34993d2020-04-01 09:15:42 -07001487 HELM_UPGRADE_DESC="downgrade"
1488 else
1489 HELM_UPGRADE_DESC="upgrade"
1490 fi
1491 HELM_UPGRADE=1
1492 else
David Bainbridged18f4942020-04-14 16:46:13 -07001493 espin "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001494 fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001495 else
David Bainbridgea34993d2020-04-01 09:15:42 -07001496 HELM_UPGRADE=1
1497 fi
1498
David Bainbridged18f4942020-04-14 16:46:13 -07001499 if [ "$HELM_UPGRADE" -ne 0 ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001500 ERR_OUT="$(mktemp)"
1501 INSTALL_HELM_BIN=$(mktemp)
David Bainbridged18f4942020-04-14 16:46:13 -07001502 espin "$NOT_VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001503 bspin - "Download and $HELM_UPGRADE_DESC Helm $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001504 (set -x; curl -o "$INSTALL_HELM_BIN" --fail -sSL https://git.io/get_helm.sh >>"$LOG" 2>"$ERR_OUT") >>"$LOG" 2>&1
1505 RESULT=$?
1506 if [ $RESULT -ne 0 ]; then
1507 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001508 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download helm installer: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001509 cat "$ERR_OUT" >> "$LOG"
1510 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT" "$GOPATH/bin/helm" "$GOPATH/bin/tiller"
1511 exit 1
1512 fi
1513 rm -rf "$ERR_OUT"
1514 chmod +x "$INSTALL_HELM_BIN"
1515 (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
1516 RESULT=$?
1517 if [ $RESULT -ne 0 ]; then
1518 espin - "$THEX"
1519 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to install helm, see install log for details${NORMAL}"
1520 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT" "$GOPATH/bin/helm" "$GOPATH/bin/tiller"
1521 exit 1
1522 fi
1523 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT"
David Bainbridged18f4942020-04-14 16:46:13 -07001524 espin - "$VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001525 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001526fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001527if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001528 NOW="$(date +%s)"
1529 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001530fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001531HELM_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 -07001532
David Bainbridged18f4942020-04-14 16:46:13 -07001533STIME="$(date +%s)"
Test Userb5712372019-07-03 21:52:17 +00001534bspin "Verify voltctl $HIGH_VOLTAGE"
David Bainbridged2811972019-12-14 01:14:09 +00001535VOK=0
1536VMESSAGE="install"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001537ERR_OUT=$(mktemp)
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001538export VC_VERSION="$VOLTCTL_VERSION"
1539if [ "$VC_VERSION" == "latest" ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001540 set -o pipefail # TODO: would be nice to run all in pipefail mode
1541 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')"
1542 RESULT=$?
1543 set +o pipefail
1544 if [ "$RESULT" -ne 0 ]; then
1545 espin - "$THEX"
1546 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to determine released version of voltctl: $(cat "$ERR_OUT")${NORMAL}"
1547 rm -rf "$ERR_OUT" "$GOPATH/bin/voltctl"
1548 exit 1
1549 fi
1550 export VC_VERSION
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001551fi
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001552
David Bainbridged18f4942020-04-14 16:46:13 -07001553if [ -x "$GOPATH/bin/voltctl" ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001554 VHAVE="$("$GOPATH/bin/voltctl" version --clientonly -o json 2>/dev/null | jq -r .version)"
David Bainbridged18f4942020-04-14 16:46:13 -07001555 RESULT=$?
1556 if [ $RESULT -eq 0 ] && [ "$VHAVE" == "$VC_VERSION" ]; then
David Bainbridged2811972019-12-14 01:14:09 +00001557 VOK=1
David Bainbridged18f4942020-04-14 16:46:13 -07001558 espin "$VERIFIED"
David Bainbridge1ba64f12019-12-18 00:40:13 +00001559 else
David Bainbridged18f4942020-04-14 16:46:13 -07001560 VCHECK="$(echo -e "$VHAVE\n$VC_VERSION" | sort -V | head -1)"
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001561 if [ "$VCHECK" == "$VHAVE" ]; then
1562 VMESSAGE="upgrade"
1563 else
1564 VMESSAGE="downgrade"
1565 fi
David Bainbridged2811972019-12-14 01:14:09 +00001566 fi
1567fi
1568
David Bainbridged18f4942020-04-14 16:46:13 -07001569if [ "$VOK" -eq 0 ]; then
1570 espin "$NOT_VERIFIED"
David Bainbridged2811972019-12-14 01:14:09 +00001571 bspin - "Download and $VMESSAGE voltctl $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001572 (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
1573 RESULT=$?
1574 if [ $RESULT -ne 0 ]; then
1575 espin - "$THEX"
1576 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download voltctl (version $VC_VERSION): $(cat "$ERR_OUT")${NORMAL}"
1577 rm -rf "$ERR_OUT" "$GOPATH/bin/voltctl"
1578 exit 1
1579 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001580 (set -x; chmod 755 "$GOPATH/bin/voltctl" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1581 espin - "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001582fi
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001583rm -rf "$ERR_OUT"
David Bainbridgee87067b2019-08-12 22:00:12 +00001584if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001585 NOW="$(date +%s)"
1586 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001587fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001588
1589bspin "Verify command PATH"
David Bainbridged18f4942020-04-14 16:46:13 -07001590espin "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001591
David Bainbridged18f4942020-04-14 16:46:13 -07001592STIME="$(date +%s)"
Test Userba1e7e72019-07-10 22:27:54 +00001593if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001594 HAVE="$(kind get clusters 2>/dev/null | grep -c "voltha-$NAME")"
Test Userba1e7e72019-07-10 22:27:54 +00001595 bspin "Verify Kubernetes/Kind Cluster"
1596 sspin
David Bainbridged18f4942020-04-14 16:46:13 -07001597 if [ "$HAVE" -eq 0 ]; then
1598 espin "$NOT_VERIFIED"
Andrea Campanella8a149192020-07-31 17:19:45 +02001599 FILE="$NAME-cluster.cfg"
David K. Bainbridge2aa08da2020-07-31 12:49:45 -07001600 if [ -n "$KIND_CFG_FILE" ]; then
1601 FILE="$KIND_CFG_FILE"
1602 else
1603 bspin - "Generating cluster configuration"
Andrea Campanelladd946472020-07-31 11:03:44 +02001604
David K. Bainbridge2aa08da2020-07-31 12:49:45 -07001605 if [ -f "$FILE" ] ; then
1606 rm "$FILE"
1607 fi
1608
1609 touch "$FILE"
1610
1611 yq w -i "$FILE" kind Cluster
1612 yq w -i "$FILE" apiVersion "kind.sigs.k8s.io/v1alpha3"
1613
1614 if [ ! "$NUM_OF_CONTROLLER_NODES" -eq 0 ]; then
1615 for instance in $(seq 1 "$NUM_OF_CONTROLLER_NODES"); do
1616 yq w -i "$FILE" "nodes[+].role" "control-plane"
1617 done
1618 fi
1619
1620 if [ ! "$NUM_OF_WORKER_NODES" -eq 0 ]; then
1621 for instance in $(seq 1 "$NUM_OF_WORKER_NODES"); do
1622 yq w -i "$FILE" "nodes[+].role" worker
1623 done
1624 fi
1625 espin - "$VERIFIED"
Andrea Campanelladd946472020-07-31 11:03:44 +02001626 fi
1627
Andrea Campanella8a149192020-07-31 17:19:45 +02001628 cat "$FILE" >> "$LOG" 2>&1
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001629
Andrea Campanella8a149192020-07-31 17:19:45 +02001630 kind create cluster --name "voltha-$NAME" --config "$FILE"
David Bainbridge491b1bd2019-07-11 17:53:11 +00001631 else
David Bainbridged18f4942020-04-14 16:46:13 -07001632 espin "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001633 fi
1634
David K. Bainbridgec0ec6492020-07-21 17:34:23 +00001635 KUBECONFIG_TMP=$(mktemp)
1636 kind get kubeconfig --name="voltha-$NAME" >"$KUBECONFIG_TMP"
1637 mkdir -p "$HOME/.kube"
1638 KUBECONFIG="$HOME/.kube/kind-config-voltha-$NAME"; export KUBECONFIG
1639 cp "$KUBECONFIG_TMP" "$KUBECONFIG"
1640 rm -rf "$KUBECONFIG_TMP"
David Bainbridge1d2c5842020-06-03 15:29:07 -07001641
Test Userba1e7e72019-07-10 22:27:54 +00001642 P="coredns-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001643 etcd-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +00001644 kindnet-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001645 kube-apiserver-voltha-$NAME-control-plane \
1646 kube-controller-manager-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +00001647 kube-proxy-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001648 kube-scheduler-voltha-$NAME-control-plane"
Test Userba1e7e72019-07-10 22:27:54 +00001649
David K. Bainbridge2aa08da2020-07-31 12:49:45 -07001650 EXPECT=2 # Always 2 DNS instances
1651 EXPECT=$((EXPECT + 4 * NUM_OF_CONTROLLER_NODES)) # etcd, apiserver, controller manager, scheduler
1652 EXPECT=$((EXPECT + 2 * (NUM_OF_CONTROLLER_NODES + NUM_OF_WORKER_NODES))) # kindnet, proxy
David Bainbridged18f4942020-04-14 16:46:13 -07001653 wait_for_pods - "kube-system" "$EXPECT" "includes" "Waiting for system PODs to start" "$NO_LABEL" "$P"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001654fi
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001655
David Bainbridgee87067b2019-08-12 22:00:12 +00001656if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001657 NOW="$(date +%s)"
1658 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001659fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001660
David Bainbridgee4d11ca2020-05-08 10:21:10 -07001661if [ "$SCHEDULE_ON_CONTROL_NODES" == "yes" ]; then
1662 bspin "Untaint control nodes to allow scheduling $LOCK"
1663 for MNODE in $(kubectl get node --selector='node-role.kubernetes.io/master' -o json | jq -r '.items[].metadata.name'); do
1664 (set -x; kubectl taint node "$MNODE" node-role.kubernetes.io/master:NoSchedule- >>"$LOG" 2>&1) >>"$LOG" 2>&1
1665 sspin
1666 done
1667 espin "$VERIFIED"
1668fi
1669
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001670if [ "$HELM_MAJOR" -le 2 ]; then
1671 STIME="$(date +%s)"
1672 COUNT="$(count_pods "kube-system" ":Running:" "$NO_LABEL" "tiller-deploy-.*")"
1673 bspin "Verify Helm"
1674 if [ "$COUNT" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001675 espin "$NOT_VERIFIED"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001676 echo -e "Configuring Helm $GEAR"
1677 if [ "$INSTALL_HELM" == "no" ]; then
1678 bspin - "Skip Helm Initialization"
1679 espin - $NO_ENTRY
1680 else
1681 bspin - "Initialize Helm"
1682 (set -x; helm init --upgrade >>"$LOG" 2>&1) >>"$LOG" 2>&1
1683 espin - "$VERIFIED"
1684 wait_for_pods - "kube-system" 1 "includes" "Waiting for Tiller POD to start" "$NO_LABEL" "tiller-deploy-.*"
1685 fi
1686
1687 # HACK (sort-of) - the config for tiller is about to be patched, which will
1688 # cause the tiller pod to be recreated. This can sometimes cause a timing
1689 # issue with the "wait_for_pods" call on tiller as it may incorrectly
1690 # identify the running/ready tiller pod that is soon to be terminated as
1691 # what it is waiting for. To avoid this issue we do a clean scale down and
1692 # scale up of the pod so the script controlls when it should be expecting
1693 # things
1694 (set -x; kubectl -n kube-system scale deploy tiller-deploy --replicas=0 >>"$LOG" 2>&1) >>"$LOG" 2>&1
1695 wait_for_pods - "kube-system" 0 "not" "Waiting for Tiller POD to shutdown" "$NO_LABEL" "tiller-deploy-.*"
1696
1697 # Create and k8s service account so that Helm can create pods
1698 bspin - "Create Tiller ServiceAccount"
1699 (set -x; kubectl create serviceaccount --namespace kube-system tiller >>"$LOG" 2>&1) >>"$LOG" 2>&1
1700 espin - "$VERIFIED"
1701 bspin - "Create Tiller ClusterRoleBinding"
1702 (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>"$LOG" 2>&1) >>"$LOG" 2>&1
1703 espin - "$VERIFIED"
1704 bspin - "Update Tiller Manifest"
1705 (set -x; kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}' >>"$LOG" 2>&1) >>"$LOG" 2>&1
1706
1707 # HACK (sort-of) - part to, spin it back up
1708 (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 -07001709 espin - "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001710 else
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001711 if [ "$(helm version -s --template '{{.Server.SemVer}}')" != "$HELM_VERSION" ]; then
1712 espin "$NOT_VERIFIED"
1713 bspin - "Sync Tiller server version with helm client"
1714 (set -x; helm init --upgrade --force-upgrade --wait >>"$LOG" 2>&1) >>"$LOG" 2>&1
1715 espin - "$VERIFIED"
1716 else
1717 espin "$VERIFIED"
1718 fi
1719
David Bainbridgea34993d2020-04-01 09:15:42 -07001720 fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001721 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 -07001722fi
David Bainbridgeddeab482020-06-24 12:43:40 -07001723
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001724# The `etcd` repo is temporary until `http://github.com/helm/charts/pull/22955` is
1725# merged into the incubator charts
David Bainbridgeddeab482020-06-24 12:43:40 -07001726REPOS="onf|https://charts.opencord.org|ONF_VOLTHA \
1727 stable|https://kubernetes-charts.storage.googleapis.com|Google_Stable \
Ubuntubaab12f2020-06-30 01:08:19 +00001728 incubator|https://kubernetes-charts-incubator.storage.googleapis.com|Google_Incubator \
1729 onos|https://charts.onosproject.org|ONF_ONOS \
1730 atomix|https://charts.atomix.io|ONF_Atomix \
1731 bbsim-sadis|https://ciena.github.io/bbsim-sadis-server/charts|Custom_BBSIM_SADIS_Server \
1732 elastic|https://helm.elastic.co|Elastic \
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001733 kiwigrid|https://kiwigrid.github.io|Fluentd-ElasticSearch \
1734 etcd|https://dbainbri-ciena.github.io/etcd-helm-chart"
David Bainbridgeddeab482020-06-24 12:43:40 -07001735
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001736REPO_UPDATE_REQ="no"
David Bainbridgeddeab482020-06-24 12:43:40 -07001737bspin - "Verify Helm Repository"
1738for REPO in $REPOS; do
1739 REPO_NAME="$(echo "$REPO" | cut -d\| -f1)"
1740 REPO_URL="$(echo "$REPO" | cut -d\| -f2)"
1741 REPO_LABEL="$(echo "$REPO" | cut -d\| -f3 | sed -e 's/_/ /g')"
1742
1743 sspin - "Verify Helm Repository: $REPO_LABEL$CEOL"
1744 if [ "$(helm repo list 2>/dev/null | grep -c "$REPO_NAME" 2>/dev/null)" -eq 0 ]; then
1745 sspin - "Add Helm Repository: $REPO_LABEL$CEOL"
1746 (set -x; helm repo add "$REPO_NAME" "$REPO_URL" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1747 REPO_UPDATE_REQ="yes"
1748 fi
1749done
1750sspin - "Verify Helm Repositories$CEOL"
1751espin - "$VERIFIED"
1752
1753if [ "$REPO_UPDATE_REQ" == "yes" ] || [ "$UPDATE_HELM_REPOS" == "yes" ]; then
1754 bspin - "Update Helm repository cache"
1755 (set -x; helm repo update >>"$LOG" 2>&1) >>"$LOG" 2>&1
1756 espin - "$VERIFIED"
1757fi
1758
David Bainbridgee87067b2019-08-12 22:00:12 +00001759if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001760 NOW="$(date +%s)"
1761 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001762fi
David Bainbridgecf546362020-04-21 23:18:50 -07001763# Resolve chart versions and log them for debug/support
1764RESOLVED_VOLTHA_CHART_VERSION=$(resolve_chart_version "$VOLTHA_CHART" "$VOLTHA_CHART_VERSION")
1765RESOLVED_VOLTHA_BBSIM_CHART_VERSION=$(resolve_chart_version "$VOLTHA_BBSIM_CHART" "$VOLTHA_BBSIM_CHART_VERSION")
Girish Kumarcc5f9172020-06-10 13:34:31 +00001766RESOLVED_VOLTHA_TRACING_CHART_VERSION=$(resolve_chart_version "$VOLTHA_TRACING_CHART" "$VOLTHA_TRACING_CHART_VERSION")
David Bainbridgecf546362020-04-21 23:18:50 -07001767RESOLVED_VOLTHA_ADAPTER_SIM_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_SIM_CHART" "$VOLTHA_ADAPTER_SIM_CHART_VERSION")
1768RESOLVED_VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_OPEN_OLT_CHART" "$VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION")
1769RESOLVED_VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_OPEN_ONU_CHART" "$VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION")
1770RESOLVED_ONOS_CHART_VERSION=$(resolve_chart_version "$ONOS_CHART" "$ONOS_CHART_VERSION")
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001771RESOLVED_ONOS_CLASSIC_CHART_VERSION=$(resolve_chart_version "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION")
David Bainbridgecf546362020-04-21 23:18:50 -07001772RESOLVED_KAFKA_CHART_VERSION=$(resolve_chart_version "$KAFKA_CHART" "$KAFKA_CHART_VERSION")
divyadesai59f987a2020-05-27 12:11:33 +00001773RESOLVED_ELASTICSEARCH_CHART_VERSION=$(resolve_chart_version "$ELASTICSEARCH_CHART" "$ELASTICSEARCH_CHART_VERSION")
1774RESOLVED_KIBANA_CHART_VERSION=$(resolve_chart_version "$KIBANA_CHART" "$KIBANA_CHART_VERSION")
1775RESOLVED_FLUENTD_ELASTICSEARCH_CHART_VERSION=$(resolve_chart_version "$FLUENTD_ELASTICSEARCH_CHART" "$FLUENTD_ELASTICSEARCH_CHART_VERSION")
David K. Bainbridge450c15c2020-06-29 10:12:06 -07001776RESOLVED_BBSIM_SADIS_SERVER_CHART_VERSION=$(resolve_chart_version "$BBSIM_SADIS_SERVER_CHART" "$BBSIM_SADIS_SERVER_CHART_VERSION")
1777RESOLVED_RADIUS_CHART_VERSION=$(resolve_chart_version "$RADIUS_CHART" "$RADIUS_CHART_VERSION")
David Bainbridgecf546362020-04-21 23:18:50 -07001778cat <<EOV >>"$LOG"
1779Resolved helm charts and versions:
1780 $VOLTHA_CHART:$RESOLVED_VOLTHA_CHART_VERSION
1781 $VOLTHA_BBSIM_CHART:$RESOLVED_VOLTHA_BBSIM_CHART_VERSION
Girish Kumarcc5f9172020-06-10 13:34:31 +00001782 $VOLTHA_TRACING_CHART:$RESOLVED_VOLTHA_TRACING_CHART_VERSION
David Bainbridgecf546362020-04-21 23:18:50 -07001783 $VOLTHA_ADAPTER_SIM_CHART:$RESOLVED_VOLTHA_ADAPTER_SIM_CHART_VERSION
1784 $VOLTHA_ADAPTER_OPEN_OLT_CHART:$RESOLVED_VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION
1785 $VOLTHA_ADAPTER_OPEN_ONU_CHART:$RESOLVED_VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION
1786 $ONOS_CHART:$RESOLVED_ONOS_CHART_VERSION
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001787 $ONOS_CLASSIC_CHART:$RESOLVED_ONOS_CLASSIC_CHART_VERSION
David Bainbridgecf546362020-04-21 23:18:50 -07001788 $KAFKA_CHART:$RESOLVED_KAFKA_CHART_VERSION
divyadesai59f987a2020-05-27 12:11:33 +00001789 $ELASTICSEARCH_CHART:$RESOLVED_ELASTICSEARCH_CHART_VERSION
1790 $KIBANA_CHART:$RESOLVED_KIBANA_CHART_VERSION
1791 $FLUENTD_ELASTICSEARCH_CHART:$RESOLVED_FLUENTD_ELASTICSEARCH_CHART_VERSION
David K. Bainbridge450c15c2020-06-29 10:12:06 -07001792 $BBSIM_SADIS_SERVER_CHART:$RESOLVED_BBSIM_SADIS_SERVER_CHART_VERSION
1793 $RADIUS_CHART:$RESOLVED_RADIUS_CHART_VERSION
David Bainbridgecf546362020-04-21 23:18:50 -07001794EOV
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001795
David Bainbridged18f4942020-04-14 16:46:13 -07001796STIME="$(date +%s)"
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001797bspin "Verify Helm values file: values.yaml"
1798if [ ! -r "./values.yaml" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001799 espin "$NOT_VERIFIED"
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001800 bspin - "Download Helm values file: values.yaml to values.yaml $DOWNLOAD"
David Bainbridged18f4942020-04-14 16:46:13 -07001801 ERR_OUT="$(mktemp)"
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001802 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 -07001803 espin - "$THEX"
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001804 echo -e "${RED}${BOLD}${ERROR}ERROR: values.yaml${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
David Bainbridged18f4942020-04-14 16:46:13 -07001805 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001806 rm -rf "$ERR_OUT" "./values.yaml"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001807 exit 1
1808 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001809 rm -rf "$ERR_OUT"
1810 espin - "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001811else
David Bainbridged18f4942020-04-14 16:46:13 -07001812 espin "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001813fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001814if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001815 NOW="$(date +%s)"
1816 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001817fi
Test Userba1e7e72019-07-10 22:27:54 +00001818
David Bainbridged18f4942020-04-14 16:46:13 -07001819STIME="$(date +%s)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001820bspin "Verify or download chart specific values files $DOWNLOAD"
1821VALUES_FILES="monkey-values.yaml"
David Bainbridged18f4942020-04-14 16:46:13 -07001822ERR_OUT="$(mktemp)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001823for i in $VALUES_FILES; do
1824 if [ ! -r ./$i ]; then
serkant.uluderya4d315132020-04-15 16:25:54 -07001825 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 -07001826 espin "$THEX"
1827 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1828 echo "ERROR: $i - $(cat "$ERR_OUT")" >>"$LOG"
1829 rm -rf "$ERR_OUT" "./$i"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001830 exit 1
1831 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001832 rm -rf "$ERR_OUT"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001833 fi
1834done
David Bainbridged18f4942020-04-14 16:46:13 -07001835rm -rf "$ERR_OUT"
1836espin "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001837if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001838 NOW="$(date +%s)"
1839 printtime $((NOW - STIME))
David Bainbridge99ac7a22019-08-31 02:26:43 +00001840fi
1841
1842if [ "$WITH_CHAOS" == "yes" ]; then
1843 bspin "Verify or clone kube-monkey helm chart $DOWNLOAD"
1844 if [ -r ./kube-monkey ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001845 espin "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001846 else
David Bainbridged18f4942020-04-14 16:46:13 -07001847 espin "$NOT_VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001848 bspin - "GIT clone kube-monkey"
David Bainbridged18f4942020-04-14 16:46:13 -07001849 (set -x; git clone https://github.com/asobti/kube-monkey kube-monkey >>"$LOG" 2>&1) >>"$LOG" 2>&1
1850 espin - "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001851 fi
1852fi
1853
Test Userba1e7e72019-07-10 22:27:54 +00001854if [ "$JUST_K8S" == "yes" ]; then
1855 echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye."
1856 echo ""
David Bainbridged18f4942020-04-14 16:46:13 -07001857 echo "Please issue the following commands in your terminal to ensure that you" | tee -a "$LOG"
1858 echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a "$LOG"
1859 echo "tools required by VOLTHA in your command path. " | tee -a "$LOG"
1860 echo "" | tee -a "$LOG"
1861 echo -en "$BOLD"
1862 if [ "$DEPLOY_K8S" == "yes" ]; then
David K. Bainbridge02ae1f32020-07-21 13:25:13 -07001863 KUBECONFIG_TMP=$(mktemp)
1864 kind get kubeconfig --name="voltha-$NAME" >"$KUBECONFIG_TMP"
1865 mkdir -p "$HOME/.kube"
1866 KUBECONFIG="$HOME/.kube/kind-config-voltha-$NAME"; export KUBECONFIG
1867 cp "$KUBECONFIG_TMP" "$KUBECONFIG"
1868 rm -rf "$KUBECONFIG_TMP"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001869 echo "export KUBECONFIG=\"$KUBECONFIG\"" | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00001870 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001871 echo "export PATH=$GOPATH/bin:\$PATH" | tee -a "$LOG"
1872 echo -en "$NORMAL"
1873 echo "" | tee -a "$LOG"
1874 echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00001875 exit 0
1876fi
1877
David Bainbridged18f4942020-04-14 16:46:13 -07001878STIME="$(date +%s)"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001879if is_in "$WITH_ONOS" "yes,legacy,classic"; then
1880 if is_in "$WITH_ONOS" "legacy"; then
1881 bspin "Verify ONOS LEGACY installed $BIRD"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001882 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^onos\$")" -ne 1 ]; then
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001883 espin "$NOT_VERIFIED"
David Bainbridge33e56c72020-06-11 11:39:56 -07001884 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 -07001885 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
1886 else
1887 espin "$VERIFIED"
1888 fi
1889 wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for ONOS to start" "$NO_LABEL" "onos-.*"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001890
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001891 if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
1892 bspin - "Forward ONOS API port $FORWARD"
1893 kill_port_forward onos-ui
1894 port_forward "$INFRA_NS" onos-ui "$ONOS_API_PORT:8181"
1895 espin - "$VERIFIED"
1896 bspin - "Forward ONOS SSH port $FORWARD"
1897 kill_port_forward onos-ssh
1898 port_forward "$INFRA_NS" onos-ssh "$ONOS_SSH_PORT:8101"
1899 espin - "$VERIFIED"
1900 _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT"
1901 else
1902 _ONOS_API_EP="$(get_service_ep "$INFRA_NS" onos-ui)"
1903 fi
1904 elif is_in "$WITH_ONOS" "yes,classic"; then
1905 bspin "Verify ONOS CLASSIC installed $BIRD"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001906 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^onos\$")" -ne 1 ]; then
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001907 espin "$NOT_VERIFIED"
Matteo Scandoloe0829b52020-05-08 14:23:56 -07001908 # 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 -07001909 # values value
David Bainbridgefad50732020-05-01 17:00:12 -07001910 YAML_VALUES=$(INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set replicas=$NUM_OF_ONOS --set atomix.replicas=$NUM_OF_ATOMIX" \
1911 helm_values "$INFRA_NS" onos "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION")
1912 _ONOS_REPO="$(echo "$YAML_VALUES" | yq read - images.onos.repository)"
David Bainbridgedee3f022020-06-05 07:45:13 -07001913 if [ -z "$_ONOS_REPO" ]; then
1914 _ONOS_REPO="voltha/voltha-onos"
1915 fi
David Bainbridgefad50732020-05-01 17:00:12 -07001916 _ONOS_TAG="$(echo "$YAML_VALUES" | yq read - images.onos.tag)"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001917 if [ -z "$_ONOS_TAG" ]; then
David Bainbridgedee3f022020-06-05 07:45:13 -07001918 _ONOS_TAG="$(echo "$YAML_VALUES" | yq read - defaults.image_tag)"
1919 fi
1920 if [ -z "$_ONOS_TAG" ]; then
1921 _ONOS_TAG="master"
1922 fi
1923 _ONOS_PULL_POLICY="$(echo "$YAML_VALUES" | yq read - images.onos.pullPolicy)"
1924 if [ -z "$_ONOS_PULL_POLICY" ]; then
1925 _ONOS_PULL_POLICY="$(echo "$YAML_VALUES" | yq read - defaults.image_pullPolicy)"
1926 fi
1927 if [ -z "$_ONOS_PULL_POLICY" ]; then
1928 _ONOS_PULL_POLICY="Always"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001929 fi
David Bainbridgefad50732020-05-01 17:00:12 -07001930
Matteo Scandoloe0829b52020-05-08 14:23:56 -07001931 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 -07001932 helm_install - "$INFRA_NS" onos "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION" "+onos" "$_HELM_DESC ONOS CLASSIC"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001933 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
1934 else
1935 espin "$VERIFIED"
1936 fi
1937 wait_for_pods - "$INFRA_NS" $((NUM_OF_ONOS + NUM_OF_ATOMIX)) "includes" "Waiting for ONOS CLASSIC to start" "$NO_LABEL" "onos-.*"
1938 if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
1939 bspin - "Forward ONOS API port $FORWARD"
1940 kill_port_forward onos-onos-classic-hs
1941 port_forward "$INFRA_NS" onos-onos-classic-hs "$ONOS_API_PORT:8181" "$ONOS_SSH_PORT:8101"
1942 espin - "$VERIFIED"
1943 _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT"
1944 else
1945 _ONOS_API_EP="$(get_service_ep "$INFRA_NS" onos-onos-classic-hs)"
1946 fi
1947 elif [ "$WITH_ONOS" == "micro" ]; then
1948 bspin "Verify micro-ONOS installed $BIRD"
1949 # We should never get here
1950 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Micro ONOS not currently supported${NORMAL}"
1951 exit 1
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001952 fi
David Bainbridged31d6122019-08-13 19:37:59 +00001953 bspin - "Verify or download ONOS configuration support files $DOWNLOAD"
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001954 ONOS_FILES="olt-onos-enableExtraneousRules.json onos-aaa.json \
David Bainbridge696bc632020-04-05 21:49:37 -07001955 onos-dhcpl2relay.json onos-sadis-sample.json"
David Bainbridged18f4942020-04-14 16:46:13 -07001956 (set -x; mkdir -p ./onos-files >>"$LOG" 2>&1) >>"$LOG" 2>&1
1957 ERR_OUT="$(mktemp)"
David Bainbridge2b19e832019-08-16 02:40:53 +00001958 for i in $ONOS_FILES; do
David Bainbridged18f4942020-04-14 16:46:13 -07001959 if [ ! -r "./onos-files/$i" ]; then
serkant.uluderya4d315132020-04-15 16:25:54 -07001960 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 -07001961 espin - "$THEX"
1962 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1963 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
1964 rm -rf "$ERR_OUT" "./onos-files/$i"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001965 exit 1
1966 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001967 rm -rf "$ERR_OUT"
David Bainbridged31d6122019-08-13 19:37:59 +00001968 fi
1969 done
David Bainbridged18f4942020-04-14 16:46:13 -07001970 rm -rf "$ERR_OUT"
1971 espin - "$VERIFIED"
David Bainbridge27790d62019-08-13 22:43:19 +00001972
David Bainbridged18f4942020-04-14 16:46:13 -07001973 if [ "$INSTALL_ONOS_APPS" == "yes" ]; then
David Bainbridge27790d62019-08-13 22:43:19 +00001974 bspin - "Installing custom ONOS applications"
David Bainbridged18f4942020-04-14 16:46:13 -07001975 if [ -x onos-files/onos-apps ] && [ "$(find onos-files/onos-apps -name "*.oar" 2>/dev/null | wc -l)" -gt 0 ]; then
1976 for OAR in onos-files/onos-apps/*.oar; do
David Bainbridge27790d62019-08-13 22:43:19 +00001977 sspin - "Installing custom ONOS applications - $OAR$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -07001978 override_onos_app "$OAR"
David Bainbridge27790d62019-08-13 22:43:19 +00001979 done
1980 espin - "$VERIFIED Installing custom ONOS applications$CEOL"
1981 else
1982 espin - "$NOT_VERIFIED Installing custom ONOS applications - None Found"
1983 fi
1984 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001985
David Bainbridged18f4942020-04-14 16:46:13 -07001986 if [ "$WITH_KAFKA" != "no" ]; then
David Bainbridge837e8bd2020-04-06 13:17:14 -07001987 check_onos_app_active org.opencord.kafka
David Bainbridge879439b2020-06-12 15:59:35 -07001988 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridgec7220622020-05-28 12:31:47 -07001989 _HOST=kafka.$INFRA_NS.svc
David Bainbridge76afd812020-04-06 09:53:52 -07001990 _PORT=9092
David Bainbridge879439b2020-06-12 15:59:35 -07001991 elif [ "$WITH_KAFKA" != "no" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001992 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
1993 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge837e8bd2020-04-06 13:17:14 -07001994 _PORT=${_PORT:-9092}
1995 fi
1996 push_onos_config "json" "Push ONOS Kafka Configuration" "network/configuration/apps/org.opencord.kafka" \
David Bainbridged18f4942020-04-14 16:46:13 -07001997 "$(cat <<EOJ | tr -d '[:space:]'
David Bainbridge696bc632020-04-05 21:49:37 -07001998{
1999 "kafka": {
2000 "bootstrapServers": "$_HOST:$_PORT"
2001 }
2002}
2003EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07002004)"
David Bainbridge837e8bd2020-04-06 13:17:14 -07002005 fi
Matteo Scandolo9a77a732020-01-09 14:24:12 -08002006 check_onos_app_active org.opencord.dhcpl2relay
Matteo Scandolo78dfee02020-02-13 16:18:03 -08002007 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 -08002008 check_onos_app_active org.opencord.olt
Matteo Scandolo78dfee02020-02-13 16:18:03 -08002009 # FIXME use WITH_DHCP and WITH_EAPOL flags to configre OLT App
Hardik Windlassa7501fb2020-02-17 14:28:20 +00002010 # Default value for "enableEapol" is true in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07002011 if [ "$WITH_EAPOL" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08002012 push_onos_config "json" "Enable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":true}'
David Bainbridged18f4942020-04-14 16:46:13 -07002013 elif [ "$WITH_EAPOL" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00002014 push_onos_config "json" "Disable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08002015 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00002016 # Default value for "enableDhcpOnProvisioning" is false and for "enableDhcpV4" is true in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07002017 if [ "$WITH_DHCP" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08002018 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 -07002019 elif [ "$WITH_DHCP" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00002020 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 -08002021 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00002022 # Default value for "enableIgmpOnProvisioning" is false in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07002023 if [ "$WITH_IGMP" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08002024 push_onos_config "json" "Enable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":true}'
David Bainbridged18f4942020-04-14 16:46:13 -07002025 elif [ "$WITH_IGMP" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00002026 push_onos_config "json" "Disable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08002027 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002028 if [ "$ENABLE_ONOS_EXTRANEOUS_RULES" == "yes" ]; then
David K. Bainbridge484d80c2020-03-05 21:44:34 -08002029 push_onos_config "file" "Enabling extraneous rules for ONOS" "configuration/org.onosproject.net.flow.impl.FlowRuleManager" "onos-files/olt-onos-enableExtraneousRules.json"
2030 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002031 if is_in "$CONFIG_SADIS" "yes,file"; then
Matteo Scandolo9a77a732020-01-09 14:24:12 -08002032 check_onos_app_active org.opencord.sadis
Hardik Windlassb3147602020-03-09 16:59:15 +05302033 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 -07002034 elif [ "$CONFIG_SADIS" == "bbsim" ]; then
2035 push_onos_config "json" \
2036 "[optional] Push ONOS configuration for BBSIM SADIS servers" \
2037 "network/configuration/apps/org.opencord.sadis" \
David Bainbridged18f4942020-04-14 16:46:13 -07002038 "$(cat <<EOJ | tr -d '[:space:]'
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002039{
2040 "sadis": {
2041 "integration": {
David Bainbridgec7220622020-05-28 12:31:47 -07002042 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:50074/v2/subscribers/%s",
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002043 "cache": {
2044 "enabled": true,
2045 "maxsize": 50,
2046 "ttl": "PT1m"
2047 }
2048 }
2049 },
2050 "bandwidthprofile": {
2051 "integration": {
David Bainbridgec7220622020-05-28 12:31:47 -07002052 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:50074/v2/bandwidthprofiles/%s",
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002053 "cache": {
2054 "enabled": true,
2055 "maxsize": 50,
2056 "ttl": "PT1m"
2057 }
2058 }
2059 }
2060}
2061EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07002062)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002063 elif [ "$CONFIG_SADIS" == "url" ]; then
2064 push_onos_config "json" \
2065 "[optional] Push ONOS configuration for custom SADIS and Bandwidth Profile servers" \
2066 "network/configuration/apps/org.opencord.sadis" \
David Bainbridged18f4942020-04-14 16:46:13 -07002067 "$(cat <<EOJ | tr -d '[:space:]'
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002068{
2069 "sadis": {
2070 "integration": {
2071 "url": "$SADIS_SUBSCRIBERS",
2072 "cache": {
2073 "enabled": true,
2074 "maxsize": 50,
2075 "ttl": "PT1m"
2076 }
2077 }
2078 },
2079 "bandwidthprofile": {
2080 "integration": {
2081 "url": "$SADIS_BANDWIDTH_PROFILES",
2082 "cache": {
2083 "enabled": true,
2084 "maxsize": 50,
2085 "ttl": "PT1m"
2086 }
2087 }
2088 }
2089}
2090EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07002091)"
David Bainbridge2b19e832019-08-16 02:40:53 +00002092 fi
Test Userba1e7e72019-07-10 22:27:54 +00002093fi
David Bainbridgee87067b2019-08-12 22:00:12 +00002094if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002095 NOW="$(date +%s)"
2096 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002097fi
Test Userba1e7e72019-07-10 22:27:54 +00002098
David Bainbridgec7220622020-05-28 12:31:47 -07002099if is_in "$WITH_ETCD" "yes,external"; then
David Bainbridged18f4942020-04-14 16:46:13 -07002100 STIME="$(date +%s)"
David Bainbridge76afd812020-04-06 09:53:52 -07002101 bspin "Verify external ETCD cluster $OLD_KEY"
Matteo Scandolo657e13c2020-07-28 11:41:42 -07002102 EXPECT=$NUM_OF_ETCD
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002103 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^etcd\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002104 espin "$NOT_VERIFIED"
Matteo Scandolo657e13c2020-07-28 11:41:42 -07002105 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"
2106 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
David Bainbridge76afd812020-04-06 09:53:52 -07002107 else
David Bainbridged18f4942020-04-14 16:46:13 -07002108 espin "$VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07002109 fi
David Bainbridgec7220622020-05-28 12:31:47 -07002110 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for ETCD cluster to start" "$NO_LABEL" "etcd-.*"
David Bainbridge76afd812020-04-06 09:53:52 -07002111 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002112 NOW="$(date +%s)"
2113 printtime $((NOW - STIME))
David Bainbridge76afd812020-04-06 09:53:52 -07002114 fi
2115fi
2116
David Bainbridgec7220622020-05-28 12:31:47 -07002117if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridged18f4942020-04-14 16:46:13 -07002118 _TMP="$(mktemp -u)"
David Bainbridged18f4942020-04-14 16:46:13 -07002119 cat << EOC > "$_TMP"
David Bainbridge76afd812020-04-06 09:53:52 -07002120configurationOverrides:
Matteo Scandolo657e13c2020-07-28 11:41:42 -07002121 "default.replication.factor": $NUM_OF_KAFKA
2122 "offsets.topic.replication.factor": $NUM_OF_KAFKA
David Bainbridge76afd812020-04-06 09:53:52 -07002123 "log.retention.hours": 4
2124 "log.message.timestamp.type": "LogAppendTime"
2125persistence:
2126 enabled: false
2127zookeeper:
Matteo Scandolo657e13c2020-07-28 11:41:42 -07002128 replicaCount: $NUM_OF_KAFKA
David Bainbridge76afd812020-04-06 09:53:52 -07002129 persistence:
2130 enabled: false
Matteo Scandolo657e13c2020-07-28 11:41:42 -07002131replicas: $NUM_OF_KAFKA
David Bainbridge76afd812020-04-06 09:53:52 -07002132EOC
David Bainbridged18f4942020-04-14 16:46:13 -07002133 STIME="$(date +%s)"
David Bainbridge76afd812020-04-06 09:53:52 -07002134 bspin "Verify external Kafka cluster $OLD_KEY"
Matteo Scandolo657e13c2020-07-28 11:41:42 -07002135 EXPECT=$((NUM_OF_KAFKA*2))
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002136 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^kafka\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002137 espin "$NOT_VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07002138 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" -f $_TMP"
David Bainbridgec7220622020-05-28 12:31:47 -07002139 helm_install - "$INFRA_NS" kafka "$KAFKA_CHART" "$KAFKA_CHART_VERSION" kafka "$_HELM_DESC external Kafka cluster"
David Bainbridge76afd812020-04-06 09:53:52 -07002140 else
David Bainbridged18f4942020-04-14 16:46:13 -07002141 espin "$VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07002142 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002143 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for Kafka cluster to start" "$NO_LABEL" "kafka-.*"
David Bainbridge76afd812020-04-06 09:53:52 -07002144 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002145 NOW="$(date +%s)"
2146 printtime $((NOW - STIME))
David Bainbridge76afd812020-04-06 09:53:52 -07002147 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002148 rm -rf "$_TMP"
David Bainbridge76afd812020-04-06 09:53:52 -07002149fi
2150
Girish Kumarcc5f9172020-06-10 13:34:31 +00002151if [ "$WITH_TRACING" == "yes" ]; then
2152 STIME="$(date +%s)"
2153 echo -e "Verify Jaeger Tracing $PLUG"
2154 bspin - "Verify Jaeger Tracing Installed"
2155 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^tracing\$")" -ne 1 ]; then
2156 espin - "$NOT_VERIFIED"
2157 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
2158 helm_install - "$INFRA_NS" tracing "$VOLTHA_TRACING_CHART" "$VOLTHA_TRACING_CHART_VERSION" tracing "$_HELM_DESC Jaeger Tracing"
2159 else
2160 espin - "$VERIFIED"
2161 fi
2162 wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for Jaeger Tracing to start" "$NO_LABEL" "jaeger*"
2163 if [ "$WITH_TIMINGS" == "yes" ]; then
2164 NOW="$(date +%s)"
2165 printtime $((NOW - STIME))
2166 fi
2167fi
2168
David Bainbridged18f4942020-04-14 16:46:13 -07002169STIME="$(date +%s)"
David Bainbridgeed476572020-06-02 14:05:45 -07002170EXPECT=2
2171# therecanbeonlyone set hardcoded to true for backward compatibility
2172INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set therecanbeonlyone=true"
Matteo Scandolo67335f02020-04-09 11:19:53 -07002173case $WITH_ETCD in
David Bainbridge76afd812020-04-06 09:53:52 -07002174 no)
David Bainbridge76afd812020-04-06 09:53:52 -07002175 ;;
David Bainbridgec7220622020-05-28 12:31:47 -07002176 yes|external)
2177 _HOST="etcd.$INFRA_NS.svc"
David Bainbridge76afd812020-04-06 09:53:52 -07002178 _PORT=2379
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002179 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
Neha Sharmaa1c92ca2020-06-24 11:50:33 +00002180 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.address=$_HOST:$_PORT"
David Bainbridge76afd812020-04-06 09:53:52 -07002181 ;;
2182 *)
David Bainbridged18f4942020-04-14 16:46:13 -07002183 _HOST="$(echo "$WITH_ETCD" | cut -d: -f1)"
2184 _PORT="$(echo "$WITH_ETCD" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07002185 _PORT=${_PORT:-2379}
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002186 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
Neha Sharmaa1c92ca2020-06-24 11:50:33 +00002187 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.address=$_HOST:$_PORT"
David Bainbridge76afd812020-04-06 09:53:52 -07002188 ;;
2189esac
2190case $WITH_KAFKA in
2191 no)
David Bainbridge76afd812020-04-06 09:53:52 -07002192 ;;
David Bainbridgec7220622020-05-28 12:31:47 -07002193 yes|external)
2194 _HOST=kafka.$INFRA_NS.svc
David Bainbridge76afd812020-04-06 09:53:52 -07002195 _PORT=9092
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002196 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"
2197 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 -07002198 ;;
2199 *)
David Bainbridged18f4942020-04-14 16:46:13 -07002200 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
2201 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07002202 _PORT=${_PORT:-9092}
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002203 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"
2204 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 -07002205 ;;
2206esac
2207
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002208if is_in "$WITH_ONOS" "legacy"; then
David Bainbridgec7220622020-05-28 12:31:47 -07002209 _HOST=onos-openflow.$INFRA_NS.svc
David Bainbridge76afd812020-04-06 09:53:52 -07002210 _PORT=6653
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002211elif is_in "$WITH_ONOS" "yes,classic"; then
David Bainbridgec7220622020-05-28 12:31:47 -07002212 _HOST=onos-onos-classic-hs.$INFRA_NS.svc
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002213 _PORT=6653
David Bainbridged18f4942020-04-14 16:46:13 -07002214elif [ "$WITH_ONOS" != "no" ]; then
2215 _HOST="$(echo "$WITH_ONOS" | cut -d: -f1)"
2216 _PORT="$(echo "$WITH_ONOS" | cut -s -d: -f2)"
David Bainbridge76afd812020-04-06 09:53:52 -07002217 _PORT=${_PORT:-6653}
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002218fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002219
David Bainbridgecf546362020-04-21 23:18:50 -07002220compare_versions "$RESOLVED_VOLTHA_CHART_VERSION" 2.4.2
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002221if [ "$?" == "1" ]; then
2222 # voltha chart > 2.4.2 uses list of controllers
David Bainbridgee4d11ca2020-05-08 10:21:10 -07002223 for NUM in $(seq 0 $((NUM_OF_ONOS-1))); do
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002224 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 +00002225 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 -07002226 done
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002227else
2228 # voltha chart <= 2.4.2 uses single controller
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002229 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.controller.service=$_HOST --set services.controller.port=$_PORT"
Neha Sharmaa1c92ca2020-06-24 11:50:33 +00002230 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.controller.address=$_HOST:$_PORT"
David Bainbridge696bc632020-04-05 21:49:37 -07002231fi
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002232
Girish Kumarcc5f9172020-06-10 13:34:31 +00002233if [ "$WITH_TRACING" == "yes" ]; then
2234 VOLTHA_TRACING_CHART_NAME=$(resolve_chart_name "$VOLTHA_TRACING_CHART")
2235 _HOST="tracing-${VOLTHA_TRACING_CHART_NAME}-jaeger-agent.$INFRA_NS.svc"
2236 _PORT=6831
2237 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set tracing.enabled=true --set services.tracing_agent.address=$_HOST:$_PORT"
2238fi
2239
Test Userb5712372019-07-03 21:52:17 +00002240bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002241if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$VOLTHA_NS" "^voltha\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002242 espin "$NOT_VERIFIED"
David Bainbridgea965ca22020-06-09 17:45:04 -07002243 helm_install - "$VOLTHA_NS" voltha "$VOLTHA_CHART" "$VOLTHA_CHART_VERSION" "+voltha" "$_HELM_DESC VOLTHA Core"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002244else
David Bainbridged18f4942020-04-14 16:46:13 -07002245 espin "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002246fi
David Bainbridge696bc632020-04-05 21:49:37 -07002247INTERNAL_EXTRA_HELM_INSTALL_ARGS=
Test Userba1e7e72019-07-10 22:27:54 +00002248
David Bainbridge90fd8e32019-08-21 23:32:47 +00002249VOLTHA="voltha-ofagent-.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002250 rw-core.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002251 voltha-zookeeper-.*"
David Bainbridged18f4942020-04-14 16:46:13 -07002252wait_for_pods - "$VOLTHA_NS" "$EXPECT" "includes" "Waiting for VOLTHA Core to start" "$NO_LABEL" "$VOLTHA"
David Bainbridgee87067b2019-08-12 22:00:12 +00002253if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002254 NOW="$(date +%s)"
2255 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002256fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002257
David Bainbridge46505fb2019-10-01 21:13:20 +00002258if [ "$WITH_ADAPTERS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002259 STIME="$(date +%s)"
David Bainbridge46505fb2019-10-01 21:13:20 +00002260 EXPECT=0
David Bainbridgec7220622020-05-28 12:31:47 -07002261 if is_in "$WITH_ETCD" "yes,external"; then
2262 _HOST=etcd.$INFRA_NS.svc
David Bainbridge3517f6c2020-04-08 12:14:08 -07002263 _PORT=2379
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002264 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
2265 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.address=$_HOST:$_PORT"
David Bainbridged18f4942020-04-14 16:46:13 -07002266 elif [ "$WITH_ETCD" != "no" ]; then
2267 _HOST="$(echo "$WITH_ETCD" | cut -d: -f1)"
2268 _PORT="$(echo "$WITH_ETCD" | cut -s -d: -f2)"
David Bainbridge3517f6c2020-04-08 12:14:08 -07002269 _PORT=${_PORT:-2379}
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002270 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
2271 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.address=$_HOST:$_PORT"
David Bainbridge696bc632020-04-05 21:49:37 -07002272 fi
David Bainbridgec7220622020-05-28 12:31:47 -07002273 if is_in "$WITH_KAFKA" "yes,external"; then
2274 _HOST=kafka.$INFRA_NS.svc
David Bainbridge3517f6c2020-04-08 12:14:08 -07002275 _PORT=9092
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002276 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"
2277 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 -07002278 elif [ "$WITH_KAFKA" != "no" ]; then
2279 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
2280 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge3517f6c2020-04-08 12:14:08 -07002281 _PORT=${_PORT:-9092}
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002282 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"
2283 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 -07002284 fi
Girish Kumarcc5f9172020-06-10 13:34:31 +00002285 if [ "$WITH_TRACING" == "yes" ]; then
2286 VOLTHA_TRACING_CHART_NAME=$(resolve_chart_name "$VOLTHA_TRACING_CHART")
2287 _HOST="tracing-${VOLTHA_TRACING_CHART_NAME}-jaeger-agent.$INFRA_NS.svc"
2288 _PORT=6831
2289 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set tracing.enabled=true --set services.tracing_agent.address=$_HOST:$_PORT"
2290 fi
David Bainbridge46505fb2019-10-01 21:13:20 +00002291 echo -e "Verify Adapters $PLUG"
2292 if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then
2293 bspin - "Verify Simulated Adapters installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002294 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$ADAPTER_NS" "^sim\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002295 espin - "$NOT_VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002296 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 +00002297 else
David Bainbridged18f4942020-04-14 16:46:13 -07002298 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00002299 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002300 EXPECT="$((EXPECT + 2))"
David Bainbridge46505fb2019-10-01 21:13:20 +00002301 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07002302
David Bainbridge46505fb2019-10-01 21:13:20 +00002303 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
2304 bspin - "Verify OpenOLT Adapter installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002305 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$ADAPTER_NS" "^open-olt\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002306 espin - "$NOT_VERIFIED"
David Bainbridgea965ca22020-06-09 17:45:04 -07002307 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 +00002308 else
David Bainbridged18f4942020-04-14 16:46:13 -07002309 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00002310 fi
Matteo Scandolo67335f02020-04-09 11:19:53 -07002311 EXPECT="$((EXPECT + 1))"
David Bainbridge46505fb2019-10-01 21:13:20 +00002312 bspin - "Verify OpenONU Adapter installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002313 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$ADAPTER_NS" "^open-onu\$")" -ne 1 ]; then
Matteo Scandolo67335f02020-04-09 11:19:53 -07002314 _ORIGINAL_EXTRA_HELM_INSTALL_ARGS="$INTERNAL_EXTRA_HELM_INSTALL_ARGS"
2315 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set replicas.adapter_open_onu=$NUM_OF_OPENONU"
Girish Gowdra4cc5d8b2020-06-11 17:12:00 -07002316 if [ "$WITH_INCREMENTAL_EVTO_UPDATE" == "yes" ]; then
Girish Gowdra1c7ad4c2020-06-26 13:35:16 -07002317 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set defaults.incremental_evto_update=true"
Girish Gowdra4cc5d8b2020-06-11 17:12:00 -07002318 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002319 espin - "$NOT_VERIFIED"
David Bainbridgea965ca22020-06-09 17:45:04 -07002320 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 -07002321 INTERNAL_EXTRA_HELM_INSTALL_ARGS="$_ORIGINAL_EXTRA_HELM_INSTALL_ARGS"
David Bainbridge46505fb2019-10-01 21:13:20 +00002322 else
David Bainbridged18f4942020-04-14 16:46:13 -07002323 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00002324 fi
Matteo Scandolo67335f02020-04-09 11:19:53 -07002325 EXPECT=$((EXPECT + NUM_OF_OPENONU))
David Bainbridge46505fb2019-10-01 21:13:20 +00002326 fi
David Bainbridge696bc632020-04-05 21:49:37 -07002327 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07002328
David Bainbridge46505fb2019-10-01 21:13:20 +00002329 ADAPTERS="adapter-.*"
David Bainbridged18f4942020-04-14 16:46:13 -07002330 wait_for_pods - "$ADAPTER_NS" "$EXPECT" "includes" "Waiting for adapters to start" "$NO_LABEL" "$ADAPTERS"
David Bainbridge46505fb2019-10-01 21:13:20 +00002331 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002332 NOW="$(date +%s)"
2333 printtime $((NOW - STIME))
David Bainbridge46505fb2019-10-01 21:13:20 +00002334 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00002335fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002336
David Bainbridged18f4942020-04-14 16:46:13 -07002337if [ "$WITH_BBSIM" == "yes" ]; then
2338 STIME="$(date +%s)"
Test User7d866122019-07-09 17:52:35 +00002339 echo -e "Verify BBSIM $PLUG"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002340 bspin - "Verify BBSIM Installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002341 for instance in $(seq 0 $((NUM_OF_BBSIM-1))); do
Matteo Scandoloc2eb0672020-05-01 14:43:15 -07002342
2343 if [ "$LEGACY_BBSIM_INDEX" == "yes" ]; then
2344 if [ "$instance" -eq 0 ]; then
2345 instance_num=""
2346 else
2347 instance_num=$instance
2348 fi
David K. Bainbridge43422402020-03-06 07:41:22 -08002349 else
2350 instance_num=$instance
2351 fi
Matteo Scandoloc2eb0672020-05-01 14:43:15 -07002352
2353
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002354 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$BBSIM_NS" "^bbsim${instance_num}\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002355 espin - "$NOT_VERIFIED"
2356 S_TAG="$((900+instance))"
Matteo Scandolo5a149572020-04-01 10:14:57 -07002357 INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set olt_id=$instance,s_tag=$S_TAG"
David Bainbridged9329af2020-05-01 11:58:52 -07002358 if [ "$WITH_EAPOL" == "yes" ]; then
2359 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set auth=true"
2360 else
2361 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set auth=false"
2362 fi
2363 if [ "$WITH_DHCP" == "yes" ]; then
2364 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set dhcp=true"
2365 else
2366 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set dhcp=false"
2367 fi
David Bainbridge33e56c72020-06-11 11:39:56 -07002368 if is_in "$WITH_KAFKA" "yes,external"; then
2369 _HOST=kafka.$INFRA_NS.svc
2370 _PORT=9092
2371 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafkaAddress=$_HOST:$_PORT"
2372 elif [ "$WITH_KAFKA" != "no" ]; then
2373 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
2374 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
2375 _PORT=${_PORT:-9092}
2376 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafkaAddress=$_HOST:$_PORT"
2377 fi
2378 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 -07002379 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
David K. Bainbridge43422402020-03-06 07:41:22 -08002380 else
David Bainbridged18f4942020-04-14 16:46:13 -07002381 espin - "$VERIFIED"
David K. Bainbridge43422402020-03-06 07:41:22 -08002382 fi
2383 done
David Bainbridged18f4942020-04-14 16:46:13 -07002384 wait_for_pods - "$BBSIM_NS" "$NUM_OF_BBSIM" "includes" "Waiting for BBSIM to start" "$BBSIM_LABEL" "bbsim*"
David Bainbridgee87067b2019-08-12 22:00:12 +00002385 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002386 NOW="$(date +%s)"
2387 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002388 fi
Test User7d866122019-07-09 17:52:35 +00002389fi
2390
divyadesai59f987a2020-05-27 12:11:33 +00002391if [ "$WITH_EFK" == "yes" ]; then
2392 STIME="$(date +%s)"
2393 echo -e "Verify EFK $PLUG"
2394 bspin - "Verify EFK Installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002395 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 +00002396 espin - "$NOT_VERIFIED"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002397 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^elasticsearch\$")" -ne 1 ]; then
divyadesai59f987a2020-05-27 12:11:33 +00002398 helm_install - "$INFRA_NS" elasticsearch "$ELASTICSEARCH_CHART" "$ELASTICSEARCH_CHART_VERSION" elasticsearch "$_HELM_DESC elasticsearch"
2399 fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002400 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^kibana\$")" -ne 1 ]; then
divyadesai59f987a2020-05-27 12:11:33 +00002401 helm_install - "$INFRA_NS" kibana "$KIBANA_CHART" "$KIBANA_CHART_VERSION" kibana "$_HELM_DESC kibana"
2402 fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002403 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^fluentd\$")" -ne 1 ]; then
divyadesai59f987a2020-05-27 12:11:33 +00002404 helm_install - "$INFRA_NS" fluentd "$FLUENTD_ELASTICSEARCH_CHART" "$FLUENTD_ELASTICSEARCH_CHART_VERSION" fluentd-elasticsearch "$_HELM_DESC fluentd-elasticsearch"
2405 fi
2406 else
2407 espin - "$VERIFIED"
2408 fi
2409 EXPECT=2 # for elastic and kibana
2410 if [ "$TYPE" == "minimal" ]; then
2411 EXPECT=$((EXPECT + 2)) # for fluentd on worker 2 worker nodes
2412 else
2413 EXPECT=$((EXPECT + 3)) # for fluentd on worker 3 worker nodes
2414 fi
2415 if [ "$SCHEDULE_ON_CONTROL_NODES" == "yes" ]; then
2416 EXPECT=$((EXPECT + 1)) # for fluentd on the control plan node
2417 fi
2418
2419 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for EFK to start" "$NO_LABEL" "fluentd-* elasticsearch-* kibana-*"
2420 if [ "$WITH_TIMINGS" == "yes" ]; then
2421 NOW="$(date +%s)"
2422 printtime $((NOW - STIME))
2423 fi
2424fi
2425
David Bainbridge309099c2020-05-05 08:47:29 -07002426if [ "$CONFIG_SADIS" == "external" ]; then
2427 STIME="$(date +%s)"
2428 echo -e "Verify BBSIM SADIS Service $PLUG"
2429 bspin - "Verify required configmap"
2430 (set -x; kubectl -n "$BBSIM_NS" delete --ignore-not-found configmap kube-config >>"$LOG" 2>&1) >>"$LOG" 2>&1
2431 (set -x; kubectl -n "$BBSIM_NS" create configmap kube-config "--from-file=kube_config=$KUBECONFIG" >>"$LOG" 2>&1) >>"$LOG" 2>&1
2432 espin - "$VERIFIED"
2433 bspin - "Verify BBSIM SADIS Service Installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002434 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$BBSIM_NS" "^bbsim-sadis-server\$")" -ne 1 ]; then
David Bainbridge309099c2020-05-05 08:47:29 -07002435 espin - "$NOT_VERIFIED"
Matteo Scandolo871fd982020-07-23 11:46:51 -07002436 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"
2437 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
David Bainbridge309099c2020-05-05 08:47:29 -07002438 else
2439 espin - "$VERIFIED"
2440 fi
2441 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 +00002442
Matteo Scandolo21660442020-07-17 11:05:21 -07002443 if is_in "$WITH_ONOS" "yes,classic,legacy"; then
Ubuntu7135e6a2020-06-30 01:46:08 +00002444 if kubectl get -n "$BBSIM_NS" svc/bbsim-sadis-server-bbsim-sadis-server >/dev/null 2>&1; then
2445 BBSIM_SADIS_SVC="bbsim-sadis-server-bbsim-sadis-server"
2446 else
2447 BBSIM_SADIS_SVC="bbsim-sadis-server"
2448 fi
2449 push_onos_config "json" \
2450 "[optional] Push ONOS configuration for custom SADIS and Bandwidth Profile servers" \
2451 "network/configuration/apps/org.opencord.sadis" \
2452 "$(cat <<EOJ | tr -d '[:space:]'
2453{
2454 "sadis": {
2455 "integration": {
2456 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:58080/subscribers/%s",
2457 "cache": {
2458 "enabled": true,
2459 "maxsize": 50,
2460 "ttl": "PT1m"
2461 }
2462 }
2463 },
2464 "bandwidthprofile": {
2465 "integration": {
2466 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:58080/profiles/%s",
2467 "cache": {
2468 "enabled": true,
2469 "maxsize": 50,
2470 "ttl": "PT1m"
2471 }
2472 }
2473 }
2474}
2475EOJ
2476)"
2477 fi
David Bainbridge309099c2020-05-05 08:47:29 -07002478 if [ "$WITH_TIMINGS" == "yes" ]; then
2479 NOW="$(date +%s)"
2480 printtime $((NOW - STIME))
2481 fi
2482fi
2483
David Bainbridged18f4942020-04-14 16:46:13 -07002484if [ "$WITH_RADIUS" == "yes" ]; then
2485 STIME="$(date +%s)"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002486 echo -e "Verify RADIUS $LOCK"
2487 bspin - "Verify RADIUS Installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002488 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^radius\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002489 espin - "$NOT_VERIFIED"
David Bainbridge879439b2020-06-12 15:59:35 -07002490 helm_install - "$INFRA_NS" radius "$RADIUS_CHART" "$RADIUS_CHART_VERSION" "+radius" "$_HELM_DESC RADIUS"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002491 else
David Bainbridged18f4942020-04-14 16:46:13 -07002492 espin - "$VERIFIED"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002493 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002494 wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for RADIUS to start" "$NO_LABEL" "radius-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00002495 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002496 NOW="$(date +%s)"
2497 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002498 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002499fi
2500
David Bainbridged18f4942020-04-14 16:46:13 -07002501if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
2502 STIME="$(date +%s)"
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002503 bspin - "Forward VOLTHA API port $FORWARD"
David Bainbridge1d2c5842020-06-03 15:29:07 -07002504 kill_port_forward voltha-api voltha-voltha-api
2505 VOLTHA_PREFIX=
2506 if kubectl get -n "$VOLTHA_NS" "svc/voltha-voltha-api" >/dev/null 2>&1; then
2507 VOLTHA_PREFIX="voltha-"
2508 fi
Matteo Scandolo21660442020-07-17 11:05:21 -07002509
David Bainbridge1d2c5842020-06-03 15:29:07 -07002510 port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-api" "$VOLTHA_API_PORT:55555"
David Bainbridged18f4942020-04-14 16:46:13 -07002511 espin - "$VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002512 if is_in "$WITH_ETCD" "yes,external"; then
David Bainbridge696bc632020-04-05 21:49:37 -07002513 bspin - "Forward VOLTHA ETCD port $FORWARD"
David Bainbridgec7220622020-05-28 12:31:47 -07002514 kill_port_forward "etcd"
2515 port_forward "$INFRA_NS" "etcd" "$VOLTHA_ETCD_PORT:2379"
David Bainbridged18f4942020-04-14 16:46:13 -07002516 espin - "$VERIFIED"
David Bainbridge696bc632020-04-05 21:49:37 -07002517 fi
David Bainbridgec7220622020-05-28 12:31:47 -07002518 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridge696bc632020-04-05 21:49:37 -07002519 bspin - "Forward VOLTHA Kafka port $FORWARD"
David Bainbridgec7220622020-05-28 12:31:47 -07002520 kill_port_forward "kafka"
2521 port_forward "$INFRA_NS" kafka "$VOLTHA_KAFKA_PORT:9092"
David Bainbridged18f4942020-04-14 16:46:13 -07002522 espin - "$VERIFIED"
David Bainbridge696bc632020-04-05 21:49:37 -07002523 fi
divyadesai59f987a2020-05-27 12:11:33 +00002524 if [ "$WITH_EFK" == "yes" ]; then
2525 bspin - "Forward EFK port $FORWARD"
2526 kill_port_forward elasticsearch-master
2527 kill_port_forward kibana-kibana
2528 port_forward "$INFRA_NS" elasticsearch-master "$ELASTICSEARCH_PORT:9200"
2529 port_forward "$INFRA_NS" kibana-kibana "$KIBANA_PORT:5601"
2530 espin - "$VERIFIED"
2531 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -07002532 if [ "$WITH_PPROF" == "yes" ]; then
David Bainbridge1d2c5842020-06-03 15:29:07 -07002533 VOLTHA_OPENOLT_PREFIX=
2534 if kubectl get -n "$ADAPTER_NS" "svc/open-olt-adapter-open-olt-profiler" >/dev/null 2>&1; then
2535 VOLTHA_OPENOLT_PREFIX="open-olt-"
2536 fi
David Bainbridge879439b2020-06-12 15:59:35 -07002537 bspin - "Forward PProf ports port $FORWARD"
2538 kill_port_forward voltha-rw-core-profiler voltha-voltha-rw-core-profiler
2539 kill_port_forward adapter-open-olt-profiler open-olt-adapter-open-olt-profiler
2540 kill_port_forward voltha-of-agent-profiler voltha-voltha-of-agent-profiler
2541 port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-rw-core-profiler" "$VOLTHA_PPROF_PORT:6060"
2542 port_forward "$ADAPTER_NS" "${VOLTHA_OPENOLT_PREFIX}adapter-open-olt-profiler" "$OPENOLT_PPROF_PORT:6060"
2543 port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-of-agent-profiler" "$OFAGENT_PPROF_PORT:6060"
2544 espin - "$VERIFIED"
Matteo Scandoloefee0432020-05-05 13:56:20 -07002545 fi
Girish Kumarcc5f9172020-06-10 13:34:31 +00002546 if [ "$WITH_TRACING" == "yes" ]; then
2547 bspin - "Forward VOLTHA Tracing GUI port $FORWARD"
2548 VOLTHA_TRACING_CHART_NAME=$(resolve_chart_name "$VOLTHA_TRACING_CHART")
2549 kill_port_forward "tracing-${VOLTHA_TRACING_CHART_NAME}-jaeger-gui"
2550 port_forward "$INFRA_NS" "tracing-${VOLTHA_TRACING_CHART_NAME}-jaeger-gui" "$TRACING_GUI_PORT:16686"
2551 espin - "$VERIFIED"
2552 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002553 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002554 NOW="$(date +%s)"
2555 printtime $((NOW - STIME))
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002556 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00002557fi
Test User3d7ad8e2019-07-03 06:15:44 +00002558
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002559if is_in "$WITH_ONOS" "yes,legacy,classic" && [ "$WITH_RADIUS" != "no" ]; then
David Bainbridge879439b2020-06-12 15:59:35 -07002560 SVC_NAME=radius
2561 if kubectl get -n "$INFRA_NS" "svc/radius-freeradius" >/dev/null 2>&1; then
2562 SVC_NAME="radius-freeradius"
2563 fi
2564 _HOST="$SVC_NAME.$INFRA_NS.svc"
David Bainbridge696bc632020-04-05 21:49:37 -07002565 _PORT=1812
David Bainbridged18f4942020-04-14 16:46:13 -07002566 if [ "$WITH_RADIUS" != "yes" ]; then
2567 _HOST="$(echo "$WITH_RADIUS" | cut -d: -f1)"
2568 _PORT="$(echo "$WITH_RADIUS" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07002569 _PORT=${_PORT:-1812}
2570 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002571 bspin "Configure ONOS RADIUS Connection $GEAR"
David Bainbridged18f4942020-04-14 16:46:13 -07002572 (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
2573 espin "$VERIFIED"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002574fi
2575
divyadesai59f987a2020-05-27 12:11:33 +00002576if [ "$WITH_EFK" == "yes" ]; then
2577 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"
2578# fi
2579fi
2580
David Bainbridge99ac7a22019-08-31 02:26:43 +00002581if [ "$WITH_CHAOS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002582 STIME="$(date +%s)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002583 echo -e "Verify kube-monkey $LOCK"
2584 bspin - "Verify kube-monkey Installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002585 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed kube-monkey "^monkey\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002586 espin - "$NOT_VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002587 helm_install - kube-monkey monkey ./kube-monkey/helm/kubemonkey latest - "$_HELM_DESC Chaos Monkey"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002588 else
David Bainbridged18f4942020-04-14 16:46:13 -07002589 espin - "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002590 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002591 wait_for_pods - "kube-monkey" 1 "includes" "Waiting for Chaos to start" "$NO_LABEL" "monkey-.*"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002592 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002593 NOW="$(date +%s)"
2594 printtime $((NOW - STIME))
David Bainbridge99ac7a22019-08-31 02:26:43 +00002595 fi
2596fi
2597
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002598bspin "Create voltctl configuration file"
David Bainbridged18f4942020-04-14 16:46:13 -07002599(set -x; mkdir -p "$HOME/.volt" >>"$LOG" 2>&1) >>"$LOG" 2>&1
2600MIN_VC_VERSION="$(echo -e "1.0.15\n$VC_VERSION" | sort -V | head -1)"
2601if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002602 KAFKA_FLAG="-k localhost:$VOLTHA_KAFKA_PORT"
2603 SERVER_FLAG="-s localhost:$VOLTHA_API_PORT"
2604 ETCD_FLAG=
2605 if [ "$MIN_VC_VERSION" == "1.0.15" ]; then
2606 ETCD_FLAG="-e localhost:$VOLTHA_ETCD_PORT"
2607 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002608else
David Bainbridgec7220622020-05-28 12:31:47 -07002609 KAFKA_FLAG="-k $(get_service_ep "$INFRA_NS" kafka)"
David Bainbridged18f4942020-04-14 16:46:13 -07002610 SERVER_FLAG="-s $(get_service_ep "$VOLTHA_NS" voltha-api)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002611 ETCD_FLAG=
2612 if [ "$MIN_VC_VERSION" == "1.0.15" ]; then
David Bainbridgec7220622020-05-28 12:31:47 -07002613 ETCD_FLAG="-e $(get_service_ep "$INFRA_NS" etcd)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002614 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002615fi
David Bainbridgea965ca22020-06-09 17:45:04 -07002616CMD=("voltctl $KAFKA_FLAG $SERVER_FLAG $ETCD_FLAG config")
David Bainbridged18f4942020-04-14 16:46:13 -07002617(set -x; ${CMD[*]} > "$HOME/.volt/config-$NAME" 2>>"$LOG") >>"$LOG" 2>&1
David Bainbridgea965ca22020-06-09 17:45:04 -07002618#(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 -07002619espin "$VERIFIED"
Test User08ebbd92019-07-03 17:15:39 +00002620
David Bainbridge0774b232019-08-02 06:37:19 +00002621if [ ! -f "$NAME-env.sh" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002622 touch "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002623fi
2624
David Bainbridge596f30d2019-07-30 17:07:59 +00002625for O in $ALL_OPTIONS; do
David Bainbridged18f4942020-04-14 16:46:13 -07002626 VAL="$(eval echo "\$$O")"
2627 if [ -n "$VAL" ] && [ "$(grep -c "^export $O=" "$NAME-env.sh")" -eq 0 ]; then
2628 echo "export $O=\"$(eval echo "\$$O")\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002629 fi
2630done
2631
David Bainbridged18f4942020-04-14 16:46:13 -07002632if [ "$DEPLOY_K8S" == "yes" ] && [ "$(grep -c "^export KUBECONFIG=" "$NAME-env.sh")" -eq 0 ]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002633 echo "export KUBECONFIG=\"$HOME/.kube/kind-config-voltha-$NAME\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002634fi
2635
David Bainbridged18f4942020-04-14 16:46:13 -07002636if [ "$(grep -c "^export VOLTCONFIG=" "$NAME-env.sh")" -eq 0 ]; then
2637 echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002638fi
2639
David Bainbridged18f4942020-04-14 16:46:13 -07002640if [ "$(grep -c "^export PATH=" "$NAME-env.sh")" -eq 0 ]; then
2641 echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002642fi
2643
Test User7d866122019-07-09 17:52:35 +00002644echo ""
David Bainbridged18f4942020-04-14 16:46:13 -07002645echo "Please issue the following commands in your terminal to ensure that you" | tee -a "$LOG"
2646echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a "$LOG"
2647echo "tools required by VOLTHA in your command path. " | tee -a "$LOG"
2648echo "" | tee -a "$LOG"
2649echo -en "$BOLD"
2650if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002651 echo "export KUBECONFIG=\"$HOME/.kube/kind-config-voltha-$NAME\"" | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00002652fi
David Bainbridged18f4942020-04-14 16:46:13 -07002653echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" | tee -a "$LOG"
2654echo "export PATH=$GOPATH/bin:\$PATH" | tee -a "$LOG"
2655echo -en "$NORMAL"
2656echo "" | tee -a "$LOG"
2657echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a "$LOG"
Test User08ebbd92019-07-03 17:15:39 +00002658
David Bainbridge712afb82019-08-14 19:55:58 +00002659if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002660 NOW="$(date +%s)"
2661 echo -e "$CLOCK ${BOLD}TOTAL: $(duration $((NOW - TOTAL_START_TIME)))${NORMAL}"
David Bainbridge712afb82019-08-14 19:55:58 +00002662fi