blob: 6eccbebcd41963ac020869240bec323d01d8f91e [file] [log] [blame]
Test User01ed0642019-07-03 20:17:06 +00001#!/bin/bash
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002# Copyright 2019 Ciena Corporation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
David Bainbridged049a612020-03-16 17:22:54 -070015set -f
David Bainbridged18f4942020-04-14 16:46:13 -070016unalias -a
David Bainbridge60ffc0f2020-04-27 22:13:22 -070017shopt -s extglob
David Bainbridged18f4942020-04-14 16:46:13 -070018TOTAL_START_TIME="$(date +%s)"
David Bainbridgeb4bbde12020-06-25 14:46:36 -070019mkdir -p "$(pwd)/bin"
20PATH="$(pwd)/bin:$PATH"; export PATH
21GOPATH="$(pwd)"; export GOPATH
David K. Bainbridgeb7285432019-07-02 22:05:24 -070022
David Bainbridge38dc1e82019-08-12 15:18:45 +000023FANCY=${FANCY:-1}
24if [ "$TERM X" == " X" ]; then
25 FANCY=0
26fi
27
David K. Bainbridgeb7285432019-07-02 22:05:24 -070028# trap ctrl-c and call ctrl_c()
29trap ctrl_c INT
30
31function ctrl_c() {
David Bainbridged18f4942020-04-14 16:46:13 -070032 echo -en "$CNORM"
David K. Bainbridgeb7285432019-07-02 22:05:24 -070033 echo ""
34 echo "ctrl-c trapped"
David Bainbridgec6a6eb62019-10-18 22:50:07 +000035 echo "Thank you for trying 'voltha up'"
David K. Bainbridgeb7285432019-07-02 22:05:24 -070036 exit
37}
38
Andrea Campanella40e48b72020-07-21 20:32:52 +020039HELM_VERSION=${HELM_VERSION:-v3.2.4}
David K. Bainbridgeebf38d92020-02-10 10:46:31 -080040VOLTCTL_VERSION=${VOLTCTL_VERSION:-latest}
David K. Bainbridge88a7a792020-07-27 17:01:14 +000041KIND_VERSION=${KIND_VERSION:-v0.8.1}
David K. Bainbridgeb3a99372020-01-08 14:39:06 -080042VK_RELEASE=${VK_RELEASE:-master}
David Bainbridge60ffc0f2020-04-27 22:13:22 -070043EXTRA_TOOLS=
Test User08ebbd92019-07-03 17:15:39 +000044
David Bainbridge38dc1e82019-08-12 15:18:45 +000045RED=
46GREEN=
47YELLOW=
48BLUE=
David Bainbridge38dc1e82019-08-12 15:18:45 +000049BOLD=
50NORMAL=
51ERROR=
52CEOL=
53CNORM=
54CIVIS=
David Bainbridged18f4942020-04-14 16:46:13 -070055if [ "$FANCY" -eq 1 ]; then
56 RED="$(tput setaf 1)"
57 GREEN="$(tput setaf 2)"
58 YELLOW="$(tput setaf 3)"
59 BLUE="$(tput setaf 4)"
60 BOLD="$(tput bold)"
61 NORMAL="$(tput sgr0)"
David Bainbridge38dc1e82019-08-12 15:18:45 +000062 ERROR="\xe2\x9c\x97\x20"
David Bainbridged18f4942020-04-14 16:46:13 -070063 CEOL="$(tput el)"
64 CNORM="$(tput cnorm)"
65 CIVIS="$(tput civis)"
David Bainbridge38dc1e82019-08-12 15:18:45 +000066fi
Test User7d866122019-07-09 17:52:35 +000067
Matteo Scandolo657e13c2020-07-28 11:41:42 -070068NAME=${NAME:-minimal}
David K. Bainbridge484d80c2020-03-05 21:44:34 -080069
70ENABLE_ONOS_EXTRANEOUS_RULES=${ENABLE_ONOS_EXTRANEOUS_RULES:-no}
David Bainbridge76afd812020-04-06 09:53:52 -070071INFRA_NS=${INFRA_NS:-default}
72VOLTHA_NS=${VOLTHA_NS:-voltha}
73BBSIM_NS=${BBSIM_NS:-voltha}
74ADAPTER_NS=${ADAPTER_NS:-voltha}
David Bainbridgee87067b2019-08-12 22:00:12 +000075WITH_TIMINGS=${WITH_TIMINGS:-no}
Test User7d866122019-07-09 17:52:35 +000076WITH_BBSIM=${WITH_BBSIM:-no}
divyadesai59f987a2020-05-27 12:11:33 +000077WITH_EFK=${WITH_EFK:-no}
Girish Kumarcc5f9172020-06-10 13:34:31 +000078WITH_TRACING=${WITH_TRACING:-no}
David Bainbridge5b7b96b2019-07-25 20:29:13 +000079WITH_RADIUS=${WITH_RADIUS:-no}
Matteo Scandolo78dfee02020-02-13 16:18:03 -080080WITH_EAPOL=${WITH_EAPOL:-yes}
81WITH_DHCP=${WITH_DHCP:-yes}
82WITH_IGMP=${WITH_IGMP:-no}
David Bainbridgeb270c202019-07-26 01:44:42 +000083WITH_ONOS=${WITH_ONOS:-yes}
David Bainbridge60ffc0f2020-04-27 22:13:22 -070084NUM_OF_ONOS=${NUM_OF_ONOS:-1}
85NUM_OF_ATOMIX=${NUM_OF_ATOMIX:-0}
David Bainbridge99ac7a22019-08-31 02:26:43 +000086WITH_CHAOS=${WITH_CHAOS:-no}
David Bainbridge46505fb2019-10-01 21:13:20 +000087WITH_ADAPTERS=${WITH_ADAPTERS:-yes}
David K. Bainbridgeda33d652020-03-06 10:31:23 -080088WITH_SIM_ADAPTERS=${WITH_SIM_ADAPTERS:-no}
David Bainbridge46505fb2019-10-01 21:13:20 +000089WITH_OPEN_ADAPTERS=${WITH_OPEN_ADAPTERS:-yes}
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -080090WITH_PORT_FORWARDS=${WITH_PORT_FORWARDS:-yes}
David Bainbridge696bc632020-04-05 21:49:37 -070091WITH_KAFKA=${WITH_KAFKA:-yes}
92WITH_ETCD=${WITH_ETCD:-yes}
Matteo Scandoloefee0432020-05-05 13:56:20 -070093WITH_PPROF=${WITH_PPROF:-no}
Girish Gowdra4cc5d8b2020-06-11 17:12:00 -070094WITH_INCREMENTAL_EVTO_UPDATE=${WITH_INCREMENTAL_EVTO_UPDATE:-no}
David Bainbridgee4d11ca2020-05-08 10:21:10 -070095SCHEDULE_ON_CONTROL_NODES=${SCHEDULE_ON_CONTROL_NODES:-no}
David Bainbridge309099c2020-05-05 08:47:29 -070096CONFIG_SADIS=${CONFIG_SADIS:-no} # yes | no | file | bbsim | external | URL
Hardik Windlassb3147602020-03-09 16:59:15 +053097SADIS_CFG=${SADIS_CFG:-onos-files/onos-sadis-sample.json}
Matteo Scandolo6402d362020-08-24 12:31:06 -070098BBSIM_CFG=${BBSIM_CFG:-configs/bbsim-sadis-att.yaml}
David Bainbridge27790d62019-08-13 22:43:19 +000099INSTALL_ONOS_APPS=${INSTALL_ONOS_APPS:-no}
Test Userba1e7e72019-07-10 22:27:54 +0000100JUST_K8S=${JUST_K8S:-no}
101DEPLOY_K8S=${DEPLOY_K8S:-yes}
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700102INSTALL_KUBECTL=${INSTALL_KUBECTL:-yes}
103INSTALL_HELM=${INSTALL_HELM:-yes}
David Bainbridge7f8bf992020-04-08 21:53:22 -0700104HELM_USE_UPGRADE=${HELM_USE_UPGRADE:-no}
David Bainbridge46505fb2019-10-01 21:13:20 +0000105UPDATE_HELM_REPOS=${UPDATE_HELM_REPOS:-yes}
Matteo Scandolofab98622020-01-28 15:17:20 -0800106WAIT_ON_DOWN=${WAIT_ON_DOWN:-yes}
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700107WAIT_TIMEOUT=${WAIT_TIMEOUT:-30m}
108VOLTHA_DOWN_ON_TIMEOUT=${VOLTHA_DOWN_ON_TIMEOUT:-no}
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000109VOLTHA_LOG_LEVEL=${VOLTHA_LOG_LEVEL:-WARN}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000110VOLTHA_CHART=${VOLTHA_CHART:-onf/voltha}
111VOLTHA_CHART_VERSION=${VOLTHA_CHART_VERSION:-latest}
112VOLTHA_BBSIM_CHART=${VOLTHA_BBSIM_CHART:-onf/bbsim}
Matteo Scandolo6402d362020-08-24 12:31:06 -0700113VOLTHA_BBSIM_CHART_VERSION=${VOLTHA_BBSIM_CHART_VERSION:-4.0.0-dev}
divyadesai59f987a2020-05-27 12:11:33 +0000114ELASTICSEARCH_CHART=${ELASTICSEARCH_CHART:-elastic/elasticsearch}
115ELASTICSEARCH_CHART_VERSION=${ELASTICSEARCH_CHART_VERSION:-latest}
116KIBANA_CHART=${KIBANA_CHART:-elastic/kibana}
117KIBANA_CHART_VERSION=${KIBANA_CHART_VERSION:-latest}
118FLUENTD_ELASTICSEARCH_CHART=${FLUENTD_ELASTICSEARCH_CHART:-kiwigrid/fluentd-elasticsearch}
119FLUENTD_ELASTICSEARCH_CHART_VERSION=${FLUENTD_ELASTICSEARCH_CHART_VERSION:-latest}
Girish Kumarcc5f9172020-06-10 13:34:31 +0000120VOLTHA_TRACING_CHART=${VOLTHA_TRACING_CHART:-onf/voltha-tracing}
121VOLTHA_TRACING_CHART_VERSION=${VOLTHA_TRACING_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000122VOLTHA_ADAPTER_SIM_CHART=${VOLTHA_ADAPTER_SIM_CHART:-onf/voltha-adapter-simulated}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000123VOLTHA_ADAPTER_SIM_CHART_VERSION=${VOLTHA_ADAPTER_SIM_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000124VOLTHA_ADAPTER_OPEN_OLT_CHART=${VOLTHA_ADAPTER_OPEN_OLT_CHART:-onf/voltha-adapter-openolt}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000125VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION=${VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000126VOLTHA_ADAPTER_OPEN_ONU_CHART=${VOLTHA_ADAPTER_OPEN_ONU_CHART:-onf/voltha-adapter-openonu}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000127VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION=${VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION:-latest}
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800128ONOS_CHART=${ONOS_CHART:-onf/onos}
Andrea Campanella21323292019-12-18 11:44:19 -0800129ONOS_CHART_VERSION=${ONOS_CHART_VERSION:-latest}
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700130ONOS_CLASSIC_CHART=${ONOS_CLASSIC_CHART:-onos/onos-classic}
Andrea Campanella26c8c992020-08-24 15:43:26 +0000131ONOS_CLASSIC_CHART_VERSION=${ONOS_CLASSIC_CHART_VERSION:-latest}
David Bainbridgecf546362020-04-21 23:18:50 -0700132KAFKA_CHART=${KAFKA_CHART:-incubator/kafka}
David Bainbridgeb4bbde12020-06-25 14:46:36 -0700133KAFKA_CHART_VERSION=${KAFKA_CHART_VERSION:=latest}
David Bainbridge309099c2020-05-05 08:47:29 -0700134BBSIM_SADIS_SERVER_CHART=${BBSIM_SADIS_SERVER_CHART:-bbsim-sadis/bbsim-sadis-server}
135BBSIM_SADIS_SERVER_CHART_VERSION=${BBSIM_SADIS_SERVER_CHART_VERSION:-latest}
David Bainbridgeb4bbde12020-06-25 14:46:36 -0700136ETCD_CHART=${ETCD_CHART:-etcd/etcd}
David Bainbridgec7220622020-05-28 12:31:47 -0700137ETCD_CHART_VERSION=${ETCD_CHART_VERSION:-latest}
David Bainbridge879439b2020-06-12 15:59:35 -0700138RADIUS_CHART=${RADIUS_CHART:-onf/freeradius}
139RADIUS_CHART_VERSION=${RADIUS_CHART_VERSION:-latest}
David Bainbridge2eaf2cf2020-03-18 12:54:08 -0700140EXTRA_HELM_INSTALL_ARGS=${EXTRA_HELM_INSTALL_ARGS:-}
141INTERNAL_EXTRA_HELM_INSTALL_ARGS=
uottrembb16d3982020-02-28 08:34:36 +0100142NUM_OF_BBSIM=${NUM_OF_BBSIM:-1}
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700143NUM_OF_WORKER_NODES=${NUM_OF_WORKER_NODES:-2}
144NUM_OF_CONTROLLER_NODES=${NUM_OF_CONTROLLER_NODES:-1}
Matteo Scandolo67335f02020-04-09 11:19:53 -0700145NUM_OF_OPENONU=${NUM_OF_OPENONU:-1}
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700146NUM_OF_KAFKA=${NUM_OF_KAFKA:-1}
147NUM_OF_ETCD=${NUM_OF_ETCD:-1}
uottrembb16d3982020-02-28 08:34:36 +0100148MAX_NUM_OF_BBSIM=10
Matteo Scandolo67335f02020-04-09 11:19:53 -0700149MAX_NUM_OF_OPENONU=10
Matteo Scandoloc2eb0672020-05-01 14:43:15 -0700150LEGACY_BBSIM_INDEX=${LEGACY_BBSIM_INDEX:-no}
David Bainbridgeb4bbde12020-06-25 14:46:36 -0700151PF_ADDRESS=${PF_ADDRESS:-0.0.0.0}
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700152KIND_CFG_FILE=${KIND_CFG_FILE:-}
Test Userba1e7e72019-07-10 22:27:54 +0000153
David Bainbridged18f4942020-04-14 16:46:13 -0700154HOSTOS="$(uname -s | tr "[:upper:]" "[:lower:"])"
155HOSTARCH="$(uname -m | tr "[:upper:]" "[:lower:"])"
156if [ "$HOSTARCH" == "x86_64" ]; then
Test Userba1e7e72019-07-10 22:27:54 +0000157 HOSTARCH="amd64"
158fi
David Bainbridge7db44002020-04-09 12:54:29 -0700159BBSIM_LABEL="-l app=bbsim"
David Bainbridged18f4942020-04-14 16:46:13 -0700160NO_LABEL=
Test User7d866122019-07-09 17:52:35 +0000161
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700162# checks to see if a given WORD is in the given LIST of words
163function is_in() {
164 local WORD LIST
165 WORD="$1"; shift
166 LIST="$*"
167 LIST=${LIST//+([[:space:],|])/:}
168
169 [ "$(echo ":$LIST:" | grep -ic ":$WORD:")" -ne 0 ]
170}
171
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700172function parseDuration() {
David Bainbridged18f4942020-04-14 16:46:13 -0700173 local DUR RESULT TERM TERMS VALUE UNIT
174 DUR=$1
175 RESULT=0
176 TERMS="$(echo "$DUR" | sed -Ee 's/([sSmMhHdD])/\1 /g' -e 's/,$//g')"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700177 for TERM in $TERMS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700178 VALUE="$(echo "$TERM" | sed -Ee 's/([0-9]+)[sSmMhHdD]/\1/')"
179 UNIT="$(echo "$TERM" | sed -Ee 's/[0-9]+([sSmMhHdD])/\1/')"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700180 case $UNIT in
181 s|S)
David Bainbridged18f4942020-04-14 16:46:13 -0700182 RESULT=$((RESULT + VALUE)) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700183 m|M)
David Bainbridged18f4942020-04-14 16:46:13 -0700184 RESULT=$((RESULT + (VALUE * 60))) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700185 h|H)
David Bainbridged18f4942020-04-14 16:46:13 -0700186 RESULT=$((RESULT + (VALUE * 3600))) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700187 d|D)
David Bainbridged18f4942020-04-14 16:46:13 -0700188 RESULT=$((RESULT + (VALUE * 86400))) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700189 *) ;;
190 esac
191 done
192 echo $RESULT
193}
194
195function doTimeout() {
196 local MSG=$1
197 2>&1 echo -e "\n${RED}${BOLD}${ERROR}TIMEOUT:${NORMAL}${RED} Operation timed out after '$WAIT_TIMEOUT': $MSG"
198 exit 125
199}
200
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800201function get_service_ep() {
202 local NS=$1
203 local NAME=$2
David Bainbridged18f4942020-04-14 16:46:13 -0700204 kubectl -n "$NS" get service "$NAME" -o json | jq -r '.spec.clusterIP + ":" + (.spec.ports[0].port|tostring)'
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800205}
206
Matteo Scandolo6402d362020-08-24 12:31:06 -0700207# returns the greater version (0 if equal)
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
251# returns true if v1 is less than v2
252function semver_greater() {
253 local v1
254 local v2
255 v1=("$1") v2=("$2")
256
257 # shellcheck disable=SC2128
258 if [[ "$v1" == "latest" ]] || [[ "$v1" == "master" ]]; then
259 # if the version is latest or master we can't really compare,
260 # but we assume is greater
261 echo "true"
262 return
263 fi
264
265 # shellcheck disable=SC2128
266 res=$(semvercompare "$v1" "$v2")
267 if [[ $res == 1 ]]; then
268 echo "true"
269 else
270 echo "false"
271 fi
272}
273
274# returns true if v2 is less than v1
275function semver_lesser() {
276 local v1
277 local v2
278 v1=("$1") v2=("$2")
279
280 # shellcheck disable=SC2128
281 if [[ "$v1" == "latest" ]] || [[ "$v1" == "master" ]]; then
282 # if the version is latest or master we can't really compare,
283 # but we assume is greater
284 echo "false"
285 return
286 fi
287
288 # shellcheck disable=SC2128
289 res=$(semvercompare "$v1" "$v2")
290 if [[ $res == 2 ]]; then
291 echo "true"
292 else
293 echo "false"
294 fi
295}
296
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000297# Used to verify configuration values are set to "yes" or "no" value or convert
298# equivalents to "yes" or "no"
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700299YES="y,yes,t,true,1"
300NO="n,no,f,false,0"
301YES_OR_NO="$YES,$NO"
302
303# If the given VAR matches a truth value then normalize that
304# value, else return original value
305function normalize_yes_no() {
306 local VAR VAL
307 VAR=$1
308 VAL="$(eval echo "\$$VAR")"
309 if ! is_in "$VAL" "$YES_OR_NO"; then
310 echo "$VAL"
311 return 1
312 fi
313 if is_in "$VAL" "$YES"; then
314 echo "yes"
315 else
316 echo "no"
317 fi
318 return 0
319}
320
321# If the given VAR matches a truth value then normalize that
322# value, else display an error
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000323function verify_yes_no() {
David Bainbridged18f4942020-04-14 16:46:13 -0700324 local VAR VAL
325 VAR=$1
326 VAL="$(eval echo "\$$VAR")"
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700327 if ! is_in "$VAL" "$YES_OR_NO"; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000328 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid '$VAR' value of '$VAL'. Should be 'yes' or 'no'${NORMAL}"
329 echo "INVALID"
330 return 1
331 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700332 if is_in "$VAL" "$YES"; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000333 echo "yes"
334 else
335 echo "no"
336 fi
337 return 0
338}
Test User7d866122019-07-09 17:52:35 +0000339
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000340ALL_YES_NO="\
David K. Bainbridge484d80c2020-03-05 21:44:34 -0800341 ENABLE_ONOS_EXTRANEOUS_RULES \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000342 WITH_TIMINGS \
343 WITH_BBSIM \
divyadesai59f987a2020-05-27 12:11:33 +0000344 WITH_EFK \
Girish Kumarcc5f9172020-06-10 13:34:31 +0000345 WITH_TRACING \
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800346 WITH_EAPOL \
347 WITH_DHCP \
348 WITH_IGMP \
David Bainbridge99ac7a22019-08-31 02:26:43 +0000349 WITH_CHAOS \
David Bainbridge46505fb2019-10-01 21:13:20 +0000350 WITH_ADAPTERS \
351 WITH_SIM_ADAPTERS \
352 WITH_OPEN_ADAPTERS \
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800353 WITH_PORT_FORWARDS \
Matteo Scandoloefee0432020-05-05 13:56:20 -0700354 WITH_PPROF \
Girish Gowdra4cc5d8b2020-06-11 17:12:00 -0700355 WITH_INCREMENTAL_EVTO_UPDATE \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000356 JUST_K8S \
357 DEPLOY_K8S \
358 INSTALL_ONOS_APPS \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000359 INSTALL_KUBECTL \
360 INSTALL_HELM \
David Bainbridge7f8bf992020-04-08 21:53:22 -0700361 HELM_USE_UPGRADE \
David Bainbridge46505fb2019-10-01 21:13:20 +0000362 UPDATE_HELM_REPOS \
David Bainbridge4f1b5562019-08-19 04:46:52 +0000363 WAIT_ON_DOWN \
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700364 VOLTHA_DOWN_ON_TIMEOUT \
Matteo Scandoloc2eb0672020-05-01 14:43:15 -0700365 LEGACY_BBSIM_INDEX \
David Bainbridgee4d11ca2020-05-08 10:21:10 -0700366 SCHEDULE_ON_CONTROL_NODES \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000367 "
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000368
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700369OPT_YES_NO="\
370 CONFIG_SADIS \
371 WITH_KAFKA \
372 WITH_RADIUS \
373 WITH_ETCD \
374 WITH_ONOS \
375 "
376
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000377ALL_OPTIONS="\
378 NAME \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000379 $ALL_YES_NO \
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700380 $OPT_YES_NO \
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700381 WAIT_TIMEOUT \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000382 VOLTHA_LOG_LEVEL \
383 VOLTHA_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000384 VOLTHA_CHART_VERSION \
385 VOLTHA_BBSIM_CHART \
386 VOLTHA_BBSIM_CHART_VERSION \
David Bainbridge879439b2020-06-12 15:59:35 -0700387 BBSIM_SADIS_SERVER_CHART \
388 BBSIM_SADIS_SERVER_CHART_VERSION \
Girish Kumarcc5f9172020-06-10 13:34:31 +0000389 VOLTHA_TRACING_CHART \
390 VOLTHA_TRACING_CHART_VERSION \
uottrembd5a20572020-03-06 09:15:01 +0100391 NUM_OF_BBSIM \
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700392 NUM_OF_WORKER_NODES \
393 NUM_OF_CONTROLLER_NODES \
394 NUM_OF_KAFKA \
395 NUM_OF_ETCD \
divyadesai59f987a2020-05-27 12:11:33 +0000396 ELASTICSEARCH_CHART \
397 ELASTICSEARCH_CHART_VERSION \
398 KIBANA_CHART \
399 KIBANA_CHART_VERSION \
400 FLUENTD_ELASTICSEARCH_CHART \
401 FLUENTD_ELASTICSEARCH_CHART_VERSION \
Matteo Scandolo67335f02020-04-09 11:19:53 -0700402 NUM_OF_OPENONU \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000403 VOLTHA_ADAPTER_SIM_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000404 VOLTHA_ADAPTER_SIM_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000405 VOLTHA_ADAPTER_OPEN_OLT_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000406 VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000407 VOLTHA_ADAPTER_OPEN_ONU_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000408 VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION \
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800409 ONOS_CHART \
Andrea Campanella21323292019-12-18 11:44:19 -0800410 ONOS_CHART_VERSION \
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700411 ONOS_CLASSIC_CHART \
412 ONOS_CLASSIC_CHART_VERSION \
David Bainbridgecf546362020-04-21 23:18:50 -0700413 KAFKA_CHART \
David Bainbridgeb9093522020-04-15 14:32:44 -0700414 KAFKA_CHART_VERSION \
David Bainbridge879439b2020-06-12 15:59:35 -0700415 ETCD_CHART \
416 ETCD_CHART_VERSION \
417 RADIUS_CHART \
418 RADIUS_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000419 ONOS_API_PORT \
420 ONOS_SSH_PORT \
Hardik Windlassb3147602020-03-09 16:59:15 +0530421 SADIS_CFG \
Matteo Scandolo6402d362020-08-24 12:31:06 -0700422 BBSIM_CFG \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000423 VOLTHA_API_PORT \
424 VOLTHA_SSH_PORT \
425 VOLTHA_ETCD_PORT \
divyadesai59f987a2020-05-27 12:11:33 +0000426 ELASTICSEARCH_PORT \
427 KIBANA_PORT \
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800428 VOLTHA_KAFKA_PORT \
Matteo Scandoloefee0432020-05-05 13:56:20 -0700429 VOLTHA_PPROF_PORT \
430 OPENOLT_PPROF_PORT \
Matteo Scandolo65c35192020-05-13 10:41:21 -0700431 OFAGENT_PPROF_PORT \
Girish Kumarcc5f9172020-06-10 13:34:31 +0000432 TRACING_GUI_PORT \
David K. Bainbridge8f7f30b2020-01-08 13:06:16 -0800433 VK_RELEASE \
434 KIND_VERSION \
435 VOLTCTL_VERSION \
David Bainbridgea34993d2020-04-01 09:15:42 -0700436 HELM_VERSION \
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700437 NUM_OF_ONOS \
438 NUM_OF_ATOMIX \
David Bainbridge6ca40102020-04-08 11:30:40 -0700439 VOLTHA_NS \
440 ADAPTER_NS \
441 INFRA_NS \
442 BBSIM_NS \
David Bainbridge7db44002020-04-09 12:54:29 -0700443 SADIS_BANDWIDTH_PROFILES \
444 SADIS_SUBSCRIBERS \
David Bainbridgeb4bbde12020-06-25 14:46:36 -0700445 PF_ADDRESS \
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700446 KIND_CFG_FILE \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000447 "
David Bainbridge01294952019-07-30 19:33:45 +0000448
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000449# Iterate over yes/no configuration options and validate
450for VAR in $ALL_YES_NO; do
David Bainbridged18f4942020-04-14 16:46:13 -0700451 eval "$VAR"="$(verify_yes_no "$VAR")"
452 if [ "$(eval echo "\$$VAR")" == "INVALID" ]; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000453 exit 1;
454 fi
455done
David Bainbridgeb270c202019-07-26 01:44:42 +0000456
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700457# Iterate over optional yes/no configuration options and
458# normalize values if they are truth values
459for VAR in $OPT_YES_NO; do
460 eval "$VAR"="$(normalize_yes_no "$VAR")"
461done
David Bainbridge15f6f232020-03-30 09:15:43 -0700462
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700463# check number (range) of bbsim, max bbsim must not exceed 10 instances!
464# note: instances will be numbered from 0 to 9
465if [ "$1" == "up" ]; then
466 if [ "$NUM_OF_BBSIM" -lt 1 ]; then
467 >&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}"
468 exit 1
469 fi
470 if [ "$NUM_OF_BBSIM" -gt "$MAX_NUM_OF_BBSIM" ]; then
471 >&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}"
472 exit 1
473 fi
474
475 if [ "$NUM_OF_OPENONU" -lt 1 ]; then
476 >&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}"
477 exit 1
478 fi
479 if [ "$NUM_OF_OPENONU" -gt "$MAX_NUM_OF_OPENONU" ]; then
480 >&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}"
481 exit 1
482 fi
483
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700484 HAVE_CLUSTER="$(kind get clusters 2>/dev/null | grep -c "voltha-$NAME")"
485 if [ "$HAVE_CLUSTER" -eq 0 ]; then
486 # If the user has specified a kind cluster configuration file,
487 # 'KIND_CFG_FILE` then we need to gleem from that file the number
488 # of worker and controller nodes as this overrides any setting of
489 # these values
490 if [ -n "$KIND_CFG_FILE" ]; then
491 NUM_OF_WORKER_NODES="$(sed 's/ //g' "$KIND_CFG_FILE" | grep -c "^-role:worker$")"
492 NUM_OF_CONTROLLER_NODES="$(sed 's/ //g' "$KIND_CFG_FILE" | grep -c "^-role:control-plane$")"
493 fi
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700494
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700495 # check that NUM_OF_KAFKA, NUM_OF_ONOS, NUM_OF_ATOMIX, NUM_OF_ETCD is:
496 # <= NUM_OF_WORKER_NODES + 1 if SCHEDULE_ON_CONTROL_NODES == y
497 # <= NUM_OF_WORKER_NODES if SCHEDULE_ON_CONTROL_NODES == n
498 SCHEDULABLE_NODES=$NUM_OF_WORKER_NODES
499
500 if [ "$SCHEDULE_ON_CONTROL_NODES" == "yes" ]; then
501 SCHEDULABLE_NODES=$((NUM_OF_CONTROLLER_NODES+NUM_OF_WORKER_NODES))
502 fi
503 else
504 TOTAL_NODES=$(kubectl get --all-namespaces nodes -o name | wc -l)
505 NUM_OF_CONTROLLER_NODES=$(kubectl get --all-namespaces nodes -l node-role.kubernetes.io/master -o name | wc -l)
506 NUM_OF_WORKER_NODES=$((TOTAL_NODES - NUM_OF_CONTROLLER_NODES))
507 # shellcheck disable=SC2016
508 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')
509 rm -f "$TMP_KUBECFG"
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700510 fi
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700511 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"
512
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700513 if is_in "$WITH_KAFKA" "yes,external" && [ ! "$NUM_OF_KAFKA" -le "$SCHEDULABLE_NODES" ]; then
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700514 >&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}"
515 exit 1
516 fi
517
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700518 if is_in "$WITH_ETCD" "yes,external" && [ ! "$NUM_OF_ETCD" -le "$SCHEDULABLE_NODES" ]; then
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700519 >&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}"
520 exit 1
521 fi
522
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700523 if is_in "$WITH_ONOS" "yes,legacy,classic,micro"; then
524 if [ ! "$NUM_OF_ATOMIX" -le "$SCHEDULABLE_NODES" ]; then
525 >&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}"
526 exit 1
527 fi
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700528
David K. Bainbridge2aa08da2020-07-31 12:49:45 -0700529 if [ ! "$NUM_OF_ONOS" -le "$SCHEDULABLE_NODES" ]; then
530 >&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}"
531 exit 1
532 fi
Matteo Scandolo657e13c2020-07-28 11:41:42 -0700533 fi
534fi
535
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700536# normalize non-truth value options
537if is_in "$WITH_KAFKA" "e,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -0700538 WITH_KAFKA="external"
539fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700540if is_in "$WITH_ETCD" "e,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -0700541 WITH_ETCD="external"
542fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700543if is_in "$WITH_ONOS" "l,legacy"; then
544 WITH_ONOS="legacy"
545elif is_in "$WITH_ONOS" "c,classic"; then
546 WITH_ONOS="classic"
547elif is_in "$WITH_ONOS" "u,m,micro"; then
548 WITH_ONOS="micro"
David Bainbridge29c31cb2020-04-06 09:45:50 -0700549fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700550
551if [ "$WITH_ONOS" == "micro" ]; then
552 >&2 echo -e "${YELLOW}${BOLD}${ERROR}WARNING:${NORMAL}${YELLOW} The value specified as WITH_ONOS, '$WITH_ONOS', is not valid.${NORMAL}"
553 exit 1
David Bainbridge29c31cb2020-04-06 09:45:50 -0700554fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700555
556if is_in "$WITH_ONOS" "yes,classic"; then
557 # there is an extra utility required if we are using ONOS CLASSIC as
558 # the chart for classic specifies images differently
559 EXTRA_TOOLS+=" yq"
David Bainbridge76afd812020-04-06 09:53:52 -0700560fi
David Bainbridge696bc632020-04-05 21:49:37 -0700561
David Bainbridge22db5dd2020-05-26 12:21:21 -0700562if [ "$LEGACY_BBSIM_INDEX" == "no" ]; then
563 BBSIM_SADIS_SVC="bbsim0"
564else
565 BBSIM_SADIS_SVC="bbsim"
566fi
567
568SADIS_SUBSCRIBERS=${SADIS_SUBSCRIBERS:-http://$BBSIM_SADIS_SVC.$VOLTHA_NS.svc:50074/v2/subscribers/%s}
569SADIS_BANDWIDTH_PROFILES=${SADIS_BANDWIDTH_PROFILES:-http://$BBSIM_SADIS_SVC.$VOLTHA_NS.svc:50074/v2/bandwidthprofiles/%s}
570
David Bainbridged18f4942020-04-14 16:46:13 -0700571if [ "$HELM_USE_UPGRADE" == "yes" ]; then
David Bainbridge7f8bf992020-04-08 21:53:22 -0700572 _HELM_DESC="Upgrade/Install"
573else
574 _HELM_DESC="Install"
575fi
576
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800577# Check for prerequiste tools
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700578TOOLS="curl sed jq $EXTRA_TOOLS"
David Bainbridged18f4942020-04-14 16:46:13 -0700579if [ "$DEPLOY_K8S" == "yes" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800580 TOOLS+=" docker"
581fi
582NOT_FOUND=""
583for T in $TOOLS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700584 if [ -z "$(command -v "$T")" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800585 NOT_FOUND+=" $T"
586 fi
587done
588
David Bainbridged18f4942020-04-14 16:46:13 -0700589if [ -n "$NOT_FOUND" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800590 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} The following required tools where not found, please install them:$NOT_FOUND"
591 exit 1
592fi
593
David Bainbridged18f4942020-04-14 16:46:13 -0700594TIMEOUT_SECONDS="$(parseDuration "$WAIT_TIMEOUT")"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700595
David Bainbridge0774b232019-08-02 06:37:19 +0000596mkdir -p .voltha
597touch .voltha/ports
David Bainbridged18f4942020-04-14 16:46:13 -0700598HAVE="$(grep "$NAME" .voltha/ports)"
David Bainbridge0774b232019-08-02 06:37:19 +0000599if [ "$HAVE X" == " X" ]; then
600 # Find free port prefix
601 START=81
602 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700603 if [ "$(grep -c $START .voltha/ports)" -eq 0 ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000604 break
605 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700606 START="$((START + 1))"
David Bainbridge0774b232019-08-02 06:37:19 +0000607 done
David Bainbridged18f4942020-04-14 16:46:13 -0700608 DELTA="$((START - 81))"
David Bainbridgea2595422019-10-22 03:54:28 +0000609 ONOS_API_PORT=${ONOS_API_PORT:-${START}81}
610 ONOS_SSH_PORT=${ONOS_SSH_PORT:-${START}01}
David Bainbridged18f4942020-04-14 16:46:13 -0700611 VOLTHA_API_PORT=${VOLTHA_API_PORT:-5$((55 + DELTA))55}
612 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$((50 + DELTA))22}
613 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$((23 + DELTA))79}
614 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$((90 + DELTA))92}
Matteo Scandoloefee0432020-05-05 13:56:20 -0700615 VOLTHA_PPROF_PORT=${VOLTHA_PPROF_PORT:-$((60 + DELTA))60}
616 OPENOLT_PPROF_PORT=${OPENOLT_PPROF_PORT:-$((60 + DELTA))61}
Matteo Scandolo65c35192020-05-13 10:41:21 -0700617 OFAGENT_PPROF_PORT=${OFAGENT_PPROF_PORT:-$((60 + DELTA))62}
divyadesai59f987a2020-05-27 12:11:33 +0000618 ELASTICSEARCH_PORT=${ELASTICSEARCH_PORT:-$((92 + DELTA))00}
619 KIBANA_PORT=${KIBANA_PORT:-$((56 + DELTA))01}
Girish Kumarcc5f9172020-06-10 13:34:31 +0000620 TRACING_GUI_PORT=${TRACING_GUI_PORT:-1$((66 + DELTA))86}
Test User01ed0642019-07-03 20:17:06 +0000621else
David Bainbridged18f4942020-04-14 16:46:13 -0700622 VALUES="$(echo "$HAVE" | sed -e 's/\s//g' | cut -d= -f2)"
623 ONOS_API_PORT=${ONOS_API_PORT:-$(echo "$VALUES" | cut -d, -f1)}
624 ONOS_SSH_PORT=${ONOS_SSH_PORT:-$(echo "$VALUES" | cut -d, -f2)}
625 VOLTHA_API_PORT=${VOLTHA_API_PORT:-$(echo "$VALUES" | cut -d, -f3)}
626 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$(echo "$VALUES" | cut -d, -f4)}
627 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$(echo "$VALUES" | cut -d, -f5)}
628 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(echo "$VALUES" | cut -d, -f6)}
Matteo Scandoloefee0432020-05-05 13:56:20 -0700629 VOLTHA_PPROF_PORT=${VOLTHA_PPROF_PORT:-$(echo "$VALUES" | cut -d, -f7)}
630 OPENOLT_PPROF_PORT=${OPENOLT_PPROF_PORT:-$(echo "$VALUES" | cut -d, -f8)}
Matteo Scandolo65c35192020-05-13 10:41:21 -0700631 OFAGENT_PPROF_PORT=${OFAGENT_PPROF_PORT:-$(echo "$VALUES" | cut -d, -f9)}
divyadesai59f987a2020-05-27 12:11:33 +0000632 ELASTICSEARCH_PORT=${ELASTICSEARCH_PORT:-$(echo "$VALUES" | cut -d, -f10)}
633 KIBANA_PORT=${KIBANA_PORT:-$(echo "$VALUES" | cut -d, -f11)}
Girish Kumarcc5f9172020-06-10 13:34:31 +0000634 TRACING_GUI_PORT=${TRACING_GUI_PORT:-$(echo "$VALUES" | cut -d, -f12)}
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800635
Matteo Scandoloefee0432020-05-05 13:56:20 -0700636 # Some ports were added after the .voltha/ports files was created.
637 # Calculate the original DELTA from the VOLTHA_SSH_PORT so that it can
638 # be used to set up newer port-forwards.
639 DELTA="$((VOLTHA_SSH_PORT/100-50))"
640
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800641 if [ -z "$VOLTHA_KAFKA_PORT" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -0700642 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$((90 + DELTA))92}
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800643 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -0700644
645 if [ -z "$VOLTHA_PPROF_PORT" ]; then
divyadesai59f987a2020-05-27 12:11:33 +0000646 VOLTHA_PPROF_PORT=${VOLTHA_PPROF_PORT:-$((60 + DELTA))60}
Matteo Scandoloefee0432020-05-05 13:56:20 -0700647 fi
648 if [ -z "$OPENOLT_PPROF_PORT" ]; then
divyadesai59f987a2020-05-27 12:11:33 +0000649 OPENOLT_PPROF_PORT=${OPENOLT_PPROF_PORT:-$((60 + DELTA))61}
Matteo Scandoloefee0432020-05-05 13:56:20 -0700650 fi
Matteo Scandolo65c35192020-05-13 10:41:21 -0700651 if [ -z "$OFAGENT_PPROF_PORT" ]; then
divyadesai59f987a2020-05-27 12:11:33 +0000652 OFAGENT_PPROF_PORT=${OFAGENT_PPROF_PORT:-$((60 + DELTA))62}
653 fi
654
655 if [ -z "$ELASTICSEARCH_PORT" ]; then
656 ELASTICSEARCH_PORT=${ELASTICSEARCH_PORT:-$((92 + DELTA))00}
657 fi
divyadesai59f987a2020-05-27 12:11:33 +0000658 if [ -z "$KIBANA_PORT" ]; then
659 KIBANA_PORT=${KIBANA_PORT:-$((56 + DELTA))01}
Matteo Scandolo65c35192020-05-13 10:41:21 -0700660 fi
Girish Kumarcc5f9172020-06-10 13:34:31 +0000661
662 if [ -z "$TRACING_GUI_PORT" ]; then
663 TRACING_GUI_PORT=${TRACING_GUI_PORT:-1$((66 + DELTA))86}
664 fi
Test User01ed0642019-07-03 20:17:06 +0000665fi
666
David Bainbridged18f4942020-04-14 16:46:13 -0700667PORTTMP="$(mktemp -u)"
668grep -v "$NAME" .voltha/ports > "$PORTTMP"
Girish Kumarcc5f9172020-06-10 13:34:31 +0000669echo "$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 -0700670cp "$PORTTMP" .voltha/ports
671rm -f "$PORTTMP"
David Bainbridge0774b232019-08-02 06:37:19 +0000672
David Bainbridge27790d62019-08-13 22:43:19 +0000673export ONOS_API_PORT ONOS_SSH_PORT
David Bainbridge01294952019-07-30 19:33:45 +0000674
Test Userd87942b2019-07-03 07:20:24 +0000675IDX=1
David Bainbridgee87067b2019-08-12 22:00:12 +0000676CLOCK="TIME:"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000677SPIN_PARTS=
678NOT_VERIFIED=
David Bainbridgef858a022019-08-14 21:25:11 +0000679THEX=
680BUILD=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000681VERIFIED=
682HELM=
683OLD_KEY=
684BIRD=
685HIGH_VOLTAGE=
686PLUG=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000687FORWARD=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000688GO=
689DOWNLOAD=
690GEAR=
691NO_ENTRY=
692LOCK=
693
David Bainbridged18f4942020-04-14 16:46:13 -0700694if [ "$FANCY" -eq 1 ]; then
695 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 +0000696 CLOCK="\xe2\x8f\xb1"
David Bainbridgef858a022019-08-14 21:25:11 +0000697 THEX="${RED}${BOLD}\xe2\x9c\x97\x20${NORMAL}"
David Bainbridgef858a022019-08-14 21:25:11 +0000698 BUILD="${YELLOW}${BOLD}\xf0\x9f\x8f\x97${NORMAL}"
699 NOT_VERIFIED="$BUILD"
700 VERIFIED="${GREEN}${BOLD}\xe2\x9c\x93\x20${NORMAL}"
701 HELM="${BLUE}${BOLD}\xE2\x8E\x88${NORMAL}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000702 OLD_KEY="\xF0\x9F\x97\x9D"
703 BIRD="\xF0\x9F\x90\xA6"
704 HIGH_VOLTAGE="\xE2\x9A\xA1"
705 PLUG="\xF0\x9F\xa7\xa9"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000706 FORWARD="\xE2\x87\xA8"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000707 GO="\xf0\x9f\x9a\x80"
708 DOWNLOAD="\xf0\x9f\x93\xa5"
709 GEAR="\xe2\x9a\x99"
710 NO_ENTRY="\xe2\x9b\x94"
711 LOCK="\xf0\x9f\x94\x92"
712fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700713
David Bainbridge712afb82019-08-14 19:55:58 +0000714duration() {
David Bainbridged18f4942020-04-14 16:46:13 -0700715 local h m s t
716 h="$(($1 / 3600))"
717 m="$(($1 % 3600 / 60))"
718 s="$(($1 % 60))"
719 t=""
David Bainbridgee87067b2019-08-12 22:00:12 +0000720
David Bainbridged18f4942020-04-14 16:46:13 -0700721 if [ "$h" -gt 0 ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +0000722 t="$t${h}h"
723 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700724 if [ "$m" -gt 0 ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +0000725 t="$t${m}m"
726 fi
David Bainbridge712afb82019-08-14 19:55:58 +0000727 echo "$t${s}s"
728}
729
730printtime() {
David Bainbridged18f4942020-04-14 16:46:13 -0700731 local INDENT
David Bainbridge712afb82019-08-14 19:55:58 +0000732 if [ "$1" == "-" ]; then
733 INDENT=" "
734 shift
735 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700736 echo -e "$INDENT $CLOCK $(duration "$1")"
David Bainbridgee87067b2019-08-12 22:00:12 +0000737}
738
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700739bspin() {
Test Userd87942b2019-07-03 07:20:24 +0000740 IDX=1
David Bainbridged18f4942020-04-14 16:46:13 -0700741 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700742 if [ "$1" == "-" ]; then
743 INDENT=" "
744 shift
745 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700746 if [ "$FANCY" -eq 0 ]; then
747 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000748 if [ "$LINE X" == " X" ]; then
749 return
750 fi
751 echo -e "$CIVIS$INDENT$*"
752 else
753 echo -en "$CIVIS$INDENT $*"
754 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700755}
756
757sspin() {
David Bainbridged18f4942020-04-14 16:46:13 -0700758 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700759 if [ "$1" == "-" ]; then
760 INDENT=" "
761 shift
762 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700763 if [ "$FANCY" -eq 0 ]; then
764 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000765 if [ "$LINE X" == " X" ]; then
766 return
767 fi
768 echo -e "$INDENT$*"
769 else
David Bainbridged18f4942020-04-14 16:46:13 -0700770 C="$(echo "$SPIN_PARTS" | cut '-d ' -f "$IDX")"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000771 echo -en "\r$INDENT$C $*"
David Bainbridged18f4942020-04-14 16:46:13 -0700772 IDX="$((IDX + 1))"
773 if [ "$IDX" -gt 8 ]; then
David Bainbridge38dc1e82019-08-12 15:18:45 +0000774 IDX=1
775 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700776 fi
777}
778
779espin() {
David Bainbridged18f4942020-04-14 16:46:13 -0700780 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700781 if [ "$1" == "-" ]; then
782 INDENT=" "
783 shift
784 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700785 if [ "$FANCY" -eq 0 ]; then
786 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000787 if [ "$LINE X" == " X" ]; then
788 return
789 fi
790 echo -e "$INDENT$*"
791 else
792 echo -e "\r$INDENT$*$CNORM"
793 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700794}
795
David Bainbridged18f4942020-04-14 16:46:13 -0700796if [ "$1" == "get" ] && [ "$2" == "voltconfig" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000797 echo "$HOME/.volt/config-$NAME"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000798 exit
799fi
800
David Bainbridgee4d11ca2020-05-08 10:21:10 -0700801if [ $# -ne 1 ] || ! is_in "$1" "up,down,dump,clean"; then
David Bainbridgeac7f8072019-08-01 22:15:33 +0000802 >&2 echo "What wouild you like to do today:"
803 >&2 echo " up - bring up voltha"
804 >&2 echo " down - tear down voltha"
805 >&2 echo " dump - create a debug dump of running system"
806 exit 1
807fi
808
divyadesai59f987a2020-05-27 12:11:33 +0000809do_curl() {
810 local DATA_ARGS CREDS CMD_ECHO CMD_OUTPUT SC_OUTPUT WAIT_START INDENTA EXTRAA NOW
811 local INDENT=$1
812 local OP=$2
813 local USER=$3
814 local PASS=$4
815 local URL=$5
816 local DATA_TYPE=$6
817 local DATA=$7
818 local MSG=$8
819 local VALID_RESULTS=$9
820 local EXTRA=${10}
821 local ICON=${11}
822
823 # Turn into an array for passing
824 INDENTA=()
825 if [ -n "$INDENT" ]; then
826 INDENTA=("$INDENT")
827 fi
828 IFS=' ' read -r -a EXTRAA <<< "$EXTRA"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000829
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800830 # Thanks to the latest version of ONOS using the return code 207 this gets a
831 # whole lot nastier. Can't thank them enough for doing this. So in order to
832 # capture the command and the output in the log file as well as capture the
833 # status code to verify it is 200 and not 207 mutltiple files and a bit of
834 # hackery must be used. Thanks again ONOS.
David Bainbridged18f4942020-04-14 16:46:13 -0700835 CMD_ECHO="$(mktemp -u)"
836 CMD_OUTPUT="$(mktemp -u)"
837 SC_OUTPUT="$(mktemp -u)"
838 WAIT_START="$(date +%s)"
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800839
divyadesai59f987a2020-05-27 12:11:33 +0000840 CREDS=()
841 if [ -n "$USER" ]; then
842 CREDS=("--user" "$USER:$PASS")
843 fi
844
845 DATA_ARGS=()
846 if [ -n "$DATA" ]; then
847 if [ "$DATA_TYPE" == "file" ]; then
848 DATA_ARGS=("--data" "@$DATA")
849 elif [ "$DATA_TYPE" == "json" ]; then
850 DATA_ARGS=("--data" "$DATA")
851 fi
852 fi
853
854 bspin "${INDENTA[@]}" "$MSG" "$ICON"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000855 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700856 NOW="$(date +%s)"
857 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
divyadesai59f987a2020-05-27 12:11:33 +0000858 espin "${INDENTA[@]}" "$THEX"
David Bainbridged18f4942020-04-14 16:46:13 -0700859 rm -f "$CMD_ECHO" "$CMD_OUTPUT" "$SC_OUTPUT"
divyadesai59f987a2020-05-27 12:11:33 +0000860 doTimeout "$MSG"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700861 fi
divyadesai59f987a2020-05-27 12:11:33 +0000862 (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
863 RESULT=$?
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800864 # Dump everything to the log
David Bainbridged18f4942020-04-14 16:46:13 -0700865 cat "$CMD_ECHO" >> "$LOG"
866 test -r "$CMD_OUTPUT" && cat "$CMD_OUTPUT" >> "$LOG"
867 SC="$(cat "$SC_OUTPUT")"
868 echo "RESPONSE CODE: $SC" >> "$LOG"
869 echo "ERROR CODE: $RESULT" >> "$LOG"
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800870
871 # clean up temp files
David Bainbridged18f4942020-04-14 16:46:13 -0700872 rm -f "$CMD_ECHO" "$CMD_OUTPUT" "$SC_OUTPUT"
divyadesai59f987a2020-05-27 12:11:33 +0000873 if [ "$RESULT" -eq 0 ] && is_in "$SC" "$VALID_RESULTS"; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000874 break
875 fi
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800876 sleep 1
divyadesai59f987a2020-05-27 12:11:33 +0000877 sspin "${INDENTA[@]}"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000878 done
divyadesai59f987a2020-05-27 12:11:33 +0000879 espin "${INDENTA[@]}" "$VERIFIED"
880}
881
882push_onos_config() {
883 local DATA_TYPE=$1
884 local MSG=$2
885 local RESOURCE=$3
886 local DATA=$4
887
888 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 +0000889}
890
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800891check_onos_app_active() {
David Bainbridged18f4942020-04-14 16:46:13 -0700892 local APP_ID WAIT_START RESULT NOW
893 APP_ID=$1
894 WAIT_START="$(date +%s)"
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800895
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700896 bspin - "Checking that $APP_ID is active $CLOCK"
897 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700898 NOW="$(date +%s)"
899 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700900 espin - "$THEX"
901 doTimeout "waiting for ONOS application activation '$APP_ID'"
902 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700903 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 -0700904 break
905 fi
906 sleep 1
907 sspin -
908 done
909 sleep 5 # OSGI components take a little longer that the app to activate
David Bainbridged18f4942020-04-14 16:46:13 -0700910 espin - "$VERIFIED"
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800911}
912
David Bainbridge4f1b5562019-08-19 04:46:52 +0000913override_onos_app() {
David Bainbridged18f4942020-04-14 16:46:13 -0700914 local APP NAME WAIT_START NOW
915 APP=$1
916 NAME="$(basename "$APP" | sed -e 's/^[0-9][0-9]*-//g' -e 's/-.*$//g')"
917 WAIT_START="$(date +%s)"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700918
David Bainbridge4f1b5562019-08-19 04:46:52 +0000919 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700920 NOW="$(date +%s)"
921 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700922 espin - "$THEX"
923 doTimeout "waiting to overwrite ONOS application '$APP'"
924 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +0000925 sspin -
926 # Attempt to delete old version (if it exists)
David Bainbridged18f4942020-04-14 16:46:13 -0700927 (set -x; curl --fail -sSL --user karaf:karaf -X DELETE "http://$_ONOS_API_EP/onos/v1/applications/$NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
928 RESULT=$?
David Bainbridge4f1b5562019-08-19 04:46:52 +0000929 sspin -
David Bainbridged18f4942020-04-14 16:46:13 -0700930 if [ $RESULT -ne 0 ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000931 continue
932 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700933 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 +0000934 break
935 fi
936 sleep .2
937 done
938}
939
940activate_onos_app() {
David Bainbridged18f4942020-04-14 16:46:13 -0700941 local MSG APP WAIT_START NOW
942 MSG="$1"
943 APP=$2
944 WAIT_START="$(date +%s)"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000945
946 bspin - "$MSG $GO"
947 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700948 NOW="$(date +%s)"
949 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700950 espin - "$THEX"
951 doTimeout "waiting to activate ONOS application '$APP'"
952 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +0000953 sspin -
David Bainbridged18f4942020-04-14 16:46:13 -0700954 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 +0000955 break
956 fi
957 sleep .2
958 done
959 espin - "$VERIFIED"
960}
961
962count_pods() {
David Bainbridged18f4942020-04-14 16:46:13 -0700963 local NAMESPACE STATES LABELS CMD PODS
964 NAMESPACE=$1; shift
David Bainbridge4f1b5562019-08-19 04:46:52 +0000965 if [ "$NAMESPACE" == "all-namespaces" ]; then
966 NAMESPACE="--all-namespaces"
967 else
968 NAMESPACE="-n $NAMESPACE"
969 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700970 STATES=$1; shift
971 LABELS=$1; shift
972 CMD=("kubectl get $NAMESPACE $LABELS pod")
973 PODS=$(${CMD[*]} -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}")
David Bainbridge4f1b5562019-08-19 04:46:52 +0000974 local COUNT=0
975 local PATTERNS="$*"
976 for POD in $PODS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700977 local NAME STATE CONTAINERS TOTAL FOUND
978 NAME="$(echo "$POD" | cut -d/ -f 1)"
979 STATE="$(echo "$POD" | cut -d/ -f 2)"
980 CONTAINERS="$(echo "$POD" | cut -d/ -f 3 | sed -e 's/_/ /g')"
981 if [ "$STATES" == "*" ] || [ "$(echo "$STATES" | grep -c ":$STATE:")" -ne 0 ]; then
982 TOTAL="$(echo "$CONTAINERS" | wc -w)"
983 FOUND="$(echo "$CONTAINERS" | grep -o true | wc -l)"
984 if [ "$TOTAL" -eq "$FOUND" ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000985 for PATTERN in $PATTERNS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700986 if [[ "$NAME" =~ $PATTERN ]]; then
987 COUNT="$((COUNT + 1))"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000988 break
989 fi
990 done
991 fi
992 fi
993 done
David Bainbridge4f1b5562019-08-19 04:46:52 +0000994 echo $COUNT
995}
996
997wait_for_pods() {
David Bainbridged18f4942020-04-14 16:46:13 -0700998 local INDENT NAMESPACE EXPECT TYPE MESSAGE LABELS PATTERNS STATES HAVE ALL WAIT_START NOW
David Bainbridge4f1b5562019-08-19 04:46:52 +0000999 if [ "$1" == "-" ]; then
1000 INDENT=$1; shift
1001 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001002 NAMESPACE=$1; shift
1003 EXPECT=$1; shift
1004 TYPE=$1; shift
1005 MESSAGE=$1; shift
1006 LABELS=$1; shift
1007 PATTERNS=("$*")
1008 STATES=":Running:"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001009 if [ "$TYPE" == "not" ]; then
1010 STATES="*"
1011 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001012 HAVE="$(count_pods "$NAMESPACE" "$STATES" "$LABELS" "${PATTERNS[@]}")"
1013 ALL=$HAVE
David Bainbridge4f1b5562019-08-19 04:46:52 +00001014 if [ "$TYPE" == "only" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001015 ALL="$(count_pods "all-namespaces" "*" ".*")"
David Bainbridge4f1b5562019-08-19 04:46:52 +00001016 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001017 COUNT="$((300 / 15))"
1018 WAIT_START="$(date +%s)"
1019 bspin "$INDENT" "$MESSAGE"
1020 sspin "$INDENT"
1021 if [ "$HAVE" -ne "$EXPECT" ] || [ "$ALL" -ne "$HAVE" ]; then
1022 while [ "$HAVE" -ne "$EXPECT" ] || [ "$ALL" -ne "$HAVE" ]; do
1023 NOW="$(date +%s)"
1024 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
1025 espin "$INDENT" "$THEX"
David Bainbridge52e6e9d2020-03-23 13:48:27 -07001026 doTimeout "waiting for PODs to start"
1027 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001028 sspin "$INDENT"
1029 COUNT="$((COUNT - 1))"
1030 if [ "$COUNT" -eq 0 ]; then
1031 HAVE="$(count_pods "$NAMESPACE" "$STATES" "$LABELS" "${PATTERNS[@]}")"
1032 ALL="$HAVE"
David Bainbridge4f1b5562019-08-19 04:46:52 +00001033 if [ "$TYPE" == "only" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001034 ALL="$(count_pods "all-namespaces" "*" ".*")"
David Bainbridge4f1b5562019-08-19 04:46:52 +00001035 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001036 COUNT="$((300 / 15))"
David Bainbridge4f1b5562019-08-19 04:46:52 +00001037 fi
1038 sleep .15
1039 done
1040 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001041 espin "$INDENT" "$VERIFIED"
1042 if [ "$HAVE" -ne "$EXPECT" ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +00001043 return 1
1044 fi
1045 return 0
1046}
1047
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001048port_forward() {
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001049 local NS=$1; shift
1050 local SVC=$1; shift
1051 local PORTS="$*"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001052 local TAG=$SVC-$NAME
1053
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001054 (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 -08001055}
1056
1057kill_port_forward() {
David Bainbridge1d2c5842020-06-03 15:29:07 -07001058 local TAG P_IDS PARENTS KIDS UNKNOWN PP_ID PF
1059
1060 while [ $# -gt 0 ]; do
1061 PF=$1; shift
1062 TAG=
1063 if [ "$PF" != "__ALL__" ]; then
1064 TAG="$PF-$NAME"
1065 fi
1066 PARENTS=
1067 KIDS=
1068 UNKNOWN=
1069 # shellcheck disable=SC2009
1070 P_IDS="$(ps e -ww -A | grep "_TAG=$TAG" | grep -v grep | awk '{print $1}')"
1071 if [ -n "$P_IDS" ]; then
1072 for P_ID in $P_IDS; do
1073 PP_ID="$(ps -o ppid "$P_ID" | tail -n +2)"
1074 if [ -n "$PP_ID" ]; then
1075 if [ "$PP_ID" -eq 1 ]; then
1076 PARENTS="$PARENTS $P_ID"
1077 else
1078 KIDS="$KIDS $P_ID"
1079 fi
David Bainbridgec6871d22019-11-13 17:10:31 +00001080 else
David Bainbridge1d2c5842020-06-03 15:29:07 -07001081 UNKNOWN="$UNKNOWN $P_ID"
David Bainbridgec6871d22019-11-13 17:10:31 +00001082 fi
David Bainbridge1d2c5842020-06-03 15:29:07 -07001083 done
1084 if [ -n "$PARENTS" ]; then
1085 # shellcheck disable=SC2086
1086 while ps -h $PARENTS >/dev/null 2>&1; do
1087 (set -x; eval "kill -9 $PARENTS" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1088 done
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001089 fi
David Bainbridge1d2c5842020-06-03 15:29:07 -07001090 if [ -n "$KIDS" ]; then
1091 # shellcheck disable=SC2086
1092 while ps -h $KIDS >/dev/null 2>&1; do
1093 (set -x; eval "kill -9 $KIDS" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1094 done
1095 fi
1096 if [ -n "$UNKNOWN" ]; then
1097 # shellcheck disable=SC2086
1098 while ps -h $UNKNOWN >/dev/null 2>&1; do
1099 (set -x; eval "kill -9 $UNKNOWN" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1100 done
1101 fi
1102 fi
1103 done
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001104}
1105
Girish Kumarcc5f9172020-06-10 13:34:31 +00001106resolve_chart_name() {
1107 helm inspect chart "$1" | grep "^name:" | awk '{print $2}'
1108}
1109
David Bainbridgecf546362020-04-21 23:18:50 -07001110resolve_chart_version() {
1111 [ "$2" != "latest" ] && echo "$2" && return
1112 helm inspect chart "$1" | grep "^version:" | awk '{print $2}'
1113}
1114
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07001115# Compares two semver-formatted version strings (e.g. 2.4.3)
1116# Returns 0 if $1 == $2, returns 1 if $1 > $2 and returns 2 if $1 < $2
1117compare_versions() {
1118 [ "$1" == "$2" ] && return 0
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07001119 local lowest
1120 lowest=$(echo -e "$1\n$2" | sort -V | head -1)
1121 [ "$lowest" == "$1" ] && return 2
1122 return 1
1123}
1124
David Bainbridgeac7f8072019-08-01 22:15:33 +00001125if [ "$1" == "down" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001126 echo "Tearing down voltha cluster $NAME"
1127 LOG="down-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -07001128 date -u +"%Y%m%dT%H%M%SZ" >"$LOG"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001129 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 -07001130 if is_in "$WITH_ONOS" "yes,legacy,classic"; then
David Bainbridge696bc632020-04-05 21:49:37 -07001131 bspin "Remove port-forwards: onos-ui-$NAME"
1132 kill_port_forward onos-ui
1133 sspin "Remove port-forwards: onos-ssh-$NAME$CEOL"
1134 kill_port_forward onos-ssh
David K. Bainbridge2aa08da2020-07-31 12:49:45 -07001135 sspin "Remove port-forwards: onos-onos-classic-hs-$NAME$CEOL"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001136 kill_port_forward onos-onos-classic-hs
David Bainbridge696bc632020-04-05 21:49:37 -07001137 fi
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001138 sspin "Remove port-forwards: voltha-api-$NAME$CEOL"
David Bainbridge1d2c5842020-06-03 15:29:07 -07001139 kill_port_forward voltha-api voltha-voltha-api
David Bainbridgec7220622020-05-28 12:31:47 -07001140 if is_in "$WITH_ETCD" "yes,external"; then
1141 sspin "Remove port-forwards: etcd-$NAME$CEOL"
1142 kill_port_forward "etcd"
David Bainbridge696bc632020-04-05 21:49:37 -07001143 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001144 if is_in "$WITH_KAFKA" "yes,external"; then
1145 sspin "Remove port-forwards: kafka-$NAME$CEOL"
1146 kill_port_forward "kafka"
David Bainbridge696bc632020-04-05 21:49:37 -07001147 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -07001148
1149 if [ "$WITH_PPROF" == "yes" ]; then
David Bainbridgec7220622020-05-28 12:31:47 -07001150 sspin "Remove port-forwards: *-profiler$CEOL"
David Bainbridge1d2c5842020-06-03 15:29:07 -07001151 kill_port_forward voltha-rw-core-profiler voltha-voltha-rw-core-profiler
1152 kill_port_forward voltha-of-agent-profiler voltha-voltha-of-agent-profiler
David Bainbridgec7220622020-05-28 12:31:47 -07001153 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
David Bainbridge1d2c5842020-06-03 15:29:07 -07001154 kill_port_forward adapter-open-olt-profiler open-olt-adapter-open-olt-profiler
David Bainbridgec7220622020-05-28 12:31:47 -07001155 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -07001156 fi
1157
Girish Kumarcc5f9172020-06-10 13:34:31 +00001158 if [ "$WITH_TRACING" == "yes" ]; then
1159 sspin "Remove port-forwards: tracing-$NAME$CEOL"
1160 VOLTHA_TRACING_CHART_NAME=$(resolve_chart_name "$VOLTHA_TRACING_CHART")
1161 kill_port_forward "tracing-${VOLTHA_TRACING_CHART_NAME}-jaeger-gui"
1162 fi
1163
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001164 espin "$VERIFIED Remove port-forwards$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -07001165 if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridgeac7f8072019-08-01 22:15:33 +00001166 if [ -x ./bin/kind ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001167 bspin "Delete Kubernetes Kind Cluster"
David Bainbridged18f4942020-04-14 16:46:13 -07001168 (set -x; ./bin/kind delete cluster --name "voltha-$NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1169 espin "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001170 else
David Bainbridge0774b232019-08-02 06:37:19 +00001171 espin "$NO_ENTRY Delete Kubernetes Kind Cluster: kind command not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001172 fi
1173 else
David Bainbridge309099c2020-05-05 08:47:29 -07001174 if [ "$CONFIG_SADIS" == "external" ]; then
1175 bspin "Remove configmap for BBSIM SADIS server"
1176 (set -x; kubectl -n "$BBSIM_NS" delete --ignore-not-found configmap kube-config >>"$LOG" 2>&1) >>"$LOG" 2>&1
1177 espin "$VERIFIED"
1178 fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001179
1180 if [ "$HELM_MAJOR" -le 2 ]; then
1181 EXISTS=$(helm list --output json 2>/dev/null | jq -r '.Releases | .[] | .Name + "," + .Namespace')
1182 else
1183 EXISTS=$(helm list --all-namespaces --output json 2>/dev/null | jq -r '.[] | .name + "," + .namespace')
1184 fi
David Bainbridge76afd812020-04-06 09:53:52 -07001185 EXPECT="voltha"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001186 if is_in "$WITH_ONOS" "yes,legacy,classic"; then
David Bainbridge696bc632020-04-05 21:49:37 -07001187 EXPECT+=" onos"
1188 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001189 if [ "$WITH_RADIUS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001190 EXPECT+=" radius"
1191 fi
David Bainbridge309099c2020-05-05 08:47:29 -07001192 if [ "$CONFIG_SADIS" == "external" ]; then
1193 EXPECT+=" bbsim-sadis-server"
1194 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001195 if [ "$WITH_BBSIM" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001196 EXPECT+=" bbsim"
1197 fi
divyadesai59f987a2020-05-27 12:11:33 +00001198 if [ "$WITH_EFK" == "yes" ]; then
1199 EXPECT+=" elasticsearch kibana fluentd"
1200 fi
Girish Kumarcc5f9172020-06-10 13:34:31 +00001201 if [ "$WITH_TRACING" == "yes" ]; then
1202 EXPECT+=" tracing"
1203 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001204 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001205 EXPECT+=" open-olt open-onu"
1206 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001207 if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001208 EXPECT+=" sim"
1209 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001210 if is_in "$WITH_ETCD" "yes,external"; then
1211 EXPECT+=" etcd"
David Bainbridge76afd812020-04-06 09:53:52 -07001212 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001213 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -07001214 EXPECT+=" kafka"
1215 fi
David Bainbridge0774b232019-08-02 06:37:19 +00001216 bspin "Remove Helm Deployments"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001217 for i in $EXISTS; do
David K. Bainbridge43422402020-03-06 07:41:22 -08001218 for j in $EXPECT; do
David Bainbridged18f4942020-04-14 16:46:13 -07001219 if [[ "$i" =~ $j ]]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001220 __NAME=$(echo "$i" | cut -d, -f1)
1221 __NS=$(echo "$i" | cut -d, -f2)
1222 sspin "Remove Helm Deployments: $__NS:$__NAME$CEOL"
1223 if [ "$HELM_MAJOR" -le 2 ]; then
1224 (set -x; helm delete --no-hooks --purge "$__NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1225 else
1226 (set -x; helm uninstall --no-hooks --namespace "$__NS" "$__NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1227 fi
David K. Bainbridge43422402020-03-06 07:41:22 -08001228 fi
1229 done
uottrembb16d3982020-02-28 08:34:36 +01001230 done
David Bainbridge0774b232019-08-02 06:37:19 +00001231 espin "$VERIFIED Remove Helm Deployments$CEOL"
David Bainbridge4f1b5562019-08-19 04:46:52 +00001232 if [ "$WAIT_ON_DOWN" == "yes" ]; then
Matteo Scandoloe93c9eb2020-06-03 12:08:51 -07001233 PODS="voltha-ofagent.* voltha-rw-core.*"
David Bainbridge76afd812020-04-06 09:53:52 -07001234 INFRA_PODS=
1235 ADAPT_PODS=
1236 SIM_PODS=
divyadesai59f987a2020-05-27 12:11:33 +00001237 EFK_PODS=
David Bainbridged18f4942020-04-14 16:46:13 -07001238 if [ "$WITH_RADIUS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001239 PODS+=" radius.*"
1240 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001241 if [ "$WITH_BBSIM" == "yes" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -07001242 SIM_PODS+=" bbsim.*"
David Bainbridge696bc632020-04-05 21:49:37 -07001243 fi
divyadesai59f987a2020-05-27 12:11:33 +00001244 if [ "$WITH_EFK" == "yes" ]; then
1245 EFK_PODS+=" kibana-* elasticsearch-* fluentd-*"
1246 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001247 if [ "$WITH_OPEN_ADAPTERS" ] || [ "$WITH_SIM_ADAPTERS" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -07001248 ADAPT_PODS+=" adapter-*"
David Bainbridge696bc632020-04-05 21:49:37 -07001249 fi
Girish Kumarcc5f9172020-06-10 13:34:31 +00001250 if [ "$WITH_TRACING" == "yes" ]; then
1251 INFRA_PODS+=" jaeger.*"
1252 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001253 if is_in "$WITH_ONOS" "yes,legacy,classic"; then
David Bainbridge76afd812020-04-06 09:53:52 -07001254 INFRA_PODS+=" onos-.*"
1255 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001256 if is_in "$WITH_ETCD" "yes,external"; then
1257 INFRA_PODS+=" etcd.*"
David Bainbridge76afd812020-04-06 09:53:52 -07001258 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001259 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -07001260 INFRA_PODS+=" kafka.*"
1261 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001262 if [ -n "$SIM_PODS" ]; then
1263 wait_for_pods "$BBSIM_NS" 0 "not" "Waiting for BBSIM PODs to terminate" "$BBSIM_LABEL" "$SIM_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -07001264 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001265 if [ -n "$INFRA_PODS" ]; then
1266 wait_for_pods "$INFRA_NS" 0 "not" "Waiting for infrastructure PODs to terminate" "$NO_LABEL" "$INFRA_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -07001267 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001268 if [ -n "$ADAPT_PODS" ]; then
1269 wait_for_pods "$ADAPTER_NS" 0 "not" "Waiting for adapter PODs to terminate" "$NO_LABEL" "$ADAPT_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -07001270 fi
divyadesai59f987a2020-05-27 12:11:33 +00001271 if [ -n "$EFK_PODS" ]; then
1272 wait_for_pods "$INFRA_NS" 0 "not" "Waiting for EFK PODs to terminate" "$NO_LABEL" "$EFK_PODS"
1273 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001274 wait_for_pods "$VOLTHA_NS" 0 "not" "Waiting for VOLTHA PODs to terminate" "$NO_LABEL" "$PODS"
David Bainbridge4f1b5562019-08-19 04:46:52 +00001275 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +00001276 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001277 exit
David Bainbridgeac7f8072019-08-01 22:15:33 +00001278fi
1279
1280if [ "$1" == "dump" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001281 LOG="dump-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -07001282 TS="$(date -u +"%Y%m%dT%H%M%SZ")"
1283 if [ -n "$DUMP_FROM" ]; then
1284 TS=${DUMP_FROM//[:-]}
David Bainbridge76514a02019-10-08 01:50:35 +00001285 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001286 WORK="$(mktemp -u -d)"
David Bainbridge0774b232019-08-02 06:37:19 +00001287 DATA=$WORK/voltha-debug-dump-$NAME-$TS
David Bainbridged18f4942020-04-14 16:46:13 -07001288 mkdir -p "$DATA"
1289 echo "$TS" > "$LOG"
David Bainbridge0774b232019-08-02 06:37:19 +00001290 echo -e "Capturing debug dump to voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001291 bspin - "Copy install log"
David Bainbridged18f4942020-04-14 16:46:13 -07001292 if [ -f "install-$NAME.log" ]; then
1293 (set -x; cp "install-$NAME.log" "$DATA/install-$NAME.log") >>"$LOG" 2>&1
1294 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001295 else
David Bainbridge0774b232019-08-02 06:37:19 +00001296 espin - "$NO_ENTRY Copy install log: install-$NAME.log not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001297 fi
1298 bspin - "Dumping Kubernetes PODs"
David Bainbridged18f4942020-04-14 16:46:13 -07001299 (set -x; kubectl get --all-namespaces pods >> "$DATA/all-pods.txt" 2>&1) >>"$LOG" 2>&1
1300 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001301 bspin - "Dumping Kubernetes SERVICEs"
David Bainbridged18f4942020-04-14 16:46:13 -07001302 (set -x; kubectl get --all-namespaces svc >> "$DATA/all-services.txt" 2>&1) >>"$LOG" 2>&1
1303 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001304 bspin - "Dumping Kubernetes EVENTs"
David Bainbridged18f4942020-04-14 16:46:13 -07001305 (set -x; kubectl get --all-namespaces events >> "$DATA/all-events.txt" 2>&1) >>"$LOG" 2>&1
1306 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001307 bspin - "Dumping VOLTHA POD details"
David Bainbridged18f4942020-04-14 16:46:13 -07001308 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 +00001309 SINCE=
David Bainbridged18f4942020-04-14 16:46:13 -07001310 if [ -n "$DUMP_FROM" ]; then
David Bainbridgecfd7ca12019-10-06 03:31:41 +00001311 SINCE="--since-time=$DUMP_FROM"
1312 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +00001313 for POD in $PODS; do
David Bainbridged18f4942020-04-14 16:46:13 -07001314 NS="$(echo "$POD" | cut -d: -f1)"
1315 POD="$(echo "$POD" | cut -d: -f2)"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001316 sspin - "Dumping VOLTHA POD details: $POD$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -07001317 mkdir -p "$DATA/$POD"
1318 (set -x; kubectl describe -n "$NS" "$POD" >> "$DATA/$POD/describe.txt" 2>&1) >>"$LOG" 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +00001319 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridged18f4942020-04-14 16:46:13 -07001320 (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 +00001321 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridged18f4942020-04-14 16:46:13 -07001322 (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 +00001323 sspin - "Dumping VOLTHA POD details: $POD"
1324 done
1325 espin - "$VERIFIED Dumping VOLTHA POD details$CEOL"
1326 bspin - "Dumping ETCD"
David Bainbridged18f4942020-04-14 16:46:13 -07001327 if [ -n "$(command -v etcdctl)" ]; then
1328 (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
1329 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001330 else
1331 espin - "$NO_ENTRY Dumping ETCD: etcdctl command not available"
1332 fi
David Bainbridge0774b232019-08-02 06:37:19 +00001333 bspin - "Creating compressed TAR: voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridged18f4942020-04-14 16:46:13 -07001334 (set -x; tar -C "$WORK" -zcf "voltha-debug-dump-$NAME-$TS.tgz" "./voltha-debug-dump-$NAME-$TS") >>"$LOG" 2>&1
1335 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001336 bspin - "Cleanup"
David Bainbridged18f4942020-04-14 16:46:13 -07001337 (set -x; rm -rf "$WORK") >>"$LOG" 2>&1
1338 espin - "$VERIFIED"
1339 bspin - "$(ls -l "voltha-debug-dump-$NAME-$TS.tgz")"
1340 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001341 exit
1342fi
1343
David Bainbridge0774b232019-08-02 06:37:19 +00001344LOG="install-$NAME.log"
David Bainbridge1d2c5842020-06-03 15:29:07 -07001345PFLOG="port-forward-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -07001346date > "$LOG"
Girish Kumarcc5f9172020-06-10 13:34:31 +00001347echo "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 +00001348
1349# Output install options to log
David Bainbridged18f4942020-04-14 16:46:13 -07001350echo "OPTIONS" >> "$LOG"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001351for O in $ALL_OPTIONS; do
David Bainbridged18f4942020-04-14 16:46:13 -07001352 VAL="$(eval echo "\$$O")"
1353 if [ -n "$VAL" ]; then
1354 printf " %-30s = %s\n" "$O" "$VAL" >> "$LOG"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001355 fi
1356done
1357
David Bainbridgee4d11ca2020-05-08 10:21:10 -07001358# Force remove any existing k8s port-forward processes. This will
1359# remove them for all kind clusters.
David Bainbridgee4d11ca2020-05-08 10:21:10 -07001360if [ "$1" == "clean" ]; then
1361 kill_port_forward __ALL__
1362 exit
1363fi
1364
David Bainbridgefad50732020-05-01 17:00:12 -07001365helm_values() {
1366 local NAMESPACE=$1; shift
1367 local INAME=$1; shift
1368 local CHART=$1; shift
1369 local CHART_VERSION=$1; shift
1370
1371 if [ "$CHART_VERSION X" != " X" ] && [ "$CHART_VERSION" != "latest" ]; then
1372 CHART_VERSION="--version $CHART_VERSION"
1373 else
1374 CHART_VERSION=
1375 fi
1376
1377 local CHART_ARGS=
1378 if [ -r "${INAME}-values.yaml" ]; then
1379 CHART_ARGS="-f ${INAME}-values.yaml"
1380 fi
1381
1382 if [ "$HELM_USE_UPGRADE" == "yes" ]; then
1383 _HELM_COMMAND="upgrade --install"
1384 _HELM_ARGS="xxxdryrunxxx"
1385 else
1386 _HELM_COMMAND="install"
Matteo Scandolof2d080b2020-07-23 13:59:29 -07001387 if [ "$HELM_MAJOR" -le 2 ]; then
1388 _HELM_NAME_ARG="--name xxxdryrunxxx"
1389 _HELM_ARGS=
1390 else
1391 _HELM_NAME_ARG="xxxdryrunxxx"
1392 _HELM_ARGS="--create-namespace"
1393 fi
David Bainbridgefad50732020-05-01 17:00:12 -07001394 fi
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001395 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 -07001396 ${CMD[*]} 2>/dev/null | awk 'PRINT==1 {print}; /^USER-SUPPLIED VALUES:/ {PRINT = 1}; /^$/ {PRINT = 0}'
1397}
1398
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001399helm_is_deployed() {
1400 local NAMESPACE=$1; shift
1401 local NAME=$1; shift
1402
1403 if [ "$HELM_MAJOR" -le 2 ]; then
1404 helm list --deployed --short --namespace "$NAMESPACE" "$NAME" 2>/dev/null | wc -l
1405 else
1406 helm list --deployed --short --namespace "$NAMESPACE" --filter "$NAME" 2>/dev/null | wc -l
1407 fi
1408}
1409
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001410helm_install() {
David Bainbridgec7220622020-05-28 12:31:47 -07001411 local INDENT NOW VALUES_FILE PPROF_ARG
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001412 if [ "$1" == "-" ]; then
1413 INDENT=$1; shift
1414 fi
1415 local NAMESPACE=$1; shift
David Bainbridge0774b232019-08-02 06:37:19 +00001416 local INAME=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001417 local CHART=$1; shift
David Bainbridge90fd8e32019-08-21 23:32:47 +00001418 local CHART_VERSION=$1; shift
David Bainbridgec7220622020-05-28 12:31:47 -07001419 local FILTER=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001420 local MESSAGE=$*
1421
David Bainbridged18f4942020-04-14 16:46:13 -07001422 if [ "$CHART_VERSION X" != " X" ] && [ "$CHART_VERSION" != "latest" ]; then
David Bainbridge90fd8e32019-08-21 23:32:47 +00001423 CHART_VERSION="--version $CHART_VERSION"
1424 else
1425 CHART_VERSION=
1426 fi
1427
David Bainbridge99ac7a22019-08-31 02:26:43 +00001428 local CHART_ARGS=
1429 if [ -r "${INAME}-values.yaml" ]; then
1430 CHART_ARGS="-f ${INAME}-values.yaml"
1431 fi
1432
David Bainbridged18f4942020-04-14 16:46:13 -07001433 local WAIT_START CMD
1434 WAIT_START="$(date +%s)"
1435 COUNT="$((300 / 15))"
1436 bspin "$INDENT" "$MESSAGE"
1437 if [ "$HELM_USE_UPGRADE" == "yes" ]; then
David Bainbridge7f8bf992020-04-08 21:53:22 -07001438 _HELM_COMMAND="upgrade --install"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001439 _HELM_NAME_ARG="$INAME"
David Bainbridge7f8bf992020-04-08 21:53:22 -07001440 else
1441 _HELM_COMMAND="install"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001442 if [ "$HELM_MAJOR" -le 2 ]; then
1443 _HELM_NAME_ARG="--name $INAME"
1444 _HELM_ARGS=
1445 else
1446 _HELM_NAME_ARG="$INAME"
1447 _HELM_ARGS="--create-namespace"
1448 fi
David Bainbridge7f8bf992020-04-08 21:53:22 -07001449 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001450
1451 VALUES_FILE="$(mktemp)"
1452 if [ "$FILTER" == "-" ]; then
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001453 cp "values.yaml" "$VALUES_FILE"
David Bainbridgea965ca22020-06-09 17:45:04 -07001454 elif [ "${FILTER:0:1}" == "+" ]; then
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001455 cp "values.yaml" "$VALUES_FILE"
1456 yq r - "${FILTER:1}" <"values.yaml" >>"$VALUES_FILE"
David Bainbridge33e56c72020-06-11 11:39:56 -07001457 cat "$VALUES_FILE" >>"$LOG"
David Bainbridgec7220622020-05-28 12:31:47 -07001458 else
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001459 yq r - "$FILTER" <"values.yaml" >"$VALUES_FILE"
David Bainbridgec7220622020-05-28 12:31:47 -07001460 fi
1461 if [ "$WITH_PPROF" == "yes" ]; then
1462 PPROF_ARG="--set profiler.enabled=true"
1463 fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001464 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 -07001465 (set -x; ${CMD[*]} >>"$LOG" 2>&1) >>"$LOG" 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001466 SUCCESS=$?
David Bainbridged18f4942020-04-14 16:46:13 -07001467 while [ "$SUCCESS" -ne 0 ]; do
1468 NOW="$(date +%s)"
1469 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -07001470 espin "$THEX"
David Bainbridgec7220622020-05-28 12:31:47 -07001471 rm -f "$VALUES_FILE"
David Bainbridge52e6e9d2020-03-23 13:48:27 -07001472 doTimeout "waiting for helm install $CHART"
1473 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001474 sspin "$INDENT"
1475 COUNT="$((COUNT - 1))"
1476 if [ "$COUNT" -eq 0 ]; then
1477 if [ "$HELM_USE_UPGRADE" == "no" ]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001478 if [ "$HELM_MAJOR" -le 2 ]; then
1479 (set -x; helm delete --purge "$INAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1480 else
1481 (set -x; helm uninstall "$INAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1482 fi
David Bainbridge7f8bf992020-04-08 21:53:22 -07001483 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001484 (set -x; ${CMD[*]} >>"$LOG" 2>&1) >>"$LOG" 2>&1
Andy Baviere22ff252019-12-19 11:40:31 -07001485 SUCCESS=$?
David Bainbridged18f4942020-04-14 16:46:13 -07001486 COUNT="$((300 / 15))"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001487 fi
1488 sleep .15
1489 done
David Bainbridgec7220622020-05-28 12:31:47 -07001490 rm -f "$VALUES_FILE"
David Bainbridged18f4942020-04-14 16:46:13 -07001491 espin "$INDENT" "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001492}
1493
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001494echo "INSTALL NAME: $NAME" >> "$LOG"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001495
David Bainbridged18f4942020-04-14 16:46:13 -07001496STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001497if [ "$INSTALL_KUBECTL" == "no" ]; then
1498 bspin "Skip kubectl install"
1499 espin $NO_ENTRY
Test Userc13bdc92019-07-03 20:57:49 +00001500else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001501 bspin "Verify kubectl $HELM"
David Bainbridged18f4942020-04-14 16:46:13 -07001502 if [ -x "$GOPATH/bin/kubectl" ]; then
1503 espin "$VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001504 else
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001505 ERR_OUT="$(mktemp)"
David Bainbridged18f4942020-04-14 16:46:13 -07001506 espin "$NOT_VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001507 bspin - "Download and install Kubernetes/kubectl $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001508 (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
1509 RESULT=$?
1510 if [ "$RESULT" -ne 0 ]; then
1511 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001512 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download kubectl: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001513 cat "$ERR_OUT" >> "$LOG"
Zack Williamsded60cb2020-04-13 10:02:20 -07001514 rm -rf "$ERR_OUT" "$GOPATH/bin/kubectl"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001515 exit 1
1516 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001517 (set -x; chmod 755 "$GOPATH/bin/kubectl" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1518 espin - "$VERIFIED"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001519 rm -rf "$ERR_OUT"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001520 fi
Test Userc13bdc92019-07-03 20:57:49 +00001521fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001522if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001523 NOW="$(date +%s)"
1524 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001525fi
Test Userc13bdc92019-07-03 20:57:49 +00001526
David Bainbridged18f4942020-04-14 16:46:13 -07001527STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001528if [ "$DEPLOY_K8S" == "no" ]; then
1529 bspin "Skip Kubernetes/Kind Deployment"
1530 espin $NO_ENTRY
1531else
Test Userba1e7e72019-07-10 22:27:54 +00001532 bspin "Verify Kubernetes/Kind $HELM"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001533 IS_INSTALLED=0
1534 OP_TYPE="install"
David Bainbridged18f4942020-04-14 16:46:13 -07001535 if [ -x "$GOPATH/bin/kind" ]; then
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001536 OP_TYPE="upgrade"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001537 if [ "$("$GOPATH/bin/kind" version | grep -c "$KIND_VERSION")" -eq 1 ]; then
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001538 IS_INSTALLED=1
David Bainbridged18f4942020-04-14 16:46:13 -07001539 espin "$VERIFIED"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001540 fi
1541 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001542 if [ "$IS_INSTALLED" -eq 0 ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001543 ERR_OUT="$(mktemp)"
David Bainbridged18f4942020-04-14 16:46:13 -07001544 espin "$NOT_VERIFIED"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001545 bspin - "Download and $OP_TYPE Kubernetes/kind $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001546 (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
1547 RESULT=$?
1548 if [ $RESULT -ne 0 ]; then
1549 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001550 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download kind: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001551 cat "$ERR_OUT" >> "$LOG"
Zack Williamsded60cb2020-04-13 10:02:20 -07001552 rm -rf "$ERR_OUT" "$GOPATH/bin/kind"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001553 exit 1
1554 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001555 (set -x; chmod 755 "$GOPATH/bin/kind" >>"$LOG" 2>&1) >>"$LOG" 2>&1
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001556 rm -rf "$ERR_OUT"
David Bainbridged18f4942020-04-14 16:46:13 -07001557 espin - "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001558 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001559fi
1560
David Bainbridgee87067b2019-08-12 22:00:12 +00001561if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001562 NOW="$(date +%s)"
1563 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001564fi
1565
David Bainbridged18f4942020-04-14 16:46:13 -07001566STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001567if [ "$INSTALL_HELM" == "no" ]; then
1568 bspin "Skip Helm Install"
1569 espin $NO_ENTRY
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001570else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001571 bspin "Verify Helm $HELM"
David Bainbridgea34993d2020-04-01 09:15:42 -07001572 HELM_UPGRADE=0
1573 HELM_UPGRADE_DESC="install"
David Bainbridged18f4942020-04-14 16:46:13 -07001574 if [ -x "$GOPATH/bin/helm" ]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001575 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 -07001576 HELM_UP_DOWN="$(echo -e "$HAVE_VER\n$HELM_VERSION" | sort -V | head -1)"
1577 if [ "$HAVE_VER" != "$HELM_VERSION" ]; then
1578 if [ "$HELM_UP_DOWN" == "$HELM_VERSION" ]; then
David Bainbridgea34993d2020-04-01 09:15:42 -07001579 HELM_UPGRADE_DESC="downgrade"
1580 else
1581 HELM_UPGRADE_DESC="upgrade"
1582 fi
1583 HELM_UPGRADE=1
1584 else
David Bainbridged18f4942020-04-14 16:46:13 -07001585 espin "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001586 fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001587 else
David Bainbridgea34993d2020-04-01 09:15:42 -07001588 HELM_UPGRADE=1
1589 fi
1590
David Bainbridged18f4942020-04-14 16:46:13 -07001591 if [ "$HELM_UPGRADE" -ne 0 ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001592 ERR_OUT="$(mktemp)"
1593 INSTALL_HELM_BIN=$(mktemp)
David Bainbridged18f4942020-04-14 16:46:13 -07001594 espin "$NOT_VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001595 bspin - "Download and $HELM_UPGRADE_DESC Helm $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001596 (set -x; curl -o "$INSTALL_HELM_BIN" --fail -sSL https://git.io/get_helm.sh >>"$LOG" 2>"$ERR_OUT") >>"$LOG" 2>&1
1597 RESULT=$?
1598 if [ $RESULT -ne 0 ]; then
1599 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001600 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download helm installer: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001601 cat "$ERR_OUT" >> "$LOG"
1602 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT" "$GOPATH/bin/helm" "$GOPATH/bin/tiller"
1603 exit 1
1604 fi
1605 rm -rf "$ERR_OUT"
1606 chmod +x "$INSTALL_HELM_BIN"
1607 (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
1608 RESULT=$?
1609 if [ $RESULT -ne 0 ]; then
1610 espin - "$THEX"
1611 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to install helm, see install log for details${NORMAL}"
1612 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT" "$GOPATH/bin/helm" "$GOPATH/bin/tiller"
1613 exit 1
1614 fi
1615 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT"
David Bainbridged18f4942020-04-14 16:46:13 -07001616 espin - "$VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001617 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001618fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001619if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001620 NOW="$(date +%s)"
1621 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001622fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001623HELM_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 -07001624
David Bainbridged18f4942020-04-14 16:46:13 -07001625STIME="$(date +%s)"
Test Userb5712372019-07-03 21:52:17 +00001626bspin "Verify voltctl $HIGH_VOLTAGE"
David Bainbridged2811972019-12-14 01:14:09 +00001627VOK=0
1628VMESSAGE="install"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001629ERR_OUT=$(mktemp)
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001630export VC_VERSION="$VOLTCTL_VERSION"
1631if [ "$VC_VERSION" == "latest" ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001632 set -o pipefail # TODO: would be nice to run all in pipefail mode
1633 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')"
1634 RESULT=$?
1635 set +o pipefail
1636 if [ "$RESULT" -ne 0 ]; then
1637 espin - "$THEX"
1638 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to determine released version of voltctl: $(cat "$ERR_OUT")${NORMAL}"
1639 rm -rf "$ERR_OUT" "$GOPATH/bin/voltctl"
1640 exit 1
1641 fi
1642 export VC_VERSION
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001643fi
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001644
David Bainbridged18f4942020-04-14 16:46:13 -07001645if [ -x "$GOPATH/bin/voltctl" ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001646 VHAVE="$("$GOPATH/bin/voltctl" version --clientonly -o json 2>/dev/null | jq -r .version)"
David Bainbridged18f4942020-04-14 16:46:13 -07001647 RESULT=$?
1648 if [ $RESULT -eq 0 ] && [ "$VHAVE" == "$VC_VERSION" ]; then
David Bainbridged2811972019-12-14 01:14:09 +00001649 VOK=1
David Bainbridged18f4942020-04-14 16:46:13 -07001650 espin "$VERIFIED"
David Bainbridge1ba64f12019-12-18 00:40:13 +00001651 else
David Bainbridged18f4942020-04-14 16:46:13 -07001652 VCHECK="$(echo -e "$VHAVE\n$VC_VERSION" | sort -V | head -1)"
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001653 if [ "$VCHECK" == "$VHAVE" ]; then
1654 VMESSAGE="upgrade"
1655 else
1656 VMESSAGE="downgrade"
1657 fi
David Bainbridged2811972019-12-14 01:14:09 +00001658 fi
1659fi
1660
David Bainbridged18f4942020-04-14 16:46:13 -07001661if [ "$VOK" -eq 0 ]; then
1662 espin "$NOT_VERIFIED"
David Bainbridged2811972019-12-14 01:14:09 +00001663 bspin - "Download and $VMESSAGE voltctl $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001664 (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
1665 RESULT=$?
1666 if [ $RESULT -ne 0 ]; then
1667 espin - "$THEX"
1668 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download voltctl (version $VC_VERSION): $(cat "$ERR_OUT")${NORMAL}"
1669 rm -rf "$ERR_OUT" "$GOPATH/bin/voltctl"
1670 exit 1
1671 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001672 (set -x; chmod 755 "$GOPATH/bin/voltctl" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1673 espin - "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001674fi
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001675rm -rf "$ERR_OUT"
David Bainbridgee87067b2019-08-12 22:00:12 +00001676if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001677 NOW="$(date +%s)"
1678 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001679fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001680
1681bspin "Verify command PATH"
David Bainbridged18f4942020-04-14 16:46:13 -07001682espin "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001683
David Bainbridged18f4942020-04-14 16:46:13 -07001684STIME="$(date +%s)"
Test Userba1e7e72019-07-10 22:27:54 +00001685if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001686 HAVE="$(kind get clusters 2>/dev/null | grep -c "voltha-$NAME")"
Test Userba1e7e72019-07-10 22:27:54 +00001687 bspin "Verify Kubernetes/Kind Cluster"
1688 sspin
David Bainbridged18f4942020-04-14 16:46:13 -07001689 if [ "$HAVE" -eq 0 ]; then
1690 espin "$NOT_VERIFIED"
Andrea Campanella8a149192020-07-31 17:19:45 +02001691 FILE="$NAME-cluster.cfg"
David K. Bainbridge2aa08da2020-07-31 12:49:45 -07001692 if [ -n "$KIND_CFG_FILE" ]; then
1693 FILE="$KIND_CFG_FILE"
1694 else
1695 bspin - "Generating cluster configuration"
Andrea Campanelladd946472020-07-31 11:03:44 +02001696
David K. Bainbridge2aa08da2020-07-31 12:49:45 -07001697 if [ -f "$FILE" ] ; then
1698 rm "$FILE"
1699 fi
1700
1701 touch "$FILE"
1702
1703 yq w -i "$FILE" kind Cluster
1704 yq w -i "$FILE" apiVersion "kind.sigs.k8s.io/v1alpha3"
1705
1706 if [ ! "$NUM_OF_CONTROLLER_NODES" -eq 0 ]; then
1707 for instance in $(seq 1 "$NUM_OF_CONTROLLER_NODES"); do
1708 yq w -i "$FILE" "nodes[+].role" "control-plane"
1709 done
1710 fi
1711
1712 if [ ! "$NUM_OF_WORKER_NODES" -eq 0 ]; then
1713 for instance in $(seq 1 "$NUM_OF_WORKER_NODES"); do
1714 yq w -i "$FILE" "nodes[+].role" worker
1715 done
1716 fi
1717 espin - "$VERIFIED"
Andrea Campanelladd946472020-07-31 11:03:44 +02001718 fi
1719
Andrea Campanella8a149192020-07-31 17:19:45 +02001720 cat "$FILE" >> "$LOG" 2>&1
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001721
Andrea Campanella8a149192020-07-31 17:19:45 +02001722 kind create cluster --name "voltha-$NAME" --config "$FILE"
David Bainbridge491b1bd2019-07-11 17:53:11 +00001723 else
David Bainbridged18f4942020-04-14 16:46:13 -07001724 espin "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001725 fi
1726
David K. Bainbridgec0ec6492020-07-21 17:34:23 +00001727 KUBECONFIG_TMP=$(mktemp)
1728 kind get kubeconfig --name="voltha-$NAME" >"$KUBECONFIG_TMP"
1729 mkdir -p "$HOME/.kube"
1730 KUBECONFIG="$HOME/.kube/kind-config-voltha-$NAME"; export KUBECONFIG
1731 cp "$KUBECONFIG_TMP" "$KUBECONFIG"
1732 rm -rf "$KUBECONFIG_TMP"
David Bainbridge1d2c5842020-06-03 15:29:07 -07001733
Test Userba1e7e72019-07-10 22:27:54 +00001734 P="coredns-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001735 etcd-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +00001736 kindnet-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001737 kube-apiserver-voltha-$NAME-control-plane \
1738 kube-controller-manager-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +00001739 kube-proxy-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001740 kube-scheduler-voltha-$NAME-control-plane"
Test Userba1e7e72019-07-10 22:27:54 +00001741
David K. Bainbridge2aa08da2020-07-31 12:49:45 -07001742 EXPECT=2 # Always 2 DNS instances
1743 EXPECT=$((EXPECT + 4 * NUM_OF_CONTROLLER_NODES)) # etcd, apiserver, controller manager, scheduler
1744 EXPECT=$((EXPECT + 2 * (NUM_OF_CONTROLLER_NODES + NUM_OF_WORKER_NODES))) # kindnet, proxy
David Bainbridged18f4942020-04-14 16:46:13 -07001745 wait_for_pods - "kube-system" "$EXPECT" "includes" "Waiting for system PODs to start" "$NO_LABEL" "$P"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001746fi
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001747
David Bainbridgee87067b2019-08-12 22:00:12 +00001748if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001749 NOW="$(date +%s)"
1750 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001751fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001752
David Bainbridgee4d11ca2020-05-08 10:21:10 -07001753if [ "$SCHEDULE_ON_CONTROL_NODES" == "yes" ]; then
1754 bspin "Untaint control nodes to allow scheduling $LOCK"
1755 for MNODE in $(kubectl get node --selector='node-role.kubernetes.io/master' -o json | jq -r '.items[].metadata.name'); do
1756 (set -x; kubectl taint node "$MNODE" node-role.kubernetes.io/master:NoSchedule- >>"$LOG" 2>&1) >>"$LOG" 2>&1
1757 sspin
1758 done
1759 espin "$VERIFIED"
1760fi
1761
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001762if [ "$HELM_MAJOR" -le 2 ]; then
1763 STIME="$(date +%s)"
1764 COUNT="$(count_pods "kube-system" ":Running:" "$NO_LABEL" "tiller-deploy-.*")"
1765 bspin "Verify Helm"
1766 if [ "$COUNT" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001767 espin "$NOT_VERIFIED"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001768 echo -e "Configuring Helm $GEAR"
1769 if [ "$INSTALL_HELM" == "no" ]; then
1770 bspin - "Skip Helm Initialization"
1771 espin - $NO_ENTRY
1772 else
1773 bspin - "Initialize Helm"
1774 (set -x; helm init --upgrade >>"$LOG" 2>&1) >>"$LOG" 2>&1
1775 espin - "$VERIFIED"
1776 wait_for_pods - "kube-system" 1 "includes" "Waiting for Tiller POD to start" "$NO_LABEL" "tiller-deploy-.*"
1777 fi
1778
1779 # HACK (sort-of) - the config for tiller is about to be patched, which will
1780 # cause the tiller pod to be recreated. This can sometimes cause a timing
1781 # issue with the "wait_for_pods" call on tiller as it may incorrectly
1782 # identify the running/ready tiller pod that is soon to be terminated as
1783 # what it is waiting for. To avoid this issue we do a clean scale down and
1784 # scale up of the pod so the script controlls when it should be expecting
1785 # things
1786 (set -x; kubectl -n kube-system scale deploy tiller-deploy --replicas=0 >>"$LOG" 2>&1) >>"$LOG" 2>&1
1787 wait_for_pods - "kube-system" 0 "not" "Waiting for Tiller POD to shutdown" "$NO_LABEL" "tiller-deploy-.*"
1788
1789 # Create and k8s service account so that Helm can create pods
1790 bspin - "Create Tiller ServiceAccount"
1791 (set -x; kubectl create serviceaccount --namespace kube-system tiller >>"$LOG" 2>&1) >>"$LOG" 2>&1
1792 espin - "$VERIFIED"
1793 bspin - "Create Tiller ClusterRoleBinding"
1794 (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>"$LOG" 2>&1) >>"$LOG" 2>&1
1795 espin - "$VERIFIED"
1796 bspin - "Update Tiller Manifest"
1797 (set -x; kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}' >>"$LOG" 2>&1) >>"$LOG" 2>&1
1798
1799 # HACK (sort-of) - part to, spin it back up
1800 (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 -07001801 espin - "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001802 else
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001803 if [ "$(helm version -s --template '{{.Server.SemVer}}')" != "$HELM_VERSION" ]; then
1804 espin "$NOT_VERIFIED"
1805 bspin - "Sync Tiller server version with helm client"
1806 (set -x; helm init --upgrade --force-upgrade --wait >>"$LOG" 2>&1) >>"$LOG" 2>&1
1807 espin - "$VERIFIED"
1808 else
1809 espin "$VERIFIED"
1810 fi
1811
David Bainbridgea34993d2020-04-01 09:15:42 -07001812 fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001813 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 -07001814fi
David Bainbridgeddeab482020-06-24 12:43:40 -07001815
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001816# The `etcd` repo is temporary until `http://github.com/helm/charts/pull/22955` is
1817# merged into the incubator charts
David Bainbridgeddeab482020-06-24 12:43:40 -07001818REPOS="onf|https://charts.opencord.org|ONF_VOLTHA \
1819 stable|https://kubernetes-charts.storage.googleapis.com|Google_Stable \
Ubuntubaab12f2020-06-30 01:08:19 +00001820 incubator|https://kubernetes-charts-incubator.storage.googleapis.com|Google_Incubator \
1821 onos|https://charts.onosproject.org|ONF_ONOS \
1822 atomix|https://charts.atomix.io|ONF_Atomix \
1823 bbsim-sadis|https://ciena.github.io/bbsim-sadis-server/charts|Custom_BBSIM_SADIS_Server \
1824 elastic|https://helm.elastic.co|Elastic \
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001825 kiwigrid|https://kiwigrid.github.io|Fluentd-ElasticSearch \
1826 etcd|https://dbainbri-ciena.github.io/etcd-helm-chart"
David Bainbridgeddeab482020-06-24 12:43:40 -07001827
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001828REPO_UPDATE_REQ="no"
David Bainbridgeddeab482020-06-24 12:43:40 -07001829bspin - "Verify Helm Repository"
1830for REPO in $REPOS; do
1831 REPO_NAME="$(echo "$REPO" | cut -d\| -f1)"
1832 REPO_URL="$(echo "$REPO" | cut -d\| -f2)"
1833 REPO_LABEL="$(echo "$REPO" | cut -d\| -f3 | sed -e 's/_/ /g')"
1834
1835 sspin - "Verify Helm Repository: $REPO_LABEL$CEOL"
1836 if [ "$(helm repo list 2>/dev/null | grep -c "$REPO_NAME" 2>/dev/null)" -eq 0 ]; then
1837 sspin - "Add Helm Repository: $REPO_LABEL$CEOL"
1838 (set -x; helm repo add "$REPO_NAME" "$REPO_URL" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1839 REPO_UPDATE_REQ="yes"
1840 fi
1841done
1842sspin - "Verify Helm Repositories$CEOL"
1843espin - "$VERIFIED"
1844
1845if [ "$REPO_UPDATE_REQ" == "yes" ] || [ "$UPDATE_HELM_REPOS" == "yes" ]; then
1846 bspin - "Update Helm repository cache"
1847 (set -x; helm repo update >>"$LOG" 2>&1) >>"$LOG" 2>&1
1848 espin - "$VERIFIED"
1849fi
1850
David Bainbridgee87067b2019-08-12 22:00:12 +00001851if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001852 NOW="$(date +%s)"
1853 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001854fi
David Bainbridgecf546362020-04-21 23:18:50 -07001855# Resolve chart versions and log them for debug/support
1856RESOLVED_VOLTHA_CHART_VERSION=$(resolve_chart_version "$VOLTHA_CHART" "$VOLTHA_CHART_VERSION")
1857RESOLVED_VOLTHA_BBSIM_CHART_VERSION=$(resolve_chart_version "$VOLTHA_BBSIM_CHART" "$VOLTHA_BBSIM_CHART_VERSION")
Girish Kumarcc5f9172020-06-10 13:34:31 +00001858RESOLVED_VOLTHA_TRACING_CHART_VERSION=$(resolve_chart_version "$VOLTHA_TRACING_CHART" "$VOLTHA_TRACING_CHART_VERSION")
David Bainbridgecf546362020-04-21 23:18:50 -07001859RESOLVED_VOLTHA_ADAPTER_SIM_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_SIM_CHART" "$VOLTHA_ADAPTER_SIM_CHART_VERSION")
1860RESOLVED_VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_OPEN_OLT_CHART" "$VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION")
1861RESOLVED_VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_OPEN_ONU_CHART" "$VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION")
1862RESOLVED_ONOS_CHART_VERSION=$(resolve_chart_version "$ONOS_CHART" "$ONOS_CHART_VERSION")
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001863RESOLVED_ONOS_CLASSIC_CHART_VERSION=$(resolve_chart_version "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION")
David Bainbridgecf546362020-04-21 23:18:50 -07001864RESOLVED_KAFKA_CHART_VERSION=$(resolve_chart_version "$KAFKA_CHART" "$KAFKA_CHART_VERSION")
divyadesai59f987a2020-05-27 12:11:33 +00001865RESOLVED_ELASTICSEARCH_CHART_VERSION=$(resolve_chart_version "$ELASTICSEARCH_CHART" "$ELASTICSEARCH_CHART_VERSION")
1866RESOLVED_KIBANA_CHART_VERSION=$(resolve_chart_version "$KIBANA_CHART" "$KIBANA_CHART_VERSION")
1867RESOLVED_FLUENTD_ELASTICSEARCH_CHART_VERSION=$(resolve_chart_version "$FLUENTD_ELASTICSEARCH_CHART" "$FLUENTD_ELASTICSEARCH_CHART_VERSION")
David K. Bainbridge450c15c2020-06-29 10:12:06 -07001868RESOLVED_BBSIM_SADIS_SERVER_CHART_VERSION=$(resolve_chart_version "$BBSIM_SADIS_SERVER_CHART" "$BBSIM_SADIS_SERVER_CHART_VERSION")
1869RESOLVED_RADIUS_CHART_VERSION=$(resolve_chart_version "$RADIUS_CHART" "$RADIUS_CHART_VERSION")
David Bainbridgecf546362020-04-21 23:18:50 -07001870cat <<EOV >>"$LOG"
1871Resolved helm charts and versions:
1872 $VOLTHA_CHART:$RESOLVED_VOLTHA_CHART_VERSION
1873 $VOLTHA_BBSIM_CHART:$RESOLVED_VOLTHA_BBSIM_CHART_VERSION
Girish Kumarcc5f9172020-06-10 13:34:31 +00001874 $VOLTHA_TRACING_CHART:$RESOLVED_VOLTHA_TRACING_CHART_VERSION
David Bainbridgecf546362020-04-21 23:18:50 -07001875 $VOLTHA_ADAPTER_SIM_CHART:$RESOLVED_VOLTHA_ADAPTER_SIM_CHART_VERSION
1876 $VOLTHA_ADAPTER_OPEN_OLT_CHART:$RESOLVED_VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION
1877 $VOLTHA_ADAPTER_OPEN_ONU_CHART:$RESOLVED_VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION
1878 $ONOS_CHART:$RESOLVED_ONOS_CHART_VERSION
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001879 $ONOS_CLASSIC_CHART:$RESOLVED_ONOS_CLASSIC_CHART_VERSION
David Bainbridgecf546362020-04-21 23:18:50 -07001880 $KAFKA_CHART:$RESOLVED_KAFKA_CHART_VERSION
divyadesai59f987a2020-05-27 12:11:33 +00001881 $ELASTICSEARCH_CHART:$RESOLVED_ELASTICSEARCH_CHART_VERSION
1882 $KIBANA_CHART:$RESOLVED_KIBANA_CHART_VERSION
1883 $FLUENTD_ELASTICSEARCH_CHART:$RESOLVED_FLUENTD_ELASTICSEARCH_CHART_VERSION
David K. Bainbridge450c15c2020-06-29 10:12:06 -07001884 $BBSIM_SADIS_SERVER_CHART:$RESOLVED_BBSIM_SADIS_SERVER_CHART_VERSION
1885 $RADIUS_CHART:$RESOLVED_RADIUS_CHART_VERSION
David Bainbridgecf546362020-04-21 23:18:50 -07001886EOV
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001887
David Bainbridged18f4942020-04-14 16:46:13 -07001888STIME="$(date +%s)"
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001889bspin "Verify Helm values file: values.yaml"
1890if [ ! -r "./values.yaml" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001891 espin "$NOT_VERIFIED"
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001892 bspin - "Download Helm values file: values.yaml to values.yaml $DOWNLOAD"
David Bainbridged18f4942020-04-14 16:46:13 -07001893 ERR_OUT="$(mktemp)"
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001894 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 -07001895 espin - "$THEX"
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001896 echo -e "${RED}${BOLD}${ERROR}ERROR: values.yaml${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
David Bainbridged18f4942020-04-14 16:46:13 -07001897 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
Matteo Scandolo657e13c2020-07-28 11:41:42 -07001898 rm -rf "$ERR_OUT" "./values.yaml"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001899 exit 1
1900 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001901 rm -rf "$ERR_OUT"
1902 espin - "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001903else
David Bainbridged18f4942020-04-14 16:46:13 -07001904 espin "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001905fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001906if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001907 NOW="$(date +%s)"
1908 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001909fi
Test Userba1e7e72019-07-10 22:27:54 +00001910
David Bainbridged18f4942020-04-14 16:46:13 -07001911STIME="$(date +%s)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001912bspin "Verify or download chart specific values files $DOWNLOAD"
1913VALUES_FILES="monkey-values.yaml"
David Bainbridged18f4942020-04-14 16:46:13 -07001914ERR_OUT="$(mktemp)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001915for i in $VALUES_FILES; do
1916 if [ ! -r ./$i ]; then
serkant.uluderya4d315132020-04-15 16:25:54 -07001917 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 -07001918 espin "$THEX"
1919 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1920 echo "ERROR: $i - $(cat "$ERR_OUT")" >>"$LOG"
1921 rm -rf "$ERR_OUT" "./$i"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001922 exit 1
1923 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001924 rm -rf "$ERR_OUT"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001925 fi
1926done
David Bainbridged18f4942020-04-14 16:46:13 -07001927rm -rf "$ERR_OUT"
1928espin "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001929if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001930 NOW="$(date +%s)"
1931 printtime $((NOW - STIME))
David Bainbridge99ac7a22019-08-31 02:26:43 +00001932fi
1933
1934if [ "$WITH_CHAOS" == "yes" ]; then
1935 bspin "Verify or clone kube-monkey helm chart $DOWNLOAD"
1936 if [ -r ./kube-monkey ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001937 espin "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001938 else
David Bainbridged18f4942020-04-14 16:46:13 -07001939 espin "$NOT_VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001940 bspin - "GIT clone kube-monkey"
David Bainbridged18f4942020-04-14 16:46:13 -07001941 (set -x; git clone https://github.com/asobti/kube-monkey kube-monkey >>"$LOG" 2>&1) >>"$LOG" 2>&1
1942 espin - "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001943 fi
1944fi
1945
Test Userba1e7e72019-07-10 22:27:54 +00001946if [ "$JUST_K8S" == "yes" ]; then
1947 echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye."
1948 echo ""
David Bainbridged18f4942020-04-14 16:46:13 -07001949 echo "Please issue the following commands in your terminal to ensure that you" | tee -a "$LOG"
1950 echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a "$LOG"
1951 echo "tools required by VOLTHA in your command path. " | tee -a "$LOG"
1952 echo "" | tee -a "$LOG"
1953 echo -en "$BOLD"
1954 if [ "$DEPLOY_K8S" == "yes" ]; then
David K. Bainbridge02ae1f32020-07-21 13:25:13 -07001955 KUBECONFIG_TMP=$(mktemp)
1956 kind get kubeconfig --name="voltha-$NAME" >"$KUBECONFIG_TMP"
1957 mkdir -p "$HOME/.kube"
1958 KUBECONFIG="$HOME/.kube/kind-config-voltha-$NAME"; export KUBECONFIG
1959 cp "$KUBECONFIG_TMP" "$KUBECONFIG"
1960 rm -rf "$KUBECONFIG_TMP"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07001961 echo "export KUBECONFIG=\"$KUBECONFIG\"" | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00001962 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001963 echo "export PATH=$GOPATH/bin:\$PATH" | tee -a "$LOG"
1964 echo -en "$NORMAL"
1965 echo "" | tee -a "$LOG"
1966 echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00001967 exit 0
1968fi
1969
David K. Bainbridgecb4b3ab2020-08-31 08:34:14 -07001970if is_in "$WITH_ETCD" "yes,external"; then
1971 STIME="$(date +%s)"
1972 bspin "Verify external ETCD cluster $OLD_KEY"
1973 EXPECT=$NUM_OF_ETCD
1974 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^etcd\$")" -ne 1 ]; then
1975 espin "$NOT_VERIFIED"
1976 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"
1977 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
1978 else
1979 espin "$VERIFIED"
1980 fi
1981 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for ETCD cluster to start" "$NO_LABEL" "etcd-.*"
1982 if [ "$WITH_TIMINGS" == "yes" ]; then
1983 NOW="$(date +%s)"
1984 printtime $((NOW - STIME))
1985 fi
1986fi
1987
1988if is_in "$WITH_KAFKA" "yes,external"; then
1989 _TMP="$(mktemp -u)"
1990 cat << EOC > "$_TMP"
1991configurationOverrides:
1992 "default.replication.factor": $NUM_OF_KAFKA
1993 "offsets.topic.replication.factor": $NUM_OF_KAFKA
1994 "log.retention.hours": 4
1995 "log.message.timestamp.type": "LogAppendTime"
1996persistence:
1997 enabled: false
1998zookeeper:
1999 replicaCount: $NUM_OF_KAFKA
2000 persistence:
2001 enabled: false
2002replicas: $NUM_OF_KAFKA
2003EOC
2004 STIME="$(date +%s)"
2005 bspin "Verify external Kafka cluster $OLD_KEY"
2006 EXPECT=$((NUM_OF_KAFKA*2))
2007 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^kafka\$")" -ne 1 ]; then
2008 espin "$NOT_VERIFIED"
2009 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" -f $_TMP"
2010 helm_install - "$INFRA_NS" kafka "$KAFKA_CHART" "$KAFKA_CHART_VERSION" kafka "$_HELM_DESC external Kafka cluster"
2011 else
2012 espin "$VERIFIED"
2013 fi
2014 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for Kafka cluster to start" "$NO_LABEL" "kafka-.*"
2015 if [ "$WITH_TIMINGS" == "yes" ]; then
2016 NOW="$(date +%s)"
2017 printtime $((NOW - STIME))
2018 fi
2019 rm -rf "$_TMP"
2020fi
2021
2022
David Bainbridged18f4942020-04-14 16:46:13 -07002023STIME="$(date +%s)"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002024if is_in "$WITH_ONOS" "yes,legacy,classic"; then
2025 if is_in "$WITH_ONOS" "legacy"; then
2026 bspin "Verify ONOS LEGACY installed $BIRD"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002027 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^onos\$")" -ne 1 ]; then
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002028 espin "$NOT_VERIFIED"
David Bainbridge33e56c72020-06-11 11:39:56 -07002029 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 -07002030 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
2031 else
2032 espin "$VERIFIED"
2033 fi
2034 wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for ONOS to start" "$NO_LABEL" "onos-.*"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07002035
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002036 if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
2037 bspin - "Forward ONOS API port $FORWARD"
2038 kill_port_forward onos-ui
2039 port_forward "$INFRA_NS" onos-ui "$ONOS_API_PORT:8181"
2040 espin - "$VERIFIED"
2041 bspin - "Forward ONOS SSH port $FORWARD"
2042 kill_port_forward onos-ssh
2043 port_forward "$INFRA_NS" onos-ssh "$ONOS_SSH_PORT:8101"
2044 espin - "$VERIFIED"
2045 _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT"
2046 else
2047 _ONOS_API_EP="$(get_service_ep "$INFRA_NS" onos-ui)"
2048 fi
2049 elif is_in "$WITH_ONOS" "yes,classic"; then
2050 bspin "Verify ONOS CLASSIC installed $BIRD"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002051 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^onos\$")" -ne 1 ]; then
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002052 espin "$NOT_VERIFIED"
Matteo Scandoloe0829b52020-05-08 14:23:56 -07002053 # ONOS CLASSIC identifies its image repo/tag/pullPolicy differently, so yq is used to grab the values from the
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002054 # values value
David Bainbridgefad50732020-05-01 17:00:12 -07002055 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")
2057 _ONOS_REPO="$(echo "$YAML_VALUES" | yq read - images.onos.repository)"
David Bainbridgedee3f022020-06-05 07:45:13 -07002058 if [ -z "$_ONOS_REPO" ]; then
2059 _ONOS_REPO="voltha/voltha-onos"
2060 fi
David Bainbridgefad50732020-05-01 17:00:12 -07002061 _ONOS_TAG="$(echo "$YAML_VALUES" | yq read - images.onos.tag)"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002062 if [ -z "$_ONOS_TAG" ]; then
David Bainbridgedee3f022020-06-05 07:45:13 -07002063 _ONOS_TAG="$(echo "$YAML_VALUES" | yq read - defaults.image_tag)"
2064 fi
2065 if [ -z "$_ONOS_TAG" ]; then
2066 _ONOS_TAG="master"
2067 fi
2068 _ONOS_PULL_POLICY="$(echo "$YAML_VALUES" | yq read - images.onos.pullPolicy)"
2069 if [ -z "$_ONOS_PULL_POLICY" ]; then
2070 _ONOS_PULL_POLICY="$(echo "$YAML_VALUES" | yq read - defaults.image_pullPolicy)"
2071 fi
2072 if [ -z "$_ONOS_PULL_POLICY" ]; then
2073 _ONOS_PULL_POLICY="Always"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002074 fi
David Bainbridgefad50732020-05-01 17:00:12 -07002075
Matteo Scandoloe0829b52020-05-08 14:23:56 -07002076 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 -07002077 helm_install - "$INFRA_NS" onos "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION" "+onos" "$_HELM_DESC ONOS CLASSIC"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002078 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
2079 else
2080 espin "$VERIFIED"
2081 fi
2082 wait_for_pods - "$INFRA_NS" $((NUM_OF_ONOS + NUM_OF_ATOMIX)) "includes" "Waiting for ONOS CLASSIC to start" "$NO_LABEL" "onos-.*"
2083 if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
2084 bspin - "Forward ONOS API port $FORWARD"
2085 kill_port_forward onos-onos-classic-hs
2086 port_forward "$INFRA_NS" onos-onos-classic-hs "$ONOS_API_PORT:8181" "$ONOS_SSH_PORT:8101"
2087 espin - "$VERIFIED"
2088 _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT"
2089 else
2090 _ONOS_API_EP="$(get_service_ep "$INFRA_NS" onos-onos-classic-hs)"
2091 fi
2092 elif [ "$WITH_ONOS" == "micro" ]; then
2093 bspin "Verify micro-ONOS installed $BIRD"
2094 # We should never get here
2095 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Micro ONOS not currently supported${NORMAL}"
2096 exit 1
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002097 fi
David Bainbridged31d6122019-08-13 19:37:59 +00002098 bspin - "Verify or download ONOS configuration support files $DOWNLOAD"
Matteo Scandolo78dfee02020-02-13 16:18:03 -08002099 ONOS_FILES="olt-onos-enableExtraneousRules.json onos-aaa.json \
David Bainbridge696bc632020-04-05 21:49:37 -07002100 onos-dhcpl2relay.json onos-sadis-sample.json"
David Bainbridged18f4942020-04-14 16:46:13 -07002101 (set -x; mkdir -p ./onos-files >>"$LOG" 2>&1) >>"$LOG" 2>&1
2102 ERR_OUT="$(mktemp)"
David Bainbridge2b19e832019-08-16 02:40:53 +00002103 for i in $ONOS_FILES; do
David Bainbridged18f4942020-04-14 16:46:13 -07002104 if [ ! -r "./onos-files/$i" ]; then
serkant.uluderya4d315132020-04-15 16:25:54 -07002105 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 -07002106 espin - "$THEX"
2107 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
2108 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
2109 rm -rf "$ERR_OUT" "./onos-files/$i"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08002110 exit 1
2111 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002112 rm -rf "$ERR_OUT"
David Bainbridged31d6122019-08-13 19:37:59 +00002113 fi
2114 done
David Bainbridged18f4942020-04-14 16:46:13 -07002115 rm -rf "$ERR_OUT"
2116 espin - "$VERIFIED"
David Bainbridge27790d62019-08-13 22:43:19 +00002117
David Bainbridged18f4942020-04-14 16:46:13 -07002118 if [ "$INSTALL_ONOS_APPS" == "yes" ]; then
David Bainbridge27790d62019-08-13 22:43:19 +00002119 bspin - "Installing custom ONOS applications"
David Bainbridged18f4942020-04-14 16:46:13 -07002120 if [ -x onos-files/onos-apps ] && [ "$(find onos-files/onos-apps -name "*.oar" 2>/dev/null | wc -l)" -gt 0 ]; then
2121 for OAR in onos-files/onos-apps/*.oar; do
David Bainbridge27790d62019-08-13 22:43:19 +00002122 sspin - "Installing custom ONOS applications - $OAR$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -07002123 override_onos_app "$OAR"
David Bainbridge27790d62019-08-13 22:43:19 +00002124 done
2125 espin - "$VERIFIED Installing custom ONOS applications$CEOL"
2126 else
2127 espin - "$NOT_VERIFIED Installing custom ONOS applications - None Found"
2128 fi
2129 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07002130
David Bainbridged18f4942020-04-14 16:46:13 -07002131 if [ "$WITH_KAFKA" != "no" ]; then
David Bainbridge837e8bd2020-04-06 13:17:14 -07002132 check_onos_app_active org.opencord.kafka
David Bainbridge879439b2020-06-12 15:59:35 -07002133 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridgec7220622020-05-28 12:31:47 -07002134 _HOST=kafka.$INFRA_NS.svc
David Bainbridge76afd812020-04-06 09:53:52 -07002135 _PORT=9092
David Bainbridge879439b2020-06-12 15:59:35 -07002136 elif [ "$WITH_KAFKA" != "no" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002137 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
2138 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge837e8bd2020-04-06 13:17:14 -07002139 _PORT=${_PORT:-9092}
2140 fi
2141 push_onos_config "json" "Push ONOS Kafka Configuration" "network/configuration/apps/org.opencord.kafka" \
David Bainbridged18f4942020-04-14 16:46:13 -07002142 "$(cat <<EOJ | tr -d '[:space:]'
David Bainbridge696bc632020-04-05 21:49:37 -07002143{
2144 "kafka": {
2145 "bootstrapServers": "$_HOST:$_PORT"
2146 }
2147}
2148EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07002149)"
David Bainbridge837e8bd2020-04-06 13:17:14 -07002150 fi
Matteo Scandolo9a77a732020-01-09 14:24:12 -08002151 check_onos_app_active org.opencord.dhcpl2relay
Matteo Scandolo78dfee02020-02-13 16:18:03 -08002152 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 -08002153 check_onos_app_active org.opencord.olt
Matteo Scandolo78dfee02020-02-13 16:18:03 -08002154 # FIXME use WITH_DHCP and WITH_EAPOL flags to configre OLT App
Hardik Windlassa7501fb2020-02-17 14:28:20 +00002155 # Default value for "enableEapol" is true in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07002156 if [ "$WITH_EAPOL" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08002157 push_onos_config "json" "Enable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":true}'
David Bainbridged18f4942020-04-14 16:46:13 -07002158 elif [ "$WITH_EAPOL" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00002159 push_onos_config "json" "Disable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08002160 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00002161 # Default value for "enableDhcpOnProvisioning" is false and for "enableDhcpV4" is true in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07002162 if [ "$WITH_DHCP" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08002163 push_onos_config "json" "Enable VOLTHA ONOS DHCP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableDhcpOnProvisioning":true,"enableDhcpV4":true}'
David Bainbridged18f4942020-04-14 16:46:13 -07002164 elif [ "$WITH_DHCP" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00002165 push_onos_config "json" "Disable VOLTHA ONOS DHCP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableDhcpOnProvisioning":false,"enableDhcpV4":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08002166 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00002167 # Default value for "enableIgmpOnProvisioning" is false in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07002168 if [ "$WITH_IGMP" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08002169 push_onos_config "json" "Enable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":true}'
David Bainbridged18f4942020-04-14 16:46:13 -07002170 elif [ "$WITH_IGMP" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00002171 push_onos_config "json" "Disable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08002172 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002173 if [ "$ENABLE_ONOS_EXTRANEOUS_RULES" == "yes" ]; then
David K. Bainbridge484d80c2020-03-05 21:44:34 -08002174 push_onos_config "file" "Enabling extraneous rules for ONOS" "configuration/org.onosproject.net.flow.impl.FlowRuleManager" "onos-files/olt-onos-enableExtraneousRules.json"
2175 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002176 if is_in "$CONFIG_SADIS" "yes,file"; then
Matteo Scandolo9a77a732020-01-09 14:24:12 -08002177 check_onos_app_active org.opencord.sadis
Hardik Windlassb3147602020-03-09 16:59:15 +05302178 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 -07002179 elif [ "$CONFIG_SADIS" == "bbsim" ]; then
2180 push_onos_config "json" \
2181 "[optional] Push ONOS configuration for BBSIM SADIS servers" \
2182 "network/configuration/apps/org.opencord.sadis" \
David Bainbridged18f4942020-04-14 16:46:13 -07002183 "$(cat <<EOJ | tr -d '[:space:]'
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002184{
2185 "sadis": {
2186 "integration": {
David Bainbridgec7220622020-05-28 12:31:47 -07002187 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:50074/v2/subscribers/%s",
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002188 "cache": {
2189 "enabled": true,
2190 "maxsize": 50,
2191 "ttl": "PT1m"
2192 }
2193 }
2194 },
2195 "bandwidthprofile": {
2196 "integration": {
David Bainbridgec7220622020-05-28 12:31:47 -07002197 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:50074/v2/bandwidthprofiles/%s",
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002198 "cache": {
2199 "enabled": true,
2200 "maxsize": 50,
2201 "ttl": "PT1m"
2202 }
2203 }
2204 }
2205}
2206EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07002207)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002208 elif [ "$CONFIG_SADIS" == "url" ]; then
2209 push_onos_config "json" \
2210 "[optional] Push ONOS configuration for custom SADIS and Bandwidth Profile servers" \
2211 "network/configuration/apps/org.opencord.sadis" \
David Bainbridged18f4942020-04-14 16:46:13 -07002212 "$(cat <<EOJ | tr -d '[:space:]'
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002213{
2214 "sadis": {
2215 "integration": {
2216 "url": "$SADIS_SUBSCRIBERS",
2217 "cache": {
2218 "enabled": true,
2219 "maxsize": 50,
2220 "ttl": "PT1m"
2221 }
2222 }
2223 },
2224 "bandwidthprofile": {
2225 "integration": {
2226 "url": "$SADIS_BANDWIDTH_PROFILES",
2227 "cache": {
2228 "enabled": true,
2229 "maxsize": 50,
2230 "ttl": "PT1m"
2231 }
2232 }
2233 }
2234}
2235EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07002236)"
David Bainbridge2b19e832019-08-16 02:40:53 +00002237 fi
Test Userba1e7e72019-07-10 22:27:54 +00002238fi
David Bainbridgee87067b2019-08-12 22:00:12 +00002239if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002240 NOW="$(date +%s)"
2241 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002242fi
Test Userba1e7e72019-07-10 22:27:54 +00002243
Girish Kumarcc5f9172020-06-10 13:34:31 +00002244if [ "$WITH_TRACING" == "yes" ]; then
2245 STIME="$(date +%s)"
2246 echo -e "Verify Jaeger Tracing $PLUG"
2247 bspin - "Verify Jaeger Tracing Installed"
2248 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^tracing\$")" -ne 1 ]; then
2249 espin - "$NOT_VERIFIED"
2250 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
2251 helm_install - "$INFRA_NS" tracing "$VOLTHA_TRACING_CHART" "$VOLTHA_TRACING_CHART_VERSION" tracing "$_HELM_DESC Jaeger Tracing"
2252 else
2253 espin - "$VERIFIED"
2254 fi
2255 wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for Jaeger Tracing to start" "$NO_LABEL" "jaeger*"
2256 if [ "$WITH_TIMINGS" == "yes" ]; then
2257 NOW="$(date +%s)"
2258 printtime $((NOW - STIME))
2259 fi
2260fi
2261
David Bainbridged18f4942020-04-14 16:46:13 -07002262STIME="$(date +%s)"
David Bainbridgeed476572020-06-02 14:05:45 -07002263EXPECT=2
2264# therecanbeonlyone set hardcoded to true for backward compatibility
2265INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set therecanbeonlyone=true"
Matteo Scandolo67335f02020-04-09 11:19:53 -07002266case $WITH_ETCD in
David Bainbridge76afd812020-04-06 09:53:52 -07002267 no)
David Bainbridge76afd812020-04-06 09:53:52 -07002268 ;;
David Bainbridgec7220622020-05-28 12:31:47 -07002269 yes|external)
2270 _HOST="etcd.$INFRA_NS.svc"
David Bainbridge76afd812020-04-06 09:53:52 -07002271 _PORT=2379
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002272 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
Neha Sharmaa1c92ca2020-06-24 11:50:33 +00002273 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.address=$_HOST:$_PORT"
David Bainbridge76afd812020-04-06 09:53:52 -07002274 ;;
2275 *)
David Bainbridged18f4942020-04-14 16:46:13 -07002276 _HOST="$(echo "$WITH_ETCD" | cut -d: -f1)"
2277 _PORT="$(echo "$WITH_ETCD" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07002278 _PORT=${_PORT:-2379}
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002279 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
Neha Sharmaa1c92ca2020-06-24 11:50:33 +00002280 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.address=$_HOST:$_PORT"
David Bainbridge76afd812020-04-06 09:53:52 -07002281 ;;
2282esac
2283case $WITH_KAFKA in
2284 no)
David Bainbridge76afd812020-04-06 09:53:52 -07002285 ;;
David Bainbridgec7220622020-05-28 12:31:47 -07002286 yes|external)
2287 _HOST=kafka.$INFRA_NS.svc
David Bainbridge76afd812020-04-06 09:53:52 -07002288 _PORT=9092
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002289 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"
2290 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 -07002291 ;;
2292 *)
David Bainbridged18f4942020-04-14 16:46:13 -07002293 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
2294 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07002295 _PORT=${_PORT:-9092}
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002296 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"
2297 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 -07002298 ;;
2299esac
2300
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002301if is_in "$WITH_ONOS" "legacy"; then
David Bainbridgec7220622020-05-28 12:31:47 -07002302 _HOST=onos-openflow.$INFRA_NS.svc
David Bainbridge76afd812020-04-06 09:53:52 -07002303 _PORT=6653
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002304elif is_in "$WITH_ONOS" "yes,classic"; then
David Bainbridgec7220622020-05-28 12:31:47 -07002305 _HOST=onos-onos-classic-hs.$INFRA_NS.svc
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002306 _PORT=6653
David Bainbridged18f4942020-04-14 16:46:13 -07002307elif [ "$WITH_ONOS" != "no" ]; then
2308 _HOST="$(echo "$WITH_ONOS" | cut -d: -f1)"
2309 _PORT="$(echo "$WITH_ONOS" | cut -s -d: -f2)"
David Bainbridge76afd812020-04-06 09:53:52 -07002310 _PORT=${_PORT:-6653}
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002311fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002312
David Bainbridgecf546362020-04-21 23:18:50 -07002313compare_versions "$RESOLVED_VOLTHA_CHART_VERSION" 2.4.2
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002314if [ "$?" == "1" ]; then
2315 # voltha chart > 2.4.2 uses list of controllers
David Bainbridgee4d11ca2020-05-08 10:21:10 -07002316 for NUM in $(seq 0 $((NUM_OF_ONOS-1))); do
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002317 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 +00002318 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 -07002319 done
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002320else
2321 # voltha chart <= 2.4.2 uses single controller
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002322 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.controller.service=$_HOST --set services.controller.port=$_PORT"
Neha Sharmaa1c92ca2020-06-24 11:50:33 +00002323 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.controller.address=$_HOST:$_PORT"
David Bainbridge696bc632020-04-05 21:49:37 -07002324fi
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002325
Girish Kumarcc5f9172020-06-10 13:34:31 +00002326if [ "$WITH_TRACING" == "yes" ]; then
2327 VOLTHA_TRACING_CHART_NAME=$(resolve_chart_name "$VOLTHA_TRACING_CHART")
2328 _HOST="tracing-${VOLTHA_TRACING_CHART_NAME}-jaeger-agent.$INFRA_NS.svc"
2329 _PORT=6831
2330 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set tracing.enabled=true --set services.tracing_agent.address=$_HOST:$_PORT"
2331fi
2332
Test Userb5712372019-07-03 21:52:17 +00002333bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002334if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$VOLTHA_NS" "^voltha\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002335 espin "$NOT_VERIFIED"
David Bainbridgea965ca22020-06-09 17:45:04 -07002336 helm_install - "$VOLTHA_NS" voltha "$VOLTHA_CHART" "$VOLTHA_CHART_VERSION" "+voltha" "$_HELM_DESC VOLTHA Core"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002337else
David Bainbridged18f4942020-04-14 16:46:13 -07002338 espin "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002339fi
David Bainbridge696bc632020-04-05 21:49:37 -07002340INTERNAL_EXTRA_HELM_INSTALL_ARGS=
Test Userba1e7e72019-07-10 22:27:54 +00002341
David Bainbridge90fd8e32019-08-21 23:32:47 +00002342VOLTHA="voltha-ofagent-.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002343 rw-core.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002344 voltha-zookeeper-.*"
David Bainbridged18f4942020-04-14 16:46:13 -07002345wait_for_pods - "$VOLTHA_NS" "$EXPECT" "includes" "Waiting for VOLTHA Core to start" "$NO_LABEL" "$VOLTHA"
David Bainbridgee87067b2019-08-12 22:00:12 +00002346if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002347 NOW="$(date +%s)"
2348 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002349fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002350
David Bainbridge46505fb2019-10-01 21:13:20 +00002351if [ "$WITH_ADAPTERS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002352 STIME="$(date +%s)"
David Bainbridge46505fb2019-10-01 21:13:20 +00002353 EXPECT=0
David Bainbridgec7220622020-05-28 12:31:47 -07002354 if is_in "$WITH_ETCD" "yes,external"; then
2355 _HOST=etcd.$INFRA_NS.svc
David Bainbridge3517f6c2020-04-08 12:14:08 -07002356 _PORT=2379
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002357 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
2358 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.address=$_HOST:$_PORT"
David Bainbridged18f4942020-04-14 16:46:13 -07002359 elif [ "$WITH_ETCD" != "no" ]; then
2360 _HOST="$(echo "$WITH_ETCD" | cut -d: -f1)"
2361 _PORT="$(echo "$WITH_ETCD" | cut -s -d: -f2)"
David Bainbridge3517f6c2020-04-08 12:14:08 -07002362 _PORT=${_PORT:-2379}
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002363 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
2364 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.address=$_HOST:$_PORT"
David Bainbridge696bc632020-04-05 21:49:37 -07002365 fi
David Bainbridgec7220622020-05-28 12:31:47 -07002366 if is_in "$WITH_KAFKA" "yes,external"; then
2367 _HOST=kafka.$INFRA_NS.svc
David Bainbridge3517f6c2020-04-08 12:14:08 -07002368 _PORT=9092
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002369 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"
2370 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 -07002371 elif [ "$WITH_KAFKA" != "no" ]; then
2372 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
2373 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge3517f6c2020-04-08 12:14:08 -07002374 _PORT=${_PORT:-9092}
David K. Bainbridgeec1cdf32020-07-23 15:51:07 +00002375 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"
2376 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 -07002377 fi
Girish Kumarcc5f9172020-06-10 13:34:31 +00002378 if [ "$WITH_TRACING" == "yes" ]; then
2379 VOLTHA_TRACING_CHART_NAME=$(resolve_chart_name "$VOLTHA_TRACING_CHART")
2380 _HOST="tracing-${VOLTHA_TRACING_CHART_NAME}-jaeger-agent.$INFRA_NS.svc"
2381 _PORT=6831
2382 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set tracing.enabled=true --set services.tracing_agent.address=$_HOST:$_PORT"
2383 fi
David Bainbridge46505fb2019-10-01 21:13:20 +00002384 echo -e "Verify Adapters $PLUG"
2385 if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then
2386 bspin - "Verify Simulated Adapters installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002387 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$ADAPTER_NS" "^sim\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002388 espin - "$NOT_VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002389 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 +00002390 else
David Bainbridged18f4942020-04-14 16:46:13 -07002391 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00002392 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002393 EXPECT="$((EXPECT + 2))"
David Bainbridge46505fb2019-10-01 21:13:20 +00002394 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07002395
David Bainbridge46505fb2019-10-01 21:13:20 +00002396 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
2397 bspin - "Verify OpenOLT Adapter installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002398 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$ADAPTER_NS" "^open-olt\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002399 espin - "$NOT_VERIFIED"
David Bainbridgea965ca22020-06-09 17:45:04 -07002400 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 +00002401 else
David Bainbridged18f4942020-04-14 16:46:13 -07002402 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00002403 fi
Matteo Scandolo67335f02020-04-09 11:19:53 -07002404 EXPECT="$((EXPECT + 1))"
David Bainbridge46505fb2019-10-01 21:13:20 +00002405 bspin - "Verify OpenONU Adapter installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002406 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$ADAPTER_NS" "^open-onu\$")" -ne 1 ]; then
Matteo Scandolo67335f02020-04-09 11:19:53 -07002407 _ORIGINAL_EXTRA_HELM_INSTALL_ARGS="$INTERNAL_EXTRA_HELM_INSTALL_ARGS"
2408 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set replicas.adapter_open_onu=$NUM_OF_OPENONU"
Girish Gowdra4cc5d8b2020-06-11 17:12:00 -07002409 if [ "$WITH_INCREMENTAL_EVTO_UPDATE" == "yes" ]; then
Girish Gowdra1c7ad4c2020-06-26 13:35:16 -07002410 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set defaults.incremental_evto_update=true"
Girish Gowdra4cc5d8b2020-06-11 17:12:00 -07002411 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002412 espin - "$NOT_VERIFIED"
David Bainbridgea965ca22020-06-09 17:45:04 -07002413 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 -07002414 INTERNAL_EXTRA_HELM_INSTALL_ARGS="$_ORIGINAL_EXTRA_HELM_INSTALL_ARGS"
David Bainbridge46505fb2019-10-01 21:13:20 +00002415 else
David Bainbridged18f4942020-04-14 16:46:13 -07002416 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00002417 fi
Matteo Scandolo67335f02020-04-09 11:19:53 -07002418 EXPECT=$((EXPECT + NUM_OF_OPENONU))
David Bainbridge46505fb2019-10-01 21:13:20 +00002419 fi
David Bainbridge696bc632020-04-05 21:49:37 -07002420 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07002421
David Bainbridge46505fb2019-10-01 21:13:20 +00002422 ADAPTERS="adapter-.*"
David Bainbridged18f4942020-04-14 16:46:13 -07002423 wait_for_pods - "$ADAPTER_NS" "$EXPECT" "includes" "Waiting for adapters to start" "$NO_LABEL" "$ADAPTERS"
David Bainbridge46505fb2019-10-01 21:13:20 +00002424 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002425 NOW="$(date +%s)"
2426 printtime $((NOW - STIME))
David Bainbridge46505fb2019-10-01 21:13:20 +00002427 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00002428fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002429
David Bainbridged18f4942020-04-14 16:46:13 -07002430if [ "$WITH_BBSIM" == "yes" ]; then
2431 STIME="$(date +%s)"
Test User7d866122019-07-09 17:52:35 +00002432 echo -e "Verify BBSIM $PLUG"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002433 bspin - "Verify BBSIM Installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002434 for instance in $(seq 0 $((NUM_OF_BBSIM-1))); do
Matteo Scandoloc2eb0672020-05-01 14:43:15 -07002435
2436 if [ "$LEGACY_BBSIM_INDEX" == "yes" ]; then
2437 if [ "$instance" -eq 0 ]; then
2438 instance_num=""
2439 else
2440 instance_num=$instance
2441 fi
David K. Bainbridge43422402020-03-06 07:41:22 -08002442 else
2443 instance_num=$instance
2444 fi
Matteo Scandoloc2eb0672020-05-01 14:43:15 -07002445
2446
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002447 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$BBSIM_NS" "^bbsim${instance_num}\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002448 espin - "$NOT_VERIFIED"
Matteo Scandolo6402d362020-08-24 12:31:06 -07002449
2450 if [[ $(semver_greater "$VOLTHA_BBSIM_CHART_VERSION" "3.1.0") == "true" ]]; then
2451 # this is the latest BBSim with support for TT
2452 # when we deploy multiple BBSims we need to update the configuration
2453 # to avoid overlapping tags.
2454 _TAG="$((900+instance))"
2455 BBSIM_TMP="$(mktemp -u)"
2456 sed -e "s/\":TAG:\"/$_TAG/g" "$BBSIM_CFG" > "$BBSIM_TMP"
2457
2458 INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set olt_id=$instance -f $BBSIM_TMP"
David Bainbridged9329af2020-05-01 11:58:52 -07002459 else
Matteo Scandolo6402d362020-08-24 12:31:06 -07002460 # these are older versio of BBSim
2461 S_TAG="$((900+instance))"
2462 INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set olt_id=$instance,s_tag=$S_TAG"
2463 if [ "$WITH_EAPOL" == "yes" ]; then
2464 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set auth=true"
2465 else
2466 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set auth=false"
2467 fi
2468 if [ "$WITH_DHCP" == "yes" ]; then
2469 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set dhcp=true"
2470 else
2471 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set dhcp=false"
2472 fi
David Bainbridged9329af2020-05-01 11:58:52 -07002473 fi
Matteo Scandolo6402d362020-08-24 12:31:06 -07002474
David Bainbridge33e56c72020-06-11 11:39:56 -07002475 if is_in "$WITH_KAFKA" "yes,external"; then
2476 _HOST=kafka.$INFRA_NS.svc
2477 _PORT=9092
2478 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafkaAddress=$_HOST:$_PORT"
2479 elif [ "$WITH_KAFKA" != "no" ]; then
2480 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
2481 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
2482 _PORT=${_PORT:-9092}
2483 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafkaAddress=$_HOST:$_PORT"
2484 fi
2485 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 -07002486 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
Matteo Scandolo6402d362020-08-24 12:31:06 -07002487 rm -f "$BBSIM_TMP"
David K. Bainbridge43422402020-03-06 07:41:22 -08002488 else
David Bainbridged18f4942020-04-14 16:46:13 -07002489 espin - "$VERIFIED"
David K. Bainbridge43422402020-03-06 07:41:22 -08002490 fi
2491 done
David Bainbridged18f4942020-04-14 16:46:13 -07002492 wait_for_pods - "$BBSIM_NS" "$NUM_OF_BBSIM" "includes" "Waiting for BBSIM to start" "$BBSIM_LABEL" "bbsim*"
David Bainbridgee87067b2019-08-12 22:00:12 +00002493 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002494 NOW="$(date +%s)"
2495 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002496 fi
Test User7d866122019-07-09 17:52:35 +00002497fi
2498
divyadesai59f987a2020-05-27 12:11:33 +00002499if [ "$WITH_EFK" == "yes" ]; then
2500 STIME="$(date +%s)"
2501 echo -e "Verify EFK $PLUG"
2502 bspin - "Verify EFK Installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002503 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 +00002504 espin - "$NOT_VERIFIED"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002505 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^elasticsearch\$")" -ne 1 ]; then
divyadesai59f987a2020-05-27 12:11:33 +00002506 helm_install - "$INFRA_NS" elasticsearch "$ELASTICSEARCH_CHART" "$ELASTICSEARCH_CHART_VERSION" elasticsearch "$_HELM_DESC elasticsearch"
2507 fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002508 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^kibana\$")" -ne 1 ]; then
divyadesai59f987a2020-05-27 12:11:33 +00002509 helm_install - "$INFRA_NS" kibana "$KIBANA_CHART" "$KIBANA_CHART_VERSION" kibana "$_HELM_DESC kibana"
2510 fi
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002511 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^fluentd\$")" -ne 1 ]; then
divyadesai59f987a2020-05-27 12:11:33 +00002512 helm_install - "$INFRA_NS" fluentd "$FLUENTD_ELASTICSEARCH_CHART" "$FLUENTD_ELASTICSEARCH_CHART_VERSION" fluentd-elasticsearch "$_HELM_DESC fluentd-elasticsearch"
2513 fi
2514 else
2515 espin - "$VERIFIED"
2516 fi
2517 EXPECT=2 # for elastic and kibana
2518 if [ "$TYPE" == "minimal" ]; then
2519 EXPECT=$((EXPECT + 2)) # for fluentd on worker 2 worker nodes
2520 else
2521 EXPECT=$((EXPECT + 3)) # for fluentd on worker 3 worker nodes
2522 fi
2523 if [ "$SCHEDULE_ON_CONTROL_NODES" == "yes" ]; then
2524 EXPECT=$((EXPECT + 1)) # for fluentd on the control plan node
2525 fi
2526
2527 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for EFK to start" "$NO_LABEL" "fluentd-* elasticsearch-* kibana-*"
2528 if [ "$WITH_TIMINGS" == "yes" ]; then
2529 NOW="$(date +%s)"
2530 printtime $((NOW - STIME))
2531 fi
2532fi
2533
David Bainbridge309099c2020-05-05 08:47:29 -07002534if [ "$CONFIG_SADIS" == "external" ]; then
2535 STIME="$(date +%s)"
2536 echo -e "Verify BBSIM SADIS Service $PLUG"
2537 bspin - "Verify required configmap"
2538 (set -x; kubectl -n "$BBSIM_NS" delete --ignore-not-found configmap kube-config >>"$LOG" 2>&1) >>"$LOG" 2>&1
2539 (set -x; kubectl -n "$BBSIM_NS" create configmap kube-config "--from-file=kube_config=$KUBECONFIG" >>"$LOG" 2>&1) >>"$LOG" 2>&1
2540 espin - "$VERIFIED"
2541 bspin - "Verify BBSIM SADIS Service Installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002542 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$BBSIM_NS" "^bbsim-sadis-server\$")" -ne 1 ]; then
David Bainbridge309099c2020-05-05 08:47:29 -07002543 espin - "$NOT_VERIFIED"
Matteo Scandolo871fd982020-07-23 11:46:51 -07002544 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"
2545 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
David Bainbridge309099c2020-05-05 08:47:29 -07002546 else
2547 espin - "$VERIFIED"
2548 fi
2549 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 +00002550
Matteo Scandolo21660442020-07-17 11:05:21 -07002551 if is_in "$WITH_ONOS" "yes,classic,legacy"; then
Ubuntu7135e6a2020-06-30 01:46:08 +00002552 if kubectl get -n "$BBSIM_NS" svc/bbsim-sadis-server-bbsim-sadis-server >/dev/null 2>&1; then
2553 BBSIM_SADIS_SVC="bbsim-sadis-server-bbsim-sadis-server"
2554 else
2555 BBSIM_SADIS_SVC="bbsim-sadis-server"
2556 fi
2557 push_onos_config "json" \
2558 "[optional] Push ONOS configuration for custom SADIS and Bandwidth Profile servers" \
2559 "network/configuration/apps/org.opencord.sadis" \
2560 "$(cat <<EOJ | tr -d '[:space:]'
2561{
2562 "sadis": {
2563 "integration": {
2564 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:58080/subscribers/%s",
2565 "cache": {
2566 "enabled": true,
2567 "maxsize": 50,
2568 "ttl": "PT1m"
2569 }
2570 }
2571 },
2572 "bandwidthprofile": {
2573 "integration": {
2574 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:58080/profiles/%s",
2575 "cache": {
2576 "enabled": true,
2577 "maxsize": 50,
2578 "ttl": "PT1m"
2579 }
2580 }
2581 }
2582}
2583EOJ
2584)"
2585 fi
David Bainbridge309099c2020-05-05 08:47:29 -07002586 if [ "$WITH_TIMINGS" == "yes" ]; then
2587 NOW="$(date +%s)"
2588 printtime $((NOW - STIME))
2589 fi
2590fi
2591
David Bainbridged18f4942020-04-14 16:46:13 -07002592if [ "$WITH_RADIUS" == "yes" ]; then
2593 STIME="$(date +%s)"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002594 echo -e "Verify RADIUS $LOCK"
2595 bspin - "Verify RADIUS Installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002596 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$INFRA_NS" "^radius\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002597 espin - "$NOT_VERIFIED"
David Bainbridge879439b2020-06-12 15:59:35 -07002598 helm_install - "$INFRA_NS" radius "$RADIUS_CHART" "$RADIUS_CHART_VERSION" "+radius" "$_HELM_DESC RADIUS"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002599 else
David Bainbridged18f4942020-04-14 16:46:13 -07002600 espin - "$VERIFIED"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002601 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002602 wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for RADIUS to start" "$NO_LABEL" "radius-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00002603 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002604 NOW="$(date +%s)"
2605 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002606 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002607fi
2608
David Bainbridged18f4942020-04-14 16:46:13 -07002609if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
2610 STIME="$(date +%s)"
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002611 bspin - "Forward VOLTHA API port $FORWARD"
David Bainbridge1d2c5842020-06-03 15:29:07 -07002612 kill_port_forward voltha-api voltha-voltha-api
2613 VOLTHA_PREFIX=
2614 if kubectl get -n "$VOLTHA_NS" "svc/voltha-voltha-api" >/dev/null 2>&1; then
2615 VOLTHA_PREFIX="voltha-"
2616 fi
Matteo Scandolo21660442020-07-17 11:05:21 -07002617
David Bainbridge1d2c5842020-06-03 15:29:07 -07002618 port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-api" "$VOLTHA_API_PORT:55555"
David Bainbridged18f4942020-04-14 16:46:13 -07002619 espin - "$VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002620 if is_in "$WITH_ETCD" "yes,external"; then
David Bainbridge696bc632020-04-05 21:49:37 -07002621 bspin - "Forward VOLTHA ETCD port $FORWARD"
David Bainbridgec7220622020-05-28 12:31:47 -07002622 kill_port_forward "etcd"
2623 port_forward "$INFRA_NS" "etcd" "$VOLTHA_ETCD_PORT:2379"
David Bainbridged18f4942020-04-14 16:46:13 -07002624 espin - "$VERIFIED"
David Bainbridge696bc632020-04-05 21:49:37 -07002625 fi
David Bainbridgec7220622020-05-28 12:31:47 -07002626 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridge696bc632020-04-05 21:49:37 -07002627 bspin - "Forward VOLTHA Kafka port $FORWARD"
David Bainbridgec7220622020-05-28 12:31:47 -07002628 kill_port_forward "kafka"
2629 port_forward "$INFRA_NS" kafka "$VOLTHA_KAFKA_PORT:9092"
David Bainbridged18f4942020-04-14 16:46:13 -07002630 espin - "$VERIFIED"
David Bainbridge696bc632020-04-05 21:49:37 -07002631 fi
divyadesai59f987a2020-05-27 12:11:33 +00002632 if [ "$WITH_EFK" == "yes" ]; then
2633 bspin - "Forward EFK port $FORWARD"
2634 kill_port_forward elasticsearch-master
2635 kill_port_forward kibana-kibana
2636 port_forward "$INFRA_NS" elasticsearch-master "$ELASTICSEARCH_PORT:9200"
2637 port_forward "$INFRA_NS" kibana-kibana "$KIBANA_PORT:5601"
2638 espin - "$VERIFIED"
2639 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -07002640 if [ "$WITH_PPROF" == "yes" ]; then
David Bainbridge1d2c5842020-06-03 15:29:07 -07002641 VOLTHA_OPENOLT_PREFIX=
2642 if kubectl get -n "$ADAPTER_NS" "svc/open-olt-adapter-open-olt-profiler" >/dev/null 2>&1; then
2643 VOLTHA_OPENOLT_PREFIX="open-olt-"
2644 fi
David Bainbridge879439b2020-06-12 15:59:35 -07002645 bspin - "Forward PProf ports port $FORWARD"
2646 kill_port_forward voltha-rw-core-profiler voltha-voltha-rw-core-profiler
2647 kill_port_forward adapter-open-olt-profiler open-olt-adapter-open-olt-profiler
2648 kill_port_forward voltha-of-agent-profiler voltha-voltha-of-agent-profiler
2649 port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-rw-core-profiler" "$VOLTHA_PPROF_PORT:6060"
2650 port_forward "$ADAPTER_NS" "${VOLTHA_OPENOLT_PREFIX}adapter-open-olt-profiler" "$OPENOLT_PPROF_PORT:6060"
2651 port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-of-agent-profiler" "$OFAGENT_PPROF_PORT:6060"
2652 espin - "$VERIFIED"
Matteo Scandoloefee0432020-05-05 13:56:20 -07002653 fi
Girish Kumarcc5f9172020-06-10 13:34:31 +00002654 if [ "$WITH_TRACING" == "yes" ]; then
2655 bspin - "Forward VOLTHA Tracing GUI port $FORWARD"
2656 VOLTHA_TRACING_CHART_NAME=$(resolve_chart_name "$VOLTHA_TRACING_CHART")
2657 kill_port_forward "tracing-${VOLTHA_TRACING_CHART_NAME}-jaeger-gui"
2658 port_forward "$INFRA_NS" "tracing-${VOLTHA_TRACING_CHART_NAME}-jaeger-gui" "$TRACING_GUI_PORT:16686"
2659 espin - "$VERIFIED"
2660 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002661 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002662 NOW="$(date +%s)"
2663 printtime $((NOW - STIME))
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002664 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00002665fi
Test User3d7ad8e2019-07-03 06:15:44 +00002666
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002667if is_in "$WITH_ONOS" "yes,legacy,classic" && [ "$WITH_RADIUS" != "no" ]; then
David Bainbridge879439b2020-06-12 15:59:35 -07002668 SVC_NAME=radius
2669 if kubectl get -n "$INFRA_NS" "svc/radius-freeradius" >/dev/null 2>&1; then
2670 SVC_NAME="radius-freeradius"
2671 fi
2672 _HOST="$SVC_NAME.$INFRA_NS.svc"
David Bainbridge696bc632020-04-05 21:49:37 -07002673 _PORT=1812
David Bainbridged18f4942020-04-14 16:46:13 -07002674 if [ "$WITH_RADIUS" != "yes" ]; then
2675 _HOST="$(echo "$WITH_RADIUS" | cut -d: -f1)"
2676 _PORT="$(echo "$WITH_RADIUS" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07002677 _PORT=${_PORT:-1812}
2678 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002679 bspin "Configure ONOS RADIUS Connection $GEAR"
David Bainbridged18f4942020-04-14 16:46:13 -07002680 (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
2681 espin "$VERIFIED"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002682fi
2683
divyadesai59f987a2020-05-27 12:11:33 +00002684if [ "$WITH_EFK" == "yes" ]; then
2685 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"
2686# fi
2687fi
2688
David Bainbridge99ac7a22019-08-31 02:26:43 +00002689if [ "$WITH_CHAOS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002690 STIME="$(date +%s)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002691 echo -e "Verify kube-monkey $LOCK"
2692 bspin - "Verify kube-monkey Installed"
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002693 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed kube-monkey "^monkey\$")" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002694 espin - "$NOT_VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002695 helm_install - kube-monkey monkey ./kube-monkey/helm/kubemonkey latest - "$_HELM_DESC Chaos Monkey"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002696 else
David Bainbridged18f4942020-04-14 16:46:13 -07002697 espin - "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002698 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002699 wait_for_pods - "kube-monkey" 1 "includes" "Waiting for Chaos to start" "$NO_LABEL" "monkey-.*"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002700 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002701 NOW="$(date +%s)"
2702 printtime $((NOW - STIME))
David Bainbridge99ac7a22019-08-31 02:26:43 +00002703 fi
2704fi
2705
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002706bspin "Create voltctl configuration file"
David Bainbridged18f4942020-04-14 16:46:13 -07002707(set -x; mkdir -p "$HOME/.volt" >>"$LOG" 2>&1) >>"$LOG" 2>&1
2708MIN_VC_VERSION="$(echo -e "1.0.15\n$VC_VERSION" | sort -V | head -1)"
2709if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002710 KAFKA_FLAG="-k localhost:$VOLTHA_KAFKA_PORT"
2711 SERVER_FLAG="-s localhost:$VOLTHA_API_PORT"
2712 ETCD_FLAG=
2713 if [ "$MIN_VC_VERSION" == "1.0.15" ]; then
2714 ETCD_FLAG="-e localhost:$VOLTHA_ETCD_PORT"
2715 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002716else
David Bainbridgec7220622020-05-28 12:31:47 -07002717 KAFKA_FLAG="-k $(get_service_ep "$INFRA_NS" kafka)"
David Bainbridged18f4942020-04-14 16:46:13 -07002718 SERVER_FLAG="-s $(get_service_ep "$VOLTHA_NS" voltha-api)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002719 ETCD_FLAG=
2720 if [ "$MIN_VC_VERSION" == "1.0.15" ]; then
David Bainbridgec7220622020-05-28 12:31:47 -07002721 ETCD_FLAG="-e $(get_service_ep "$INFRA_NS" etcd)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002722 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002723fi
David Bainbridgea965ca22020-06-09 17:45:04 -07002724CMD=("voltctl $KAFKA_FLAG $SERVER_FLAG $ETCD_FLAG config")
David Bainbridged18f4942020-04-14 16:46:13 -07002725(set -x; ${CMD[*]} > "$HOME/.volt/config-$NAME" 2>>"$LOG") >>"$LOG" 2>&1
David Bainbridgea965ca22020-06-09 17:45:04 -07002726#(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 -07002727espin "$VERIFIED"
Test User08ebbd92019-07-03 17:15:39 +00002728
David Bainbridge0774b232019-08-02 06:37:19 +00002729if [ ! -f "$NAME-env.sh" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002730 touch "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002731fi
2732
David Bainbridge596f30d2019-07-30 17:07:59 +00002733for O in $ALL_OPTIONS; do
David Bainbridged18f4942020-04-14 16:46:13 -07002734 VAL="$(eval echo "\$$O")"
2735 if [ -n "$VAL" ] && [ "$(grep -c "^export $O=" "$NAME-env.sh")" -eq 0 ]; then
2736 echo "export $O=\"$(eval echo "\$$O")\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002737 fi
2738done
2739
David Bainbridged18f4942020-04-14 16:46:13 -07002740if [ "$DEPLOY_K8S" == "yes" ] && [ "$(grep -c "^export KUBECONFIG=" "$NAME-env.sh")" -eq 0 ]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002741 echo "export KUBECONFIG=\"$HOME/.kube/kind-config-voltha-$NAME\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002742fi
2743
David Bainbridged18f4942020-04-14 16:46:13 -07002744if [ "$(grep -c "^export VOLTCONFIG=" "$NAME-env.sh")" -eq 0 ]; then
2745 echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002746fi
2747
David Bainbridged18f4942020-04-14 16:46:13 -07002748if [ "$(grep -c "^export PATH=" "$NAME-env.sh")" -eq 0 ]; then
2749 echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002750fi
2751
Test User7d866122019-07-09 17:52:35 +00002752echo ""
David Bainbridged18f4942020-04-14 16:46:13 -07002753echo "Please issue the following commands in your terminal to ensure that you" | tee -a "$LOG"
2754echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a "$LOG"
2755echo "tools required by VOLTHA in your command path. " | tee -a "$LOG"
2756echo "" | tee -a "$LOG"
2757echo -en "$BOLD"
2758if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridgeb4bbde12020-06-25 14:46:36 -07002759 echo "export KUBECONFIG=\"$HOME/.kube/kind-config-voltha-$NAME\"" | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00002760fi
David Bainbridged18f4942020-04-14 16:46:13 -07002761echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" | tee -a "$LOG"
2762echo "export PATH=$GOPATH/bin:\$PATH" | tee -a "$LOG"
2763echo -en "$NORMAL"
2764echo "" | tee -a "$LOG"
2765echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a "$LOG"
Test User08ebbd92019-07-03 17:15:39 +00002766
David Bainbridge712afb82019-08-14 19:55:58 +00002767if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002768 NOW="$(date +%s)"
2769 echo -e "$CLOCK ${BOLD}TOTAL: $(duration $((NOW - TOTAL_START_TIME)))${NORMAL}"
David Bainbridge712afb82019-08-14 19:55:58 +00002770fi