blob: e31fdf70d881ede9456b945f54a05000a88b7cda [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 K. Bainbridgeb7285432019-07-02 22:05:24 -070019
David Bainbridge38dc1e82019-08-12 15:18:45 +000020FANCY=${FANCY:-1}
21if [ "$TERM X" == " X" ]; then
22 FANCY=0
23fi
24
David K. Bainbridgeb7285432019-07-02 22:05:24 -070025# trap ctrl-c and call ctrl_c()
26trap ctrl_c INT
27
28function ctrl_c() {
David Bainbridged18f4942020-04-14 16:46:13 -070029 echo -en "$CNORM"
David K. Bainbridgeb7285432019-07-02 22:05:24 -070030 echo ""
31 echo "ctrl-c trapped"
David Bainbridgec6a6eb62019-10-18 22:50:07 +000032 echo "Thank you for trying 'voltha up'"
David K. Bainbridgeb7285432019-07-02 22:05:24 -070033 exit
34}
35
David Bainbridgea34993d2020-04-01 09:15:42 -070036HELM_VERSION=${HELM_VERSION:-v2.14.3}
David K. Bainbridgeebf38d92020-02-10 10:46:31 -080037VOLTCTL_VERSION=${VOLTCTL_VERSION:-latest}
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -080038KIND_VERSION=${KIND_VERSION:-v0.5.1}
David K. Bainbridgeb3a99372020-01-08 14:39:06 -080039VK_RELEASE=${VK_RELEASE:-master}
David Bainbridge60ffc0f2020-04-27 22:13:22 -070040EXTRA_TOOLS=
Test User08ebbd92019-07-03 17:15:39 +000041
David Bainbridge38dc1e82019-08-12 15:18:45 +000042RED=
43GREEN=
44YELLOW=
45BLUE=
David Bainbridge38dc1e82019-08-12 15:18:45 +000046BOLD=
47NORMAL=
48ERROR=
49CEOL=
50CNORM=
51CIVIS=
David Bainbridged18f4942020-04-14 16:46:13 -070052if [ "$FANCY" -eq 1 ]; then
53 RED="$(tput setaf 1)"
54 GREEN="$(tput setaf 2)"
55 YELLOW="$(tput setaf 3)"
56 BLUE="$(tput setaf 4)"
57 BOLD="$(tput bold)"
58 NORMAL="$(tput sgr0)"
David Bainbridge38dc1e82019-08-12 15:18:45 +000059 ERROR="\xe2\x9c\x97\x20"
David Bainbridged18f4942020-04-14 16:46:13 -070060 CEOL="$(tput el)"
61 CNORM="$(tput cnorm)"
62 CIVIS="$(tput civis)"
David Bainbridge38dc1e82019-08-12 15:18:45 +000063fi
Test User7d866122019-07-09 17:52:35 +000064
Test User3d7ad8e2019-07-03 06:15:44 +000065TYPE=${TYPE:-minimal}
David Bainbridge0774b232019-08-02 06:37:19 +000066NAME=${NAME:-$TYPE}
David K. Bainbridge484d80c2020-03-05 21:44:34 -080067
68ENABLE_ONOS_EXTRANEOUS_RULES=${ENABLE_ONOS_EXTRANEOUS_RULES:-no}
David Bainbridge76afd812020-04-06 09:53:52 -070069INFRA_NS=${INFRA_NS:-default}
70VOLTHA_NS=${VOLTHA_NS:-voltha}
71BBSIM_NS=${BBSIM_NS:-voltha}
72ADAPTER_NS=${ADAPTER_NS:-voltha}
David Bainbridgee87067b2019-08-12 22:00:12 +000073WITH_TIMINGS=${WITH_TIMINGS:-no}
Test User7d866122019-07-09 17:52:35 +000074WITH_BBSIM=${WITH_BBSIM:-no}
divyadesai59f987a2020-05-27 12:11:33 +000075WITH_EFK=${WITH_EFK:-no}
David Bainbridge5b7b96b2019-07-25 20:29:13 +000076WITH_RADIUS=${WITH_RADIUS:-no}
Matteo Scandolo78dfee02020-02-13 16:18:03 -080077WITH_EAPOL=${WITH_EAPOL:-yes}
78WITH_DHCP=${WITH_DHCP:-yes}
79WITH_IGMP=${WITH_IGMP:-no}
David Bainbridgeb270c202019-07-26 01:44:42 +000080WITH_ONOS=${WITH_ONOS:-yes}
David Bainbridge60ffc0f2020-04-27 22:13:22 -070081NUM_OF_ONOS=${NUM_OF_ONOS:-1}
82NUM_OF_ATOMIX=${NUM_OF_ATOMIX:-0}
David Bainbridge99ac7a22019-08-31 02:26:43 +000083WITH_CHAOS=${WITH_CHAOS:-no}
David Bainbridge46505fb2019-10-01 21:13:20 +000084WITH_ADAPTERS=${WITH_ADAPTERS:-yes}
David K. Bainbridgeda33d652020-03-06 10:31:23 -080085WITH_SIM_ADAPTERS=${WITH_SIM_ADAPTERS:-no}
David Bainbridge46505fb2019-10-01 21:13:20 +000086WITH_OPEN_ADAPTERS=${WITH_OPEN_ADAPTERS:-yes}
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -080087WITH_PORT_FORWARDS=${WITH_PORT_FORWARDS:-yes}
David Bainbridge696bc632020-04-05 21:49:37 -070088WITH_KAFKA=${WITH_KAFKA:-yes}
89WITH_ETCD=${WITH_ETCD:-yes}
Matteo Scandoloefee0432020-05-05 13:56:20 -070090WITH_PPROF=${WITH_PPROF:-no}
Girish Gowdra4cc5d8b2020-06-11 17:12:00 -070091WITH_INCREMENTAL_EVTO_UPDATE=${WITH_INCREMENTAL_EVTO_UPDATE:-no}
David Bainbridgee4d11ca2020-05-08 10:21:10 -070092SCHEDULE_ON_CONTROL_NODES=${SCHEDULE_ON_CONTROL_NODES:-no}
David Bainbridge309099c2020-05-05 08:47:29 -070093CONFIG_SADIS=${CONFIG_SADIS:-no} # yes | no | file | bbsim | external | URL
Hardik Windlassb3147602020-03-09 16:59:15 +053094SADIS_CFG=${SADIS_CFG:-onos-files/onos-sadis-sample.json}
David Bainbridge27790d62019-08-13 22:43:19 +000095INSTALL_ONOS_APPS=${INSTALL_ONOS_APPS:-no}
Test Userba1e7e72019-07-10 22:27:54 +000096JUST_K8S=${JUST_K8S:-no}
97DEPLOY_K8S=${DEPLOY_K8S:-yes}
David K. Bainbridge0e89cb92019-07-17 11:30:10 -070098INSTALL_KUBECTL=${INSTALL_KUBECTL:-yes}
99INSTALL_HELM=${INSTALL_HELM:-yes}
David Bainbridge7f8bf992020-04-08 21:53:22 -0700100HELM_USE_UPGRADE=${HELM_USE_UPGRADE:-no}
David Bainbridge46505fb2019-10-01 21:13:20 +0000101UPDATE_HELM_REPOS=${UPDATE_HELM_REPOS:-yes}
Matteo Scandolofab98622020-01-28 15:17:20 -0800102WAIT_ON_DOWN=${WAIT_ON_DOWN:-yes}
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700103WAIT_TIMEOUT=${WAIT_TIMEOUT:-30m}
104VOLTHA_DOWN_ON_TIMEOUT=${VOLTHA_DOWN_ON_TIMEOUT:-no}
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000105VOLTHA_LOG_LEVEL=${VOLTHA_LOG_LEVEL:-WARN}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000106VOLTHA_CHART=${VOLTHA_CHART:-onf/voltha}
107VOLTHA_CHART_VERSION=${VOLTHA_CHART_VERSION:-latest}
108VOLTHA_BBSIM_CHART=${VOLTHA_BBSIM_CHART:-onf/bbsim}
Matteo Scandolodcd29f52019-10-07 15:42:42 -0700109VOLTHA_BBSIM_CHART_VERSION=${VOLTHA_BBSIM_CHART_VERSION:-latest}
divyadesai59f987a2020-05-27 12:11:33 +0000110ELASTICSEARCH_CHART=${ELASTICSEARCH_CHART:-elastic/elasticsearch}
111ELASTICSEARCH_CHART_VERSION=${ELASTICSEARCH_CHART_VERSION:-latest}
112KIBANA_CHART=${KIBANA_CHART:-elastic/kibana}
113KIBANA_CHART_VERSION=${KIBANA_CHART_VERSION:-latest}
114FLUENTD_ELASTICSEARCH_CHART=${FLUENTD_ELASTICSEARCH_CHART:-kiwigrid/fluentd-elasticsearch}
115FLUENTD_ELASTICSEARCH_CHART_VERSION=${FLUENTD_ELASTICSEARCH_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000116VOLTHA_ADAPTER_SIM_CHART=${VOLTHA_ADAPTER_SIM_CHART:-onf/voltha-adapter-simulated}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000117VOLTHA_ADAPTER_SIM_CHART_VERSION=${VOLTHA_ADAPTER_SIM_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000118VOLTHA_ADAPTER_OPEN_OLT_CHART=${VOLTHA_ADAPTER_OPEN_OLT_CHART:-onf/voltha-adapter-openolt}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000119VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION=${VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000120VOLTHA_ADAPTER_OPEN_ONU_CHART=${VOLTHA_ADAPTER_OPEN_ONU_CHART:-onf/voltha-adapter-openonu}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000121VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION=${VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION:-latest}
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800122ONOS_CHART=${ONOS_CHART:-onf/onos}
Andrea Campanella21323292019-12-18 11:44:19 -0800123ONOS_CHART_VERSION=${ONOS_CHART_VERSION:-latest}
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700124ONOS_CLASSIC_CHART=${ONOS_CLASSIC_CHART:-onos/onos-classic}
Andrea Campanella655499f2020-07-16 09:57:35 +0200125ONOS_CLASSIC_CHART_VERSION=${ONOS_CLASSIC_CHART_VERSION:-0.1.1}
David Bainbridgecf546362020-04-21 23:18:50 -0700126KAFKA_CHART=${KAFKA_CHART:-incubator/kafka}
David Bainbridgeb9093522020-04-15 14:32:44 -0700127KAFKA_CHART_VERSION=${KAFKA_CHART_VERSION:=0.15.3}
David Bainbridge309099c2020-05-05 08:47:29 -0700128BBSIM_SADIS_SERVER_CHART=${BBSIM_SADIS_SERVER_CHART:-bbsim-sadis/bbsim-sadis-server}
129BBSIM_SADIS_SERVER_CHART_VERSION=${BBSIM_SADIS_SERVER_CHART_VERSION:-latest}
David Bainbridgec7220622020-05-28 12:31:47 -0700130ETCD_CHART=${ETCD_CHART:-incubator/etcd}
131ETCD_CHART_VERSION=${ETCD_CHART_VERSION:-latest}
David Bainbridge879439b2020-06-12 15:59:35 -0700132RADIUS_CHART=${RADIUS_CHART:-onf/freeradius}
133RADIUS_CHART_VERSION=${RADIUS_CHART_VERSION:-latest}
David Bainbridge2eaf2cf2020-03-18 12:54:08 -0700134EXTRA_HELM_INSTALL_ARGS=${EXTRA_HELM_INSTALL_ARGS:-}
135INTERNAL_EXTRA_HELM_INSTALL_ARGS=
uottrembb16d3982020-02-28 08:34:36 +0100136NUM_OF_BBSIM=${NUM_OF_BBSIM:-1}
Matteo Scandolo67335f02020-04-09 11:19:53 -0700137NUM_OF_OPENONU=${NUM_OF_OPENONU:-1}
uottrembb16d3982020-02-28 08:34:36 +0100138MAX_NUM_OF_BBSIM=10
Matteo Scandolo67335f02020-04-09 11:19:53 -0700139MAX_NUM_OF_OPENONU=10
Matteo Scandoloc2eb0672020-05-01 14:43:15 -0700140LEGACY_BBSIM_INDEX=${LEGACY_BBSIM_INDEX:-no}
Test Userba1e7e72019-07-10 22:27:54 +0000141
David Bainbridged18f4942020-04-14 16:46:13 -0700142HOSTOS="$(uname -s | tr "[:upper:]" "[:lower:"])"
143HOSTARCH="$(uname -m | tr "[:upper:]" "[:lower:"])"
144if [ "$HOSTARCH" == "x86_64" ]; then
Test Userba1e7e72019-07-10 22:27:54 +0000145 HOSTARCH="amd64"
146fi
David Bainbridge7db44002020-04-09 12:54:29 -0700147BBSIM_LABEL="-l app=bbsim"
David Bainbridged18f4942020-04-14 16:46:13 -0700148NO_LABEL=
Test User7d866122019-07-09 17:52:35 +0000149
uottrembb16d3982020-02-28 08:34:36 +0100150# check number (range) of bbsim, max bbsim must not exceed 10 instances!
151# note: instances will be numbered from 0 to 9
152if [ "$1" == "up" ]; then
David K. Bainbridge43422402020-03-06 07:41:22 -0800153 if [ "$NUM_OF_BBSIM" -lt 1 ]; then
Matteo Scandolo67335f02020-04-09 11:19:53 -0700154 >&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}"
David K. Bainbridge43422402020-03-06 07:41:22 -0800155 exit 1
156 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700157 if [ "$NUM_OF_BBSIM" -gt "$MAX_NUM_OF_BBSIM" ]; then
Matteo Scandolo67335f02020-04-09 11:19:53 -0700158 >&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}"
159 exit 1
160 fi
161
162 if [ "$NUM_OF_OPENONU" -lt 1 ]; then
163 >&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}"
164 exit 1
165 fi
166 if [ "$NUM_OF_OPENONU" -gt "$MAX_NUM_OF_OPENONU" ]; then
167 >&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}"
David K. Bainbridge43422402020-03-06 07:41:22 -0800168 exit 1
169 fi
uottrembb16d3982020-02-28 08:34:36 +0100170fi
Test User7d866122019-07-09 17:52:35 +0000171# Verify TYPE setting
David Bainbridged18f4942020-04-14 16:46:13 -0700172if [ "$(echo ":minimal:full:" | grep -ic ":$TYPE:")" -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700173 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$TYPE value of '$TYPE'. Should be 'minimal' or 'full'${NORMAL}"
Test User7d866122019-07-09 17:52:35 +0000174 exit 1
175fi
176
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700177# checks to see if a given WORD is in the given LIST of words
178function is_in() {
179 local WORD LIST
180 WORD="$1"; shift
181 LIST="$*"
182 LIST=${LIST//+([[:space:],|])/:}
183
184 [ "$(echo ":$LIST:" | grep -ic ":$WORD:")" -ne 0 ]
185}
186
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700187function parseDuration() {
David Bainbridged18f4942020-04-14 16:46:13 -0700188 local DUR RESULT TERM TERMS VALUE UNIT
189 DUR=$1
190 RESULT=0
191 TERMS="$(echo "$DUR" | sed -Ee 's/([sSmMhHdD])/\1 /g' -e 's/,$//g')"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700192 for TERM in $TERMS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700193 VALUE="$(echo "$TERM" | sed -Ee 's/([0-9]+)[sSmMhHdD]/\1/')"
194 UNIT="$(echo "$TERM" | sed -Ee 's/[0-9]+([sSmMhHdD])/\1/')"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700195 case $UNIT in
196 s|S)
David Bainbridged18f4942020-04-14 16:46:13 -0700197 RESULT=$((RESULT + VALUE)) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700198 m|M)
David Bainbridged18f4942020-04-14 16:46:13 -0700199 RESULT=$((RESULT + (VALUE * 60))) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700200 h|H)
David Bainbridged18f4942020-04-14 16:46:13 -0700201 RESULT=$((RESULT + (VALUE * 3600))) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700202 d|D)
David Bainbridged18f4942020-04-14 16:46:13 -0700203 RESULT=$((RESULT + (VALUE * 86400))) ;;
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700204 *) ;;
205 esac
206 done
207 echo $RESULT
208}
209
210function doTimeout() {
211 local MSG=$1
212 2>&1 echo -e "\n${RED}${BOLD}${ERROR}TIMEOUT:${NORMAL}${RED} Operation timed out after '$WAIT_TIMEOUT': $MSG"
213 exit 125
214}
215
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800216function get_service_ep() {
217 local NS=$1
218 local NAME=$2
David Bainbridged18f4942020-04-14 16:46:13 -0700219 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 -0800220}
221
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000222# Used to verify configuration values are set to "yes" or "no" value or convert
223# equivalents to "yes" or "no"
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700224YES="y,yes,t,true,1"
225NO="n,no,f,false,0"
226YES_OR_NO="$YES,$NO"
227
228# If the given VAR matches a truth value then normalize that
229# value, else return original value
230function normalize_yes_no() {
231 local VAR VAL
232 VAR=$1
233 VAL="$(eval echo "\$$VAR")"
234 if ! is_in "$VAL" "$YES_OR_NO"; then
235 echo "$VAL"
236 return 1
237 fi
238 if is_in "$VAL" "$YES"; then
239 echo "yes"
240 else
241 echo "no"
242 fi
243 return 0
244}
245
246# If the given VAR matches a truth value then normalize that
247# value, else display an error
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000248function verify_yes_no() {
David Bainbridged18f4942020-04-14 16:46:13 -0700249 local VAR VAL
250 VAR=$1
251 VAL="$(eval echo "\$$VAR")"
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700252 if ! is_in "$VAL" "$YES_OR_NO"; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000253 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid '$VAR' value of '$VAL'. Should be 'yes' or 'no'${NORMAL}"
254 echo "INVALID"
255 return 1
256 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700257 if is_in "$VAL" "$YES"; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000258 echo "yes"
259 else
260 echo "no"
261 fi
262 return 0
263}
Test User7d866122019-07-09 17:52:35 +0000264
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000265ALL_YES_NO="\
David K. Bainbridge484d80c2020-03-05 21:44:34 -0800266 ENABLE_ONOS_EXTRANEOUS_RULES \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000267 WITH_TIMINGS \
268 WITH_BBSIM \
divyadesai59f987a2020-05-27 12:11:33 +0000269 WITH_EFK \
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800270 WITH_EAPOL \
271 WITH_DHCP \
272 WITH_IGMP \
David Bainbridge99ac7a22019-08-31 02:26:43 +0000273 WITH_CHAOS \
David Bainbridge46505fb2019-10-01 21:13:20 +0000274 WITH_ADAPTERS \
275 WITH_SIM_ADAPTERS \
276 WITH_OPEN_ADAPTERS \
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800277 WITH_PORT_FORWARDS \
Matteo Scandoloefee0432020-05-05 13:56:20 -0700278 WITH_PPROF \
Girish Gowdra4cc5d8b2020-06-11 17:12:00 -0700279 WITH_INCREMENTAL_EVTO_UPDATE \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000280 JUST_K8S \
281 DEPLOY_K8S \
282 INSTALL_ONOS_APPS \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000283 INSTALL_KUBECTL \
284 INSTALL_HELM \
David Bainbridge7f8bf992020-04-08 21:53:22 -0700285 HELM_USE_UPGRADE \
David Bainbridge46505fb2019-10-01 21:13:20 +0000286 UPDATE_HELM_REPOS \
David Bainbridge4f1b5562019-08-19 04:46:52 +0000287 WAIT_ON_DOWN \
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700288 VOLTHA_DOWN_ON_TIMEOUT \
Matteo Scandoloc2eb0672020-05-01 14:43:15 -0700289 LEGACY_BBSIM_INDEX \
David Bainbridgee4d11ca2020-05-08 10:21:10 -0700290 SCHEDULE_ON_CONTROL_NODES \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000291 "
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000292
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700293OPT_YES_NO="\
294 CONFIG_SADIS \
295 WITH_KAFKA \
296 WITH_RADIUS \
297 WITH_ETCD \
298 WITH_ONOS \
299 "
300
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000301ALL_OPTIONS="\
302 NAME \
303 TYPE \
304 $ALL_YES_NO \
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700305 $OPT_YES_NO \
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700306 WAIT_TIMEOUT \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000307 VOLTHA_LOG_LEVEL \
308 VOLTHA_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000309 VOLTHA_CHART_VERSION \
310 VOLTHA_BBSIM_CHART \
311 VOLTHA_BBSIM_CHART_VERSION \
David Bainbridge879439b2020-06-12 15:59:35 -0700312 BBSIM_SADIS_SERVER_CHART \
313 BBSIM_SADIS_SERVER_CHART_VERSION \
uottrembd5a20572020-03-06 09:15:01 +0100314 NUM_OF_BBSIM \
divyadesai59f987a2020-05-27 12:11:33 +0000315 ELASTICSEARCH_CHART \
316 ELASTICSEARCH_CHART_VERSION \
317 KIBANA_CHART \
318 KIBANA_CHART_VERSION \
319 FLUENTD_ELASTICSEARCH_CHART \
320 FLUENTD_ELASTICSEARCH_CHART_VERSION \
Matteo Scandolo67335f02020-04-09 11:19:53 -0700321 NUM_OF_OPENONU \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000322 VOLTHA_ADAPTER_SIM_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000323 VOLTHA_ADAPTER_SIM_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000324 VOLTHA_ADAPTER_OPEN_OLT_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000325 VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000326 VOLTHA_ADAPTER_OPEN_ONU_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000327 VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION \
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800328 ONOS_CHART \
Andrea Campanella21323292019-12-18 11:44:19 -0800329 ONOS_CHART_VERSION \
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700330 ONOS_CLASSIC_CHART \
331 ONOS_CLASSIC_CHART_VERSION \
David Bainbridgecf546362020-04-21 23:18:50 -0700332 KAFKA_CHART \
David Bainbridgeb9093522020-04-15 14:32:44 -0700333 KAFKA_CHART_VERSION \
David Bainbridge879439b2020-06-12 15:59:35 -0700334 ETCD_CHART \
335 ETCD_CHART_VERSION \
336 RADIUS_CHART \
337 RADIUS_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000338 ONOS_API_PORT \
339 ONOS_SSH_PORT \
Hardik Windlassb3147602020-03-09 16:59:15 +0530340 SADIS_CFG \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000341 VOLTHA_API_PORT \
342 VOLTHA_SSH_PORT \
343 VOLTHA_ETCD_PORT \
divyadesai59f987a2020-05-27 12:11:33 +0000344 ELASTICSEARCH_PORT \
345 KIBANA_PORT \
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800346 VOLTHA_KAFKA_PORT \
Matteo Scandoloefee0432020-05-05 13:56:20 -0700347 VOLTHA_PPROF_PORT \
348 OPENOLT_PPROF_PORT \
Matteo Scandolo65c35192020-05-13 10:41:21 -0700349 OFAGENT_PPROF_PORT \
David K. Bainbridge8f7f30b2020-01-08 13:06:16 -0800350 VK_RELEASE \
351 KIND_VERSION \
352 VOLTCTL_VERSION \
David Bainbridgea34993d2020-04-01 09:15:42 -0700353 HELM_VERSION \
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700354 NUM_OF_ONOS \
355 NUM_OF_ATOMIX \
David Bainbridge6ca40102020-04-08 11:30:40 -0700356 VOLTHA_NS \
357 ADAPTER_NS \
358 INFRA_NS \
359 BBSIM_NS \
David Bainbridge7db44002020-04-09 12:54:29 -0700360 SADIS_BANDWIDTH_PROFILES \
361 SADIS_SUBSCRIBERS \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000362 "
David Bainbridge01294952019-07-30 19:33:45 +0000363
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000364# Iterate over yes/no configuration options and validate
365for VAR in $ALL_YES_NO; do
David Bainbridged18f4942020-04-14 16:46:13 -0700366 eval "$VAR"="$(verify_yes_no "$VAR")"
367 if [ "$(eval echo "\$$VAR")" == "INVALID" ]; then
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000368 exit 1;
369 fi
370done
David Bainbridgeb270c202019-07-26 01:44:42 +0000371
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700372# Iterate over optional yes/no configuration options and
373# normalize values if they are truth values
374for VAR in $OPT_YES_NO; do
375 eval "$VAR"="$(normalize_yes_no "$VAR")"
376done
David Bainbridge15f6f232020-03-30 09:15:43 -0700377
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700378# normalize non-truth value options
379if is_in "$WITH_KAFKA" "e,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -0700380 WITH_KAFKA="external"
381fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700382if is_in "$WITH_ETCD" "e,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -0700383 WITH_ETCD="external"
384fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700385if is_in "$WITH_ONOS" "l,legacy"; then
386 WITH_ONOS="legacy"
387elif is_in "$WITH_ONOS" "c,classic"; then
388 WITH_ONOS="classic"
389elif is_in "$WITH_ONOS" "u,m,micro"; then
390 WITH_ONOS="micro"
David Bainbridge29c31cb2020-04-06 09:45:50 -0700391fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700392
393if [ "$WITH_ONOS" == "micro" ]; then
394 >&2 echo -e "${YELLOW}${BOLD}${ERROR}WARNING:${NORMAL}${YELLOW} The value specified as WITH_ONOS, '$WITH_ONOS', is not valid.${NORMAL}"
395 exit 1
David Bainbridge29c31cb2020-04-06 09:45:50 -0700396fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700397
398if is_in "$WITH_ONOS" "yes,classic"; then
399 # there is an extra utility required if we are using ONOS CLASSIC as
400 # the chart for classic specifies images differently
401 EXTRA_TOOLS+=" yq"
David Bainbridge76afd812020-04-06 09:53:52 -0700402fi
David Bainbridge696bc632020-04-05 21:49:37 -0700403
David Bainbridge22db5dd2020-05-26 12:21:21 -0700404if [ "$LEGACY_BBSIM_INDEX" == "no" ]; then
405 BBSIM_SADIS_SVC="bbsim0"
406else
407 BBSIM_SADIS_SVC="bbsim"
408fi
409
410SADIS_SUBSCRIBERS=${SADIS_SUBSCRIBERS:-http://$BBSIM_SADIS_SVC.$VOLTHA_NS.svc:50074/v2/subscribers/%s}
411SADIS_BANDWIDTH_PROFILES=${SADIS_BANDWIDTH_PROFILES:-http://$BBSIM_SADIS_SVC.$VOLTHA_NS.svc:50074/v2/bandwidthprofiles/%s}
412
David Bainbridged18f4942020-04-14 16:46:13 -0700413if [ "$HELM_USE_UPGRADE" == "yes" ]; then
David Bainbridge7f8bf992020-04-08 21:53:22 -0700414 _HELM_DESC="Upgrade/Install"
415else
416 _HELM_DESC="Install"
417fi
418
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800419# Check for prerequiste tools
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700420TOOLS="curl sed jq $EXTRA_TOOLS"
David Bainbridged18f4942020-04-14 16:46:13 -0700421if [ "$DEPLOY_K8S" == "yes" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800422 TOOLS+=" docker"
423fi
424NOT_FOUND=""
425for T in $TOOLS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700426 if [ -z "$(command -v "$T")" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800427 NOT_FOUND+=" $T"
428 fi
429done
430
David Bainbridged18f4942020-04-14 16:46:13 -0700431if [ -n "$NOT_FOUND" ]; then
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800432 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} The following required tools where not found, please install them:$NOT_FOUND"
433 exit 1
434fi
435
David Bainbridged18f4942020-04-14 16:46:13 -0700436TIMEOUT_SECONDS="$(parseDuration "$WAIT_TIMEOUT")"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700437
David Bainbridge0774b232019-08-02 06:37:19 +0000438mkdir -p .voltha
439touch .voltha/ports
David Bainbridged18f4942020-04-14 16:46:13 -0700440HAVE="$(grep "$NAME" .voltha/ports)"
David Bainbridge0774b232019-08-02 06:37:19 +0000441if [ "$HAVE X" == " X" ]; then
442 # Find free port prefix
443 START=81
444 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700445 if [ "$(grep -c $START .voltha/ports)" -eq 0 ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000446 break
447 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700448 START="$((START + 1))"
David Bainbridge0774b232019-08-02 06:37:19 +0000449 done
David Bainbridged18f4942020-04-14 16:46:13 -0700450 DELTA="$((START - 81))"
David Bainbridgea2595422019-10-22 03:54:28 +0000451 ONOS_API_PORT=${ONOS_API_PORT:-${START}81}
452 ONOS_SSH_PORT=${ONOS_SSH_PORT:-${START}01}
David Bainbridged18f4942020-04-14 16:46:13 -0700453 VOLTHA_API_PORT=${VOLTHA_API_PORT:-5$((55 + DELTA))55}
454 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$((50 + DELTA))22}
455 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$((23 + DELTA))79}
456 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$((90 + DELTA))92}
Matteo Scandoloefee0432020-05-05 13:56:20 -0700457 VOLTHA_PPROF_PORT=${VOLTHA_PPROF_PORT:-$((60 + DELTA))60}
458 OPENOLT_PPROF_PORT=${OPENOLT_PPROF_PORT:-$((60 + DELTA))61}
Matteo Scandolo65c35192020-05-13 10:41:21 -0700459 OFAGENT_PPROF_PORT=${OFAGENT_PPROF_PORT:-$((60 + DELTA))62}
divyadesai59f987a2020-05-27 12:11:33 +0000460 ELASTICSEARCH_PORT=${ELASTICSEARCH_PORT:-$((92 + DELTA))00}
461 KIBANA_PORT=${KIBANA_PORT:-$((56 + DELTA))01}
Test User01ed0642019-07-03 20:17:06 +0000462else
David Bainbridged18f4942020-04-14 16:46:13 -0700463 VALUES="$(echo "$HAVE" | sed -e 's/\s//g' | cut -d= -f2)"
464 ONOS_API_PORT=${ONOS_API_PORT:-$(echo "$VALUES" | cut -d, -f1)}
465 ONOS_SSH_PORT=${ONOS_SSH_PORT:-$(echo "$VALUES" | cut -d, -f2)}
466 VOLTHA_API_PORT=${VOLTHA_API_PORT:-$(echo "$VALUES" | cut -d, -f3)}
467 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$(echo "$VALUES" | cut -d, -f4)}
468 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$(echo "$VALUES" | cut -d, -f5)}
469 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(echo "$VALUES" | cut -d, -f6)}
Matteo Scandoloefee0432020-05-05 13:56:20 -0700470 VOLTHA_PPROF_PORT=${VOLTHA_PPROF_PORT:-$(echo "$VALUES" | cut -d, -f7)}
471 OPENOLT_PPROF_PORT=${OPENOLT_PPROF_PORT:-$(echo "$VALUES" | cut -d, -f8)}
Matteo Scandolo65c35192020-05-13 10:41:21 -0700472 OFAGENT_PPROF_PORT=${OFAGENT_PPROF_PORT:-$(echo "$VALUES" | cut -d, -f9)}
divyadesai59f987a2020-05-27 12:11:33 +0000473 ELASTICSEARCH_PORT=${ELASTICSEARCH_PORT:-$(echo "$VALUES" | cut -d, -f10)}
474 KIBANA_PORT=${KIBANA_PORT:-$(echo "$VALUES" | cut -d, -f11)}
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800475
Matteo Scandoloefee0432020-05-05 13:56:20 -0700476 # Some ports were added after the .voltha/ports files was created.
477 # Calculate the original DELTA from the VOLTHA_SSH_PORT so that it can
478 # be used to set up newer port-forwards.
479 DELTA="$((VOLTHA_SSH_PORT/100-50))"
480
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800481 if [ -z "$VOLTHA_KAFKA_PORT" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -0700482 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$((90 + DELTA))92}
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800483 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -0700484
485 if [ -z "$VOLTHA_PPROF_PORT" ]; then
divyadesai59f987a2020-05-27 12:11:33 +0000486 VOLTHA_PPROF_PORT=${VOLTHA_PPROF_PORT:-$((60 + DELTA))60}
Matteo Scandoloefee0432020-05-05 13:56:20 -0700487 fi
488 if [ -z "$OPENOLT_PPROF_PORT" ]; then
divyadesai59f987a2020-05-27 12:11:33 +0000489 OPENOLT_PPROF_PORT=${OPENOLT_PPROF_PORT:-$((60 + DELTA))61}
Matteo Scandoloefee0432020-05-05 13:56:20 -0700490 fi
Matteo Scandolo65c35192020-05-13 10:41:21 -0700491 if [ -z "$OFAGENT_PPROF_PORT" ]; then
divyadesai59f987a2020-05-27 12:11:33 +0000492 OFAGENT_PPROF_PORT=${OFAGENT_PPROF_PORT:-$((60 + DELTA))62}
493 fi
494
495 if [ -z "$ELASTICSEARCH_PORT" ]; then
496 ELASTICSEARCH_PORT=${ELASTICSEARCH_PORT:-$((92 + DELTA))00}
497 fi
498
499 if [ -z "$KIBANA_PORT" ]; then
500 KIBANA_PORT=${KIBANA_PORT:-$((56 + DELTA))01}
Matteo Scandolo65c35192020-05-13 10:41:21 -0700501 fi
Test User01ed0642019-07-03 20:17:06 +0000502fi
503
David Bainbridged18f4942020-04-14 16:46:13 -0700504PORTTMP="$(mktemp -u)"
505grep -v "$NAME" .voltha/ports > "$PORTTMP"
divyadesai59f987a2020-05-27 12:11:33 +0000506echo "$NAME=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT,$VOLTHA_KAFKA_PORT,$VOLTHA_PPROF_PORT,$OPENOLT_PPROF_PORT,$OFAGENT_PPROF_PORT,$ELASTICSEARCH_PORT,$KIBANA_PORT" >> "$PORTTMP"
David Bainbridged18f4942020-04-14 16:46:13 -0700507cp "$PORTTMP" .voltha/ports
508rm -f "$PORTTMP"
David Bainbridge0774b232019-08-02 06:37:19 +0000509
David Bainbridge27790d62019-08-13 22:43:19 +0000510export ONOS_API_PORT ONOS_SSH_PORT
David Bainbridge01294952019-07-30 19:33:45 +0000511
Test Userd87942b2019-07-03 07:20:24 +0000512IDX=1
David Bainbridgee87067b2019-08-12 22:00:12 +0000513CLOCK="TIME:"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000514SPIN_PARTS=
515NOT_VERIFIED=
David Bainbridgef858a022019-08-14 21:25:11 +0000516THEX=
517BUILD=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000518VERIFIED=
519HELM=
520OLD_KEY=
521BIRD=
522HIGH_VOLTAGE=
523PLUG=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000524FORWARD=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000525GO=
526DOWNLOAD=
527GEAR=
528NO_ENTRY=
529LOCK=
530
David Bainbridged18f4942020-04-14 16:46:13 -0700531if [ "$FANCY" -eq 1 ]; then
532 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 +0000533 CLOCK="\xe2\x8f\xb1"
David Bainbridgef858a022019-08-14 21:25:11 +0000534 THEX="${RED}${BOLD}\xe2\x9c\x97\x20${NORMAL}"
David Bainbridgef858a022019-08-14 21:25:11 +0000535 BUILD="${YELLOW}${BOLD}\xf0\x9f\x8f\x97${NORMAL}"
536 NOT_VERIFIED="$BUILD"
537 VERIFIED="${GREEN}${BOLD}\xe2\x9c\x93\x20${NORMAL}"
538 HELM="${BLUE}${BOLD}\xE2\x8E\x88${NORMAL}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000539 OLD_KEY="\xF0\x9F\x97\x9D"
540 BIRD="\xF0\x9F\x90\xA6"
541 HIGH_VOLTAGE="\xE2\x9A\xA1"
542 PLUG="\xF0\x9F\xa7\xa9"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000543 FORWARD="\xE2\x87\xA8"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000544 GO="\xf0\x9f\x9a\x80"
545 DOWNLOAD="\xf0\x9f\x93\xa5"
546 GEAR="\xe2\x9a\x99"
547 NO_ENTRY="\xe2\x9b\x94"
548 LOCK="\xf0\x9f\x94\x92"
549fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700550
David Bainbridge712afb82019-08-14 19:55:58 +0000551duration() {
David Bainbridged18f4942020-04-14 16:46:13 -0700552 local h m s t
553 h="$(($1 / 3600))"
554 m="$(($1 % 3600 / 60))"
555 s="$(($1 % 60))"
556 t=""
David Bainbridgee87067b2019-08-12 22:00:12 +0000557
David Bainbridged18f4942020-04-14 16:46:13 -0700558 if [ "$h" -gt 0 ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +0000559 t="$t${h}h"
560 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700561 if [ "$m" -gt 0 ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +0000562 t="$t${m}m"
563 fi
David Bainbridge712afb82019-08-14 19:55:58 +0000564 echo "$t${s}s"
565}
566
567printtime() {
David Bainbridged18f4942020-04-14 16:46:13 -0700568 local INDENT
David Bainbridge712afb82019-08-14 19:55:58 +0000569 if [ "$1" == "-" ]; then
570 INDENT=" "
571 shift
572 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700573 echo -e "$INDENT $CLOCK $(duration "$1")"
David Bainbridgee87067b2019-08-12 22:00:12 +0000574}
575
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700576bspin() {
Test Userd87942b2019-07-03 07:20:24 +0000577 IDX=1
David Bainbridged18f4942020-04-14 16:46:13 -0700578 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700579 if [ "$1" == "-" ]; then
580 INDENT=" "
581 shift
582 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700583 if [ "$FANCY" -eq 0 ]; then
584 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000585 if [ "$LINE X" == " X" ]; then
586 return
587 fi
588 echo -e "$CIVIS$INDENT$*"
589 else
590 echo -en "$CIVIS$INDENT $*"
591 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700592}
593
594sspin() {
David Bainbridged18f4942020-04-14 16:46:13 -0700595 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700596 if [ "$1" == "-" ]; then
597 INDENT=" "
598 shift
599 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700600 if [ "$FANCY" -eq 0 ]; then
601 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000602 if [ "$LINE X" == " X" ]; then
603 return
604 fi
605 echo -e "$INDENT$*"
606 else
David Bainbridged18f4942020-04-14 16:46:13 -0700607 C="$(echo "$SPIN_PARTS" | cut '-d ' -f "$IDX")"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000608 echo -en "\r$INDENT$C $*"
David Bainbridged18f4942020-04-14 16:46:13 -0700609 IDX="$((IDX + 1))"
610 if [ "$IDX" -gt 8 ]; then
David Bainbridge38dc1e82019-08-12 15:18:45 +0000611 IDX=1
612 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700613 fi
614}
615
616espin() {
David Bainbridged18f4942020-04-14 16:46:13 -0700617 local INDENT
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700618 if [ "$1" == "-" ]; then
619 INDENT=" "
620 shift
621 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700622 if [ "$FANCY" -eq 0 ]; then
623 LINE="${*//[[:space:]+-]}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000624 if [ "$LINE X" == " X" ]; then
625 return
626 fi
627 echo -e "$INDENT$*"
628 else
629 echo -e "\r$INDENT$*$CNORM"
630 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700631}
632
David Bainbridged18f4942020-04-14 16:46:13 -0700633if [ "$1" == "get" ] && [ "$2" == "voltconfig" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000634 echo "$HOME/.volt/config-$NAME"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000635 exit
636fi
637
David Bainbridgee4d11ca2020-05-08 10:21:10 -0700638if [ $# -ne 1 ] || ! is_in "$1" "up,down,dump,clean"; then
David Bainbridgeac7f8072019-08-01 22:15:33 +0000639 >&2 echo "What wouild you like to do today:"
640 >&2 echo " up - bring up voltha"
641 >&2 echo " down - tear down voltha"
642 >&2 echo " dump - create a debug dump of running system"
643 exit 1
644fi
645
divyadesai59f987a2020-05-27 12:11:33 +0000646do_curl() {
647 local DATA_ARGS CREDS CMD_ECHO CMD_OUTPUT SC_OUTPUT WAIT_START INDENTA EXTRAA NOW
648 local INDENT=$1
649 local OP=$2
650 local USER=$3
651 local PASS=$4
652 local URL=$5
653 local DATA_TYPE=$6
654 local DATA=$7
655 local MSG=$8
656 local VALID_RESULTS=$9
657 local EXTRA=${10}
658 local ICON=${11}
659
660 # Turn into an array for passing
661 INDENTA=()
662 if [ -n "$INDENT" ]; then
663 INDENTA=("$INDENT")
664 fi
665 IFS=' ' read -r -a EXTRAA <<< "$EXTRA"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000666
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800667 # Thanks to the latest version of ONOS using the return code 207 this gets a
668 # whole lot nastier. Can't thank them enough for doing this. So in order to
669 # capture the command and the output in the log file as well as capture the
670 # status code to verify it is 200 and not 207 mutltiple files and a bit of
671 # hackery must be used. Thanks again ONOS.
David Bainbridged18f4942020-04-14 16:46:13 -0700672 CMD_ECHO="$(mktemp -u)"
673 CMD_OUTPUT="$(mktemp -u)"
674 SC_OUTPUT="$(mktemp -u)"
675 WAIT_START="$(date +%s)"
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800676
divyadesai59f987a2020-05-27 12:11:33 +0000677 CREDS=()
678 if [ -n "$USER" ]; then
679 CREDS=("--user" "$USER:$PASS")
680 fi
681
682 DATA_ARGS=()
683 if [ -n "$DATA" ]; then
684 if [ "$DATA_TYPE" == "file" ]; then
685 DATA_ARGS=("--data" "@$DATA")
686 elif [ "$DATA_TYPE" == "json" ]; then
687 DATA_ARGS=("--data" "$DATA")
688 fi
689 fi
690
691 bspin "${INDENTA[@]}" "$MSG" "$ICON"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000692 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700693 NOW="$(date +%s)"
694 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
divyadesai59f987a2020-05-27 12:11:33 +0000695 espin "${INDENTA[@]}" "$THEX"
David Bainbridged18f4942020-04-14 16:46:13 -0700696 rm -f "$CMD_ECHO" "$CMD_OUTPUT" "$SC_OUTPUT"
divyadesai59f987a2020-05-27 12:11:33 +0000697 doTimeout "$MSG"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700698 fi
divyadesai59f987a2020-05-27 12:11:33 +0000699 (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
700 RESULT=$?
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800701 # Dump everything to the log
David Bainbridged18f4942020-04-14 16:46:13 -0700702 cat "$CMD_ECHO" >> "$LOG"
703 test -r "$CMD_OUTPUT" && cat "$CMD_OUTPUT" >> "$LOG"
704 SC="$(cat "$SC_OUTPUT")"
705 echo "RESPONSE CODE: $SC" >> "$LOG"
706 echo "ERROR CODE: $RESULT" >> "$LOG"
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800707
708 # clean up temp files
David Bainbridged18f4942020-04-14 16:46:13 -0700709 rm -f "$CMD_ECHO" "$CMD_OUTPUT" "$SC_OUTPUT"
divyadesai59f987a2020-05-27 12:11:33 +0000710 if [ "$RESULT" -eq 0 ] && is_in "$SC" "$VALID_RESULTS"; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000711 break
712 fi
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800713 sleep 1
divyadesai59f987a2020-05-27 12:11:33 +0000714 sspin "${INDENTA[@]}"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000715 done
divyadesai59f987a2020-05-27 12:11:33 +0000716 espin "${INDENTA[@]}" "$VERIFIED"
717}
718
719push_onos_config() {
720 local DATA_TYPE=$1
721 local MSG=$2
722 local RESOURCE=$3
723 local DATA=$4
724
725 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 +0000726}
727
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800728check_onos_app_active() {
David Bainbridged18f4942020-04-14 16:46:13 -0700729 local APP_ID WAIT_START RESULT NOW
730 APP_ID=$1
731 WAIT_START="$(date +%s)"
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800732
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700733 bspin - "Checking that $APP_ID is active $CLOCK"
734 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700735 NOW="$(date +%s)"
736 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700737 espin - "$THEX"
738 doTimeout "waiting for ONOS application activation '$APP_ID'"
739 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700740 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 -0700741 break
742 fi
743 sleep 1
744 sspin -
745 done
746 sleep 5 # OSGI components take a little longer that the app to activate
David Bainbridged18f4942020-04-14 16:46:13 -0700747 espin - "$VERIFIED"
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800748}
749
David Bainbridge4f1b5562019-08-19 04:46:52 +0000750override_onos_app() {
David Bainbridged18f4942020-04-14 16:46:13 -0700751 local APP NAME WAIT_START NOW
752 APP=$1
753 NAME="$(basename "$APP" | sed -e 's/^[0-9][0-9]*-//g' -e 's/-.*$//g')"
754 WAIT_START="$(date +%s)"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700755
David Bainbridge4f1b5562019-08-19 04:46:52 +0000756 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700757 NOW="$(date +%s)"
758 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700759 espin - "$THEX"
760 doTimeout "waiting to overwrite ONOS application '$APP'"
761 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +0000762 sspin -
763 # Attempt to delete old version (if it exists)
David Bainbridged18f4942020-04-14 16:46:13 -0700764 (set -x; curl --fail -sSL --user karaf:karaf -X DELETE "http://$_ONOS_API_EP/onos/v1/applications/$NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
765 RESULT=$?
David Bainbridge4f1b5562019-08-19 04:46:52 +0000766 sspin -
David Bainbridged18f4942020-04-14 16:46:13 -0700767 if [ $RESULT -ne 0 ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000768 continue
769 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700770 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 +0000771 break
772 fi
773 sleep .2
774 done
775}
776
777activate_onos_app() {
David Bainbridged18f4942020-04-14 16:46:13 -0700778 local MSG APP WAIT_START NOW
779 MSG="$1"
780 APP=$2
781 WAIT_START="$(date +%s)"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000782
783 bspin - "$MSG $GO"
784 while true; do
David Bainbridged18f4942020-04-14 16:46:13 -0700785 NOW="$(date +%s)"
786 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700787 espin - "$THEX"
788 doTimeout "waiting to activate ONOS application '$APP'"
789 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +0000790 sspin -
David Bainbridged18f4942020-04-14 16:46:13 -0700791 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 +0000792 break
793 fi
794 sleep .2
795 done
796 espin - "$VERIFIED"
797}
798
799count_pods() {
David Bainbridged18f4942020-04-14 16:46:13 -0700800 local NAMESPACE STATES LABELS CMD PODS
801 NAMESPACE=$1; shift
David Bainbridge4f1b5562019-08-19 04:46:52 +0000802 if [ "$NAMESPACE" == "all-namespaces" ]; then
803 NAMESPACE="--all-namespaces"
804 else
805 NAMESPACE="-n $NAMESPACE"
806 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700807 STATES=$1; shift
808 LABELS=$1; shift
809 CMD=("kubectl get $NAMESPACE $LABELS pod")
810 PODS=$(${CMD[*]} -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}")
David Bainbridge4f1b5562019-08-19 04:46:52 +0000811 local COUNT=0
812 local PATTERNS="$*"
813 for POD in $PODS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700814 local NAME STATE CONTAINERS TOTAL FOUND
815 NAME="$(echo "$POD" | cut -d/ -f 1)"
816 STATE="$(echo "$POD" | cut -d/ -f 2)"
817 CONTAINERS="$(echo "$POD" | cut -d/ -f 3 | sed -e 's/_/ /g')"
818 if [ "$STATES" == "*" ] || [ "$(echo "$STATES" | grep -c ":$STATE:")" -ne 0 ]; then
819 TOTAL="$(echo "$CONTAINERS" | wc -w)"
820 FOUND="$(echo "$CONTAINERS" | grep -o true | wc -l)"
821 if [ "$TOTAL" -eq "$FOUND" ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000822 for PATTERN in $PATTERNS; do
David Bainbridged18f4942020-04-14 16:46:13 -0700823 if [[ "$NAME" =~ $PATTERN ]]; then
824 COUNT="$((COUNT + 1))"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000825 break
826 fi
827 done
828 fi
829 fi
830 done
David Bainbridge4f1b5562019-08-19 04:46:52 +0000831 echo $COUNT
832}
833
834wait_for_pods() {
David Bainbridged18f4942020-04-14 16:46:13 -0700835 local INDENT NAMESPACE EXPECT TYPE MESSAGE LABELS PATTERNS STATES HAVE ALL WAIT_START NOW
David Bainbridge4f1b5562019-08-19 04:46:52 +0000836 if [ "$1" == "-" ]; then
837 INDENT=$1; shift
838 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700839 NAMESPACE=$1; shift
840 EXPECT=$1; shift
841 TYPE=$1; shift
842 MESSAGE=$1; shift
843 LABELS=$1; shift
844 PATTERNS=("$*")
845 STATES=":Running:"
David Bainbridge99ac7a22019-08-31 02:26:43 +0000846 if [ "$TYPE" == "not" ]; then
847 STATES="*"
848 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700849 HAVE="$(count_pods "$NAMESPACE" "$STATES" "$LABELS" "${PATTERNS[@]}")"
850 ALL=$HAVE
David Bainbridge4f1b5562019-08-19 04:46:52 +0000851 if [ "$TYPE" == "only" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -0700852 ALL="$(count_pods "all-namespaces" "*" ".*")"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000853 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700854 COUNT="$((300 / 15))"
855 WAIT_START="$(date +%s)"
856 bspin "$INDENT" "$MESSAGE"
857 sspin "$INDENT"
858 if [ "$HAVE" -ne "$EXPECT" ] || [ "$ALL" -ne "$HAVE" ]; then
859 while [ "$HAVE" -ne "$EXPECT" ] || [ "$ALL" -ne "$HAVE" ]; do
860 NOW="$(date +%s)"
861 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
862 espin "$INDENT" "$THEX"
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700863 doTimeout "waiting for PODs to start"
864 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700865 sspin "$INDENT"
866 COUNT="$((COUNT - 1))"
867 if [ "$COUNT" -eq 0 ]; then
868 HAVE="$(count_pods "$NAMESPACE" "$STATES" "$LABELS" "${PATTERNS[@]}")"
869 ALL="$HAVE"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000870 if [ "$TYPE" == "only" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -0700871 ALL="$(count_pods "all-namespaces" "*" ".*")"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000872 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700873 COUNT="$((300 / 15))"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000874 fi
875 sleep .15
876 done
877 fi
David Bainbridged18f4942020-04-14 16:46:13 -0700878 espin "$INDENT" "$VERIFIED"
879 if [ "$HAVE" -ne "$EXPECT" ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000880 return 1
881 fi
882 return 0
883}
884
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800885port_forward() {
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700886 local NS=$1; shift
887 local SVC=$1; shift
888 local PORTS="$*"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800889 local TAG=$SVC-$NAME
890
David Bainbridge1d2c5842020-06-03 15:29:07 -0700891 (set -x; _TAG="$TAG" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n $NS service/$SVC $PORTS; done" >>"$PFLOG" 2>&1 &) >>"$PFLOG" 2>&1
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800892}
893
894kill_port_forward() {
David Bainbridge1d2c5842020-06-03 15:29:07 -0700895 local TAG P_IDS PARENTS KIDS UNKNOWN PP_ID PF
896
897 while [ $# -gt 0 ]; do
898 PF=$1; shift
899 TAG=
900 if [ "$PF" != "__ALL__" ]; then
901 TAG="$PF-$NAME"
902 fi
903 PARENTS=
904 KIDS=
905 UNKNOWN=
906 # shellcheck disable=SC2009
907 P_IDS="$(ps e -ww -A | grep "_TAG=$TAG" | grep -v grep | awk '{print $1}')"
908 if [ -n "$P_IDS" ]; then
909 for P_ID in $P_IDS; do
910 PP_ID="$(ps -o ppid "$P_ID" | tail -n +2)"
911 if [ -n "$PP_ID" ]; then
912 if [ "$PP_ID" -eq 1 ]; then
913 PARENTS="$PARENTS $P_ID"
914 else
915 KIDS="$KIDS $P_ID"
916 fi
David Bainbridgec6871d22019-11-13 17:10:31 +0000917 else
David Bainbridge1d2c5842020-06-03 15:29:07 -0700918 UNKNOWN="$UNKNOWN $P_ID"
David Bainbridgec6871d22019-11-13 17:10:31 +0000919 fi
David Bainbridge1d2c5842020-06-03 15:29:07 -0700920 done
921 if [ -n "$PARENTS" ]; then
922 # shellcheck disable=SC2086
923 while ps -h $PARENTS >/dev/null 2>&1; do
924 (set -x; eval "kill -9 $PARENTS" >>"$LOG" 2>&1) >>"$LOG" 2>&1
925 done
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800926 fi
David Bainbridge1d2c5842020-06-03 15:29:07 -0700927 if [ -n "$KIDS" ]; then
928 # shellcheck disable=SC2086
929 while ps -h $KIDS >/dev/null 2>&1; do
930 (set -x; eval "kill -9 $KIDS" >>"$LOG" 2>&1) >>"$LOG" 2>&1
931 done
932 fi
933 if [ -n "$UNKNOWN" ]; then
934 # shellcheck disable=SC2086
935 while ps -h $UNKNOWN >/dev/null 2>&1; do
936 (set -x; eval "kill -9 $UNKNOWN" >>"$LOG" 2>&1) >>"$LOG" 2>&1
937 done
938 fi
939 fi
940 done
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800941}
942
David Bainbridgecf546362020-04-21 23:18:50 -0700943resolve_chart_version() {
944 [ "$2" != "latest" ] && echo "$2" && return
945 helm inspect chart "$1" | grep "^version:" | awk '{print $2}'
946}
947
Jonathan Hart6a91e6c2020-04-16 14:28:33 -0700948# Compares two semver-formatted version strings (e.g. 2.4.3)
949# Returns 0 if $1 == $2, returns 1 if $1 > $2 and returns 2 if $1 < $2
950compare_versions() {
951 [ "$1" == "$2" ] && return 0
Jonathan Hart6a91e6c2020-04-16 14:28:33 -0700952 local lowest
953 lowest=$(echo -e "$1\n$2" | sort -V | head -1)
954 [ "$lowest" == "$1" ] && return 2
955 return 1
956}
957
David Bainbridgeac7f8072019-08-01 22:15:33 +0000958if [ "$1" == "down" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000959 echo "Tearing down voltha cluster $NAME"
960 LOG="down-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -0700961 date -u +"%Y%m%dT%H%M%SZ" >"$LOG"
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700962 if is_in "$WITH_ONOS" "yes,legacy,classic"; then
David Bainbridge696bc632020-04-05 21:49:37 -0700963 bspin "Remove port-forwards: onos-ui-$NAME"
964 kill_port_forward onos-ui
965 sspin "Remove port-forwards: onos-ssh-$NAME$CEOL"
966 kill_port_forward onos-ssh
David Bainbridge60ffc0f2020-04-27 22:13:22 -0700967 bspin "Remove port-forwards: onos-onos-classic-hs-$NAME$CEOL"
968 kill_port_forward onos-onos-classic-hs
David Bainbridge696bc632020-04-05 21:49:37 -0700969 fi
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800970 sspin "Remove port-forwards: voltha-api-$NAME$CEOL"
David Bainbridge1d2c5842020-06-03 15:29:07 -0700971 kill_port_forward voltha-api voltha-voltha-api
David Bainbridgec7220622020-05-28 12:31:47 -0700972 if is_in "$WITH_ETCD" "yes,external"; then
973 sspin "Remove port-forwards: etcd-$NAME$CEOL"
974 kill_port_forward "etcd"
David Bainbridge696bc632020-04-05 21:49:37 -0700975 fi
David Bainbridgec7220622020-05-28 12:31:47 -0700976 if is_in "$WITH_KAFKA" "yes,external"; then
977 sspin "Remove port-forwards: kafka-$NAME$CEOL"
978 kill_port_forward "kafka"
David Bainbridge696bc632020-04-05 21:49:37 -0700979 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -0700980
981 if [ "$WITH_PPROF" == "yes" ]; then
David Bainbridgec7220622020-05-28 12:31:47 -0700982 sspin "Remove port-forwards: *-profiler$CEOL"
David Bainbridge1d2c5842020-06-03 15:29:07 -0700983 kill_port_forward voltha-rw-core-profiler voltha-voltha-rw-core-profiler
984 kill_port_forward voltha-of-agent-profiler voltha-voltha-of-agent-profiler
David Bainbridgec7220622020-05-28 12:31:47 -0700985 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
David Bainbridge1d2c5842020-06-03 15:29:07 -0700986 kill_port_forward adapter-open-olt-profiler open-olt-adapter-open-olt-profiler
David Bainbridgec7220622020-05-28 12:31:47 -0700987 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -0700988 fi
989
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800990 espin "$VERIFIED Remove port-forwards$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -0700991 if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridgeac7f8072019-08-01 22:15:33 +0000992 if [ -x ./bin/kind ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000993 bspin "Delete Kubernetes Kind Cluster"
David Bainbridged18f4942020-04-14 16:46:13 -0700994 (set -x; ./bin/kind delete cluster --name "voltha-$NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
995 espin "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000996 else
David Bainbridge0774b232019-08-02 06:37:19 +0000997 espin "$NO_ENTRY Delete Kubernetes Kind Cluster: kind command not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000998 fi
999 else
David Bainbridge309099c2020-05-05 08:47:29 -07001000 if [ "$CONFIG_SADIS" == "external" ]; then
1001 bspin "Remove configmap for BBSIM SADIS server"
1002 (set -x; kubectl -n "$BBSIM_NS" delete --ignore-not-found configmap kube-config >>"$LOG" 2>&1) >>"$LOG" 2>&1
1003 espin "$VERIFIED"
1004 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001005 EXISTS="$(helm list -q)"
David Bainbridge76afd812020-04-06 09:53:52 -07001006 EXPECT="voltha"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001007 if is_in "$WITH_ONOS" "yes,legacy,classic"; then
David Bainbridge696bc632020-04-05 21:49:37 -07001008 EXPECT+=" onos"
1009 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001010 if [ "$WITH_RADIUS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001011 EXPECT+=" radius"
1012 fi
David Bainbridge309099c2020-05-05 08:47:29 -07001013 if [ "$CONFIG_SADIS" == "external" ]; then
1014 EXPECT+=" bbsim-sadis-server"
1015 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001016 if [ "$WITH_BBSIM" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001017 EXPECT+=" bbsim"
1018 fi
divyadesai59f987a2020-05-27 12:11:33 +00001019 if [ "$WITH_EFK" == "yes" ]; then
1020 EXPECT+=" elasticsearch kibana fluentd"
1021 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001022 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001023 EXPECT+=" open-olt open-onu"
1024 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001025 if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001026 EXPECT+=" sim"
1027 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001028 if is_in "$WITH_ETCD" "yes,external"; then
1029 EXPECT+=" etcd"
David Bainbridge76afd812020-04-06 09:53:52 -07001030 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001031 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -07001032 EXPECT+=" kafka"
1033 fi
David Bainbridge0774b232019-08-02 06:37:19 +00001034 bspin "Remove Helm Deployments"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001035 for i in $EXISTS; do
David K. Bainbridge43422402020-03-06 07:41:22 -08001036 for j in $EXPECT; do
David Bainbridged18f4942020-04-14 16:46:13 -07001037 if [[ "$i" =~ $j ]]; then
David K. Bainbridge43422402020-03-06 07:41:22 -08001038 sspin "Remove Helm Deployments: $i$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -07001039 (set -x; ./bin/helm delete --no-hooks --purge "$i" >>"$LOG" 2>&1) >>"$LOG" 2>&1
David K. Bainbridge43422402020-03-06 07:41:22 -08001040 fi
1041 done
uottrembb16d3982020-02-28 08:34:36 +01001042 done
David Bainbridge0774b232019-08-02 06:37:19 +00001043 espin "$VERIFIED Remove Helm Deployments$CEOL"
David Bainbridge4f1b5562019-08-19 04:46:52 +00001044 if [ "$WAIT_ON_DOWN" == "yes" ]; then
Matteo Scandoloe93c9eb2020-06-03 12:08:51 -07001045 PODS="voltha-ofagent.* voltha-rw-core.*"
David Bainbridge76afd812020-04-06 09:53:52 -07001046 INFRA_PODS=
1047 ADAPT_PODS=
1048 SIM_PODS=
divyadesai59f987a2020-05-27 12:11:33 +00001049 EFK_PODS=
David Bainbridged18f4942020-04-14 16:46:13 -07001050 if [ "$WITH_RADIUS" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -07001051 PODS+=" radius.*"
1052 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001053 if [ "$WITH_BBSIM" == "yes" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -07001054 SIM_PODS+=" bbsim.*"
David Bainbridge696bc632020-04-05 21:49:37 -07001055 fi
divyadesai59f987a2020-05-27 12:11:33 +00001056 if [ "$WITH_EFK" == "yes" ]; then
1057 EFK_PODS+=" kibana-* elasticsearch-* fluentd-*"
1058 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001059 if [ "$WITH_OPEN_ADAPTERS" ] || [ "$WITH_SIM_ADAPTERS" ]; then
David Bainbridge76afd812020-04-06 09:53:52 -07001060 ADAPT_PODS+=" adapter-*"
David Bainbridge696bc632020-04-05 21:49:37 -07001061 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001062 if is_in "$WITH_ONOS" "yes,legacy,classic"; then
David Bainbridge76afd812020-04-06 09:53:52 -07001063 INFRA_PODS+=" onos-.*"
1064 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001065 if is_in "$WITH_ETCD" "yes,external"; then
1066 INFRA_PODS+=" etcd.*"
David Bainbridge76afd812020-04-06 09:53:52 -07001067 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001068 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridge76afd812020-04-06 09:53:52 -07001069 INFRA_PODS+=" kafka.*"
1070 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001071 if [ -n "$SIM_PODS" ]; then
1072 wait_for_pods "$BBSIM_NS" 0 "not" "Waiting for BBSIM PODs to terminate" "$BBSIM_LABEL" "$SIM_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -07001073 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001074 if [ -n "$INFRA_PODS" ]; then
1075 wait_for_pods "$INFRA_NS" 0 "not" "Waiting for infrastructure PODs to terminate" "$NO_LABEL" "$INFRA_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -07001076 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001077 if [ -n "$ADAPT_PODS" ]; then
1078 wait_for_pods "$ADAPTER_NS" 0 "not" "Waiting for adapter PODs to terminate" "$NO_LABEL" "$ADAPT_PODS"
David Bainbridge76afd812020-04-06 09:53:52 -07001079 fi
divyadesai59f987a2020-05-27 12:11:33 +00001080 if [ -n "$EFK_PODS" ]; then
1081 wait_for_pods "$INFRA_NS" 0 "not" "Waiting for EFK PODs to terminate" "$NO_LABEL" "$EFK_PODS"
1082 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001083 wait_for_pods "$VOLTHA_NS" 0 "not" "Waiting for VOLTHA PODs to terminate" "$NO_LABEL" "$PODS"
David Bainbridge4f1b5562019-08-19 04:46:52 +00001084 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +00001085 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001086 exit
David Bainbridgeac7f8072019-08-01 22:15:33 +00001087fi
1088
1089if [ "$1" == "dump" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001090 LOG="dump-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -07001091 TS="$(date -u +"%Y%m%dT%H%M%SZ")"
1092 if [ -n "$DUMP_FROM" ]; then
1093 TS=${DUMP_FROM//[:-]}
David Bainbridge76514a02019-10-08 01:50:35 +00001094 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001095 WORK="$(mktemp -u -d)"
David Bainbridge0774b232019-08-02 06:37:19 +00001096 DATA=$WORK/voltha-debug-dump-$NAME-$TS
David Bainbridged18f4942020-04-14 16:46:13 -07001097 mkdir -p "$DATA"
1098 echo "$TS" > "$LOG"
David Bainbridge0774b232019-08-02 06:37:19 +00001099 echo -e "Capturing debug dump to voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001100 bspin - "Copy install log"
David Bainbridged18f4942020-04-14 16:46:13 -07001101 if [ -f "install-$NAME.log" ]; then
1102 (set -x; cp "install-$NAME.log" "$DATA/install-$NAME.log") >>"$LOG" 2>&1
1103 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001104 else
David Bainbridge0774b232019-08-02 06:37:19 +00001105 espin - "$NO_ENTRY Copy install log: install-$NAME.log not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001106 fi
1107 bspin - "Dumping Kubernetes PODs"
David Bainbridged18f4942020-04-14 16:46:13 -07001108 (set -x; kubectl get --all-namespaces pods >> "$DATA/all-pods.txt" 2>&1) >>"$LOG" 2>&1
1109 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001110 bspin - "Dumping Kubernetes SERVICEs"
David Bainbridged18f4942020-04-14 16:46:13 -07001111 (set -x; kubectl get --all-namespaces svc >> "$DATA/all-services.txt" 2>&1) >>"$LOG" 2>&1
1112 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001113 bspin - "Dumping Kubernetes EVENTs"
David Bainbridged18f4942020-04-14 16:46:13 -07001114 (set -x; kubectl get --all-namespaces events >> "$DATA/all-events.txt" 2>&1) >>"$LOG" 2>&1
1115 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001116 bspin - "Dumping VOLTHA POD details"
David Bainbridged18f4942020-04-14 16:46:13 -07001117 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 +00001118 SINCE=
David Bainbridged18f4942020-04-14 16:46:13 -07001119 if [ -n "$DUMP_FROM" ]; then
David Bainbridgecfd7ca12019-10-06 03:31:41 +00001120 SINCE="--since-time=$DUMP_FROM"
1121 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +00001122 for POD in $PODS; do
David Bainbridged18f4942020-04-14 16:46:13 -07001123 NS="$(echo "$POD" | cut -d: -f1)"
1124 POD="$(echo "$POD" | cut -d: -f2)"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001125 sspin - "Dumping VOLTHA POD details: $POD$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -07001126 mkdir -p "$DATA/$POD"
1127 (set -x; kubectl describe -n "$NS" "$POD" >> "$DATA/$POD/describe.txt" 2>&1) >>"$LOG" 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +00001128 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridged18f4942020-04-14 16:46:13 -07001129 (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 +00001130 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridged18f4942020-04-14 16:46:13 -07001131 (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 +00001132 sspin - "Dumping VOLTHA POD details: $POD"
1133 done
1134 espin - "$VERIFIED Dumping VOLTHA POD details$CEOL"
1135 bspin - "Dumping ETCD"
David Bainbridged18f4942020-04-14 16:46:13 -07001136 if [ -n "$(command -v etcdctl)" ]; then
1137 (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
1138 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001139 else
1140 espin - "$NO_ENTRY Dumping ETCD: etcdctl command not available"
1141 fi
David Bainbridge0774b232019-08-02 06:37:19 +00001142 bspin - "Creating compressed TAR: voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridged18f4942020-04-14 16:46:13 -07001143 (set -x; tar -C "$WORK" -zcf "voltha-debug-dump-$NAME-$TS.tgz" "./voltha-debug-dump-$NAME-$TS") >>"$LOG" 2>&1
1144 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001145 bspin - "Cleanup"
David Bainbridged18f4942020-04-14 16:46:13 -07001146 (set -x; rm -rf "$WORK") >>"$LOG" 2>&1
1147 espin - "$VERIFIED"
1148 bspin - "$(ls -l "voltha-debug-dump-$NAME-$TS.tgz")"
1149 espin - "$VERIFIED"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001150 exit
1151fi
1152
David Bainbridge0774b232019-08-02 06:37:19 +00001153LOG="install-$NAME.log"
David Bainbridge1d2c5842020-06-03 15:29:07 -07001154PFLOG="port-forward-$NAME.log"
David Bainbridged18f4942020-04-14 16:46:13 -07001155date > "$LOG"
divyadesai59f987a2020-05-27 12:11:33 +00001156echo "PORTS=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT,$ELASTICSEARCH_PORT,$KIBANA_PORT" >> "$LOG"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001157
1158# Output install options to log
David Bainbridged18f4942020-04-14 16:46:13 -07001159echo "OPTIONS" >> "$LOG"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001160for O in $ALL_OPTIONS; do
David Bainbridged18f4942020-04-14 16:46:13 -07001161 VAL="$(eval echo "\$$O")"
1162 if [ -n "$VAL" ]; then
1163 printf " %-30s = %s\n" "$O" "$VAL" >> "$LOG"
David Bainbridgeac7f8072019-08-01 22:15:33 +00001164 fi
1165done
1166
David Bainbridgee4d11ca2020-05-08 10:21:10 -07001167# Force remove any existing k8s port-forward processes. This will
1168# remove them for all kind clusters.
David Bainbridgee4d11ca2020-05-08 10:21:10 -07001169if [ "$1" == "clean" ]; then
1170 kill_port_forward __ALL__
1171 exit
1172fi
1173
David Bainbridgefad50732020-05-01 17:00:12 -07001174helm_values() {
1175 local NAMESPACE=$1; shift
1176 local INAME=$1; shift
1177 local CHART=$1; shift
1178 local CHART_VERSION=$1; shift
1179
1180 if [ "$CHART_VERSION X" != " X" ] && [ "$CHART_VERSION" != "latest" ]; then
1181 CHART_VERSION="--version $CHART_VERSION"
1182 else
1183 CHART_VERSION=
1184 fi
1185
1186 local CHART_ARGS=
1187 if [ -r "${INAME}-values.yaml" ]; then
1188 CHART_ARGS="-f ${INAME}-values.yaml"
1189 fi
1190
1191 if [ "$HELM_USE_UPGRADE" == "yes" ]; then
1192 _HELM_COMMAND="upgrade --install"
1193 _HELM_ARGS="xxxdryrunxxx"
1194 else
1195 _HELM_COMMAND="install"
1196 _HELM_ARGS="--name xxxdryrunxxx"
1197 fi
1198 CMD=("helm $_HELM_COMMAND --debug --dry-run -f $NAME-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 $CHART")
1199 ${CMD[*]} 2>/dev/null | awk 'PRINT==1 {print}; /^USER-SUPPLIED VALUES:/ {PRINT = 1}; /^$/ {PRINT = 0}'
1200}
1201
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001202helm_install() {
David Bainbridgec7220622020-05-28 12:31:47 -07001203 local INDENT NOW VALUES_FILE PPROF_ARG
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001204 if [ "$1" == "-" ]; then
1205 INDENT=$1; shift
1206 fi
1207 local NAMESPACE=$1; shift
David Bainbridge0774b232019-08-02 06:37:19 +00001208 local INAME=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001209 local CHART=$1; shift
David Bainbridge90fd8e32019-08-21 23:32:47 +00001210 local CHART_VERSION=$1; shift
David Bainbridgec7220622020-05-28 12:31:47 -07001211 local FILTER=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001212 local MESSAGE=$*
1213
David Bainbridged18f4942020-04-14 16:46:13 -07001214 if [ "$CHART_VERSION X" != " X" ] && [ "$CHART_VERSION" != "latest" ]; then
David Bainbridge90fd8e32019-08-21 23:32:47 +00001215 CHART_VERSION="--version $CHART_VERSION"
1216 else
1217 CHART_VERSION=
1218 fi
1219
David Bainbridge99ac7a22019-08-31 02:26:43 +00001220 local CHART_ARGS=
1221 if [ -r "${INAME}-values.yaml" ]; then
1222 CHART_ARGS="-f ${INAME}-values.yaml"
1223 fi
1224
David Bainbridged18f4942020-04-14 16:46:13 -07001225 local WAIT_START CMD
1226 WAIT_START="$(date +%s)"
1227 COUNT="$((300 / 15))"
1228 bspin "$INDENT" "$MESSAGE"
1229 if [ "$HELM_USE_UPGRADE" == "yes" ]; then
David Bainbridge7f8bf992020-04-08 21:53:22 -07001230 _HELM_COMMAND="upgrade --install"
1231 _HELM_ARGS="$INAME"
1232 else
1233 _HELM_COMMAND="install"
1234 _HELM_ARGS="--name $INAME"
1235 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001236
1237 VALUES_FILE="$(mktemp)"
1238 if [ "$FILTER" == "-" ]; then
1239 cp "$NAME-values.yaml" "$VALUES_FILE"
David Bainbridgea965ca22020-06-09 17:45:04 -07001240 elif [ "${FILTER:0:1}" == "+" ]; then
1241 cp "$NAME-values.yaml" "$VALUES_FILE"
1242 yq r - "${FILTER:1}" <"$NAME-values.yaml" >>"$VALUES_FILE"
David Bainbridge33e56c72020-06-11 11:39:56 -07001243 cat "$VALUES_FILE" >>"$LOG"
David Bainbridgec7220622020-05-28 12:31:47 -07001244 else
David Bainbridge43f2df52020-06-02 15:30:54 -07001245 yq r - "$FILTER" <"$NAME-values.yaml" >"$VALUES_FILE"
David Bainbridgec7220622020-05-28 12:31:47 -07001246 fi
1247 if [ "$WITH_PPROF" == "yes" ]; then
1248 PPROF_ARG="--set profiler.enabled=true"
1249 fi
1250 CMD=("helm $_HELM_COMMAND -f $VALUES_FILE $CHART_ARGS $PPROF_ARG $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 $CHART")
David Bainbridged18f4942020-04-14 16:46:13 -07001251 (set -x; ${CMD[*]} >>"$LOG" 2>&1) >>"$LOG" 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001252 SUCCESS=$?
David Bainbridged18f4942020-04-14 16:46:13 -07001253 while [ "$SUCCESS" -ne 0 ]; do
1254 NOW="$(date +%s)"
1255 if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then
David Bainbridge52e6e9d2020-03-23 13:48:27 -07001256 espin "$THEX"
David Bainbridgec7220622020-05-28 12:31:47 -07001257 rm -f "$VALUES_FILE"
David Bainbridge52e6e9d2020-03-23 13:48:27 -07001258 doTimeout "waiting for helm install $CHART"
1259 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001260 sspin "$INDENT"
1261 COUNT="$((COUNT - 1))"
1262 if [ "$COUNT" -eq 0 ]; then
1263 if [ "$HELM_USE_UPGRADE" == "no" ]; then
1264 (set -x; helm delete --purge "$INAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1
David Bainbridge7f8bf992020-04-08 21:53:22 -07001265 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001266 (set -x; ${CMD[*]} >>"$LOG" 2>&1) >>"$LOG" 2>&1
Andy Baviere22ff252019-12-19 11:40:31 -07001267 SUCCESS=$?
David Bainbridged18f4942020-04-14 16:46:13 -07001268 COUNT="$((300 / 15))"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001269 fi
1270 sleep .15
1271 done
David Bainbridgec7220622020-05-28 12:31:47 -07001272 rm -f "$VALUES_FILE"
David Bainbridged18f4942020-04-14 16:46:13 -07001273 espin "$INDENT" "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001274}
1275
David Bainbridged18f4942020-04-14 16:46:13 -07001276echo "INSTALL TYPE: $TYPE" >> "$LOG"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001277
1278bspin "Verify GOPATH"
David Bainbridged18f4942020-04-14 16:46:13 -07001279GOPATH="$(pwd)"; export GOPATH
1280mkdir -p "$GOPATH/bin"
1281espin "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001282
David Bainbridged18f4942020-04-14 16:46:13 -07001283STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001284if [ "$INSTALL_KUBECTL" == "no" ]; then
1285 bspin "Skip kubectl install"
1286 espin $NO_ENTRY
Test Userc13bdc92019-07-03 20:57:49 +00001287else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001288 bspin "Verify kubectl $HELM"
David Bainbridged18f4942020-04-14 16:46:13 -07001289 if [ -x "$GOPATH/bin/kubectl" ]; then
1290 espin "$VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001291 else
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001292 ERR_OUT="$(mktemp)"
David Bainbridged18f4942020-04-14 16:46:13 -07001293 espin "$NOT_VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001294 bspin - "Download and install Kubernetes/kubectl $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001295 (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
1296 RESULT=$?
1297 if [ "$RESULT" -ne 0 ]; then
1298 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001299 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download kubectl: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001300 cat "$ERR_OUT" >> "$LOG"
Zack Williamsded60cb2020-04-13 10:02:20 -07001301 rm -rf "$ERR_OUT" "$GOPATH/bin/kubectl"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001302 exit 1
1303 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001304 (set -x; chmod 755 "$GOPATH/bin/kubectl" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1305 espin - "$VERIFIED"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001306 rm -rf "$ERR_OUT"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001307 fi
Test Userc13bdc92019-07-03 20:57:49 +00001308fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001309if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001310 NOW="$(date +%s)"
1311 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001312fi
Test Userc13bdc92019-07-03 20:57:49 +00001313
David Bainbridged18f4942020-04-14 16:46:13 -07001314STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001315if [ "$DEPLOY_K8S" == "no" ]; then
1316 bspin "Skip Kubernetes/Kind Deployment"
1317 espin $NO_ENTRY
1318else
Test Userba1e7e72019-07-10 22:27:54 +00001319 bspin "Verify Kubernetes/Kind $HELM"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001320 IS_INSTALLED=0
1321 OP_TYPE="install"
David Bainbridged18f4942020-04-14 16:46:13 -07001322 if [ -x "$GOPATH/bin/kind" ]; then
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001323 OP_TYPE="upgrade"
David Bainbridged18f4942020-04-14 16:46:13 -07001324 if [ "$("$GOPATH/bin/kind" --version | grep -c "$KIND_VERSION")" -eq 1 ]; then
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001325 IS_INSTALLED=1
David Bainbridged18f4942020-04-14 16:46:13 -07001326 espin "$VERIFIED"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001327 fi
1328 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001329 if [ "$IS_INSTALLED" -eq 0 ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001330 ERR_OUT="$(mktemp)"
David Bainbridged18f4942020-04-14 16:46:13 -07001331 espin "$NOT_VERIFIED"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001332 bspin - "Download and $OP_TYPE Kubernetes/kind $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001333 (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
1334 RESULT=$?
1335 if [ $RESULT -ne 0 ]; then
1336 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001337 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download kind: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001338 cat "$ERR_OUT" >> "$LOG"
Zack Williamsded60cb2020-04-13 10:02:20 -07001339 rm -rf "$ERR_OUT" "$GOPATH/bin/kind"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001340 exit 1
1341 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001342 (set -x; chmod 755 "$GOPATH/bin/kind" >>"$LOG" 2>&1) >>"$LOG" 2>&1
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001343 rm -rf "$ERR_OUT"
David Bainbridged18f4942020-04-14 16:46:13 -07001344 espin - "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001345 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001346fi
1347
David Bainbridgee87067b2019-08-12 22:00:12 +00001348if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001349 NOW="$(date +%s)"
1350 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001351fi
1352
David Bainbridged18f4942020-04-14 16:46:13 -07001353STIME="$(date +%s)"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001354if [ "$INSTALL_HELM" == "no" ]; then
1355 bspin "Skip Helm Install"
1356 espin $NO_ENTRY
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001357else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001358 bspin "Verify Helm $HELM"
David Bainbridgea34993d2020-04-01 09:15:42 -07001359 HELM_UPGRADE=0
1360 HELM_UPGRADE_DESC="install"
David Bainbridged18f4942020-04-14 16:46:13 -07001361 if [ -x "$GOPATH/bin/helm" ]; then
1362 HAVE_VER="$("$GOPATH/bin/helm" version -c --template '{{.Client.SemVer}}')"
1363 HELM_UP_DOWN="$(echo -e "$HAVE_VER\n$HELM_VERSION" | sort -V | head -1)"
1364 if [ "$HAVE_VER" != "$HELM_VERSION" ]; then
1365 if [ "$HELM_UP_DOWN" == "$HELM_VERSION" ]; then
David Bainbridgea34993d2020-04-01 09:15:42 -07001366 HELM_UPGRADE_DESC="downgrade"
1367 else
1368 HELM_UPGRADE_DESC="upgrade"
1369 fi
1370 HELM_UPGRADE=1
1371 else
David Bainbridged18f4942020-04-14 16:46:13 -07001372 espin "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001373 fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001374 else
David Bainbridgea34993d2020-04-01 09:15:42 -07001375 HELM_UPGRADE=1
1376 fi
1377
David Bainbridged18f4942020-04-14 16:46:13 -07001378 if [ "$HELM_UPGRADE" -ne 0 ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001379 ERR_OUT="$(mktemp)"
1380 INSTALL_HELM_BIN=$(mktemp)
David Bainbridged18f4942020-04-14 16:46:13 -07001381 espin "$NOT_VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001382 bspin - "Download and $HELM_UPGRADE_DESC Helm $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001383 (set -x; curl -o "$INSTALL_HELM_BIN" --fail -sSL https://git.io/get_helm.sh >>"$LOG" 2>"$ERR_OUT") >>"$LOG" 2>&1
1384 RESULT=$?
1385 if [ $RESULT -ne 0 ]; then
1386 espin - "$THEX"
David Bainbridgee3fc0c32020-04-21 15:34:04 -07001387 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download helm installer: $(tail "$ERR_OUT")${NORMAL}"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001388 cat "$ERR_OUT" >> "$LOG"
1389 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT" "$GOPATH/bin/helm" "$GOPATH/bin/tiller"
1390 exit 1
1391 fi
1392 rm -rf "$ERR_OUT"
1393 chmod +x "$INSTALL_HELM_BIN"
1394 (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
1395 RESULT=$?
1396 if [ $RESULT -ne 0 ]; then
1397 espin - "$THEX"
1398 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to install helm, see install log for details${NORMAL}"
1399 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT" "$GOPATH/bin/helm" "$GOPATH/bin/tiller"
1400 exit 1
1401 fi
1402 rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT"
David Bainbridged18f4942020-04-14 16:46:13 -07001403 espin - "$VERIFIED"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001404 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001405fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001406if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001407 NOW="$(date +%s)"
1408 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001409fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001410
David Bainbridged18f4942020-04-14 16:46:13 -07001411STIME="$(date +%s)"
Test Userb5712372019-07-03 21:52:17 +00001412bspin "Verify voltctl $HIGH_VOLTAGE"
David Bainbridged2811972019-12-14 01:14:09 +00001413VOK=0
1414VMESSAGE="install"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001415ERR_OUT=$(mktemp)
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001416export VC_VERSION="$VOLTCTL_VERSION"
1417if [ "$VC_VERSION" == "latest" ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001418 set -o pipefail # TODO: would be nice to run all in pipefail mode
1419 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')"
1420 RESULT=$?
1421 set +o pipefail
1422 if [ "$RESULT" -ne 0 ]; then
1423 espin - "$THEX"
1424 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to determine released version of voltctl: $(cat "$ERR_OUT")${NORMAL}"
1425 rm -rf "$ERR_OUT" "$GOPATH/bin/voltctl"
1426 exit 1
1427 fi
1428 export VC_VERSION
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001429fi
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001430
David Bainbridged18f4942020-04-14 16:46:13 -07001431if [ -x "$GOPATH/bin/voltctl" ]; then
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001432 VHAVE="$("$GOPATH/bin/voltctl" version --clientonly -o json 2>/dev/null | jq -r .version)"
David Bainbridged18f4942020-04-14 16:46:13 -07001433 RESULT=$?
1434 if [ $RESULT -eq 0 ] && [ "$VHAVE" == "$VC_VERSION" ]; then
David Bainbridged2811972019-12-14 01:14:09 +00001435 VOK=1
David Bainbridged18f4942020-04-14 16:46:13 -07001436 espin "$VERIFIED"
David Bainbridge1ba64f12019-12-18 00:40:13 +00001437 else
David Bainbridged18f4942020-04-14 16:46:13 -07001438 VCHECK="$(echo -e "$VHAVE\n$VC_VERSION" | sort -V | head -1)"
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001439 if [ "$VCHECK" == "$VHAVE" ]; then
1440 VMESSAGE="upgrade"
1441 else
1442 VMESSAGE="downgrade"
1443 fi
David Bainbridged2811972019-12-14 01:14:09 +00001444 fi
1445fi
1446
David Bainbridged18f4942020-04-14 16:46:13 -07001447if [ "$VOK" -eq 0 ]; then
1448 espin "$NOT_VERIFIED"
David Bainbridged2811972019-12-14 01:14:09 +00001449 bspin - "Download and $VMESSAGE voltctl $DOWNLOAD"
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001450 (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
1451 RESULT=$?
1452 if [ $RESULT -ne 0 ]; then
1453 espin - "$THEX"
1454 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download voltctl (version $VC_VERSION): $(cat "$ERR_OUT")${NORMAL}"
1455 rm -rf "$ERR_OUT" "$GOPATH/bin/voltctl"
1456 exit 1
1457 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001458 (set -x; chmod 755 "$GOPATH/bin/voltctl" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1459 espin - "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001460fi
David Bainbridgee40e6ef2020-04-21 13:15:58 -07001461rm -rf "$ERR_OUT"
David Bainbridgee87067b2019-08-12 22:00:12 +00001462if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001463 NOW="$(date +%s)"
1464 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001465fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001466
1467bspin "Verify command PATH"
Test Userba1e7e72019-07-10 22:27:54 +00001468export PATH=$GOPATH/bin:$PATH
David Bainbridged18f4942020-04-14 16:46:13 -07001469espin "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001470
David Bainbridged18f4942020-04-14 16:46:13 -07001471STIME="$(date +%s)"
Test Userba1e7e72019-07-10 22:27:54 +00001472if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001473 HAVE="$(kind get clusters | grep -c "voltha-$NAME")"
Test Userba1e7e72019-07-10 22:27:54 +00001474 bspin "Verify Kubernetes/Kind Cluster"
1475 sspin
David Bainbridged18f4942020-04-14 16:46:13 -07001476 if [ "$HAVE" -eq 0 ]; then
1477 espin "$NOT_VERIFIED"
David Bainbridge491b1bd2019-07-11 17:53:11 +00001478 bspin - "Verify cluster configuration"
David Bainbridged18f4942020-04-14 16:46:13 -07001479 if [ ! -r "./$NAME-cluster.cfg" ]; then
1480 espin - "$NOT_VERIFIED"
David K. Bainbridge43422402020-03-06 07:41:22 -08001481 bspin - "Download cluster configuration: $TYPE-cluster.cfg to $NAME-cluster.cfg $DOWNLOAD"
David Bainbridged18f4942020-04-14 16:46:13 -07001482 ERR_OUT="$(mktemp)"
serkant.uluderya4d315132020-04-15 16:25:54 -07001483 if ! (set -x; curl --fail -o "./$NAME-cluster.cfg" -sSL "https://raw.githubusercontent.com/opencord/kind-voltha/$VK_RELEASE/$TYPE-cluster.cfg" >>"$LOG" 2>>"$ERR_OUT") >>"$LOG" 2>&1; then
David Bainbridged18f4942020-04-14 16:46:13 -07001484 espin - "$THEX"
1485 echo -e "${RED}${BOLD}${ERROR}ERROR: $NAME-cluster.cfg${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1486 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
1487 rm -rf "$ERR_OUT" "./$NAME-cluster.cfg"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001488 exit 1
1489 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001490 rm -rf "$ERR_OUT"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001491 else
David Bainbridged18f4942020-04-14 16:46:13 -07001492 espin - "$VERIFIED"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001493 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001494 kind create cluster --name "voltha-$NAME" --config "$NAME-cluster.cfg"
David Bainbridge491b1bd2019-07-11 17:53:11 +00001495 else
David Bainbridged18f4942020-04-14 16:46:13 -07001496 espin "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001497 fi
1498
David Bainbridge1d2c5842020-06-03 15:29:07 -07001499 export KUBECONFIG="./kube-config-$NAME"
1500 kind get kubeconfig --name="voltha-$NAME" >"$KUBECONFIG"
1501 # For backward compatibility also copy to old location
David Bainbridgedee3f022020-06-05 07:45:13 -07001502 mkdir -p "$HOME/.kube"
David Bainbridge7b3c1632020-06-05 10:04:14 -07001503 cp "$KUBECONFIG" "$HOME/.kube/kind-config-voltha-$NAME"
David Bainbridge1d2c5842020-06-03 15:29:07 -07001504
Test Userba1e7e72019-07-10 22:27:54 +00001505 P="coredns-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001506 etcd-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +00001507 kindnet-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001508 kube-apiserver-voltha-$NAME-control-plane \
1509 kube-controller-manager-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +00001510 kube-proxy-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001511 kube-scheduler-voltha-$NAME-control-plane"
Test Userba1e7e72019-07-10 22:27:54 +00001512
David Bainbridged18f4942020-04-14 16:46:13 -07001513 EXPECT="$(test "$TYPE" == "minimal" && echo "12" || echo "14")"
1514 wait_for_pods - "kube-system" "$EXPECT" "includes" "Waiting for system PODs to start" "$NO_LABEL" "$P"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001515fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001516if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001517 NOW="$(date +%s)"
1518 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001519fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001520
David Bainbridgee4d11ca2020-05-08 10:21:10 -07001521if [ "$SCHEDULE_ON_CONTROL_NODES" == "yes" ]; then
1522 bspin "Untaint control nodes to allow scheduling $LOCK"
1523 for MNODE in $(kubectl get node --selector='node-role.kubernetes.io/master' -o json | jq -r '.items[].metadata.name'); do
1524 (set -x; kubectl taint node "$MNODE" node-role.kubernetes.io/master:NoSchedule- >>"$LOG" 2>&1) >>"$LOG" 2>&1
1525 sspin
1526 done
1527 espin "$VERIFIED"
1528fi
1529
David Bainbridged18f4942020-04-14 16:46:13 -07001530STIME="$(date +%s)"
1531COUNT="$(count_pods "kube-system" ":Running:" "$NO_LABEL" "tiller-deploy-.*")"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001532bspin "Verify Helm"
David Bainbridged18f4942020-04-14 16:46:13 -07001533if [ "$COUNT" -ne 1 ]; then
1534 espin "$NOT_VERIFIED"
Test Userb5712372019-07-03 21:52:17 +00001535 echo -e "Configuring Helm $GEAR"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001536 if [ "$INSTALL_HELM" == "no" ]; then
1537 bspin - "Skip Helm/Tiller Initialization"
1538 espin - $NO_ENTRY
1539 else
1540 bspin - "Initialize Helm"
David Bainbridged18f4942020-04-14 16:46:13 -07001541 (set -x; helm init --upgrade >>"$LOG" 2>&1) >>"$LOG" 2>&1
1542 espin - "$VERIFIED"
1543 wait_for_pods - "kube-system" 1 "includes" "Waiting for Tiller POD to start" "$NO_LABEL" "tiller-deploy-.*"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001544 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001545
Test Userba1e7e72019-07-10 22:27:54 +00001546 # HACK (sort-of) - the config for tiller is about to be patched, which will
1547 # cause the tiller pod to be recreated. This can sometimes cause a timing
1548 # issue with the "wait_for_pods" call on tiller as it may incorrectly
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001549 # identify the running/ready tiller pod that is soon to be terminated as
Test Userba1e7e72019-07-10 22:27:54 +00001550 # what it is waiting for. To avoid this issue we do a clean scale down and
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001551 # scale up of the pod so the script controlls when it should be expecting
Test Userba1e7e72019-07-10 22:27:54 +00001552 # things
David Bainbridged18f4942020-04-14 16:46:13 -07001553 (set -x; kubectl -n kube-system scale deploy tiller-deploy --replicas=0 >>"$LOG" 2>&1) >>"$LOG" 2>&1
David Bainbridgeddeab482020-06-24 12:43:40 -07001554 wait_for_pods - "kube-system" 0 "not" "Waiting for Tiller POD to shutdown" "$NO_LABEL" "tiller-deploy-.*"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001555
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001556 # Create and k8s service account so that Helm can create pods
Test Userb5712372019-07-03 21:52:17 +00001557 bspin - "Create Tiller ServiceAccount"
David Bainbridged18f4942020-04-14 16:46:13 -07001558 (set -x; kubectl create serviceaccount --namespace kube-system tiller >>"$LOG" 2>&1) >>"$LOG" 2>&1
1559 espin - "$VERIFIED"
Test Userb5712372019-07-03 21:52:17 +00001560 bspin - "Create Tiller ClusterRoleBinding"
David Bainbridged18f4942020-04-14 16:46:13 -07001561 (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>"$LOG" 2>&1) >>"$LOG" 2>&1
1562 espin - "$VERIFIED"
Test Userb5712372019-07-03 21:52:17 +00001563 bspin - "Update Tiller Manifest"
David Bainbridged18f4942020-04-14 16:46:13 -07001564 (set -x; kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}' >>"$LOG" 2>&1) >>"$LOG" 2>&1
Test Userba1e7e72019-07-10 22:27:54 +00001565
1566 # HACK (sort-of) - part to, spin it back up
David Bainbridged18f4942020-04-14 16:46:13 -07001567 (set -x; kubectl -n kube-system scale deploy tiller-deploy --replicas=1 >>"$LOG" 2>&1) >>"$LOG" 2>&1
1568 espin - "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001569else
David Bainbridged18f4942020-04-14 16:46:13 -07001570 if [ "$(helm version -s --template '{{.Server.SemVer}}')" != "$HELM_VERSION" ]; then
1571 espin "$NOT_VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001572 bspin - "Sync Tiller server version with helm client"
David Bainbridged18f4942020-04-14 16:46:13 -07001573 (set -x; helm init --upgrade --force-upgrade --wait >>"$LOG" 2>&1) >>"$LOG" 2>&1
1574 espin - "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001575 else
David Bainbridged18f4942020-04-14 16:46:13 -07001576 espin "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001577 fi
1578
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001579fi
David Bainbridged18f4942020-04-14 16:46:13 -07001580wait_for_pods - "kube-system" 1 "includes" "Waiting for Tiller POD to start" "$NO_LABEL" "tiller-deploy-.*"
David Bainbridgeddeab482020-06-24 12:43:40 -07001581
1582REPOS="onf|https://charts.opencord.org|ONF_VOLTHA \
1583 stable|https://kubernetes-charts.storage.googleapis.com|Google_Stable \
Ubuntubaab12f2020-06-30 01:08:19 +00001584 incubator|https://kubernetes-charts-incubator.storage.googleapis.com|Google_Incubator \
1585 onos|https://charts.onosproject.org|ONF_ONOS \
1586 atomix|https://charts.atomix.io|ONF_Atomix \
1587 bbsim-sadis|https://ciena.github.io/bbsim-sadis-server/charts|Custom_BBSIM_SADIS_Server \
1588 elastic|https://helm.elastic.co|Elastic \
David Bainbridgeddeab482020-06-24 12:43:40 -07001589 kiwigrid|https://kiwigrid.github.io|Fluentd-ElasticSearch"
David Bainbridgeddeab482020-06-24 12:43:40 -07001590REPO_UPDATE_REQ="no"
1591
1592bspin - "Verify Helm Repository"
1593for REPO in $REPOS; do
1594 REPO_NAME="$(echo "$REPO" | cut -d\| -f1)"
1595 REPO_URL="$(echo "$REPO" | cut -d\| -f2)"
1596 REPO_LABEL="$(echo "$REPO" | cut -d\| -f3 | sed -e 's/_/ /g')"
1597
1598 sspin - "Verify Helm Repository: $REPO_LABEL$CEOL"
1599 if [ "$(helm repo list 2>/dev/null | grep -c "$REPO_NAME" 2>/dev/null)" -eq 0 ]; then
1600 sspin - "Add Helm Repository: $REPO_LABEL$CEOL"
1601 (set -x; helm repo add "$REPO_NAME" "$REPO_URL" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1602 REPO_UPDATE_REQ="yes"
1603 fi
1604done
1605sspin - "Verify Helm Repositories$CEOL"
1606espin - "$VERIFIED"
1607
1608if [ "$REPO_UPDATE_REQ" == "yes" ] || [ "$UPDATE_HELM_REPOS" == "yes" ]; then
1609 bspin - "Update Helm repository cache"
1610 (set -x; helm repo update >>"$LOG" 2>&1) >>"$LOG" 2>&1
1611 espin - "$VERIFIED"
1612fi
1613
David Bainbridgee87067b2019-08-12 22:00:12 +00001614if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001615 NOW="$(date +%s)"
1616 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001617fi
David Bainbridgecf546362020-04-21 23:18:50 -07001618# Resolve chart versions and log them for debug/support
1619RESOLVED_VOLTHA_CHART_VERSION=$(resolve_chart_version "$VOLTHA_CHART" "$VOLTHA_CHART_VERSION")
1620RESOLVED_VOLTHA_BBSIM_CHART_VERSION=$(resolve_chart_version "$VOLTHA_BBSIM_CHART" "$VOLTHA_BBSIM_CHART_VERSION")
1621RESOLVED_VOLTHA_ADAPTER_SIM_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_SIM_CHART" "$VOLTHA_ADAPTER_SIM_CHART_VERSION")
1622RESOLVED_VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_OPEN_OLT_CHART" "$VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION")
1623RESOLVED_VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_OPEN_ONU_CHART" "$VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION")
1624RESOLVED_ONOS_CHART_VERSION=$(resolve_chart_version "$ONOS_CHART" "$ONOS_CHART_VERSION")
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001625RESOLVED_ONOS_CLASSIC_CHART_VERSION=$(resolve_chart_version "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION")
David Bainbridgecf546362020-04-21 23:18:50 -07001626RESOLVED_KAFKA_CHART_VERSION=$(resolve_chart_version "$KAFKA_CHART" "$KAFKA_CHART_VERSION")
divyadesai59f987a2020-05-27 12:11:33 +00001627RESOLVED_ELASTICSEARCH_CHART_VERSION=$(resolve_chart_version "$ELASTICSEARCH_CHART" "$ELASTICSEARCH_CHART_VERSION")
1628RESOLVED_KIBANA_CHART_VERSION=$(resolve_chart_version "$KIBANA_CHART" "$KIBANA_CHART_VERSION")
1629RESOLVED_FLUENTD_ELASTICSEARCH_CHART_VERSION=$(resolve_chart_version "$FLUENTD_ELASTICSEARCH_CHART" "$FLUENTD_ELASTICSEARCH_CHART_VERSION")
David K. Bainbridge450c15c2020-06-29 10:12:06 -07001630RESOLVED_BBSIM_SADIS_SERVER_CHART_VERSION=$(resolve_chart_version "$BBSIM_SADIS_SERVER_CHART" "$BBSIM_SADIS_SERVER_CHART_VERSION")
1631RESOLVED_RADIUS_CHART_VERSION=$(resolve_chart_version "$RADIUS_CHART" "$RADIUS_CHART_VERSION")
David Bainbridgecf546362020-04-21 23:18:50 -07001632cat <<EOV >>"$LOG"
1633Resolved helm charts and versions:
1634 $VOLTHA_CHART:$RESOLVED_VOLTHA_CHART_VERSION
1635 $VOLTHA_BBSIM_CHART:$RESOLVED_VOLTHA_BBSIM_CHART_VERSION
1636 $VOLTHA_ADAPTER_SIM_CHART:$RESOLVED_VOLTHA_ADAPTER_SIM_CHART_VERSION
1637 $VOLTHA_ADAPTER_OPEN_OLT_CHART:$RESOLVED_VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION
1638 $VOLTHA_ADAPTER_OPEN_ONU_CHART:$RESOLVED_VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION
1639 $ONOS_CHART:$RESOLVED_ONOS_CHART_VERSION
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001640 $ONOS_CLASSIC_CHART:$RESOLVED_ONOS_CLASSIC_CHART_VERSION
David Bainbridgecf546362020-04-21 23:18:50 -07001641 $KAFKA_CHART:$RESOLVED_KAFKA_CHART_VERSION
divyadesai59f987a2020-05-27 12:11:33 +00001642 $ELASTICSEARCH_CHART:$RESOLVED_ELASTICSEARCH_CHART_VERSION
1643 $KIBANA_CHART:$RESOLVED_KIBANA_CHART_VERSION
1644 $FLUENTD_ELASTICSEARCH_CHART:$RESOLVED_FLUENTD_ELASTICSEARCH_CHART_VERSION
David K. Bainbridge450c15c2020-06-29 10:12:06 -07001645 $BBSIM_SADIS_SERVER_CHART:$RESOLVED_BBSIM_SADIS_SERVER_CHART_VERSION
1646 $RADIUS_CHART:$RESOLVED_RADIUS_CHART_VERSION
David Bainbridgecf546362020-04-21 23:18:50 -07001647EOV
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001648
David Bainbridged18f4942020-04-14 16:46:13 -07001649STIME="$(date +%s)"
David Bainbridge0774b232019-08-02 06:37:19 +00001650bspin "Verify Helm values file: $NAME-values.yaml"
1651if [ ! -r "./$NAME-values.yaml" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001652 espin "$NOT_VERIFIED"
David Bainbridge0774b232019-08-02 06:37:19 +00001653 bspin - "Download Helm values file: $TYPE-values.yaml to $NAME-values.yaml $DOWNLOAD"
David Bainbridged18f4942020-04-14 16:46:13 -07001654 ERR_OUT="$(mktemp)"
serkant.uluderya4d315132020-04-15 16:25:54 -07001655 if ! (set -x; curl --fail -o "./$NAME-values.yaml" -sSL "https://raw.githubusercontent.com/opencord/kind-voltha/$VK_RELEASE/$TYPE-values.yaml" >>"$LOG" 2>"$ERR_OUT") >>"$LOG" 2>&1; then
David Bainbridged18f4942020-04-14 16:46:13 -07001656 espin - "$THEX"
1657 echo -e "${RED}${BOLD}${ERROR}ERROR: $NAME-values.yaml${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1658 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
1659 rm -rf "$ERR_OUT" "./$NAME-values.yaml"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001660 exit 1
1661 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001662 rm -rf "$ERR_OUT"
1663 espin - "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001664else
David Bainbridged18f4942020-04-14 16:46:13 -07001665 espin "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001666fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001667if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001668 NOW="$(date +%s)"
1669 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001670fi
Test Userba1e7e72019-07-10 22:27:54 +00001671
David Bainbridged18f4942020-04-14 16:46:13 -07001672STIME="$(date +%s)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001673bspin "Verify or download chart specific values files $DOWNLOAD"
1674VALUES_FILES="monkey-values.yaml"
David Bainbridged18f4942020-04-14 16:46:13 -07001675ERR_OUT="$(mktemp)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001676for i in $VALUES_FILES; do
1677 if [ ! -r ./$i ]; then
serkant.uluderya4d315132020-04-15 16:25:54 -07001678 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 -07001679 espin "$THEX"
1680 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1681 echo "ERROR: $i - $(cat "$ERR_OUT")" >>"$LOG"
1682 rm -rf "$ERR_OUT" "./$i"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001683 exit 1
1684 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001685 rm -rf "$ERR_OUT"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001686 fi
1687done
David Bainbridged18f4942020-04-14 16:46:13 -07001688rm -rf "$ERR_OUT"
1689espin "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001690if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001691 NOW="$(date +%s)"
1692 printtime $((NOW - STIME))
David Bainbridge99ac7a22019-08-31 02:26:43 +00001693fi
1694
1695if [ "$WITH_CHAOS" == "yes" ]; then
1696 bspin "Verify or clone kube-monkey helm chart $DOWNLOAD"
1697 if [ -r ./kube-monkey ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001698 espin "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001699 else
David Bainbridged18f4942020-04-14 16:46:13 -07001700 espin "$NOT_VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001701 bspin - "GIT clone kube-monkey"
David Bainbridged18f4942020-04-14 16:46:13 -07001702 (set -x; git clone https://github.com/asobti/kube-monkey kube-monkey >>"$LOG" 2>&1) >>"$LOG" 2>&1
1703 espin - "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001704 fi
1705fi
1706
Test Userba1e7e72019-07-10 22:27:54 +00001707if [ "$JUST_K8S" == "yes" ]; then
1708 echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye."
1709 echo ""
David Bainbridged18f4942020-04-14 16:46:13 -07001710 echo "Please issue the following commands in your terminal to ensure that you" | tee -a "$LOG"
1711 echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a "$LOG"
1712 echo "tools required by VOLTHA in your command path. " | tee -a "$LOG"
1713 echo "" | tee -a "$LOG"
1714 echo -en "$BOLD"
1715 if [ "$DEPLOY_K8S" == "yes" ]; then
1716 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00001717 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001718 echo "export PATH=$GOPATH/bin:\$PATH" | tee -a "$LOG"
1719 echo -en "$NORMAL"
1720 echo "" | tee -a "$LOG"
1721 echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00001722 exit 0
1723fi
1724
David Bainbridged18f4942020-04-14 16:46:13 -07001725STIME="$(date +%s)"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001726if is_in "$WITH_ONOS" "yes,legacy,classic"; then
1727 if is_in "$WITH_ONOS" "legacy"; then
1728 bspin "Verify ONOS LEGACY installed $BIRD"
1729 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^onos\$" | wc -l)" -ne 1 ]; then
1730 espin "$NOT_VERIFIED"
David Bainbridge33e56c72020-06-11 11:39:56 -07001731 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 -07001732 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
1733 else
1734 espin "$VERIFIED"
1735 fi
1736 wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for ONOS to start" "$NO_LABEL" "onos-.*"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001737
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001738 if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
1739 bspin - "Forward ONOS API port $FORWARD"
1740 kill_port_forward onos-ui
1741 port_forward "$INFRA_NS" onos-ui "$ONOS_API_PORT:8181"
1742 espin - "$VERIFIED"
1743 bspin - "Forward ONOS SSH port $FORWARD"
1744 kill_port_forward onos-ssh
1745 port_forward "$INFRA_NS" onos-ssh "$ONOS_SSH_PORT:8101"
1746 espin - "$VERIFIED"
1747 _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT"
1748 else
1749 _ONOS_API_EP="$(get_service_ep "$INFRA_NS" onos-ui)"
1750 fi
1751 elif is_in "$WITH_ONOS" "yes,classic"; then
1752 bspin "Verify ONOS CLASSIC installed $BIRD"
1753 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^onos\$" | wc -l)" -ne 1 ]; then
1754 espin "$NOT_VERIFIED"
Matteo Scandoloe0829b52020-05-08 14:23:56 -07001755 # 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 -07001756 # values value
David Bainbridgefad50732020-05-01 17:00:12 -07001757 YAML_VALUES=$(INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set replicas=$NUM_OF_ONOS --set atomix.replicas=$NUM_OF_ATOMIX" \
1758 helm_values "$INFRA_NS" onos "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION")
1759 _ONOS_REPO="$(echo "$YAML_VALUES" | yq read - images.onos.repository)"
David Bainbridgedee3f022020-06-05 07:45:13 -07001760 if [ -z "$_ONOS_REPO" ]; then
1761 _ONOS_REPO="voltha/voltha-onos"
1762 fi
David Bainbridgefad50732020-05-01 17:00:12 -07001763 _ONOS_TAG="$(echo "$YAML_VALUES" | yq read - images.onos.tag)"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001764 if [ -z "$_ONOS_TAG" ]; then
David Bainbridgedee3f022020-06-05 07:45:13 -07001765 _ONOS_TAG="$(echo "$YAML_VALUES" | yq read - defaults.image_tag)"
1766 fi
1767 if [ -z "$_ONOS_TAG" ]; then
1768 _ONOS_TAG="master"
1769 fi
1770 _ONOS_PULL_POLICY="$(echo "$YAML_VALUES" | yq read - images.onos.pullPolicy)"
1771 if [ -z "$_ONOS_PULL_POLICY" ]; then
1772 _ONOS_PULL_POLICY="$(echo "$YAML_VALUES" | yq read - defaults.image_pullPolicy)"
1773 fi
1774 if [ -z "$_ONOS_PULL_POLICY" ]; then
1775 _ONOS_PULL_POLICY="Always"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001776 fi
David Bainbridgefad50732020-05-01 17:00:12 -07001777
Matteo Scandoloe0829b52020-05-08 14:23:56 -07001778 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 -07001779 helm_install - "$INFRA_NS" onos "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION" "+onos" "$_HELM_DESC ONOS CLASSIC"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001780 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
1781 else
1782 espin "$VERIFIED"
1783 fi
1784 wait_for_pods - "$INFRA_NS" $((NUM_OF_ONOS + NUM_OF_ATOMIX)) "includes" "Waiting for ONOS CLASSIC to start" "$NO_LABEL" "onos-.*"
1785 if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
1786 bspin - "Forward ONOS API port $FORWARD"
1787 kill_port_forward onos-onos-classic-hs
1788 port_forward "$INFRA_NS" onos-onos-classic-hs "$ONOS_API_PORT:8181" "$ONOS_SSH_PORT:8101"
1789 espin - "$VERIFIED"
1790 _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT"
1791 else
1792 _ONOS_API_EP="$(get_service_ep "$INFRA_NS" onos-onos-classic-hs)"
1793 fi
1794 elif [ "$WITH_ONOS" == "micro" ]; then
1795 bspin "Verify micro-ONOS installed $BIRD"
1796 # We should never get here
1797 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Micro ONOS not currently supported${NORMAL}"
1798 exit 1
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001799 fi
David Bainbridged31d6122019-08-13 19:37:59 +00001800 bspin - "Verify or download ONOS configuration support files $DOWNLOAD"
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001801 ONOS_FILES="olt-onos-enableExtraneousRules.json onos-aaa.json \
David Bainbridge696bc632020-04-05 21:49:37 -07001802 onos-dhcpl2relay.json onos-sadis-sample.json"
David Bainbridged18f4942020-04-14 16:46:13 -07001803 (set -x; mkdir -p ./onos-files >>"$LOG" 2>&1) >>"$LOG" 2>&1
1804 ERR_OUT="$(mktemp)"
David Bainbridge2b19e832019-08-16 02:40:53 +00001805 for i in $ONOS_FILES; do
David Bainbridged18f4942020-04-14 16:46:13 -07001806 if [ ! -r "./onos-files/$i" ]; then
serkant.uluderya4d315132020-04-15 16:25:54 -07001807 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 -07001808 espin - "$THEX"
1809 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1810 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
1811 rm -rf "$ERR_OUT" "./onos-files/$i"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001812 exit 1
1813 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001814 rm -rf "$ERR_OUT"
David Bainbridged31d6122019-08-13 19:37:59 +00001815 fi
1816 done
David Bainbridged18f4942020-04-14 16:46:13 -07001817 rm -rf "$ERR_OUT"
1818 espin - "$VERIFIED"
David Bainbridge27790d62019-08-13 22:43:19 +00001819
David Bainbridged18f4942020-04-14 16:46:13 -07001820 if [ "$INSTALL_ONOS_APPS" == "yes" ]; then
David Bainbridge27790d62019-08-13 22:43:19 +00001821 bspin - "Installing custom ONOS applications"
David Bainbridged18f4942020-04-14 16:46:13 -07001822 if [ -x onos-files/onos-apps ] && [ "$(find onos-files/onos-apps -name "*.oar" 2>/dev/null | wc -l)" -gt 0 ]; then
1823 for OAR in onos-files/onos-apps/*.oar; do
David Bainbridge27790d62019-08-13 22:43:19 +00001824 sspin - "Installing custom ONOS applications - $OAR$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -07001825 override_onos_app "$OAR"
David Bainbridge27790d62019-08-13 22:43:19 +00001826 done
1827 espin - "$VERIFIED Installing custom ONOS applications$CEOL"
1828 else
1829 espin - "$NOT_VERIFIED Installing custom ONOS applications - None Found"
1830 fi
1831 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001832
David Bainbridged18f4942020-04-14 16:46:13 -07001833 if [ "$WITH_KAFKA" != "no" ]; then
David Bainbridge837e8bd2020-04-06 13:17:14 -07001834 check_onos_app_active org.opencord.kafka
David Bainbridge879439b2020-06-12 15:59:35 -07001835 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridgec7220622020-05-28 12:31:47 -07001836 _HOST=kafka.$INFRA_NS.svc
David Bainbridge76afd812020-04-06 09:53:52 -07001837 _PORT=9092
David Bainbridge879439b2020-06-12 15:59:35 -07001838 elif [ "$WITH_KAFKA" != "no" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001839 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
1840 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge837e8bd2020-04-06 13:17:14 -07001841 _PORT=${_PORT:-9092}
1842 fi
1843 push_onos_config "json" "Push ONOS Kafka Configuration" "network/configuration/apps/org.opencord.kafka" \
David Bainbridged18f4942020-04-14 16:46:13 -07001844 "$(cat <<EOJ | tr -d '[:space:]'
David Bainbridge696bc632020-04-05 21:49:37 -07001845{
1846 "kafka": {
1847 "bootstrapServers": "$_HOST:$_PORT"
1848 }
1849}
1850EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07001851)"
David Bainbridge837e8bd2020-04-06 13:17:14 -07001852 fi
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001853 check_onos_app_active org.opencord.dhcpl2relay
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001854 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 -08001855 check_onos_app_active org.opencord.olt
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001856 # FIXME use WITH_DHCP and WITH_EAPOL flags to configre OLT App
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001857 # Default value for "enableEapol" is true in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07001858 if [ "$WITH_EAPOL" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001859 push_onos_config "json" "Enable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":true}'
David Bainbridged18f4942020-04-14 16:46:13 -07001860 elif [ "$WITH_EAPOL" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001861 push_onos_config "json" "Disable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001862 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001863 # Default value for "enableDhcpOnProvisioning" is false and for "enableDhcpV4" is true in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07001864 if [ "$WITH_DHCP" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001865 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 -07001866 elif [ "$WITH_DHCP" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001867 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 -08001868 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001869 # Default value for "enableIgmpOnProvisioning" is false in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07001870 if [ "$WITH_IGMP" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001871 push_onos_config "json" "Enable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":true}'
David Bainbridged18f4942020-04-14 16:46:13 -07001872 elif [ "$WITH_IGMP" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001873 push_onos_config "json" "Disable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001874 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001875 if [ "$ENABLE_ONOS_EXTRANEOUS_RULES" == "yes" ]; then
David K. Bainbridge484d80c2020-03-05 21:44:34 -08001876 push_onos_config "file" "Enabling extraneous rules for ONOS" "configuration/org.onosproject.net.flow.impl.FlowRuleManager" "onos-files/olt-onos-enableExtraneousRules.json"
1877 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001878 if is_in "$CONFIG_SADIS" "yes,file"; then
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001879 check_onos_app_active org.opencord.sadis
Hardik Windlassb3147602020-03-09 16:59:15 +05301880 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 -07001881 elif [ "$CONFIG_SADIS" == "bbsim" ]; then
1882 push_onos_config "json" \
1883 "[optional] Push ONOS configuration for BBSIM SADIS servers" \
1884 "network/configuration/apps/org.opencord.sadis" \
David Bainbridged18f4942020-04-14 16:46:13 -07001885 "$(cat <<EOJ | tr -d '[:space:]'
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001886{
1887 "sadis": {
1888 "integration": {
David Bainbridgec7220622020-05-28 12:31:47 -07001889 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:50074/v2/subscribers/%s",
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001890 "cache": {
1891 "enabled": true,
1892 "maxsize": 50,
1893 "ttl": "PT1m"
1894 }
1895 }
1896 },
1897 "bandwidthprofile": {
1898 "integration": {
David Bainbridgec7220622020-05-28 12:31:47 -07001899 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:50074/v2/bandwidthprofiles/%s",
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001900 "cache": {
1901 "enabled": true,
1902 "maxsize": 50,
1903 "ttl": "PT1m"
1904 }
1905 }
1906 }
1907}
1908EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07001909)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001910 elif [ "$CONFIG_SADIS" == "url" ]; then
1911 push_onos_config "json" \
1912 "[optional] Push ONOS configuration for custom SADIS and Bandwidth Profile servers" \
1913 "network/configuration/apps/org.opencord.sadis" \
David Bainbridged18f4942020-04-14 16:46:13 -07001914 "$(cat <<EOJ | tr -d '[:space:]'
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001915{
1916 "sadis": {
1917 "integration": {
1918 "url": "$SADIS_SUBSCRIBERS",
1919 "cache": {
1920 "enabled": true,
1921 "maxsize": 50,
1922 "ttl": "PT1m"
1923 }
1924 }
1925 },
1926 "bandwidthprofile": {
1927 "integration": {
1928 "url": "$SADIS_BANDWIDTH_PROFILES",
1929 "cache": {
1930 "enabled": true,
1931 "maxsize": 50,
1932 "ttl": "PT1m"
1933 }
1934 }
1935 }
1936}
1937EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07001938)"
David Bainbridge2b19e832019-08-16 02:40:53 +00001939 fi
Test Userba1e7e72019-07-10 22:27:54 +00001940fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001941if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001942 NOW="$(date +%s)"
1943 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001944fi
Test Userba1e7e72019-07-10 22:27:54 +00001945
David Bainbridgec7220622020-05-28 12:31:47 -07001946if is_in "$WITH_ETCD" "yes,external"; then
David Bainbridged18f4942020-04-14 16:46:13 -07001947 STIME="$(date +%s)"
David Bainbridge76afd812020-04-06 09:53:52 -07001948 bspin "Verify external ETCD cluster $OLD_KEY"
David Bainbridge43f2df52020-06-02 15:30:54 -07001949 EXPECT="$(yq r - "etcd.replicas" <"$NAME-values.yaml")"
David Bainbridgec7220622020-05-28 12:31:47 -07001950 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^etcd\$" | wc -l)" -ne 1 ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001951 espin "$NOT_VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07001952 helm_install - "$INFRA_NS" etcd "$ETCD_CHART" "$ETCD_CHART_VERSION" etcd "$_HELM_DESC external ETCD cluster"
David Bainbridge76afd812020-04-06 09:53:52 -07001953 else
David Bainbridged18f4942020-04-14 16:46:13 -07001954 espin "$VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07001955 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001956 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for ETCD cluster to start" "$NO_LABEL" "etcd-.*"
David Bainbridge76afd812020-04-06 09:53:52 -07001957 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001958 NOW="$(date +%s)"
1959 printtime $((NOW - STIME))
David Bainbridge76afd812020-04-06 09:53:52 -07001960 fi
1961fi
1962
David Bainbridgec7220622020-05-28 12:31:47 -07001963if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridged18f4942020-04-14 16:46:13 -07001964 _TMP="$(mktemp -u)"
1965 _COUNT="$(test "$TYPE" == "minimal" && echo "1" || echo "3")"
1966 cat << EOC > "$_TMP"
David Bainbridge76afd812020-04-06 09:53:52 -07001967configurationOverrides:
1968 "default.replication.factor": $_COUNT
1969 "offsets.topic.replication.factor": $_COUNT
1970 "log.retention.hours": 4
1971 "log.message.timestamp.type": "LogAppendTime"
1972persistence:
1973 enabled: false
1974zookeeper:
1975 replicaCount: 1
1976 persistence:
1977 enabled: false
1978replicas: $_COUNT
1979EOC
David Bainbridged18f4942020-04-14 16:46:13 -07001980 STIME="$(date +%s)"
David Bainbridge76afd812020-04-06 09:53:52 -07001981 bspin "Verify external Kafka cluster $OLD_KEY"
David Bainbridged18f4942020-04-14 16:46:13 -07001982 EXPECT="$(test "$TYPE" == "minimal" && echo "2" || echo "4")"
1983 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^kafka\$" | wc -l)" -ne 1 ]; then
1984 espin "$NOT_VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07001985 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" -f $_TMP"
David Bainbridgec7220622020-05-28 12:31:47 -07001986 helm_install - "$INFRA_NS" kafka "$KAFKA_CHART" "$KAFKA_CHART_VERSION" kafka "$_HELM_DESC external Kafka cluster"
David Bainbridge76afd812020-04-06 09:53:52 -07001987 else
David Bainbridged18f4942020-04-14 16:46:13 -07001988 espin "$VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07001989 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001990 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for Kafka cluster to start" "$NO_LABEL" "kafka-.*"
David Bainbridge76afd812020-04-06 09:53:52 -07001991 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001992 NOW="$(date +%s)"
1993 printtime $((NOW - STIME))
David Bainbridge76afd812020-04-06 09:53:52 -07001994 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001995 rm -rf "$_TMP"
David Bainbridge76afd812020-04-06 09:53:52 -07001996fi
1997
David Bainbridged18f4942020-04-14 16:46:13 -07001998STIME="$(date +%s)"
David Bainbridgeed476572020-06-02 14:05:45 -07001999EXPECT=2
2000# therecanbeonlyone set hardcoded to true for backward compatibility
2001INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set therecanbeonlyone=true"
Matteo Scandolo67335f02020-04-09 11:19:53 -07002002case $WITH_ETCD in
David Bainbridge76afd812020-04-06 09:53:52 -07002003 no)
David Bainbridge76afd812020-04-06 09:53:52 -07002004 ;;
David Bainbridgec7220622020-05-28 12:31:47 -07002005 yes|external)
2006 _HOST="etcd.$INFRA_NS.svc"
David Bainbridge76afd812020-04-06 09:53:52 -07002007 _PORT=2379
2008 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridge76afd812020-04-06 09:53:52 -07002009 ;;
2010 *)
David Bainbridged18f4942020-04-14 16:46:13 -07002011 _HOST="$(echo "$WITH_ETCD" | cut -d: -f1)"
2012 _PORT="$(echo "$WITH_ETCD" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07002013 _PORT=${_PORT:-2379}
David Bainbridgec7220622020-05-28 12:31:47 -07002014 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridge76afd812020-04-06 09:53:52 -07002015 ;;
2016esac
2017case $WITH_KAFKA in
2018 no)
David Bainbridge76afd812020-04-06 09:53:52 -07002019 ;;
David Bainbridgec7220622020-05-28 12:31:47 -07002020 yes|external)
2021 _HOST=kafka.$INFRA_NS.svc
David Bainbridge76afd812020-04-06 09:53:52 -07002022 _PORT=9092
2023 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"
David Bainbridge76afd812020-04-06 09:53:52 -07002024 ;;
2025 *)
David Bainbridged18f4942020-04-14 16:46:13 -07002026 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
2027 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07002028 _PORT=${_PORT:-9092}
David Bainbridgec7220622020-05-28 12:31:47 -07002029 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"
David Bainbridge76afd812020-04-06 09:53:52 -07002030 ;;
2031esac
2032
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002033if is_in "$WITH_ONOS" "legacy"; then
David Bainbridgec7220622020-05-28 12:31:47 -07002034 _HOST=onos-openflow.$INFRA_NS.svc
David Bainbridge76afd812020-04-06 09:53:52 -07002035 _PORT=6653
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002036elif is_in "$WITH_ONOS" "yes,classic"; then
David Bainbridgec7220622020-05-28 12:31:47 -07002037 _HOST=onos-onos-classic-hs.$INFRA_NS.svc
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002038 _PORT=6653
David Bainbridged18f4942020-04-14 16:46:13 -07002039elif [ "$WITH_ONOS" != "no" ]; then
2040 _HOST="$(echo "$WITH_ONOS" | cut -d: -f1)"
2041 _PORT="$(echo "$WITH_ONOS" | cut -s -d: -f2)"
David Bainbridge76afd812020-04-06 09:53:52 -07002042 _PORT=${_PORT:-6653}
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002043fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002044
David Bainbridgecf546362020-04-21 23:18:50 -07002045compare_versions "$RESOLVED_VOLTHA_CHART_VERSION" 2.4.2
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002046if [ "$?" == "1" ]; then
2047 # voltha chart > 2.4.2 uses list of controllers
David Bainbridgee4d11ca2020-05-08 10:21:10 -07002048 for NUM in $(seq 0 $((NUM_OF_ONOS-1))); do
David Bainbridgec7220622020-05-28 12:31:47 -07002049 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"
David Bainbridgee4d11ca2020-05-08 10:21:10 -07002050 done
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002051else
2052 # voltha chart <= 2.4.2 uses single controller
David Bainbridge76afd812020-04-06 09:53:52 -07002053 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.controller.service=$_HOST --set services.controller.port=$_PORT"
David Bainbridge696bc632020-04-05 21:49:37 -07002054fi
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002055
Test Userb5712372019-07-03 21:52:17 +00002056bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
David Bainbridged18f4942020-04-14 16:46:13 -07002057if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$VOLTHA_NS" "^voltha\$" | wc -l)" -ne 1 ]; then
2058 espin "$NOT_VERIFIED"
David Bainbridgea965ca22020-06-09 17:45:04 -07002059 helm_install - "$VOLTHA_NS" voltha "$VOLTHA_CHART" "$VOLTHA_CHART_VERSION" "+voltha" "$_HELM_DESC VOLTHA Core"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002060else
David Bainbridged18f4942020-04-14 16:46:13 -07002061 espin "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002062fi
David Bainbridge696bc632020-04-05 21:49:37 -07002063INTERNAL_EXTRA_HELM_INSTALL_ARGS=
Test Userba1e7e72019-07-10 22:27:54 +00002064
David Bainbridge90fd8e32019-08-21 23:32:47 +00002065VOLTHA="voltha-ofagent-.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002066 rw-core.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002067 voltha-zookeeper-.*"
David Bainbridged18f4942020-04-14 16:46:13 -07002068wait_for_pods - "$VOLTHA_NS" "$EXPECT" "includes" "Waiting for VOLTHA Core to start" "$NO_LABEL" "$VOLTHA"
David Bainbridgee87067b2019-08-12 22:00:12 +00002069if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002070 NOW="$(date +%s)"
2071 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002072fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002073
David Bainbridge46505fb2019-10-01 21:13:20 +00002074if [ "$WITH_ADAPTERS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002075 STIME="$(date +%s)"
David Bainbridge46505fb2019-10-01 21:13:20 +00002076 EXPECT=0
David Bainbridgec7220622020-05-28 12:31:47 -07002077 if is_in "$WITH_ETCD" "yes,external"; then
2078 _HOST=etcd.$INFRA_NS.svc
David Bainbridge3517f6c2020-04-08 12:14:08 -07002079 _PORT=2379
2080 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridged18f4942020-04-14 16:46:13 -07002081 elif [ "$WITH_ETCD" != "no" ]; then
2082 _HOST="$(echo "$WITH_ETCD" | cut -d: -f1)"
2083 _PORT="$(echo "$WITH_ETCD" | cut -s -d: -f2)"
David Bainbridge3517f6c2020-04-08 12:14:08 -07002084 _PORT=${_PORT:-2379}
2085 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridge696bc632020-04-05 21:49:37 -07002086 fi
David Bainbridgec7220622020-05-28 12:31:47 -07002087 if is_in "$WITH_KAFKA" "yes,external"; then
2088 _HOST=kafka.$INFRA_NS.svc
David Bainbridge3517f6c2020-04-08 12:14:08 -07002089 _PORT=9092
2090 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"
David Bainbridged18f4942020-04-14 16:46:13 -07002091 elif [ "$WITH_KAFKA" != "no" ]; then
2092 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
2093 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge3517f6c2020-04-08 12:14:08 -07002094 _PORT=${_PORT:-9092}
2095 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"
David Bainbridge696bc632020-04-05 21:49:37 -07002096 fi
David Bainbridge46505fb2019-10-01 21:13:20 +00002097 echo -e "Verify Adapters $PLUG"
2098 if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then
2099 bspin - "Verify Simulated Adapters installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002100 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$ADAPTER_NS" "^sim\$" | wc -l)" -ne 1 ]; then
2101 espin - "$NOT_VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002102 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 +00002103 else
David Bainbridged18f4942020-04-14 16:46:13 -07002104 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00002105 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002106 EXPECT="$((EXPECT + 2))"
David Bainbridge46505fb2019-10-01 21:13:20 +00002107 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07002108
David Bainbridge46505fb2019-10-01 21:13:20 +00002109 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
2110 bspin - "Verify OpenOLT Adapter installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002111 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$ADAPTER_NS" "^open-olt\$" | wc -l)" -ne 1 ]; then
2112 espin - "$NOT_VERIFIED"
David Bainbridgea965ca22020-06-09 17:45:04 -07002113 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 +00002114 else
David Bainbridged18f4942020-04-14 16:46:13 -07002115 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00002116 fi
Matteo Scandolo67335f02020-04-09 11:19:53 -07002117 EXPECT="$((EXPECT + 1))"
David Bainbridge46505fb2019-10-01 21:13:20 +00002118 bspin - "Verify OpenONU Adapter installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002119 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$ADAPTER_NS" "^open-onu\$" | wc -l)" -ne 1 ]; then
Matteo Scandolo67335f02020-04-09 11:19:53 -07002120 _ORIGINAL_EXTRA_HELM_INSTALL_ARGS="$INTERNAL_EXTRA_HELM_INSTALL_ARGS"
2121 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set replicas.adapter_open_onu=$NUM_OF_OPENONU"
Girish Gowdra4cc5d8b2020-06-11 17:12:00 -07002122 if [ "$WITH_INCREMENTAL_EVTO_UPDATE" == "yes" ]; then
Girish Gowdra1c7ad4c2020-06-26 13:35:16 -07002123 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set defaults.incremental_evto_update=true"
Girish Gowdra4cc5d8b2020-06-11 17:12:00 -07002124 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002125 espin - "$NOT_VERIFIED"
David Bainbridgea965ca22020-06-09 17:45:04 -07002126 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 -07002127 INTERNAL_EXTRA_HELM_INSTALL_ARGS="$_ORIGINAL_EXTRA_HELM_INSTALL_ARGS"
David Bainbridge46505fb2019-10-01 21:13:20 +00002128 else
David Bainbridged18f4942020-04-14 16:46:13 -07002129 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00002130 fi
Matteo Scandolo67335f02020-04-09 11:19:53 -07002131 EXPECT=$((EXPECT + NUM_OF_OPENONU))
David Bainbridge46505fb2019-10-01 21:13:20 +00002132 fi
David Bainbridge696bc632020-04-05 21:49:37 -07002133 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07002134
David Bainbridge46505fb2019-10-01 21:13:20 +00002135 ADAPTERS="adapter-.*"
David Bainbridged18f4942020-04-14 16:46:13 -07002136 wait_for_pods - "$ADAPTER_NS" "$EXPECT" "includes" "Waiting for adapters to start" "$NO_LABEL" "$ADAPTERS"
David Bainbridge46505fb2019-10-01 21:13:20 +00002137 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002138 NOW="$(date +%s)"
2139 printtime $((NOW - STIME))
David Bainbridge46505fb2019-10-01 21:13:20 +00002140 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00002141fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002142
David Bainbridged18f4942020-04-14 16:46:13 -07002143if [ "$WITH_BBSIM" == "yes" ]; then
2144 STIME="$(date +%s)"
Test User7d866122019-07-09 17:52:35 +00002145 echo -e "Verify BBSIM $PLUG"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002146 bspin - "Verify BBSIM Installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002147 for instance in $(seq 0 $((NUM_OF_BBSIM-1))); do
Matteo Scandoloc2eb0672020-05-01 14:43:15 -07002148
2149 if [ "$LEGACY_BBSIM_INDEX" == "yes" ]; then
2150 if [ "$instance" -eq 0 ]; then
2151 instance_num=""
2152 else
2153 instance_num=$instance
2154 fi
David K. Bainbridge43422402020-03-06 07:41:22 -08002155 else
2156 instance_num=$instance
2157 fi
Matteo Scandoloc2eb0672020-05-01 14:43:15 -07002158
2159
David Bainbridged18f4942020-04-14 16:46:13 -07002160 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$BBSIM_NS" "^bbsim${instance_num}\$" | wc -l)" -ne 1 ]; then
2161 espin - "$NOT_VERIFIED"
2162 S_TAG="$((900+instance))"
Matteo Scandolo5a149572020-04-01 10:14:57 -07002163 INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set olt_id=$instance,s_tag=$S_TAG"
David Bainbridged9329af2020-05-01 11:58:52 -07002164 if [ "$WITH_EAPOL" == "yes" ]; then
2165 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set auth=true"
2166 else
2167 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set auth=false"
2168 fi
2169 if [ "$WITH_DHCP" == "yes" ]; then
2170 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set dhcp=true"
2171 else
2172 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set dhcp=false"
2173 fi
David Bainbridge33e56c72020-06-11 11:39:56 -07002174 if is_in "$WITH_KAFKA" "yes,external"; then
2175 _HOST=kafka.$INFRA_NS.svc
2176 _PORT=9092
2177 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafkaAddress=$_HOST:$_PORT"
2178 elif [ "$WITH_KAFKA" != "no" ]; then
2179 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
2180 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
2181 _PORT=${_PORT:-9092}
2182 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafkaAddress=$_HOST:$_PORT"
2183 fi
2184 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 -07002185 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
David K. Bainbridge43422402020-03-06 07:41:22 -08002186 else
David Bainbridged18f4942020-04-14 16:46:13 -07002187 espin - "$VERIFIED"
David K. Bainbridge43422402020-03-06 07:41:22 -08002188 fi
2189 done
David Bainbridged18f4942020-04-14 16:46:13 -07002190 wait_for_pods - "$BBSIM_NS" "$NUM_OF_BBSIM" "includes" "Waiting for BBSIM to start" "$BBSIM_LABEL" "bbsim*"
David Bainbridgee87067b2019-08-12 22:00:12 +00002191 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002192 NOW="$(date +%s)"
2193 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002194 fi
Test User7d866122019-07-09 17:52:35 +00002195fi
2196
divyadesai59f987a2020-05-27 12:11:33 +00002197if [ "$WITH_EFK" == "yes" ]; then
2198 STIME="$(date +%s)"
2199 echo -e "Verify EFK $PLUG"
2200 bspin - "Verify EFK Installed"
2201 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^elasticsearch\$" | wc -l)" -ne 1 ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^kibana\$" | wc -l)" -ne 1 ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^fluentd\$" | wc -l)" -ne 1 ]; then
2202 espin - "$NOT_VERIFIED"
2203 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^elasticsearch\$" | wc -l)" -ne 1 ]; then
2204 helm_install - "$INFRA_NS" elasticsearch "$ELASTICSEARCH_CHART" "$ELASTICSEARCH_CHART_VERSION" elasticsearch "$_HELM_DESC elasticsearch"
2205 fi
2206 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^kibana\$" | wc -l)" -ne 1 ]; then
2207 helm_install - "$INFRA_NS" kibana "$KIBANA_CHART" "$KIBANA_CHART_VERSION" kibana "$_HELM_DESC kibana"
2208 fi
2209 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^fluentd\$" | wc -l)" -ne 1 ]; then
2210 helm_install - "$INFRA_NS" fluentd "$FLUENTD_ELASTICSEARCH_CHART" "$FLUENTD_ELASTICSEARCH_CHART_VERSION" fluentd-elasticsearch "$_HELM_DESC fluentd-elasticsearch"
2211 fi
2212 else
2213 espin - "$VERIFIED"
2214 fi
2215 EXPECT=2 # for elastic and kibana
2216 if [ "$TYPE" == "minimal" ]; then
2217 EXPECT=$((EXPECT + 2)) # for fluentd on worker 2 worker nodes
2218 else
2219 EXPECT=$((EXPECT + 3)) # for fluentd on worker 3 worker nodes
2220 fi
2221 if [ "$SCHEDULE_ON_CONTROL_NODES" == "yes" ]; then
2222 EXPECT=$((EXPECT + 1)) # for fluentd on the control plan node
2223 fi
2224
2225 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for EFK to start" "$NO_LABEL" "fluentd-* elasticsearch-* kibana-*"
2226 if [ "$WITH_TIMINGS" == "yes" ]; then
2227 NOW="$(date +%s)"
2228 printtime $((NOW - STIME))
2229 fi
2230fi
2231
David Bainbridge309099c2020-05-05 08:47:29 -07002232if [ "$CONFIG_SADIS" == "external" ]; then
2233 STIME="$(date +%s)"
2234 echo -e "Verify BBSIM SADIS Service $PLUG"
2235 bspin - "Verify required configmap"
2236 (set -x; kubectl -n "$BBSIM_NS" delete --ignore-not-found configmap kube-config >>"$LOG" 2>&1) >>"$LOG" 2>&1
2237 (set -x; kubectl -n "$BBSIM_NS" create configmap kube-config "--from-file=kube_config=$KUBECONFIG" >>"$LOG" 2>&1) >>"$LOG" 2>&1
2238 espin - "$VERIFIED"
2239 bspin - "Verify BBSIM SADIS Service Installed"
divyadesai59f987a2020-05-27 12:11:33 +00002240 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$BBSIM_NS" "^bbsim-sadis-server\$" | wc -l)" -ne 1 ]; then
David Bainbridge309099c2020-05-05 08:47:29 -07002241 espin - "$NOT_VERIFIED"
David Bainbridge879439b2020-06-12 15:59:35 -07002242 helm_install - "$BBSIM_NS" bbsim-sadis-server "$BBSIM_SADIS_SERVER_CHART" "$BBSIM_SADIS_SERVER_CHART_VERSION" "+sadis" "$_HELM_DESC BBSIM SADIS Server"
David Bainbridge309099c2020-05-05 08:47:29 -07002243 else
2244 espin - "$VERIFIED"
2245 fi
2246 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 +00002247
2248 if [ "$WITH_ONOS" == "yes" ]; then
2249 if kubectl get -n "$BBSIM_NS" svc/bbsim-sadis-server-bbsim-sadis-server >/dev/null 2>&1; then
2250 BBSIM_SADIS_SVC="bbsim-sadis-server-bbsim-sadis-server"
2251 else
2252 BBSIM_SADIS_SVC="bbsim-sadis-server"
2253 fi
2254 push_onos_config "json" \
2255 "[optional] Push ONOS configuration for custom SADIS and Bandwidth Profile servers" \
2256 "network/configuration/apps/org.opencord.sadis" \
2257 "$(cat <<EOJ | tr -d '[:space:]'
2258{
2259 "sadis": {
2260 "integration": {
2261 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:58080/subscribers/%s",
2262 "cache": {
2263 "enabled": true,
2264 "maxsize": 50,
2265 "ttl": "PT1m"
2266 }
2267 }
2268 },
2269 "bandwidthprofile": {
2270 "integration": {
2271 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:58080/profiles/%s",
2272 "cache": {
2273 "enabled": true,
2274 "maxsize": 50,
2275 "ttl": "PT1m"
2276 }
2277 }
2278 }
2279}
2280EOJ
2281)"
2282 fi
David Bainbridge309099c2020-05-05 08:47:29 -07002283 if [ "$WITH_TIMINGS" == "yes" ]; then
2284 NOW="$(date +%s)"
2285 printtime $((NOW - STIME))
2286 fi
2287fi
2288
David Bainbridged18f4942020-04-14 16:46:13 -07002289if [ "$WITH_RADIUS" == "yes" ]; then
2290 STIME="$(date +%s)"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002291 echo -e "Verify RADIUS $LOCK"
2292 bspin - "Verify RADIUS Installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002293 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^radius\$" | wc -l)" -ne 1 ]; then
2294 espin - "$NOT_VERIFIED"
David Bainbridge879439b2020-06-12 15:59:35 -07002295 helm_install - "$INFRA_NS" radius "$RADIUS_CHART" "$RADIUS_CHART_VERSION" "+radius" "$_HELM_DESC RADIUS"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002296 else
David Bainbridged18f4942020-04-14 16:46:13 -07002297 espin - "$VERIFIED"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002298 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002299 wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for RADIUS to start" "$NO_LABEL" "radius-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00002300 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002301 NOW="$(date +%s)"
2302 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002303 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002304fi
2305
David Bainbridged18f4942020-04-14 16:46:13 -07002306if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
2307 STIME="$(date +%s)"
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002308 bspin - "Forward VOLTHA API port $FORWARD"
David Bainbridge1d2c5842020-06-03 15:29:07 -07002309 kill_port_forward voltha-api voltha-voltha-api
2310 VOLTHA_PREFIX=
2311 if kubectl get -n "$VOLTHA_NS" "svc/voltha-voltha-api" >/dev/null 2>&1; then
2312 VOLTHA_PREFIX="voltha-"
2313 fi
2314
2315 port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-api" "$VOLTHA_API_PORT:55555"
David Bainbridged18f4942020-04-14 16:46:13 -07002316 espin - "$VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002317 if is_in "$WITH_ETCD" "yes,external"; then
David Bainbridge696bc632020-04-05 21:49:37 -07002318 bspin - "Forward VOLTHA ETCD port $FORWARD"
David Bainbridgec7220622020-05-28 12:31:47 -07002319 kill_port_forward "etcd"
2320 port_forward "$INFRA_NS" "etcd" "$VOLTHA_ETCD_PORT:2379"
David Bainbridged18f4942020-04-14 16:46:13 -07002321 espin - "$VERIFIED"
David Bainbridge696bc632020-04-05 21:49:37 -07002322 fi
David Bainbridgec7220622020-05-28 12:31:47 -07002323 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridge696bc632020-04-05 21:49:37 -07002324 bspin - "Forward VOLTHA Kafka port $FORWARD"
David Bainbridgec7220622020-05-28 12:31:47 -07002325 kill_port_forward "kafka"
2326 port_forward "$INFRA_NS" kafka "$VOLTHA_KAFKA_PORT:9092"
David Bainbridged18f4942020-04-14 16:46:13 -07002327 espin - "$VERIFIED"
David Bainbridge696bc632020-04-05 21:49:37 -07002328 fi
divyadesai59f987a2020-05-27 12:11:33 +00002329 if [ "$WITH_EFK" == "yes" ]; then
2330 bspin - "Forward EFK port $FORWARD"
2331 kill_port_forward elasticsearch-master
2332 kill_port_forward kibana-kibana
2333 port_forward "$INFRA_NS" elasticsearch-master "$ELASTICSEARCH_PORT:9200"
2334 port_forward "$INFRA_NS" kibana-kibana "$KIBANA_PORT:5601"
2335 espin - "$VERIFIED"
2336 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -07002337 if [ "$WITH_PPROF" == "yes" ]; then
David Bainbridge1d2c5842020-06-03 15:29:07 -07002338 VOLTHA_OPENOLT_PREFIX=
2339 if kubectl get -n "$ADAPTER_NS" "svc/open-olt-adapter-open-olt-profiler" >/dev/null 2>&1; then
2340 VOLTHA_OPENOLT_PREFIX="open-olt-"
2341 fi
David Bainbridge879439b2020-06-12 15:59:35 -07002342 bspin - "Forward PProf ports port $FORWARD"
2343 kill_port_forward voltha-rw-core-profiler voltha-voltha-rw-core-profiler
2344 kill_port_forward adapter-open-olt-profiler open-olt-adapter-open-olt-profiler
2345 kill_port_forward voltha-of-agent-profiler voltha-voltha-of-agent-profiler
2346 port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-rw-core-profiler" "$VOLTHA_PPROF_PORT:6060"
2347 port_forward "$ADAPTER_NS" "${VOLTHA_OPENOLT_PREFIX}adapter-open-olt-profiler" "$OPENOLT_PPROF_PORT:6060"
2348 port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-of-agent-profiler" "$OFAGENT_PPROF_PORT:6060"
2349 espin - "$VERIFIED"
Matteo Scandoloefee0432020-05-05 13:56:20 -07002350 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002351 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002352 NOW="$(date +%s)"
2353 printtime $((NOW - STIME))
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002354 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00002355fi
Test User3d7ad8e2019-07-03 06:15:44 +00002356
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002357if is_in "$WITH_ONOS" "yes,legacy,classic" && [ "$WITH_RADIUS" != "no" ]; then
David Bainbridge879439b2020-06-12 15:59:35 -07002358 SVC_NAME=radius
2359 if kubectl get -n "$INFRA_NS" "svc/radius-freeradius" >/dev/null 2>&1; then
2360 SVC_NAME="radius-freeradius"
2361 fi
2362 _HOST="$SVC_NAME.$INFRA_NS.svc"
David Bainbridge696bc632020-04-05 21:49:37 -07002363 _PORT=1812
David Bainbridged18f4942020-04-14 16:46:13 -07002364 if [ "$WITH_RADIUS" != "yes" ]; then
2365 _HOST="$(echo "$WITH_RADIUS" | cut -d: -f1)"
2366 _PORT="$(echo "$WITH_RADIUS" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07002367 _PORT=${_PORT:-1812}
2368 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002369 bspin "Configure ONOS RADIUS Connection $GEAR"
David Bainbridged18f4942020-04-14 16:46:13 -07002370 (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
2371 espin "$VERIFIED"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002372fi
2373
divyadesai59f987a2020-05-27 12:11:33 +00002374if [ "$WITH_EFK" == "yes" ]; then
2375 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"
2376# fi
2377fi
2378
David Bainbridge99ac7a22019-08-31 02:26:43 +00002379if [ "$WITH_CHAOS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002380 STIME="$(date +%s)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002381 echo -e "Verify kube-monkey $LOCK"
2382 bspin - "Verify kube-monkey Installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002383 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace kube-monkey "^monkey\$" | wc -l)" -ne 1 ]; then
2384 espin - "$NOT_VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002385 helm_install - kube-monkey monkey ./kube-monkey/helm/kubemonkey latest - "$_HELM_DESC Chaos Monkey"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002386 else
David Bainbridged18f4942020-04-14 16:46:13 -07002387 espin - "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002388 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002389 wait_for_pods - "kube-monkey" 1 "includes" "Waiting for Chaos to start" "$NO_LABEL" "monkey-.*"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002390 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002391 NOW="$(date +%s)"
2392 printtime $((NOW - STIME))
David Bainbridge99ac7a22019-08-31 02:26:43 +00002393 fi
2394fi
2395
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002396bspin "Create voltctl configuration file"
David Bainbridged18f4942020-04-14 16:46:13 -07002397(set -x; mkdir -p "$HOME/.volt" >>"$LOG" 2>&1) >>"$LOG" 2>&1
2398MIN_VC_VERSION="$(echo -e "1.0.15\n$VC_VERSION" | sort -V | head -1)"
2399if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002400 KAFKA_FLAG="-k localhost:$VOLTHA_KAFKA_PORT"
2401 SERVER_FLAG="-s localhost:$VOLTHA_API_PORT"
2402 ETCD_FLAG=
2403 if [ "$MIN_VC_VERSION" == "1.0.15" ]; then
2404 ETCD_FLAG="-e localhost:$VOLTHA_ETCD_PORT"
2405 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002406else
David Bainbridgec7220622020-05-28 12:31:47 -07002407 KAFKA_FLAG="-k $(get_service_ep "$INFRA_NS" kafka)"
David Bainbridged18f4942020-04-14 16:46:13 -07002408 SERVER_FLAG="-s $(get_service_ep "$VOLTHA_NS" voltha-api)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002409 ETCD_FLAG=
2410 if [ "$MIN_VC_VERSION" == "1.0.15" ]; then
David Bainbridgec7220622020-05-28 12:31:47 -07002411 ETCD_FLAG="-e $(get_service_ep "$INFRA_NS" etcd)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002412 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002413fi
David Bainbridgea965ca22020-06-09 17:45:04 -07002414CMD=("voltctl $KAFKA_FLAG $SERVER_FLAG $ETCD_FLAG config")
David Bainbridged18f4942020-04-14 16:46:13 -07002415(set -x; ${CMD[*]} > "$HOME/.volt/config-$NAME" 2>>"$LOG") >>"$LOG" 2>&1
David Bainbridgea965ca22020-06-09 17:45:04 -07002416#(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 -07002417espin "$VERIFIED"
Test User08ebbd92019-07-03 17:15:39 +00002418
David Bainbridge0774b232019-08-02 06:37:19 +00002419if [ ! -f "$NAME-env.sh" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002420 touch "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002421fi
2422
David Bainbridge596f30d2019-07-30 17:07:59 +00002423for O in $ALL_OPTIONS; do
David Bainbridged18f4942020-04-14 16:46:13 -07002424 VAL="$(eval echo "\$$O")"
2425 if [ -n "$VAL" ] && [ "$(grep -c "^export $O=" "$NAME-env.sh")" -eq 0 ]; then
2426 echo "export $O=\"$(eval echo "\$$O")\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002427 fi
2428done
2429
David Bainbridged18f4942020-04-14 16:46:13 -07002430if [ "$DEPLOY_K8S" == "yes" ] && [ "$(grep -c "^export KUBECONFIG=" "$NAME-env.sh")" -eq 0 ]; then
2431 echo "export KUBECONFIG=\"$(./bin/kind get kubeconfig-path "--name=voltha-$NAME")\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002432fi
2433
David Bainbridged18f4942020-04-14 16:46:13 -07002434if [ "$(grep -c "^export VOLTCONFIG=" "$NAME-env.sh")" -eq 0 ]; then
2435 echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002436fi
2437
David Bainbridged18f4942020-04-14 16:46:13 -07002438if [ "$(grep -c "^export PATH=" "$NAME-env.sh")" -eq 0 ]; then
2439 echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002440fi
2441
Test User7d866122019-07-09 17:52:35 +00002442echo ""
David Bainbridged18f4942020-04-14 16:46:13 -07002443echo "Please issue the following commands in your terminal to ensure that you" | tee -a "$LOG"
2444echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a "$LOG"
2445echo "tools required by VOLTHA in your command path. " | tee -a "$LOG"
2446echo "" | tee -a "$LOG"
2447echo -en "$BOLD"
2448if [ "$DEPLOY_K8S" == "yes" ]; then
2449 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00002450fi
David Bainbridged18f4942020-04-14 16:46:13 -07002451echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" | tee -a "$LOG"
2452echo "export PATH=$GOPATH/bin:\$PATH" | tee -a "$LOG"
2453echo -en "$NORMAL"
2454echo "" | tee -a "$LOG"
2455echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a "$LOG"
Test User08ebbd92019-07-03 17:15:39 +00002456
David Bainbridge712afb82019-08-14 19:55:58 +00002457if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002458 NOW="$(date +%s)"
2459 echo -e "$CLOCK ${BOLD}TOTAL: $(duration $((NOW - TOTAL_START_TIME)))${NORMAL}"
David Bainbridge712afb82019-08-14 19:55:58 +00002460fi