blob: ceb91545c6f170112c67acf4364da2ef95986fc1 [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}
Matteo Scandolo6402d362020-08-24 12:31:06 -070098BBSIM_CFG=${BBSIM_CFG:-configs/bbsim-sadis-att.yaml}
David Bainbridge27790d62019-08-13 22:43:19 +000099INSTALL_ONOS_APPS=${INSTALL_ONOS_APPS:-no}
Test Userba1e7e72019-07-10 22:27:54 +0000100JUST_K8S=${JUST_K8S:-no}
101DEPLOY_K8S=${DEPLOY_K8S:-yes}
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700102INSTALL_KUBECTL=${INSTALL_KUBECTL:-yes}
103INSTALL_HELM=${INSTALL_HELM:-yes}
David Bainbridge7f8bf992020-04-08 21:53:22 -0700104HELM_USE_UPGRADE=${HELM_USE_UPGRADE:-no}
David Bainbridge46505fb2019-10-01 21:13:20 +0000105UPDATE_HELM_REPOS=${UPDATE_HELM_REPOS:-yes}
Matteo Scandolofab98622020-01-28 15:17:20 -0800106WAIT_ON_DOWN=${WAIT_ON_DOWN:-yes}
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700107WAIT_TIMEOUT=${WAIT_TIMEOUT:-30m}
108VOLTHA_DOWN_ON_TIMEOUT=${VOLTHA_DOWN_ON_TIMEOUT:-no}
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000109VOLTHA_LOG_LEVEL=${VOLTHA_LOG_LEVEL:-WARN}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000110VOLTHA_CHART=${VOLTHA_CHART:-onf/voltha}
111VOLTHA_CHART_VERSION=${VOLTHA_CHART_VERSION:-latest}
112VOLTHA_BBSIM_CHART=${VOLTHA_BBSIM_CHART:-onf/bbsim}
Matteo Scandolo6402d362020-08-24 12:31:06 -0700113VOLTHA_BBSIM_CHART_VERSION=${VOLTHA_BBSIM_CHART_VERSION:-4.0.0-dev}
divyadesai59f987a2020-05-27 12:11:33 +0000114ELASTICSEARCH_CHART=${ELASTICSEARCH_CHART:-elastic/elasticsearch}
115ELASTICSEARCH_CHART_VERSION=${ELASTICSEARCH_CHART_VERSION:-latest}
116KIBANA_CHART=${KIBANA_CHART:-elastic/kibana}
117KIBANA_CHART_VERSION=${KIBANA_CHART_VERSION:-latest}
118FLUENTD_ELASTICSEARCH_CHART=${FLUENTD_ELASTICSEARCH_CHART:-kiwigrid/fluentd-elasticsearch}
119FLUENTD_ELASTICSEARCH_CHART_VERSION=${FLUENTD_ELASTICSEARCH_CHART_VERSION:-latest}
Girish Kumarcc5f9172020-06-10 13:34:31 +0000120VOLTHA_TRACING_CHART=${VOLTHA_TRACING_CHART:-onf/voltha-tracing}
121VOLTHA_TRACING_CHART_VERSION=${VOLTHA_TRACING_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000122VOLTHA_ADAPTER_SIM_CHART=${VOLTHA_ADAPTER_SIM_CHART:-onf/voltha-adapter-simulated}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000123VOLTHA_ADAPTER_SIM_CHART_VERSION=${VOLTHA_ADAPTER_SIM_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000124VOLTHA_ADAPTER_OPEN_OLT_CHART=${VOLTHA_ADAPTER_OPEN_OLT_CHART:-onf/voltha-adapter-openolt}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000125VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION=${VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000126VOLTHA_ADAPTER_OPEN_ONU_CHART=${VOLTHA_ADAPTER_OPEN_ONU_CHART:-onf/voltha-adapter-openonu}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000127VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION=${VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION:-latest}
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800128ONOS_CHART=${ONOS_CHART:-onf/onos}
Andrea Campanella21323292019-12-18 11:44:19 -0800129ONOS_CHART_VERSION=${ONOS_CHART_VERSION:-latest}
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700130ONOS_CLASSIC_CHART=${ONOS_CLASSIC_CHART:-onos/onos-classic}
Andrea Campanella26c8c992020-08-24 15:43:26 +0000131ONOS_CLASSIC_CHART_VERSION=${ONOS_CLASSIC_CHART_VERSION:-latest}
David Bainbridgecf546362020-04-21 23:18:50 -0700132KAFKA_CHART=${KAFKA_CHART:-incubator/kafka}
David Bainbridgeb4bbde12020-06-25 14:46:36 -0700133KAFKA_CHART_VERSION=${KAFKA_CHART_VERSION:=latest}
David Bainbridge309099c2020-05-05 08:47:29 -0700134BBSIM_SADIS_SERVER_CHART=${BBSIM_SADIS_SERVER_CHART:-bbsim-sadis/bbsim-sadis-server}
135BBSIM_SADIS_SERVER_CHART_VERSION=${BBSIM_SADIS_SERVER_CHART_VERSION:-latest}
David Bainbridgeb4bbde12020-06-25 14:46:36 -0700136ETCD_CHART=${ETCD_CHART:-etcd/etcd}
David Bainbridgec7220622020-05-28 12:31:47 -0700137ETCD_CHART_VERSION=${ETCD_CHART_VERSION:-latest}
David Bainbridge879439b2020-06-12 15:59:35 -0700138RADIUS_CHART=${RADIUS_CHART:-onf/freeradius}
139RADIUS_CHART_VERSION=${RADIUS_CHART_VERSION:-latest}
David Bainbridge2eaf2cf2020-03-18 12:54:08 -0700140EXTRA_HELM_INSTALL_ARGS=${EXTRA_HELM_INSTALL_ARGS:-}
141INTERNAL_EXTRA_HELM_INSTALL_ARGS=
uottrembb16d3982020-02-28 08:34:36 +0100142NUM_OF_BBSIM=${NUM_OF_BBSIM:-1}
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700143NUM_OF_WORKER_NODES=${NUM_OF_WORKER_NODES:-2}
144NUM_OF_CONTROLLER_NODES=${NUM_OF_CONTROLLER_NODES:-1}
Matteo Scandolo67335f02020-04-09 11:19:53 -0700145NUM_OF_OPENONU=${NUM_OF_OPENONU:-1}
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700146NUM_OF_KAFKA=${NUM_OF_KAFKA:-1}
147NUM_OF_ETCD=${NUM_OF_ETCD:-1}
uottrembb16d3982020-02-28 08:34:36 +0100148MAX_NUM_OF_BBSIM=10
Matteo Scandolo67335f02020-04-09 11:19:53 -0700149MAX_NUM_OF_OPENONU=10
Matteo Scandoloc2eb0672020-05-01 14:43:15 -0700150LEGACY_BBSIM_INDEX=${LEGACY_BBSIM_INDEX:-no}
David Bainbridgeb4bbde12020-06-25 14:46:36 -0700151PF_ADDRESS=${PF_ADDRESS:-0.0.0.0}
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700152KIND_CFG_FILE=${KIND_CFG_FILE:-}
Test Userba1e7e72019-07-10 22:27:54 +0000153
David Bainbridged18f4942020-04-14 16:46:13 -0700154HOSTOS="$(uname -s | tr "[:upper:]" "[:lower:"])"
155HOSTARCH="$(uname -m | tr "[:upper:]" "[:lower:"])"
156if [ "$HOSTARCH" == "x86_64" ]; then
Test Userba1e7e72019-07-10 22:27:54 +0000157 HOSTARCH="amd64"
158fi
David Bainbridge7db44002020-04-09 12:54:29 -0700159BBSIM_LABEL="-l app=bbsim"
David Bainbridged18f4942020-04-14 16:46:13 -0700160NO_LABEL=
Test User7d866122019-07-09 17:52:35 +0000161
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700162# checks to see if a given WORD is in the given LIST of words
163function is_in() {
164 local WORD LIST
165 WORD="$1"; shift
166 LIST="$*"
167 LIST=${LIST//+([[:space:],|])/:}
168
169 [ "$(echo ":$LIST:" | grep -ic ":$WORD:")" -ne 0 ]
170}
171
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700172function parseDuration() {
David Bainbridged18f4942020-04-14 16:46:13 -0700173 local DUR RESULT TERM TERMS VALUE UNIT
174 DUR=$1
175 RESULT=0
176 TERMS="$(echo "$DUR" | sed -Ee 's/([sSmMhHdD])/\1 /g' -e 's/,$//g')"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700177 for TERM in $TERMS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700178 VALUE="$(echo "$TERM" | sed -Ee 's/([0-9]+)[sSmMhHdD]/\1/')"
179 UNIT="$(echo "$TERM" | sed -Ee 's/[0-9]+([sSmMhHdD])/\1/')"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700180 case $UNIT in
181 s|S)
David Bainbridged18f4942020-04-14 16:46:13 -0700182 RESULT=$((RESULT + VALUE)) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700183 m|M)
David Bainbridged18f4942020-04-14 16:46:13 -0700184 RESULT=$((RESULT + (VALUE * 60))) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700185 h|H)
David Bainbridged18f4942020-04-14 16:46:13 -0700186 RESULT=$((RESULT + (VALUE * 3600))) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700187 d|D)
David Bainbridged18f4942020-04-14 16:46:13 -0700188 RESULT=$((RESULT + (VALUE * 86400))) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700189 *) ;;
190 esac
191 done
192 echo $RESULT
193}
194
195function doTimeout() {
196 local MSG=$1
197 2>&1 echo -e "\n${RED}${BOLD}${ERROR}TIMEOUT:${NORMAL}${RED} Operation timed out after '$WAIT_TIMEOUT': $MSG"
198 exit 125
199}
200
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800201function get_service_ep() {
202 local NS=$1
203 local NAME=$2
David Bainbridged18f4942020-04-14 16:46:13 -0700204 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 -0800205}
206
Matteo Scandolo6402d362020-08-24 12:31:06 -0700207# returns the greater version (0 if equal)
208function semvercompare() {
209 if [[ "$1" == "$2" ]]
210 then
211 echo 0
212 return
213 fi
214
215 local tmp1 tmp2
216 tmp1=$(echo "${1//v/}" | awk -F'-' '{print $1}')
217 tmp2=$(echo "${2//v/}" | awk -F'-' '{print $1}')
218
219 local IFS=.
220 # shellcheck disable=SC2206
221 local i ver1=($tmp1) ver2=($tmp2)
222
223 # fill empty fields in ver1 with zeros
224 for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
225 do
226 ver1[i]=0
227 done
228 for ((i=0; i<${#ver1[@]}; i++))
229 do
230 if [[ -z ${ver2[i]} ]]
231 then
232 # fill empty fields in ver2 with zeros
233 ver2[i]=0
234 fi
235 if ((10#${ver1[i]} > 10#${ver2[i]}))
236 then
237 echo 1
238 return
239 fi
240 if ((10#${ver1[i]} < 10#${ver2[i]}))
241 then
242 echo 2
243 return
244 fi
245 done
246 echo 0
247 return
248}
249
250# returns true if v1 is less than v2
251function semver_greater() {
252 local v1
253 local v2
254 v1=("$1") v2=("$2")
255
256 # shellcheck disable=SC2128
257 if [[ "$v1" == "latest" ]] || [[ "$v1" == "master" ]]; then
258 # if the version is latest or master we can't really compare,
259 # but we assume is greater
260 echo "true"
261 return
262 fi
263
264 # shellcheck disable=SC2128
265 res=$(semvercompare "$v1" "$v2")
266 if [[ $res == 1 ]]; then
267 echo "true"
268 else
269 echo "false"
270 fi
271}
272
273# returns true if v2 is less than v1
274function semver_lesser() {
275 local v1
276 local v2
277 v1=("$1") v2=("$2")
278
279 # shellcheck disable=SC2128
280 if [[ "$v1" == "latest" ]] || [[ "$v1" == "master" ]]; then
281 # if the version is latest or master we can't really compare,
282 # but we assume is greater
283 echo "false"
284 return
285 fi
286
287 # shellcheck disable=SC2128
288 res=$(semvercompare "$v1" "$v2")
289 if [[ $res == 2 ]]; then
290 echo "true"
291 else
292 echo "false"
293 fi
294}
295
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000296# Used to verify configuration values are set to "yes" or "no" value or convert
297# equivalents to "yes" or "no"
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700298YES="y,yes,t,true,1"
299NO="n,no,f,false,0"
300YES_OR_NO="$YES,$NO"
301
302# If the given VAR matches a truth value then normalize that
303# value, else return original value
304function normalize_yes_no() {
305 local VAR VAL
306 VAR=$1
307 VAL="$(eval echo "\$$VAR")"
308 if ! is_in "$VAL" "$YES_OR_NO"; then
309 echo "$VAL"
310 return 1
311 fi
312 if is_in "$VAL" "$YES"; then
313 echo "yes"
314 else
315 echo "no"
316 fi
317 return 0
318}
319
320# If the given VAR matches a truth value then normalize that
321# value, else display an error
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000322function verify_yes_no() {
David Bainbridged18f4942020-04-14 16:46:13 -0700323 local VAR VAL
324 VAR=$1
325 VAL="$(eval echo "\$$VAR")"
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700326 if ! is_in "$VAL" "$YES_OR_NO"; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000327 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid '$VAR' value of '$VAL'. Should be 'yes' or 'no'${NORMAL}"
328 echo "INVALID"
329 return 1
330 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700331 if is_in "$VAL" "$YES"; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000332 echo "yes"
333 else
334 echo "no"
335 fi
336 return 0
337}
Test User7d866122019-07-09 17:52:35 +0000338
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000339ALL_YES_NO="\
David K. Bainbridge484d80c2020-03-05 21:44:34 -0800340 ENABLE_ONOS_EXTRANEOUS_RULES \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000341 WITH_TIMINGS \
342 WITH_BBSIM \
divyadesai59f987a2020-05-27 12:11:33 +0000343 WITH_EFK \
Girish Kumarcc5f9172020-06-10 13:34:31 +0000344 WITH_TRACING \
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800345 WITH_EAPOL \
346 WITH_DHCP \
347 WITH_IGMP \
David Bainbridge99ac7a22019-08-31 02:26:43 +0000348 WITH_CHAOS \
David Bainbridge46505fb2019-10-01 21:13:20 +0000349 WITH_ADAPTERS \
350 WITH_SIM_ADAPTERS \
351 WITH_OPEN_ADAPTERS \
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800352 WITH_PORT_FORWARDS \
Matteo Scandoloefee0432020-05-05 13:56:20 -0700353 WITH_PPROF \
Girish Gowdra4cc5d8b2020-06-11 17:12:00 -0700354 WITH_INCREMENTAL_EVTO_UPDATE \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000355 JUST_K8S \
356 DEPLOY_K8S \
357 INSTALL_ONOS_APPS \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000358 INSTALL_KUBECTL \
359 INSTALL_HELM \
David Bainbridge7f8bf992020-04-08 21:53:22 -0700360 HELM_USE_UPGRADE \
David Bainbridge46505fb2019-10-01 21:13:20 +0000361 UPDATE_HELM_REPOS \
David Bainbridge4f1b5562019-08-19 04:46:52 +0000362 WAIT_ON_DOWN \
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700363 VOLTHA_DOWN_ON_TIMEOUT \
Matteo Scandoloc2eb0672020-05-01 14:43:15 -0700364 LEGACY_BBSIM_INDEX \
David Bainbridgee4d11ca2020-05-08 10:21:10 -0700365 SCHEDULE_ON_CONTROL_NODES \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000366 "
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000367
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700368OPT_YES_NO="\
369 CONFIG_SADIS \
370 WITH_KAFKA \
371 WITH_RADIUS \
372 WITH_ETCD \
373 WITH_ONOS \
374 "
375
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000376ALL_OPTIONS="\
377 NAME \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000378 $ALL_YES_NO \
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700379 $OPT_YES_NO \
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700380 WAIT_TIMEOUT \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000381 VOLTHA_LOG_LEVEL \
382 VOLTHA_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000383 VOLTHA_CHART_VERSION \
384 VOLTHA_BBSIM_CHART \
385 VOLTHA_BBSIM_CHART_VERSION \
David Bainbridge879439b2020-06-12 15:59:35 -0700386 BBSIM_SADIS_SERVER_CHART \
387 BBSIM_SADIS_SERVER_CHART_VERSION \
Girish Kumarcc5f9172020-06-10 13:34:31 +0000388 VOLTHA_TRACING_CHART \
389 VOLTHA_TRACING_CHART_VERSION \
uottrembd5a20572020-03-06 09:15:01 +0100390 NUM_OF_BBSIM \
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700391 NUM_OF_WORKER_NODES \
392 NUM_OF_CONTROLLER_NODES \
393 NUM_OF_KAFKA \
394 NUM_OF_ETCD \
divyadesai59f987a2020-05-27 12:11:33 +0000395 ELASTICSEARCH_CHART \
396 ELASTICSEARCH_CHART_VERSION \
397 KIBANA_CHART \
398 KIBANA_CHART_VERSION \
399 FLUENTD_ELASTICSEARCH_CHART \
400 FLUENTD_ELASTICSEARCH_CHART_VERSION \
Matteo Scandolo67335f02020-04-09 11:19:53 -0700401 NUM_OF_OPENONU \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000402 VOLTHA_ADAPTER_SIM_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000403 VOLTHA_ADAPTER_SIM_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000404 VOLTHA_ADAPTER_OPEN_OLT_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000405 VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000406 VOLTHA_ADAPTER_OPEN_ONU_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000407 VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION \
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800408 ONOS_CHART \
Andrea Campanella21323292019-12-18 11:44:19 -0800409 ONOS_CHART_VERSION \
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700410 ONOS_CLASSIC_CHART \
411 ONOS_CLASSIC_CHART_VERSION \
David Bainbridgecf546362020-04-21 23:18:50 -0700412 KAFKA_CHART \
David Bainbridgeb9093522020-04-15 14:32:44 -0700413 KAFKA_CHART_VERSION \
David Bainbridge879439b2020-06-12 15:59:35 -0700414 ETCD_CHART \
415 ETCD_CHART_VERSION \
416 RADIUS_CHART \
417 RADIUS_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000418 ONOS_API_PORT \
419 ONOS_SSH_PORT \
Hardik Windlassb3147602020-03-09 16:59:15 +0530420 SADIS_CFG \
Matteo Scandolo6402d362020-08-24 12:31:06 -0700421 BBSIM_CFG \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000422 VOLTHA_API_PORT \
423 VOLTHA_SSH_PORT \
424 VOLTHA_ETCD_PORT \
divyadesai59f987a2020-05-27 12:11:33 +0000425 ELASTICSEARCH_PORT \
426 KIBANA_PORT \
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800427 VOLTHA_KAFKA_PORT \
Matteo Scandoloefee0432020-05-05 13:56:20 -0700428 VOLTHA_PPROF_PORT \
429 OPENOLT_PPROF_PORT \
Matteo Scandolo65c35192020-05-13 10:41:21 -0700430 OFAGENT_PPROF_PORT \
Girish Kumarcc5f9172020-06-10 13:34:31 +0000431 TRACING_GUI_PORT \
David K. Bainbridge8f7f30b2020-01-08 13:06:16 -0800432 VK_RELEASE \
433 KIND_VERSION \
434 VOLTCTL_VERSION \
David Bainbridgea34993d2020-04-01 09:15:42 -0700435 HELM_VERSION \
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700436 NUM_OF_ONOS \
437 NUM_OF_ATOMIX \
David Bainbridge6ca40102020-04-08 11:30:40 -0700438 VOLTHA_NS \
439 ADAPTER_NS \
440 INFRA_NS \
441 BBSIM_NS \
David Bainbridge7db44002020-04-09 12:54:29 -0700442 SADIS_BANDWIDTH_PROFILES \
443 SADIS_SUBSCRIBERS \
David Bainbridgeb4bbde12020-06-25 14:46:36 -0700444 PF_ADDRESS \
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700445 KIND_CFG_FILE \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000446 "
David Bainbridge01294952019-07-30 19:33:45 +0000447
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000448# Iterate over yes/no configuration options and validate
449for VAR in $ALL_YES_NO; do
David Bainbridged18f4942020-04-14 16:46:13 -0700450 eval "$VAR"="$(verify_yes_no "$VAR")"
451 if [ "$(eval echo "\$$VAR")" == "INVALID" ]; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000452 exit 1;
453 fi
454done
David Bainbridgeb270c202019-07-26 01:44:42 +0000455
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700456# Iterate over optional yes/no configuration options and
457# normalize values if they are truth values
458for VAR in $OPT_YES_NO; do
459 eval "$VAR"="$(normalize_yes_no "$VAR")"
460done
David Bainbridge15f6f232020-03-30 09:15:43 -0700461
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700462# check number (range) of bbsim, max bbsim must not exceed 10 instances!
463# note: instances will be numbered from 0 to 9
464if [ "$1" == "up" ]; then
465 if [ "$NUM_OF_BBSIM" -lt 1 ]; then
466 >&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}"
467 exit 1
468 fi
469 if [ "$NUM_OF_BBSIM" -gt "$MAX_NUM_OF_BBSIM" ]; then
470 >&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}"
471 exit 1
472 fi
473
474 if [ "$NUM_OF_OPENONU" -lt 1 ]; then
475 >&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}"
476 exit 1
477 fi
478 if [ "$NUM_OF_OPENONU" -gt "$MAX_NUM_OF_OPENONU" ]; then
479 >&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}"
480 exit 1
481 fi
482
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700483 HAVE_CLUSTER="$(kind get clusters 2>/dev/null | grep -c "voltha-$NAME")"
484 if [ "$HAVE_CLUSTER" -eq 0 ]; then
485 # If the user has specified a kind cluster configuration file,
486 # 'KIND_CFG_FILE` then we need to gleem from that file the number
487 # of worker and controller nodes as this overrides any setting of
488 # these values
489 if [ -n "$KIND_CFG_FILE" ]; then
490 NUM_OF_WORKER_NODES="$(sed 's/ //g' "$KIND_CFG_FILE" | grep -c "^-role:worker$")"
491 NUM_OF_CONTROLLER_NODES="$(sed 's/ //g' "$KIND_CFG_FILE" | grep -c "^-role:control-plane$")"
492 fi
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700493
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700494 # check that NUM_OF_KAFKA, NUM_OF_ONOS, NUM_OF_ATOMIX, NUM_OF_ETCD is:
495 # <= NUM_OF_WORKER_NODES + 1 if SCHEDULE_ON_CONTROL_NODES == y
496 # <= NUM_OF_WORKER_NODES if SCHEDULE_ON_CONTROL_NODES == n
497 SCHEDULABLE_NODES=$NUM_OF_WORKER_NODES
498
499 if [ "$SCHEDULE_ON_CONTROL_NODES" == "yes" ]; then
500 SCHEDULABLE_NODES=$((NUM_OF_CONTROLLER_NODES+NUM_OF_WORKER_NODES))
501 fi
502 else
503 TOTAL_NODES=$(kubectl get --all-namespaces nodes -o name | wc -l)
504 NUM_OF_CONTROLLER_NODES=$(kubectl get --all-namespaces nodes -l node-role.kubernetes.io/master -o name | wc -l)
505 NUM_OF_WORKER_NODES=$((TOTAL_NODES - NUM_OF_CONTROLLER_NODES))
506 # shellcheck disable=SC2016
507 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')
508 rm -f "$TMP_KUBECFG"
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700509 fi
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700510 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"
511
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700512 if is_in "$WITH_KAFKA" "yes,external" && [ ! "$NUM_OF_KAFKA" -le "$SCHEDULABLE_NODES" ]; then
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700513 >&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}"
514 exit 1
515 fi
516
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700517 if is_in "$WITH_ETCD" "yes,external" && [ ! "$NUM_OF_ETCD" -le "$SCHEDULABLE_NODES" ]; then
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700518 >&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}"
519 exit 1
520 fi
521
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700522 if is_in "$WITH_ONOS" "yes,legacy,classic,micro"; then
523 if [ ! "$NUM_OF_ATOMIX" -le "$SCHEDULABLE_NODES" ]; then
524 >&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}"
525 exit 1
526 fi
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700527
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700528 if [ ! "$NUM_OF_ONOS" -le "$SCHEDULABLE_NODES" ]; then
529 >&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}"
530 exit 1
531 fi
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700532 fi
533fi
534
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700535# normalize non-truth value options
536if is_in "$WITH_KAFKA" "e,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -0700537 WITH_KAFKA="external"
538fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700539if is_in "$WITH_ETCD" "e,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -0700540 WITH_ETCD="external"
541fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700542if is_in "$WITH_ONOS" "l,legacy"; then
543 WITH_ONOS="legacy"
544elif is_in "$WITH_ONOS" "c,classic"; then
545 WITH_ONOS="classic"
546elif is_in "$WITH_ONOS" "u,m,micro"; then
547 WITH_ONOS="micro"
David Bainbridge29c31cb2020-04-06 09:45:50 -0700548fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700549
550if [ "$WITH_ONOS" == "micro" ]; then
551 >&2 echo -e "${YELLOW}${BOLD}${ERROR}WARNING:${NORMAL}${YELLOW} The value specified as WITH_ONOS, '$WITH_ONOS', is not valid.${NORMAL}"
552 exit 1
David Bainbridge29c31cb2020-04-06 09:45:50 -0700553fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700554
555if is_in "$WITH_ONOS" "yes,classic"; then
556 # there is an extra utility required if we are using ONOS CLASSIC as
557 # the chart for classic specifies images differently
558 EXTRA_TOOLS+=" yq"
David Bainbridge76afd812020-04-06 09:53:52 -0700559fi
David Bainbridge696bc632020-04-05 21:49:37 -0700560
David Bainbridge22db5dd2020-05-26 12:21:21 -0700561if [ "$LEGACY_BBSIM_INDEX" == "no" ]; then
562 BBSIM_SADIS_SVC="bbsim0"
563else
564 BBSIM_SADIS_SVC="bbsim"
565fi
566
567SADIS_SUBSCRIBERS=${SADIS_SUBSCRIBERS:-http://$BBSIM_SADIS_SVC.$VOLTHA_NS.svc:50074/v2/subscribers/%s}
568SADIS_BANDWIDTH_PROFILES=${SADIS_BANDWIDTH_PROFILES:-http://$BBSIM_SADIS_SVC.$VOLTHA_NS.svc:50074/v2/bandwidthprofiles/%s}
569
David Bainbridged18f4942020-04-14 16:46:13 -0700570if [ "$HELM_USE_UPGRADE" == "yes" ]; then
David Bainbridge7f8bf992020-04-08 21:53:22 -0700571 _HELM_DESC="Upgrade/Install"
572else
573 _HELM_DESC="Install"
574fi
575
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800576# Check for prerequiste tools
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700577TOOLS="curl sed jq $EXTRA_TOOLS"
David Bainbridged18f4942020-04-14 16:46:13 -0700578if [ "$DEPLOY_K8S" == "yes" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800579 TOOLS+=" docker"
580fi
581NOT_FOUND=""
582for T in $TOOLS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700583 if [ -z "$(command -v "$T")" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800584 NOT_FOUND+=" $T"
585 fi
586done
587
David Bainbridged18f4942020-04-14 16:46:13 -0700588if [ -n "$NOT_FOUND" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800589 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} The following required tools where not found, please install them:$NOT_FOUND"
590 exit 1
591fi
592
David Bainbridged18f4942020-04-14 16:46:13 -0700593TIMEOUT_SECONDS="$(parseDuration "$WAIT_TIMEOUT")"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700594
David Bainbridge0774b232019-08-02 06:37:19 +0000595mkdir -p .voltha
596touch .voltha/ports
David Bainbridged18f4942020-04-14 16:46:13 -0700597HAVE="$(grep "$NAME" .voltha/ports)"
David Bainbridge0774b232019-08-02 06:37:19 +0000598if [ "$HAVE X" == " X" ]; then
599 # Find free port prefix
600 START=81
601 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700602 if [ "$(grep -c $START .voltha/ports)" -eq 0 ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000603 break
604 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700605 START="$((START + 1))"
David Bainbridge0774b232019-08-02 06:37:19 +0000606 done
David Bainbridged18f4942020-04-14 16:46:13 -0700607 DELTA="$((START - 81))"
David Bainbridgea2595422019-10-22 03:54:28 +0000608 ONOS_API_PORT=${ONOS_API_PORT:-${START}81}
609 ONOS_SSH_PORT=${ONOS_SSH_PORT:-${START}01}
David Bainbridged18f4942020-04-14 16:46:13 -0700610 VOLTHA_API_PORT=${VOLTHA_API_PORT:-5$((55 + DELTA))55}
611 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$((50 + DELTA))22}
612 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$((23 + DELTA))79}
613 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$((90 + DELTA))92}
Matteo Scandoloefee0432020-05-05 13:56:20 -0700614 VOLTHA_PPROF_PORT=${VOLTHA_PPROF_PORT:-$((60 + DELTA))60}
615 OPENOLT_PPROF_PORT=${OPENOLT_PPROF_PORT:-$((60 + DELTA))61}
Matteo Scandolo65c35192020-05-13 10:41:21 -0700616 OFAGENT_PPROF_PORT=${OFAGENT_PPROF_PORT:-$((60 + DELTA))62}
divyadesai59f987a2020-05-27 12:11:33 +0000617 ELASTICSEARCH_PORT=${ELASTICSEARCH_PORT:-$((92 + DELTA))00}
618 KIBANA_PORT=${KIBANA_PORT:-$((56 + DELTA))01}
Girish Kumarcc5f9172020-06-10 13:34:31 +0000619 TRACING_GUI_PORT=${TRACING_GUI_PORT:-1$((66 + DELTA))86}
Test User01ed0642019-07-03 20:17:06 +0000620else
David Bainbridged18f4942020-04-14 16:46:13 -0700621 VALUES="$(echo "$HAVE" | sed -e 's/\s//g' | cut -d= -f2)"
622 ONOS_API_PORT=${ONOS_API_PORT:-$(echo "$VALUES" | cut -d, -f1)}
623 ONOS_SSH_PORT=${ONOS_SSH_PORT:-$(echo "$VALUES" | cut -d, -f2)}
624 VOLTHA_API_PORT=${VOLTHA_API_PORT:-$(echo "$VALUES" | cut -d, -f3)}
625 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$(echo "$VALUES" | cut -d, -f4)}
626 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$(echo "$VALUES" | cut -d, -f5)}
627 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(echo "$VALUES" | cut -d, -f6)}
Matteo Scandoloefee0432020-05-05 13:56:20 -0700628 VOLTHA_PPROF_PORT=${VOLTHA_PPROF_PORT:-$(echo "$VALUES" | cut -d, -f7)}
629 OPENOLT_PPROF_PORT=${OPENOLT_PPROF_PORT:-$(echo "$VALUES" | cut -d, -f8)}
Matteo Scandolo65c35192020-05-13 10:41:21 -0700630 OFAGENT_PPROF_PORT=${OFAGENT_PPROF_PORT:-$(echo "$VALUES" | cut -d, -f9)}
divyadesai59f987a2020-05-27 12:11:33 +0000631 ELASTICSEARCH_PORT=${ELASTICSEARCH_PORT:-$(echo "$VALUES" | cut -d, -f10)}
632 KIBANA_PORT=${KIBANA_PORT:-$(echo "$VALUES" | cut -d, -f11)}
Girish Kumarcc5f9172020-06-10 13:34:31 +0000633 TRACING_GUI_PORT=${TRACING_GUI_PORT:-$(echo "$VALUES" | cut -d, -f12)}
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800634
Matteo Scandoloefee0432020-05-05 13:56:20 -0700635 # Some ports were added after the .voltha/ports files was created.
636 # Calculate the original DELTA from the VOLTHA_SSH_PORT so that it can
637 # be used to set up newer port-forwards.
638 DELTA="$((VOLTHA_SSH_PORT/100-50))"
639
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800640 if [ -z "$VOLTHA_KAFKA_PORT" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -0700641 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$((90 + DELTA))92}
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800642 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -0700643
644 if [ -z "$VOLTHA_PPROF_PORT" ]; then
divyadesai59f987a2020-05-27 12:11:33 +0000645 VOLTHA_PPROF_PORT=${VOLTHA_PPROF_PORT:-$((60 + DELTA))60}
Matteo Scandoloefee0432020-05-05 13:56:20 -0700646 fi
647 if [ -z "$OPENOLT_PPROF_PORT" ]; then
divyadesai59f987a2020-05-27 12:11:33 +0000648 OPENOLT_PPROF_PORT=${OPENOLT_PPROF_PORT:-$((60 + DELTA))61}
Matteo Scandoloefee0432020-05-05 13:56:20 -0700649 fi
Matteo Scandolo65c35192020-05-13 10:41:21 -0700650 if [ -z "$OFAGENT_PPROF_PORT" ]; then
divyadesai59f987a2020-05-27 12:11:33 +0000651 OFAGENT_PPROF_PORT=${OFAGENT_PPROF_PORT:-$((60 + DELTA))62}
652 fi
653
654 if [ -z "$ELASTICSEARCH_PORT" ]; then
655 ELASTICSEARCH_PORT=${ELASTICSEARCH_PORT:-$((92 + DELTA))00}
656 fi
divyadesai59f987a2020-05-27 12:11:33 +0000657 if [ -z "$KIBANA_PORT" ]; then
658 KIBANA_PORT=${KIBANA_PORT:-$((56 + DELTA))01}
Matteo Scandolo65c35192020-05-13 10:41:21 -0700659 fi
Girish Kumarcc5f9172020-06-10 13:34:31 +0000660
661 if [ -z "$TRACING_GUI_PORT" ]; then
662 TRACING_GUI_PORT=${TRACING_GUI_PORT:-1$((66 + DELTA))86}
663 fi
Test User01ed0642019-07-03 20:17:06 +0000664fi
665
David Bainbridged18f4942020-04-14 16:46:13 -0700666PORTTMP="$(mktemp -u)"
667grep -v "$NAME" .voltha/ports > "$PORTTMP"
Girish Kumarcc5f9172020-06-10 13:34:31 +0000668echo "$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 -0700669cp "$PORTTMP" .voltha/ports
670rm -f "$PORTTMP"
David Bainbridge0774b232019-08-02 06:37:19 +0000671
David Bainbridge27790d62019-08-13 22:43:19 +0000672export ONOS_API_PORT ONOS_SSH_PORT
David Bainbridge01294952019-07-30 19:33:45 +0000673
Test Userd87942b2019-07-03 07:20:24 +0000674IDX=1
David Bainbridgee87067b2019-08-12 22:00:12 +0000675CLOCK="TIME:"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000676SPIN_PARTS=
677NOT_VERIFIED=
David Bainbridgef858a022019-08-14 21:25:11 +0000678THEX=
679BUILD=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000680VERIFIED=
681HELM=
682OLD_KEY=
683BIRD=
684HIGH_VOLTAGE=
685PLUG=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000686FORWARD=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000687GO=
688DOWNLOAD=
689GEAR=
690NO_ENTRY=
691LOCK=
692
David Bainbridged18f4942020-04-14 16:46:13 -0700693if [ "$FANCY" -eq 1 ]; then
694 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 +0000695 CLOCK="\xe2\x8f\xb1"
David Bainbridgef858a022019-08-14 21:25:11 +0000696 THEX="${RED}${BOLD}\xe2\x9c\x97\x20${NORMAL}"
David Bainbridgef858a022019-08-14 21:25:11 +0000697 BUILD="${YELLOW}${BOLD}\xf0\x9f\x8f\x97${NORMAL}"
698 NOT_VERIFIED="$BUILD"
699 VERIFIED="${GREEN}${BOLD}\xe2\x9c\x93\x20${NORMAL}"
700 HELM="${BLUE}${BOLD}\xE2\x8E\x88${NORMAL}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000701 OLD_KEY="\xF0\x9F\x97\x9D"
702 BIRD="\xF0\x9F\x90\xA6"
703 HIGH_VOLTAGE="\xE2\x9A\xA1"
704 PLUG="\xF0\x9F\xa7\xa9"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000705 FORWARD="\xE2\x87\xA8"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000706 GO="\xf0\x9f\x9a\x80"
707 DOWNLOAD="\xf0\x9f\x93\xa5"
708 GEAR="\xe2\x9a\x99"
709 NO_ENTRY="\xe2\x9b\x94"
710 LOCK="\xf0\x9f\x94\x92"
711fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700712
David Bainbridge712afb82019-08-14 19:55:58 +0000713duration() {
David Bainbridged18f4942020-04-14 16:46:13 -0700714 local h m s t
715 h="$(($1 / 3600))"
716 m="$(($1 % 3600 / 60))"
717 s="$(($1 % 60))"
718 t=""
David Bainbridgee87067b2019-08-12 22:00:12 +0000719
David Bainbridged18f4942020-04-14 16:46:13 -0700720 if [ "$h" -gt 0 ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +0000721 t="$t${h}h"
722 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700723 if [ "$m" -gt 0 ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +0000724 t="$t${m}m"
725 fi
David Bainbridge712afb82019-08-14 19:55:58 +0000726 echo "$t${s}s"
727}
728
729printtime() {
David Bainbridged18f4942020-04-14 16:46:13 -0700730 local INDENT
David Bainbridge712afb82019-08-14 19:55:58 +0000731 if [ "$1" == "-" ]; then
732 INDENT=" "
733 shift
734 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700735 echo -e "$INDENT $CLOCK $(duration "$1")"
David Bainbridgee87067b2019-08-12 22:00:12 +0000736}
737
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700738bspin() {
Test Userd87942b2019-07-03 07:20:24 +0000739 IDX=1
David Bainbridged18f4942020-04-14 16:46:13 -0700740 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700741 if [ "$1" == "-" ]; then
742 INDENT=" "
743 shift
744 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700745 if [ "$FANCY" -eq 0 ]; then
746 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000747 if [ "$LINE X" == " X" ]; then
748 return
749 fi
750 echo -e "$CIVIS$INDENT$*"
751 else
752 echo -en "$CIVIS$INDENT $*"
753 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700754}
755
756sspin() {
David Bainbridged18f4942020-04-14 16:46:13 -0700757 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700758 if [ "$1" == "-" ]; then
759 INDENT=" "
760 shift
761 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700762 if [ "$FANCY" -eq 0 ]; then
763 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000764 if [ "$LINE X" == " X" ]; then
765 return
766 fi
767 echo -e "$INDENT$*"
768 else
David Bainbridged18f4942020-04-14 16:46:13 -0700769 C="$(echo "$SPIN_PARTS" | cut '-d ' -f "$IDX")"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000770 echo -en "\r$INDENT$C $*"
David Bainbridged18f4942020-04-14 16:46:13 -0700771 IDX="$((IDX + 1))"
772 if [ "$IDX" -gt 8 ]; then
David Bainbridge38dc1e82019-08-12 15:18:45 +0000773 IDX=1
774 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700775 fi
776}
777
778espin() {
David Bainbridged18f4942020-04-14 16:46:13 -0700779 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700780 if [ "$1" == "-" ]; then
781 INDENT=" "
782 shift
783 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700784 if [ "$FANCY" -eq 0 ]; then
785 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000786 if [ "$LINE X" == " X" ]; then
787 return
788 fi
789 echo -e "$INDENT$*"
790 else
791 echo -e "\r$INDENT$*$CNORM"
792 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700793}
794
David Bainbridged18f4942020-04-14 16:46:13 -0700795if [ "$1" == "get" ] && [ "$2" == "voltconfig" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000796 echo "$HOME/.volt/config-$NAME"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000797 exit
798fi
799
David Bainbridgee4d11ca2020-05-08 10:21:10 -0700800if [ $# -ne 1 ] || ! is_in "$1" "up,down,dump,clean"; then
David Bainbridgeac7f8072019-08-01 22:15:33 +0000801 >&2 echo "What wouild you like to do today:"
802 >&2 echo " up - bring up voltha"
803 >&2 echo " down - tear down voltha"
804 >&2 echo " dump - create a debug dump of running system"
805 exit 1
806fi
807
divyadesai59f987a2020-05-27 12:11:33 +0000808do_curl() {
809 local DATA_ARGS CREDS CMD_ECHO CMD_OUTPUT SC_OUTPUT WAIT_START INDENTA EXTRAA NOW
810 local INDENT=$1
811 local OP=$2
812 local USER=$3
813 local PASS=$4
814 local URL=$5
815 local DATA_TYPE=$6
816 local DATA=$7
817 local MSG=$8
818 local VALID_RESULTS=$9
819 local EXTRA=${10}
820 local ICON=${11}
821
822 # Turn into an array for passing
823 INDENTA=()
824 if [ -n "$INDENT" ]; then
825 INDENTA=("$INDENT")
826 fi
827 IFS=' ' read -r -a EXTRAA <<< "$EXTRA"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000828
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800829 # Thanks to the latest version of ONOS using the return code 207 this gets a
830 # whole lot nastier. Can't thank them enough for doing this. So in order to
831 # capture the command and the output in the log file as well as capture the
832 # status code to verify it is 200 and not 207 mutltiple files and a bit of
833 # hackery must be used. Thanks again ONOS.
David Bainbridged18f4942020-04-14 16:46:13 -0700834 CMD_ECHO="$(mktemp -u)"
835 CMD_OUTPUT="$(mktemp -u)"
836 SC_OUTPUT="$(mktemp -u)"
837 WAIT_START="$(date +%s)"
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800838
divyadesai59f987a2020-05-27 12:11:33 +0000839 CREDS=()
840 if [ -n "$USER" ]; then
841 CREDS=("--user" "$USER:$PASS")
842 fi
843
844 DATA_ARGS=()
845 if [ -n "$DATA" ]; then
846 if [ "$DATA_TYPE" == "file" ]; then
847 DATA_ARGS=("--data" "@$DATA")
848 elif [ "$DATA_TYPE" == "json" ]; then
849 DATA_ARGS=("--data" "$DATA")
850 fi
851 fi
852
853 bspin "${INDENTA[@]}" "$MSG" "$ICON"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000854 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700855 NOW="$(date +%s)"
856 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
divyadesai59f987a2020-05-27 12:11:33 +0000857 espin "${INDENTA[@]}" "$THEX"
David Bainbridged18f4942020-04-14 16:46:13 -0700858 rm -f "$CMD_ECHO" "$CMD_OUTPUT" "$SC_OUTPUT"
divyadesai59f987a2020-05-27 12:11:33 +0000859 doTimeout "$MSG"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700860 fi
divyadesai59f987a2020-05-27 12:11:33 +0000861 (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
862 RESULT=$?
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800863 # Dump everything to the log
David Bainbridged18f4942020-04-14 16:46:13 -0700864 cat "$CMD_ECHO" >> "$LOG"
865 test -r "$CMD_OUTPUT" && cat "$CMD_OUTPUT" >> "$LOG"
866 SC="$(cat "$SC_OUTPUT")"
867 echo "RESPONSE CODE: $SC" >> "$LOG"
868 echo "ERROR CODE: $RESULT" >> "$LOG"
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800869
870 # clean up temp files
David Bainbridged18f4942020-04-14 16:46:13 -0700871 rm -f "$CMD_ECHO" "$CMD_OUTPUT" "$SC_OUTPUT"
divyadesai59f987a2020-05-27 12:11:33 +0000872 if [ "$RESULT" -eq 0 ] && is_in "$SC" "$VALID_RESULTS"; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000873 break
874 fi
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800875 sleep 1
divyadesai59f987a2020-05-27 12:11:33 +0000876 sspin "${INDENTA[@]}"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000877 done
divyadesai59f987a2020-05-27 12:11:33 +0000878 espin "${INDENTA[@]}" "$VERIFIED"
879}
880
881push_onos_config() {
882 local DATA_TYPE=$1
883 local MSG=$2
884 local RESOURCE=$3
885 local DATA=$4
886
887 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 +0000888}
889
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800890check_onos_app_active() {
David Bainbridged18f4942020-04-14 16:46:13 -0700891 local APP_ID WAIT_START RESULT NOW
892 APP_ID=$1
893 WAIT_START="$(date +%s)"
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800894
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700895 bspin - "Checking that $APP_ID is active $CLOCK"
896 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700897 NOW="$(date +%s)"
898 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700899 espin - "$THEX"
900 doTimeout "waiting for ONOS application activation '$APP_ID'"
901 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700902 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 -0700903 break
904 fi
905 sleep 1
906 sspin -
907 done
908 sleep 5 # OSGI components take a little longer that the app to activate
David Bainbridged18f4942020-04-14 16:46:13 -0700909 espin - "$VERIFIED"
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800910}
911
David Bainbridge4f1b5562019-08-19 04:46:52 +0000912override_onos_app() {
David Bainbridged18f4942020-04-14 16:46:13 -0700913 local APP NAME WAIT_START NOW
914 APP=$1
915 NAME="$(basename "$APP" | sed -e 's/^[0-9][0-9]*-//g' -e 's/-.*$//g')"
916 WAIT_START="$(date +%s)"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700917
David Bainbridge4f1b5562019-08-19 04:46:52 +0000918 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700919 NOW="$(date +%s)"
920 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700921 espin - "$THEX"
922 doTimeout "waiting to overwrite ONOS application '$APP'"
923 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +0000924 sspin -
925 # Attempt to delete old version (if it exists)
David Bainbridged18f4942020-04-14 16:46:13 -0700926 (set -x; curl --fail -sSL --user karaf:karaf -X DELETE "http://$_ONOS_API_EP/onos/v1/applications/$NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
927 RESULT=$?
David Bainbridge4f1b5562019-08-19 04:46:52 +0000928 sspin -
David Bainbridged18f4942020-04-14 16:46:13 -0700929 if [ $RESULT -ne 0 ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000930 continue
931 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700932 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 +0000933 break
934 fi
935 sleep .2
936 done
937}
938
939activate_onos_app() {
David Bainbridged18f4942020-04-14 16:46:13 -0700940 local MSG APP WAIT_START NOW
941 MSG="$1"
942 APP=$2
943 WAIT_START="$(date +%s)"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000944
945 bspin - "$MSG $GO"
946 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700947 NOW="$(date +%s)"
948 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700949 espin - "$THEX"
950 doTimeout "waiting to activate ONOS application '$APP'"
951 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +0000952 sspin -
David Bainbridged18f4942020-04-14 16:46:13 -0700953 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 +0000954 break
955 fi
956 sleep .2
957 done
958 espin - "$VERIFIED"
959}
960
961count_pods() {
David Bainbridged18f4942020-04-14 16:46:13 -0700962 local NAMESPACE STATES LABELS CMD PODS
963 NAMESPACE=$1; shift
David Bainbridge4f1b5562019-08-19 04:46:52 +0000964 if [ "$NAMESPACE" == "all-namespaces" ]; then
965 NAMESPACE="--all-namespaces"
966 else
967 NAMESPACE="-n $NAMESPACE"
968 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700969 STATES=$1; shift
970 LABELS=$1; shift
971 CMD=("kubectl get $NAMESPACE $LABELS pod")
972 PODS=$(${CMD[*]} -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}")
David Bainbridge4f1b5562019-08-19 04:46:52 +0000973 local COUNT=0
974 local PATTERNS="$*"
975 for POD in $PODS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700976 local NAME STATE CONTAINERS TOTAL FOUND
977 NAME="$(echo "$POD" | cut -d/ -f 1)"
978 STATE="$(echo "$POD" | cut -d/ -f 2)"
979 CONTAINERS="$(echo "$POD" | cut -d/ -f 3 | sed -e 's/_/ /g')"
980 if [ "$STATES" == "*" ] || [ "$(echo "$STATES" | grep -c ":$STATE:")" -ne 0 ]; then
981 TOTAL="$(echo "$CONTAINERS" | wc -w)"
982 FOUND="$(echo "$CONTAINERS" | grep -o true | wc -l)"
983 if [ "$TOTAL" -eq "$FOUND" ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000984 for PATTERN in $PATTERNS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700985 if [[ "$NAME" =~ $PATTERN ]]; then
986 COUNT="$((COUNT + 1))"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000987 break
988 fi
989 done
990 fi
991 fi
992 done
David Bainbridge4f1b5562019-08-19 04:46:52 +0000993 echo $COUNT
994}
995
996wait_for_pods() {
David Bainbridged18f4942020-04-14 16:46:13 -0700997 local INDENT NAMESPACE EXPECT TYPE MESSAGE LABELS PATTERNS STATES HAVE ALL WAIT_START NOW
David Bainbridge4f1b5562019-08-19 04:46:52 +0000998 if [ "$1" == "-" ]; then
999 INDENT=$1; shift
1000 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001001 NAMESPACE=$1; shift
1002 EXPECT=$1; shift
1003 TYPE=$1; shift
1004 MESSAGE=$1; shift
1005 LABELS=$1; shift
1006 PATTERNS=("$*")
1007 STATES=":Running:"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001008 if [ "$TYPE" == "not" ]; then
1009 STATES="*"
1010 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001011 HAVE="$(count_pods "$NAMESPACE" "$STATES" "$LABELS" "${PATTERNS[@]}")"
1012 ALL=$HAVE
David Bainbridge4f1b5562019-08-19 04:46:52 +00001013 if [ "$TYPE" == "only" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001014 ALL="$(count_pods "all-namespaces" "*" ".*")"
David Bainbridge4f1b5562019-08-19 04:46:52 +00001015 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001016 COUNT="$((300 / 15))"
1017 WAIT_START="$(date +%s)"
1018 bspin "$INDENT" "$MESSAGE"
1019 sspin "$INDENT"
1020 if [ "$HAVE" -ne "$EXPECT" ] || [ "$ALL" -ne "$HAVE" ]; then
1021 while [ "$HAVE" -ne "$EXPECT" ] || [ "$ALL" -ne "$HAVE" ]; do
1022 NOW="$(date +%s)"
1023 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
1024 espin "$INDENT" "$THEX"
David Bainbridge52e6e9d2020-03-23 13:48:27 -07001025 doTimeout "waiting for PODs to start"
1026 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001027 sspin "$INDENT"
1028 COUNT="$((COUNT - 1))"
1029 if [ "$COUNT" -eq 0 ]; then
1030 HAVE="$(count_pods "$NAMESPACE" "$STATES" "$LABELS" "${PATTERNS[@]}")"
1031 ALL="$HAVE"
David Bainbridge4f1b5562019-08-19 04:46:52 +00001032 if [ "$TYPE" == "only" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001033 ALL="$(count_pods "all-namespaces" "*" ".*")"
David Bainbridge4f1b5562019-08-19 04:46:52 +00001034 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001035 COUNT="$((300 / 15))"
David Bainbridge4f1b5562019-08-19 04:46:52 +00001036 fi
1037 sleep .15
1038 done
1039 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001040 espin "$INDENT" "$VERIFIED"
1041 if [ "$HAVE" -ne "$EXPECT" ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +00001042 return 1
1043 fi
1044 return 0
1045}
1046
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001047port_forward() {
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001048 local NS=$1; shift
1049 local SVC=$1; shift
1050 local PORTS="$*"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001051 local TAG=$SVC-$NAME
1052
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001053 (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 -08001054}
1055
1056kill_port_forward() {
David Bainbridge1d2c5842020-06-03 15:29:07 -07001057 local TAG P_IDS PARENTS KIDS UNKNOWN PP_ID PF
1058
1059 while [ $# -gt 0 ]; do
1060 PF=$1; shift
1061 TAG=
1062 if [ "$PF" != "__ALL__" ]; then
1063 TAG="$PF-$NAME"
1064 fi
1065 PARENTS=
1066 KIDS=
1067 UNKNOWN=
1068 # shellcheck disable=SC2009
1069 P_IDS="$(ps e -ww -A | grep "_TAG=$TAG" | grep -v grep | awk '{print $1}')"
1070 if [ -n "$P_IDS" ]; then
1071 for P_ID in $P_IDS; do
1072 PP_ID="$(ps -o ppid "$P_ID" | tail -n +2)"
1073 if [ -n "$PP_ID" ]; then
1074 if [ "$PP_ID" -eq 1 ]; then
1075 PARENTS="$PARENTS $P_ID"
1076 else
1077 KIDS="$KIDS $P_ID"
1078 fi
David Bainbridgec6871d22019-11-13 17:10:31 +00001079 else
David Bainbridge1d2c5842020-06-03 15:29:07 -07001080 UNKNOWN="$UNKNOWN $P_ID"
David Bainbridgec6871d22019-11-13 17:10:31 +00001081 fi
David Bainbridge1d2c5842020-06-03 15:29:07 -07001082 done
1083 if [ -n "$PARENTS" ]; then
1084 # shellcheck disable=SC2086
1085 while ps -h $PARENTS >/dev/null 2>&1; do
1086 (set -x; eval "kill -9 $PARENTS" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1087 done
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001088 fi
David Bainbridge1d2c5842020-06-03 15:29:07 -07001089 if [ -n "$KIDS" ]; then
1090 # shellcheck disable=SC2086
1091 while ps -h $KIDS >/dev/null 2>&1; do
1092 (set -x; eval "kill -9 $KIDS" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1093 done
1094 fi
1095 if [ -n "$UNKNOWN" ]; then
1096 # shellcheck disable=SC2086
1097 while ps -h $UNKNOWN >/dev/null 2>&1; do
1098 (set -x; eval "kill -9 $UNKNOWN" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1099 done
1100 fi
1101 fi
1102 done
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001103}
1104
Girish Kumarcc5f9172020-06-10 13:34:31 +00001105resolve_chart_name() {
1106 helm inspect chart "$1" | grep "^name:" | awk '{print $2}'
1107}
1108
David Bainbridgecf546362020-04-21 23:18:50 -07001109resolve_chart_version() {
1110 [ "$2" != "latest" ] && echo "$2" && return
1111 helm inspect chart "$1" | grep "^version:" | awk '{print $2}'
1112}
1113
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07001114# Compares two semver-formatted version strings (e.g. 2.4.3)
1115# Returns 0 if $1 == $2, returns 1 if $1 > $2 and returns 2 if $1 < $2
1116compare_versions() {
1117 [ "$1" == "$2" ] && return 0
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07001118 local lowest
1119 lowest=$(echo -e "$1\n$2" | sort -V | head -1)
1120 [ "$lowest" == "$1" ] && return 2
1121 return 1
1122}
1123
David Bainbridgeac7f8072019-08-01 22:15:33 +00001124if [ "$1" == "down" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001125 echo "Tearing down voltha cluster $NAME"
1126 LOG="down-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -07001127 date -u +"%Y%m%dT%H%M%SZ" >"$LOG"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001128 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 -07001129 if is_in "$WITH_ONOS" "yes,legacy,classic"; then
David Bainbridge696bc632020-04-05 21:49:37 -07001130 bspin "Remove port-forwards: onos-ui-$NAME"
1131 kill_port_forward onos-ui
1132 sspin "Remove port-forwards: onos-ssh-$NAME$CEOL"
1133 kill_port_forward onos-ssh
David K. Bainbridge2aa08da2020-07-31 12:49:45 -07001134 sspin "Remove port-forwards: onos-onos-classic-hs-$NAME$CEOL"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001135 kill_port_forward onos-onos-classic-hs
David Bainbridge696bc632020-04-05 21:49:37 -07001136 fi
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001137 sspin "Remove port-forwards: voltha-api-$NAME$CEOL"
David Bainbridge1d2c5842020-06-03 15:29:07 -07001138 kill_port_forward voltha-api voltha-voltha-api
David Bainbridgec7220622020-05-28 12:31:47 -07001139 if is_in "$WITH_ETCD" "yes,external"; then
1140 sspin "Remove port-forwards: etcd-$NAME$CEOL"
1141 kill_port_forward "etcd"
David Bainbridge696bc632020-04-05 21:49:37 -07001142 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001143 if is_in "$WITH_KAFKA" "yes,external"; then
1144 sspin "Remove port-forwards: kafka-$NAME$CEOL"
1145 kill_port_forward "kafka"
David Bainbridge696bc632020-04-05 21:49:37 -07001146 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -07001147
1148 if [ "$WITH_PPROF" == "yes" ]; then
David Bainbridgec7220622020-05-28 12:31:47 -07001149 sspin "Remove port-forwards: *-profiler$CEOL"
David Bainbridge1d2c5842020-06-03 15:29:07 -07001150 kill_port_forward voltha-rw-core-profiler voltha-voltha-rw-core-profiler
1151 kill_port_forward voltha-of-agent-profiler voltha-voltha-of-agent-profiler
David Bainbridgec7220622020-05-28 12:31:47 -07001152 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
David Bainbridge1d2c5842020-06-03 15:29:07 -07001153 kill_port_forward adapter-open-olt-profiler open-olt-adapter-open-olt-profiler
David Bainbridgec7220622020-05-28 12:31:47 -07001154 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -07001155 fi
1156
Girish Kumarcc5f9172020-06-10 13:34:31 +00001157 if [ "$WITH_TRACING" == "yes" ]; then
1158 sspin "Remove port-forwards: tracing-$NAME$CEOL"
1159 VOLTHA_TRACING_CHART_NAME=$(resolve_chart_name "$VOLTHA_TRACING_CHART")
1160 kill_port_forward "tracing-${VOLTHA_TRACING_CHART_NAME}-jaeger-gui"
1161 fi
1162
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001163 espin "$VERIFIED Remove port-forwards$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -07001164 if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridgeac7f8072019-08-01 22:15:33 +00001165 if [ -x ./bin/kind ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001166 bspin "Delete Kubernetes Kind Cluster"
David Bainbridged18f4942020-04-14 16:46:13 -07001167 (set -x; ./bin/kind delete cluster --name "voltha-$NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1168 espin "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001169 else
David Bainbridge0774b232019-08-02 06:37:19 +00001170 espin "$NO_ENTRY Delete Kubernetes Kind Cluster: kind command not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001171 fi
1172 else
David Bainbridge309099c2020-05-05 08:47:29 -07001173 if [ "$CONFIG_SADIS" == "external" ]; then
1174 bspin "Remove configmap for BBSIM SADIS server"
1175 (set -x; kubectl -n "$BBSIM_NS" delete --ignore-not-found configmap kube-config >>"$LOG" 2>&1) >>"$LOG" 2>&1
1176 espin "$VERIFIED"
1177 fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001178
1179 if [ "$HELM_MAJOR" -le 2 ]; then
1180 EXISTS=$(helm list --output json 2>/dev/null | jq -r '.Releases | .[] | .Name + "," + .Namespace')
1181 else
1182 EXISTS=$(helm list --all-namespaces --output json 2>/dev/null | jq -r '.[] | .name + "," + .namespace')
1183 fi
David Bainbridge76afd812020-04-06 09:53:52 -07001184 EXPECT="voltha"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001185 if is_in "$WITH_ONOS" "yes,legacy,classic"; then
David Bainbridge696bc632020-04-05 21:49:37 -07001186 EXPECT+=" onos"
1187 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001188 if [ "$WITH_RADIUS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001189 EXPECT+=" radius"
1190 fi
David Bainbridge309099c2020-05-05 08:47:29 -07001191 if [ "$CONFIG_SADIS" == "external" ]; then
1192 EXPECT+=" bbsim-sadis-server"
1193 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001194 if [ "$WITH_BBSIM" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001195 EXPECT+=" bbsim"
1196 fi
divyadesai59f987a2020-05-27 12:11:33 +00001197 if [ "$WITH_EFK" == "yes" ]; then
1198 EXPECT+=" elasticsearch kibana fluentd"
1199 fi
Girish Kumarcc5f9172020-06-10 13:34:31 +00001200 if [ "$WITH_TRACING" == "yes" ]; then
1201 EXPECT+=" tracing"
1202 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001203 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001204 EXPECT+=" open-olt open-onu"
1205 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001206 if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001207 EXPECT+=" sim"
1208 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001209 if is_in "$WITH_ETCD" "yes,external"; then
1210 EXPECT+=" etcd"
David Bainbridge76afd812020-04-06 09:53:52 -07001211 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001212 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -07001213 EXPECT+=" kafka"
1214 fi
David Bainbridge0774b232019-08-02 06:37:19 +00001215 bspin "Remove Helm Deployments"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001216 for i in $EXISTS; do
David K. Bainbridge43422402020-03-06 07:41:22 -08001217 for j in $EXPECT; do
David Bainbridged18f4942020-04-14 16:46:13 -07001218 if [[ "$i" =~ $j ]]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001219 __NAME=$(echo "$i" | cut -d, -f1)
1220 __NS=$(echo "$i" | cut -d, -f2)
1221 sspin "Remove Helm Deployments: $__NS:$__NAME$CEOL"
1222 if [ "$HELM_MAJOR" -le 2 ]; then
1223 (set -x; helm delete --no-hooks --purge "$__NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1224 else
1225 (set -x; helm uninstall --no-hooks --namespace "$__NS" "$__NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1226 fi
David K. Bainbridge43422402020-03-06 07:41:22 -08001227 fi
1228 done
uottrembb16d3982020-02-28 08:34:36 +01001229 done
David Bainbridge0774b232019-08-02 06:37:19 +00001230 espin "$VERIFIED Remove Helm Deployments$CEOL"
David Bainbridge4f1b5562019-08-19 04:46:52 +00001231 if [ "$WAIT_ON_DOWN" == "yes" ]; then
Matteo Scandoloe93c9eb2020-06-03 12:08:51 -07001232 PODS="voltha-ofagent.* voltha-rw-core.*"
David Bainbridge76afd812020-04-06 09:53:52 -07001233 INFRA_PODS=
1234 ADAPT_PODS=
1235 SIM_PODS=
divyadesai59f987a2020-05-27 12:11:33 +00001236 EFK_PODS=
David Bainbridged18f4942020-04-14 16:46:13 -07001237 if [ "$WITH_RADIUS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001238 PODS+=" radius.*"
1239 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001240 if [ "$WITH_BBSIM" == "yes" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -07001241 SIM_PODS+=" bbsim.*"
David Bainbridge696bc632020-04-05 21:49:37 -07001242 fi
divyadesai59f987a2020-05-27 12:11:33 +00001243 if [ "$WITH_EFK" == "yes" ]; then
1244 EFK_PODS+=" kibana-* elasticsearch-* fluentd-*"
1245 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001246 if [ "$WITH_OPEN_ADAPTERS" ] || [ "$WITH_SIM_ADAPTERS" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -07001247 ADAPT_PODS+=" adapter-*"
David Bainbridge696bc632020-04-05 21:49:37 -07001248 fi
Girish Kumarcc5f9172020-06-10 13:34:31 +00001249 if [ "$WITH_TRACING" == "yes" ]; then
1250 INFRA_PODS+=" jaeger.*"
1251 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001252 if is_in "$WITH_ONOS" "yes,legacy,classic"; then
David Bainbridge76afd812020-04-06 09:53:52 -07001253 INFRA_PODS+=" onos-.*"
1254 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001255 if is_in "$WITH_ETCD" "yes,external"; then
1256 INFRA_PODS+=" etcd.*"
David Bainbridge76afd812020-04-06 09:53:52 -07001257 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001258 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -07001259 INFRA_PODS+=" kafka.*"
1260 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001261 if [ -n "$SIM_PODS" ]; then
1262 wait_for_pods "$BBSIM_NS" 0 "not" "Waiting for BBSIM PODs to terminate" "$BBSIM_LABEL" "$SIM_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -07001263 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001264 if [ -n "$INFRA_PODS" ]; then
1265 wait_for_pods "$INFRA_NS" 0 "not" "Waiting for infrastructure PODs to terminate" "$NO_LABEL" "$INFRA_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -07001266 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001267 if [ -n "$ADAPT_PODS" ]; then
1268 wait_for_pods "$ADAPTER_NS" 0 "not" "Waiting for adapter PODs to terminate" "$NO_LABEL" "$ADAPT_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -07001269 fi
divyadesai59f987a2020-05-27 12:11:33 +00001270 if [ -n "$EFK_PODS" ]; then
1271 wait_for_pods "$INFRA_NS" 0 "not" "Waiting for EFK PODs to terminate" "$NO_LABEL" "$EFK_PODS"
1272 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001273 wait_for_pods "$VOLTHA_NS" 0 "not" "Waiting for VOLTHA PODs to terminate" "$NO_LABEL" "$PODS"
David Bainbridge4f1b5562019-08-19 04:46:52 +00001274 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +00001275 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001276 exit
David Bainbridgeac7f8072019-08-01 22:15:33 +00001277fi
1278
1279if [ "$1" == "dump" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001280 LOG="dump-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -07001281 TS="$(date -u +"%Y%m%dT%H%M%SZ")"
1282 if [ -n "$DUMP_FROM" ]; then
1283 TS=${DUMP_FROM//[:-]}
David Bainbridge76514a02019-10-08 01:50:35 +00001284 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001285 WORK="$(mktemp -u -d)"
David Bainbridge0774b232019-08-02 06:37:19 +00001286 DATA=$WORK/voltha-debug-dump-$NAME-$TS
David Bainbridged18f4942020-04-14 16:46:13 -07001287 mkdir -p "$DATA"
1288 echo "$TS" > "$LOG"
David Bainbridge0774b232019-08-02 06:37:19 +00001289 echo -e "Capturing debug dump to voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001290 bspin - "Copy install log"
David Bainbridged18f4942020-04-14 16:46:13 -07001291 if [ -f "install-$NAME.log" ]; then
1292 (set -x; cp "install-$NAME.log" "$DATA/install-$NAME.log") >>"$LOG" 2>&1
1293 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001294 else
David Bainbridge0774b232019-08-02 06:37:19 +00001295 espin - "$NO_ENTRY Copy install log: install-$NAME.log not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001296 fi
1297 bspin - "Dumping Kubernetes PODs"
David Bainbridged18f4942020-04-14 16:46:13 -07001298 (set -x; kubectl get --all-namespaces pods >> "$DATA/all-pods.txt" 2>&1) >>"$LOG" 2>&1
1299 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001300 bspin - "Dumping Kubernetes SERVICEs"
David Bainbridged18f4942020-04-14 16:46:13 -07001301 (set -x; kubectl get --all-namespaces svc >> "$DATA/all-services.txt" 2>&1) >>"$LOG" 2>&1
1302 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001303 bspin - "Dumping Kubernetes EVENTs"
David Bainbridged18f4942020-04-14 16:46:13 -07001304 (set -x; kubectl get --all-namespaces events >> "$DATA/all-events.txt" 2>&1) >>"$LOG" 2>&1
1305 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001306 bspin - "Dumping VOLTHA POD details"
David Bainbridged18f4942020-04-14 16:46:13 -07001307 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 +00001308 SINCE=
David Bainbridged18f4942020-04-14 16:46:13 -07001309 if [ -n "$DUMP_FROM" ]; then
David Bainbridgecfd7ca12019-10-06 03:31:41 +00001310 SINCE="--since-time=$DUMP_FROM"
1311 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +00001312 for POD in $PODS; do
David Bainbridged18f4942020-04-14 16:46:13 -07001313 NS="$(echo "$POD" | cut -d: -f1)"
1314 POD="$(echo "$POD" | cut -d: -f2)"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001315 sspin - "Dumping VOLTHA POD details: $POD$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -07001316 mkdir -p "$DATA/$POD"
1317 (set -x; kubectl describe -n "$NS" "$POD" >> "$DATA/$POD/describe.txt" 2>&1) >>"$LOG" 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +00001318 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridged18f4942020-04-14 16:46:13 -07001319 (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 +00001320 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridged18f4942020-04-14 16:46:13 -07001321 (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 +00001322 sspin - "Dumping VOLTHA POD details: $POD"
1323 done
1324 espin - "$VERIFIED Dumping VOLTHA POD details$CEOL"
1325 bspin - "Dumping ETCD"
David Bainbridged18f4942020-04-14 16:46:13 -07001326 if [ -n "$(command -v etcdctl)" ]; then
1327 (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
1328 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001329 else
1330 espin - "$NO_ENTRY Dumping ETCD: etcdctl command not available"
1331 fi
David Bainbridge0774b232019-08-02 06:37:19 +00001332 bspin - "Creating compressed TAR: voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridged18f4942020-04-14 16:46:13 -07001333 (set -x; tar -C "$WORK" -zcf "voltha-debug-dump-$NAME-$TS.tgz" "./voltha-debug-dump-$NAME-$TS") >>"$LOG" 2>&1
1334 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001335 bspin - "Cleanup"
David Bainbridged18f4942020-04-14 16:46:13 -07001336 (set -x; rm -rf "$WORK") >>"$LOG" 2>&1
1337 espin - "$VERIFIED"
1338 bspin - "$(ls -l "voltha-debug-dump-$NAME-$TS.tgz")"
1339 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001340 exit
1341fi
1342
David Bainbridge0774b232019-08-02 06:37:19 +00001343LOG="install-$NAME.log"
David Bainbridge1d2c5842020-06-03 15:29:07 -07001344PFLOG="port-forward-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -07001345date > "$LOG"
Girish Kumarcc5f9172020-06-10 13:34:31 +00001346echo "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 +00001347
1348# Output install options to log
David Bainbridged18f4942020-04-14 16:46:13 -07001349echo "OPTIONS" >> "$LOG"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001350for O in $ALL_OPTIONS; do
David Bainbridged18f4942020-04-14 16:46:13 -07001351 VAL="$(eval echo "\$$O")"
1352 if [ -n "$VAL" ]; then
1353 printf " %-30s = %s\n" "$O" "$VAL" >> "$LOG"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001354 fi
1355done
1356
David Bainbridgee4d11ca2020-05-08 10:21:10 -07001357# Force remove any existing k8s port-forward processes. This will
1358# remove them for all kind clusters.
David Bainbridgee4d11ca2020-05-08 10:21:10 -07001359if [ "$1" == "clean" ]; then
1360 kill_port_forward __ALL__
1361 exit
1362fi
1363
David Bainbridgefad50732020-05-01 17:00:12 -07001364helm_values() {
1365 local NAMESPACE=$1; shift
1366 local INAME=$1; shift
1367 local CHART=$1; shift
1368 local CHART_VERSION=$1; shift
1369
1370 if [ "$CHART_VERSION X" != " X" ] && [ "$CHART_VERSION" != "latest" ]; then
1371 CHART_VERSION="--version $CHART_VERSION"
1372 else
1373 CHART_VERSION=
1374 fi
1375
1376 local CHART_ARGS=
1377 if [ -r "${INAME}-values.yaml" ]; then
1378 CHART_ARGS="-f ${INAME}-values.yaml"
1379 fi
1380
1381 if [ "$HELM_USE_UPGRADE" == "yes" ]; then
1382 _HELM_COMMAND="upgrade --install"
1383 _HELM_ARGS="xxxdryrunxxx"
1384 else
1385 _HELM_COMMAND="install"
Matteo Scandolof2d080b2020-07-23 13:59:29 -07001386 if [ "$HELM_MAJOR" -le 2 ]; then
1387 _HELM_NAME_ARG="--name xxxdryrunxxx"
1388 _HELM_ARGS=
1389 else
1390 _HELM_NAME_ARG="xxxdryrunxxx"
1391 _HELM_ARGS="--create-namespace"
1392 fi
David Bainbridgefad50732020-05-01 17:00:12 -07001393 fi
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001394 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 -07001395 ${CMD[*]} 2>/dev/null | awk 'PRINT==1 {print}; /^USER-SUPPLIED VALUES:/ {PRINT = 1}; /^$/ {PRINT = 0}'
1396}
1397
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001398helm_is_deployed() {
1399 local NAMESPACE=$1; shift
1400 local NAME=$1; shift
1401
1402 if [ "$HELM_MAJOR" -le 2 ]; then
1403 helm list --deployed --short --namespace "$NAMESPACE" "$NAME" 2>/dev/null | wc -l
1404 else
1405 helm list --deployed --short --namespace "$NAMESPACE" --filter "$NAME" 2>/dev/null | wc -l
1406 fi
1407}
1408
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001409helm_install() {
David Bainbridgec7220622020-05-28 12:31:47 -07001410 local INDENT NOW VALUES_FILE PPROF_ARG
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001411 if [ "$1" == "-" ]; then
1412 INDENT=$1; shift
1413 fi
1414 local NAMESPACE=$1; shift
David Bainbridge0774b232019-08-02 06:37:19 +00001415 local INAME=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001416 local CHART=$1; shift
David Bainbridge90fd8e32019-08-21 23:32:47 +00001417 local CHART_VERSION=$1; shift
David Bainbridgec7220622020-05-28 12:31:47 -07001418 local FILTER=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001419 local MESSAGE=$*
1420
David Bainbridged18f4942020-04-14 16:46:13 -07001421 if [ "$CHART_VERSION X" != " X" ] && [ "$CHART_VERSION" != "latest" ]; then
David Bainbridge90fd8e32019-08-21 23:32:47 +00001422 CHART_VERSION="--version $CHART_VERSION"
1423 else
1424 CHART_VERSION=
1425 fi
1426
David Bainbridge99ac7a22019-08-31 02:26:43 +00001427 local CHART_ARGS=
1428 if [ -r "${INAME}-values.yaml" ]; then
1429 CHART_ARGS="-f ${INAME}-values.yaml"
1430 fi
1431
David Bainbridged18f4942020-04-14 16:46:13 -07001432 local WAIT_START CMD
1433 WAIT_START="$(date +%s)"
1434 COUNT="$((300 / 15))"
1435 bspin "$INDENT" "$MESSAGE"
1436 if [ "$HELM_USE_UPGRADE" == "yes" ]; then
David Bainbridge7f8bf992020-04-08 21:53:22 -07001437 _HELM_COMMAND="upgrade --install"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001438 _HELM_NAME_ARG="$INAME"
David Bainbridge7f8bf992020-04-08 21:53:22 -07001439 else
1440 _HELM_COMMAND="install"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001441 if [ "$HELM_MAJOR" -le 2 ]; then
1442 _HELM_NAME_ARG="--name $INAME"
1443 _HELM_ARGS=
1444 else
1445 _HELM_NAME_ARG="$INAME"
1446 _HELM_ARGS="--create-namespace"
1447 fi
David Bainbridge7f8bf992020-04-08 21:53:22 -07001448 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001449
1450 VALUES_FILE="$(mktemp)"
1451 if [ "$FILTER" == "-" ]; then
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001452 cp "values.yaml" "$VALUES_FILE"
David Bainbridgea965ca22020-06-09 17:45:04 -07001453 elif [ "${FILTER:0:1}" == "+" ]; then
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001454 cp "values.yaml" "$VALUES_FILE"
1455 yq r - "${FILTER:1}" <"values.yaml" >>"$VALUES_FILE"
David Bainbridge33e56c72020-06-11 11:39:56 -07001456 cat "$VALUES_FILE" >>"$LOG"
David Bainbridgec7220622020-05-28 12:31:47 -07001457 else
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001458 yq r - "$FILTER" <"values.yaml" >"$VALUES_FILE"
David Bainbridgec7220622020-05-28 12:31:47 -07001459 fi
1460 if [ "$WITH_PPROF" == "yes" ]; then
1461 PPROF_ARG="--set profiler.enabled=true"
1462 fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001463 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 -07001464 (set -x; ${CMD[*]} >>"$LOG" 2>&1) >>"$LOG" 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001465 SUCCESS=$?
David Bainbridged18f4942020-04-14 16:46:13 -07001466 while [ "$SUCCESS" -ne 0 ]; do
1467 NOW="$(date +%s)"
1468 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -07001469 espin "$THEX"
David Bainbridgec7220622020-05-28 12:31:47 -07001470 rm -f "$VALUES_FILE"
David Bainbridge52e6e9d2020-03-23 13:48:27 -07001471 doTimeout "waiting for helm install $CHART"
1472 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001473 sspin "$INDENT"
1474 COUNT="$((COUNT - 1))"
1475 if [ "$COUNT" -eq 0 ]; then
1476 if [ "$HELM_USE_UPGRADE" == "no" ]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001477 if [ "$HELM_MAJOR" -le 2 ]; then
1478 (set -x; helm delete --purge "$INAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1479 else
1480 (set -x; helm uninstall "$INAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1481 fi
David Bainbridge7f8bf992020-04-08 21:53:22 -07001482 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001483 (set -x; ${CMD[*]} >>"$LOG" 2>&1) >>"$LOG" 2>&1
Andy Baviere22ff252019-12-19 11:40:31 -07001484 SUCCESS=$?
David Bainbridged18f4942020-04-14 16:46:13 -07001485 COUNT="$((300 / 15))"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001486 fi
1487 sleep .15
1488 done
David Bainbridgec7220622020-05-28 12:31:47 -07001489 rm -f "$VALUES_FILE"
David Bainbridged18f4942020-04-14 16:46:13 -07001490 espin "$INDENT" "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001491}
1492
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001493echo "INSTALL NAME: $NAME" >> "$LOG"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001494
David Bainbridged18f4942020-04-14 16:46:13 -07001495STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001496if [ "$INSTALL_KUBECTL" == "no" ]; then
1497 bspin "Skip kubectl install"
1498 espin $NO_ENTRY
Test Userc13bdc92019-07-03 20:57:49 +00001499else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001500 bspin "Verify kubectl $HELM"
David Bainbridged18f4942020-04-14 16:46:13 -07001501 if [ -x "$GOPATH/bin/kubectl" ]; then
1502 espin "$VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001503 else
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001504 ERR_OUT="$(mktemp)"
David Bainbridged18f4942020-04-14 16:46:13 -07001505 espin "$NOT_VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001506 bspin - "Download and install Kubernetes/kubectl $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001507 (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
1508 RESULT=$?
1509 if [ "$RESULT" -ne 0 ]; then
1510 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001511 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download kubectl: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001512 cat "$ERR_OUT" >> "$LOG"
Zack Williamsded60cb2020-04-13 10:02:20 -07001513 rm -rf "$ERR_OUT" "$GOPATH/bin/kubectl"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001514 exit 1
1515 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001516 (set -x; chmod 755 "$GOPATH/bin/kubectl" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1517 espin - "$VERIFIED"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001518 rm -rf "$ERR_OUT"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001519 fi
Test Userc13bdc92019-07-03 20:57:49 +00001520fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001521if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001522 NOW="$(date +%s)"
1523 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001524fi
Test Userc13bdc92019-07-03 20:57:49 +00001525
David Bainbridged18f4942020-04-14 16:46:13 -07001526STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001527if [ "$DEPLOY_K8S" == "no" ]; then
1528 bspin "Skip Kubernetes/Kind Deployment"
1529 espin $NO_ENTRY
1530else
Test Userba1e7e72019-07-10 22:27:54 +00001531 bspin "Verify Kubernetes/Kind $HELM"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001532 IS_INSTALLED=0
1533 OP_TYPE="install"
David Bainbridged18f4942020-04-14 16:46:13 -07001534 if [ -x "$GOPATH/bin/kind" ]; then
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001535 OP_TYPE="upgrade"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001536 if [ "$("$GOPATH/bin/kind" version | grep -c "$KIND_VERSION")" -eq 1 ]; then
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001537 IS_INSTALLED=1
David Bainbridged18f4942020-04-14 16:46:13 -07001538 espin "$VERIFIED"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001539 fi
1540 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001541 if [ "$IS_INSTALLED" -eq 0 ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001542 ERR_OUT="$(mktemp)"
David Bainbridged18f4942020-04-14 16:46:13 -07001543 espin "$NOT_VERIFIED"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001544 bspin - "Download and $OP_TYPE Kubernetes/kind $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001545 (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
1546 RESULT=$?
1547 if [ $RESULT -ne 0 ]; then
1548 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001549 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download kind: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001550 cat "$ERR_OUT" >> "$LOG"
Zack Williamsded60cb2020-04-13 10:02:20 -07001551 rm -rf "$ERR_OUT" "$GOPATH/bin/kind"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001552 exit 1
1553 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001554 (set -x; chmod 755 "$GOPATH/bin/kind" >>"$LOG" 2>&1) >>"$LOG" 2>&1
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001555 rm -rf "$ERR_OUT"
David Bainbridged18f4942020-04-14 16:46:13 -07001556 espin - "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001557 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001558fi
1559
David Bainbridgee87067b2019-08-12 22:00:12 +00001560if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001561 NOW="$(date +%s)"
1562 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001563fi
1564
David Bainbridged18f4942020-04-14 16:46:13 -07001565STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001566if [ "$INSTALL_HELM" == "no" ]; then
1567 bspin "Skip Helm Install"
1568 espin $NO_ENTRY
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001569else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001570 bspin "Verify Helm $HELM"
David Bainbridgea34993d2020-04-01 09:15:42 -07001571 HELM_UPGRADE=0
1572 HELM_UPGRADE_DESC="install"
David Bainbridged18f4942020-04-14 16:46:13 -07001573 if [ -x "$GOPATH/bin/helm" ]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001574 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 -07001575 HELM_UP_DOWN="$(echo -e "$HAVE_VER\n$HELM_VERSION" | sort -V | head -1)"
1576 if [ "$HAVE_VER" != "$HELM_VERSION" ]; then
1577 if [ "$HELM_UP_DOWN" == "$HELM_VERSION" ]; then
David Bainbridgea34993d2020-04-01 09:15:42 -07001578 HELM_UPGRADE_DESC="downgrade"
1579 else
1580 HELM_UPGRADE_DESC="upgrade"
1581 fi
1582 HELM_UPGRADE=1
1583 else
David Bainbridged18f4942020-04-14 16:46:13 -07001584 espin "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001585 fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001586 else
David Bainbridgea34993d2020-04-01 09:15:42 -07001587 HELM_UPGRADE=1
1588 fi
1589
David Bainbridged18f4942020-04-14 16:46:13 -07001590 if [ "$HELM_UPGRADE" -ne 0 ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001591 ERR_OUT="$(mktemp)"
1592 INSTALL_HELM_BIN=$(mktemp)
David Bainbridged18f4942020-04-14 16:46:13 -07001593 espin "$NOT_VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001594 bspin - "Download and $HELM_UPGRADE_DESC Helm $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001595 (set -x; curl -o "$INSTALL_HELM_BIN" --fail -sSL https://git.io/get_helm.sh >>"$LOG" 2>"$ERR_OUT") >>"$LOG" 2>&1
1596 RESULT=$?
1597 if [ $RESULT -ne 0 ]; then
1598 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001599 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download helm installer: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001600 cat "$ERR_OUT" >> "$LOG"
1601 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT" "$GOPATH/bin/helm" "$GOPATH/bin/tiller"
1602 exit 1
1603 fi
1604 rm -rf "$ERR_OUT"
1605 chmod +x "$INSTALL_HELM_BIN"
1606 (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
1607 RESULT=$?
1608 if [ $RESULT -ne 0 ]; then
1609 espin - "$THEX"
1610 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to install helm, see install log for details${NORMAL}"
1611 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT" "$GOPATH/bin/helm" "$GOPATH/bin/tiller"
1612 exit 1
1613 fi
1614 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT"
David Bainbridged18f4942020-04-14 16:46:13 -07001615 espin - "$VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001616 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001617fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001618if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001619 NOW="$(date +%s)"
1620 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001621fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001622HELM_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 -07001623
David Bainbridged18f4942020-04-14 16:46:13 -07001624STIME="$(date +%s)"
Test Userb5712372019-07-03 21:52:17 +00001625bspin "Verify voltctl $HIGH_VOLTAGE"
David Bainbridged2811972019-12-14 01:14:09 +00001626VOK=0
1627VMESSAGE="install"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001628ERR_OUT=$(mktemp)
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001629export VC_VERSION="$VOLTCTL_VERSION"
1630if [ "$VC_VERSION" == "latest" ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001631 set -o pipefail # TODO: would be nice to run all in pipefail mode
1632 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')"
1633 RESULT=$?
1634 set +o pipefail
1635 if [ "$RESULT" -ne 0 ]; then
1636 espin - "$THEX"
1637 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to determine released version of voltctl: $(cat "$ERR_OUT")${NORMAL}"
1638 rm -rf "$ERR_OUT" "$GOPATH/bin/voltctl"
1639 exit 1
1640 fi
1641 export VC_VERSION
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001642fi
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001643
David Bainbridged18f4942020-04-14 16:46:13 -07001644if [ -x "$GOPATH/bin/voltctl" ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001645 VHAVE="$("$GOPATH/bin/voltctl" version --clientonly -o json 2>/dev/null | jq -r .version)"
David Bainbridged18f4942020-04-14 16:46:13 -07001646 RESULT=$?
1647 if [ $RESULT -eq 0 ] && [ "$VHAVE" == "$VC_VERSION" ]; then
David Bainbridged2811972019-12-14 01:14:09 +00001648 VOK=1
David Bainbridged18f4942020-04-14 16:46:13 -07001649 espin "$VERIFIED"
David Bainbridge1ba64f12019-12-18 00:40:13 +00001650 else
David Bainbridged18f4942020-04-14 16:46:13 -07001651 VCHECK="$(echo -e "$VHAVE\n$VC_VERSION" | sort -V | head -1)"
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001652 if [ "$VCHECK" == "$VHAVE" ]; then
1653 VMESSAGE="upgrade"
1654 else
1655 VMESSAGE="downgrade"
1656 fi
David Bainbridged2811972019-12-14 01:14:09 +00001657 fi
1658fi
1659
David Bainbridged18f4942020-04-14 16:46:13 -07001660if [ "$VOK" -eq 0 ]; then
1661 espin "$NOT_VERIFIED"
David Bainbridged2811972019-12-14 01:14:09 +00001662 bspin - "Download and $VMESSAGE voltctl $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001663 (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
1664 RESULT=$?
1665 if [ $RESULT -ne 0 ]; then
1666 espin - "$THEX"
1667 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download voltctl (version $VC_VERSION): $(cat "$ERR_OUT")${NORMAL}"
1668 rm -rf "$ERR_OUT" "$GOPATH/bin/voltctl"
1669 exit 1
1670 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001671 (set -x; chmod 755 "$GOPATH/bin/voltctl" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1672 espin - "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001673fi
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001674rm -rf "$ERR_OUT"
David Bainbridgee87067b2019-08-12 22:00:12 +00001675if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001676 NOW="$(date +%s)"
1677 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001678fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001679
1680bspin "Verify command PATH"
David Bainbridged18f4942020-04-14 16:46:13 -07001681espin "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001682
David Bainbridged18f4942020-04-14 16:46:13 -07001683STIME="$(date +%s)"
Test Userba1e7e72019-07-10 22:27:54 +00001684if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001685 HAVE="$(kind get clusters 2>/dev/null | grep -c "voltha-$NAME")"
Test Userba1e7e72019-07-10 22:27:54 +00001686 bspin "Verify Kubernetes/Kind Cluster"
1687 sspin
David Bainbridged18f4942020-04-14 16:46:13 -07001688 if [ "$HAVE" -eq 0 ]; then
1689 espin "$NOT_VERIFIED"
Andrea Campanella8a149192020-07-31 17:19:45 +02001690 FILE="$NAME-cluster.cfg"
David K. Bainbridge2aa08da2020-07-31 12:49:45 -07001691 if [ -n "$KIND_CFG_FILE" ]; then
1692 FILE="$KIND_CFG_FILE"
1693 else
1694 bspin - "Generating cluster configuration"
Andrea Campanelladd946472020-07-31 11:03:44 +02001695
David K. Bainbridge2aa08da2020-07-31 12:49:45 -07001696 if [ -f "$FILE" ] ; then
1697 rm "$FILE"
1698 fi
1699
1700 touch "$FILE"
1701
1702 yq w -i "$FILE" kind Cluster
1703 yq w -i "$FILE" apiVersion "kind.sigs.k8s.io/v1alpha3"
1704
1705 if [ ! "$NUM_OF_CONTROLLER_NODES" -eq 0 ]; then
1706 for instance in $(seq 1 "$NUM_OF_CONTROLLER_NODES"); do
1707 yq w -i "$FILE" "nodes[+].role" "control-plane"
1708 done
1709 fi
1710
1711 if [ ! "$NUM_OF_WORKER_NODES" -eq 0 ]; then
1712 for instance in $(seq 1 "$NUM_OF_WORKER_NODES"); do
1713 yq w -i "$FILE" "nodes[+].role" worker
1714 done
1715 fi
1716 espin - "$VERIFIED"
Andrea Campanelladd946472020-07-31 11:03:44 +02001717 fi
1718
Andrea Campanella8a149192020-07-31 17:19:45 +02001719 cat "$FILE" >> "$LOG" 2>&1
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001720
Andrea Campanella8a149192020-07-31 17:19:45 +02001721 kind create cluster --name "voltha-$NAME" --config "$FILE"
David Bainbridge491b1bd2019-07-11 17:53:11 +00001722 else
David Bainbridged18f4942020-04-14 16:46:13 -07001723 espin "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001724 fi
1725
David K. Bainbridgec0ec6492020-07-21 17:34:23 +00001726 KUBECONFIG_TMP=$(mktemp)
1727 kind get kubeconfig --name="voltha-$NAME" >"$KUBECONFIG_TMP"
1728 mkdir -p "$HOME/.kube"
1729 KUBECONFIG="$HOME/.kube/kind-config-voltha-$NAME"; export KUBECONFIG
1730 cp "$KUBECONFIG_TMP" "$KUBECONFIG"
1731 rm -rf "$KUBECONFIG_TMP"
David Bainbridge1d2c5842020-06-03 15:29:07 -07001732
Test Userba1e7e72019-07-10 22:27:54 +00001733 P="coredns-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001734 etcd-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +00001735 kindnet-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001736 kube-apiserver-voltha-$NAME-control-plane \
1737 kube-controller-manager-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +00001738 kube-proxy-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001739 kube-scheduler-voltha-$NAME-control-plane"
Test Userba1e7e72019-07-10 22:27:54 +00001740
David K. Bainbridge2aa08da2020-07-31 12:49:45 -07001741 EXPECT=2 # Always 2 DNS instances
1742 EXPECT=$((EXPECT + 4 * NUM_OF_CONTROLLER_NODES)) # etcd, apiserver, controller manager, scheduler
1743 EXPECT=$((EXPECT + 2 * (NUM_OF_CONTROLLER_NODES + NUM_OF_WORKER_NODES))) # kindnet, proxy
David Bainbridged18f4942020-04-14 16:46:13 -07001744 wait_for_pods - "kube-system" "$EXPECT" "includes" "Waiting for system PODs to start" "$NO_LABEL" "$P"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001745fi
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001746
David Bainbridgee87067b2019-08-12 22:00:12 +00001747if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001748 NOW="$(date +%s)"
1749 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001750fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001751
David Bainbridgee4d11ca2020-05-08 10:21:10 -07001752if [ "$SCHEDULE_ON_CONTROL_NODES" == "yes" ]; then
1753 bspin "Untaint control nodes to allow scheduling $LOCK"
1754 for MNODE in $(kubectl get node --selector='node-role.kubernetes.io/master' -o json | jq -r '.items[].metadata.name'); do
1755 (set -x; kubectl taint node "$MNODE" node-role.kubernetes.io/master:NoSchedule- >>"$LOG" 2>&1) >>"$LOG" 2>&1
1756 sspin
1757 done
1758 espin "$VERIFIED"
1759fi
1760
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001761if [ "$HELM_MAJOR" -le 2 ]; then
1762 STIME="$(date +%s)"
1763 COUNT="$(count_pods "kube-system" ":Running:" "$NO_LABEL" "tiller-deploy-.*")"
1764 bspin "Verify Helm"
1765 if [ "$COUNT" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001766 espin "$NOT_VERIFIED"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001767 echo -e "Configuring Helm $GEAR"
1768 if [ "$INSTALL_HELM" == "no" ]; then
1769 bspin - "Skip Helm Initialization"
1770 espin - $NO_ENTRY
1771 else
1772 bspin - "Initialize Helm"
1773 (set -x; helm init --upgrade >>"$LOG" 2>&1) >>"$LOG" 2>&1
1774 espin - "$VERIFIED"
1775 wait_for_pods - "kube-system" 1 "includes" "Waiting for Tiller POD to start" "$NO_LABEL" "tiller-deploy-.*"
1776 fi
1777
1778 # HACK (sort-of) - the config for tiller is about to be patched, which will
1779 # cause the tiller pod to be recreated. This can sometimes cause a timing
1780 # issue with the "wait_for_pods" call on tiller as it may incorrectly
1781 # identify the running/ready tiller pod that is soon to be terminated as
1782 # what it is waiting for. To avoid this issue we do a clean scale down and
1783 # scale up of the pod so the script controlls when it should be expecting
1784 # things
1785 (set -x; kubectl -n kube-system scale deploy tiller-deploy --replicas=0 >>"$LOG" 2>&1) >>"$LOG" 2>&1
1786 wait_for_pods - "kube-system" 0 "not" "Waiting for Tiller POD to shutdown" "$NO_LABEL" "tiller-deploy-.*"
1787
1788 # Create and k8s service account so that Helm can create pods
1789 bspin - "Create Tiller ServiceAccount"
1790 (set -x; kubectl create serviceaccount --namespace kube-system tiller >>"$LOG" 2>&1) >>"$LOG" 2>&1
1791 espin - "$VERIFIED"
1792 bspin - "Create Tiller ClusterRoleBinding"
1793 (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>"$LOG" 2>&1) >>"$LOG" 2>&1
1794 espin - "$VERIFIED"
1795 bspin - "Update Tiller Manifest"
1796 (set -x; kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}' >>"$LOG" 2>&1) >>"$LOG" 2>&1
1797
1798 # HACK (sort-of) - part to, spin it back up
1799 (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 -07001800 espin - "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001801 else
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001802 if [ "$(helm version -s --template '{{.Server.SemVer}}')" != "$HELM_VERSION" ]; then
1803 espin "$NOT_VERIFIED"
1804 bspin - "Sync Tiller server version with helm client"
1805 (set -x; helm init --upgrade --force-upgrade --wait >>"$LOG" 2>&1) >>"$LOG" 2>&1
1806 espin - "$VERIFIED"
1807 else
1808 espin "$VERIFIED"
1809 fi
1810
David Bainbridgea34993d2020-04-01 09:15:42 -07001811 fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001812 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 -07001813fi
David Bainbridgeddeab482020-06-24 12:43:40 -07001814
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001815# The `etcd` repo is temporary until `http://github.com/helm/charts/pull/22955` is
1816# merged into the incubator charts
David Bainbridgeddeab482020-06-24 12:43:40 -07001817REPOS="onf|https://charts.opencord.org|ONF_VOLTHA \
1818 stable|https://kubernetes-charts.storage.googleapis.com|Google_Stable \
Ubuntubaab12f2020-06-30 01:08:19 +00001819 incubator|https://kubernetes-charts-incubator.storage.googleapis.com|Google_Incubator \
1820 onos|https://charts.onosproject.org|ONF_ONOS \
1821 atomix|https://charts.atomix.io|ONF_Atomix \
1822 bbsim-sadis|https://ciena.github.io/bbsim-sadis-server/charts|Custom_BBSIM_SADIS_Server \
1823 elastic|https://helm.elastic.co|Elastic \
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001824 kiwigrid|https://kiwigrid.github.io|Fluentd-ElasticSearch \
1825 etcd|https://dbainbri-ciena.github.io/etcd-helm-chart"
David Bainbridgeddeab482020-06-24 12:43:40 -07001826
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001827REPO_UPDATE_REQ="no"
David Bainbridgeddeab482020-06-24 12:43:40 -07001828bspin - "Verify Helm Repository"
1829for REPO in $REPOS; do
1830 REPO_NAME="$(echo "$REPO" | cut -d\| -f1)"
1831 REPO_URL="$(echo "$REPO" | cut -d\| -f2)"
1832 REPO_LABEL="$(echo "$REPO" | cut -d\| -f3 | sed -e 's/_/ /g')"
1833
1834 sspin - "Verify Helm Repository: $REPO_LABEL$CEOL"
1835 if [ "$(helm repo list 2>/dev/null | grep -c "$REPO_NAME" 2>/dev/null)" -eq 0 ]; then
1836 sspin - "Add Helm Repository: $REPO_LABEL$CEOL"
1837 (set -x; helm repo add "$REPO_NAME" "$REPO_URL" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1838 REPO_UPDATE_REQ="yes"
1839 fi
1840done
1841sspin - "Verify Helm Repositories$CEOL"
1842espin - "$VERIFIED"
1843
1844if [ "$REPO_UPDATE_REQ" == "yes" ] || [ "$UPDATE_HELM_REPOS" == "yes" ]; then
1845 bspin - "Update Helm repository cache"
1846 (set -x; helm repo update >>"$LOG" 2>&1) >>"$LOG" 2>&1
1847 espin - "$VERIFIED"
1848fi
1849
David Bainbridgee87067b2019-08-12 22:00:12 +00001850if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001851 NOW="$(date +%s)"
1852 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001853fi
David Bainbridgecf546362020-04-21 23:18:50 -07001854# Resolve chart versions and log them for debug/support
1855RESOLVED_VOLTHA_CHART_VERSION=$(resolve_chart_version "$VOLTHA_CHART" "$VOLTHA_CHART_VERSION")
1856RESOLVED_VOLTHA_BBSIM_CHART_VERSION=$(resolve_chart_version "$VOLTHA_BBSIM_CHART" "$VOLTHA_BBSIM_CHART_VERSION")
Girish Kumarcc5f9172020-06-10 13:34:31 +00001857RESOLVED_VOLTHA_TRACING_CHART_VERSION=$(resolve_chart_version "$VOLTHA_TRACING_CHART" "$VOLTHA_TRACING_CHART_VERSION")
David Bainbridgecf546362020-04-21 23:18:50 -07001858RESOLVED_VOLTHA_ADAPTER_SIM_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_SIM_CHART" "$VOLTHA_ADAPTER_SIM_CHART_VERSION")
1859RESOLVED_VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_OPEN_OLT_CHART" "$VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION")
1860RESOLVED_VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_OPEN_ONU_CHART" "$VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION")
1861RESOLVED_ONOS_CHART_VERSION=$(resolve_chart_version "$ONOS_CHART" "$ONOS_CHART_VERSION")
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001862RESOLVED_ONOS_CLASSIC_CHART_VERSION=$(resolve_chart_version "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION")
David Bainbridgecf546362020-04-21 23:18:50 -07001863RESOLVED_KAFKA_CHART_VERSION=$(resolve_chart_version "$KAFKA_CHART" "$KAFKA_CHART_VERSION")
divyadesai59f987a2020-05-27 12:11:33 +00001864RESOLVED_ELASTICSEARCH_CHART_VERSION=$(resolve_chart_version "$ELASTICSEARCH_CHART" "$ELASTICSEARCH_CHART_VERSION")
1865RESOLVED_KIBANA_CHART_VERSION=$(resolve_chart_version "$KIBANA_CHART" "$KIBANA_CHART_VERSION")
1866RESOLVED_FLUENTD_ELASTICSEARCH_CHART_VERSION=$(resolve_chart_version "$FLUENTD_ELASTICSEARCH_CHART" "$FLUENTD_ELASTICSEARCH_CHART_VERSION")
David K. Bainbridge450c15c2020-06-29 10:12:06 -07001867RESOLVED_BBSIM_SADIS_SERVER_CHART_VERSION=$(resolve_chart_version "$BBSIM_SADIS_SERVER_CHART" "$BBSIM_SADIS_SERVER_CHART_VERSION")
1868RESOLVED_RADIUS_CHART_VERSION=$(resolve_chart_version "$RADIUS_CHART" "$RADIUS_CHART_VERSION")
David Bainbridgecf546362020-04-21 23:18:50 -07001869cat <<EOV >>"$LOG"
1870Resolved helm charts and versions:
1871 $VOLTHA_CHART:$RESOLVED_VOLTHA_CHART_VERSION
1872 $VOLTHA_BBSIM_CHART:$RESOLVED_VOLTHA_BBSIM_CHART_VERSION
Girish Kumarcc5f9172020-06-10 13:34:31 +00001873 $VOLTHA_TRACING_CHART:$RESOLVED_VOLTHA_TRACING_CHART_VERSION
David Bainbridgecf546362020-04-21 23:18:50 -07001874 $VOLTHA_ADAPTER_SIM_CHART:$RESOLVED_VOLTHA_ADAPTER_SIM_CHART_VERSION
1875 $VOLTHA_ADAPTER_OPEN_OLT_CHART:$RESOLVED_VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION
1876 $VOLTHA_ADAPTER_OPEN_ONU_CHART:$RESOLVED_VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION
1877 $ONOS_CHART:$RESOLVED_ONOS_CHART_VERSION
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001878 $ONOS_CLASSIC_CHART:$RESOLVED_ONOS_CLASSIC_CHART_VERSION
David Bainbridgecf546362020-04-21 23:18:50 -07001879 $KAFKA_CHART:$RESOLVED_KAFKA_CHART_VERSION
divyadesai59f987a2020-05-27 12:11:33 +00001880 $ELASTICSEARCH_CHART:$RESOLVED_ELASTICSEARCH_CHART_VERSION
1881 $KIBANA_CHART:$RESOLVED_KIBANA_CHART_VERSION
1882 $FLUENTD_ELASTICSEARCH_CHART:$RESOLVED_FLUENTD_ELASTICSEARCH_CHART_VERSION
David K. Bainbridge450c15c2020-06-29 10:12:06 -07001883 $BBSIM_SADIS_SERVER_CHART:$RESOLVED_BBSIM_SADIS_SERVER_CHART_VERSION
1884 $RADIUS_CHART:$RESOLVED_RADIUS_CHART_VERSION
David Bainbridgecf546362020-04-21 23:18:50 -07001885EOV
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001886
David Bainbridged18f4942020-04-14 16:46:13 -07001887STIME="$(date +%s)"
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001888bspin "Verify Helm values file: values.yaml"
1889if [ ! -r "./values.yaml" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001890 espin "$NOT_VERIFIED"
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001891 bspin - "Download Helm values file: values.yaml to values.yaml $DOWNLOAD"
David Bainbridged18f4942020-04-14 16:46:13 -07001892 ERR_OUT="$(mktemp)"
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001893 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 -07001894 espin - "$THEX"
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001895 echo -e "${RED}${BOLD}${ERROR}ERROR: values.yaml${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
David Bainbridged18f4942020-04-14 16:46:13 -07001896 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001897 rm -rf "$ERR_OUT" "./values.yaml"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001898 exit 1
1899 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001900 rm -rf "$ERR_OUT"
1901 espin - "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001902else
David Bainbridged18f4942020-04-14 16:46:13 -07001903 espin "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001904fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001905if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001906 NOW="$(date +%s)"
1907 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001908fi
Test Userba1e7e72019-07-10 22:27:54 +00001909
David Bainbridged18f4942020-04-14 16:46:13 -07001910STIME="$(date +%s)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001911bspin "Verify or download chart specific values files $DOWNLOAD"
1912VALUES_FILES="monkey-values.yaml"
David Bainbridged18f4942020-04-14 16:46:13 -07001913ERR_OUT="$(mktemp)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001914for i in $VALUES_FILES; do
1915 if [ ! -r ./$i ]; then
serkant.uluderya4d315132020-04-15 16:25:54 -07001916 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 -07001917 espin "$THEX"
1918 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1919 echo "ERROR: $i - $(cat "$ERR_OUT")" >>"$LOG"
1920 rm -rf "$ERR_OUT" "./$i"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001921 exit 1
1922 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001923 rm -rf "$ERR_OUT"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001924 fi
1925done
David Bainbridged18f4942020-04-14 16:46:13 -07001926rm -rf "$ERR_OUT"
1927espin "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001928if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001929 NOW="$(date +%s)"
1930 printtime $((NOW - STIME))
David Bainbridge99ac7a22019-08-31 02:26:43 +00001931fi
1932
1933if [ "$WITH_CHAOS" == "yes" ]; then
1934 bspin "Verify or clone kube-monkey helm chart $DOWNLOAD"
1935 if [ -r ./kube-monkey ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001936 espin "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001937 else
David Bainbridged18f4942020-04-14 16:46:13 -07001938 espin "$NOT_VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001939 bspin - "GIT clone kube-monkey"
David Bainbridged18f4942020-04-14 16:46:13 -07001940 (set -x; git clone https://github.com/asobti/kube-monkey kube-monkey >>"$LOG" 2>&1) >>"$LOG" 2>&1
1941 espin - "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001942 fi
1943fi
1944
Test Userba1e7e72019-07-10 22:27:54 +00001945if [ "$JUST_K8S" == "yes" ]; then
1946 echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye."
1947 echo ""
David Bainbridged18f4942020-04-14 16:46:13 -07001948 echo "Please issue the following commands in your terminal to ensure that you" | tee -a "$LOG"
1949 echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a "$LOG"
1950 echo "tools required by VOLTHA in your command path. " | tee -a "$LOG"
1951 echo "" | tee -a "$LOG"
1952 echo -en "$BOLD"
1953 if [ "$DEPLOY_K8S" == "yes" ]; then
David K. Bainbridge02ae1f32020-07-21 13:25:13 -07001954 KUBECONFIG_TMP=$(mktemp)
1955 kind get kubeconfig --name="voltha-$NAME" >"$KUBECONFIG_TMP"
1956 mkdir -p "$HOME/.kube"
1957 KUBECONFIG="$HOME/.kube/kind-config-voltha-$NAME"; export KUBECONFIG
1958 cp "$KUBECONFIG_TMP" "$KUBECONFIG"
1959 rm -rf "$KUBECONFIG_TMP"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001960 echo "export KUBECONFIG=\"$KUBECONFIG\"" | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00001961 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001962 echo "export PATH=$GOPATH/bin:\$PATH" | tee -a "$LOG"
1963 echo -en "$NORMAL"
1964 echo "" | tee -a "$LOG"
1965 echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00001966 exit 0
1967fi
1968
David K. Bainbridgecb4b3ab2020-08-31 08:34:14 -07001969if is_in "$WITH_ETCD" "yes,external"; then
1970 STIME="$(date +%s)"
1971 bspin "Verify external ETCD cluster $OLD_KEY"
1972 EXPECT=$NUM_OF_ETCD
1973 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^etcd\$")" -ne 1 ]; then
1974 espin "$NOT_VERIFIED"
1975 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"
1976 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
1977 else
1978 espin "$VERIFIED"
1979 fi
1980 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for ETCD cluster to start" "$NO_LABEL" "etcd-.*"
1981 if [ "$WITH_TIMINGS" == "yes" ]; then
1982 NOW="$(date +%s)"
1983 printtime $((NOW - STIME))
1984 fi
1985fi
1986
1987if is_in "$WITH_KAFKA" "yes,external"; then
1988 _TMP="$(mktemp -u)"
1989 cat << EOC > "$_TMP"
1990configurationOverrides:
1991 "default.replication.factor": $NUM_OF_KAFKA
1992 "offsets.topic.replication.factor": $NUM_OF_KAFKA
1993 "log.retention.hours": 4
1994 "log.message.timestamp.type": "LogAppendTime"
1995persistence:
1996 enabled: false
1997zookeeper:
1998 replicaCount: $NUM_OF_KAFKA
1999 persistence:
2000 enabled: false
2001replicas: $NUM_OF_KAFKA
2002EOC
2003 STIME="$(date +%s)"
2004 bspin "Verify external Kafka cluster $OLD_KEY"
2005 EXPECT=$((NUM_OF_KAFKA*2))
2006 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^kafka\$")" -ne 1 ]; then
2007 espin "$NOT_VERIFIED"
2008 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" -f $_TMP"
2009 helm_install - "$INFRA_NS" kafka "$KAFKA_CHART" "$KAFKA_CHART_VERSION" kafka "$_HELM_DESC external Kafka cluster"
2010 else
2011 espin "$VERIFIED"
2012 fi
2013 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for Kafka cluster to start" "$NO_LABEL" "kafka-.*"
2014 if [ "$WITH_TIMINGS" == "yes" ]; then
2015 NOW="$(date +%s)"
2016 printtime $((NOW - STIME))
2017 fi
2018 rm -rf "$_TMP"
2019fi
2020
2021
David Bainbridged18f4942020-04-14 16:46:13 -07002022STIME="$(date +%s)"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002023if is_in "$WITH_ONOS" "yes,legacy,classic"; then
2024 if is_in "$WITH_ONOS" "legacy"; then
2025 bspin "Verify ONOS LEGACY installed $BIRD"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002026 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^onos\$")" -ne 1 ]; then
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002027 espin "$NOT_VERIFIED"
David Bainbridge33e56c72020-06-11 11:39:56 -07002028 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 -07002029 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
2030 else
2031 espin "$VERIFIED"
2032 fi
2033 wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for ONOS to start" "$NO_LABEL" "onos-.*"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07002034
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002035 if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
2036 bspin - "Forward ONOS API port $FORWARD"
2037 kill_port_forward onos-ui
2038 port_forward "$INFRA_NS" onos-ui "$ONOS_API_PORT:8181"
2039 espin - "$VERIFIED"
2040 bspin - "Forward ONOS SSH port $FORWARD"
2041 kill_port_forward onos-ssh
2042 port_forward "$INFRA_NS" onos-ssh "$ONOS_SSH_PORT:8101"
2043 espin - "$VERIFIED"
2044 _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT"
2045 else
2046 _ONOS_API_EP="$(get_service_ep "$INFRA_NS" onos-ui)"
2047 fi
2048 elif is_in "$WITH_ONOS" "yes,classic"; then
2049 bspin "Verify ONOS CLASSIC installed $BIRD"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002050 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^onos\$")" -ne 1 ]; then
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002051 espin "$NOT_VERIFIED"
Matteo Scandoloe0829b52020-05-08 14:23:56 -07002052 # 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 -07002053 # values value
David Bainbridgefad50732020-05-01 17:00:12 -07002054 YAML_VALUES=$(INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set replicas=$NUM_OF_ONOS --set atomix.replicas=$NUM_OF_ATOMIX" \
2055 helm_values "$INFRA_NS" onos "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION")
2056 _ONOS_REPO="$(echo "$YAML_VALUES" | yq read - images.onos.repository)"
David Bainbridgedee3f022020-06-05 07:45:13 -07002057 if [ -z "$_ONOS_REPO" ]; then
2058 _ONOS_REPO="voltha/voltha-onos"
2059 fi
David Bainbridgefad50732020-05-01 17:00:12 -07002060 _ONOS_TAG="$(echo "$YAML_VALUES" | yq read - images.onos.tag)"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002061 if [ -z "$_ONOS_TAG" ]; then
David Bainbridgedee3f022020-06-05 07:45:13 -07002062 _ONOS_TAG="$(echo "$YAML_VALUES" | yq read - defaults.image_tag)"
2063 fi
2064 if [ -z "$_ONOS_TAG" ]; then
2065 _ONOS_TAG="master"
2066 fi
2067 _ONOS_PULL_POLICY="$(echo "$YAML_VALUES" | yq read - images.onos.pullPolicy)"
2068 if [ -z "$_ONOS_PULL_POLICY" ]; then
2069 _ONOS_PULL_POLICY="$(echo "$YAML_VALUES" | yq read - defaults.image_pullPolicy)"
2070 fi
2071 if [ -z "$_ONOS_PULL_POLICY" ]; then
2072 _ONOS_PULL_POLICY="Always"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002073 fi
David Bainbridgefad50732020-05-01 17:00:12 -07002074
Matteo Scandoloe0829b52020-05-08 14:23:56 -07002075 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 -07002076 helm_install - "$INFRA_NS" onos "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION" "+onos" "$_HELM_DESC ONOS CLASSIC"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002077 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
2078 else
2079 espin "$VERIFIED"
2080 fi
2081 wait_for_pods - "$INFRA_NS" $((NUM_OF_ONOS + NUM_OF_ATOMIX)) "includes" "Waiting for ONOS CLASSIC to start" "$NO_LABEL" "onos-.*"
2082 if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
2083 bspin - "Forward ONOS API port $FORWARD"
2084 kill_port_forward onos-onos-classic-hs
2085 port_forward "$INFRA_NS" onos-onos-classic-hs "$ONOS_API_PORT:8181" "$ONOS_SSH_PORT:8101"
2086 espin - "$VERIFIED"
2087 _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT"
2088 else
2089 _ONOS_API_EP="$(get_service_ep "$INFRA_NS" onos-onos-classic-hs)"
2090 fi
2091 elif [ "$WITH_ONOS" == "micro" ]; then
2092 bspin "Verify micro-ONOS installed $BIRD"
2093 # We should never get here
2094 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Micro ONOS not currently supported${NORMAL}"
2095 exit 1
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002096 fi
David Bainbridged31d6122019-08-13 19:37:59 +00002097 bspin - "Verify or download ONOS configuration support files $DOWNLOAD"
Matteo Scandolo78dfee02020-02-13 16:18:03 -08002098 ONOS_FILES="olt-onos-enableExtraneousRules.json onos-aaa.json \
David Bainbridge696bc632020-04-05 21:49:37 -07002099 onos-dhcpl2relay.json onos-sadis-sample.json"
David Bainbridged18f4942020-04-14 16:46:13 -07002100 (set -x; mkdir -p ./onos-files >>"$LOG" 2>&1) >>"$LOG" 2>&1
2101 ERR_OUT="$(mktemp)"
David Bainbridge2b19e832019-08-16 02:40:53 +00002102 for i in $ONOS_FILES; do
David Bainbridged18f4942020-04-14 16:46:13 -07002103 if [ ! -r "./onos-files/$i" ]; then
serkant.uluderya4d315132020-04-15 16:25:54 -07002104 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 -07002105 espin - "$THEX"
2106 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
2107 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
2108 rm -rf "$ERR_OUT" "./onos-files/$i"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08002109 exit 1
2110 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002111 rm -rf "$ERR_OUT"
David Bainbridged31d6122019-08-13 19:37:59 +00002112 fi
2113 done
David Bainbridged18f4942020-04-14 16:46:13 -07002114 rm -rf "$ERR_OUT"
2115 espin - "$VERIFIED"
David Bainbridge27790d62019-08-13 22:43:19 +00002116
David Bainbridged18f4942020-04-14 16:46:13 -07002117 if [ "$INSTALL_ONOS_APPS" == "yes" ]; then
David Bainbridge27790d62019-08-13 22:43:19 +00002118 bspin - "Installing custom ONOS applications"
David Bainbridged18f4942020-04-14 16:46:13 -07002119 if [ -x onos-files/onos-apps ] && [ "$(find onos-files/onos-apps -name "*.oar" 2>/dev/null | wc -l)" -gt 0 ]; then
2120 for OAR in onos-files/onos-apps/*.oar; do
David Bainbridge27790d62019-08-13 22:43:19 +00002121 sspin - "Installing custom ONOS applications - $OAR$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -07002122 override_onos_app "$OAR"
David Bainbridge27790d62019-08-13 22:43:19 +00002123 done
2124 espin - "$VERIFIED Installing custom ONOS applications$CEOL"
2125 else
2126 espin - "$NOT_VERIFIED Installing custom ONOS applications - None Found"
2127 fi
2128 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07002129
David Bainbridged18f4942020-04-14 16:46:13 -07002130 if [ "$WITH_KAFKA" != "no" ]; then
David Bainbridge837e8bd2020-04-06 13:17:14 -07002131 check_onos_app_active org.opencord.kafka
David Bainbridge879439b2020-06-12 15:59:35 -07002132 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridgec7220622020-05-28 12:31:47 -07002133 _HOST=kafka.$INFRA_NS.svc
David Bainbridge76afd812020-04-06 09:53:52 -07002134 _PORT=9092
David Bainbridge879439b2020-06-12 15:59:35 -07002135 elif [ "$WITH_KAFKA" != "no" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002136 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
2137 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge837e8bd2020-04-06 13:17:14 -07002138 _PORT=${_PORT:-9092}
2139 fi
2140 push_onos_config "json" "Push ONOS Kafka Configuration" "network/configuration/apps/org.opencord.kafka" \
David Bainbridged18f4942020-04-14 16:46:13 -07002141 "$(cat <<EOJ | tr -d '[:space:]'
David Bainbridge696bc632020-04-05 21:49:37 -07002142{
2143 "kafka": {
2144 "bootstrapServers": "$_HOST:$_PORT"
2145 }
2146}
2147EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07002148)"
David Bainbridge837e8bd2020-04-06 13:17:14 -07002149 fi
Matteo Scandolo9a77a732020-01-09 14:24:12 -08002150 check_onos_app_active org.opencord.dhcpl2relay
Matteo Scandolo78dfee02020-02-13 16:18:03 -08002151 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 -08002152 check_onos_app_active org.opencord.olt
Matteo Scandolo78dfee02020-02-13 16:18:03 -08002153 # FIXME use WITH_DHCP and WITH_EAPOL flags to configre OLT App
Hardik Windlassa7501fb2020-02-17 14:28:20 +00002154 # Default value for "enableEapol" is true in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07002155 if [ "$WITH_EAPOL" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08002156 push_onos_config "json" "Enable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":true}'
David Bainbridged18f4942020-04-14 16:46:13 -07002157 elif [ "$WITH_EAPOL" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00002158 push_onos_config "json" "Disable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08002159 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00002160 # Default value for "enableDhcpOnProvisioning" is false and for "enableDhcpV4" is true in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07002161 if [ "$WITH_DHCP" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08002162 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 -07002163 elif [ "$WITH_DHCP" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00002164 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 -08002165 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00002166 # Default value for "enableIgmpOnProvisioning" is false in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07002167 if [ "$WITH_IGMP" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08002168 push_onos_config "json" "Enable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":true}'
David Bainbridged18f4942020-04-14 16:46:13 -07002169 elif [ "$WITH_IGMP" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00002170 push_onos_config "json" "Disable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08002171 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002172 if [ "$ENABLE_ONOS_EXTRANEOUS_RULES" == "yes" ]; then
David K. Bainbridge484d80c2020-03-05 21:44:34 -08002173 push_onos_config "file" "Enabling extraneous rules for ONOS" "configuration/org.onosproject.net.flow.impl.FlowRuleManager" "onos-files/olt-onos-enableExtraneousRules.json"
2174 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002175 if is_in "$CONFIG_SADIS" "yes,file"; then
Matteo Scandolo9a77a732020-01-09 14:24:12 -08002176 check_onos_app_active org.opencord.sadis
Hardik Windlassb3147602020-03-09 16:59:15 +05302177 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 -07002178 elif [ "$CONFIG_SADIS" == "bbsim" ]; then
2179 push_onos_config "json" \
2180 "[optional] Push ONOS configuration for BBSIM SADIS servers" \
2181 "network/configuration/apps/org.opencord.sadis" \
David Bainbridged18f4942020-04-14 16:46:13 -07002182 "$(cat <<EOJ | tr -d '[:space:]'
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002183{
2184 "sadis": {
2185 "integration": {
David Bainbridgec7220622020-05-28 12:31:47 -07002186 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:50074/v2/subscribers/%s",
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002187 "cache": {
2188 "enabled": true,
2189 "maxsize": 50,
2190 "ttl": "PT1m"
2191 }
2192 }
2193 },
2194 "bandwidthprofile": {
2195 "integration": {
David Bainbridgec7220622020-05-28 12:31:47 -07002196 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:50074/v2/bandwidthprofiles/%s",
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002197 "cache": {
2198 "enabled": true,
2199 "maxsize": 50,
2200 "ttl": "PT1m"
2201 }
2202 }
2203 }
2204}
2205EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07002206)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002207 elif [ "$CONFIG_SADIS" == "url" ]; then
2208 push_onos_config "json" \
2209 "[optional] Push ONOS configuration for custom SADIS and Bandwidth Profile servers" \
2210 "network/configuration/apps/org.opencord.sadis" \
David Bainbridged18f4942020-04-14 16:46:13 -07002211 "$(cat <<EOJ | tr -d '[:space:]'
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002212{
2213 "sadis": {
2214 "integration": {
2215 "url": "$SADIS_SUBSCRIBERS",
2216 "cache": {
2217 "enabled": true,
2218 "maxsize": 50,
2219 "ttl": "PT1m"
2220 }
2221 }
2222 },
2223 "bandwidthprofile": {
2224 "integration": {
2225 "url": "$SADIS_BANDWIDTH_PROFILES",
2226 "cache": {
2227 "enabled": true,
2228 "maxsize": 50,
2229 "ttl": "PT1m"
2230 }
2231 }
2232 }
2233}
2234EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07002235)"
David Bainbridge2b19e832019-08-16 02:40:53 +00002236 fi
Test Userba1e7e72019-07-10 22:27:54 +00002237fi
David Bainbridgee87067b2019-08-12 22:00:12 +00002238if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002239 NOW="$(date +%s)"
2240 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002241fi
Test Userba1e7e72019-07-10 22:27:54 +00002242
Girish Kumarcc5f9172020-06-10 13:34:31 +00002243if [ "$WITH_TRACING" == "yes" ]; then
2244 STIME="$(date +%s)"
2245 echo -e "Verify Jaeger Tracing $PLUG"
2246 bspin - "Verify Jaeger Tracing Installed"
2247 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^tracing\$")" -ne 1 ]; then
2248 espin - "$NOT_VERIFIED"
2249 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
2250 helm_install - "$INFRA_NS" tracing "$VOLTHA_TRACING_CHART" "$VOLTHA_TRACING_CHART_VERSION" tracing "$_HELM_DESC Jaeger Tracing"
2251 else
2252 espin - "$VERIFIED"
2253 fi
2254 wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for Jaeger Tracing to start" "$NO_LABEL" "jaeger*"
2255 if [ "$WITH_TIMINGS" == "yes" ]; then
2256 NOW="$(date +%s)"
2257 printtime $((NOW - STIME))
2258 fi
2259fi
2260
David Bainbridged18f4942020-04-14 16:46:13 -07002261STIME="$(date +%s)"
David Bainbridgeed476572020-06-02 14:05:45 -07002262EXPECT=2
2263# therecanbeonlyone set hardcoded to true for backward compatibility
2264INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set therecanbeonlyone=true"
Matteo Scandolo67335f02020-04-09 11:19:53 -07002265case $WITH_ETCD in
David Bainbridge76afd812020-04-06 09:53:52 -07002266 no)
David Bainbridge76afd812020-04-06 09:53:52 -07002267 ;;
David Bainbridgec7220622020-05-28 12:31:47 -07002268 yes|external)
2269 _HOST="etcd.$INFRA_NS.svc"
David Bainbridge76afd812020-04-06 09:53:52 -07002270 _PORT=2379
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002271 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
Neha Sharmaa1c92ca2020-06-24 11:50:33 +00002272 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.address=$_HOST:$_PORT"
David Bainbridge76afd812020-04-06 09:53:52 -07002273 ;;
2274 *)
David Bainbridged18f4942020-04-14 16:46:13 -07002275 _HOST="$(echo "$WITH_ETCD" | cut -d: -f1)"
2276 _PORT="$(echo "$WITH_ETCD" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07002277 _PORT=${_PORT:-2379}
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002278 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
Neha Sharmaa1c92ca2020-06-24 11:50:33 +00002279 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.address=$_HOST:$_PORT"
David Bainbridge76afd812020-04-06 09:53:52 -07002280 ;;
2281esac
2282case $WITH_KAFKA in
2283 no)
David Bainbridge76afd812020-04-06 09:53:52 -07002284 ;;
David Bainbridgec7220622020-05-28 12:31:47 -07002285 yes|external)
2286 _HOST=kafka.$INFRA_NS.svc
David Bainbridge76afd812020-04-06 09:53:52 -07002287 _PORT=9092
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002288 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"
2289 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 -07002290 ;;
2291 *)
David Bainbridged18f4942020-04-14 16:46:13 -07002292 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
2293 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07002294 _PORT=${_PORT:-9092}
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002295 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"
2296 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 -07002297 ;;
2298esac
2299
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002300if is_in "$WITH_ONOS" "legacy"; then
David Bainbridgec7220622020-05-28 12:31:47 -07002301 _HOST=onos-openflow.$INFRA_NS.svc
David Bainbridge76afd812020-04-06 09:53:52 -07002302 _PORT=6653
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002303elif is_in "$WITH_ONOS" "yes,classic"; then
David Bainbridgec7220622020-05-28 12:31:47 -07002304 _HOST=onos-onos-classic-hs.$INFRA_NS.svc
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002305 _PORT=6653
David Bainbridged18f4942020-04-14 16:46:13 -07002306elif [ "$WITH_ONOS" != "no" ]; then
2307 _HOST="$(echo "$WITH_ONOS" | cut -d: -f1)"
2308 _PORT="$(echo "$WITH_ONOS" | cut -s -d: -f2)"
David Bainbridge76afd812020-04-06 09:53:52 -07002309 _PORT=${_PORT:-6653}
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002310fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002311
David Bainbridgecf546362020-04-21 23:18:50 -07002312compare_versions "$RESOLVED_VOLTHA_CHART_VERSION" 2.4.2
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002313if [ "$?" == "1" ]; then
2314 # voltha chart > 2.4.2 uses list of controllers
David Bainbridgee4d11ca2020-05-08 10:21:10 -07002315 for NUM in $(seq 0 $((NUM_OF_ONOS-1))); do
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002316 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 +00002317 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 -07002318 done
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002319else
2320 # voltha chart <= 2.4.2 uses single controller
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002321 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.controller.service=$_HOST --set services.controller.port=$_PORT"
Neha Sharmaa1c92ca2020-06-24 11:50:33 +00002322 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.controller.address=$_HOST:$_PORT"
David Bainbridge696bc632020-04-05 21:49:37 -07002323fi
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002324
Girish Kumarcc5f9172020-06-10 13:34:31 +00002325if [ "$WITH_TRACING" == "yes" ]; then
2326 VOLTHA_TRACING_CHART_NAME=$(resolve_chart_name "$VOLTHA_TRACING_CHART")
2327 _HOST="tracing-${VOLTHA_TRACING_CHART_NAME}-jaeger-agent.$INFRA_NS.svc"
2328 _PORT=6831
2329 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set tracing.enabled=true --set services.tracing_agent.address=$_HOST:$_PORT"
2330fi
2331
Test Userb5712372019-07-03 21:52:17 +00002332bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002333if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$VOLTHA_NS" "^voltha\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002334 espin "$NOT_VERIFIED"
David Bainbridgea965ca22020-06-09 17:45:04 -07002335 helm_install - "$VOLTHA_NS" voltha "$VOLTHA_CHART" "$VOLTHA_CHART_VERSION" "+voltha" "$_HELM_DESC VOLTHA Core"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002336else
David Bainbridged18f4942020-04-14 16:46:13 -07002337 espin "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002338fi
David Bainbridge696bc632020-04-05 21:49:37 -07002339INTERNAL_EXTRA_HELM_INSTALL_ARGS=
Test Userba1e7e72019-07-10 22:27:54 +00002340
David Bainbridge90fd8e32019-08-21 23:32:47 +00002341VOLTHA="voltha-ofagent-.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002342 rw-core.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002343 voltha-zookeeper-.*"
David Bainbridged18f4942020-04-14 16:46:13 -07002344wait_for_pods - "$VOLTHA_NS" "$EXPECT" "includes" "Waiting for VOLTHA Core to start" "$NO_LABEL" "$VOLTHA"
David Bainbridgee87067b2019-08-12 22:00:12 +00002345if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002346 NOW="$(date +%s)"
2347 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002348fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002349
David Bainbridge46505fb2019-10-01 21:13:20 +00002350if [ "$WITH_ADAPTERS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002351 STIME="$(date +%s)"
David Bainbridge46505fb2019-10-01 21:13:20 +00002352 EXPECT=0
David Bainbridgec7220622020-05-28 12:31:47 -07002353 if is_in "$WITH_ETCD" "yes,external"; then
2354 _HOST=etcd.$INFRA_NS.svc
David Bainbridge3517f6c2020-04-08 12:14:08 -07002355 _PORT=2379
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002356 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
2357 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.address=$_HOST:$_PORT"
David Bainbridged18f4942020-04-14 16:46:13 -07002358 elif [ "$WITH_ETCD" != "no" ]; then
2359 _HOST="$(echo "$WITH_ETCD" | cut -d: -f1)"
2360 _PORT="$(echo "$WITH_ETCD" | cut -s -d: -f2)"
David Bainbridge3517f6c2020-04-08 12:14:08 -07002361 _PORT=${_PORT:-2379}
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002362 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
2363 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.address=$_HOST:$_PORT"
David Bainbridge696bc632020-04-05 21:49:37 -07002364 fi
David Bainbridgec7220622020-05-28 12:31:47 -07002365 if is_in "$WITH_KAFKA" "yes,external"; then
2366 _HOST=kafka.$INFRA_NS.svc
David Bainbridge3517f6c2020-04-08 12:14:08 -07002367 _PORT=9092
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002368 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"
2369 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 -07002370 elif [ "$WITH_KAFKA" != "no" ]; then
2371 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
2372 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge3517f6c2020-04-08 12:14:08 -07002373 _PORT=${_PORT:-9092}
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002374 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"
2375 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 -07002376 fi
Girish Kumarcc5f9172020-06-10 13:34:31 +00002377 if [ "$WITH_TRACING" == "yes" ]; then
2378 VOLTHA_TRACING_CHART_NAME=$(resolve_chart_name "$VOLTHA_TRACING_CHART")
2379 _HOST="tracing-${VOLTHA_TRACING_CHART_NAME}-jaeger-agent.$INFRA_NS.svc"
2380 _PORT=6831
2381 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set tracing.enabled=true --set services.tracing_agent.address=$_HOST:$_PORT"
2382 fi
David Bainbridge46505fb2019-10-01 21:13:20 +00002383 echo -e "Verify Adapters $PLUG"
2384 if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then
2385 bspin - "Verify Simulated Adapters installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002386 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$ADAPTER_NS" "^sim\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002387 espin - "$NOT_VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002388 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 +00002389 else
David Bainbridged18f4942020-04-14 16:46:13 -07002390 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00002391 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002392 EXPECT="$((EXPECT + 2))"
David Bainbridge46505fb2019-10-01 21:13:20 +00002393 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07002394
David Bainbridge46505fb2019-10-01 21:13:20 +00002395 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
2396 bspin - "Verify OpenOLT Adapter installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002397 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$ADAPTER_NS" "^open-olt\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002398 espin - "$NOT_VERIFIED"
David Bainbridgea965ca22020-06-09 17:45:04 -07002399 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 +00002400 else
David Bainbridged18f4942020-04-14 16:46:13 -07002401 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00002402 fi
Matteo Scandolo67335f02020-04-09 11:19:53 -07002403 EXPECT="$((EXPECT + 1))"
David Bainbridge46505fb2019-10-01 21:13:20 +00002404 bspin - "Verify OpenONU Adapter installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002405 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$ADAPTER_NS" "^open-onu\$")" -ne 1 ]; then
Matteo Scandolo67335f02020-04-09 11:19:53 -07002406 _ORIGINAL_EXTRA_HELM_INSTALL_ARGS="$INTERNAL_EXTRA_HELM_INSTALL_ARGS"
2407 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set replicas.adapter_open_onu=$NUM_OF_OPENONU"
Girish Gowdra4cc5d8b2020-06-11 17:12:00 -07002408 if [ "$WITH_INCREMENTAL_EVTO_UPDATE" == "yes" ]; then
Girish Gowdra1c7ad4c2020-06-26 13:35:16 -07002409 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set defaults.incremental_evto_update=true"
Girish Gowdra4cc5d8b2020-06-11 17:12:00 -07002410 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002411 espin - "$NOT_VERIFIED"
David Bainbridgea965ca22020-06-09 17:45:04 -07002412 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 -07002413 INTERNAL_EXTRA_HELM_INSTALL_ARGS="$_ORIGINAL_EXTRA_HELM_INSTALL_ARGS"
David Bainbridge46505fb2019-10-01 21:13:20 +00002414 else
David Bainbridged18f4942020-04-14 16:46:13 -07002415 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00002416 fi
Matteo Scandolo67335f02020-04-09 11:19:53 -07002417 EXPECT=$((EXPECT + NUM_OF_OPENONU))
David Bainbridge46505fb2019-10-01 21:13:20 +00002418 fi
David Bainbridge696bc632020-04-05 21:49:37 -07002419 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07002420
David Bainbridge46505fb2019-10-01 21:13:20 +00002421 ADAPTERS="adapter-.*"
David Bainbridged18f4942020-04-14 16:46:13 -07002422 wait_for_pods - "$ADAPTER_NS" "$EXPECT" "includes" "Waiting for adapters to start" "$NO_LABEL" "$ADAPTERS"
David Bainbridge46505fb2019-10-01 21:13:20 +00002423 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002424 NOW="$(date +%s)"
2425 printtime $((NOW - STIME))
David Bainbridge46505fb2019-10-01 21:13:20 +00002426 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00002427fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002428
David Bainbridged18f4942020-04-14 16:46:13 -07002429if [ "$WITH_BBSIM" == "yes" ]; then
2430 STIME="$(date +%s)"
Test User7d866122019-07-09 17:52:35 +00002431 echo -e "Verify BBSIM $PLUG"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002432 bspin - "Verify BBSIM Installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002433 for instance in $(seq 0 $((NUM_OF_BBSIM-1))); do
Matteo Scandoloc2eb0672020-05-01 14:43:15 -07002434
2435 if [ "$LEGACY_BBSIM_INDEX" == "yes" ]; then
2436 if [ "$instance" -eq 0 ]; then
2437 instance_num=""
2438 else
2439 instance_num=$instance
2440 fi
David K. Bainbridge43422402020-03-06 07:41:22 -08002441 else
2442 instance_num=$instance
2443 fi
Matteo Scandoloc2eb0672020-05-01 14:43:15 -07002444
2445
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002446 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$BBSIM_NS" "^bbsim${instance_num}\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002447 espin - "$NOT_VERIFIED"
Matteo Scandolo6402d362020-08-24 12:31:06 -07002448
2449 if [[ $(semver_greater "$VOLTHA_BBSIM_CHART_VERSION" "3.1.0") == "true" ]]; then
2450 # this is the latest BBSim with support for TT
2451 # when we deploy multiple BBSims we need to update the configuration
2452 # to avoid overlapping tags.
2453 _TAG="$((900+instance))"
2454 BBSIM_TMP="$(mktemp -u)"
2455 sed -e "s/\":TAG:\"/$_TAG/g" "$BBSIM_CFG" > "$BBSIM_TMP"
2456
2457 INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set olt_id=$instance -f $BBSIM_TMP"
David Bainbridged9329af2020-05-01 11:58:52 -07002458 else
Matteo Scandolo6402d362020-08-24 12:31:06 -07002459 # these are older versio of BBSim
2460 S_TAG="$((900+instance))"
2461 INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set olt_id=$instance,s_tag=$S_TAG"
2462 if [ "$WITH_EAPOL" == "yes" ]; then
2463 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set auth=true"
2464 else
2465 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set auth=false"
2466 fi
2467 if [ "$WITH_DHCP" == "yes" ]; then
2468 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set dhcp=true"
2469 else
2470 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set dhcp=false"
2471 fi
David Bainbridged9329af2020-05-01 11:58:52 -07002472 fi
Matteo Scandolo6402d362020-08-24 12:31:06 -07002473
David Bainbridge33e56c72020-06-11 11:39:56 -07002474 if is_in "$WITH_KAFKA" "yes,external"; then
2475 _HOST=kafka.$INFRA_NS.svc
2476 _PORT=9092
2477 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafkaAddress=$_HOST:$_PORT"
2478 elif [ "$WITH_KAFKA" != "no" ]; then
2479 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
2480 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
2481 _PORT=${_PORT:-9092}
2482 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafkaAddress=$_HOST:$_PORT"
2483 fi
2484 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 -07002485 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
Matteo Scandolo6402d362020-08-24 12:31:06 -07002486 rm -f "$BBSIM_TMP"
David K. Bainbridge43422402020-03-06 07:41:22 -08002487 else
David Bainbridged18f4942020-04-14 16:46:13 -07002488 espin - "$VERIFIED"
David K. Bainbridge43422402020-03-06 07:41:22 -08002489 fi
2490 done
David Bainbridged18f4942020-04-14 16:46:13 -07002491 wait_for_pods - "$BBSIM_NS" "$NUM_OF_BBSIM" "includes" "Waiting for BBSIM to start" "$BBSIM_LABEL" "bbsim*"
David Bainbridgee87067b2019-08-12 22:00:12 +00002492 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002493 NOW="$(date +%s)"
2494 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002495 fi
Test User7d866122019-07-09 17:52:35 +00002496fi
2497
divyadesai59f987a2020-05-27 12:11:33 +00002498if [ "$WITH_EFK" == "yes" ]; then
2499 STIME="$(date +%s)"
2500 echo -e "Verify EFK $PLUG"
2501 bspin - "Verify EFK Installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002502 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 +00002503 espin - "$NOT_VERIFIED"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002504 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^elasticsearch\$")" -ne 1 ]; then
divyadesai59f987a2020-05-27 12:11:33 +00002505 helm_install - "$INFRA_NS" elasticsearch "$ELASTICSEARCH_CHART" "$ELASTICSEARCH_CHART_VERSION" elasticsearch "$_HELM_DESC elasticsearch"
2506 fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002507 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^kibana\$")" -ne 1 ]; then
divyadesai59f987a2020-05-27 12:11:33 +00002508 helm_install - "$INFRA_NS" kibana "$KIBANA_CHART" "$KIBANA_CHART_VERSION" kibana "$_HELM_DESC kibana"
2509 fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002510 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^fluentd\$")" -ne 1 ]; then
divyadesai59f987a2020-05-27 12:11:33 +00002511 helm_install - "$INFRA_NS" fluentd "$FLUENTD_ELASTICSEARCH_CHART" "$FLUENTD_ELASTICSEARCH_CHART_VERSION" fluentd-elasticsearch "$_HELM_DESC fluentd-elasticsearch"
2512 fi
2513 else
2514 espin - "$VERIFIED"
2515 fi
2516 EXPECT=2 # for elastic and kibana
2517 if [ "$TYPE" == "minimal" ]; then
2518 EXPECT=$((EXPECT + 2)) # for fluentd on worker 2 worker nodes
2519 else
2520 EXPECT=$((EXPECT + 3)) # for fluentd on worker 3 worker nodes
2521 fi
2522 if [ "$SCHEDULE_ON_CONTROL_NODES" == "yes" ]; then
2523 EXPECT=$((EXPECT + 1)) # for fluentd on the control plan node
2524 fi
2525
2526 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for EFK to start" "$NO_LABEL" "fluentd-* elasticsearch-* kibana-*"
2527 if [ "$WITH_TIMINGS" == "yes" ]; then
2528 NOW="$(date +%s)"
2529 printtime $((NOW - STIME))
2530 fi
2531fi
2532
David Bainbridge309099c2020-05-05 08:47:29 -07002533if [ "$CONFIG_SADIS" == "external" ]; then
2534 STIME="$(date +%s)"
2535 echo -e "Verify BBSIM SADIS Service $PLUG"
2536 bspin - "Verify required configmap"
2537 (set -x; kubectl -n "$BBSIM_NS" delete --ignore-not-found configmap kube-config >>"$LOG" 2>&1) >>"$LOG" 2>&1
2538 (set -x; kubectl -n "$BBSIM_NS" create configmap kube-config "--from-file=kube_config=$KUBECONFIG" >>"$LOG" 2>&1) >>"$LOG" 2>&1
2539 espin - "$VERIFIED"
2540 bspin - "Verify BBSIM SADIS Service Installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002541 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$BBSIM_NS" "^bbsim-sadis-server\$")" -ne 1 ]; then
David Bainbridge309099c2020-05-05 08:47:29 -07002542 espin - "$NOT_VERIFIED"
Matteo Scandolo871fd982020-07-23 11:46:51 -07002543 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"
2544 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
David Bainbridge309099c2020-05-05 08:47:29 -07002545 else
2546 espin - "$VERIFIED"
2547 fi
2548 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 +00002549
Matteo Scandolo21660442020-07-17 11:05:21 -07002550 if is_in "$WITH_ONOS" "yes,classic,legacy"; then
Ubuntu7135e6a2020-06-30 01:46:08 +00002551 if kubectl get -n "$BBSIM_NS" svc/bbsim-sadis-server-bbsim-sadis-server >/dev/null 2>&1; then
2552 BBSIM_SADIS_SVC="bbsim-sadis-server-bbsim-sadis-server"
2553 else
2554 BBSIM_SADIS_SVC="bbsim-sadis-server"
2555 fi
2556 push_onos_config "json" \
2557 "[optional] Push ONOS configuration for custom SADIS and Bandwidth Profile servers" \
2558 "network/configuration/apps/org.opencord.sadis" \
2559 "$(cat <<EOJ | tr -d '[:space:]'
2560{
2561 "sadis": {
2562 "integration": {
2563 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:58080/subscribers/%s",
2564 "cache": {
2565 "enabled": true,
2566 "maxsize": 50,
2567 "ttl": "PT1m"
2568 }
2569 }
2570 },
2571 "bandwidthprofile": {
2572 "integration": {
2573 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:58080/profiles/%s",
2574 "cache": {
2575 "enabled": true,
2576 "maxsize": 50,
2577 "ttl": "PT1m"
2578 }
2579 }
2580 }
2581}
2582EOJ
2583)"
2584 fi
David Bainbridge309099c2020-05-05 08:47:29 -07002585 if [ "$WITH_TIMINGS" == "yes" ]; then
2586 NOW="$(date +%s)"
2587 printtime $((NOW - STIME))
2588 fi
2589fi
2590
David Bainbridged18f4942020-04-14 16:46:13 -07002591if [ "$WITH_RADIUS" == "yes" ]; then
2592 STIME="$(date +%s)"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002593 echo -e "Verify RADIUS $LOCK"
2594 bspin - "Verify RADIUS Installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002595 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^radius\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002596 espin - "$NOT_VERIFIED"
David Bainbridge879439b2020-06-12 15:59:35 -07002597 helm_install - "$INFRA_NS" radius "$RADIUS_CHART" "$RADIUS_CHART_VERSION" "+radius" "$_HELM_DESC RADIUS"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002598 else
David Bainbridged18f4942020-04-14 16:46:13 -07002599 espin - "$VERIFIED"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002600 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002601 wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for RADIUS to start" "$NO_LABEL" "radius-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00002602 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002603 NOW="$(date +%s)"
2604 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002605 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002606fi
2607
David Bainbridged18f4942020-04-14 16:46:13 -07002608if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
2609 STIME="$(date +%s)"
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002610 bspin - "Forward VOLTHA API port $FORWARD"
David Bainbridge1d2c5842020-06-03 15:29:07 -07002611 kill_port_forward voltha-api voltha-voltha-api
2612 VOLTHA_PREFIX=
2613 if kubectl get -n "$VOLTHA_NS" "svc/voltha-voltha-api" >/dev/null 2>&1; then
2614 VOLTHA_PREFIX="voltha-"
2615 fi
Matteo Scandolo21660442020-07-17 11:05:21 -07002616
David Bainbridge1d2c5842020-06-03 15:29:07 -07002617 port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-api" "$VOLTHA_API_PORT:55555"
David Bainbridged18f4942020-04-14 16:46:13 -07002618 espin - "$VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002619 if is_in "$WITH_ETCD" "yes,external"; then
David Bainbridge696bc632020-04-05 21:49:37 -07002620 bspin - "Forward VOLTHA ETCD port $FORWARD"
David Bainbridgec7220622020-05-28 12:31:47 -07002621 kill_port_forward "etcd"
2622 port_forward "$INFRA_NS" "etcd" "$VOLTHA_ETCD_PORT:2379"
David Bainbridged18f4942020-04-14 16:46:13 -07002623 espin - "$VERIFIED"
David Bainbridge696bc632020-04-05 21:49:37 -07002624 fi
David Bainbridgec7220622020-05-28 12:31:47 -07002625 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridge696bc632020-04-05 21:49:37 -07002626 bspin - "Forward VOLTHA Kafka port $FORWARD"
David Bainbridgec7220622020-05-28 12:31:47 -07002627 kill_port_forward "kafka"
2628 port_forward "$INFRA_NS" kafka "$VOLTHA_KAFKA_PORT:9092"
David Bainbridged18f4942020-04-14 16:46:13 -07002629 espin - "$VERIFIED"
David Bainbridge696bc632020-04-05 21:49:37 -07002630 fi
divyadesai59f987a2020-05-27 12:11:33 +00002631 if [ "$WITH_EFK" == "yes" ]; then
2632 bspin - "Forward EFK port $FORWARD"
2633 kill_port_forward elasticsearch-master
2634 kill_port_forward kibana-kibana
2635 port_forward "$INFRA_NS" elasticsearch-master "$ELASTICSEARCH_PORT:9200"
2636 port_forward "$INFRA_NS" kibana-kibana "$KIBANA_PORT:5601"
2637 espin - "$VERIFIED"
2638 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -07002639 if [ "$WITH_PPROF" == "yes" ]; then
David Bainbridge1d2c5842020-06-03 15:29:07 -07002640 VOLTHA_OPENOLT_PREFIX=
2641 if kubectl get -n "$ADAPTER_NS" "svc/open-olt-adapter-open-olt-profiler" >/dev/null 2>&1; then
2642 VOLTHA_OPENOLT_PREFIX="open-olt-"
2643 fi
David Bainbridge879439b2020-06-12 15:59:35 -07002644 bspin - "Forward PProf ports port $FORWARD"
2645 kill_port_forward voltha-rw-core-profiler voltha-voltha-rw-core-profiler
2646 kill_port_forward adapter-open-olt-profiler open-olt-adapter-open-olt-profiler
2647 kill_port_forward voltha-of-agent-profiler voltha-voltha-of-agent-profiler
2648 port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-rw-core-profiler" "$VOLTHA_PPROF_PORT:6060"
2649 port_forward "$ADAPTER_NS" "${VOLTHA_OPENOLT_PREFIX}adapter-open-olt-profiler" "$OPENOLT_PPROF_PORT:6060"
2650 port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-of-agent-profiler" "$OFAGENT_PPROF_PORT:6060"
2651 espin - "$VERIFIED"
Matteo Scandoloefee0432020-05-05 13:56:20 -07002652 fi
Girish Kumarcc5f9172020-06-10 13:34:31 +00002653 if [ "$WITH_TRACING" == "yes" ]; then
2654 bspin - "Forward VOLTHA Tracing GUI port $FORWARD"
2655 VOLTHA_TRACING_CHART_NAME=$(resolve_chart_name "$VOLTHA_TRACING_CHART")
2656 kill_port_forward "tracing-${VOLTHA_TRACING_CHART_NAME}-jaeger-gui"
2657 port_forward "$INFRA_NS" "tracing-${VOLTHA_TRACING_CHART_NAME}-jaeger-gui" "$TRACING_GUI_PORT:16686"
2658 espin - "$VERIFIED"
2659 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002660 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002661 NOW="$(date +%s)"
2662 printtime $((NOW - STIME))
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002663 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00002664fi
Test User3d7ad8e2019-07-03 06:15:44 +00002665
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002666if is_in "$WITH_ONOS" "yes,legacy,classic" && [ "$WITH_RADIUS" != "no" ]; then
David Bainbridge879439b2020-06-12 15:59:35 -07002667 SVC_NAME=radius
2668 if kubectl get -n "$INFRA_NS" "svc/radius-freeradius" >/dev/null 2>&1; then
2669 SVC_NAME="radius-freeradius"
2670 fi
2671 _HOST="$SVC_NAME.$INFRA_NS.svc"
David Bainbridge696bc632020-04-05 21:49:37 -07002672 _PORT=1812
David Bainbridged18f4942020-04-14 16:46:13 -07002673 if [ "$WITH_RADIUS" != "yes" ]; then
2674 _HOST="$(echo "$WITH_RADIUS" | cut -d: -f1)"
2675 _PORT="$(echo "$WITH_RADIUS" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07002676 _PORT=${_PORT:-1812}
2677 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002678 bspin "Configure ONOS RADIUS Connection $GEAR"
David Bainbridged18f4942020-04-14 16:46:13 -07002679 (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
2680 espin "$VERIFIED"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002681fi
2682
divyadesai59f987a2020-05-27 12:11:33 +00002683if [ "$WITH_EFK" == "yes" ]; then
2684 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"
2685# fi
2686fi
2687
David Bainbridge99ac7a22019-08-31 02:26:43 +00002688if [ "$WITH_CHAOS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002689 STIME="$(date +%s)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002690 echo -e "Verify kube-monkey $LOCK"
2691 bspin - "Verify kube-monkey Installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002692 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed kube-monkey "^monkey\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002693 espin - "$NOT_VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002694 helm_install - kube-monkey monkey ./kube-monkey/helm/kubemonkey latest - "$_HELM_DESC Chaos Monkey"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002695 else
David Bainbridged18f4942020-04-14 16:46:13 -07002696 espin - "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002697 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002698 wait_for_pods - "kube-monkey" 1 "includes" "Waiting for Chaos to start" "$NO_LABEL" "monkey-.*"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002699 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002700 NOW="$(date +%s)"
2701 printtime $((NOW - STIME))
David Bainbridge99ac7a22019-08-31 02:26:43 +00002702 fi
2703fi
2704
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002705bspin "Create voltctl configuration file"
David Bainbridged18f4942020-04-14 16:46:13 -07002706(set -x; mkdir -p "$HOME/.volt" >>"$LOG" 2>&1) >>"$LOG" 2>&1
2707MIN_VC_VERSION="$(echo -e "1.0.15\n$VC_VERSION" | sort -V | head -1)"
2708if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002709 KAFKA_FLAG="-k localhost:$VOLTHA_KAFKA_PORT"
2710 SERVER_FLAG="-s localhost:$VOLTHA_API_PORT"
2711 ETCD_FLAG=
2712 if [ "$MIN_VC_VERSION" == "1.0.15" ]; then
2713 ETCD_FLAG="-e localhost:$VOLTHA_ETCD_PORT"
2714 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002715else
David Bainbridgec7220622020-05-28 12:31:47 -07002716 KAFKA_FLAG="-k $(get_service_ep "$INFRA_NS" kafka)"
David Bainbridged18f4942020-04-14 16:46:13 -07002717 SERVER_FLAG="-s $(get_service_ep "$VOLTHA_NS" voltha-api)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002718 ETCD_FLAG=
2719 if [ "$MIN_VC_VERSION" == "1.0.15" ]; then
David Bainbridgec7220622020-05-28 12:31:47 -07002720 ETCD_FLAG="-e $(get_service_ep "$INFRA_NS" etcd)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002721 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002722fi
David Bainbridgea965ca22020-06-09 17:45:04 -07002723CMD=("voltctl $KAFKA_FLAG $SERVER_FLAG $ETCD_FLAG config")
David Bainbridged18f4942020-04-14 16:46:13 -07002724(set -x; ${CMD[*]} > "$HOME/.volt/config-$NAME" 2>>"$LOG") >>"$LOG" 2>&1
David Bainbridgea965ca22020-06-09 17:45:04 -07002725#(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 -07002726espin "$VERIFIED"
Test User08ebbd92019-07-03 17:15:39 +00002727
David Bainbridge0774b232019-08-02 06:37:19 +00002728if [ ! -f "$NAME-env.sh" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002729 touch "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002730fi
2731
David Bainbridge596f30d2019-07-30 17:07:59 +00002732for O in $ALL_OPTIONS; do
David Bainbridged18f4942020-04-14 16:46:13 -07002733 VAL="$(eval echo "\$$O")"
2734 if [ -n "$VAL" ] && [ "$(grep -c "^export $O=" "$NAME-env.sh")" -eq 0 ]; then
2735 echo "export $O=\"$(eval echo "\$$O")\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002736 fi
2737done
2738
David Bainbridged18f4942020-04-14 16:46:13 -07002739if [ "$DEPLOY_K8S" == "yes" ] && [ "$(grep -c "^export KUBECONFIG=" "$NAME-env.sh")" -eq 0 ]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002740 echo "export KUBECONFIG=\"$HOME/.kube/kind-config-voltha-$NAME\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002741fi
2742
David Bainbridged18f4942020-04-14 16:46:13 -07002743if [ "$(grep -c "^export VOLTCONFIG=" "$NAME-env.sh")" -eq 0 ]; then
2744 echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002745fi
2746
David Bainbridged18f4942020-04-14 16:46:13 -07002747if [ "$(grep -c "^export PATH=" "$NAME-env.sh")" -eq 0 ]; then
2748 echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002749fi
2750
Test User7d866122019-07-09 17:52:35 +00002751echo ""
David Bainbridged18f4942020-04-14 16:46:13 -07002752echo "Please issue the following commands in your terminal to ensure that you" | tee -a "$LOG"
2753echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a "$LOG"
2754echo "tools required by VOLTHA in your command path. " | tee -a "$LOG"
2755echo "" | tee -a "$LOG"
2756echo -en "$BOLD"
2757if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002758 echo "export KUBECONFIG=\"$HOME/.kube/kind-config-voltha-$NAME\"" | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00002759fi
David Bainbridged18f4942020-04-14 16:46:13 -07002760echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" | tee -a "$LOG"
2761echo "export PATH=$GOPATH/bin:\$PATH" | tee -a "$LOG"
2762echo -en "$NORMAL"
2763echo "" | tee -a "$LOG"
2764echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a "$LOG"
Test User08ebbd92019-07-03 17:15:39 +00002765
David Bainbridge712afb82019-08-14 19:55:58 +00002766if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002767 NOW="$(date +%s)"
2768 echo -e "$CLOCK ${BOLD}TOTAL: $(duration $((NOW - TOTAL_START_TIME)))${NORMAL}"
David Bainbridge712afb82019-08-14 19:55:58 +00002769fi