blob: eb02a2adc09194e00e5a98ead35afb846e008998 [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}
125ONOS_CLASSIC_CHART_VERSION=${ONOS_CHART_VERSION:-latest}
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
Test Userb5712372019-07-03 21:52:17 +00001545 bspin - "Add Google Incubator repository to Helm"
David Bainbridged18f4942020-04-14 16:46:13 -07001546 (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>"$LOG" 2>&1) >>"$LOG" 2>&1
1547 espin - "$VERIFIED"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001548
Test Userba1e7e72019-07-10 22:27:54 +00001549 # HACK (sort-of) - the config for tiller is about to be patched, which will
1550 # cause the tiller pod to be recreated. This can sometimes cause a timing
1551 # issue with the "wait_for_pods" call on tiller as it may incorrectly
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001552 # identify the running/ready tiller pod that is soon to be terminated as
Test Userba1e7e72019-07-10 22:27:54 +00001553 # what it is waiting for. To avoid this issue we do a clean scale down and
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001554 # scale up of the pod so the script controlls when it should be expecting
Test Userba1e7e72019-07-10 22:27:54 +00001555 # things
David Bainbridged18f4942020-04-14 16:46:13 -07001556 (set -x; kubectl -n kube-system scale deploy tiller-deploy --replicas=0 >>"$LOG" 2>&1) >>"$LOG" 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001557
Test Userb5712372019-07-03 21:52:17 +00001558 bspin - "Add Google Stable repository to Helm"
David Bainbridged18f4942020-04-14 16:46:13 -07001559 (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>"$LOG" 2>&1) >>"$LOG" 2>&1
1560 espin - "$VERIFIED"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001561 bspin - "Add ONF VOLTHA repository to Helm"
David Bainbridged18f4942020-04-14 16:46:13 -07001562 (set -x; helm repo add onf https://charts.opencord.org >>"$LOG" 2>&1) >>"$LOG" 2>&1
1563 espin - "$VERIFIED"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001564 bspin - "Add ONF ONOS repository to Helm"
1565 (set -x; helm repo add onos https://charts.onosproject.org >>"$LOG" 2>&1) >>"$LOG" 2>&1
1566 espin - "$VERIFIED"
1567 bspin - "Add ONF Atomix repository to Helm"
1568 (set -x; helm repo add atomix https://charts.atomix.io >>"$LOG" 2>&1) >>"$LOG" 2>&1
1569 espin - "$VERIFIED"
David Bainbridge309099c2020-05-05 08:47:29 -07001570 bspin - "Add Custom BBSIM SADIS Server repository to Helm"
1571 (set -x; helm repo add bbsim-sadis https://ciena.github.io/bbsim-sadis-server/charts >>"$LOG" 2>&1) >>"$LOG" 2>&1
1572 espin - "$VERIFIED"
divyadesai59f987a2020-05-27 12:11:33 +00001573 bspin - "Add Elastic repository to Helm"
1574 (set -x; helm repo add elastic https://helm.elastic.co >>"$LOG" 2>&1) >>"$LOG" 2>&1
1575 espin - "$VERIFIED"
1576 bspin - "Add Fluentd-ElasticSearch repository to Helm"
1577 (set -x; helm repo add kiwigrid https://kiwigrid.github.io >>"$LOG" 2>&1) >>"$LOG" 2>&1
1578 espin - "$VERIFIED"
Test Userb5712372019-07-03 21:52:17 +00001579 bspin - "Update Helm repository cache"
David Bainbridged18f4942020-04-14 16:46:13 -07001580 (set -x; helm repo update >>"$LOG" 2>&1) >>"$LOG" 2>&1
1581 espin - "$VERIFIED"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001582
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001583 # Create and k8s service account so that Helm can create pods
Test Userb5712372019-07-03 21:52:17 +00001584 bspin - "Create Tiller ServiceAccount"
David Bainbridged18f4942020-04-14 16:46:13 -07001585 (set -x; kubectl create serviceaccount --namespace kube-system tiller >>"$LOG" 2>&1) >>"$LOG" 2>&1
1586 espin - "$VERIFIED"
Test Userb5712372019-07-03 21:52:17 +00001587 bspin - "Create Tiller ClusterRoleBinding"
David Bainbridged18f4942020-04-14 16:46:13 -07001588 (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>"$LOG" 2>&1) >>"$LOG" 2>&1
1589 espin - "$VERIFIED"
Test Userb5712372019-07-03 21:52:17 +00001590 bspin - "Update Tiller Manifest"
David Bainbridged18f4942020-04-14 16:46:13 -07001591 (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 +00001592
1593 # HACK (sort-of) - part to, spin it back up
David Bainbridged18f4942020-04-14 16:46:13 -07001594 (set -x; kubectl -n kube-system scale deploy tiller-deploy --replicas=1 >>"$LOG" 2>&1) >>"$LOG" 2>&1
1595 espin - "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001596else
David Bainbridged18f4942020-04-14 16:46:13 -07001597 if [ "$(helm version -s --template '{{.Server.SemVer}}')" != "$HELM_VERSION" ]; then
1598 espin "$NOT_VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001599 bspin - "Sync Tiller server version with helm client"
David Bainbridged18f4942020-04-14 16:46:13 -07001600 (set -x; helm init --upgrade --force-upgrade --wait >>"$LOG" 2>&1) >>"$LOG" 2>&1
1601 espin - "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001602 else
David Bainbridged18f4942020-04-14 16:46:13 -07001603 espin "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001604 fi
1605
David Bainbridge46505fb2019-10-01 21:13:20 +00001606 if [ "$UPDATE_HELM_REPOS" == "yes" ]; then
1607 bspin - "Update Helm repository cache"
David Bainbridged18f4942020-04-14 16:46:13 -07001608 (set -x; helm repo update >>"$LOG" 2>&1) >>"$LOG" 2>&1
1609 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00001610 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001611fi
David Bainbridged18f4942020-04-14 16:46:13 -07001612wait_for_pods - "kube-system" 1 "includes" "Waiting for Tiller POD to start" "$NO_LABEL" "tiller-deploy-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001613if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001614 NOW="$(date +%s)"
1615 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001616fi
David Bainbridgecf546362020-04-21 23:18:50 -07001617# Resolve chart versions and log them for debug/support
1618RESOLVED_VOLTHA_CHART_VERSION=$(resolve_chart_version "$VOLTHA_CHART" "$VOLTHA_CHART_VERSION")
1619RESOLVED_VOLTHA_BBSIM_CHART_VERSION=$(resolve_chart_version "$VOLTHA_BBSIM_CHART" "$VOLTHA_BBSIM_CHART_VERSION")
1620RESOLVED_VOLTHA_ADAPTER_SIM_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_SIM_CHART" "$VOLTHA_ADAPTER_SIM_CHART_VERSION")
1621RESOLVED_VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_OPEN_OLT_CHART" "$VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION")
1622RESOLVED_VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_OPEN_ONU_CHART" "$VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION")
1623RESOLVED_ONOS_CHART_VERSION=$(resolve_chart_version "$ONOS_CHART" "$ONOS_CHART_VERSION")
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001624RESOLVED_ONOS_CLASSIC_CHART_VERSION=$(resolve_chart_version "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION")
David Bainbridgecf546362020-04-21 23:18:50 -07001625RESOLVED_KAFKA_CHART_VERSION=$(resolve_chart_version "$KAFKA_CHART" "$KAFKA_CHART_VERSION")
divyadesai59f987a2020-05-27 12:11:33 +00001626RESOLVED_ELASTICSEARCH_CHART_VERSION=$(resolve_chart_version "$ELASTICSEARCH_CHART" "$ELASTICSEARCH_CHART_VERSION")
1627RESOLVED_KIBANA_CHART_VERSION=$(resolve_chart_version "$KIBANA_CHART" "$KIBANA_CHART_VERSION")
1628RESOLVED_FLUENTD_ELASTICSEARCH_CHART_VERSION=$(resolve_chart_version "$FLUENTD_ELASTICSEARCH_CHART" "$FLUENTD_ELASTICSEARCH_CHART_VERSION")
David Bainbridgecf546362020-04-21 23:18:50 -07001629cat <<EOV >>"$LOG"
1630Resolved helm charts and versions:
1631 $VOLTHA_CHART:$RESOLVED_VOLTHA_CHART_VERSION
1632 $VOLTHA_BBSIM_CHART:$RESOLVED_VOLTHA_BBSIM_CHART_VERSION
1633 $VOLTHA_ADAPTER_SIM_CHART:$RESOLVED_VOLTHA_ADAPTER_SIM_CHART_VERSION
1634 $VOLTHA_ADAPTER_OPEN_OLT_CHART:$RESOLVED_VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION
1635 $VOLTHA_ADAPTER_OPEN_ONU_CHART:$RESOLVED_VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION
1636 $ONOS_CHART:$RESOLVED_ONOS_CHART_VERSION
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001637 $ONOS_CLASSIC_CHART:$RESOLVED_ONOS_CLASSIC_CHART_VERSION
David Bainbridgecf546362020-04-21 23:18:50 -07001638 $KAFKA_CHART:$RESOLVED_KAFKA_CHART_VERSION
divyadesai59f987a2020-05-27 12:11:33 +00001639 $ELASTICSEARCH_CHART:$RESOLVED_ELASTICSEARCH_CHART_VERSION
1640 $KIBANA_CHART:$RESOLVED_KIBANA_CHART_VERSION
1641 $FLUENTD_ELASTICSEARCH_CHART:$RESOLVED_FLUENTD_ELASTICSEARCH_CHART_VERSION
David Bainbridgecf546362020-04-21 23:18:50 -07001642EOV
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001643
David Bainbridged18f4942020-04-14 16:46:13 -07001644STIME="$(date +%s)"
David Bainbridge0774b232019-08-02 06:37:19 +00001645bspin "Verify Helm values file: $NAME-values.yaml"
1646if [ ! -r "./$NAME-values.yaml" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001647 espin "$NOT_VERIFIED"
David Bainbridge0774b232019-08-02 06:37:19 +00001648 bspin - "Download Helm values file: $TYPE-values.yaml to $NAME-values.yaml $DOWNLOAD"
David Bainbridged18f4942020-04-14 16:46:13 -07001649 ERR_OUT="$(mktemp)"
serkant.uluderya4d315132020-04-15 16:25:54 -07001650 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 -07001651 espin - "$THEX"
1652 echo -e "${RED}${BOLD}${ERROR}ERROR: $NAME-values.yaml${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1653 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
1654 rm -rf "$ERR_OUT" "./$NAME-values.yaml"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001655 exit 1
1656 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001657 rm -rf "$ERR_OUT"
1658 espin - "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001659else
David Bainbridged18f4942020-04-14 16:46:13 -07001660 espin "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001661fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001662if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001663 NOW="$(date +%s)"
1664 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001665fi
Test Userba1e7e72019-07-10 22:27:54 +00001666
David Bainbridged18f4942020-04-14 16:46:13 -07001667STIME="$(date +%s)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001668bspin "Verify or download chart specific values files $DOWNLOAD"
1669VALUES_FILES="monkey-values.yaml"
David Bainbridged18f4942020-04-14 16:46:13 -07001670ERR_OUT="$(mktemp)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001671for i in $VALUES_FILES; do
1672 if [ ! -r ./$i ]; then
serkant.uluderya4d315132020-04-15 16:25:54 -07001673 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 -07001674 espin "$THEX"
1675 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1676 echo "ERROR: $i - $(cat "$ERR_OUT")" >>"$LOG"
1677 rm -rf "$ERR_OUT" "./$i"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001678 exit 1
1679 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001680 rm -rf "$ERR_OUT"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001681 fi
1682done
David Bainbridged18f4942020-04-14 16:46:13 -07001683rm -rf "$ERR_OUT"
1684espin "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001685if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001686 NOW="$(date +%s)"
1687 printtime $((NOW - STIME))
David Bainbridge99ac7a22019-08-31 02:26:43 +00001688fi
1689
1690if [ "$WITH_CHAOS" == "yes" ]; then
1691 bspin "Verify or clone kube-monkey helm chart $DOWNLOAD"
1692 if [ -r ./kube-monkey ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001693 espin "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001694 else
David Bainbridged18f4942020-04-14 16:46:13 -07001695 espin "$NOT_VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001696 bspin - "GIT clone kube-monkey"
David Bainbridged18f4942020-04-14 16:46:13 -07001697 (set -x; git clone https://github.com/asobti/kube-monkey kube-monkey >>"$LOG" 2>&1) >>"$LOG" 2>&1
1698 espin - "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001699 fi
1700fi
1701
Test Userba1e7e72019-07-10 22:27:54 +00001702if [ "$JUST_K8S" == "yes" ]; then
1703 echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye."
1704 echo ""
David Bainbridged18f4942020-04-14 16:46:13 -07001705 echo "Please issue the following commands in your terminal to ensure that you" | tee -a "$LOG"
1706 echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a "$LOG"
1707 echo "tools required by VOLTHA in your command path. " | tee -a "$LOG"
1708 echo "" | tee -a "$LOG"
1709 echo -en "$BOLD"
1710 if [ "$DEPLOY_K8S" == "yes" ]; then
1711 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00001712 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001713 echo "export PATH=$GOPATH/bin:\$PATH" | tee -a "$LOG"
1714 echo -en "$NORMAL"
1715 echo "" | tee -a "$LOG"
1716 echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00001717 exit 0
1718fi
1719
David Bainbridged18f4942020-04-14 16:46:13 -07001720STIME="$(date +%s)"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001721if is_in "$WITH_ONOS" "yes,legacy,classic"; then
1722 if is_in "$WITH_ONOS" "legacy"; then
1723 bspin "Verify ONOS LEGACY installed $BIRD"
1724 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^onos\$" | wc -l)" -ne 1 ]; then
1725 espin "$NOT_VERIFIED"
David Bainbridge33e56c72020-06-11 11:39:56 -07001726 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 -07001727 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
1728 else
1729 espin "$VERIFIED"
1730 fi
1731 wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for ONOS to start" "$NO_LABEL" "onos-.*"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001732
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001733 if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
1734 bspin - "Forward ONOS API port $FORWARD"
1735 kill_port_forward onos-ui
1736 port_forward "$INFRA_NS" onos-ui "$ONOS_API_PORT:8181"
1737 espin - "$VERIFIED"
1738 bspin - "Forward ONOS SSH port $FORWARD"
1739 kill_port_forward onos-ssh
1740 port_forward "$INFRA_NS" onos-ssh "$ONOS_SSH_PORT:8101"
1741 espin - "$VERIFIED"
1742 _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT"
1743 else
1744 _ONOS_API_EP="$(get_service_ep "$INFRA_NS" onos-ui)"
1745 fi
1746 elif is_in "$WITH_ONOS" "yes,classic"; then
1747 bspin "Verify ONOS CLASSIC installed $BIRD"
1748 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^onos\$" | wc -l)" -ne 1 ]; then
1749 espin "$NOT_VERIFIED"
Matteo Scandoloe0829b52020-05-08 14:23:56 -07001750 # 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 -07001751 # values value
David Bainbridgefad50732020-05-01 17:00:12 -07001752 YAML_VALUES=$(INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set replicas=$NUM_OF_ONOS --set atomix.replicas=$NUM_OF_ATOMIX" \
1753 helm_values "$INFRA_NS" onos "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION")
1754 _ONOS_REPO="$(echo "$YAML_VALUES" | yq read - images.onos.repository)"
David Bainbridgedee3f022020-06-05 07:45:13 -07001755 if [ -z "$_ONOS_REPO" ]; then
1756 _ONOS_REPO="voltha/voltha-onos"
1757 fi
David Bainbridgefad50732020-05-01 17:00:12 -07001758 _ONOS_TAG="$(echo "$YAML_VALUES" | yq read - images.onos.tag)"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001759 if [ -z "$_ONOS_TAG" ]; then
David Bainbridgedee3f022020-06-05 07:45:13 -07001760 _ONOS_TAG="$(echo "$YAML_VALUES" | yq read - defaults.image_tag)"
1761 fi
1762 if [ -z "$_ONOS_TAG" ]; then
1763 _ONOS_TAG="master"
1764 fi
1765 _ONOS_PULL_POLICY="$(echo "$YAML_VALUES" | yq read - images.onos.pullPolicy)"
1766 if [ -z "$_ONOS_PULL_POLICY" ]; then
1767 _ONOS_PULL_POLICY="$(echo "$YAML_VALUES" | yq read - defaults.image_pullPolicy)"
1768 fi
1769 if [ -z "$_ONOS_PULL_POLICY" ]; then
1770 _ONOS_PULL_POLICY="Always"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001771 fi
David Bainbridgefad50732020-05-01 17:00:12 -07001772
Matteo Scandoloe0829b52020-05-08 14:23:56 -07001773 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 -07001774 helm_install - "$INFRA_NS" onos "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION" "+onos" "$_HELM_DESC ONOS CLASSIC"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001775 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
1776 else
1777 espin "$VERIFIED"
1778 fi
1779 wait_for_pods - "$INFRA_NS" $((NUM_OF_ONOS + NUM_OF_ATOMIX)) "includes" "Waiting for ONOS CLASSIC to start" "$NO_LABEL" "onos-.*"
1780 if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
1781 bspin - "Forward ONOS API port $FORWARD"
1782 kill_port_forward onos-onos-classic-hs
1783 port_forward "$INFRA_NS" onos-onos-classic-hs "$ONOS_API_PORT:8181" "$ONOS_SSH_PORT:8101"
1784 espin - "$VERIFIED"
1785 _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT"
1786 else
1787 _ONOS_API_EP="$(get_service_ep "$INFRA_NS" onos-onos-classic-hs)"
1788 fi
1789 elif [ "$WITH_ONOS" == "micro" ]; then
1790 bspin "Verify micro-ONOS installed $BIRD"
1791 # We should never get here
1792 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Micro ONOS not currently supported${NORMAL}"
1793 exit 1
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001794 fi
David Bainbridged31d6122019-08-13 19:37:59 +00001795 bspin - "Verify or download ONOS configuration support files $DOWNLOAD"
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001796 ONOS_FILES="olt-onos-enableExtraneousRules.json onos-aaa.json \
David Bainbridge696bc632020-04-05 21:49:37 -07001797 onos-dhcpl2relay.json onos-sadis-sample.json"
David Bainbridged18f4942020-04-14 16:46:13 -07001798 (set -x; mkdir -p ./onos-files >>"$LOG" 2>&1) >>"$LOG" 2>&1
1799 ERR_OUT="$(mktemp)"
David Bainbridge2b19e832019-08-16 02:40:53 +00001800 for i in $ONOS_FILES; do
David Bainbridged18f4942020-04-14 16:46:13 -07001801 if [ ! -r "./onos-files/$i" ]; then
serkant.uluderya4d315132020-04-15 16:25:54 -07001802 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 -07001803 espin - "$THEX"
1804 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1805 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
1806 rm -rf "$ERR_OUT" "./onos-files/$i"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001807 exit 1
1808 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001809 rm -rf "$ERR_OUT"
David Bainbridged31d6122019-08-13 19:37:59 +00001810 fi
1811 done
David Bainbridged18f4942020-04-14 16:46:13 -07001812 rm -rf "$ERR_OUT"
1813 espin - "$VERIFIED"
David Bainbridge27790d62019-08-13 22:43:19 +00001814
David Bainbridged18f4942020-04-14 16:46:13 -07001815 if [ "$INSTALL_ONOS_APPS" == "yes" ]; then
David Bainbridge27790d62019-08-13 22:43:19 +00001816 bspin - "Installing custom ONOS applications"
David Bainbridged18f4942020-04-14 16:46:13 -07001817 if [ -x onos-files/onos-apps ] && [ "$(find onos-files/onos-apps -name "*.oar" 2>/dev/null | wc -l)" -gt 0 ]; then
1818 for OAR in onos-files/onos-apps/*.oar; do
David Bainbridge27790d62019-08-13 22:43:19 +00001819 sspin - "Installing custom ONOS applications - $OAR$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -07001820 override_onos_app "$OAR"
David Bainbridge27790d62019-08-13 22:43:19 +00001821 done
1822 espin - "$VERIFIED Installing custom ONOS applications$CEOL"
1823 else
1824 espin - "$NOT_VERIFIED Installing custom ONOS applications - None Found"
1825 fi
1826 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001827
David Bainbridged18f4942020-04-14 16:46:13 -07001828 if [ "$WITH_KAFKA" != "no" ]; then
David Bainbridge837e8bd2020-04-06 13:17:14 -07001829 check_onos_app_active org.opencord.kafka
David Bainbridge879439b2020-06-12 15:59:35 -07001830 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridgec7220622020-05-28 12:31:47 -07001831 _HOST=kafka.$INFRA_NS.svc
David Bainbridge76afd812020-04-06 09:53:52 -07001832 _PORT=9092
David Bainbridge879439b2020-06-12 15:59:35 -07001833 elif [ "$WITH_KAFKA" != "no" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001834 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
1835 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge837e8bd2020-04-06 13:17:14 -07001836 _PORT=${_PORT:-9092}
1837 fi
1838 push_onos_config "json" "Push ONOS Kafka Configuration" "network/configuration/apps/org.opencord.kafka" \
David Bainbridged18f4942020-04-14 16:46:13 -07001839 "$(cat <<EOJ | tr -d '[:space:]'
David Bainbridge696bc632020-04-05 21:49:37 -07001840{
1841 "kafka": {
1842 "bootstrapServers": "$_HOST:$_PORT"
1843 }
1844}
1845EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07001846)"
David Bainbridge837e8bd2020-04-06 13:17:14 -07001847 fi
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001848 check_onos_app_active org.opencord.dhcpl2relay
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001849 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 -08001850 check_onos_app_active org.opencord.olt
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001851 # FIXME use WITH_DHCP and WITH_EAPOL flags to configre OLT App
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001852 # Default value for "enableEapol" is true in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07001853 if [ "$WITH_EAPOL" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001854 push_onos_config "json" "Enable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":true}'
David Bainbridged18f4942020-04-14 16:46:13 -07001855 elif [ "$WITH_EAPOL" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001856 push_onos_config "json" "Disable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001857 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001858 # Default value for "enableDhcpOnProvisioning" is false and for "enableDhcpV4" is true in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07001859 if [ "$WITH_DHCP" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001860 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 -07001861 elif [ "$WITH_DHCP" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001862 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 -08001863 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001864 # Default value for "enableIgmpOnProvisioning" is false in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07001865 if [ "$WITH_IGMP" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001866 push_onos_config "json" "Enable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":true}'
David Bainbridged18f4942020-04-14 16:46:13 -07001867 elif [ "$WITH_IGMP" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001868 push_onos_config "json" "Disable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001869 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001870 if [ "$ENABLE_ONOS_EXTRANEOUS_RULES" == "yes" ]; then
David K. Bainbridge484d80c2020-03-05 21:44:34 -08001871 push_onos_config "file" "Enabling extraneous rules for ONOS" "configuration/org.onosproject.net.flow.impl.FlowRuleManager" "onos-files/olt-onos-enableExtraneousRules.json"
1872 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001873 if is_in "$CONFIG_SADIS" "yes,file"; then
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001874 check_onos_app_active org.opencord.sadis
Hardik Windlassb3147602020-03-09 16:59:15 +05301875 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 -07001876 elif [ "$CONFIG_SADIS" == "bbsim" ]; then
1877 push_onos_config "json" \
1878 "[optional] Push ONOS configuration for BBSIM SADIS servers" \
1879 "network/configuration/apps/org.opencord.sadis" \
David Bainbridged18f4942020-04-14 16:46:13 -07001880 "$(cat <<EOJ | tr -d '[:space:]'
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001881{
1882 "sadis": {
1883 "integration": {
David Bainbridgec7220622020-05-28 12:31:47 -07001884 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:50074/v2/subscribers/%s",
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001885 "cache": {
1886 "enabled": true,
1887 "maxsize": 50,
1888 "ttl": "PT1m"
1889 }
1890 }
1891 },
1892 "bandwidthprofile": {
1893 "integration": {
David Bainbridgec7220622020-05-28 12:31:47 -07001894 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:50074/v2/bandwidthprofiles/%s",
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001895 "cache": {
1896 "enabled": true,
1897 "maxsize": 50,
1898 "ttl": "PT1m"
1899 }
1900 }
1901 }
1902}
1903EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07001904)"
David Bainbridge309099c2020-05-05 08:47:29 -07001905 elif [ "$CONFIG_SADIS" == "external" ]; then
David Bainbridge879439b2020-06-12 15:59:35 -07001906 if kubectl get -n "$BBSIM_NS" svc/bbsim-sadis-server-bbsim-sadis-server >/dev/null 2>&1; then
1907 BBSIM_SADIS_SVC="bbsim-sadis-server-bbsim-sadis-server"
1908 else
1909 BBSIM_SADIS_SVC="bbsim-sadis-server"
1910 fi
David Bainbridge309099c2020-05-05 08:47:29 -07001911 push_onos_config "json" \
1912 "[optional] Push ONOS configuration for custom SADIS and Bandwidth Profile servers" \
1913 "network/configuration/apps/org.opencord.sadis" \
1914 "$(cat <<EOJ | tr -d '[:space:]'
1915{
1916 "sadis": {
1917 "integration": {
David Bainbridge879439b2020-06-12 15:59:35 -07001918 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:58080/subscribers/%s",
David Bainbridge309099c2020-05-05 08:47:29 -07001919 "cache": {
1920 "enabled": true,
1921 "maxsize": 50,
1922 "ttl": "PT1m"
1923 }
1924 }
1925 },
1926 "bandwidthprofile": {
1927 "integration": {
David Bainbridge879439b2020-06-12 15:59:35 -07001928 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:58080/profiles/%s",
David Bainbridge309099c2020-05-05 08:47:29 -07001929 "cache": {
1930 "enabled": true,
1931 "maxsize": 50,
1932 "ttl": "PT1m"
1933 }
1934 }
1935 }
1936}
1937EOJ
1938)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001939 elif [ "$CONFIG_SADIS" == "url" ]; then
1940 push_onos_config "json" \
1941 "[optional] Push ONOS configuration for custom SADIS and Bandwidth Profile servers" \
1942 "network/configuration/apps/org.opencord.sadis" \
David Bainbridged18f4942020-04-14 16:46:13 -07001943 "$(cat <<EOJ | tr -d '[:space:]'
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001944{
1945 "sadis": {
1946 "integration": {
1947 "url": "$SADIS_SUBSCRIBERS",
1948 "cache": {
1949 "enabled": true,
1950 "maxsize": 50,
1951 "ttl": "PT1m"
1952 }
1953 }
1954 },
1955 "bandwidthprofile": {
1956 "integration": {
1957 "url": "$SADIS_BANDWIDTH_PROFILES",
1958 "cache": {
1959 "enabled": true,
1960 "maxsize": 50,
1961 "ttl": "PT1m"
1962 }
1963 }
1964 }
1965}
1966EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07001967)"
David Bainbridge2b19e832019-08-16 02:40:53 +00001968 fi
Test Userba1e7e72019-07-10 22:27:54 +00001969fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001970if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001971 NOW="$(date +%s)"
1972 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001973fi
Test Userba1e7e72019-07-10 22:27:54 +00001974
David Bainbridgec7220622020-05-28 12:31:47 -07001975if is_in "$WITH_ETCD" "yes,external"; then
David Bainbridged18f4942020-04-14 16:46:13 -07001976 STIME="$(date +%s)"
David Bainbridge76afd812020-04-06 09:53:52 -07001977 bspin "Verify external ETCD cluster $OLD_KEY"
David Bainbridge43f2df52020-06-02 15:30:54 -07001978 EXPECT="$(yq r - "etcd.replicas" <"$NAME-values.yaml")"
David Bainbridgec7220622020-05-28 12:31:47 -07001979 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 -07001980 espin "$NOT_VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07001981 helm_install - "$INFRA_NS" etcd "$ETCD_CHART" "$ETCD_CHART_VERSION" etcd "$_HELM_DESC external ETCD cluster"
David Bainbridge76afd812020-04-06 09:53:52 -07001982 else
David Bainbridged18f4942020-04-14 16:46:13 -07001983 espin "$VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07001984 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001985 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for ETCD cluster to start" "$NO_LABEL" "etcd-.*"
David Bainbridge76afd812020-04-06 09:53:52 -07001986 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001987 NOW="$(date +%s)"
1988 printtime $((NOW - STIME))
David Bainbridge76afd812020-04-06 09:53:52 -07001989 fi
1990fi
1991
David Bainbridgec7220622020-05-28 12:31:47 -07001992if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridged18f4942020-04-14 16:46:13 -07001993 _TMP="$(mktemp -u)"
1994 _COUNT="$(test "$TYPE" == "minimal" && echo "1" || echo "3")"
1995 cat << EOC > "$_TMP"
David Bainbridge76afd812020-04-06 09:53:52 -07001996configurationOverrides:
1997 "default.replication.factor": $_COUNT
1998 "offsets.topic.replication.factor": $_COUNT
1999 "log.retention.hours": 4
2000 "log.message.timestamp.type": "LogAppendTime"
2001persistence:
2002 enabled: false
2003zookeeper:
2004 replicaCount: 1
2005 persistence:
2006 enabled: false
2007replicas: $_COUNT
2008EOC
David Bainbridged18f4942020-04-14 16:46:13 -07002009 STIME="$(date +%s)"
David Bainbridge76afd812020-04-06 09:53:52 -07002010 bspin "Verify external Kafka cluster $OLD_KEY"
David Bainbridged18f4942020-04-14 16:46:13 -07002011 EXPECT="$(test "$TYPE" == "minimal" && echo "2" || echo "4")"
2012 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^kafka\$" | wc -l)" -ne 1 ]; then
2013 espin "$NOT_VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07002014 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" -f $_TMP"
David Bainbridgec7220622020-05-28 12:31:47 -07002015 helm_install - "$INFRA_NS" kafka "$KAFKA_CHART" "$KAFKA_CHART_VERSION" kafka "$_HELM_DESC external Kafka cluster"
David Bainbridge76afd812020-04-06 09:53:52 -07002016 else
David Bainbridged18f4942020-04-14 16:46:13 -07002017 espin "$VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07002018 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002019 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for Kafka cluster to start" "$NO_LABEL" "kafka-.*"
David Bainbridge76afd812020-04-06 09:53:52 -07002020 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002021 NOW="$(date +%s)"
2022 printtime $((NOW - STIME))
David Bainbridge76afd812020-04-06 09:53:52 -07002023 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002024 rm -rf "$_TMP"
David Bainbridge76afd812020-04-06 09:53:52 -07002025fi
2026
David Bainbridged18f4942020-04-14 16:46:13 -07002027STIME="$(date +%s)"
David Bainbridgeed476572020-06-02 14:05:45 -07002028EXPECT=2
2029# therecanbeonlyone set hardcoded to true for backward compatibility
2030INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set therecanbeonlyone=true"
Matteo Scandolo67335f02020-04-09 11:19:53 -07002031case $WITH_ETCD in
David Bainbridge76afd812020-04-06 09:53:52 -07002032 no)
David Bainbridge76afd812020-04-06 09:53:52 -07002033 ;;
David Bainbridgec7220622020-05-28 12:31:47 -07002034 yes|external)
2035 _HOST="etcd.$INFRA_NS.svc"
David Bainbridge76afd812020-04-06 09:53:52 -07002036 _PORT=2379
2037 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridge76afd812020-04-06 09:53:52 -07002038 ;;
2039 *)
David Bainbridged18f4942020-04-14 16:46:13 -07002040 _HOST="$(echo "$WITH_ETCD" | cut -d: -f1)"
2041 _PORT="$(echo "$WITH_ETCD" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07002042 _PORT=${_PORT:-2379}
David Bainbridgec7220622020-05-28 12:31:47 -07002043 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridge76afd812020-04-06 09:53:52 -07002044 ;;
2045esac
2046case $WITH_KAFKA in
2047 no)
David Bainbridge76afd812020-04-06 09:53:52 -07002048 ;;
David Bainbridgec7220622020-05-28 12:31:47 -07002049 yes|external)
2050 _HOST=kafka.$INFRA_NS.svc
David Bainbridge76afd812020-04-06 09:53:52 -07002051 _PORT=9092
2052 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 -07002053 ;;
2054 *)
David Bainbridged18f4942020-04-14 16:46:13 -07002055 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
2056 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07002057 _PORT=${_PORT:-9092}
David Bainbridgec7220622020-05-28 12:31:47 -07002058 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 -07002059 ;;
2060esac
2061
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002062if is_in "$WITH_ONOS" "legacy"; then
David Bainbridgec7220622020-05-28 12:31:47 -07002063 _HOST=onos-openflow.$INFRA_NS.svc
David Bainbridge76afd812020-04-06 09:53:52 -07002064 _PORT=6653
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002065elif is_in "$WITH_ONOS" "yes,classic"; then
David Bainbridgec7220622020-05-28 12:31:47 -07002066 _HOST=onos-onos-classic-hs.$INFRA_NS.svc
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002067 _PORT=6653
David Bainbridged18f4942020-04-14 16:46:13 -07002068elif [ "$WITH_ONOS" != "no" ]; then
2069 _HOST="$(echo "$WITH_ONOS" | cut -d: -f1)"
2070 _PORT="$(echo "$WITH_ONOS" | cut -s -d: -f2)"
David Bainbridge76afd812020-04-06 09:53:52 -07002071 _PORT=${_PORT:-6653}
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002072fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002073
David Bainbridgecf546362020-04-21 23:18:50 -07002074compare_versions "$RESOLVED_VOLTHA_CHART_VERSION" 2.4.2
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002075if [ "$?" == "1" ]; then
2076 # voltha chart > 2.4.2 uses list of controllers
David Bainbridgee4d11ca2020-05-08 10:21:10 -07002077 for NUM in $(seq 0 $((NUM_OF_ONOS-1))); do
David Bainbridgec7220622020-05-28 12:31:47 -07002078 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 -07002079 done
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002080else
2081 # voltha chart <= 2.4.2 uses single controller
David Bainbridge76afd812020-04-06 09:53:52 -07002082 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.controller.service=$_HOST --set services.controller.port=$_PORT"
David Bainbridge696bc632020-04-05 21:49:37 -07002083fi
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002084
Test Userb5712372019-07-03 21:52:17 +00002085bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
David Bainbridged18f4942020-04-14 16:46:13 -07002086if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$VOLTHA_NS" "^voltha\$" | wc -l)" -ne 1 ]; then
2087 espin "$NOT_VERIFIED"
David Bainbridgea965ca22020-06-09 17:45:04 -07002088 helm_install - "$VOLTHA_NS" voltha "$VOLTHA_CHART" "$VOLTHA_CHART_VERSION" "+voltha" "$_HELM_DESC VOLTHA Core"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002089else
David Bainbridged18f4942020-04-14 16:46:13 -07002090 espin "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002091fi
David Bainbridge696bc632020-04-05 21:49:37 -07002092INTERNAL_EXTRA_HELM_INSTALL_ARGS=
Test Userba1e7e72019-07-10 22:27:54 +00002093
David Bainbridge90fd8e32019-08-21 23:32:47 +00002094VOLTHA="voltha-ofagent-.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002095 rw-core.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002096 voltha-zookeeper-.*"
David Bainbridged18f4942020-04-14 16:46:13 -07002097wait_for_pods - "$VOLTHA_NS" "$EXPECT" "includes" "Waiting for VOLTHA Core to start" "$NO_LABEL" "$VOLTHA"
David Bainbridgee87067b2019-08-12 22:00:12 +00002098if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002099 NOW="$(date +%s)"
2100 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002101fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002102
David Bainbridge46505fb2019-10-01 21:13:20 +00002103if [ "$WITH_ADAPTERS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002104 STIME="$(date +%s)"
David Bainbridge46505fb2019-10-01 21:13:20 +00002105 EXPECT=0
David Bainbridgec7220622020-05-28 12:31:47 -07002106 if is_in "$WITH_ETCD" "yes,external"; then
2107 _HOST=etcd.$INFRA_NS.svc
David Bainbridge3517f6c2020-04-08 12:14:08 -07002108 _PORT=2379
2109 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridged18f4942020-04-14 16:46:13 -07002110 elif [ "$WITH_ETCD" != "no" ]; then
2111 _HOST="$(echo "$WITH_ETCD" | cut -d: -f1)"
2112 _PORT="$(echo "$WITH_ETCD" | cut -s -d: -f2)"
David Bainbridge3517f6c2020-04-08 12:14:08 -07002113 _PORT=${_PORT:-2379}
2114 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridge696bc632020-04-05 21:49:37 -07002115 fi
David Bainbridgec7220622020-05-28 12:31:47 -07002116 if is_in "$WITH_KAFKA" "yes,external"; then
2117 _HOST=kafka.$INFRA_NS.svc
David Bainbridge3517f6c2020-04-08 12:14:08 -07002118 _PORT=9092
2119 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 -07002120 elif [ "$WITH_KAFKA" != "no" ]; then
2121 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
2122 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge3517f6c2020-04-08 12:14:08 -07002123 _PORT=${_PORT:-9092}
2124 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 -07002125 fi
David Bainbridge46505fb2019-10-01 21:13:20 +00002126 echo -e "Verify Adapters $PLUG"
2127 if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then
2128 bspin - "Verify Simulated Adapters installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002129 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$ADAPTER_NS" "^sim\$" | wc -l)" -ne 1 ]; then
2130 espin - "$NOT_VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002131 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 +00002132 else
David Bainbridged18f4942020-04-14 16:46:13 -07002133 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00002134 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002135 EXPECT="$((EXPECT + 2))"
David Bainbridge46505fb2019-10-01 21:13:20 +00002136 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07002137
David Bainbridge46505fb2019-10-01 21:13:20 +00002138 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
2139 bspin - "Verify OpenOLT Adapter installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002140 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$ADAPTER_NS" "^open-olt\$" | wc -l)" -ne 1 ]; then
2141 espin - "$NOT_VERIFIED"
David Bainbridgea965ca22020-06-09 17:45:04 -07002142 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 +00002143 else
David Bainbridged18f4942020-04-14 16:46:13 -07002144 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00002145 fi
Matteo Scandolo67335f02020-04-09 11:19:53 -07002146 EXPECT="$((EXPECT + 1))"
David Bainbridge46505fb2019-10-01 21:13:20 +00002147 bspin - "Verify OpenONU Adapter installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002148 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 -07002149 _ORIGINAL_EXTRA_HELM_INSTALL_ARGS="$INTERNAL_EXTRA_HELM_INSTALL_ARGS"
2150 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set replicas.adapter_open_onu=$NUM_OF_OPENONU"
Girish Gowdra4cc5d8b2020-06-11 17:12:00 -07002151 if [ "$WITH_INCREMENTAL_EVTO_UPDATE" == "yes" ]; then
2152 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set adapter_open_onu.incremental_evto_update=true"
2153 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002154 espin - "$NOT_VERIFIED"
David Bainbridgea965ca22020-06-09 17:45:04 -07002155 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 -07002156 INTERNAL_EXTRA_HELM_INSTALL_ARGS="$_ORIGINAL_EXTRA_HELM_INSTALL_ARGS"
David Bainbridge46505fb2019-10-01 21:13:20 +00002157 else
David Bainbridged18f4942020-04-14 16:46:13 -07002158 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00002159 fi
Matteo Scandolo67335f02020-04-09 11:19:53 -07002160 EXPECT=$((EXPECT + NUM_OF_OPENONU))
David Bainbridge46505fb2019-10-01 21:13:20 +00002161 fi
David Bainbridge696bc632020-04-05 21:49:37 -07002162 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07002163
David Bainbridge46505fb2019-10-01 21:13:20 +00002164 ADAPTERS="adapter-.*"
David Bainbridged18f4942020-04-14 16:46:13 -07002165 wait_for_pods - "$ADAPTER_NS" "$EXPECT" "includes" "Waiting for adapters to start" "$NO_LABEL" "$ADAPTERS"
David Bainbridge46505fb2019-10-01 21:13:20 +00002166 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002167 NOW="$(date +%s)"
2168 printtime $((NOW - STIME))
David Bainbridge46505fb2019-10-01 21:13:20 +00002169 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00002170fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002171
David Bainbridged18f4942020-04-14 16:46:13 -07002172if [ "$WITH_BBSIM" == "yes" ]; then
2173 STIME="$(date +%s)"
Test User7d866122019-07-09 17:52:35 +00002174 echo -e "Verify BBSIM $PLUG"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002175 bspin - "Verify BBSIM Installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002176 for instance in $(seq 0 $((NUM_OF_BBSIM-1))); do
Matteo Scandoloc2eb0672020-05-01 14:43:15 -07002177
2178 if [ "$LEGACY_BBSIM_INDEX" == "yes" ]; then
2179 if [ "$instance" -eq 0 ]; then
2180 instance_num=""
2181 else
2182 instance_num=$instance
2183 fi
David K. Bainbridge43422402020-03-06 07:41:22 -08002184 else
2185 instance_num=$instance
2186 fi
Matteo Scandoloc2eb0672020-05-01 14:43:15 -07002187
2188
David Bainbridged18f4942020-04-14 16:46:13 -07002189 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$BBSIM_NS" "^bbsim${instance_num}\$" | wc -l)" -ne 1 ]; then
2190 espin - "$NOT_VERIFIED"
2191 S_TAG="$((900+instance))"
Matteo Scandolo5a149572020-04-01 10:14:57 -07002192 INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set olt_id=$instance,s_tag=$S_TAG"
David Bainbridged9329af2020-05-01 11:58:52 -07002193 if [ "$WITH_EAPOL" == "yes" ]; then
2194 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set auth=true"
2195 else
2196 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set auth=false"
2197 fi
2198 if [ "$WITH_DHCP" == "yes" ]; then
2199 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set dhcp=true"
2200 else
2201 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set dhcp=false"
2202 fi
David Bainbridge33e56c72020-06-11 11:39:56 -07002203 if is_in "$WITH_KAFKA" "yes,external"; then
2204 _HOST=kafka.$INFRA_NS.svc
2205 _PORT=9092
2206 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafkaAddress=$_HOST:$_PORT"
2207 elif [ "$WITH_KAFKA" != "no" ]; then
2208 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
2209 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
2210 _PORT=${_PORT:-9092}
2211 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafkaAddress=$_HOST:$_PORT"
2212 fi
2213 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 -07002214 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
David K. Bainbridge43422402020-03-06 07:41:22 -08002215 else
David Bainbridged18f4942020-04-14 16:46:13 -07002216 espin - "$VERIFIED"
David K. Bainbridge43422402020-03-06 07:41:22 -08002217 fi
2218 done
David Bainbridged18f4942020-04-14 16:46:13 -07002219 wait_for_pods - "$BBSIM_NS" "$NUM_OF_BBSIM" "includes" "Waiting for BBSIM to start" "$BBSIM_LABEL" "bbsim*"
David Bainbridgee87067b2019-08-12 22:00:12 +00002220 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002221 NOW="$(date +%s)"
2222 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002223 fi
Test User7d866122019-07-09 17:52:35 +00002224fi
2225
divyadesai59f987a2020-05-27 12:11:33 +00002226if [ "$WITH_EFK" == "yes" ]; then
2227 STIME="$(date +%s)"
2228 echo -e "Verify EFK $PLUG"
2229 bspin - "Verify EFK Installed"
2230 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
2231 espin - "$NOT_VERIFIED"
2232 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^elasticsearch\$" | wc -l)" -ne 1 ]; then
2233 helm_install - "$INFRA_NS" elasticsearch "$ELASTICSEARCH_CHART" "$ELASTICSEARCH_CHART_VERSION" elasticsearch "$_HELM_DESC elasticsearch"
2234 fi
2235 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^kibana\$" | wc -l)" -ne 1 ]; then
2236 helm_install - "$INFRA_NS" kibana "$KIBANA_CHART" "$KIBANA_CHART_VERSION" kibana "$_HELM_DESC kibana"
2237 fi
2238 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^fluentd\$" | wc -l)" -ne 1 ]; then
2239 helm_install - "$INFRA_NS" fluentd "$FLUENTD_ELASTICSEARCH_CHART" "$FLUENTD_ELASTICSEARCH_CHART_VERSION" fluentd-elasticsearch "$_HELM_DESC fluentd-elasticsearch"
2240 fi
2241 else
2242 espin - "$VERIFIED"
2243 fi
2244 EXPECT=2 # for elastic and kibana
2245 if [ "$TYPE" == "minimal" ]; then
2246 EXPECT=$((EXPECT + 2)) # for fluentd on worker 2 worker nodes
2247 else
2248 EXPECT=$((EXPECT + 3)) # for fluentd on worker 3 worker nodes
2249 fi
2250 if [ "$SCHEDULE_ON_CONTROL_NODES" == "yes" ]; then
2251 EXPECT=$((EXPECT + 1)) # for fluentd on the control plan node
2252 fi
2253
2254 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for EFK to start" "$NO_LABEL" "fluentd-* elasticsearch-* kibana-*"
2255 if [ "$WITH_TIMINGS" == "yes" ]; then
2256 NOW="$(date +%s)"
2257 printtime $((NOW - STIME))
2258 fi
2259fi
2260
David Bainbridge309099c2020-05-05 08:47:29 -07002261if [ "$CONFIG_SADIS" == "external" ]; then
2262 STIME="$(date +%s)"
2263 echo -e "Verify BBSIM SADIS Service $PLUG"
2264 bspin - "Verify required configmap"
2265 (set -x; kubectl -n "$BBSIM_NS" delete --ignore-not-found configmap kube-config >>"$LOG" 2>&1) >>"$LOG" 2>&1
2266 (set -x; kubectl -n "$BBSIM_NS" create configmap kube-config "--from-file=kube_config=$KUBECONFIG" >>"$LOG" 2>&1) >>"$LOG" 2>&1
2267 espin - "$VERIFIED"
2268 bspin - "Verify BBSIM SADIS Service Installed"
divyadesai59f987a2020-05-27 12:11:33 +00002269 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 -07002270 espin - "$NOT_VERIFIED"
David Bainbridge879439b2020-06-12 15:59:35 -07002271 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 -07002272 else
2273 espin - "$VERIFIED"
2274 fi
2275 wait_for_pods - "$BBSIM_NS" 1 "includes" "Waiting for BBSIM SADIS Server to start" "$NO_LABEL" "bbsim-sadis-server-.*"
2276 if [ "$WITH_TIMINGS" == "yes" ]; then
2277 NOW="$(date +%s)"
2278 printtime $((NOW - STIME))
2279 fi
2280fi
2281
David Bainbridged18f4942020-04-14 16:46:13 -07002282if [ "$WITH_RADIUS" == "yes" ]; then
2283 STIME="$(date +%s)"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002284 echo -e "Verify RADIUS $LOCK"
2285 bspin - "Verify RADIUS Installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002286 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^radius\$" | wc -l)" -ne 1 ]; then
2287 espin - "$NOT_VERIFIED"
David Bainbridge879439b2020-06-12 15:59:35 -07002288 helm_install - "$INFRA_NS" radius "$RADIUS_CHART" "$RADIUS_CHART_VERSION" "+radius" "$_HELM_DESC RADIUS"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002289 else
David Bainbridged18f4942020-04-14 16:46:13 -07002290 espin - "$VERIFIED"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002291 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002292 wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for RADIUS to start" "$NO_LABEL" "radius-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00002293 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002294 NOW="$(date +%s)"
2295 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002296 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002297fi
2298
David Bainbridged18f4942020-04-14 16:46:13 -07002299if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
2300 STIME="$(date +%s)"
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002301 bspin - "Forward VOLTHA API port $FORWARD"
David Bainbridge1d2c5842020-06-03 15:29:07 -07002302 kill_port_forward voltha-api voltha-voltha-api
2303 VOLTHA_PREFIX=
2304 if kubectl get -n "$VOLTHA_NS" "svc/voltha-voltha-api" >/dev/null 2>&1; then
2305 VOLTHA_PREFIX="voltha-"
2306 fi
2307
2308 port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-api" "$VOLTHA_API_PORT:55555"
David Bainbridged18f4942020-04-14 16:46:13 -07002309 espin - "$VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002310 if is_in "$WITH_ETCD" "yes,external"; then
David Bainbridge696bc632020-04-05 21:49:37 -07002311 bspin - "Forward VOLTHA ETCD port $FORWARD"
David Bainbridgec7220622020-05-28 12:31:47 -07002312 kill_port_forward "etcd"
2313 port_forward "$INFRA_NS" "etcd" "$VOLTHA_ETCD_PORT:2379"
David Bainbridged18f4942020-04-14 16:46:13 -07002314 espin - "$VERIFIED"
David Bainbridge696bc632020-04-05 21:49:37 -07002315 fi
David Bainbridgec7220622020-05-28 12:31:47 -07002316 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridge696bc632020-04-05 21:49:37 -07002317 bspin - "Forward VOLTHA Kafka port $FORWARD"
David Bainbridgec7220622020-05-28 12:31:47 -07002318 kill_port_forward "kafka"
2319 port_forward "$INFRA_NS" kafka "$VOLTHA_KAFKA_PORT:9092"
David Bainbridged18f4942020-04-14 16:46:13 -07002320 espin - "$VERIFIED"
David Bainbridge696bc632020-04-05 21:49:37 -07002321 fi
divyadesai59f987a2020-05-27 12:11:33 +00002322 if [ "$WITH_EFK" == "yes" ]; then
2323 bspin - "Forward EFK port $FORWARD"
2324 kill_port_forward elasticsearch-master
2325 kill_port_forward kibana-kibana
2326 port_forward "$INFRA_NS" elasticsearch-master "$ELASTICSEARCH_PORT:9200"
2327 port_forward "$INFRA_NS" kibana-kibana "$KIBANA_PORT:5601"
2328 espin - "$VERIFIED"
2329 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -07002330 if [ "$WITH_PPROF" == "yes" ]; then
David Bainbridge1d2c5842020-06-03 15:29:07 -07002331 VOLTHA_OPENOLT_PREFIX=
2332 if kubectl get -n "$ADAPTER_NS" "svc/open-olt-adapter-open-olt-profiler" >/dev/null 2>&1; then
2333 VOLTHA_OPENOLT_PREFIX="open-olt-"
2334 fi
David Bainbridge879439b2020-06-12 15:59:35 -07002335 bspin - "Forward PProf ports port $FORWARD"
2336 kill_port_forward voltha-rw-core-profiler voltha-voltha-rw-core-profiler
2337 kill_port_forward adapter-open-olt-profiler open-olt-adapter-open-olt-profiler
2338 kill_port_forward voltha-of-agent-profiler voltha-voltha-of-agent-profiler
2339 port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-rw-core-profiler" "$VOLTHA_PPROF_PORT:6060"
2340 port_forward "$ADAPTER_NS" "${VOLTHA_OPENOLT_PREFIX}adapter-open-olt-profiler" "$OPENOLT_PPROF_PORT:6060"
2341 port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-of-agent-profiler" "$OFAGENT_PPROF_PORT:6060"
2342 espin - "$VERIFIED"
Matteo Scandoloefee0432020-05-05 13:56:20 -07002343 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002344 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002345 NOW="$(date +%s)"
2346 printtime $((NOW - STIME))
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002347 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00002348fi
Test User3d7ad8e2019-07-03 06:15:44 +00002349
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002350if is_in "$WITH_ONOS" "yes,legacy,classic" && [ "$WITH_RADIUS" != "no" ]; then
David Bainbridge879439b2020-06-12 15:59:35 -07002351 SVC_NAME=radius
2352 if kubectl get -n "$INFRA_NS" "svc/radius-freeradius" >/dev/null 2>&1; then
2353 SVC_NAME="radius-freeradius"
2354 fi
2355 _HOST="$SVC_NAME.$INFRA_NS.svc"
David Bainbridge696bc632020-04-05 21:49:37 -07002356 _PORT=1812
David Bainbridged18f4942020-04-14 16:46:13 -07002357 if [ "$WITH_RADIUS" != "yes" ]; then
2358 _HOST="$(echo "$WITH_RADIUS" | cut -d: -f1)"
2359 _PORT="$(echo "$WITH_RADIUS" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07002360 _PORT=${_PORT:-1812}
2361 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002362 bspin "Configure ONOS RADIUS Connection $GEAR"
David Bainbridged18f4942020-04-14 16:46:13 -07002363 (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
2364 espin "$VERIFIED"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002365fi
2366
divyadesai59f987a2020-05-27 12:11:33 +00002367if [ "$WITH_EFK" == "yes" ]; then
2368 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"
2369# fi
2370fi
2371
David Bainbridge99ac7a22019-08-31 02:26:43 +00002372if [ "$WITH_CHAOS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002373 STIME="$(date +%s)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002374 echo -e "Verify kube-monkey $LOCK"
2375 bspin - "Verify kube-monkey Installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002376 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace kube-monkey "^monkey\$" | wc -l)" -ne 1 ]; then
2377 espin - "$NOT_VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002378 helm_install - kube-monkey monkey ./kube-monkey/helm/kubemonkey latest - "$_HELM_DESC Chaos Monkey"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002379 else
David Bainbridged18f4942020-04-14 16:46:13 -07002380 espin - "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002381 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002382 wait_for_pods - "kube-monkey" 1 "includes" "Waiting for Chaos to start" "$NO_LABEL" "monkey-.*"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002383 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002384 NOW="$(date +%s)"
2385 printtime $((NOW - STIME))
David Bainbridge99ac7a22019-08-31 02:26:43 +00002386 fi
2387fi
2388
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002389bspin "Create voltctl configuration file"
David Bainbridged18f4942020-04-14 16:46:13 -07002390(set -x; mkdir -p "$HOME/.volt" >>"$LOG" 2>&1) >>"$LOG" 2>&1
2391MIN_VC_VERSION="$(echo -e "1.0.15\n$VC_VERSION" | sort -V | head -1)"
2392if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002393 KAFKA_FLAG="-k localhost:$VOLTHA_KAFKA_PORT"
2394 SERVER_FLAG="-s localhost:$VOLTHA_API_PORT"
2395 ETCD_FLAG=
2396 if [ "$MIN_VC_VERSION" == "1.0.15" ]; then
2397 ETCD_FLAG="-e localhost:$VOLTHA_ETCD_PORT"
2398 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002399else
David Bainbridgec7220622020-05-28 12:31:47 -07002400 KAFKA_FLAG="-k $(get_service_ep "$INFRA_NS" kafka)"
David Bainbridged18f4942020-04-14 16:46:13 -07002401 SERVER_FLAG="-s $(get_service_ep "$VOLTHA_NS" voltha-api)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002402 ETCD_FLAG=
2403 if [ "$MIN_VC_VERSION" == "1.0.15" ]; then
David Bainbridgec7220622020-05-28 12:31:47 -07002404 ETCD_FLAG="-e $(get_service_ep "$INFRA_NS" etcd)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002405 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002406fi
David Bainbridgea965ca22020-06-09 17:45:04 -07002407CMD=("voltctl $KAFKA_FLAG $SERVER_FLAG $ETCD_FLAG config")
David Bainbridged18f4942020-04-14 16:46:13 -07002408(set -x; ${CMD[*]} > "$HOME/.volt/config-$NAME" 2>>"$LOG") >>"$LOG" 2>&1
David Bainbridgea965ca22020-06-09 17:45:04 -07002409#(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 -07002410espin "$VERIFIED"
Test User08ebbd92019-07-03 17:15:39 +00002411
David Bainbridge0774b232019-08-02 06:37:19 +00002412if [ ! -f "$NAME-env.sh" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002413 touch "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002414fi
2415
David Bainbridge596f30d2019-07-30 17:07:59 +00002416for O in $ALL_OPTIONS; do
David Bainbridged18f4942020-04-14 16:46:13 -07002417 VAL="$(eval echo "\$$O")"
2418 if [ -n "$VAL" ] && [ "$(grep -c "^export $O=" "$NAME-env.sh")" -eq 0 ]; then
2419 echo "export $O=\"$(eval echo "\$$O")\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002420 fi
2421done
2422
David Bainbridged18f4942020-04-14 16:46:13 -07002423if [ "$DEPLOY_K8S" == "yes" ] && [ "$(grep -c "^export KUBECONFIG=" "$NAME-env.sh")" -eq 0 ]; then
2424 echo "export KUBECONFIG=\"$(./bin/kind get kubeconfig-path "--name=voltha-$NAME")\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002425fi
2426
David Bainbridged18f4942020-04-14 16:46:13 -07002427if [ "$(grep -c "^export VOLTCONFIG=" "$NAME-env.sh")" -eq 0 ]; then
2428 echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002429fi
2430
David Bainbridged18f4942020-04-14 16:46:13 -07002431if [ "$(grep -c "^export PATH=" "$NAME-env.sh")" -eq 0 ]; then
2432 echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002433fi
2434
Test User7d866122019-07-09 17:52:35 +00002435echo ""
David Bainbridged18f4942020-04-14 16:46:13 -07002436echo "Please issue the following commands in your terminal to ensure that you" | tee -a "$LOG"
2437echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a "$LOG"
2438echo "tools required by VOLTHA in your command path. " | tee -a "$LOG"
2439echo "" | tee -a "$LOG"
2440echo -en "$BOLD"
2441if [ "$DEPLOY_K8S" == "yes" ]; then
2442 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00002443fi
David Bainbridged18f4942020-04-14 16:46:13 -07002444echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" | tee -a "$LOG"
2445echo "export PATH=$GOPATH/bin:\$PATH" | tee -a "$LOG"
2446echo -en "$NORMAL"
2447echo "" | tee -a "$LOG"
2448echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a "$LOG"
Test User08ebbd92019-07-03 17:15:39 +00002449
David Bainbridge712afb82019-08-14 19:55:58 +00002450if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002451 NOW="$(date +%s)"
2452 echo -e "$CLOCK ${BOLD}TOTAL: $(duration $((NOW - TOTAL_START_TIME)))${NORMAL}"
David Bainbridge712afb82019-08-14 19:55:58 +00002453fi