blob: 939829a5c0a2b0c13823f64291fc6f3ba4edeaec [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 Scandolocdfb4e22020-09-11 19:46:59 -0700113VOLTHA_BBSIM_CHART_VERSION=${VOLTHA_BBSIM_CHART_VERSION:-latest}
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 K. Bainbridge55007402020-09-21 12:49:48 -0700136ETCD_CHART=${ETCD_CHART:-incubator/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)
Matteo Scandolo734fe962020-09-02 17:47:16 -0700208# inspired by https://stackoverflow.com/questions/4023830/how-to-compare-two-strings-in-dot-separated-version-format-in-bash
Matteo Scandolo6402d362020-08-24 12:31:06 -0700209function semvercompare() {
210 if [[ "$1" == "$2" ]]
211 then
212 echo 0
213 return
214 fi
215
216 local tmp1 tmp2
217 tmp1=$(echo "${1//v/}" | awk -F'-' '{print $1}')
218 tmp2=$(echo "${2//v/}" | awk -F'-' '{print $1}')
219
220 local IFS=.
221 # shellcheck disable=SC2206
222 local i ver1=($tmp1) ver2=($tmp2)
223
224 # fill empty fields in ver1 with zeros
225 for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
226 do
227 ver1[i]=0
228 done
229 for ((i=0; i<${#ver1[@]}; i++))
230 do
231 if [[ -z ${ver2[i]} ]]
232 then
233 # fill empty fields in ver2 with zeros
234 ver2[i]=0
235 fi
236 if ((10#${ver1[i]} > 10#${ver2[i]}))
237 then
238 echo 1
239 return
240 fi
241 if ((10#${ver1[i]} < 10#${ver2[i]}))
242 then
243 echo 2
244 return
245 fi
246 done
247 echo 0
248 return
249}
250
Matteo Scandolo99dbed32020-09-03 14:11:27 -0700251# returns true if v1 is greater than v2 (false if they are the same)
Matteo Scandolo6402d362020-08-24 12:31:06 -0700252function semver_greater() {
253 local v1
254 local v2
Matteo Scandolo99dbed32020-09-03 14:11:27 -0700255 v1="$1" v2="$2"
Matteo Scandolo6402d362020-08-24 12:31:06 -0700256
257 # shellcheck disable=SC2128
Matteo Scandolo48890712020-09-11 15:48:24 -0700258 if [[ ! "$v1" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
259 # if the version is custom, we assume it's newer than master
Matteo Scandolo6402d362020-08-24 12:31:06 -0700260 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
Matteo Scandolo99dbed32020-09-03 14:11:27 -0700273# returns true if v1 is lesser than v2 (false if they are the same)
Matteo Scandolo6402d362020-08-24 12:31:06 -0700274function semver_lesser() {
275 local v1
276 local v2
Matteo Scandolo99dbed32020-09-03 14:11:27 -0700277 v1="$1" v2="$2"
Matteo Scandolo6402d362020-08-24 12:31:06 -0700278
279 # shellcheck disable=SC2128
Matteo Scandolo48890712020-09-11 15:48:24 -0700280 if [[ ! "$v1" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
281 # if the version is custom, we assume it's newer than master
Matteo Scandolo6402d362020-08-24 12:31:06 -0700282 echo "false"
283 return
284 fi
285
286 # shellcheck disable=SC2128
287 res=$(semvercompare "$v1" "$v2")
288 if [[ $res == 2 ]]; then
289 echo "true"
290 else
291 echo "false"
292 fi
293}
294
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000295# Used to verify configuration values are set to "yes" or "no" value or convert
296# equivalents to "yes" or "no"
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700297YES="y,yes,t,true,1"
298NO="n,no,f,false,0"
299YES_OR_NO="$YES,$NO"
300
301# If the given VAR matches a truth value then normalize that
302# value, else return original value
303function normalize_yes_no() {
304 local VAR VAL
305 VAR=$1
306 VAL="$(eval echo "\$$VAR")"
307 if ! is_in "$VAL" "$YES_OR_NO"; then
308 echo "$VAL"
309 return 1
310 fi
311 if is_in "$VAL" "$YES"; then
312 echo "yes"
313 else
314 echo "no"
315 fi
316 return 0
317}
318
319# If the given VAR matches a truth value then normalize that
320# value, else display an error
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000321function verify_yes_no() {
David Bainbridged18f4942020-04-14 16:46:13 -0700322 local VAR VAL
323 VAR=$1
324 VAL="$(eval echo "\$$VAR")"
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700325 if ! is_in "$VAL" "$YES_OR_NO"; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000326 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid '$VAR' value of '$VAL'. Should be 'yes' or 'no'${NORMAL}"
327 echo "INVALID"
328 return 1
329 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700330 if is_in "$VAL" "$YES"; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000331 echo "yes"
332 else
333 echo "no"
334 fi
335 return 0
336}
Test User7d866122019-07-09 17:52:35 +0000337
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000338ALL_YES_NO="\
David K. Bainbridge484d80c2020-03-05 21:44:34 -0800339 ENABLE_ONOS_EXTRANEOUS_RULES \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000340 WITH_TIMINGS \
341 WITH_BBSIM \
divyadesai59f987a2020-05-27 12:11:33 +0000342 WITH_EFK \
Girish Kumarcc5f9172020-06-10 13:34:31 +0000343 WITH_TRACING \
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800344 WITH_EAPOL \
345 WITH_DHCP \
346 WITH_IGMP \
David Bainbridge99ac7a22019-08-31 02:26:43 +0000347 WITH_CHAOS \
David Bainbridge46505fb2019-10-01 21:13:20 +0000348 WITH_ADAPTERS \
349 WITH_SIM_ADAPTERS \
350 WITH_OPEN_ADAPTERS \
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800351 WITH_PORT_FORWARDS \
Matteo Scandoloefee0432020-05-05 13:56:20 -0700352 WITH_PPROF \
Girish Gowdra4cc5d8b2020-06-11 17:12:00 -0700353 WITH_INCREMENTAL_EVTO_UPDATE \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000354 JUST_K8S \
355 DEPLOY_K8S \
356 INSTALL_ONOS_APPS \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000357 INSTALL_KUBECTL \
358 INSTALL_HELM \
David Bainbridge7f8bf992020-04-08 21:53:22 -0700359 HELM_USE_UPGRADE \
David Bainbridge46505fb2019-10-01 21:13:20 +0000360 UPDATE_HELM_REPOS \
David Bainbridge4f1b5562019-08-19 04:46:52 +0000361 WAIT_ON_DOWN \
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700362 VOLTHA_DOWN_ON_TIMEOUT \
Matteo Scandoloc2eb0672020-05-01 14:43:15 -0700363 LEGACY_BBSIM_INDEX \
David Bainbridgee4d11ca2020-05-08 10:21:10 -0700364 SCHEDULE_ON_CONTROL_NODES \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000365 "
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000366
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700367OPT_YES_NO="\
368 CONFIG_SADIS \
369 WITH_KAFKA \
370 WITH_RADIUS \
371 WITH_ETCD \
372 WITH_ONOS \
373 "
374
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000375ALL_OPTIONS="\
376 NAME \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000377 $ALL_YES_NO \
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700378 $OPT_YES_NO \
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700379 WAIT_TIMEOUT \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000380 VOLTHA_LOG_LEVEL \
381 VOLTHA_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000382 VOLTHA_CHART_VERSION \
383 VOLTHA_BBSIM_CHART \
384 VOLTHA_BBSIM_CHART_VERSION \
David Bainbridge879439b2020-06-12 15:59:35 -0700385 BBSIM_SADIS_SERVER_CHART \
386 BBSIM_SADIS_SERVER_CHART_VERSION \
Girish Kumarcc5f9172020-06-10 13:34:31 +0000387 VOLTHA_TRACING_CHART \
388 VOLTHA_TRACING_CHART_VERSION \
uottrembd5a20572020-03-06 09:15:01 +0100389 NUM_OF_BBSIM \
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700390 NUM_OF_WORKER_NODES \
391 NUM_OF_CONTROLLER_NODES \
392 NUM_OF_KAFKA \
393 NUM_OF_ETCD \
divyadesai59f987a2020-05-27 12:11:33 +0000394 ELASTICSEARCH_CHART \
395 ELASTICSEARCH_CHART_VERSION \
396 KIBANA_CHART \
397 KIBANA_CHART_VERSION \
398 FLUENTD_ELASTICSEARCH_CHART \
399 FLUENTD_ELASTICSEARCH_CHART_VERSION \
Matteo Scandolo67335f02020-04-09 11:19:53 -0700400 NUM_OF_OPENONU \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000401 VOLTHA_ADAPTER_SIM_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000402 VOLTHA_ADAPTER_SIM_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000403 VOLTHA_ADAPTER_OPEN_OLT_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000404 VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000405 VOLTHA_ADAPTER_OPEN_ONU_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000406 VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION \
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800407 ONOS_CHART \
Andrea Campanella21323292019-12-18 11:44:19 -0800408 ONOS_CHART_VERSION \
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700409 ONOS_CLASSIC_CHART \
410 ONOS_CLASSIC_CHART_VERSION \
David Bainbridgecf546362020-04-21 23:18:50 -0700411 KAFKA_CHART \
David Bainbridgeb9093522020-04-15 14:32:44 -0700412 KAFKA_CHART_VERSION \
David Bainbridge879439b2020-06-12 15:59:35 -0700413 ETCD_CHART \
414 ETCD_CHART_VERSION \
415 RADIUS_CHART \
416 RADIUS_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000417 ONOS_API_PORT \
418 ONOS_SSH_PORT \
Hardik Windlassb3147602020-03-09 16:59:15 +0530419 SADIS_CFG \
Matteo Scandolo6402d362020-08-24 12:31:06 -0700420 BBSIM_CFG \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000421 VOLTHA_API_PORT \
422 VOLTHA_SSH_PORT \
423 VOLTHA_ETCD_PORT \
divyadesai59f987a2020-05-27 12:11:33 +0000424 ELASTICSEARCH_PORT \
425 KIBANA_PORT \
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800426 VOLTHA_KAFKA_PORT \
Matteo Scandoloefee0432020-05-05 13:56:20 -0700427 VOLTHA_PPROF_PORT \
428 OPENOLT_PPROF_PORT \
Matteo Scandolo65c35192020-05-13 10:41:21 -0700429 OFAGENT_PPROF_PORT \
Girish Kumarcc5f9172020-06-10 13:34:31 +0000430 TRACING_GUI_PORT \
David K. Bainbridge8f7f30b2020-01-08 13:06:16 -0800431 VK_RELEASE \
432 KIND_VERSION \
433 VOLTCTL_VERSION \
David Bainbridgea34993d2020-04-01 09:15:42 -0700434 HELM_VERSION \
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700435 NUM_OF_ONOS \
436 NUM_OF_ATOMIX \
David Bainbridge6ca40102020-04-08 11:30:40 -0700437 VOLTHA_NS \
438 ADAPTER_NS \
439 INFRA_NS \
440 BBSIM_NS \
David Bainbridge7db44002020-04-09 12:54:29 -0700441 SADIS_BANDWIDTH_PROFILES \
442 SADIS_SUBSCRIBERS \
David Bainbridgeb4bbde12020-06-25 14:46:36 -0700443 PF_ADDRESS \
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700444 KIND_CFG_FILE \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000445 "
David Bainbridge01294952019-07-30 19:33:45 +0000446
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000447# Iterate over yes/no configuration options and validate
448for VAR in $ALL_YES_NO; do
David Bainbridged18f4942020-04-14 16:46:13 -0700449 eval "$VAR"="$(verify_yes_no "$VAR")"
450 if [ "$(eval echo "\$$VAR")" == "INVALID" ]; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000451 exit 1;
452 fi
453done
David Bainbridgeb270c202019-07-26 01:44:42 +0000454
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700455# Iterate over optional yes/no configuration options and
456# normalize values if they are truth values
457for VAR in $OPT_YES_NO; do
458 eval "$VAR"="$(normalize_yes_no "$VAR")"
459done
David Bainbridge15f6f232020-03-30 09:15:43 -0700460
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700461# check number (range) of bbsim, max bbsim must not exceed 10 instances!
462# note: instances will be numbered from 0 to 9
463if [ "$1" == "up" ]; then
464 if [ "$NUM_OF_BBSIM" -lt 1 ]; then
465 >&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}"
466 exit 1
467 fi
468 if [ "$NUM_OF_BBSIM" -gt "$MAX_NUM_OF_BBSIM" ]; then
469 >&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}"
470 exit 1
471 fi
472
473 if [ "$NUM_OF_OPENONU" -lt 1 ]; then
474 >&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}"
475 exit 1
476 fi
477 if [ "$NUM_OF_OPENONU" -gt "$MAX_NUM_OF_OPENONU" ]; then
478 >&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}"
479 exit 1
480 fi
481
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700482 HAVE_CLUSTER="$(kind get clusters 2>/dev/null | grep -c "voltha-$NAME")"
483 if [ "$HAVE_CLUSTER" -eq 0 ]; then
484 # If the user has specified a kind cluster configuration file,
485 # 'KIND_CFG_FILE` then we need to gleem from that file the number
486 # of worker and controller nodes as this overrides any setting of
487 # these values
488 if [ -n "$KIND_CFG_FILE" ]; then
489 NUM_OF_WORKER_NODES="$(sed 's/ //g' "$KIND_CFG_FILE" | grep -c "^-role:worker$")"
490 NUM_OF_CONTROLLER_NODES="$(sed 's/ //g' "$KIND_CFG_FILE" | grep -c "^-role:control-plane$")"
491 fi
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700492
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700493 # check that NUM_OF_KAFKA, NUM_OF_ONOS, NUM_OF_ATOMIX, NUM_OF_ETCD is:
494 # <= NUM_OF_WORKER_NODES + 1 if SCHEDULE_ON_CONTROL_NODES == y
495 # <= NUM_OF_WORKER_NODES if SCHEDULE_ON_CONTROL_NODES == n
496 SCHEDULABLE_NODES=$NUM_OF_WORKER_NODES
497
498 if [ "$SCHEDULE_ON_CONTROL_NODES" == "yes" ]; then
499 SCHEDULABLE_NODES=$((NUM_OF_CONTROLLER_NODES+NUM_OF_WORKER_NODES))
500 fi
501 else
502 TOTAL_NODES=$(kubectl get --all-namespaces nodes -o name | wc -l)
503 NUM_OF_CONTROLLER_NODES=$(kubectl get --all-namespaces nodes -l node-role.kubernetes.io/master -o name | wc -l)
504 NUM_OF_WORKER_NODES=$((TOTAL_NODES - NUM_OF_CONTROLLER_NODES))
505 # shellcheck disable=SC2016
506 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')
507 rm -f "$TMP_KUBECFG"
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700508 fi
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700509 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"
510
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700511 if is_in "$WITH_KAFKA" "yes,external" && [ ! "$NUM_OF_KAFKA" -le "$SCHEDULABLE_NODES" ]; then
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700512 >&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}"
513 exit 1
514 fi
515
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700516 if is_in "$WITH_ETCD" "yes,external" && [ ! "$NUM_OF_ETCD" -le "$SCHEDULABLE_NODES" ]; then
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700517 >&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}"
518 exit 1
519 fi
520
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700521 if is_in "$WITH_ONOS" "yes,legacy,classic,micro"; then
522 if [ ! "$NUM_OF_ATOMIX" -le "$SCHEDULABLE_NODES" ]; then
523 >&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}"
524 exit 1
525 fi
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700526
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700527 if [ ! "$NUM_OF_ONOS" -le "$SCHEDULABLE_NODES" ]; then
528 >&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}"
529 exit 1
530 fi
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700531 fi
532fi
533
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700534# normalize non-truth value options
535if is_in "$WITH_KAFKA" "e,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -0700536 WITH_KAFKA="external"
537fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700538if is_in "$WITH_ETCD" "e,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -0700539 WITH_ETCD="external"
540fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700541if is_in "$WITH_ONOS" "l,legacy"; then
542 WITH_ONOS="legacy"
543elif is_in "$WITH_ONOS" "c,classic"; then
544 WITH_ONOS="classic"
545elif is_in "$WITH_ONOS" "u,m,micro"; then
546 WITH_ONOS="micro"
David Bainbridge29c31cb2020-04-06 09:45:50 -0700547fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700548
549if [ "$WITH_ONOS" == "micro" ]; then
550 >&2 echo -e "${YELLOW}${BOLD}${ERROR}WARNING:${NORMAL}${YELLOW} The value specified as WITH_ONOS, '$WITH_ONOS', is not valid.${NORMAL}"
551 exit 1
David Bainbridge29c31cb2020-04-06 09:45:50 -0700552fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700553
554if is_in "$WITH_ONOS" "yes,classic"; then
555 # there is an extra utility required if we are using ONOS CLASSIC as
556 # the chart for classic specifies images differently
557 EXTRA_TOOLS+=" yq"
David Bainbridge76afd812020-04-06 09:53:52 -0700558fi
David Bainbridge696bc632020-04-05 21:49:37 -0700559
David Bainbridge22db5dd2020-05-26 12:21:21 -0700560if [ "$LEGACY_BBSIM_INDEX" == "no" ]; then
561 BBSIM_SADIS_SVC="bbsim0"
562else
563 BBSIM_SADIS_SVC="bbsim"
564fi
565
566SADIS_SUBSCRIBERS=${SADIS_SUBSCRIBERS:-http://$BBSIM_SADIS_SVC.$VOLTHA_NS.svc:50074/v2/subscribers/%s}
567SADIS_BANDWIDTH_PROFILES=${SADIS_BANDWIDTH_PROFILES:-http://$BBSIM_SADIS_SVC.$VOLTHA_NS.svc:50074/v2/bandwidthprofiles/%s}
568
David Bainbridged18f4942020-04-14 16:46:13 -0700569if [ "$HELM_USE_UPGRADE" == "yes" ]; then
David Bainbridge7f8bf992020-04-08 21:53:22 -0700570 _HELM_DESC="Upgrade/Install"
571else
572 _HELM_DESC="Install"
573fi
574
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800575# Check for prerequiste tools
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700576TOOLS="curl sed jq $EXTRA_TOOLS"
David Bainbridged18f4942020-04-14 16:46:13 -0700577if [ "$DEPLOY_K8S" == "yes" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800578 TOOLS+=" docker"
579fi
580NOT_FOUND=""
581for T in $TOOLS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700582 if [ -z "$(command -v "$T")" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800583 NOT_FOUND+=" $T"
584 fi
585done
586
David Bainbridged18f4942020-04-14 16:46:13 -0700587if [ -n "$NOT_FOUND" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800588 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} The following required tools where not found, please install them:$NOT_FOUND"
589 exit 1
590fi
591
David Bainbridged18f4942020-04-14 16:46:13 -0700592TIMEOUT_SECONDS="$(parseDuration "$WAIT_TIMEOUT")"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700593
David Bainbridge0774b232019-08-02 06:37:19 +0000594mkdir -p .voltha
595touch .voltha/ports
David Bainbridged18f4942020-04-14 16:46:13 -0700596HAVE="$(grep "$NAME" .voltha/ports)"
David Bainbridge0774b232019-08-02 06:37:19 +0000597if [ "$HAVE X" == " X" ]; then
598 # Find free port prefix
599 START=81
600 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700601 if [ "$(grep -c $START .voltha/ports)" -eq 0 ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000602 break
603 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700604 START="$((START + 1))"
David Bainbridge0774b232019-08-02 06:37:19 +0000605 done
David Bainbridged18f4942020-04-14 16:46:13 -0700606 DELTA="$((START - 81))"
David Bainbridgea2595422019-10-22 03:54:28 +0000607 ONOS_API_PORT=${ONOS_API_PORT:-${START}81}
608 ONOS_SSH_PORT=${ONOS_SSH_PORT:-${START}01}
David Bainbridged18f4942020-04-14 16:46:13 -0700609 VOLTHA_API_PORT=${VOLTHA_API_PORT:-5$((55 + DELTA))55}
610 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$((50 + DELTA))22}
611 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$((23 + DELTA))79}
612 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$((90 + DELTA))92}
Matteo Scandoloefee0432020-05-05 13:56:20 -0700613 VOLTHA_PPROF_PORT=${VOLTHA_PPROF_PORT:-$((60 + DELTA))60}
614 OPENOLT_PPROF_PORT=${OPENOLT_PPROF_PORT:-$((60 + DELTA))61}
Matteo Scandolo65c35192020-05-13 10:41:21 -0700615 OFAGENT_PPROF_PORT=${OFAGENT_PPROF_PORT:-$((60 + DELTA))62}
divyadesai59f987a2020-05-27 12:11:33 +0000616 ELASTICSEARCH_PORT=${ELASTICSEARCH_PORT:-$((92 + DELTA))00}
617 KIBANA_PORT=${KIBANA_PORT:-$((56 + DELTA))01}
Girish Kumarcc5f9172020-06-10 13:34:31 +0000618 TRACING_GUI_PORT=${TRACING_GUI_PORT:-1$((66 + DELTA))86}
Test User01ed0642019-07-03 20:17:06 +0000619else
David Bainbridged18f4942020-04-14 16:46:13 -0700620 VALUES="$(echo "$HAVE" | sed -e 's/\s//g' | cut -d= -f2)"
621 ONOS_API_PORT=${ONOS_API_PORT:-$(echo "$VALUES" | cut -d, -f1)}
622 ONOS_SSH_PORT=${ONOS_SSH_PORT:-$(echo "$VALUES" | cut -d, -f2)}
623 VOLTHA_API_PORT=${VOLTHA_API_PORT:-$(echo "$VALUES" | cut -d, -f3)}
624 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$(echo "$VALUES" | cut -d, -f4)}
625 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$(echo "$VALUES" | cut -d, -f5)}
626 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(echo "$VALUES" | cut -d, -f6)}
Matteo Scandoloefee0432020-05-05 13:56:20 -0700627 VOLTHA_PPROF_PORT=${VOLTHA_PPROF_PORT:-$(echo "$VALUES" | cut -d, -f7)}
628 OPENOLT_PPROF_PORT=${OPENOLT_PPROF_PORT:-$(echo "$VALUES" | cut -d, -f8)}
Matteo Scandolo65c35192020-05-13 10:41:21 -0700629 OFAGENT_PPROF_PORT=${OFAGENT_PPROF_PORT:-$(echo "$VALUES" | cut -d, -f9)}
divyadesai59f987a2020-05-27 12:11:33 +0000630 ELASTICSEARCH_PORT=${ELASTICSEARCH_PORT:-$(echo "$VALUES" | cut -d, -f10)}
631 KIBANA_PORT=${KIBANA_PORT:-$(echo "$VALUES" | cut -d, -f11)}
Girish Kumarcc5f9172020-06-10 13:34:31 +0000632 TRACING_GUI_PORT=${TRACING_GUI_PORT:-$(echo "$VALUES" | cut -d, -f12)}
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800633
Matteo Scandoloefee0432020-05-05 13:56:20 -0700634 # Some ports were added after the .voltha/ports files was created.
635 # Calculate the original DELTA from the VOLTHA_SSH_PORT so that it can
636 # be used to set up newer port-forwards.
637 DELTA="$((VOLTHA_SSH_PORT/100-50))"
638
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800639 if [ -z "$VOLTHA_KAFKA_PORT" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -0700640 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$((90 + DELTA))92}
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800641 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -0700642
643 if [ -z "$VOLTHA_PPROF_PORT" ]; then
divyadesai59f987a2020-05-27 12:11:33 +0000644 VOLTHA_PPROF_PORT=${VOLTHA_PPROF_PORT:-$((60 + DELTA))60}
Matteo Scandoloefee0432020-05-05 13:56:20 -0700645 fi
646 if [ -z "$OPENOLT_PPROF_PORT" ]; then
divyadesai59f987a2020-05-27 12:11:33 +0000647 OPENOLT_PPROF_PORT=${OPENOLT_PPROF_PORT:-$((60 + DELTA))61}
Matteo Scandoloefee0432020-05-05 13:56:20 -0700648 fi
Matteo Scandolo65c35192020-05-13 10:41:21 -0700649 if [ -z "$OFAGENT_PPROF_PORT" ]; then
divyadesai59f987a2020-05-27 12:11:33 +0000650 OFAGENT_PPROF_PORT=${OFAGENT_PPROF_PORT:-$((60 + DELTA))62}
651 fi
652
653 if [ -z "$ELASTICSEARCH_PORT" ]; then
654 ELASTICSEARCH_PORT=${ELASTICSEARCH_PORT:-$((92 + DELTA))00}
655 fi
divyadesai59f987a2020-05-27 12:11:33 +0000656 if [ -z "$KIBANA_PORT" ]; then
657 KIBANA_PORT=${KIBANA_PORT:-$((56 + DELTA))01}
Matteo Scandolo65c35192020-05-13 10:41:21 -0700658 fi
Girish Kumarcc5f9172020-06-10 13:34:31 +0000659
660 if [ -z "$TRACING_GUI_PORT" ]; then
661 TRACING_GUI_PORT=${TRACING_GUI_PORT:-1$((66 + DELTA))86}
662 fi
Test User01ed0642019-07-03 20:17:06 +0000663fi
664
David Bainbridged18f4942020-04-14 16:46:13 -0700665PORTTMP="$(mktemp -u)"
666grep -v "$NAME" .voltha/ports > "$PORTTMP"
Girish Kumarcc5f9172020-06-10 13:34:31 +0000667echo "$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 -0700668cp "$PORTTMP" .voltha/ports
669rm -f "$PORTTMP"
David Bainbridge0774b232019-08-02 06:37:19 +0000670
David Bainbridge27790d62019-08-13 22:43:19 +0000671export ONOS_API_PORT ONOS_SSH_PORT
David Bainbridge01294952019-07-30 19:33:45 +0000672
Test Userd87942b2019-07-03 07:20:24 +0000673IDX=1
David Bainbridgee87067b2019-08-12 22:00:12 +0000674CLOCK="TIME:"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000675SPIN_PARTS=
676NOT_VERIFIED=
David Bainbridgef858a022019-08-14 21:25:11 +0000677THEX=
678BUILD=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000679VERIFIED=
680HELM=
681OLD_KEY=
682BIRD=
683HIGH_VOLTAGE=
684PLUG=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000685FORWARD=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000686GO=
687DOWNLOAD=
688GEAR=
689NO_ENTRY=
690LOCK=
691
David Bainbridged18f4942020-04-14 16:46:13 -0700692if [ "$FANCY" -eq 1 ]; then
693 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 +0000694 CLOCK="\xe2\x8f\xb1"
David Bainbridgef858a022019-08-14 21:25:11 +0000695 THEX="${RED}${BOLD}\xe2\x9c\x97\x20${NORMAL}"
David Bainbridgef858a022019-08-14 21:25:11 +0000696 BUILD="${YELLOW}${BOLD}\xf0\x9f\x8f\x97${NORMAL}"
697 NOT_VERIFIED="$BUILD"
698 VERIFIED="${GREEN}${BOLD}\xe2\x9c\x93\x20${NORMAL}"
699 HELM="${BLUE}${BOLD}\xE2\x8E\x88${NORMAL}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000700 OLD_KEY="\xF0\x9F\x97\x9D"
701 BIRD="\xF0\x9F\x90\xA6"
702 HIGH_VOLTAGE="\xE2\x9A\xA1"
703 PLUG="\xF0\x9F\xa7\xa9"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000704 FORWARD="\xE2\x87\xA8"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000705 GO="\xf0\x9f\x9a\x80"
706 DOWNLOAD="\xf0\x9f\x93\xa5"
707 GEAR="\xe2\x9a\x99"
708 NO_ENTRY="\xe2\x9b\x94"
709 LOCK="\xf0\x9f\x94\x92"
710fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700711
David Bainbridge712afb82019-08-14 19:55:58 +0000712duration() {
David Bainbridged18f4942020-04-14 16:46:13 -0700713 local h m s t
714 h="$(($1 / 3600))"
715 m="$(($1 % 3600 / 60))"
716 s="$(($1 % 60))"
717 t=""
David Bainbridgee87067b2019-08-12 22:00:12 +0000718
David Bainbridged18f4942020-04-14 16:46:13 -0700719 if [ "$h" -gt 0 ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +0000720 t="$t${h}h"
721 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700722 if [ "$m" -gt 0 ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +0000723 t="$t${m}m"
724 fi
David Bainbridge712afb82019-08-14 19:55:58 +0000725 echo "$t${s}s"
726}
727
728printtime() {
David Bainbridged18f4942020-04-14 16:46:13 -0700729 local INDENT
David Bainbridge712afb82019-08-14 19:55:58 +0000730 if [ "$1" == "-" ]; then
731 INDENT=" "
732 shift
733 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700734 echo -e "$INDENT $CLOCK $(duration "$1")"
David Bainbridgee87067b2019-08-12 22:00:12 +0000735}
736
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700737bspin() {
Test Userd87942b2019-07-03 07:20:24 +0000738 IDX=1
David Bainbridged18f4942020-04-14 16:46:13 -0700739 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700740 if [ "$1" == "-" ]; then
741 INDENT=" "
742 shift
743 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700744 if [ "$FANCY" -eq 0 ]; then
745 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000746 if [ "$LINE X" == " X" ]; then
747 return
748 fi
749 echo -e "$CIVIS$INDENT$*"
750 else
751 echo -en "$CIVIS$INDENT $*"
752 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700753}
754
755sspin() {
David Bainbridged18f4942020-04-14 16:46:13 -0700756 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700757 if [ "$1" == "-" ]; then
758 INDENT=" "
759 shift
760 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700761 if [ "$FANCY" -eq 0 ]; then
762 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000763 if [ "$LINE X" == " X" ]; then
764 return
765 fi
766 echo -e "$INDENT$*"
767 else
David Bainbridged18f4942020-04-14 16:46:13 -0700768 C="$(echo "$SPIN_PARTS" | cut '-d ' -f "$IDX")"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000769 echo -en "\r$INDENT$C $*"
David Bainbridged18f4942020-04-14 16:46:13 -0700770 IDX="$((IDX + 1))"
771 if [ "$IDX" -gt 8 ]; then
David Bainbridge38dc1e82019-08-12 15:18:45 +0000772 IDX=1
773 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700774 fi
775}
776
777espin() {
David Bainbridged18f4942020-04-14 16:46:13 -0700778 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700779 if [ "$1" == "-" ]; then
780 INDENT=" "
781 shift
782 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700783 if [ "$FANCY" -eq 0 ]; then
784 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000785 if [ "$LINE X" == " X" ]; then
786 return
787 fi
788 echo -e "$INDENT$*"
789 else
790 echo -e "\r$INDENT$*$CNORM"
791 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700792}
793
David Bainbridged18f4942020-04-14 16:46:13 -0700794if [ "$1" == "get" ] && [ "$2" == "voltconfig" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000795 echo "$HOME/.volt/config-$NAME"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000796 exit
797fi
798
David Bainbridgee4d11ca2020-05-08 10:21:10 -0700799if [ $# -ne 1 ] || ! is_in "$1" "up,down,dump,clean"; then
David Bainbridgeac7f8072019-08-01 22:15:33 +0000800 >&2 echo "What wouild you like to do today:"
801 >&2 echo " up - bring up voltha"
802 >&2 echo " down - tear down voltha"
803 >&2 echo " dump - create a debug dump of running system"
804 exit 1
805fi
806
divyadesai59f987a2020-05-27 12:11:33 +0000807do_curl() {
808 local DATA_ARGS CREDS CMD_ECHO CMD_OUTPUT SC_OUTPUT WAIT_START INDENTA EXTRAA NOW
809 local INDENT=$1
810 local OP=$2
811 local USER=$3
812 local PASS=$4
813 local URL=$5
814 local DATA_TYPE=$6
815 local DATA=$7
816 local MSG=$8
817 local VALID_RESULTS=$9
818 local EXTRA=${10}
819 local ICON=${11}
820
821 # Turn into an array for passing
822 INDENTA=()
823 if [ -n "$INDENT" ]; then
824 INDENTA=("$INDENT")
825 fi
826 IFS=' ' read -r -a EXTRAA <<< "$EXTRA"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000827
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800828 # Thanks to the latest version of ONOS using the return code 207 this gets a
829 # whole lot nastier. Can't thank them enough for doing this. So in order to
830 # capture the command and the output in the log file as well as capture the
831 # status code to verify it is 200 and not 207 mutltiple files and a bit of
832 # hackery must be used. Thanks again ONOS.
David Bainbridged18f4942020-04-14 16:46:13 -0700833 CMD_ECHO="$(mktemp -u)"
834 CMD_OUTPUT="$(mktemp -u)"
835 SC_OUTPUT="$(mktemp -u)"
836 WAIT_START="$(date +%s)"
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800837
divyadesai59f987a2020-05-27 12:11:33 +0000838 CREDS=()
839 if [ -n "$USER" ]; then
840 CREDS=("--user" "$USER:$PASS")
841 fi
842
843 DATA_ARGS=()
844 if [ -n "$DATA" ]; then
845 if [ "$DATA_TYPE" == "file" ]; then
846 DATA_ARGS=("--data" "@$DATA")
847 elif [ "$DATA_TYPE" == "json" ]; then
848 DATA_ARGS=("--data" "$DATA")
849 fi
850 fi
851
852 bspin "${INDENTA[@]}" "$MSG" "$ICON"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000853 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700854 NOW="$(date +%s)"
855 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
divyadesai59f987a2020-05-27 12:11:33 +0000856 espin "${INDENTA[@]}" "$THEX"
David Bainbridged18f4942020-04-14 16:46:13 -0700857 rm -f "$CMD_ECHO" "$CMD_OUTPUT" "$SC_OUTPUT"
divyadesai59f987a2020-05-27 12:11:33 +0000858 doTimeout "$MSG"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700859 fi
divyadesai59f987a2020-05-27 12:11:33 +0000860 (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
861 RESULT=$?
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800862 # Dump everything to the log
David Bainbridged18f4942020-04-14 16:46:13 -0700863 cat "$CMD_ECHO" >> "$LOG"
864 test -r "$CMD_OUTPUT" && cat "$CMD_OUTPUT" >> "$LOG"
865 SC="$(cat "$SC_OUTPUT")"
866 echo "RESPONSE CODE: $SC" >> "$LOG"
867 echo "ERROR CODE: $RESULT" >> "$LOG"
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800868
869 # clean up temp files
David Bainbridged18f4942020-04-14 16:46:13 -0700870 rm -f "$CMD_ECHO" "$CMD_OUTPUT" "$SC_OUTPUT"
divyadesai59f987a2020-05-27 12:11:33 +0000871 if [ "$RESULT" -eq 0 ] && is_in "$SC" "$VALID_RESULTS"; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000872 break
873 fi
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800874 sleep 1
divyadesai59f987a2020-05-27 12:11:33 +0000875 sspin "${INDENTA[@]}"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000876 done
divyadesai59f987a2020-05-27 12:11:33 +0000877 espin "${INDENTA[@]}" "$VERIFIED"
878}
879
880push_onos_config() {
881 local DATA_TYPE=$1
882 local MSG=$2
883 local RESOURCE=$3
884 local DATA=$4
885
886 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 +0000887}
888
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800889check_onos_app_active() {
David Bainbridged18f4942020-04-14 16:46:13 -0700890 local APP_ID WAIT_START RESULT NOW
891 APP_ID=$1
892 WAIT_START="$(date +%s)"
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800893
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700894 bspin - "Checking that $APP_ID is active $CLOCK"
895 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700896 NOW="$(date +%s)"
897 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700898 espin - "$THEX"
899 doTimeout "waiting for ONOS application activation '$APP_ID'"
900 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700901 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 -0700902 break
903 fi
904 sleep 1
905 sspin -
906 done
907 sleep 5 # OSGI components take a little longer that the app to activate
David Bainbridged18f4942020-04-14 16:46:13 -0700908 espin - "$VERIFIED"
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800909}
910
David Bainbridge4f1b5562019-08-19 04:46:52 +0000911override_onos_app() {
David Bainbridged18f4942020-04-14 16:46:13 -0700912 local APP NAME WAIT_START NOW
913 APP=$1
914 NAME="$(basename "$APP" | sed -e 's/^[0-9][0-9]*-//g' -e 's/-.*$//g')"
915 WAIT_START="$(date +%s)"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700916
David Bainbridge4f1b5562019-08-19 04:46:52 +0000917 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700918 NOW="$(date +%s)"
919 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700920 espin - "$THEX"
921 doTimeout "waiting to overwrite ONOS application '$APP'"
922 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +0000923 sspin -
924 # Attempt to delete old version (if it exists)
David Bainbridged18f4942020-04-14 16:46:13 -0700925 (set -x; curl --fail -sSL --user karaf:karaf -X DELETE "http://$_ONOS_API_EP/onos/v1/applications/$NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
926 RESULT=$?
David Bainbridge4f1b5562019-08-19 04:46:52 +0000927 sspin -
David Bainbridged18f4942020-04-14 16:46:13 -0700928 if [ $RESULT -ne 0 ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000929 continue
930 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700931 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 +0000932 break
933 fi
934 sleep .2
935 done
936}
937
938activate_onos_app() {
David Bainbridged18f4942020-04-14 16:46:13 -0700939 local MSG APP WAIT_START NOW
940 MSG="$1"
941 APP=$2
942 WAIT_START="$(date +%s)"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000943
944 bspin - "$MSG $GO"
945 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700946 NOW="$(date +%s)"
947 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700948 espin - "$THEX"
949 doTimeout "waiting to activate ONOS application '$APP'"
950 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +0000951 sspin -
David Bainbridged18f4942020-04-14 16:46:13 -0700952 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 +0000953 break
954 fi
955 sleep .2
956 done
957 espin - "$VERIFIED"
958}
959
960count_pods() {
David Bainbridged18f4942020-04-14 16:46:13 -0700961 local NAMESPACE STATES LABELS CMD PODS
962 NAMESPACE=$1; shift
David Bainbridge4f1b5562019-08-19 04:46:52 +0000963 if [ "$NAMESPACE" == "all-namespaces" ]; then
964 NAMESPACE="--all-namespaces"
965 else
966 NAMESPACE="-n $NAMESPACE"
967 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700968 STATES=$1; shift
969 LABELS=$1; shift
970 CMD=("kubectl get $NAMESPACE $LABELS pod")
971 PODS=$(${CMD[*]} -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}")
David Bainbridge4f1b5562019-08-19 04:46:52 +0000972 local COUNT=0
973 local PATTERNS="$*"
974 for POD in $PODS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700975 local NAME STATE CONTAINERS TOTAL FOUND
976 NAME="$(echo "$POD" | cut -d/ -f 1)"
977 STATE="$(echo "$POD" | cut -d/ -f 2)"
978 CONTAINERS="$(echo "$POD" | cut -d/ -f 3 | sed -e 's/_/ /g')"
979 if [ "$STATES" == "*" ] || [ "$(echo "$STATES" | grep -c ":$STATE:")" -ne 0 ]; then
980 TOTAL="$(echo "$CONTAINERS" | wc -w)"
981 FOUND="$(echo "$CONTAINERS" | grep -o true | wc -l)"
982 if [ "$TOTAL" -eq "$FOUND" ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000983 for PATTERN in $PATTERNS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700984 if [[ "$NAME" =~ $PATTERN ]]; then
985 COUNT="$((COUNT + 1))"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000986 break
987 fi
988 done
989 fi
990 fi
991 done
David Bainbridge4f1b5562019-08-19 04:46:52 +0000992 echo $COUNT
993}
994
995wait_for_pods() {
David Bainbridged18f4942020-04-14 16:46:13 -0700996 local INDENT NAMESPACE EXPECT TYPE MESSAGE LABELS PATTERNS STATES HAVE ALL WAIT_START NOW
David Bainbridge4f1b5562019-08-19 04:46:52 +0000997 if [ "$1" == "-" ]; then
998 INDENT=$1; shift
999 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001000 NAMESPACE=$1; shift
1001 EXPECT=$1; shift
1002 TYPE=$1; shift
1003 MESSAGE=$1; shift
1004 LABELS=$1; shift
1005 PATTERNS=("$*")
1006 STATES=":Running:"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001007 if [ "$TYPE" == "not" ]; then
1008 STATES="*"
1009 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001010 HAVE="$(count_pods "$NAMESPACE" "$STATES" "$LABELS" "${PATTERNS[@]}")"
1011 ALL=$HAVE
David Bainbridge4f1b5562019-08-19 04:46:52 +00001012 if [ "$TYPE" == "only" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001013 ALL="$(count_pods "all-namespaces" "*" ".*")"
David Bainbridge4f1b5562019-08-19 04:46:52 +00001014 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001015 COUNT="$((300 / 15))"
1016 WAIT_START="$(date +%s)"
1017 bspin "$INDENT" "$MESSAGE"
1018 sspin "$INDENT"
1019 if [ "$HAVE" -ne "$EXPECT" ] || [ "$ALL" -ne "$HAVE" ]; then
1020 while [ "$HAVE" -ne "$EXPECT" ] || [ "$ALL" -ne "$HAVE" ]; do
1021 NOW="$(date +%s)"
1022 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
1023 espin "$INDENT" "$THEX"
David Bainbridge52e6e9d2020-03-23 13:48:27 -07001024 doTimeout "waiting for PODs to start"
1025 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001026 sspin "$INDENT"
1027 COUNT="$((COUNT - 1))"
1028 if [ "$COUNT" -eq 0 ]; then
1029 HAVE="$(count_pods "$NAMESPACE" "$STATES" "$LABELS" "${PATTERNS[@]}")"
1030 ALL="$HAVE"
David Bainbridge4f1b5562019-08-19 04:46:52 +00001031 if [ "$TYPE" == "only" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001032 ALL="$(count_pods "all-namespaces" "*" ".*")"
David Bainbridge4f1b5562019-08-19 04:46:52 +00001033 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001034 COUNT="$((300 / 15))"
David Bainbridge4f1b5562019-08-19 04:46:52 +00001035 fi
1036 sleep .15
1037 done
1038 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001039 espin "$INDENT" "$VERIFIED"
1040 if [ "$HAVE" -ne "$EXPECT" ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +00001041 return 1
1042 fi
1043 return 0
1044}
1045
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001046port_forward() {
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001047 local NS=$1; shift
1048 local SVC=$1; shift
1049 local PORTS="$*"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001050 local TAG=$SVC-$NAME
1051
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001052 (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 -08001053}
1054
1055kill_port_forward() {
David Bainbridge1d2c5842020-06-03 15:29:07 -07001056 local TAG P_IDS PARENTS KIDS UNKNOWN PP_ID PF
1057
1058 while [ $# -gt 0 ]; do
1059 PF=$1; shift
1060 TAG=
1061 if [ "$PF" != "__ALL__" ]; then
Andrea Campanellaeacf7f42020-10-15 14:46:33 +02001062 TAG="$PF"
David Bainbridge1d2c5842020-06-03 15:29:07 -07001063 fi
1064 PARENTS=
1065 KIDS=
1066 UNKNOWN=
1067 # shellcheck disable=SC2009
1068 P_IDS="$(ps e -ww -A | grep "_TAG=$TAG" | grep -v grep | awk '{print $1}')"
1069 if [ -n "$P_IDS" ]; then
1070 for P_ID in $P_IDS; do
1071 PP_ID="$(ps -o ppid "$P_ID" | tail -n +2)"
1072 if [ -n "$PP_ID" ]; then
1073 if [ "$PP_ID" -eq 1 ]; then
1074 PARENTS="$PARENTS $P_ID"
1075 else
1076 KIDS="$KIDS $P_ID"
1077 fi
David Bainbridgec6871d22019-11-13 17:10:31 +00001078 else
David Bainbridge1d2c5842020-06-03 15:29:07 -07001079 UNKNOWN="$UNKNOWN $P_ID"
David Bainbridgec6871d22019-11-13 17:10:31 +00001080 fi
David Bainbridge1d2c5842020-06-03 15:29:07 -07001081 done
1082 if [ -n "$PARENTS" ]; then
1083 # shellcheck disable=SC2086
1084 while ps -h $PARENTS >/dev/null 2>&1; do
1085 (set -x; eval "kill -9 $PARENTS" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1086 done
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001087 fi
David Bainbridge1d2c5842020-06-03 15:29:07 -07001088 if [ -n "$KIDS" ]; then
1089 # shellcheck disable=SC2086
1090 while ps -h $KIDS >/dev/null 2>&1; do
1091 (set -x; eval "kill -9 $KIDS" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1092 done
1093 fi
1094 if [ -n "$UNKNOWN" ]; then
1095 # shellcheck disable=SC2086
1096 while ps -h $UNKNOWN >/dev/null 2>&1; do
1097 (set -x; eval "kill -9 $UNKNOWN" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1098 done
1099 fi
1100 fi
1101 done
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001102}
1103
Girish Kumarcc5f9172020-06-10 13:34:31 +00001104resolve_chart_name() {
1105 helm inspect chart "$1" | grep "^name:" | awk '{print $2}'
1106}
1107
David Bainbridgecf546362020-04-21 23:18:50 -07001108resolve_chart_version() {
1109 [ "$2" != "latest" ] && echo "$2" && return
1110 helm inspect chart "$1" | grep "^version:" | awk '{print $2}'
1111}
1112
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07001113# Compares two semver-formatted version strings (e.g. 2.4.3)
1114# Returns 0 if $1 == $2, returns 1 if $1 > $2 and returns 2 if $1 < $2
1115compare_versions() {
1116 [ "$1" == "$2" ] && return 0
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07001117 local lowest
1118 lowest=$(echo -e "$1\n$2" | sort -V | head -1)
1119 [ "$lowest" == "$1" ] && return 2
1120 return 1
1121}
1122
David Bainbridgeac7f8072019-08-01 22:15:33 +00001123if [ "$1" == "down" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001124 echo "Tearing down voltha cluster $NAME"
1125 LOG="down-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -07001126 date -u +"%Y%m%dT%H%M%SZ" >"$LOG"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001127 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 -07001128 if is_in "$WITH_ONOS" "yes,legacy,classic"; then
David Bainbridge696bc632020-04-05 21:49:37 -07001129 bspin "Remove port-forwards: onos-ui-$NAME"
1130 kill_port_forward onos-ui
1131 sspin "Remove port-forwards: onos-ssh-$NAME$CEOL"
1132 kill_port_forward onos-ssh
David K. Bainbridge2aa08da2020-07-31 12:49:45 -07001133 sspin "Remove port-forwards: onos-onos-classic-hs-$NAME$CEOL"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001134 kill_port_forward onos-onos-classic-hs
David Bainbridge696bc632020-04-05 21:49:37 -07001135 fi
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001136 sspin "Remove port-forwards: voltha-api-$NAME$CEOL"
David Bainbridge1d2c5842020-06-03 15:29:07 -07001137 kill_port_forward voltha-api voltha-voltha-api
David Bainbridgec7220622020-05-28 12:31:47 -07001138 if is_in "$WITH_ETCD" "yes,external"; then
1139 sspin "Remove port-forwards: etcd-$NAME$CEOL"
1140 kill_port_forward "etcd"
David Bainbridge696bc632020-04-05 21:49:37 -07001141 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001142 if is_in "$WITH_KAFKA" "yes,external"; then
1143 sspin "Remove port-forwards: kafka-$NAME$CEOL"
1144 kill_port_forward "kafka"
David Bainbridge696bc632020-04-05 21:49:37 -07001145 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -07001146
Andrea Campanellaeacf7f42020-10-15 14:46:33 +02001147 if is_in "$WITH_BBSIM" "yes"; then
1148 sspin "Remove port-forwards: bbsim$CEOL"
1149 kill_port_forward bbsim
1150 fi
1151
Matteo Scandoloefee0432020-05-05 13:56:20 -07001152 if [ "$WITH_PPROF" == "yes" ]; then
David Bainbridgec7220622020-05-28 12:31:47 -07001153 sspin "Remove port-forwards: *-profiler$CEOL"
David Bainbridge1d2c5842020-06-03 15:29:07 -07001154 kill_port_forward voltha-rw-core-profiler voltha-voltha-rw-core-profiler
1155 kill_port_forward voltha-of-agent-profiler voltha-voltha-of-agent-profiler
David Bainbridgec7220622020-05-28 12:31:47 -07001156 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
David Bainbridge1d2c5842020-06-03 15:29:07 -07001157 kill_port_forward adapter-open-olt-profiler open-olt-adapter-open-olt-profiler
David Bainbridgec7220622020-05-28 12:31:47 -07001158 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -07001159 fi
1160
Girish Kumarcc5f9172020-06-10 13:34:31 +00001161 if [ "$WITH_TRACING" == "yes" ]; then
1162 sspin "Remove port-forwards: tracing-$NAME$CEOL"
1163 VOLTHA_TRACING_CHART_NAME=$(resolve_chart_name "$VOLTHA_TRACING_CHART")
1164 kill_port_forward "tracing-${VOLTHA_TRACING_CHART_NAME}-jaeger-gui"
1165 fi
1166
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001167 espin "$VERIFIED Remove port-forwards$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -07001168 if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridgeac7f8072019-08-01 22:15:33 +00001169 if [ -x ./bin/kind ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001170 bspin "Delete Kubernetes Kind Cluster"
David Bainbridged18f4942020-04-14 16:46:13 -07001171 (set -x; ./bin/kind delete cluster --name "voltha-$NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1172 espin "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001173 else
David Bainbridge0774b232019-08-02 06:37:19 +00001174 espin "$NO_ENTRY Delete Kubernetes Kind Cluster: kind command not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001175 fi
1176 else
David Bainbridge309099c2020-05-05 08:47:29 -07001177 if [ "$CONFIG_SADIS" == "external" ]; then
1178 bspin "Remove configmap for BBSIM SADIS server"
1179 (set -x; kubectl -n "$BBSIM_NS" delete --ignore-not-found configmap kube-config >>"$LOG" 2>&1) >>"$LOG" 2>&1
1180 espin "$VERIFIED"
1181 fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001182
1183 if [ "$HELM_MAJOR" -le 2 ]; then
1184 EXISTS=$(helm list --output json 2>/dev/null | jq -r '.Releases | .[] | .Name + "," + .Namespace')
1185 else
1186 EXISTS=$(helm list --all-namespaces --output json 2>/dev/null | jq -r '.[] | .name + "," + .namespace')
1187 fi
David Bainbridge76afd812020-04-06 09:53:52 -07001188 EXPECT="voltha"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001189 if is_in "$WITH_ONOS" "yes,legacy,classic"; then
David Bainbridge696bc632020-04-05 21:49:37 -07001190 EXPECT+=" onos"
1191 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001192 if [ "$WITH_RADIUS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001193 EXPECT+=" radius"
1194 fi
David Bainbridge309099c2020-05-05 08:47:29 -07001195 if [ "$CONFIG_SADIS" == "external" ]; then
1196 EXPECT+=" bbsim-sadis-server"
1197 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001198 if [ "$WITH_BBSIM" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001199 EXPECT+=" bbsim"
1200 fi
divyadesai59f987a2020-05-27 12:11:33 +00001201 if [ "$WITH_EFK" == "yes" ]; then
1202 EXPECT+=" elasticsearch kibana fluentd"
1203 fi
Girish Kumarcc5f9172020-06-10 13:34:31 +00001204 if [ "$WITH_TRACING" == "yes" ]; then
1205 EXPECT+=" tracing"
1206 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001207 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001208 EXPECT+=" open-olt open-onu"
1209 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001210 if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001211 EXPECT+=" sim"
1212 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001213 if is_in "$WITH_ETCD" "yes,external"; then
1214 EXPECT+=" etcd"
David Bainbridge76afd812020-04-06 09:53:52 -07001215 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001216 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -07001217 EXPECT+=" kafka"
1218 fi
David Bainbridge0774b232019-08-02 06:37:19 +00001219 bspin "Remove Helm Deployments"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001220 for i in $EXISTS; do
David K. Bainbridge43422402020-03-06 07:41:22 -08001221 for j in $EXPECT; do
David Bainbridged18f4942020-04-14 16:46:13 -07001222 if [[ "$i" =~ $j ]]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001223 __NAME=$(echo "$i" | cut -d, -f1)
1224 __NS=$(echo "$i" | cut -d, -f2)
1225 sspin "Remove Helm Deployments: $__NS:$__NAME$CEOL"
1226 if [ "$HELM_MAJOR" -le 2 ]; then
1227 (set -x; helm delete --no-hooks --purge "$__NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1228 else
1229 (set -x; helm uninstall --no-hooks --namespace "$__NS" "$__NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1230 fi
David K. Bainbridge43422402020-03-06 07:41:22 -08001231 fi
1232 done
uottrembb16d3982020-02-28 08:34:36 +01001233 done
David Bainbridge0774b232019-08-02 06:37:19 +00001234 espin "$VERIFIED Remove Helm Deployments$CEOL"
David Bainbridge4f1b5562019-08-19 04:46:52 +00001235 if [ "$WAIT_ON_DOWN" == "yes" ]; then
Matteo Scandoloe93c9eb2020-06-03 12:08:51 -07001236 PODS="voltha-ofagent.* voltha-rw-core.*"
David Bainbridge76afd812020-04-06 09:53:52 -07001237 INFRA_PODS=
1238 ADAPT_PODS=
1239 SIM_PODS=
divyadesai59f987a2020-05-27 12:11:33 +00001240 EFK_PODS=
David Bainbridged18f4942020-04-14 16:46:13 -07001241 if [ "$WITH_RADIUS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001242 PODS+=" radius.*"
1243 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001244 if [ "$WITH_BBSIM" == "yes" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -07001245 SIM_PODS+=" bbsim.*"
David Bainbridge696bc632020-04-05 21:49:37 -07001246 fi
divyadesai59f987a2020-05-27 12:11:33 +00001247 if [ "$WITH_EFK" == "yes" ]; then
1248 EFK_PODS+=" kibana-* elasticsearch-* fluentd-*"
1249 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001250 if [ "$WITH_OPEN_ADAPTERS" ] || [ "$WITH_SIM_ADAPTERS" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -07001251 ADAPT_PODS+=" adapter-*"
David Bainbridge696bc632020-04-05 21:49:37 -07001252 fi
Girish Kumarcc5f9172020-06-10 13:34:31 +00001253 if [ "$WITH_TRACING" == "yes" ]; then
1254 INFRA_PODS+=" jaeger.*"
1255 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001256 if is_in "$WITH_ONOS" "yes,legacy,classic"; then
David Bainbridge76afd812020-04-06 09:53:52 -07001257 INFRA_PODS+=" onos-.*"
1258 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001259 if is_in "$WITH_ETCD" "yes,external"; then
1260 INFRA_PODS+=" etcd.*"
David Bainbridge76afd812020-04-06 09:53:52 -07001261 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001262 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -07001263 INFRA_PODS+=" kafka.*"
1264 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001265 if [ -n "$SIM_PODS" ]; then
1266 wait_for_pods "$BBSIM_NS" 0 "not" "Waiting for BBSIM PODs to terminate" "$BBSIM_LABEL" "$SIM_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -07001267 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001268 if [ -n "$INFRA_PODS" ]; then
1269 wait_for_pods "$INFRA_NS" 0 "not" "Waiting for infrastructure PODs to terminate" "$NO_LABEL" "$INFRA_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -07001270 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001271 if [ -n "$ADAPT_PODS" ]; then
1272 wait_for_pods "$ADAPTER_NS" 0 "not" "Waiting for adapter PODs to terminate" "$NO_LABEL" "$ADAPT_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -07001273 fi
divyadesai59f987a2020-05-27 12:11:33 +00001274 if [ -n "$EFK_PODS" ]; then
1275 wait_for_pods "$INFRA_NS" 0 "not" "Waiting for EFK PODs to terminate" "$NO_LABEL" "$EFK_PODS"
1276 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001277 wait_for_pods "$VOLTHA_NS" 0 "not" "Waiting for VOLTHA PODs to terminate" "$NO_LABEL" "$PODS"
David Bainbridge4f1b5562019-08-19 04:46:52 +00001278 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +00001279 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001280 exit
David Bainbridgeac7f8072019-08-01 22:15:33 +00001281fi
1282
1283if [ "$1" == "dump" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001284 LOG="dump-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -07001285 TS="$(date -u +"%Y%m%dT%H%M%SZ")"
1286 if [ -n "$DUMP_FROM" ]; then
1287 TS=${DUMP_FROM//[:-]}
David Bainbridge76514a02019-10-08 01:50:35 +00001288 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001289 WORK="$(mktemp -u -d)"
David Bainbridge0774b232019-08-02 06:37:19 +00001290 DATA=$WORK/voltha-debug-dump-$NAME-$TS
David Bainbridged18f4942020-04-14 16:46:13 -07001291 mkdir -p "$DATA"
1292 echo "$TS" > "$LOG"
David Bainbridge0774b232019-08-02 06:37:19 +00001293 echo -e "Capturing debug dump to voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001294 bspin - "Copy install log"
David Bainbridged18f4942020-04-14 16:46:13 -07001295 if [ -f "install-$NAME.log" ]; then
1296 (set -x; cp "install-$NAME.log" "$DATA/install-$NAME.log") >>"$LOG" 2>&1
1297 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001298 else
David Bainbridge0774b232019-08-02 06:37:19 +00001299 espin - "$NO_ENTRY Copy install log: install-$NAME.log not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001300 fi
1301 bspin - "Dumping Kubernetes PODs"
David Bainbridged18f4942020-04-14 16:46:13 -07001302 (set -x; kubectl get --all-namespaces pods >> "$DATA/all-pods.txt" 2>&1) >>"$LOG" 2>&1
1303 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001304 bspin - "Dumping Kubernetes SERVICEs"
David Bainbridged18f4942020-04-14 16:46:13 -07001305 (set -x; kubectl get --all-namespaces svc >> "$DATA/all-services.txt" 2>&1) >>"$LOG" 2>&1
1306 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001307 bspin - "Dumping Kubernetes EVENTs"
David Bainbridged18f4942020-04-14 16:46:13 -07001308 (set -x; kubectl get --all-namespaces events >> "$DATA/all-events.txt" 2>&1) >>"$LOG" 2>&1
1309 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001310 bspin - "Dumping VOLTHA POD details"
David Bainbridged18f4942020-04-14 16:46:13 -07001311 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 +00001312 SINCE=
David Bainbridged18f4942020-04-14 16:46:13 -07001313 if [ -n "$DUMP_FROM" ]; then
David Bainbridgecfd7ca12019-10-06 03:31:41 +00001314 SINCE="--since-time=$DUMP_FROM"
1315 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +00001316 for POD in $PODS; do
David Bainbridged18f4942020-04-14 16:46:13 -07001317 NS="$(echo "$POD" | cut -d: -f1)"
1318 POD="$(echo "$POD" | cut -d: -f2)"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001319 sspin - "Dumping VOLTHA POD details: $POD$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -07001320 mkdir -p "$DATA/$POD"
1321 (set -x; kubectl describe -n "$NS" "$POD" >> "$DATA/$POD/describe.txt" 2>&1) >>"$LOG" 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +00001322 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridged18f4942020-04-14 16:46:13 -07001323 (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 +00001324 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridged18f4942020-04-14 16:46:13 -07001325 (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 +00001326 sspin - "Dumping VOLTHA POD details: $POD"
1327 done
1328 espin - "$VERIFIED Dumping VOLTHA POD details$CEOL"
1329 bspin - "Dumping ETCD"
David Bainbridged18f4942020-04-14 16:46:13 -07001330 if [ -n "$(command -v etcdctl)" ]; then
1331 (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
1332 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001333 else
1334 espin - "$NO_ENTRY Dumping ETCD: etcdctl command not available"
1335 fi
David Bainbridge0774b232019-08-02 06:37:19 +00001336 bspin - "Creating compressed TAR: voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridged18f4942020-04-14 16:46:13 -07001337 (set -x; tar -C "$WORK" -zcf "voltha-debug-dump-$NAME-$TS.tgz" "./voltha-debug-dump-$NAME-$TS") >>"$LOG" 2>&1
1338 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001339 bspin - "Cleanup"
David Bainbridged18f4942020-04-14 16:46:13 -07001340 (set -x; rm -rf "$WORK") >>"$LOG" 2>&1
1341 espin - "$VERIFIED"
1342 bspin - "$(ls -l "voltha-debug-dump-$NAME-$TS.tgz")"
1343 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001344 exit
1345fi
1346
David Bainbridge0774b232019-08-02 06:37:19 +00001347LOG="install-$NAME.log"
David Bainbridge1d2c5842020-06-03 15:29:07 -07001348PFLOG="port-forward-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -07001349date > "$LOG"
Girish Kumarcc5f9172020-06-10 13:34:31 +00001350echo "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 +00001351
1352# Output install options to log
David Bainbridged18f4942020-04-14 16:46:13 -07001353echo "OPTIONS" >> "$LOG"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001354for O in $ALL_OPTIONS; do
David Bainbridged18f4942020-04-14 16:46:13 -07001355 VAL="$(eval echo "\$$O")"
1356 if [ -n "$VAL" ]; then
1357 printf " %-30s = %s\n" "$O" "$VAL" >> "$LOG"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001358 fi
1359done
1360
David Bainbridgee4d11ca2020-05-08 10:21:10 -07001361# Force remove any existing k8s port-forward processes. This will
1362# remove them for all kind clusters.
David Bainbridgee4d11ca2020-05-08 10:21:10 -07001363if [ "$1" == "clean" ]; then
1364 kill_port_forward __ALL__
1365 exit
1366fi
1367
David Bainbridgefad50732020-05-01 17:00:12 -07001368helm_values() {
1369 local NAMESPACE=$1; shift
1370 local INAME=$1; shift
1371 local CHART=$1; shift
1372 local CHART_VERSION=$1; shift
1373
1374 if [ "$CHART_VERSION X" != " X" ] && [ "$CHART_VERSION" != "latest" ]; then
1375 CHART_VERSION="--version $CHART_VERSION"
1376 else
1377 CHART_VERSION=
1378 fi
1379
1380 local CHART_ARGS=
1381 if [ -r "${INAME}-values.yaml" ]; then
1382 CHART_ARGS="-f ${INAME}-values.yaml"
1383 fi
1384
1385 if [ "$HELM_USE_UPGRADE" == "yes" ]; then
1386 _HELM_COMMAND="upgrade --install"
1387 _HELM_ARGS="xxxdryrunxxx"
1388 else
1389 _HELM_COMMAND="install"
Matteo Scandolof2d080b2020-07-23 13:59:29 -07001390 if [ "$HELM_MAJOR" -le 2 ]; then
1391 _HELM_NAME_ARG="--name xxxdryrunxxx"
1392 _HELM_ARGS=
1393 else
1394 _HELM_NAME_ARG="xxxdryrunxxx"
1395 _HELM_ARGS="--create-namespace"
1396 fi
David Bainbridgefad50732020-05-01 17:00:12 -07001397 fi
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001398 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 -07001399 ${CMD[*]} 2>/dev/null | awk 'PRINT==1 {print}; /^USER-SUPPLIED VALUES:/ {PRINT = 1}; /^$/ {PRINT = 0}'
1400}
1401
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001402helm_is_deployed() {
1403 local NAMESPACE=$1; shift
1404 local NAME=$1; shift
1405
1406 if [ "$HELM_MAJOR" -le 2 ]; then
1407 helm list --deployed --short --namespace "$NAMESPACE" "$NAME" 2>/dev/null | wc -l
1408 else
1409 helm list --deployed --short --namespace "$NAMESPACE" --filter "$NAME" 2>/dev/null | wc -l
1410 fi
1411}
1412
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001413helm_install() {
David Bainbridgec7220622020-05-28 12:31:47 -07001414 local INDENT NOW VALUES_FILE PPROF_ARG
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001415 if [ "$1" == "-" ]; then
1416 INDENT=$1; shift
1417 fi
1418 local NAMESPACE=$1; shift
David Bainbridge0774b232019-08-02 06:37:19 +00001419 local INAME=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001420 local CHART=$1; shift
David Bainbridge90fd8e32019-08-21 23:32:47 +00001421 local CHART_VERSION=$1; shift
David Bainbridgec7220622020-05-28 12:31:47 -07001422 local FILTER=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001423 local MESSAGE=$*
1424
David Bainbridged18f4942020-04-14 16:46:13 -07001425 if [ "$CHART_VERSION X" != " X" ] && [ "$CHART_VERSION" != "latest" ]; then
David Bainbridge90fd8e32019-08-21 23:32:47 +00001426 CHART_VERSION="--version $CHART_VERSION"
1427 else
1428 CHART_VERSION=
1429 fi
1430
David Bainbridge99ac7a22019-08-31 02:26:43 +00001431 local CHART_ARGS=
1432 if [ -r "${INAME}-values.yaml" ]; then
1433 CHART_ARGS="-f ${INAME}-values.yaml"
1434 fi
1435
David Bainbridged18f4942020-04-14 16:46:13 -07001436 local WAIT_START CMD
1437 WAIT_START="$(date +%s)"
1438 COUNT="$((300 / 15))"
1439 bspin "$INDENT" "$MESSAGE"
1440 if [ "$HELM_USE_UPGRADE" == "yes" ]; then
David Bainbridge7f8bf992020-04-08 21:53:22 -07001441 _HELM_COMMAND="upgrade --install"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001442 _HELM_NAME_ARG="$INAME"
David Bainbridge7f8bf992020-04-08 21:53:22 -07001443 else
1444 _HELM_COMMAND="install"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001445 if [ "$HELM_MAJOR" -le 2 ]; then
1446 _HELM_NAME_ARG="--name $INAME"
1447 _HELM_ARGS=
1448 else
1449 _HELM_NAME_ARG="$INAME"
1450 _HELM_ARGS="--create-namespace"
1451 fi
David Bainbridge7f8bf992020-04-08 21:53:22 -07001452 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001453
1454 VALUES_FILE="$(mktemp)"
1455 if [ "$FILTER" == "-" ]; then
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001456 cp "values.yaml" "$VALUES_FILE"
David Bainbridgea965ca22020-06-09 17:45:04 -07001457 elif [ "${FILTER:0:1}" == "+" ]; then
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001458 cp "values.yaml" "$VALUES_FILE"
1459 yq r - "${FILTER:1}" <"values.yaml" >>"$VALUES_FILE"
David Bainbridge33e56c72020-06-11 11:39:56 -07001460 cat "$VALUES_FILE" >>"$LOG"
David Bainbridgec7220622020-05-28 12:31:47 -07001461 else
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001462 yq r - "$FILTER" <"values.yaml" >"$VALUES_FILE"
David Bainbridgec7220622020-05-28 12:31:47 -07001463 fi
1464 if [ "$WITH_PPROF" == "yes" ]; then
1465 PPROF_ARG="--set profiler.enabled=true"
1466 fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001467 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 -07001468 (set -x; ${CMD[*]} >>"$LOG" 2>&1) >>"$LOG" 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001469 SUCCESS=$?
David Bainbridged18f4942020-04-14 16:46:13 -07001470 while [ "$SUCCESS" -ne 0 ]; do
1471 NOW="$(date +%s)"
1472 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -07001473 espin "$THEX"
David Bainbridgec7220622020-05-28 12:31:47 -07001474 rm -f "$VALUES_FILE"
David Bainbridge52e6e9d2020-03-23 13:48:27 -07001475 doTimeout "waiting for helm install $CHART"
1476 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001477 sspin "$INDENT"
1478 COUNT="$((COUNT - 1))"
1479 if [ "$COUNT" -eq 0 ]; then
1480 if [ "$HELM_USE_UPGRADE" == "no" ]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001481 if [ "$HELM_MAJOR" -le 2 ]; then
1482 (set -x; helm delete --purge "$INAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1483 else
1484 (set -x; helm uninstall "$INAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1485 fi
David Bainbridge7f8bf992020-04-08 21:53:22 -07001486 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001487 (set -x; ${CMD[*]} >>"$LOG" 2>&1) >>"$LOG" 2>&1
Andy Baviere22ff252019-12-19 11:40:31 -07001488 SUCCESS=$?
David Bainbridged18f4942020-04-14 16:46:13 -07001489 COUNT="$((300 / 15))"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001490 fi
1491 sleep .15
1492 done
David Bainbridgec7220622020-05-28 12:31:47 -07001493 rm -f "$VALUES_FILE"
David Bainbridged18f4942020-04-14 16:46:13 -07001494 espin "$INDENT" "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001495}
1496
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001497echo "INSTALL NAME: $NAME" >> "$LOG"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001498
David Bainbridged18f4942020-04-14 16:46:13 -07001499STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001500if [ "$INSTALL_KUBECTL" == "no" ]; then
1501 bspin "Skip kubectl install"
1502 espin $NO_ENTRY
Test Userc13bdc92019-07-03 20:57:49 +00001503else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001504 bspin "Verify kubectl $HELM"
David Bainbridged18f4942020-04-14 16:46:13 -07001505 if [ -x "$GOPATH/bin/kubectl" ]; then
1506 espin "$VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001507 else
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001508 ERR_OUT="$(mktemp)"
David Bainbridged18f4942020-04-14 16:46:13 -07001509 espin "$NOT_VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001510 bspin - "Download and install Kubernetes/kubectl $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001511 (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
1512 RESULT=$?
1513 if [ "$RESULT" -ne 0 ]; then
1514 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001515 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download kubectl: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001516 cat "$ERR_OUT" >> "$LOG"
Zack Williamsded60cb2020-04-13 10:02:20 -07001517 rm -rf "$ERR_OUT" "$GOPATH/bin/kubectl"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001518 exit 1
1519 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001520 (set -x; chmod 755 "$GOPATH/bin/kubectl" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1521 espin - "$VERIFIED"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001522 rm -rf "$ERR_OUT"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001523 fi
Test Userc13bdc92019-07-03 20:57:49 +00001524fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001525if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001526 NOW="$(date +%s)"
1527 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001528fi
Test Userc13bdc92019-07-03 20:57:49 +00001529
David Bainbridged18f4942020-04-14 16:46:13 -07001530STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001531if [ "$DEPLOY_K8S" == "no" ]; then
1532 bspin "Skip Kubernetes/Kind Deployment"
1533 espin $NO_ENTRY
1534else
Test Userba1e7e72019-07-10 22:27:54 +00001535 bspin "Verify Kubernetes/Kind $HELM"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001536 IS_INSTALLED=0
1537 OP_TYPE="install"
David Bainbridged18f4942020-04-14 16:46:13 -07001538 if [ -x "$GOPATH/bin/kind" ]; then
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001539 OP_TYPE="upgrade"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001540 if [ "$("$GOPATH/bin/kind" version | grep -c "$KIND_VERSION")" -eq 1 ]; then
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001541 IS_INSTALLED=1
David Bainbridged18f4942020-04-14 16:46:13 -07001542 espin "$VERIFIED"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001543 fi
1544 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001545 if [ "$IS_INSTALLED" -eq 0 ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001546 ERR_OUT="$(mktemp)"
David Bainbridged18f4942020-04-14 16:46:13 -07001547 espin "$NOT_VERIFIED"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001548 bspin - "Download and $OP_TYPE Kubernetes/kind $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001549 (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
1550 RESULT=$?
1551 if [ $RESULT -ne 0 ]; then
1552 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001553 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download kind: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001554 cat "$ERR_OUT" >> "$LOG"
Zack Williamsded60cb2020-04-13 10:02:20 -07001555 rm -rf "$ERR_OUT" "$GOPATH/bin/kind"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001556 exit 1
1557 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001558 (set -x; chmod 755 "$GOPATH/bin/kind" >>"$LOG" 2>&1) >>"$LOG" 2>&1
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001559 rm -rf "$ERR_OUT"
David Bainbridged18f4942020-04-14 16:46:13 -07001560 espin - "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001561 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001562fi
1563
David Bainbridgee87067b2019-08-12 22:00:12 +00001564if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001565 NOW="$(date +%s)"
1566 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001567fi
1568
David Bainbridged18f4942020-04-14 16:46:13 -07001569STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001570if [ "$INSTALL_HELM" == "no" ]; then
1571 bspin "Skip Helm Install"
1572 espin $NO_ENTRY
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001573else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001574 bspin "Verify Helm $HELM"
David Bainbridgea34993d2020-04-01 09:15:42 -07001575 HELM_UPGRADE=0
1576 HELM_UPGRADE_DESC="install"
David Bainbridged18f4942020-04-14 16:46:13 -07001577 if [ -x "$GOPATH/bin/helm" ]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001578 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 -07001579 HELM_UP_DOWN="$(echo -e "$HAVE_VER\n$HELM_VERSION" | sort -V | head -1)"
1580 if [ "$HAVE_VER" != "$HELM_VERSION" ]; then
1581 if [ "$HELM_UP_DOWN" == "$HELM_VERSION" ]; then
David Bainbridgea34993d2020-04-01 09:15:42 -07001582 HELM_UPGRADE_DESC="downgrade"
1583 else
1584 HELM_UPGRADE_DESC="upgrade"
1585 fi
1586 HELM_UPGRADE=1
1587 else
David Bainbridged18f4942020-04-14 16:46:13 -07001588 espin "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001589 fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001590 else
David Bainbridgea34993d2020-04-01 09:15:42 -07001591 HELM_UPGRADE=1
1592 fi
1593
David Bainbridged18f4942020-04-14 16:46:13 -07001594 if [ "$HELM_UPGRADE" -ne 0 ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001595 ERR_OUT="$(mktemp)"
1596 INSTALL_HELM_BIN=$(mktemp)
David Bainbridged18f4942020-04-14 16:46:13 -07001597 espin "$NOT_VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001598 bspin - "Download and $HELM_UPGRADE_DESC Helm $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001599 (set -x; curl -o "$INSTALL_HELM_BIN" --fail -sSL https://git.io/get_helm.sh >>"$LOG" 2>"$ERR_OUT") >>"$LOG" 2>&1
1600 RESULT=$?
1601 if [ $RESULT -ne 0 ]; then
1602 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001603 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download helm installer: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001604 cat "$ERR_OUT" >> "$LOG"
1605 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT" "$GOPATH/bin/helm" "$GOPATH/bin/tiller"
1606 exit 1
1607 fi
1608 rm -rf "$ERR_OUT"
1609 chmod +x "$INSTALL_HELM_BIN"
1610 (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
1611 RESULT=$?
1612 if [ $RESULT -ne 0 ]; then
1613 espin - "$THEX"
1614 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to install helm, see install log for details${NORMAL}"
1615 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT" "$GOPATH/bin/helm" "$GOPATH/bin/tiller"
1616 exit 1
1617 fi
1618 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT"
David Bainbridged18f4942020-04-14 16:46:13 -07001619 espin - "$VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001620 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001621fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001622if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001623 NOW="$(date +%s)"
1624 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001625fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001626HELM_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 -07001627
David Bainbridged18f4942020-04-14 16:46:13 -07001628STIME="$(date +%s)"
Test Userb5712372019-07-03 21:52:17 +00001629bspin "Verify voltctl $HIGH_VOLTAGE"
David Bainbridged2811972019-12-14 01:14:09 +00001630VOK=0
1631VMESSAGE="install"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001632ERR_OUT=$(mktemp)
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001633export VC_VERSION="$VOLTCTL_VERSION"
1634if [ "$VC_VERSION" == "latest" ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001635 set -o pipefail # TODO: would be nice to run all in pipefail mode
1636 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')"
1637 RESULT=$?
1638 set +o pipefail
1639 if [ "$RESULT" -ne 0 ]; then
1640 espin - "$THEX"
1641 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to determine released version of voltctl: $(cat "$ERR_OUT")${NORMAL}"
1642 rm -rf "$ERR_OUT" "$GOPATH/bin/voltctl"
1643 exit 1
1644 fi
1645 export VC_VERSION
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001646fi
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001647
David Bainbridged18f4942020-04-14 16:46:13 -07001648if [ -x "$GOPATH/bin/voltctl" ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001649 VHAVE="$("$GOPATH/bin/voltctl" version --clientonly -o json 2>/dev/null | jq -r .version)"
David Bainbridged18f4942020-04-14 16:46:13 -07001650 RESULT=$?
1651 if [ $RESULT -eq 0 ] && [ "$VHAVE" == "$VC_VERSION" ]; then
David Bainbridged2811972019-12-14 01:14:09 +00001652 VOK=1
David Bainbridged18f4942020-04-14 16:46:13 -07001653 espin "$VERIFIED"
David Bainbridge1ba64f12019-12-18 00:40:13 +00001654 else
David Bainbridged18f4942020-04-14 16:46:13 -07001655 VCHECK="$(echo -e "$VHAVE\n$VC_VERSION" | sort -V | head -1)"
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001656 if [ "$VCHECK" == "$VHAVE" ]; then
1657 VMESSAGE="upgrade"
1658 else
1659 VMESSAGE="downgrade"
1660 fi
David Bainbridged2811972019-12-14 01:14:09 +00001661 fi
1662fi
1663
David Bainbridged18f4942020-04-14 16:46:13 -07001664if [ "$VOK" -eq 0 ]; then
1665 espin "$NOT_VERIFIED"
David Bainbridged2811972019-12-14 01:14:09 +00001666 bspin - "Download and $VMESSAGE voltctl $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001667 (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
1668 RESULT=$?
1669 if [ $RESULT -ne 0 ]; then
1670 espin - "$THEX"
1671 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download voltctl (version $VC_VERSION): $(cat "$ERR_OUT")${NORMAL}"
1672 rm -rf "$ERR_OUT" "$GOPATH/bin/voltctl"
1673 exit 1
1674 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001675 (set -x; chmod 755 "$GOPATH/bin/voltctl" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1676 espin - "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001677fi
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001678rm -rf "$ERR_OUT"
David Bainbridgee87067b2019-08-12 22:00:12 +00001679if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001680 NOW="$(date +%s)"
1681 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001682fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001683
1684bspin "Verify command PATH"
David Bainbridged18f4942020-04-14 16:46:13 -07001685espin "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001686
David Bainbridged18f4942020-04-14 16:46:13 -07001687STIME="$(date +%s)"
Test Userba1e7e72019-07-10 22:27:54 +00001688if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001689 HAVE="$(kind get clusters 2>/dev/null | grep -c "voltha-$NAME")"
Test Userba1e7e72019-07-10 22:27:54 +00001690 bspin "Verify Kubernetes/Kind Cluster"
1691 sspin
David Bainbridged18f4942020-04-14 16:46:13 -07001692 if [ "$HAVE" -eq 0 ]; then
1693 espin "$NOT_VERIFIED"
Andrea Campanella8a149192020-07-31 17:19:45 +02001694 FILE="$NAME-cluster.cfg"
David K. Bainbridge2aa08da2020-07-31 12:49:45 -07001695 if [ -n "$KIND_CFG_FILE" ]; then
1696 FILE="$KIND_CFG_FILE"
1697 else
1698 bspin - "Generating cluster configuration"
Andrea Campanelladd946472020-07-31 11:03:44 +02001699
David K. Bainbridge2aa08da2020-07-31 12:49:45 -07001700 if [ -f "$FILE" ] ; then
1701 rm "$FILE"
1702 fi
1703
1704 touch "$FILE"
1705
1706 yq w -i "$FILE" kind Cluster
1707 yq w -i "$FILE" apiVersion "kind.sigs.k8s.io/v1alpha3"
1708
1709 if [ ! "$NUM_OF_CONTROLLER_NODES" -eq 0 ]; then
1710 for instance in $(seq 1 "$NUM_OF_CONTROLLER_NODES"); do
1711 yq w -i "$FILE" "nodes[+].role" "control-plane"
1712 done
1713 fi
1714
1715 if [ ! "$NUM_OF_WORKER_NODES" -eq 0 ]; then
1716 for instance in $(seq 1 "$NUM_OF_WORKER_NODES"); do
1717 yq w -i "$FILE" "nodes[+].role" worker
1718 done
1719 fi
1720 espin - "$VERIFIED"
Andrea Campanelladd946472020-07-31 11:03:44 +02001721 fi
1722
Andrea Campanella8a149192020-07-31 17:19:45 +02001723 cat "$FILE" >> "$LOG" 2>&1
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001724
Andrea Campanella8a149192020-07-31 17:19:45 +02001725 kind create cluster --name "voltha-$NAME" --config "$FILE"
David Bainbridge491b1bd2019-07-11 17:53:11 +00001726 else
David Bainbridged18f4942020-04-14 16:46:13 -07001727 espin "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001728 fi
1729
David K. Bainbridgec0ec6492020-07-21 17:34:23 +00001730 KUBECONFIG_TMP=$(mktemp)
1731 kind get kubeconfig --name="voltha-$NAME" >"$KUBECONFIG_TMP"
1732 mkdir -p "$HOME/.kube"
1733 KUBECONFIG="$HOME/.kube/kind-config-voltha-$NAME"; export KUBECONFIG
1734 cp "$KUBECONFIG_TMP" "$KUBECONFIG"
1735 rm -rf "$KUBECONFIG_TMP"
David Bainbridge1d2c5842020-06-03 15:29:07 -07001736
Test Userba1e7e72019-07-10 22:27:54 +00001737 P="coredns-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001738 etcd-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +00001739 kindnet-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001740 kube-apiserver-voltha-$NAME-control-plane \
1741 kube-controller-manager-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +00001742 kube-proxy-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001743 kube-scheduler-voltha-$NAME-control-plane"
Test Userba1e7e72019-07-10 22:27:54 +00001744
David K. Bainbridge2aa08da2020-07-31 12:49:45 -07001745 EXPECT=2 # Always 2 DNS instances
1746 EXPECT=$((EXPECT + 4 * NUM_OF_CONTROLLER_NODES)) # etcd, apiserver, controller manager, scheduler
1747 EXPECT=$((EXPECT + 2 * (NUM_OF_CONTROLLER_NODES + NUM_OF_WORKER_NODES))) # kindnet, proxy
David Bainbridged18f4942020-04-14 16:46:13 -07001748 wait_for_pods - "kube-system" "$EXPECT" "includes" "Waiting for system PODs to start" "$NO_LABEL" "$P"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001749fi
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001750
David Bainbridgee87067b2019-08-12 22:00:12 +00001751if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001752 NOW="$(date +%s)"
1753 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001754fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001755
David Bainbridgee4d11ca2020-05-08 10:21:10 -07001756if [ "$SCHEDULE_ON_CONTROL_NODES" == "yes" ]; then
1757 bspin "Untaint control nodes to allow scheduling $LOCK"
1758 for MNODE in $(kubectl get node --selector='node-role.kubernetes.io/master' -o json | jq -r '.items[].metadata.name'); do
1759 (set -x; kubectl taint node "$MNODE" node-role.kubernetes.io/master:NoSchedule- >>"$LOG" 2>&1) >>"$LOG" 2>&1
1760 sspin
1761 done
1762 espin "$VERIFIED"
1763fi
1764
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001765if [ "$HELM_MAJOR" -le 2 ]; then
1766 STIME="$(date +%s)"
1767 COUNT="$(count_pods "kube-system" ":Running:" "$NO_LABEL" "tiller-deploy-.*")"
1768 bspin "Verify Helm"
1769 if [ "$COUNT" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001770 espin "$NOT_VERIFIED"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001771 echo -e "Configuring Helm $GEAR"
1772 if [ "$INSTALL_HELM" == "no" ]; then
1773 bspin - "Skip Helm Initialization"
1774 espin - $NO_ENTRY
1775 else
1776 bspin - "Initialize Helm"
1777 (set -x; helm init --upgrade >>"$LOG" 2>&1) >>"$LOG" 2>&1
1778 espin - "$VERIFIED"
1779 wait_for_pods - "kube-system" 1 "includes" "Waiting for Tiller POD to start" "$NO_LABEL" "tiller-deploy-.*"
1780 fi
1781
1782 # HACK (sort-of) - the config for tiller is about to be patched, which will
1783 # cause the tiller pod to be recreated. This can sometimes cause a timing
1784 # issue with the "wait_for_pods" call on tiller as it may incorrectly
1785 # identify the running/ready tiller pod that is soon to be terminated as
1786 # what it is waiting for. To avoid this issue we do a clean scale down and
1787 # scale up of the pod so the script controlls when it should be expecting
1788 # things
1789 (set -x; kubectl -n kube-system scale deploy tiller-deploy --replicas=0 >>"$LOG" 2>&1) >>"$LOG" 2>&1
1790 wait_for_pods - "kube-system" 0 "not" "Waiting for Tiller POD to shutdown" "$NO_LABEL" "tiller-deploy-.*"
1791
1792 # Create and k8s service account so that Helm can create pods
1793 bspin - "Create Tiller ServiceAccount"
1794 (set -x; kubectl create serviceaccount --namespace kube-system tiller >>"$LOG" 2>&1) >>"$LOG" 2>&1
1795 espin - "$VERIFIED"
1796 bspin - "Create Tiller ClusterRoleBinding"
1797 (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>"$LOG" 2>&1) >>"$LOG" 2>&1
1798 espin - "$VERIFIED"
1799 bspin - "Update Tiller Manifest"
1800 (set -x; kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}' >>"$LOG" 2>&1) >>"$LOG" 2>&1
1801
1802 # HACK (sort-of) - part to, spin it back up
1803 (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 -07001804 espin - "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001805 else
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001806 if [ "$(helm version -s --template '{{.Server.SemVer}}')" != "$HELM_VERSION" ]; then
1807 espin "$NOT_VERIFIED"
1808 bspin - "Sync Tiller server version with helm client"
1809 (set -x; helm init --upgrade --force-upgrade --wait >>"$LOG" 2>&1) >>"$LOG" 2>&1
1810 espin - "$VERIFIED"
1811 else
1812 espin "$VERIFIED"
1813 fi
1814
David Bainbridgea34993d2020-04-01 09:15:42 -07001815 fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001816 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 -07001817fi
David Bainbridgeddeab482020-06-24 12:43:40 -07001818
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001819# The `etcd` repo is temporary until `http://github.com/helm/charts/pull/22955` is
1820# merged into the incubator charts
David Bainbridgeddeab482020-06-24 12:43:40 -07001821REPOS="onf|https://charts.opencord.org|ONF_VOLTHA \
1822 stable|https://kubernetes-charts.storage.googleapis.com|Google_Stable \
Ubuntubaab12f2020-06-30 01:08:19 +00001823 incubator|https://kubernetes-charts-incubator.storage.googleapis.com|Google_Incubator \
1824 onos|https://charts.onosproject.org|ONF_ONOS \
1825 atomix|https://charts.atomix.io|ONF_Atomix \
1826 bbsim-sadis|https://ciena.github.io/bbsim-sadis-server/charts|Custom_BBSIM_SADIS_Server \
1827 elastic|https://helm.elastic.co|Elastic \
David K. Bainbridge55007402020-09-21 12:49:48 -07001828 kiwigrid|https://kiwigrid.github.io|Fluentd-ElasticSearch"
David Bainbridgeddeab482020-06-24 12:43:40 -07001829
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001830REPO_UPDATE_REQ="no"
David Bainbridgeddeab482020-06-24 12:43:40 -07001831bspin - "Verify Helm Repository"
1832for REPO in $REPOS; do
1833 REPO_NAME="$(echo "$REPO" | cut -d\| -f1)"
1834 REPO_URL="$(echo "$REPO" | cut -d\| -f2)"
1835 REPO_LABEL="$(echo "$REPO" | cut -d\| -f3 | sed -e 's/_/ /g')"
1836
1837 sspin - "Verify Helm Repository: $REPO_LABEL$CEOL"
1838 if [ "$(helm repo list 2>/dev/null | grep -c "$REPO_NAME" 2>/dev/null)" -eq 0 ]; then
1839 sspin - "Add Helm Repository: $REPO_LABEL$CEOL"
1840 (set -x; helm repo add "$REPO_NAME" "$REPO_URL" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1841 REPO_UPDATE_REQ="yes"
1842 fi
1843done
1844sspin - "Verify Helm Repositories$CEOL"
1845espin - "$VERIFIED"
1846
1847if [ "$REPO_UPDATE_REQ" == "yes" ] || [ "$UPDATE_HELM_REPOS" == "yes" ]; then
1848 bspin - "Update Helm repository cache"
1849 (set -x; helm repo update >>"$LOG" 2>&1) >>"$LOG" 2>&1
1850 espin - "$VERIFIED"
1851fi
1852
David Bainbridgee87067b2019-08-12 22:00:12 +00001853if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001854 NOW="$(date +%s)"
1855 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001856fi
David Bainbridgecf546362020-04-21 23:18:50 -07001857# Resolve chart versions and log them for debug/support
1858RESOLVED_VOLTHA_CHART_VERSION=$(resolve_chart_version "$VOLTHA_CHART" "$VOLTHA_CHART_VERSION")
1859RESOLVED_VOLTHA_BBSIM_CHART_VERSION=$(resolve_chart_version "$VOLTHA_BBSIM_CHART" "$VOLTHA_BBSIM_CHART_VERSION")
Girish Kumarcc5f9172020-06-10 13:34:31 +00001860RESOLVED_VOLTHA_TRACING_CHART_VERSION=$(resolve_chart_version "$VOLTHA_TRACING_CHART" "$VOLTHA_TRACING_CHART_VERSION")
David Bainbridgecf546362020-04-21 23:18:50 -07001861RESOLVED_VOLTHA_ADAPTER_SIM_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_SIM_CHART" "$VOLTHA_ADAPTER_SIM_CHART_VERSION")
1862RESOLVED_VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_OPEN_OLT_CHART" "$VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION")
1863RESOLVED_VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_OPEN_ONU_CHART" "$VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION")
1864RESOLVED_ONOS_CHART_VERSION=$(resolve_chart_version "$ONOS_CHART" "$ONOS_CHART_VERSION")
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001865RESOLVED_ONOS_CLASSIC_CHART_VERSION=$(resolve_chart_version "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION")
David Bainbridgecf546362020-04-21 23:18:50 -07001866RESOLVED_KAFKA_CHART_VERSION=$(resolve_chart_version "$KAFKA_CHART" "$KAFKA_CHART_VERSION")
divyadesai59f987a2020-05-27 12:11:33 +00001867RESOLVED_ELASTICSEARCH_CHART_VERSION=$(resolve_chart_version "$ELASTICSEARCH_CHART" "$ELASTICSEARCH_CHART_VERSION")
1868RESOLVED_KIBANA_CHART_VERSION=$(resolve_chart_version "$KIBANA_CHART" "$KIBANA_CHART_VERSION")
1869RESOLVED_FLUENTD_ELASTICSEARCH_CHART_VERSION=$(resolve_chart_version "$FLUENTD_ELASTICSEARCH_CHART" "$FLUENTD_ELASTICSEARCH_CHART_VERSION")
David K. Bainbridge450c15c2020-06-29 10:12:06 -07001870RESOLVED_BBSIM_SADIS_SERVER_CHART_VERSION=$(resolve_chart_version "$BBSIM_SADIS_SERVER_CHART" "$BBSIM_SADIS_SERVER_CHART_VERSION")
1871RESOLVED_RADIUS_CHART_VERSION=$(resolve_chart_version "$RADIUS_CHART" "$RADIUS_CHART_VERSION")
David Bainbridgecf546362020-04-21 23:18:50 -07001872cat <<EOV >>"$LOG"
1873Resolved helm charts and versions:
1874 $VOLTHA_CHART:$RESOLVED_VOLTHA_CHART_VERSION
1875 $VOLTHA_BBSIM_CHART:$RESOLVED_VOLTHA_BBSIM_CHART_VERSION
Girish Kumarcc5f9172020-06-10 13:34:31 +00001876 $VOLTHA_TRACING_CHART:$RESOLVED_VOLTHA_TRACING_CHART_VERSION
David Bainbridgecf546362020-04-21 23:18:50 -07001877 $VOLTHA_ADAPTER_SIM_CHART:$RESOLVED_VOLTHA_ADAPTER_SIM_CHART_VERSION
1878 $VOLTHA_ADAPTER_OPEN_OLT_CHART:$RESOLVED_VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION
1879 $VOLTHA_ADAPTER_OPEN_ONU_CHART:$RESOLVED_VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION
1880 $ONOS_CHART:$RESOLVED_ONOS_CHART_VERSION
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001881 $ONOS_CLASSIC_CHART:$RESOLVED_ONOS_CLASSIC_CHART_VERSION
David Bainbridgecf546362020-04-21 23:18:50 -07001882 $KAFKA_CHART:$RESOLVED_KAFKA_CHART_VERSION
divyadesai59f987a2020-05-27 12:11:33 +00001883 $ELASTICSEARCH_CHART:$RESOLVED_ELASTICSEARCH_CHART_VERSION
1884 $KIBANA_CHART:$RESOLVED_KIBANA_CHART_VERSION
1885 $FLUENTD_ELASTICSEARCH_CHART:$RESOLVED_FLUENTD_ELASTICSEARCH_CHART_VERSION
David K. Bainbridge450c15c2020-06-29 10:12:06 -07001886 $BBSIM_SADIS_SERVER_CHART:$RESOLVED_BBSIM_SADIS_SERVER_CHART_VERSION
1887 $RADIUS_CHART:$RESOLVED_RADIUS_CHART_VERSION
David Bainbridgecf546362020-04-21 23:18:50 -07001888EOV
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001889
David Bainbridged18f4942020-04-14 16:46:13 -07001890STIME="$(date +%s)"
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001891bspin "Verify Helm values file: values.yaml"
1892if [ ! -r "./values.yaml" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001893 espin "$NOT_VERIFIED"
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001894 bspin - "Download Helm values file: values.yaml to values.yaml $DOWNLOAD"
David Bainbridged18f4942020-04-14 16:46:13 -07001895 ERR_OUT="$(mktemp)"
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001896 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 -07001897 espin - "$THEX"
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001898 echo -e "${RED}${BOLD}${ERROR}ERROR: values.yaml${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
David Bainbridged18f4942020-04-14 16:46:13 -07001899 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001900 rm -rf "$ERR_OUT" "./values.yaml"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001901 exit 1
1902 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001903 rm -rf "$ERR_OUT"
1904 espin - "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001905else
David Bainbridged18f4942020-04-14 16:46:13 -07001906 espin "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001907fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001908if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001909 NOW="$(date +%s)"
1910 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001911fi
Test Userba1e7e72019-07-10 22:27:54 +00001912
David Bainbridged18f4942020-04-14 16:46:13 -07001913STIME="$(date +%s)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001914bspin "Verify or download chart specific values files $DOWNLOAD"
1915VALUES_FILES="monkey-values.yaml"
David Bainbridged18f4942020-04-14 16:46:13 -07001916ERR_OUT="$(mktemp)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001917for i in $VALUES_FILES; do
1918 if [ ! -r ./$i ]; then
serkant.uluderya4d315132020-04-15 16:25:54 -07001919 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 -07001920 espin "$THEX"
1921 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1922 echo "ERROR: $i - $(cat "$ERR_OUT")" >>"$LOG"
1923 rm -rf "$ERR_OUT" "./$i"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001924 exit 1
1925 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001926 rm -rf "$ERR_OUT"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001927 fi
1928done
David Bainbridged18f4942020-04-14 16:46:13 -07001929rm -rf "$ERR_OUT"
1930espin "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001931if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001932 NOW="$(date +%s)"
1933 printtime $((NOW - STIME))
David Bainbridge99ac7a22019-08-31 02:26:43 +00001934fi
1935
1936if [ "$WITH_CHAOS" == "yes" ]; then
1937 bspin "Verify or clone kube-monkey helm chart $DOWNLOAD"
1938 if [ -r ./kube-monkey ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001939 espin "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001940 else
David Bainbridged18f4942020-04-14 16:46:13 -07001941 espin "$NOT_VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001942 bspin - "GIT clone kube-monkey"
David Bainbridged18f4942020-04-14 16:46:13 -07001943 (set -x; git clone https://github.com/asobti/kube-monkey kube-monkey >>"$LOG" 2>&1) >>"$LOG" 2>&1
1944 espin - "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001945 fi
1946fi
1947
Test Userba1e7e72019-07-10 22:27:54 +00001948if [ "$JUST_K8S" == "yes" ]; then
1949 echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye."
1950 echo ""
David Bainbridged18f4942020-04-14 16:46:13 -07001951 echo "Please issue the following commands in your terminal to ensure that you" | tee -a "$LOG"
1952 echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a "$LOG"
1953 echo "tools required by VOLTHA in your command path. " | tee -a "$LOG"
1954 echo "" | tee -a "$LOG"
1955 echo -en "$BOLD"
1956 if [ "$DEPLOY_K8S" == "yes" ]; then
David K. Bainbridge02ae1f32020-07-21 13:25:13 -07001957 KUBECONFIG_TMP=$(mktemp)
1958 kind get kubeconfig --name="voltha-$NAME" >"$KUBECONFIG_TMP"
1959 mkdir -p "$HOME/.kube"
1960 KUBECONFIG="$HOME/.kube/kind-config-voltha-$NAME"; export KUBECONFIG
1961 cp "$KUBECONFIG_TMP" "$KUBECONFIG"
1962 rm -rf "$KUBECONFIG_TMP"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001963 echo "export KUBECONFIG=\"$KUBECONFIG\"" | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00001964 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001965 echo "export PATH=$GOPATH/bin:\$PATH" | tee -a "$LOG"
1966 echo -en "$NORMAL"
1967 echo "" | tee -a "$LOG"
1968 echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00001969 exit 0
1970fi
1971
David K. Bainbridgecb4b3ab2020-08-31 08:34:14 -07001972if is_in "$WITH_ETCD" "yes,external"; then
1973 STIME="$(date +%s)"
1974 bspin "Verify external ETCD cluster $OLD_KEY"
1975 EXPECT=$NUM_OF_ETCD
1976 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^etcd\$")" -ne 1 ]; then
1977 espin "$NOT_VERIFIED"
1978 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"
1979 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
1980 else
1981 espin "$VERIFIED"
1982 fi
1983 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for ETCD cluster to start" "$NO_LABEL" "etcd-.*"
1984 if [ "$WITH_TIMINGS" == "yes" ]; then
1985 NOW="$(date +%s)"
1986 printtime $((NOW - STIME))
1987 fi
1988fi
1989
1990if is_in "$WITH_KAFKA" "yes,external"; then
1991 _TMP="$(mktemp -u)"
1992 cat << EOC > "$_TMP"
1993configurationOverrides:
1994 "default.replication.factor": $NUM_OF_KAFKA
1995 "offsets.topic.replication.factor": $NUM_OF_KAFKA
1996 "log.retention.hours": 4
1997 "log.message.timestamp.type": "LogAppendTime"
1998persistence:
1999 enabled: false
2000zookeeper:
2001 replicaCount: $NUM_OF_KAFKA
2002 persistence:
2003 enabled: false
2004replicas: $NUM_OF_KAFKA
2005EOC
2006 STIME="$(date +%s)"
2007 bspin "Verify external Kafka cluster $OLD_KEY"
2008 EXPECT=$((NUM_OF_KAFKA*2))
2009 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^kafka\$")" -ne 1 ]; then
2010 espin "$NOT_VERIFIED"
2011 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" -f $_TMP"
2012 helm_install - "$INFRA_NS" kafka "$KAFKA_CHART" "$KAFKA_CHART_VERSION" kafka "$_HELM_DESC external Kafka cluster"
2013 else
2014 espin "$VERIFIED"
2015 fi
2016 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for Kafka cluster to start" "$NO_LABEL" "kafka-.*"
2017 if [ "$WITH_TIMINGS" == "yes" ]; then
2018 NOW="$(date +%s)"
2019 printtime $((NOW - STIME))
2020 fi
2021 rm -rf "$_TMP"
2022fi
2023
2024
David Bainbridged18f4942020-04-14 16:46:13 -07002025STIME="$(date +%s)"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002026if is_in "$WITH_ONOS" "yes,legacy,classic"; then
2027 if is_in "$WITH_ONOS" "legacy"; then
2028 bspin "Verify ONOS LEGACY installed $BIRD"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002029 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^onos\$")" -ne 1 ]; then
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002030 espin "$NOT_VERIFIED"
David Bainbridge33e56c72020-06-11 11:39:56 -07002031 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 -07002032 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
2033 else
2034 espin "$VERIFIED"
2035 fi
2036 wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for ONOS to start" "$NO_LABEL" "onos-.*"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07002037
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002038 if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
2039 bspin - "Forward ONOS API port $FORWARD"
2040 kill_port_forward onos-ui
2041 port_forward "$INFRA_NS" onos-ui "$ONOS_API_PORT:8181"
2042 espin - "$VERIFIED"
2043 bspin - "Forward ONOS SSH port $FORWARD"
2044 kill_port_forward onos-ssh
2045 port_forward "$INFRA_NS" onos-ssh "$ONOS_SSH_PORT:8101"
2046 espin - "$VERIFIED"
2047 _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT"
2048 else
2049 _ONOS_API_EP="$(get_service_ep "$INFRA_NS" onos-ui)"
2050 fi
2051 elif is_in "$WITH_ONOS" "yes,classic"; then
2052 bspin "Verify ONOS CLASSIC installed $BIRD"
Matteo Scandolo48890712020-09-11 15:48:24 -07002053 # ONOS CLASSIC identifies its image repo/tag/pullPolicy differently, so yq is used to grab the values from the
2054 # values value
2055 YAML_VALUES=$(INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set replicas=$NUM_OF_ONOS --set atomix.replicas=$NUM_OF_ATOMIX" \
2056 helm_values "$INFRA_NS" onos "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION")
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002057 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^onos\$")" -ne 1 ]; then
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002058 espin "$NOT_VERIFIED"
David Bainbridgefad50732020-05-01 17:00:12 -07002059 _ONOS_REPO="$(echo "$YAML_VALUES" | yq read - images.onos.repository)"
David Bainbridgedee3f022020-06-05 07:45:13 -07002060 if [ -z "$_ONOS_REPO" ]; then
2061 _ONOS_REPO="voltha/voltha-onos"
2062 fi
David Bainbridgefad50732020-05-01 17:00:12 -07002063 _ONOS_TAG="$(echo "$YAML_VALUES" | yq read - images.onos.tag)"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002064 if [ -z "$_ONOS_TAG" ]; then
David Bainbridgedee3f022020-06-05 07:45:13 -07002065 _ONOS_TAG="$(echo "$YAML_VALUES" | yq read - defaults.image_tag)"
2066 fi
2067 if [ -z "$_ONOS_TAG" ]; then
2068 _ONOS_TAG="master"
2069 fi
2070 _ONOS_PULL_POLICY="$(echo "$YAML_VALUES" | yq read - images.onos.pullPolicy)"
2071 if [ -z "$_ONOS_PULL_POLICY" ]; then
2072 _ONOS_PULL_POLICY="$(echo "$YAML_VALUES" | yq read - defaults.image_pullPolicy)"
2073 fi
2074 if [ -z "$_ONOS_PULL_POLICY" ]; then
2075 _ONOS_PULL_POLICY="Always"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002076 fi
David Bainbridgefad50732020-05-01 17:00:12 -07002077
Matteo Scandoloe0829b52020-05-08 14:23:56 -07002078 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 -07002079 helm_install - "$INFRA_NS" onos "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION" "+onos" "$_HELM_DESC ONOS CLASSIC"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002080 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
2081 else
Matteo Scandolo48890712020-09-11 15:48:24 -07002082 _ONOS_TAG="$(echo "$YAML_VALUES" | yq read - images.onos.tag)"
2083 if [ -z "$_ONOS_TAG" ]; then
2084 _ONOS_TAG="$(echo "$YAML_VALUES" | yq read - defaults.image_tag)"
2085 fi
2086 if [ -z "$_ONOS_TAG" ]; then
2087 _ONOS_TAG="master"
2088 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002089 espin "$VERIFIED"
2090 fi
2091 wait_for_pods - "$INFRA_NS" $((NUM_OF_ONOS + NUM_OF_ATOMIX)) "includes" "Waiting for ONOS CLASSIC to start" "$NO_LABEL" "onos-.*"
2092 if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
2093 bspin - "Forward ONOS API port $FORWARD"
2094 kill_port_forward onos-onos-classic-hs
2095 port_forward "$INFRA_NS" onos-onos-classic-hs "$ONOS_API_PORT:8181" "$ONOS_SSH_PORT:8101"
2096 espin - "$VERIFIED"
2097 _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT"
2098 else
2099 _ONOS_API_EP="$(get_service_ep "$INFRA_NS" onos-onos-classic-hs)"
2100 fi
2101 elif [ "$WITH_ONOS" == "micro" ]; then
2102 bspin "Verify micro-ONOS installed $BIRD"
2103 # We should never get here
2104 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Micro ONOS not currently supported${NORMAL}"
2105 exit 1
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002106 fi
David Bainbridged31d6122019-08-13 19:37:59 +00002107 bspin - "Verify or download ONOS configuration support files $DOWNLOAD"
Matteo Scandolo78dfee02020-02-13 16:18:03 -08002108 ONOS_FILES="olt-onos-enableExtraneousRules.json onos-aaa.json \
David Bainbridge696bc632020-04-05 21:49:37 -07002109 onos-dhcpl2relay.json onos-sadis-sample.json"
David Bainbridged18f4942020-04-14 16:46:13 -07002110 (set -x; mkdir -p ./onos-files >>"$LOG" 2>&1) >>"$LOG" 2>&1
2111 ERR_OUT="$(mktemp)"
David Bainbridge2b19e832019-08-16 02:40:53 +00002112 for i in $ONOS_FILES; do
David Bainbridged18f4942020-04-14 16:46:13 -07002113 if [ ! -r "./onos-files/$i" ]; then
serkant.uluderya4d315132020-04-15 16:25:54 -07002114 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 -07002115 espin - "$THEX"
2116 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
2117 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
2118 rm -rf "$ERR_OUT" "./onos-files/$i"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08002119 exit 1
2120 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002121 rm -rf "$ERR_OUT"
David Bainbridged31d6122019-08-13 19:37:59 +00002122 fi
2123 done
David Bainbridged18f4942020-04-14 16:46:13 -07002124 rm -rf "$ERR_OUT"
2125 espin - "$VERIFIED"
David Bainbridge27790d62019-08-13 22:43:19 +00002126
David Bainbridged18f4942020-04-14 16:46:13 -07002127 if [ "$INSTALL_ONOS_APPS" == "yes" ]; then
David Bainbridge27790d62019-08-13 22:43:19 +00002128 bspin - "Installing custom ONOS applications"
David Bainbridged18f4942020-04-14 16:46:13 -07002129 if [ -x onos-files/onos-apps ] && [ "$(find onos-files/onos-apps -name "*.oar" 2>/dev/null | wc -l)" -gt 0 ]; then
2130 for OAR in onos-files/onos-apps/*.oar; do
David Bainbridge27790d62019-08-13 22:43:19 +00002131 sspin - "Installing custom ONOS applications - $OAR$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -07002132 override_onos_app "$OAR"
David Bainbridge27790d62019-08-13 22:43:19 +00002133 done
2134 espin - "$VERIFIED Installing custom ONOS applications$CEOL"
2135 else
2136 espin - "$NOT_VERIFIED Installing custom ONOS applications - None Found"
2137 fi
2138 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07002139
David Bainbridged18f4942020-04-14 16:46:13 -07002140 if [ "$WITH_KAFKA" != "no" ]; then
David Bainbridge837e8bd2020-04-06 13:17:14 -07002141 check_onos_app_active org.opencord.kafka
David Bainbridge879439b2020-06-12 15:59:35 -07002142 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridgec7220622020-05-28 12:31:47 -07002143 _HOST=kafka.$INFRA_NS.svc
David Bainbridge76afd812020-04-06 09:53:52 -07002144 _PORT=9092
David Bainbridge879439b2020-06-12 15:59:35 -07002145 elif [ "$WITH_KAFKA" != "no" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002146 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
2147 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge837e8bd2020-04-06 13:17:14 -07002148 _PORT=${_PORT:-9092}
2149 fi
2150 push_onos_config "json" "Push ONOS Kafka Configuration" "network/configuration/apps/org.opencord.kafka" \
David Bainbridged18f4942020-04-14 16:46:13 -07002151 "$(cat <<EOJ | tr -d '[:space:]'
David Bainbridge696bc632020-04-05 21:49:37 -07002152{
2153 "kafka": {
2154 "bootstrapServers": "$_HOST:$_PORT"
2155 }
2156}
2157EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07002158)"
David Bainbridge837e8bd2020-04-06 13:17:14 -07002159 fi
Matteo Scandolo9a77a732020-01-09 14:24:12 -08002160 check_onos_app_active org.opencord.dhcpl2relay
Matteo Scandolo78dfee02020-02-13 16:18:03 -08002161 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 -08002162 check_onos_app_active org.opencord.olt
Hardik Windlassa7501fb2020-02-17 14:28:20 +00002163 # Default value for "enableEapol" is true in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07002164 if [ "$WITH_EAPOL" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08002165 push_onos_config "json" "Enable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":true}'
David Bainbridged18f4942020-04-14 16:46:13 -07002166 elif [ "$WITH_EAPOL" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00002167 push_onos_config "json" "Disable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08002168 fi
Saurav Dasf67baf62020-08-27 14:21:58 -07002169 # Enable DHCP via component configs for dhcp programming in the OLT app. Note that sadis config per UNI port/service is also required for dhcp to work.
2170 # Two component configs are "enableDhcpV4" which is true by default, and "enableDhcpV6" which is false by default. These don't need to change until we support v6.
2171 if [[ $(semver_greater "$_ONOS_TAG" "4.1.4") == "true" ]]; then
2172 # newer versions use "enableDhcpOnNni" which is false by default
2173 if [ "$WITH_DHCP" == "yes" ]; then
2174 push_onos_config "json" "Enable VOLTHA ONOS DHCP on NNI port(s)" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableDhcpOnNni":true}'
2175 elif [ "$WITH_DHCP" == "no" ]; then
2176 push_onos_config "json" "Disable VOLTHA ONOS DHCP on NNI port(s)" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableDhcpOnNni":false}'
2177 fi
2178 else
2179 # older versions use "enableDhcpOnProvisioning" which is false by default
2180 if [ "$WITH_DHCP" == "yes" ]; then
2181 push_onos_config "json" "Enable VOLTHA ONOS DHCP on provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableDhcpOnProvisioning":true}'
2182 elif [ "$WITH_DHCP" == "no" ]; then
2183 push_onos_config "json" "Disable VOLTHA ONOS DHCP on provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableDhcpOnProvisioning":false}'
2184 fi
Matteo Scandolo78dfee02020-02-13 16:18:03 -08002185 fi
Saurav Dasf67baf62020-08-27 14:21:58 -07002186 # Enable IGMP via component configs for IGMP programming in the OLT app. Note that sadis config on UNI port/service is also required for igmp to work.
2187 # Default value for "enableIgmpOnNni" is false in OLT App
2188 if [[ $(semver_greater "$_ONOS_TAG" "4.1.4") == "true" ]]; then
2189 if [ "$WITH_IGMP" == "yes" ]; then
2190 push_onos_config "json" "Enable VOLTHA ONOS IGMP on NNI port(s)" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnNni":true}'
2191 elif [ "$WITH_IGMP" == "no" ]; then
2192 push_onos_config "json" "Disable VOLTHA ONOS IGMP on NNI port(s)" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnNni":false}'
2193 fi
2194 else
2195 if [ "$WITH_IGMP" == "yes" ]; then
2196 push_onos_config "json" "Enable VOLTHA ONOS IGMP on provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":true}'
2197 elif [ "$WITH_IGMP" == "no" ]; then
2198 push_onos_config "json" "Disable VOLTHA ONOS IGMP on provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":false}'
2199 fi
Matteo Scandolo78dfee02020-02-13 16:18:03 -08002200 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002201 if [ "$ENABLE_ONOS_EXTRANEOUS_RULES" == "yes" ]; then
David K. Bainbridge484d80c2020-03-05 21:44:34 -08002202 push_onos_config "file" "Enabling extraneous rules for ONOS" "configuration/org.onosproject.net.flow.impl.FlowRuleManager" "onos-files/olt-onos-enableExtraneousRules.json"
2203 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002204 if is_in "$CONFIG_SADIS" "yes,file"; then
Matteo Scandolo9a77a732020-01-09 14:24:12 -08002205 check_onos_app_active org.opencord.sadis
Hardik Windlassb3147602020-03-09 16:59:15 +05302206 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 -07002207 elif [ "$CONFIG_SADIS" == "bbsim" ]; then
2208 push_onos_config "json" \
2209 "[optional] Push ONOS configuration for BBSIM SADIS 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": {
David Bainbridgec7220622020-05-28 12:31:47 -07002215 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:50074/v2/subscribers/%s",
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002216 "cache": {
2217 "enabled": true,
2218 "maxsize": 50,
2219 "ttl": "PT1m"
2220 }
2221 }
2222 },
2223 "bandwidthprofile": {
2224 "integration": {
David Bainbridgec7220622020-05-28 12:31:47 -07002225 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:50074/v2/bandwidthprofiles/%s",
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002226 "cache": {
2227 "enabled": true,
2228 "maxsize": 50,
2229 "ttl": "PT1m"
2230 }
2231 }
2232 }
2233}
2234EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07002235)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002236 elif [ "$CONFIG_SADIS" == "url" ]; then
2237 push_onos_config "json" \
2238 "[optional] Push ONOS configuration for custom SADIS and Bandwidth Profile servers" \
2239 "network/configuration/apps/org.opencord.sadis" \
David Bainbridged18f4942020-04-14 16:46:13 -07002240 "$(cat <<EOJ | tr -d '[:space:]'
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002241{
2242 "sadis": {
2243 "integration": {
2244 "url": "$SADIS_SUBSCRIBERS",
2245 "cache": {
2246 "enabled": true,
2247 "maxsize": 50,
2248 "ttl": "PT1m"
2249 }
2250 }
2251 },
2252 "bandwidthprofile": {
2253 "integration": {
2254 "url": "$SADIS_BANDWIDTH_PROFILES",
2255 "cache": {
2256 "enabled": true,
2257 "maxsize": 50,
2258 "ttl": "PT1m"
2259 }
2260 }
2261 }
2262}
2263EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07002264)"
David Bainbridge2b19e832019-08-16 02:40:53 +00002265 fi
Test Userba1e7e72019-07-10 22:27:54 +00002266fi
David Bainbridgee87067b2019-08-12 22:00:12 +00002267if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002268 NOW="$(date +%s)"
2269 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002270fi
Test Userba1e7e72019-07-10 22:27:54 +00002271
Girish Kumarcc5f9172020-06-10 13:34:31 +00002272if [ "$WITH_TRACING" == "yes" ]; then
2273 STIME="$(date +%s)"
2274 echo -e "Verify Jaeger Tracing $PLUG"
2275 bspin - "Verify Jaeger Tracing Installed"
2276 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^tracing\$")" -ne 1 ]; then
2277 espin - "$NOT_VERIFIED"
2278 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
2279 helm_install - "$INFRA_NS" tracing "$VOLTHA_TRACING_CHART" "$VOLTHA_TRACING_CHART_VERSION" tracing "$_HELM_DESC Jaeger Tracing"
2280 else
2281 espin - "$VERIFIED"
2282 fi
2283 wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for Jaeger Tracing to start" "$NO_LABEL" "jaeger*"
2284 if [ "$WITH_TIMINGS" == "yes" ]; then
2285 NOW="$(date +%s)"
2286 printtime $((NOW - STIME))
2287 fi
2288fi
2289
David Bainbridged18f4942020-04-14 16:46:13 -07002290STIME="$(date +%s)"
David Bainbridgeed476572020-06-02 14:05:45 -07002291EXPECT=2
2292# therecanbeonlyone set hardcoded to true for backward compatibility
2293INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set therecanbeonlyone=true"
Matteo Scandolo67335f02020-04-09 11:19:53 -07002294case $WITH_ETCD in
David Bainbridge76afd812020-04-06 09:53:52 -07002295 no)
David Bainbridge76afd812020-04-06 09:53:52 -07002296 ;;
David Bainbridgec7220622020-05-28 12:31:47 -07002297 yes|external)
2298 _HOST="etcd.$INFRA_NS.svc"
David Bainbridge76afd812020-04-06 09:53:52 -07002299 _PORT=2379
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002300 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
Neha Sharmaa1c92ca2020-06-24 11:50:33 +00002301 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.address=$_HOST:$_PORT"
David Bainbridge76afd812020-04-06 09:53:52 -07002302 ;;
2303 *)
David Bainbridged18f4942020-04-14 16:46:13 -07002304 _HOST="$(echo "$WITH_ETCD" | cut -d: -f1)"
2305 _PORT="$(echo "$WITH_ETCD" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07002306 _PORT=${_PORT:-2379}
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002307 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
Neha Sharmaa1c92ca2020-06-24 11:50:33 +00002308 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.address=$_HOST:$_PORT"
David Bainbridge76afd812020-04-06 09:53:52 -07002309 ;;
2310esac
2311case $WITH_KAFKA in
2312 no)
David Bainbridge76afd812020-04-06 09:53:52 -07002313 ;;
David Bainbridgec7220622020-05-28 12:31:47 -07002314 yes|external)
2315 _HOST=kafka.$INFRA_NS.svc
David Bainbridge76afd812020-04-06 09:53:52 -07002316 _PORT=9092
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002317 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"
2318 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 -07002319 ;;
2320 *)
David Bainbridged18f4942020-04-14 16:46:13 -07002321 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
2322 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07002323 _PORT=${_PORT:-9092}
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002324 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"
2325 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 -07002326 ;;
2327esac
2328
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002329if is_in "$WITH_ONOS" "legacy"; then
David Bainbridgec7220622020-05-28 12:31:47 -07002330 _HOST=onos-openflow.$INFRA_NS.svc
David Bainbridge76afd812020-04-06 09:53:52 -07002331 _PORT=6653
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002332elif is_in "$WITH_ONOS" "yes,classic"; then
David Bainbridgec7220622020-05-28 12:31:47 -07002333 _HOST=onos-onos-classic-hs.$INFRA_NS.svc
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002334 _PORT=6653
David Bainbridged18f4942020-04-14 16:46:13 -07002335elif [ "$WITH_ONOS" != "no" ]; then
2336 _HOST="$(echo "$WITH_ONOS" | cut -d: -f1)"
2337 _PORT="$(echo "$WITH_ONOS" | cut -s -d: -f2)"
David Bainbridge76afd812020-04-06 09:53:52 -07002338 _PORT=${_PORT:-6653}
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002339fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002340
David Bainbridgecf546362020-04-21 23:18:50 -07002341compare_versions "$RESOLVED_VOLTHA_CHART_VERSION" 2.4.2
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002342if [ "$?" == "1" ]; then
2343 # voltha chart > 2.4.2 uses list of controllers
David Bainbridgee4d11ca2020-05-08 10:21:10 -07002344 for NUM in $(seq 0 $((NUM_OF_ONOS-1))); do
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002345 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 +00002346 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 -07002347 done
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002348else
2349 # voltha chart <= 2.4.2 uses single controller
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002350 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.controller.service=$_HOST --set services.controller.port=$_PORT"
Neha Sharmaa1c92ca2020-06-24 11:50:33 +00002351 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.controller.address=$_HOST:$_PORT"
David Bainbridge696bc632020-04-05 21:49:37 -07002352fi
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002353
Girish Kumarcc5f9172020-06-10 13:34:31 +00002354if [ "$WITH_TRACING" == "yes" ]; then
2355 VOLTHA_TRACING_CHART_NAME=$(resolve_chart_name "$VOLTHA_TRACING_CHART")
2356 _HOST="tracing-${VOLTHA_TRACING_CHART_NAME}-jaeger-agent.$INFRA_NS.svc"
2357 _PORT=6831
2358 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set tracing.enabled=true --set services.tracing_agent.address=$_HOST:$_PORT"
2359fi
2360
Test Userb5712372019-07-03 21:52:17 +00002361bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002362if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$VOLTHA_NS" "^voltha\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002363 espin "$NOT_VERIFIED"
David Bainbridgea965ca22020-06-09 17:45:04 -07002364 helm_install - "$VOLTHA_NS" voltha "$VOLTHA_CHART" "$VOLTHA_CHART_VERSION" "+voltha" "$_HELM_DESC VOLTHA Core"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002365else
David Bainbridged18f4942020-04-14 16:46:13 -07002366 espin "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002367fi
David Bainbridge696bc632020-04-05 21:49:37 -07002368INTERNAL_EXTRA_HELM_INSTALL_ARGS=
Test Userba1e7e72019-07-10 22:27:54 +00002369
David Bainbridge90fd8e32019-08-21 23:32:47 +00002370VOLTHA="voltha-ofagent-.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002371 rw-core.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002372 voltha-zookeeper-.*"
David Bainbridged18f4942020-04-14 16:46:13 -07002373wait_for_pods - "$VOLTHA_NS" "$EXPECT" "includes" "Waiting for VOLTHA Core to start" "$NO_LABEL" "$VOLTHA"
David Bainbridgee87067b2019-08-12 22:00:12 +00002374if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002375 NOW="$(date +%s)"
2376 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002377fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002378
David Bainbridge46505fb2019-10-01 21:13:20 +00002379if [ "$WITH_ADAPTERS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002380 STIME="$(date +%s)"
David Bainbridge46505fb2019-10-01 21:13:20 +00002381 EXPECT=0
David Bainbridgec7220622020-05-28 12:31:47 -07002382 if is_in "$WITH_ETCD" "yes,external"; then
2383 _HOST=etcd.$INFRA_NS.svc
David Bainbridge3517f6c2020-04-08 12:14:08 -07002384 _PORT=2379
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002385 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
2386 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.address=$_HOST:$_PORT"
David Bainbridged18f4942020-04-14 16:46:13 -07002387 elif [ "$WITH_ETCD" != "no" ]; then
2388 _HOST="$(echo "$WITH_ETCD" | cut -d: -f1)"
2389 _PORT="$(echo "$WITH_ETCD" | cut -s -d: -f2)"
David Bainbridge3517f6c2020-04-08 12:14:08 -07002390 _PORT=${_PORT:-2379}
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002391 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
2392 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.address=$_HOST:$_PORT"
David Bainbridge696bc632020-04-05 21:49:37 -07002393 fi
David Bainbridgec7220622020-05-28 12:31:47 -07002394 if is_in "$WITH_KAFKA" "yes,external"; then
2395 _HOST=kafka.$INFRA_NS.svc
David Bainbridge3517f6c2020-04-08 12:14:08 -07002396 _PORT=9092
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002397 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"
2398 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 -07002399 elif [ "$WITH_KAFKA" != "no" ]; then
2400 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
2401 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge3517f6c2020-04-08 12:14:08 -07002402 _PORT=${_PORT:-9092}
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002403 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"
2404 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 -07002405 fi
Girish Kumarcc5f9172020-06-10 13:34:31 +00002406 if [ "$WITH_TRACING" == "yes" ]; then
2407 VOLTHA_TRACING_CHART_NAME=$(resolve_chart_name "$VOLTHA_TRACING_CHART")
2408 _HOST="tracing-${VOLTHA_TRACING_CHART_NAME}-jaeger-agent.$INFRA_NS.svc"
2409 _PORT=6831
2410 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set tracing.enabled=true --set services.tracing_agent.address=$_HOST:$_PORT"
2411 fi
David Bainbridge46505fb2019-10-01 21:13:20 +00002412 echo -e "Verify Adapters $PLUG"
2413 if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then
2414 bspin - "Verify Simulated Adapters installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002415 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$ADAPTER_NS" "^sim\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002416 espin - "$NOT_VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002417 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 +00002418 else
David Bainbridged18f4942020-04-14 16:46:13 -07002419 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00002420 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002421 EXPECT="$((EXPECT + 2))"
David Bainbridge46505fb2019-10-01 21:13:20 +00002422 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07002423
David Bainbridge46505fb2019-10-01 21:13:20 +00002424 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
2425 bspin - "Verify OpenOLT Adapter installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002426 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$ADAPTER_NS" "^open-olt\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002427 espin - "$NOT_VERIFIED"
David Bainbridgea965ca22020-06-09 17:45:04 -07002428 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 +00002429 else
David Bainbridged18f4942020-04-14 16:46:13 -07002430 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00002431 fi
Matteo Scandolo67335f02020-04-09 11:19:53 -07002432 EXPECT="$((EXPECT + 1))"
David Bainbridge46505fb2019-10-01 21:13:20 +00002433 bspin - "Verify OpenONU Adapter installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002434 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$ADAPTER_NS" "^open-onu\$")" -ne 1 ]; then
Matteo Scandolo67335f02020-04-09 11:19:53 -07002435 _ORIGINAL_EXTRA_HELM_INSTALL_ARGS="$INTERNAL_EXTRA_HELM_INSTALL_ARGS"
2436 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set replicas.adapter_open_onu=$NUM_OF_OPENONU"
Girish Gowdra4cc5d8b2020-06-11 17:12:00 -07002437 if [ "$WITH_INCREMENTAL_EVTO_UPDATE" == "yes" ]; then
Girish Gowdra1c7ad4c2020-06-26 13:35:16 -07002438 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set defaults.incremental_evto_update=true"
Girish Gowdra4cc5d8b2020-06-11 17:12:00 -07002439 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002440 espin - "$NOT_VERIFIED"
David Bainbridgea965ca22020-06-09 17:45:04 -07002441 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 -07002442 INTERNAL_EXTRA_HELM_INSTALL_ARGS="$_ORIGINAL_EXTRA_HELM_INSTALL_ARGS"
David Bainbridge46505fb2019-10-01 21:13:20 +00002443 else
David Bainbridged18f4942020-04-14 16:46:13 -07002444 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00002445 fi
Matteo Scandolo67335f02020-04-09 11:19:53 -07002446 EXPECT=$((EXPECT + NUM_OF_OPENONU))
David Bainbridge46505fb2019-10-01 21:13:20 +00002447 fi
David Bainbridge696bc632020-04-05 21:49:37 -07002448 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07002449
David Bainbridge46505fb2019-10-01 21:13:20 +00002450 ADAPTERS="adapter-.*"
David Bainbridged18f4942020-04-14 16:46:13 -07002451 wait_for_pods - "$ADAPTER_NS" "$EXPECT" "includes" "Waiting for adapters to start" "$NO_LABEL" "$ADAPTERS"
David Bainbridge46505fb2019-10-01 21:13:20 +00002452 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002453 NOW="$(date +%s)"
2454 printtime $((NOW - STIME))
David Bainbridge46505fb2019-10-01 21:13:20 +00002455 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00002456fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002457
David Bainbridged18f4942020-04-14 16:46:13 -07002458if [ "$WITH_BBSIM" == "yes" ]; then
2459 STIME="$(date +%s)"
Test User7d866122019-07-09 17:52:35 +00002460 echo -e "Verify BBSIM $PLUG"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002461 bspin - "Verify BBSIM Installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002462 for instance in $(seq 0 $((NUM_OF_BBSIM-1))); do
Matteo Scandoloc2eb0672020-05-01 14:43:15 -07002463
2464 if [ "$LEGACY_BBSIM_INDEX" == "yes" ]; then
2465 if [ "$instance" -eq 0 ]; then
2466 instance_num=""
2467 else
2468 instance_num=$instance
2469 fi
David K. Bainbridge43422402020-03-06 07:41:22 -08002470 else
2471 instance_num=$instance
2472 fi
Matteo Scandoloc2eb0672020-05-01 14:43:15 -07002473
2474
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002475 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$BBSIM_NS" "^bbsim${instance_num}\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002476 espin - "$NOT_VERIFIED"
Matteo Scandolo6402d362020-08-24 12:31:06 -07002477
2478 if [[ $(semver_greater "$VOLTHA_BBSIM_CHART_VERSION" "3.1.0") == "true" ]]; then
2479 # this is the latest BBSim with support for TT
2480 # when we deploy multiple BBSims we need to update the configuration
2481 # to avoid overlapping tags.
2482 _TAG="$((900+instance))"
2483 BBSIM_TMP="$(mktemp -u)"
2484 sed -e "s/\":TAG:\"/$_TAG/g" "$BBSIM_CFG" > "$BBSIM_TMP"
2485
2486 INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set olt_id=$instance -f $BBSIM_TMP"
David Bainbridged9329af2020-05-01 11:58:52 -07002487 else
Matteo Scandolo6402d362020-08-24 12:31:06 -07002488 # these are older versio of BBSim
2489 S_TAG="$((900+instance))"
2490 INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set olt_id=$instance,s_tag=$S_TAG"
2491 if [ "$WITH_EAPOL" == "yes" ]; then
2492 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set auth=true"
2493 else
2494 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set auth=false"
2495 fi
2496 if [ "$WITH_DHCP" == "yes" ]; then
2497 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set dhcp=true"
2498 else
2499 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set dhcp=false"
2500 fi
David Bainbridged9329af2020-05-01 11:58:52 -07002501 fi
Matteo Scandolo6402d362020-08-24 12:31:06 -07002502
David Bainbridge33e56c72020-06-11 11:39:56 -07002503 if is_in "$WITH_KAFKA" "yes,external"; then
2504 _HOST=kafka.$INFRA_NS.svc
2505 _PORT=9092
2506 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafkaAddress=$_HOST:$_PORT"
2507 elif [ "$WITH_KAFKA" != "no" ]; then
2508 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
2509 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
2510 _PORT=${_PORT:-9092}
2511 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafkaAddress=$_HOST:$_PORT"
2512 fi
2513 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 -07002514 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
Matteo Scandolo6402d362020-08-24 12:31:06 -07002515 rm -f "$BBSIM_TMP"
David K. Bainbridge43422402020-03-06 07:41:22 -08002516 else
David Bainbridged18f4942020-04-14 16:46:13 -07002517 espin - "$VERIFIED"
David K. Bainbridge43422402020-03-06 07:41:22 -08002518 fi
2519 done
David Bainbridged18f4942020-04-14 16:46:13 -07002520 wait_for_pods - "$BBSIM_NS" "$NUM_OF_BBSIM" "includes" "Waiting for BBSIM to start" "$BBSIM_LABEL" "bbsim*"
Andrea Campanella8a75f722020-10-14 14:22:01 +02002521 if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
2522 for instance in $(seq 0 $((NUM_OF_BBSIM-1))); do
2523 bspin - "Forward BBSIM DMI port $FORWARD"
Andrea Campanellaeacf7f42020-10-15 14:46:33 +02002524 kill_port_forward "bbsim"
2525 _PORT=$((50075+instance))
2526 port_forward "$BBSIM_NS" "bbsim${instance}" "50075:$_PORT"
Andrea Campanella8a75f722020-10-14 14:22:01 +02002527 espin - "$VERIFIED"
2528 done
2529 fi
2530
David Bainbridgee87067b2019-08-12 22:00:12 +00002531 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002532 NOW="$(date +%s)"
2533 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002534 fi
Test User7d866122019-07-09 17:52:35 +00002535fi
2536
divyadesai59f987a2020-05-27 12:11:33 +00002537if [ "$WITH_EFK" == "yes" ]; then
2538 STIME="$(date +%s)"
2539 echo -e "Verify EFK $PLUG"
2540 bspin - "Verify EFK Installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002541 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 +00002542 espin - "$NOT_VERIFIED"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002543 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^elasticsearch\$")" -ne 1 ]; then
divyadesai59f987a2020-05-27 12:11:33 +00002544 helm_install - "$INFRA_NS" elasticsearch "$ELASTICSEARCH_CHART" "$ELASTICSEARCH_CHART_VERSION" elasticsearch "$_HELM_DESC elasticsearch"
2545 fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002546 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^kibana\$")" -ne 1 ]; then
divyadesai59f987a2020-05-27 12:11:33 +00002547 helm_install - "$INFRA_NS" kibana "$KIBANA_CHART" "$KIBANA_CHART_VERSION" kibana "$_HELM_DESC kibana"
2548 fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002549 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^fluentd\$")" -ne 1 ]; then
divyadesai59f987a2020-05-27 12:11:33 +00002550 helm_install - "$INFRA_NS" fluentd "$FLUENTD_ELASTICSEARCH_CHART" "$FLUENTD_ELASTICSEARCH_CHART_VERSION" fluentd-elasticsearch "$_HELM_DESC fluentd-elasticsearch"
2551 fi
2552 else
2553 espin - "$VERIFIED"
2554 fi
2555 EXPECT=2 # for elastic and kibana
2556 if [ "$TYPE" == "minimal" ]; then
2557 EXPECT=$((EXPECT + 2)) # for fluentd on worker 2 worker nodes
2558 else
2559 EXPECT=$((EXPECT + 3)) # for fluentd on worker 3 worker nodes
2560 fi
2561 if [ "$SCHEDULE_ON_CONTROL_NODES" == "yes" ]; then
2562 EXPECT=$((EXPECT + 1)) # for fluentd on the control plan node
2563 fi
2564
2565 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for EFK to start" "$NO_LABEL" "fluentd-* elasticsearch-* kibana-*"
2566 if [ "$WITH_TIMINGS" == "yes" ]; then
2567 NOW="$(date +%s)"
2568 printtime $((NOW - STIME))
2569 fi
2570fi
2571
David Bainbridge309099c2020-05-05 08:47:29 -07002572if [ "$CONFIG_SADIS" == "external" ]; then
2573 STIME="$(date +%s)"
2574 echo -e "Verify BBSIM SADIS Service $PLUG"
2575 bspin - "Verify required configmap"
2576 (set -x; kubectl -n "$BBSIM_NS" delete --ignore-not-found configmap kube-config >>"$LOG" 2>&1) >>"$LOG" 2>&1
2577 (set -x; kubectl -n "$BBSIM_NS" create configmap kube-config "--from-file=kube_config=$KUBECONFIG" >>"$LOG" 2>&1) >>"$LOG" 2>&1
2578 espin - "$VERIFIED"
2579 bspin - "Verify BBSIM SADIS Service Installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002580 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$BBSIM_NS" "^bbsim-sadis-server\$")" -ne 1 ]; then
David Bainbridge309099c2020-05-05 08:47:29 -07002581 espin - "$NOT_VERIFIED"
Matteo Scandolo871fd982020-07-23 11:46:51 -07002582 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"
2583 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
David Bainbridge309099c2020-05-05 08:47:29 -07002584 else
2585 espin - "$VERIFIED"
2586 fi
2587 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 +00002588
Matteo Scandolo21660442020-07-17 11:05:21 -07002589 if is_in "$WITH_ONOS" "yes,classic,legacy"; then
Ubuntu7135e6a2020-06-30 01:46:08 +00002590 if kubectl get -n "$BBSIM_NS" svc/bbsim-sadis-server-bbsim-sadis-server >/dev/null 2>&1; then
2591 BBSIM_SADIS_SVC="bbsim-sadis-server-bbsim-sadis-server"
2592 else
2593 BBSIM_SADIS_SVC="bbsim-sadis-server"
2594 fi
2595 push_onos_config "json" \
2596 "[optional] Push ONOS configuration for custom SADIS and Bandwidth Profile servers" \
2597 "network/configuration/apps/org.opencord.sadis" \
2598 "$(cat <<EOJ | tr -d '[:space:]'
2599{
2600 "sadis": {
2601 "integration": {
2602 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:58080/subscribers/%s",
2603 "cache": {
2604 "enabled": true,
2605 "maxsize": 50,
2606 "ttl": "PT1m"
2607 }
2608 }
2609 },
2610 "bandwidthprofile": {
2611 "integration": {
2612 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:58080/profiles/%s",
2613 "cache": {
2614 "enabled": true,
2615 "maxsize": 50,
2616 "ttl": "PT1m"
2617 }
2618 }
2619 }
2620}
2621EOJ
2622)"
2623 fi
David Bainbridge309099c2020-05-05 08:47:29 -07002624 if [ "$WITH_TIMINGS" == "yes" ]; then
2625 NOW="$(date +%s)"
2626 printtime $((NOW - STIME))
2627 fi
2628fi
2629
David Bainbridged18f4942020-04-14 16:46:13 -07002630if [ "$WITH_RADIUS" == "yes" ]; then
2631 STIME="$(date +%s)"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002632 echo -e "Verify RADIUS $LOCK"
2633 bspin - "Verify RADIUS Installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002634 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^radius\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002635 espin - "$NOT_VERIFIED"
David Bainbridge879439b2020-06-12 15:59:35 -07002636 helm_install - "$INFRA_NS" radius "$RADIUS_CHART" "$RADIUS_CHART_VERSION" "+radius" "$_HELM_DESC RADIUS"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002637 else
David Bainbridged18f4942020-04-14 16:46:13 -07002638 espin - "$VERIFIED"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002639 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002640 wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for RADIUS to start" "$NO_LABEL" "radius-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00002641 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002642 NOW="$(date +%s)"
2643 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002644 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002645fi
2646
David Bainbridged18f4942020-04-14 16:46:13 -07002647if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
2648 STIME="$(date +%s)"
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002649 bspin - "Forward VOLTHA API port $FORWARD"
David Bainbridge1d2c5842020-06-03 15:29:07 -07002650 kill_port_forward voltha-api voltha-voltha-api
2651 VOLTHA_PREFIX=
2652 if kubectl get -n "$VOLTHA_NS" "svc/voltha-voltha-api" >/dev/null 2>&1; then
2653 VOLTHA_PREFIX="voltha-"
2654 fi
Matteo Scandolo21660442020-07-17 11:05:21 -07002655
David Bainbridge1d2c5842020-06-03 15:29:07 -07002656 port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-api" "$VOLTHA_API_PORT:55555"
David Bainbridged18f4942020-04-14 16:46:13 -07002657 espin - "$VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002658 if is_in "$WITH_ETCD" "yes,external"; then
David Bainbridge696bc632020-04-05 21:49:37 -07002659 bspin - "Forward VOLTHA ETCD port $FORWARD"
David Bainbridgec7220622020-05-28 12:31:47 -07002660 kill_port_forward "etcd"
2661 port_forward "$INFRA_NS" "etcd" "$VOLTHA_ETCD_PORT:2379"
David Bainbridged18f4942020-04-14 16:46:13 -07002662 espin - "$VERIFIED"
David Bainbridge696bc632020-04-05 21:49:37 -07002663 fi
David Bainbridgec7220622020-05-28 12:31:47 -07002664 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridge696bc632020-04-05 21:49:37 -07002665 bspin - "Forward VOLTHA Kafka port $FORWARD"
David Bainbridgec7220622020-05-28 12:31:47 -07002666 kill_port_forward "kafka"
2667 port_forward "$INFRA_NS" kafka "$VOLTHA_KAFKA_PORT:9092"
David Bainbridged18f4942020-04-14 16:46:13 -07002668 espin - "$VERIFIED"
David Bainbridge696bc632020-04-05 21:49:37 -07002669 fi
divyadesai59f987a2020-05-27 12:11:33 +00002670 if [ "$WITH_EFK" == "yes" ]; then
2671 bspin - "Forward EFK port $FORWARD"
2672 kill_port_forward elasticsearch-master
2673 kill_port_forward kibana-kibana
2674 port_forward "$INFRA_NS" elasticsearch-master "$ELASTICSEARCH_PORT:9200"
2675 port_forward "$INFRA_NS" kibana-kibana "$KIBANA_PORT:5601"
2676 espin - "$VERIFIED"
2677 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -07002678 if [ "$WITH_PPROF" == "yes" ]; then
David Bainbridge1d2c5842020-06-03 15:29:07 -07002679 VOLTHA_OPENOLT_PREFIX=
2680 if kubectl get -n "$ADAPTER_NS" "svc/open-olt-adapter-open-olt-profiler" >/dev/null 2>&1; then
2681 VOLTHA_OPENOLT_PREFIX="open-olt-"
2682 fi
David Bainbridge879439b2020-06-12 15:59:35 -07002683 bspin - "Forward PProf ports port $FORWARD"
2684 kill_port_forward voltha-rw-core-profiler voltha-voltha-rw-core-profiler
2685 kill_port_forward adapter-open-olt-profiler open-olt-adapter-open-olt-profiler
2686 kill_port_forward voltha-of-agent-profiler voltha-voltha-of-agent-profiler
2687 port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-rw-core-profiler" "$VOLTHA_PPROF_PORT:6060"
2688 port_forward "$ADAPTER_NS" "${VOLTHA_OPENOLT_PREFIX}adapter-open-olt-profiler" "$OPENOLT_PPROF_PORT:6060"
2689 port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-of-agent-profiler" "$OFAGENT_PPROF_PORT:6060"
2690 espin - "$VERIFIED"
Matteo Scandoloefee0432020-05-05 13:56:20 -07002691 fi
Girish Kumarcc5f9172020-06-10 13:34:31 +00002692 if [ "$WITH_TRACING" == "yes" ]; then
2693 bspin - "Forward VOLTHA Tracing GUI port $FORWARD"
2694 VOLTHA_TRACING_CHART_NAME=$(resolve_chart_name "$VOLTHA_TRACING_CHART")
2695 kill_port_forward "tracing-${VOLTHA_TRACING_CHART_NAME}-jaeger-gui"
2696 port_forward "$INFRA_NS" "tracing-${VOLTHA_TRACING_CHART_NAME}-jaeger-gui" "$TRACING_GUI_PORT:16686"
2697 espin - "$VERIFIED"
2698 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002699 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002700 NOW="$(date +%s)"
2701 printtime $((NOW - STIME))
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002702 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00002703fi
Test User3d7ad8e2019-07-03 06:15:44 +00002704
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002705if is_in "$WITH_ONOS" "yes,legacy,classic" && [ "$WITH_RADIUS" != "no" ]; then
David Bainbridge879439b2020-06-12 15:59:35 -07002706 SVC_NAME=radius
2707 if kubectl get -n "$INFRA_NS" "svc/radius-freeradius" >/dev/null 2>&1; then
2708 SVC_NAME="radius-freeradius"
2709 fi
2710 _HOST="$SVC_NAME.$INFRA_NS.svc"
David Bainbridge696bc632020-04-05 21:49:37 -07002711 _PORT=1812
David Bainbridged18f4942020-04-14 16:46:13 -07002712 if [ "$WITH_RADIUS" != "yes" ]; then
2713 _HOST="$(echo "$WITH_RADIUS" | cut -d: -f1)"
2714 _PORT="$(echo "$WITH_RADIUS" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07002715 _PORT=${_PORT:-1812}
2716 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002717 bspin "Configure ONOS RADIUS Connection $GEAR"
David Bainbridged18f4942020-04-14 16:46:13 -07002718 (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
2719 espin "$VERIFIED"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002720fi
2721
divyadesai59f987a2020-05-27 12:11:33 +00002722if [ "$WITH_EFK" == "yes" ]; then
2723 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"
2724# fi
2725fi
2726
David Bainbridge99ac7a22019-08-31 02:26:43 +00002727if [ "$WITH_CHAOS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002728 STIME="$(date +%s)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002729 echo -e "Verify kube-monkey $LOCK"
2730 bspin - "Verify kube-monkey Installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002731 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed kube-monkey "^monkey\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002732 espin - "$NOT_VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002733 helm_install - kube-monkey monkey ./kube-monkey/helm/kubemonkey latest - "$_HELM_DESC Chaos Monkey"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002734 else
David Bainbridged18f4942020-04-14 16:46:13 -07002735 espin - "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002736 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002737 wait_for_pods - "kube-monkey" 1 "includes" "Waiting for Chaos to start" "$NO_LABEL" "monkey-.*"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002738 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002739 NOW="$(date +%s)"
2740 printtime $((NOW - STIME))
David Bainbridge99ac7a22019-08-31 02:26:43 +00002741 fi
2742fi
2743
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002744bspin "Create voltctl configuration file"
David Bainbridged18f4942020-04-14 16:46:13 -07002745(set -x; mkdir -p "$HOME/.volt" >>"$LOG" 2>&1) >>"$LOG" 2>&1
2746MIN_VC_VERSION="$(echo -e "1.0.15\n$VC_VERSION" | sort -V | head -1)"
2747if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002748 KAFKA_FLAG="-k localhost:$VOLTHA_KAFKA_PORT"
2749 SERVER_FLAG="-s localhost:$VOLTHA_API_PORT"
2750 ETCD_FLAG=
2751 if [ "$MIN_VC_VERSION" == "1.0.15" ]; then
2752 ETCD_FLAG="-e localhost:$VOLTHA_ETCD_PORT"
2753 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002754else
David Bainbridgec7220622020-05-28 12:31:47 -07002755 KAFKA_FLAG="-k $(get_service_ep "$INFRA_NS" kafka)"
David Bainbridged18f4942020-04-14 16:46:13 -07002756 SERVER_FLAG="-s $(get_service_ep "$VOLTHA_NS" voltha-api)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002757 ETCD_FLAG=
2758 if [ "$MIN_VC_VERSION" == "1.0.15" ]; then
David Bainbridgec7220622020-05-28 12:31:47 -07002759 ETCD_FLAG="-e $(get_service_ep "$INFRA_NS" etcd)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002760 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002761fi
David Bainbridgea965ca22020-06-09 17:45:04 -07002762CMD=("voltctl $KAFKA_FLAG $SERVER_FLAG $ETCD_FLAG config")
David Bainbridged18f4942020-04-14 16:46:13 -07002763(set -x; ${CMD[*]} > "$HOME/.volt/config-$NAME" 2>>"$LOG") >>"$LOG" 2>&1
David Bainbridgea965ca22020-06-09 17:45:04 -07002764#(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 -07002765espin "$VERIFIED"
Test User08ebbd92019-07-03 17:15:39 +00002766
David Bainbridge0774b232019-08-02 06:37:19 +00002767if [ ! -f "$NAME-env.sh" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002768 touch "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002769fi
2770
David Bainbridge596f30d2019-07-30 17:07:59 +00002771for O in $ALL_OPTIONS; do
David Bainbridged18f4942020-04-14 16:46:13 -07002772 VAL="$(eval echo "\$$O")"
2773 if [ -n "$VAL" ] && [ "$(grep -c "^export $O=" "$NAME-env.sh")" -eq 0 ]; then
2774 echo "export $O=\"$(eval echo "\$$O")\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002775 fi
2776done
2777
David Bainbridged18f4942020-04-14 16:46:13 -07002778if [ "$DEPLOY_K8S" == "yes" ] && [ "$(grep -c "^export KUBECONFIG=" "$NAME-env.sh")" -eq 0 ]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002779 echo "export KUBECONFIG=\"$HOME/.kube/kind-config-voltha-$NAME\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002780fi
2781
David Bainbridged18f4942020-04-14 16:46:13 -07002782if [ "$(grep -c "^export VOLTCONFIG=" "$NAME-env.sh")" -eq 0 ]; then
2783 echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002784fi
2785
David Bainbridged18f4942020-04-14 16:46:13 -07002786if [ "$(grep -c "^export PATH=" "$NAME-env.sh")" -eq 0 ]; then
2787 echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002788fi
2789
Test User7d866122019-07-09 17:52:35 +00002790echo ""
David Bainbridged18f4942020-04-14 16:46:13 -07002791echo "Please issue the following commands in your terminal to ensure that you" | tee -a "$LOG"
2792echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a "$LOG"
2793echo "tools required by VOLTHA in your command path. " | tee -a "$LOG"
2794echo "" | tee -a "$LOG"
2795echo -en "$BOLD"
2796if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002797 echo "export KUBECONFIG=\"$HOME/.kube/kind-config-voltha-$NAME\"" | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00002798fi
David Bainbridged18f4942020-04-14 16:46:13 -07002799echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" | tee -a "$LOG"
2800echo "export PATH=$GOPATH/bin:\$PATH" | tee -a "$LOG"
2801echo -en "$NORMAL"
2802echo "" | tee -a "$LOG"
2803echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a "$LOG"
Test User08ebbd92019-07-03 17:15:39 +00002804
David Bainbridge712afb82019-08-14 19:55:58 +00002805if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002806 NOW="$(date +%s)"
2807 echo -e "$CLOCK ${BOLD}TOTAL: $(duration $((NOW - TOTAL_START_TIME)))${NORMAL}"
David Bainbridge712afb82019-08-14 19:55:58 +00002808fi