blob: af97675dcaac2b171c807c8e1a6446b005c1afe9 [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
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001545
Test Userba1e7e72019-07-10 22:27:54 +00001546 # HACK (sort-of) - the config for tiller is about to be patched, which will
1547 # cause the tiller pod to be recreated. This can sometimes cause a timing
1548 # issue with the "wait_for_pods" call on tiller as it may incorrectly
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001549 # identify the running/ready tiller pod that is soon to be terminated as
Test Userba1e7e72019-07-10 22:27:54 +00001550 # what it is waiting for. To avoid this issue we do a clean scale down and
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001551 # scale up of the pod so the script controlls when it should be expecting
Test Userba1e7e72019-07-10 22:27:54 +00001552 # things
David Bainbridged18f4942020-04-14 16:46:13 -07001553 (set -x; kubectl -n kube-system scale deploy tiller-deploy --replicas=0 >>"$LOG" 2>&1) >>"$LOG" 2>&1
David Bainbridgeddeab482020-06-24 12:43:40 -07001554 wait_for_pods - "kube-system" 0 "not" "Waiting for Tiller POD to shutdown" "$NO_LABEL" "tiller-deploy-.*"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001555
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001556 # Create and k8s service account so that Helm can create pods
Test Userb5712372019-07-03 21:52:17 +00001557 bspin - "Create Tiller ServiceAccount"
David Bainbridged18f4942020-04-14 16:46:13 -07001558 (set -x; kubectl create serviceaccount --namespace kube-system tiller >>"$LOG" 2>&1) >>"$LOG" 2>&1
1559 espin - "$VERIFIED"
Test Userb5712372019-07-03 21:52:17 +00001560 bspin - "Create Tiller ClusterRoleBinding"
David Bainbridged18f4942020-04-14 16:46:13 -07001561 (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>"$LOG" 2>&1) >>"$LOG" 2>&1
1562 espin - "$VERIFIED"
Test Userb5712372019-07-03 21:52:17 +00001563 bspin - "Update Tiller Manifest"
David Bainbridged18f4942020-04-14 16:46:13 -07001564 (set -x; kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}' >>"$LOG" 2>&1) >>"$LOG" 2>&1
Test Userba1e7e72019-07-10 22:27:54 +00001565
1566 # HACK (sort-of) - part to, spin it back up
David Bainbridged18f4942020-04-14 16:46:13 -07001567 (set -x; kubectl -n kube-system scale deploy tiller-deploy --replicas=1 >>"$LOG" 2>&1) >>"$LOG" 2>&1
1568 espin - "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001569else
David Bainbridged18f4942020-04-14 16:46:13 -07001570 if [ "$(helm version -s --template '{{.Server.SemVer}}')" != "$HELM_VERSION" ]; then
1571 espin "$NOT_VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001572 bspin - "Sync Tiller server version with helm client"
David Bainbridged18f4942020-04-14 16:46:13 -07001573 (set -x; helm init --upgrade --force-upgrade --wait >>"$LOG" 2>&1) >>"$LOG" 2>&1
1574 espin - "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001575 else
David Bainbridged18f4942020-04-14 16:46:13 -07001576 espin "$VERIFIED"
David Bainbridgea34993d2020-04-01 09:15:42 -07001577 fi
1578
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001579fi
David Bainbridged18f4942020-04-14 16:46:13 -07001580wait_for_pods - "kube-system" 1 "includes" "Waiting for Tiller POD to start" "$NO_LABEL" "tiller-deploy-.*"
David Bainbridgeddeab482020-06-24 12:43:40 -07001581
1582REPOS="onf|https://charts.opencord.org|ONF_VOLTHA \
1583 stable|https://kubernetes-charts.storage.googleapis.com|Google_Stable \
1584 incubator|https://kubernetes-charts-incubator.storage.googleapis.com|Google_Incubator"
1585
1586if is_in "$WITH_ONOS" "yes,legacy,classic"; then
1587 REPOS+=" onos|https://charts.onosproject.org|ONF_ONOS \
1588 atomix|https://charts.atomix.io|ONF_Atomi"
1589fi
1590if [ "$CONFIG_SADIS" == "external" ]; then
1591 REPOS+=" bbsim-sadis|https://ciena.github.io/bbsim-sadis-server/charts|Custom_BBSIM_SADIS_Server"
1592fi
1593if [ "$WITH_EFK" == "yes" ]; then
1594 REPOS+=" elastic|https://helm.elastic.co|Elastic \
1595 kiwigrid|https://kiwigrid.github.io|Fluentd-ElasticSearch"
1596fi
1597REPO_UPDATE_REQ="no"
1598
1599bspin - "Verify Helm Repository"
1600for REPO in $REPOS; do
1601 REPO_NAME="$(echo "$REPO" | cut -d\| -f1)"
1602 REPO_URL="$(echo "$REPO" | cut -d\| -f2)"
1603 REPO_LABEL="$(echo "$REPO" | cut -d\| -f3 | sed -e 's/_/ /g')"
1604
1605 sspin - "Verify Helm Repository: $REPO_LABEL$CEOL"
1606 if [ "$(helm repo list 2>/dev/null | grep -c "$REPO_NAME" 2>/dev/null)" -eq 0 ]; then
1607 sspin - "Add Helm Repository: $REPO_LABEL$CEOL"
1608 (set -x; helm repo add "$REPO_NAME" "$REPO_URL" >>"$LOG" 2>&1) >>"$LOG" 2>&1
1609 REPO_UPDATE_REQ="yes"
1610 fi
1611done
1612sspin - "Verify Helm Repositories$CEOL"
1613espin - "$VERIFIED"
1614
1615if [ "$REPO_UPDATE_REQ" == "yes" ] || [ "$UPDATE_HELM_REPOS" == "yes" ]; then
1616 bspin - "Update Helm repository cache"
1617 (set -x; helm repo update >>"$LOG" 2>&1) >>"$LOG" 2>&1
1618 espin - "$VERIFIED"
1619fi
1620
David Bainbridgee87067b2019-08-12 22:00:12 +00001621if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001622 NOW="$(date +%s)"
1623 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001624fi
David Bainbridgecf546362020-04-21 23:18:50 -07001625# Resolve chart versions and log them for debug/support
1626RESOLVED_VOLTHA_CHART_VERSION=$(resolve_chart_version "$VOLTHA_CHART" "$VOLTHA_CHART_VERSION")
1627RESOLVED_VOLTHA_BBSIM_CHART_VERSION=$(resolve_chart_version "$VOLTHA_BBSIM_CHART" "$VOLTHA_BBSIM_CHART_VERSION")
1628RESOLVED_VOLTHA_ADAPTER_SIM_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_SIM_CHART" "$VOLTHA_ADAPTER_SIM_CHART_VERSION")
1629RESOLVED_VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_OPEN_OLT_CHART" "$VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION")
1630RESOLVED_VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_OPEN_ONU_CHART" "$VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION")
1631RESOLVED_ONOS_CHART_VERSION=$(resolve_chart_version "$ONOS_CHART" "$ONOS_CHART_VERSION")
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001632RESOLVED_ONOS_CLASSIC_CHART_VERSION=$(resolve_chart_version "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION")
David Bainbridgecf546362020-04-21 23:18:50 -07001633RESOLVED_KAFKA_CHART_VERSION=$(resolve_chart_version "$KAFKA_CHART" "$KAFKA_CHART_VERSION")
divyadesai59f987a2020-05-27 12:11:33 +00001634RESOLVED_ELASTICSEARCH_CHART_VERSION=$(resolve_chart_version "$ELASTICSEARCH_CHART" "$ELASTICSEARCH_CHART_VERSION")
1635RESOLVED_KIBANA_CHART_VERSION=$(resolve_chart_version "$KIBANA_CHART" "$KIBANA_CHART_VERSION")
1636RESOLVED_FLUENTD_ELASTICSEARCH_CHART_VERSION=$(resolve_chart_version "$FLUENTD_ELASTICSEARCH_CHART" "$FLUENTD_ELASTICSEARCH_CHART_VERSION")
David K. Bainbridge450c15c2020-06-29 10:12:06 -07001637RESOLVED_BBSIM_SADIS_SERVER_CHART_VERSION=$(resolve_chart_version "$BBSIM_SADIS_SERVER_CHART" "$BBSIM_SADIS_SERVER_CHART_VERSION")
1638RESOLVED_RADIUS_CHART_VERSION=$(resolve_chart_version "$RADIUS_CHART" "$RADIUS_CHART_VERSION")
David Bainbridgecf546362020-04-21 23:18:50 -07001639cat <<EOV >>"$LOG"
1640Resolved helm charts and versions:
1641 $VOLTHA_CHART:$RESOLVED_VOLTHA_CHART_VERSION
1642 $VOLTHA_BBSIM_CHART:$RESOLVED_VOLTHA_BBSIM_CHART_VERSION
1643 $VOLTHA_ADAPTER_SIM_CHART:$RESOLVED_VOLTHA_ADAPTER_SIM_CHART_VERSION
1644 $VOLTHA_ADAPTER_OPEN_OLT_CHART:$RESOLVED_VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION
1645 $VOLTHA_ADAPTER_OPEN_ONU_CHART:$RESOLVED_VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION
1646 $ONOS_CHART:$RESOLVED_ONOS_CHART_VERSION
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001647 $ONOS_CLASSIC_CHART:$RESOLVED_ONOS_CLASSIC_CHART_VERSION
David Bainbridgecf546362020-04-21 23:18:50 -07001648 $KAFKA_CHART:$RESOLVED_KAFKA_CHART_VERSION
divyadesai59f987a2020-05-27 12:11:33 +00001649 $ELASTICSEARCH_CHART:$RESOLVED_ELASTICSEARCH_CHART_VERSION
1650 $KIBANA_CHART:$RESOLVED_KIBANA_CHART_VERSION
1651 $FLUENTD_ELASTICSEARCH_CHART:$RESOLVED_FLUENTD_ELASTICSEARCH_CHART_VERSION
David K. Bainbridge450c15c2020-06-29 10:12:06 -07001652 $BBSIM_SADIS_SERVER_CHART:$RESOLVED_BBSIM_SADIS_SERVER_CHART_VERSION
1653 $RADIUS_CHART:$RESOLVED_RADIUS_CHART_VERSION
David Bainbridgecf546362020-04-21 23:18:50 -07001654EOV
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001655
David Bainbridged18f4942020-04-14 16:46:13 -07001656STIME="$(date +%s)"
David Bainbridge0774b232019-08-02 06:37:19 +00001657bspin "Verify Helm values file: $NAME-values.yaml"
1658if [ ! -r "./$NAME-values.yaml" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001659 espin "$NOT_VERIFIED"
David Bainbridge0774b232019-08-02 06:37:19 +00001660 bspin - "Download Helm values file: $TYPE-values.yaml to $NAME-values.yaml $DOWNLOAD"
David Bainbridged18f4942020-04-14 16:46:13 -07001661 ERR_OUT="$(mktemp)"
serkant.uluderya4d315132020-04-15 16:25:54 -07001662 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 -07001663 espin - "$THEX"
1664 echo -e "${RED}${BOLD}${ERROR}ERROR: $NAME-values.yaml${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1665 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
1666 rm -rf "$ERR_OUT" "./$NAME-values.yaml"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001667 exit 1
1668 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001669 rm -rf "$ERR_OUT"
1670 espin - "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001671else
David Bainbridged18f4942020-04-14 16:46:13 -07001672 espin "$VERIFIED"
Test Userba1e7e72019-07-10 22:27:54 +00001673fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001674if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001675 NOW="$(date +%s)"
1676 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001677fi
Test Userba1e7e72019-07-10 22:27:54 +00001678
David Bainbridged18f4942020-04-14 16:46:13 -07001679STIME="$(date +%s)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001680bspin "Verify or download chart specific values files $DOWNLOAD"
1681VALUES_FILES="monkey-values.yaml"
David Bainbridged18f4942020-04-14 16:46:13 -07001682ERR_OUT="$(mktemp)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001683for i in $VALUES_FILES; do
1684 if [ ! -r ./$i ]; then
serkant.uluderya4d315132020-04-15 16:25:54 -07001685 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 -07001686 espin "$THEX"
1687 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1688 echo "ERROR: $i - $(cat "$ERR_OUT")" >>"$LOG"
1689 rm -rf "$ERR_OUT" "./$i"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001690 exit 1
1691 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001692 rm -rf "$ERR_OUT"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001693 fi
1694done
David Bainbridged18f4942020-04-14 16:46:13 -07001695rm -rf "$ERR_OUT"
1696espin "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001697if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001698 NOW="$(date +%s)"
1699 printtime $((NOW - STIME))
David Bainbridge99ac7a22019-08-31 02:26:43 +00001700fi
1701
1702if [ "$WITH_CHAOS" == "yes" ]; then
1703 bspin "Verify or clone kube-monkey helm chart $DOWNLOAD"
1704 if [ -r ./kube-monkey ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001705 espin "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001706 else
David Bainbridged18f4942020-04-14 16:46:13 -07001707 espin "$NOT_VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001708 bspin - "GIT clone kube-monkey"
David Bainbridged18f4942020-04-14 16:46:13 -07001709 (set -x; git clone https://github.com/asobti/kube-monkey kube-monkey >>"$LOG" 2>&1) >>"$LOG" 2>&1
1710 espin - "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00001711 fi
1712fi
1713
Test Userba1e7e72019-07-10 22:27:54 +00001714if [ "$JUST_K8S" == "yes" ]; then
1715 echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye."
1716 echo ""
David Bainbridged18f4942020-04-14 16:46:13 -07001717 echo "Please issue the following commands in your terminal to ensure that you" | tee -a "$LOG"
1718 echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a "$LOG"
1719 echo "tools required by VOLTHA in your command path. " | tee -a "$LOG"
1720 echo "" | tee -a "$LOG"
1721 echo -en "$BOLD"
1722 if [ "$DEPLOY_K8S" == "yes" ]; then
1723 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00001724 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001725 echo "export PATH=$GOPATH/bin:\$PATH" | tee -a "$LOG"
1726 echo -en "$NORMAL"
1727 echo "" | tee -a "$LOG"
1728 echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00001729 exit 0
1730fi
1731
David Bainbridged18f4942020-04-14 16:46:13 -07001732STIME="$(date +%s)"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001733if is_in "$WITH_ONOS" "yes,legacy,classic"; then
1734 if is_in "$WITH_ONOS" "legacy"; then
1735 bspin "Verify ONOS LEGACY installed $BIRD"
1736 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^onos\$" | wc -l)" -ne 1 ]; then
1737 espin "$NOT_VERIFIED"
David Bainbridge33e56c72020-06-11 11:39:56 -07001738 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 -07001739 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
1740 else
1741 espin "$VERIFIED"
1742 fi
1743 wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for ONOS to start" "$NO_LABEL" "onos-.*"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001744
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001745 if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
1746 bspin - "Forward ONOS API port $FORWARD"
1747 kill_port_forward onos-ui
1748 port_forward "$INFRA_NS" onos-ui "$ONOS_API_PORT:8181"
1749 espin - "$VERIFIED"
1750 bspin - "Forward ONOS SSH port $FORWARD"
1751 kill_port_forward onos-ssh
1752 port_forward "$INFRA_NS" onos-ssh "$ONOS_SSH_PORT:8101"
1753 espin - "$VERIFIED"
1754 _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT"
1755 else
1756 _ONOS_API_EP="$(get_service_ep "$INFRA_NS" onos-ui)"
1757 fi
1758 elif is_in "$WITH_ONOS" "yes,classic"; then
1759 bspin "Verify ONOS CLASSIC installed $BIRD"
1760 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^onos\$" | wc -l)" -ne 1 ]; then
1761 espin "$NOT_VERIFIED"
Matteo Scandoloe0829b52020-05-08 14:23:56 -07001762 # 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 -07001763 # values value
David Bainbridgefad50732020-05-01 17:00:12 -07001764 YAML_VALUES=$(INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set replicas=$NUM_OF_ONOS --set atomix.replicas=$NUM_OF_ATOMIX" \
1765 helm_values "$INFRA_NS" onos "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION")
1766 _ONOS_REPO="$(echo "$YAML_VALUES" | yq read - images.onos.repository)"
David Bainbridgedee3f022020-06-05 07:45:13 -07001767 if [ -z "$_ONOS_REPO" ]; then
1768 _ONOS_REPO="voltha/voltha-onos"
1769 fi
David Bainbridgefad50732020-05-01 17:00:12 -07001770 _ONOS_TAG="$(echo "$YAML_VALUES" | yq read - images.onos.tag)"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001771 if [ -z "$_ONOS_TAG" ]; then
David Bainbridgedee3f022020-06-05 07:45:13 -07001772 _ONOS_TAG="$(echo "$YAML_VALUES" | yq read - defaults.image_tag)"
1773 fi
1774 if [ -z "$_ONOS_TAG" ]; then
1775 _ONOS_TAG="master"
1776 fi
1777 _ONOS_PULL_POLICY="$(echo "$YAML_VALUES" | yq read - images.onos.pullPolicy)"
1778 if [ -z "$_ONOS_PULL_POLICY" ]; then
1779 _ONOS_PULL_POLICY="$(echo "$YAML_VALUES" | yq read - defaults.image_pullPolicy)"
1780 fi
1781 if [ -z "$_ONOS_PULL_POLICY" ]; then
1782 _ONOS_PULL_POLICY="Always"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001783 fi
David Bainbridgefad50732020-05-01 17:00:12 -07001784
Matteo Scandoloe0829b52020-05-08 14:23:56 -07001785 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 -07001786 helm_install - "$INFRA_NS" onos "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION" "+onos" "$_HELM_DESC ONOS CLASSIC"
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001787 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
1788 else
1789 espin "$VERIFIED"
1790 fi
1791 wait_for_pods - "$INFRA_NS" $((NUM_OF_ONOS + NUM_OF_ATOMIX)) "includes" "Waiting for ONOS CLASSIC to start" "$NO_LABEL" "onos-.*"
1792 if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
1793 bspin - "Forward ONOS API port $FORWARD"
1794 kill_port_forward onos-onos-classic-hs
1795 port_forward "$INFRA_NS" onos-onos-classic-hs "$ONOS_API_PORT:8181" "$ONOS_SSH_PORT:8101"
1796 espin - "$VERIFIED"
1797 _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT"
1798 else
1799 _ONOS_API_EP="$(get_service_ep "$INFRA_NS" onos-onos-classic-hs)"
1800 fi
1801 elif [ "$WITH_ONOS" == "micro" ]; then
1802 bspin "Verify micro-ONOS installed $BIRD"
1803 # We should never get here
1804 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Micro ONOS not currently supported${NORMAL}"
1805 exit 1
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001806 fi
David Bainbridged31d6122019-08-13 19:37:59 +00001807 bspin - "Verify or download ONOS configuration support files $DOWNLOAD"
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001808 ONOS_FILES="olt-onos-enableExtraneousRules.json onos-aaa.json \
David Bainbridge696bc632020-04-05 21:49:37 -07001809 onos-dhcpl2relay.json onos-sadis-sample.json"
David Bainbridged18f4942020-04-14 16:46:13 -07001810 (set -x; mkdir -p ./onos-files >>"$LOG" 2>&1) >>"$LOG" 2>&1
1811 ERR_OUT="$(mktemp)"
David Bainbridge2b19e832019-08-16 02:40:53 +00001812 for i in $ONOS_FILES; do
David Bainbridged18f4942020-04-14 16:46:13 -07001813 if [ ! -r "./onos-files/$i" ]; then
serkant.uluderya4d315132020-04-15 16:25:54 -07001814 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 -07001815 espin - "$THEX"
1816 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}"
1817 echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG"
1818 rm -rf "$ERR_OUT" "./onos-files/$i"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001819 exit 1
1820 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001821 rm -rf "$ERR_OUT"
David Bainbridged31d6122019-08-13 19:37:59 +00001822 fi
1823 done
David Bainbridged18f4942020-04-14 16:46:13 -07001824 rm -rf "$ERR_OUT"
1825 espin - "$VERIFIED"
David Bainbridge27790d62019-08-13 22:43:19 +00001826
David Bainbridged18f4942020-04-14 16:46:13 -07001827 if [ "$INSTALL_ONOS_APPS" == "yes" ]; then
David Bainbridge27790d62019-08-13 22:43:19 +00001828 bspin - "Installing custom ONOS applications"
David Bainbridged18f4942020-04-14 16:46:13 -07001829 if [ -x onos-files/onos-apps ] && [ "$(find onos-files/onos-apps -name "*.oar" 2>/dev/null | wc -l)" -gt 0 ]; then
1830 for OAR in onos-files/onos-apps/*.oar; do
David Bainbridge27790d62019-08-13 22:43:19 +00001831 sspin - "Installing custom ONOS applications - $OAR$CEOL"
David Bainbridged18f4942020-04-14 16:46:13 -07001832 override_onos_app "$OAR"
David Bainbridge27790d62019-08-13 22:43:19 +00001833 done
1834 espin - "$VERIFIED Installing custom ONOS applications$CEOL"
1835 else
1836 espin - "$NOT_VERIFIED Installing custom ONOS applications - None Found"
1837 fi
1838 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001839
David Bainbridged18f4942020-04-14 16:46:13 -07001840 if [ "$WITH_KAFKA" != "no" ]; then
David Bainbridge837e8bd2020-04-06 13:17:14 -07001841 check_onos_app_active org.opencord.kafka
David Bainbridge879439b2020-06-12 15:59:35 -07001842 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridgec7220622020-05-28 12:31:47 -07001843 _HOST=kafka.$INFRA_NS.svc
David Bainbridge76afd812020-04-06 09:53:52 -07001844 _PORT=9092
David Bainbridge879439b2020-06-12 15:59:35 -07001845 elif [ "$WITH_KAFKA" != "no" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001846 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
1847 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge837e8bd2020-04-06 13:17:14 -07001848 _PORT=${_PORT:-9092}
1849 fi
1850 push_onos_config "json" "Push ONOS Kafka Configuration" "network/configuration/apps/org.opencord.kafka" \
David Bainbridged18f4942020-04-14 16:46:13 -07001851 "$(cat <<EOJ | tr -d '[:space:]'
David Bainbridge696bc632020-04-05 21:49:37 -07001852{
1853 "kafka": {
1854 "bootstrapServers": "$_HOST:$_PORT"
1855 }
1856}
1857EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07001858)"
David Bainbridge837e8bd2020-04-06 13:17:14 -07001859 fi
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001860 check_onos_app_active org.opencord.dhcpl2relay
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001861 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 -08001862 check_onos_app_active org.opencord.olt
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001863 # FIXME use WITH_DHCP and WITH_EAPOL flags to configre OLT App
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001864 # Default value for "enableEapol" is true in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07001865 if [ "$WITH_EAPOL" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001866 push_onos_config "json" "Enable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":true}'
David Bainbridged18f4942020-04-14 16:46:13 -07001867 elif [ "$WITH_EAPOL" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001868 push_onos_config "json" "Disable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001869 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001870 # Default value for "enableDhcpOnProvisioning" is false and for "enableDhcpV4" is true in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07001871 if [ "$WITH_DHCP" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001872 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 -07001873 elif [ "$WITH_DHCP" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001874 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 -08001875 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001876 # Default value for "enableIgmpOnProvisioning" is false in OLT App
David Bainbridged18f4942020-04-14 16:46:13 -07001877 if [ "$WITH_IGMP" == "yes" ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001878 push_onos_config "json" "Enable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":true}'
David Bainbridged18f4942020-04-14 16:46:13 -07001879 elif [ "$WITH_IGMP" == "no" ]; then
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001880 push_onos_config "json" "Disable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001881 fi
David Bainbridged18f4942020-04-14 16:46:13 -07001882 if [ "$ENABLE_ONOS_EXTRANEOUS_RULES" == "yes" ]; then
David K. Bainbridge484d80c2020-03-05 21:44:34 -08001883 push_onos_config "file" "Enabling extraneous rules for ONOS" "configuration/org.onosproject.net.flow.impl.FlowRuleManager" "onos-files/olt-onos-enableExtraneousRules.json"
1884 fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -07001885 if is_in "$CONFIG_SADIS" "yes,file"; then
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001886 check_onos_app_active org.opencord.sadis
Hardik Windlassb3147602020-03-09 16:59:15 +05301887 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 -07001888 elif [ "$CONFIG_SADIS" == "bbsim" ]; then
1889 push_onos_config "json" \
1890 "[optional] Push ONOS configuration for BBSIM SADIS servers" \
1891 "network/configuration/apps/org.opencord.sadis" \
David Bainbridged18f4942020-04-14 16:46:13 -07001892 "$(cat <<EOJ | tr -d '[:space:]'
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001893{
1894 "sadis": {
1895 "integration": {
David Bainbridgec7220622020-05-28 12:31:47 -07001896 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:50074/v2/subscribers/%s",
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001897 "cache": {
1898 "enabled": true,
1899 "maxsize": 50,
1900 "ttl": "PT1m"
1901 }
1902 }
1903 },
1904 "bandwidthprofile": {
1905 "integration": {
David Bainbridgec7220622020-05-28 12:31:47 -07001906 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:50074/v2/bandwidthprofiles/%s",
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001907 "cache": {
1908 "enabled": true,
1909 "maxsize": 50,
1910 "ttl": "PT1m"
1911 }
1912 }
1913 }
1914}
1915EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07001916)"
David Bainbridge309099c2020-05-05 08:47:29 -07001917 elif [ "$CONFIG_SADIS" == "external" ]; then
David Bainbridge879439b2020-06-12 15:59:35 -07001918 if kubectl get -n "$BBSIM_NS" svc/bbsim-sadis-server-bbsim-sadis-server >/dev/null 2>&1; then
1919 BBSIM_SADIS_SVC="bbsim-sadis-server-bbsim-sadis-server"
1920 else
1921 BBSIM_SADIS_SVC="bbsim-sadis-server"
1922 fi
David Bainbridge309099c2020-05-05 08:47:29 -07001923 push_onos_config "json" \
1924 "[optional] Push ONOS configuration for custom SADIS and Bandwidth Profile servers" \
1925 "network/configuration/apps/org.opencord.sadis" \
1926 "$(cat <<EOJ | tr -d '[:space:]'
1927{
1928 "sadis": {
1929 "integration": {
David Bainbridge879439b2020-06-12 15:59:35 -07001930 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:58080/subscribers/%s",
David Bainbridge309099c2020-05-05 08:47:29 -07001931 "cache": {
1932 "enabled": true,
1933 "maxsize": 50,
1934 "ttl": "PT1m"
1935 }
1936 }
1937 },
1938 "bandwidthprofile": {
1939 "integration": {
David Bainbridge879439b2020-06-12 15:59:35 -07001940 "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:58080/profiles/%s",
David Bainbridge309099c2020-05-05 08:47:29 -07001941 "cache": {
1942 "enabled": true,
1943 "maxsize": 50,
1944 "ttl": "PT1m"
1945 }
1946 }
1947 }
1948}
1949EOJ
1950)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001951 elif [ "$CONFIG_SADIS" == "url" ]; then
1952 push_onos_config "json" \
1953 "[optional] Push ONOS configuration for custom SADIS and Bandwidth Profile servers" \
1954 "network/configuration/apps/org.opencord.sadis" \
David Bainbridged18f4942020-04-14 16:46:13 -07001955 "$(cat <<EOJ | tr -d '[:space:]'
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001956{
1957 "sadis": {
1958 "integration": {
1959 "url": "$SADIS_SUBSCRIBERS",
1960 "cache": {
1961 "enabled": true,
1962 "maxsize": 50,
1963 "ttl": "PT1m"
1964 }
1965 }
1966 },
1967 "bandwidthprofile": {
1968 "integration": {
1969 "url": "$SADIS_BANDWIDTH_PROFILES",
1970 "cache": {
1971 "enabled": true,
1972 "maxsize": 50,
1973 "ttl": "PT1m"
1974 }
1975 }
1976 }
1977}
1978EOJ
David Bainbridged18f4942020-04-14 16:46:13 -07001979)"
David Bainbridge2b19e832019-08-16 02:40:53 +00001980 fi
Test Userba1e7e72019-07-10 22:27:54 +00001981fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001982if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001983 NOW="$(date +%s)"
1984 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00001985fi
Test Userba1e7e72019-07-10 22:27:54 +00001986
David Bainbridgec7220622020-05-28 12:31:47 -07001987if is_in "$WITH_ETCD" "yes,external"; then
David Bainbridged18f4942020-04-14 16:46:13 -07001988 STIME="$(date +%s)"
David Bainbridge76afd812020-04-06 09:53:52 -07001989 bspin "Verify external ETCD cluster $OLD_KEY"
David Bainbridge43f2df52020-06-02 15:30:54 -07001990 EXPECT="$(yq r - "etcd.replicas" <"$NAME-values.yaml")"
David Bainbridgec7220622020-05-28 12:31:47 -07001991 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 -07001992 espin "$NOT_VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07001993 helm_install - "$INFRA_NS" etcd "$ETCD_CHART" "$ETCD_CHART_VERSION" etcd "$_HELM_DESC external ETCD cluster"
David Bainbridge76afd812020-04-06 09:53:52 -07001994 else
David Bainbridged18f4942020-04-14 16:46:13 -07001995 espin "$VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07001996 fi
David Bainbridgec7220622020-05-28 12:31:47 -07001997 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for ETCD cluster to start" "$NO_LABEL" "etcd-.*"
David Bainbridge76afd812020-04-06 09:53:52 -07001998 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07001999 NOW="$(date +%s)"
2000 printtime $((NOW - STIME))
David Bainbridge76afd812020-04-06 09:53:52 -07002001 fi
2002fi
2003
David Bainbridgec7220622020-05-28 12:31:47 -07002004if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridged18f4942020-04-14 16:46:13 -07002005 _TMP="$(mktemp -u)"
2006 _COUNT="$(test "$TYPE" == "minimal" && echo "1" || echo "3")"
2007 cat << EOC > "$_TMP"
David Bainbridge76afd812020-04-06 09:53:52 -07002008configurationOverrides:
2009 "default.replication.factor": $_COUNT
2010 "offsets.topic.replication.factor": $_COUNT
2011 "log.retention.hours": 4
2012 "log.message.timestamp.type": "LogAppendTime"
2013persistence:
2014 enabled: false
2015zookeeper:
2016 replicaCount: 1
2017 persistence:
2018 enabled: false
2019replicas: $_COUNT
2020EOC
David Bainbridged18f4942020-04-14 16:46:13 -07002021 STIME="$(date +%s)"
David Bainbridge76afd812020-04-06 09:53:52 -07002022 bspin "Verify external Kafka cluster $OLD_KEY"
David Bainbridged18f4942020-04-14 16:46:13 -07002023 EXPECT="$(test "$TYPE" == "minimal" && echo "2" || echo "4")"
2024 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^kafka\$" | wc -l)" -ne 1 ]; then
2025 espin "$NOT_VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07002026 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" -f $_TMP"
David Bainbridgec7220622020-05-28 12:31:47 -07002027 helm_install - "$INFRA_NS" kafka "$KAFKA_CHART" "$KAFKA_CHART_VERSION" kafka "$_HELM_DESC external Kafka cluster"
David Bainbridge76afd812020-04-06 09:53:52 -07002028 else
David Bainbridged18f4942020-04-14 16:46:13 -07002029 espin "$VERIFIED"
David Bainbridge76afd812020-04-06 09:53:52 -07002030 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002031 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for Kafka cluster to start" "$NO_LABEL" "kafka-.*"
David Bainbridge76afd812020-04-06 09:53:52 -07002032 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002033 NOW="$(date +%s)"
2034 printtime $((NOW - STIME))
David Bainbridge76afd812020-04-06 09:53:52 -07002035 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002036 rm -rf "$_TMP"
David Bainbridge76afd812020-04-06 09:53:52 -07002037fi
2038
David Bainbridged18f4942020-04-14 16:46:13 -07002039STIME="$(date +%s)"
David Bainbridgeed476572020-06-02 14:05:45 -07002040EXPECT=2
2041# therecanbeonlyone set hardcoded to true for backward compatibility
2042INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set therecanbeonlyone=true"
Matteo Scandolo67335f02020-04-09 11:19:53 -07002043case $WITH_ETCD in
David Bainbridge76afd812020-04-06 09:53:52 -07002044 no)
David Bainbridge76afd812020-04-06 09:53:52 -07002045 ;;
David Bainbridgec7220622020-05-28 12:31:47 -07002046 yes|external)
2047 _HOST="etcd.$INFRA_NS.svc"
David Bainbridge76afd812020-04-06 09:53:52 -07002048 _PORT=2379
2049 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridge76afd812020-04-06 09:53:52 -07002050 ;;
2051 *)
David Bainbridged18f4942020-04-14 16:46:13 -07002052 _HOST="$(echo "$WITH_ETCD" | cut -d: -f1)"
2053 _PORT="$(echo "$WITH_ETCD" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07002054 _PORT=${_PORT:-2379}
David Bainbridgec7220622020-05-28 12:31:47 -07002055 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridge76afd812020-04-06 09:53:52 -07002056 ;;
2057esac
2058case $WITH_KAFKA in
2059 no)
David Bainbridge76afd812020-04-06 09:53:52 -07002060 ;;
David Bainbridgec7220622020-05-28 12:31:47 -07002061 yes|external)
2062 _HOST=kafka.$INFRA_NS.svc
David Bainbridge76afd812020-04-06 09:53:52 -07002063 _PORT=9092
2064 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 -07002065 ;;
2066 *)
David Bainbridged18f4942020-04-14 16:46:13 -07002067 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
2068 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07002069 _PORT=${_PORT:-9092}
David Bainbridgec7220622020-05-28 12:31:47 -07002070 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 -07002071 ;;
2072esac
2073
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002074if is_in "$WITH_ONOS" "legacy"; then
David Bainbridgec7220622020-05-28 12:31:47 -07002075 _HOST=onos-openflow.$INFRA_NS.svc
David Bainbridge76afd812020-04-06 09:53:52 -07002076 _PORT=6653
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002077elif is_in "$WITH_ONOS" "yes,classic"; then
David Bainbridgec7220622020-05-28 12:31:47 -07002078 _HOST=onos-onos-classic-hs.$INFRA_NS.svc
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002079 _PORT=6653
David Bainbridged18f4942020-04-14 16:46:13 -07002080elif [ "$WITH_ONOS" != "no" ]; then
2081 _HOST="$(echo "$WITH_ONOS" | cut -d: -f1)"
2082 _PORT="$(echo "$WITH_ONOS" | cut -s -d: -f2)"
David Bainbridge76afd812020-04-06 09:53:52 -07002083 _PORT=${_PORT:-6653}
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002084fi
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002085
David Bainbridgecf546362020-04-21 23:18:50 -07002086compare_versions "$RESOLVED_VOLTHA_CHART_VERSION" 2.4.2
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002087if [ "$?" == "1" ]; then
2088 # voltha chart > 2.4.2 uses list of controllers
David Bainbridgee4d11ca2020-05-08 10:21:10 -07002089 for NUM in $(seq 0 $((NUM_OF_ONOS-1))); do
David Bainbridgec7220622020-05-28 12:31:47 -07002090 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 -07002091 done
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002092else
2093 # voltha chart <= 2.4.2 uses single controller
David Bainbridge76afd812020-04-06 09:53:52 -07002094 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.controller.service=$_HOST --set services.controller.port=$_PORT"
David Bainbridge696bc632020-04-05 21:49:37 -07002095fi
Jonathan Hart6a91e6c2020-04-16 14:28:33 -07002096
Test Userb5712372019-07-03 21:52:17 +00002097bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
David Bainbridged18f4942020-04-14 16:46:13 -07002098if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$VOLTHA_NS" "^voltha\$" | wc -l)" -ne 1 ]; then
2099 espin "$NOT_VERIFIED"
David Bainbridgea965ca22020-06-09 17:45:04 -07002100 helm_install - "$VOLTHA_NS" voltha "$VOLTHA_CHART" "$VOLTHA_CHART_VERSION" "+voltha" "$_HELM_DESC VOLTHA Core"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002101else
David Bainbridged18f4942020-04-14 16:46:13 -07002102 espin "$VERIFIED"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002103fi
David Bainbridge696bc632020-04-05 21:49:37 -07002104INTERNAL_EXTRA_HELM_INSTALL_ARGS=
Test Userba1e7e72019-07-10 22:27:54 +00002105
David Bainbridge90fd8e32019-08-21 23:32:47 +00002106VOLTHA="voltha-ofagent-.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002107 rw-core.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002108 voltha-zookeeper-.*"
David Bainbridged18f4942020-04-14 16:46:13 -07002109wait_for_pods - "$VOLTHA_NS" "$EXPECT" "includes" "Waiting for VOLTHA Core to start" "$NO_LABEL" "$VOLTHA"
David Bainbridgee87067b2019-08-12 22:00:12 +00002110if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002111 NOW="$(date +%s)"
2112 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002113fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002114
David Bainbridge46505fb2019-10-01 21:13:20 +00002115if [ "$WITH_ADAPTERS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002116 STIME="$(date +%s)"
David Bainbridge46505fb2019-10-01 21:13:20 +00002117 EXPECT=0
David Bainbridgec7220622020-05-28 12:31:47 -07002118 if is_in "$WITH_ETCD" "yes,external"; then
2119 _HOST=etcd.$INFRA_NS.svc
David Bainbridge3517f6c2020-04-08 12:14:08 -07002120 _PORT=2379
2121 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridged18f4942020-04-14 16:46:13 -07002122 elif [ "$WITH_ETCD" != "no" ]; then
2123 _HOST="$(echo "$WITH_ETCD" | cut -d: -f1)"
2124 _PORT="$(echo "$WITH_ETCD" | cut -s -d: -f2)"
David Bainbridge3517f6c2020-04-08 12:14:08 -07002125 _PORT=${_PORT:-2379}
2126 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
David Bainbridge696bc632020-04-05 21:49:37 -07002127 fi
David Bainbridgec7220622020-05-28 12:31:47 -07002128 if is_in "$WITH_KAFKA" "yes,external"; then
2129 _HOST=kafka.$INFRA_NS.svc
David Bainbridge3517f6c2020-04-08 12:14:08 -07002130 _PORT=9092
2131 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 -07002132 elif [ "$WITH_KAFKA" != "no" ]; then
2133 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
2134 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
David Bainbridge3517f6c2020-04-08 12:14:08 -07002135 _PORT=${_PORT:-9092}
2136 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 -07002137 fi
David Bainbridge46505fb2019-10-01 21:13:20 +00002138 echo -e "Verify Adapters $PLUG"
2139 if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then
2140 bspin - "Verify Simulated Adapters installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002141 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$ADAPTER_NS" "^sim\$" | wc -l)" -ne 1 ]; then
2142 espin - "$NOT_VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002143 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 +00002144 else
David Bainbridged18f4942020-04-14 16:46:13 -07002145 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00002146 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002147 EXPECT="$((EXPECT + 2))"
David Bainbridge46505fb2019-10-01 21:13:20 +00002148 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07002149
David Bainbridge46505fb2019-10-01 21:13:20 +00002150 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
2151 bspin - "Verify OpenOLT Adapter installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002152 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$ADAPTER_NS" "^open-olt\$" | wc -l)" -ne 1 ]; then
2153 espin - "$NOT_VERIFIED"
David Bainbridgea965ca22020-06-09 17:45:04 -07002154 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 +00002155 else
David Bainbridged18f4942020-04-14 16:46:13 -07002156 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00002157 fi
Matteo Scandolo67335f02020-04-09 11:19:53 -07002158 EXPECT="$((EXPECT + 1))"
David Bainbridge46505fb2019-10-01 21:13:20 +00002159 bspin - "Verify OpenONU Adapter installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002160 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 -07002161 _ORIGINAL_EXTRA_HELM_INSTALL_ARGS="$INTERNAL_EXTRA_HELM_INSTALL_ARGS"
2162 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set replicas.adapter_open_onu=$NUM_OF_OPENONU"
Girish Gowdra4cc5d8b2020-06-11 17:12:00 -07002163 if [ "$WITH_INCREMENTAL_EVTO_UPDATE" == "yes" ]; then
Girish Gowdra1c7ad4c2020-06-26 13:35:16 -07002164 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set defaults.incremental_evto_update=true"
Girish Gowdra4cc5d8b2020-06-11 17:12:00 -07002165 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002166 espin - "$NOT_VERIFIED"
David Bainbridgea965ca22020-06-09 17:45:04 -07002167 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 -07002168 INTERNAL_EXTRA_HELM_INSTALL_ARGS="$_ORIGINAL_EXTRA_HELM_INSTALL_ARGS"
David Bainbridge46505fb2019-10-01 21:13:20 +00002169 else
David Bainbridged18f4942020-04-14 16:46:13 -07002170 espin - "$VERIFIED"
David Bainbridge46505fb2019-10-01 21:13:20 +00002171 fi
Matteo Scandolo67335f02020-04-09 11:19:53 -07002172 EXPECT=$((EXPECT + NUM_OF_OPENONU))
David Bainbridge46505fb2019-10-01 21:13:20 +00002173 fi
David Bainbridge696bc632020-04-05 21:49:37 -07002174 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07002175
David Bainbridge46505fb2019-10-01 21:13:20 +00002176 ADAPTERS="adapter-.*"
David Bainbridged18f4942020-04-14 16:46:13 -07002177 wait_for_pods - "$ADAPTER_NS" "$EXPECT" "includes" "Waiting for adapters to start" "$NO_LABEL" "$ADAPTERS"
David Bainbridge46505fb2019-10-01 21:13:20 +00002178 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002179 NOW="$(date +%s)"
2180 printtime $((NOW - STIME))
David Bainbridge46505fb2019-10-01 21:13:20 +00002181 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00002182fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07002183
David Bainbridged18f4942020-04-14 16:46:13 -07002184if [ "$WITH_BBSIM" == "yes" ]; then
2185 STIME="$(date +%s)"
Test User7d866122019-07-09 17:52:35 +00002186 echo -e "Verify BBSIM $PLUG"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002187 bspin - "Verify BBSIM Installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002188 for instance in $(seq 0 $((NUM_OF_BBSIM-1))); do
Matteo Scandoloc2eb0672020-05-01 14:43:15 -07002189
2190 if [ "$LEGACY_BBSIM_INDEX" == "yes" ]; then
2191 if [ "$instance" -eq 0 ]; then
2192 instance_num=""
2193 else
2194 instance_num=$instance
2195 fi
David K. Bainbridge43422402020-03-06 07:41:22 -08002196 else
2197 instance_num=$instance
2198 fi
Matteo Scandoloc2eb0672020-05-01 14:43:15 -07002199
2200
David Bainbridged18f4942020-04-14 16:46:13 -07002201 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$BBSIM_NS" "^bbsim${instance_num}\$" | wc -l)" -ne 1 ]; then
2202 espin - "$NOT_VERIFIED"
2203 S_TAG="$((900+instance))"
Matteo Scandolo5a149572020-04-01 10:14:57 -07002204 INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set olt_id=$instance,s_tag=$S_TAG"
David Bainbridged9329af2020-05-01 11:58:52 -07002205 if [ "$WITH_EAPOL" == "yes" ]; then
2206 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set auth=true"
2207 else
2208 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set auth=false"
2209 fi
2210 if [ "$WITH_DHCP" == "yes" ]; then
2211 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set dhcp=true"
2212 else
2213 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set dhcp=false"
2214 fi
David Bainbridge33e56c72020-06-11 11:39:56 -07002215 if is_in "$WITH_KAFKA" "yes,external"; then
2216 _HOST=kafka.$INFRA_NS.svc
2217 _PORT=9092
2218 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafkaAddress=$_HOST:$_PORT"
2219 elif [ "$WITH_KAFKA" != "no" ]; then
2220 _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
2221 _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
2222 _PORT=${_PORT:-9092}
2223 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafkaAddress=$_HOST:$_PORT"
2224 fi
2225 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 -07002226 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
David K. Bainbridge43422402020-03-06 07:41:22 -08002227 else
David Bainbridged18f4942020-04-14 16:46:13 -07002228 espin - "$VERIFIED"
David K. Bainbridge43422402020-03-06 07:41:22 -08002229 fi
2230 done
David Bainbridged18f4942020-04-14 16:46:13 -07002231 wait_for_pods - "$BBSIM_NS" "$NUM_OF_BBSIM" "includes" "Waiting for BBSIM to start" "$BBSIM_LABEL" "bbsim*"
David Bainbridgee87067b2019-08-12 22:00:12 +00002232 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002233 NOW="$(date +%s)"
2234 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002235 fi
Test User7d866122019-07-09 17:52:35 +00002236fi
2237
divyadesai59f987a2020-05-27 12:11:33 +00002238if [ "$WITH_EFK" == "yes" ]; then
2239 STIME="$(date +%s)"
2240 echo -e "Verify EFK $PLUG"
2241 bspin - "Verify EFK Installed"
2242 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
2243 espin - "$NOT_VERIFIED"
2244 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^elasticsearch\$" | wc -l)" -ne 1 ]; then
2245 helm_install - "$INFRA_NS" elasticsearch "$ELASTICSEARCH_CHART" "$ELASTICSEARCH_CHART_VERSION" elasticsearch "$_HELM_DESC elasticsearch"
2246 fi
2247 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^kibana\$" | wc -l)" -ne 1 ]; then
2248 helm_install - "$INFRA_NS" kibana "$KIBANA_CHART" "$KIBANA_CHART_VERSION" kibana "$_HELM_DESC kibana"
2249 fi
2250 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^fluentd\$" | wc -l)" -ne 1 ]; then
2251 helm_install - "$INFRA_NS" fluentd "$FLUENTD_ELASTICSEARCH_CHART" "$FLUENTD_ELASTICSEARCH_CHART_VERSION" fluentd-elasticsearch "$_HELM_DESC fluentd-elasticsearch"
2252 fi
2253 else
2254 espin - "$VERIFIED"
2255 fi
2256 EXPECT=2 # for elastic and kibana
2257 if [ "$TYPE" == "minimal" ]; then
2258 EXPECT=$((EXPECT + 2)) # for fluentd on worker 2 worker nodes
2259 else
2260 EXPECT=$((EXPECT + 3)) # for fluentd on worker 3 worker nodes
2261 fi
2262 if [ "$SCHEDULE_ON_CONTROL_NODES" == "yes" ]; then
2263 EXPECT=$((EXPECT + 1)) # for fluentd on the control plan node
2264 fi
2265
2266 wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for EFK to start" "$NO_LABEL" "fluentd-* elasticsearch-* kibana-*"
2267 if [ "$WITH_TIMINGS" == "yes" ]; then
2268 NOW="$(date +%s)"
2269 printtime $((NOW - STIME))
2270 fi
2271fi
2272
David Bainbridge309099c2020-05-05 08:47:29 -07002273if [ "$CONFIG_SADIS" == "external" ]; then
2274 STIME="$(date +%s)"
2275 echo -e "Verify BBSIM SADIS Service $PLUG"
2276 bspin - "Verify required configmap"
2277 (set -x; kubectl -n "$BBSIM_NS" delete --ignore-not-found configmap kube-config >>"$LOG" 2>&1) >>"$LOG" 2>&1
2278 (set -x; kubectl -n "$BBSIM_NS" create configmap kube-config "--from-file=kube_config=$KUBECONFIG" >>"$LOG" 2>&1) >>"$LOG" 2>&1
2279 espin - "$VERIFIED"
2280 bspin - "Verify BBSIM SADIS Service Installed"
divyadesai59f987a2020-05-27 12:11:33 +00002281 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 -07002282 espin - "$NOT_VERIFIED"
David Bainbridge879439b2020-06-12 15:59:35 -07002283 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 -07002284 else
2285 espin - "$VERIFIED"
2286 fi
2287 wait_for_pods - "$BBSIM_NS" 1 "includes" "Waiting for BBSIM SADIS Server to start" "$NO_LABEL" "bbsim-sadis-server-.*"
2288 if [ "$WITH_TIMINGS" == "yes" ]; then
2289 NOW="$(date +%s)"
2290 printtime $((NOW - STIME))
2291 fi
2292fi
2293
David Bainbridged18f4942020-04-14 16:46:13 -07002294if [ "$WITH_RADIUS" == "yes" ]; then
2295 STIME="$(date +%s)"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002296 echo -e "Verify RADIUS $LOCK"
2297 bspin - "Verify RADIUS Installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002298 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^radius\$" | wc -l)" -ne 1 ]; then
2299 espin - "$NOT_VERIFIED"
David Bainbridge879439b2020-06-12 15:59:35 -07002300 helm_install - "$INFRA_NS" radius "$RADIUS_CHART" "$RADIUS_CHART_VERSION" "+radius" "$_HELM_DESC RADIUS"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002301 else
David Bainbridged18f4942020-04-14 16:46:13 -07002302 espin - "$VERIFIED"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002303 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002304 wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for RADIUS to start" "$NO_LABEL" "radius-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00002305 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002306 NOW="$(date +%s)"
2307 printtime $((NOW - STIME))
David Bainbridgee87067b2019-08-12 22:00:12 +00002308 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002309fi
2310
David Bainbridged18f4942020-04-14 16:46:13 -07002311if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
2312 STIME="$(date +%s)"
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002313 bspin - "Forward VOLTHA API port $FORWARD"
David Bainbridge1d2c5842020-06-03 15:29:07 -07002314 kill_port_forward voltha-api voltha-voltha-api
2315 VOLTHA_PREFIX=
2316 if kubectl get -n "$VOLTHA_NS" "svc/voltha-voltha-api" >/dev/null 2>&1; then
2317 VOLTHA_PREFIX="voltha-"
2318 fi
2319
2320 port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-api" "$VOLTHA_API_PORT:55555"
David Bainbridged18f4942020-04-14 16:46:13 -07002321 espin - "$VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002322 if is_in "$WITH_ETCD" "yes,external"; then
David Bainbridge696bc632020-04-05 21:49:37 -07002323 bspin - "Forward VOLTHA ETCD port $FORWARD"
David Bainbridgec7220622020-05-28 12:31:47 -07002324 kill_port_forward "etcd"
2325 port_forward "$INFRA_NS" "etcd" "$VOLTHA_ETCD_PORT:2379"
David Bainbridged18f4942020-04-14 16:46:13 -07002326 espin - "$VERIFIED"
David Bainbridge696bc632020-04-05 21:49:37 -07002327 fi
David Bainbridgec7220622020-05-28 12:31:47 -07002328 if is_in "$WITH_KAFKA" "yes,external"; then
David Bainbridge696bc632020-04-05 21:49:37 -07002329 bspin - "Forward VOLTHA Kafka port $FORWARD"
David Bainbridgec7220622020-05-28 12:31:47 -07002330 kill_port_forward "kafka"
2331 port_forward "$INFRA_NS" kafka "$VOLTHA_KAFKA_PORT:9092"
David Bainbridged18f4942020-04-14 16:46:13 -07002332 espin - "$VERIFIED"
David Bainbridge696bc632020-04-05 21:49:37 -07002333 fi
divyadesai59f987a2020-05-27 12:11:33 +00002334 if [ "$WITH_EFK" == "yes" ]; then
2335 bspin - "Forward EFK port $FORWARD"
2336 kill_port_forward elasticsearch-master
2337 kill_port_forward kibana-kibana
2338 port_forward "$INFRA_NS" elasticsearch-master "$ELASTICSEARCH_PORT:9200"
2339 port_forward "$INFRA_NS" kibana-kibana "$KIBANA_PORT:5601"
2340 espin - "$VERIFIED"
2341 fi
Matteo Scandoloefee0432020-05-05 13:56:20 -07002342 if [ "$WITH_PPROF" == "yes" ]; then
David Bainbridge1d2c5842020-06-03 15:29:07 -07002343 VOLTHA_OPENOLT_PREFIX=
2344 if kubectl get -n "$ADAPTER_NS" "svc/open-olt-adapter-open-olt-profiler" >/dev/null 2>&1; then
2345 VOLTHA_OPENOLT_PREFIX="open-olt-"
2346 fi
David Bainbridge879439b2020-06-12 15:59:35 -07002347 bspin - "Forward PProf ports port $FORWARD"
2348 kill_port_forward voltha-rw-core-profiler voltha-voltha-rw-core-profiler
2349 kill_port_forward adapter-open-olt-profiler open-olt-adapter-open-olt-profiler
2350 kill_port_forward voltha-of-agent-profiler voltha-voltha-of-agent-profiler
2351 port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-rw-core-profiler" "$VOLTHA_PPROF_PORT:6060"
2352 port_forward "$ADAPTER_NS" "${VOLTHA_OPENOLT_PREFIX}adapter-open-olt-profiler" "$OPENOLT_PPROF_PORT:6060"
2353 port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-of-agent-profiler" "$OFAGENT_PPROF_PORT:6060"
2354 espin - "$VERIFIED"
Matteo Scandoloefee0432020-05-05 13:56:20 -07002355 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002356 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002357 NOW="$(date +%s)"
2358 printtime $((NOW - STIME))
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002359 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00002360fi
Test User3d7ad8e2019-07-03 06:15:44 +00002361
David Bainbridge60ffc0f2020-04-27 22:13:22 -07002362if is_in "$WITH_ONOS" "yes,legacy,classic" && [ "$WITH_RADIUS" != "no" ]; then
David Bainbridge879439b2020-06-12 15:59:35 -07002363 SVC_NAME=radius
2364 if kubectl get -n "$INFRA_NS" "svc/radius-freeradius" >/dev/null 2>&1; then
2365 SVC_NAME="radius-freeradius"
2366 fi
2367 _HOST="$SVC_NAME.$INFRA_NS.svc"
David Bainbridge696bc632020-04-05 21:49:37 -07002368 _PORT=1812
David Bainbridged18f4942020-04-14 16:46:13 -07002369 if [ "$WITH_RADIUS" != "yes" ]; then
2370 _HOST="$(echo "$WITH_RADIUS" | cut -d: -f1)"
2371 _PORT="$(echo "$WITH_RADIUS" | cut -s -d: -f2)"
David Bainbridge696bc632020-04-05 21:49:37 -07002372 _PORT=${_PORT:-1812}
2373 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002374 bspin "Configure ONOS RADIUS Connection $GEAR"
David Bainbridged18f4942020-04-14 16:46:13 -07002375 (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
2376 espin "$VERIFIED"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002377fi
2378
divyadesai59f987a2020-05-27 12:11:33 +00002379if [ "$WITH_EFK" == "yes" ]; then
2380 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"
2381# fi
2382fi
2383
David Bainbridge99ac7a22019-08-31 02:26:43 +00002384if [ "$WITH_CHAOS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002385 STIME="$(date +%s)"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002386 echo -e "Verify kube-monkey $LOCK"
2387 bspin - "Verify kube-monkey Installed"
David Bainbridged18f4942020-04-14 16:46:13 -07002388 if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace kube-monkey "^monkey\$" | wc -l)" -ne 1 ]; then
2389 espin - "$NOT_VERIFIED"
David Bainbridgec7220622020-05-28 12:31:47 -07002390 helm_install - kube-monkey monkey ./kube-monkey/helm/kubemonkey latest - "$_HELM_DESC Chaos Monkey"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002391 else
David Bainbridged18f4942020-04-14 16:46:13 -07002392 espin - "$VERIFIED"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002393 fi
David Bainbridged18f4942020-04-14 16:46:13 -07002394 wait_for_pods - "kube-monkey" 1 "includes" "Waiting for Chaos to start" "$NO_LABEL" "monkey-.*"
David Bainbridge99ac7a22019-08-31 02:26:43 +00002395 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002396 NOW="$(date +%s)"
2397 printtime $((NOW - STIME))
David Bainbridge99ac7a22019-08-31 02:26:43 +00002398 fi
2399fi
2400
David Bainbridge5b7b96b2019-07-25 20:29:13 +00002401bspin "Create voltctl configuration file"
David Bainbridged18f4942020-04-14 16:46:13 -07002402(set -x; mkdir -p "$HOME/.volt" >>"$LOG" 2>&1) >>"$LOG" 2>&1
2403MIN_VC_VERSION="$(echo -e "1.0.15\n$VC_VERSION" | sort -V | head -1)"
2404if [ "$WITH_PORT_FORWARDS" == "yes" ]; then
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002405 KAFKA_FLAG="-k localhost:$VOLTHA_KAFKA_PORT"
2406 SERVER_FLAG="-s localhost:$VOLTHA_API_PORT"
2407 ETCD_FLAG=
2408 if [ "$MIN_VC_VERSION" == "1.0.15" ]; then
2409 ETCD_FLAG="-e localhost:$VOLTHA_ETCD_PORT"
2410 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002411else
David Bainbridgec7220622020-05-28 12:31:47 -07002412 KAFKA_FLAG="-k $(get_service_ep "$INFRA_NS" kafka)"
David Bainbridged18f4942020-04-14 16:46:13 -07002413 SERVER_FLAG="-s $(get_service_ep "$VOLTHA_NS" voltha-api)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002414 ETCD_FLAG=
2415 if [ "$MIN_VC_VERSION" == "1.0.15" ]; then
David Bainbridgec7220622020-05-28 12:31:47 -07002416 ETCD_FLAG="-e $(get_service_ep "$INFRA_NS" etcd)"
David K. Bainbridgeb859e912020-03-13 14:07:52 -07002417 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08002418fi
David Bainbridgea965ca22020-06-09 17:45:04 -07002419CMD=("voltctl $KAFKA_FLAG $SERVER_FLAG $ETCD_FLAG config")
David Bainbridged18f4942020-04-14 16:46:13 -07002420(set -x; ${CMD[*]} > "$HOME/.volt/config-$NAME" 2>>"$LOG") >>"$LOG" 2>&1
David Bainbridgea965ca22020-06-09 17:45:04 -07002421#(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 -07002422espin "$VERIFIED"
Test User08ebbd92019-07-03 17:15:39 +00002423
David Bainbridge0774b232019-08-02 06:37:19 +00002424if [ ! -f "$NAME-env.sh" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002425 touch "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002426fi
2427
David Bainbridge596f30d2019-07-30 17:07:59 +00002428for O in $ALL_OPTIONS; do
David Bainbridged18f4942020-04-14 16:46:13 -07002429 VAL="$(eval echo "\$$O")"
2430 if [ -n "$VAL" ] && [ "$(grep -c "^export $O=" "$NAME-env.sh")" -eq 0 ]; then
2431 echo "export $O=\"$(eval echo "\$$O")\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002432 fi
2433done
2434
David Bainbridged18f4942020-04-14 16:46:13 -07002435if [ "$DEPLOY_K8S" == "yes" ] && [ "$(grep -c "^export KUBECONFIG=" "$NAME-env.sh")" -eq 0 ]; then
2436 echo "export KUBECONFIG=\"$(./bin/kind get kubeconfig-path "--name=voltha-$NAME")\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002437fi
2438
David Bainbridged18f4942020-04-14 16:46:13 -07002439if [ "$(grep -c "^export VOLTCONFIG=" "$NAME-env.sh")" -eq 0 ]; then
2440 echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002441fi
2442
David Bainbridged18f4942020-04-14 16:46:13 -07002443if [ "$(grep -c "^export PATH=" "$NAME-env.sh")" -eq 0 ]; then
2444 echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> "$NAME-env.sh"
David Bainbridgeb07fdf72019-07-29 22:51:40 +00002445fi
2446
Test User7d866122019-07-09 17:52:35 +00002447echo ""
David Bainbridged18f4942020-04-14 16:46:13 -07002448echo "Please issue the following commands in your terminal to ensure that you" | tee -a "$LOG"
2449echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a "$LOG"
2450echo "tools required by VOLTHA in your command path. " | tee -a "$LOG"
2451echo "" | tee -a "$LOG"
2452echo -en "$BOLD"
2453if [ "$DEPLOY_K8S" == "yes" ]; then
2454 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a "$LOG"
Test Userba1e7e72019-07-10 22:27:54 +00002455fi
David Bainbridged18f4942020-04-14 16:46:13 -07002456echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" | tee -a "$LOG"
2457echo "export PATH=$GOPATH/bin:\$PATH" | tee -a "$LOG"
2458echo -en "$NORMAL"
2459echo "" | tee -a "$LOG"
2460echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a "$LOG"
Test User08ebbd92019-07-03 17:15:39 +00002461
David Bainbridge712afb82019-08-14 19:55:58 +00002462if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridged18f4942020-04-14 16:46:13 -07002463 NOW="$(date +%s)"
2464 echo -e "$CLOCK ${BOLD}TOTAL: $(duration $((NOW - TOTAL_START_TIME)))${NORMAL}"
David Bainbridge712afb82019-08-14 19:55:58 +00002465fi