blob: b597a89d86af8d8ac46b065ed9a4a6fcd12c1ea9 [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 Bainbridge712afb82019-08-14 19:55:58 +000016TOTAL_START_TIME=$(date +%s)
David K. Bainbridgeb7285432019-07-02 22:05:24 -070017
David Bainbridge38dc1e82019-08-12 15:18:45 +000018FANCY=${FANCY:-1}
19if [ "$TERM X" == " X" ]; then
20 FANCY=0
21fi
22
David K. Bainbridgeb7285432019-07-02 22:05:24 -070023# trap ctrl-c and call ctrl_c()
24trap ctrl_c INT
25
26function ctrl_c() {
David Bainbridge38dc1e82019-08-12 15:18:45 +000027 echo -en $CNORM
David K. Bainbridgeb7285432019-07-02 22:05:24 -070028 echo ""
29 echo "ctrl-c trapped"
David Bainbridgec6a6eb62019-10-18 22:50:07 +000030 echo "Thank you for trying 'voltha up'"
David K. Bainbridgeb7285432019-07-02 22:05:24 -070031 exit
32}
33
David Bainbridgea34993d2020-04-01 09:15:42 -070034HELM_VERSION=${HELM_VERSION:-v2.14.3}
David K. Bainbridgeebf38d92020-02-10 10:46:31 -080035VOLTCTL_VERSION=${VOLTCTL_VERSION:-latest}
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -080036KIND_VERSION=${KIND_VERSION:-v0.5.1}
David K. Bainbridgeb3a99372020-01-08 14:39:06 -080037VK_RELEASE=${VK_RELEASE:-master}
Test User08ebbd92019-07-03 17:15:39 +000038
David Bainbridge38dc1e82019-08-12 15:18:45 +000039BLACK=
40RED=
41GREEN=
42YELLOW=
43BLUE=
44MAGENTA=
45CYAN=
46WHITE=
47BOLD=
48NORMAL=
49ERROR=
50CEOL=
51CNORM=
52CIVIS=
53if [ $FANCY -eq 1 ]; then
54 BLACK=$(tput setaf 0)
55 RED=$(tput setaf 1)
56 GREEN=$(tput setaf 2)
57 YELLOW=$(tput setaf 3)
58 BLUE=$(tput setaf 4)
59 MAGENTA=$(tput setaf 5)
60 CYAN=$(tput setaf 6)
61 WHITE=$(tput setaf 7)
62 BOLD=$(tput bold)
63 NORMAL=$(tput sgr0)
64 ERROR="\xe2\x9c\x97\x20"
65 CEOL=$(tput el)
66 CNORM=$(tput cnorm)
67 CIVIS=$(tput civis)
68fi
Test User7d866122019-07-09 17:52:35 +000069
Test User3d7ad8e2019-07-03 06:15:44 +000070TYPE=${TYPE:-minimal}
David Bainbridge0774b232019-08-02 06:37:19 +000071NAME=${NAME:-$TYPE}
David K. Bainbridge484d80c2020-03-05 21:44:34 -080072
73ENABLE_ONOS_EXTRANEOUS_RULES=${ENABLE_ONOS_EXTRANEOUS_RULES:-no}
David Bainbridgee87067b2019-08-12 22:00:12 +000074WITH_TIMINGS=${WITH_TIMINGS:-no}
Test User7d866122019-07-09 17:52:35 +000075WITH_BBSIM=${WITH_BBSIM:-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 Bainbridge99ac7a22019-08-31 02:26:43 +000081WITH_CHAOS=${WITH_CHAOS:-no}
David Bainbridge46505fb2019-10-01 21:13:20 +000082WITH_ADAPTERS=${WITH_ADAPTERS:-yes}
David K. Bainbridgeda33d652020-03-06 10:31:23 -080083WITH_SIM_ADAPTERS=${WITH_SIM_ADAPTERS:-no}
David Bainbridge46505fb2019-10-01 21:13:20 +000084WITH_OPEN_ADAPTERS=${WITH_OPEN_ADAPTERS:-yes}
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -080085WITH_PORT_FORWARDS=${WITH_PORT_FORWARDS:-yes}
David Bainbridge696bc632020-04-05 21:49:37 -070086WITH_KAFKA=${WITH_KAFKA:-yes}
87WITH_ETCD=${WITH_ETCD:-yes}
David Bainbridge05cd8822019-11-19 17:43:53 +000088ONLY_ONE=${ONLY_ONE:-yes}
David K. Bainbridgeb859e912020-03-13 14:07:52 -070089CONFIG_SADIS=${CONFIG_SADIS:-no} # yes | no | file | bbsim | URL
90SADIS_SUBSCRIBERS=${SADIS_SUBSCRIBERS:-http://bbsim.voltha.svc:50074/v2/subscribers/%s}
91SADIS_BANDWIDTH_PROFILES=${SADIS_BANDWIDTH_PROFILES:-http://bbsim.voltha.svc:50074/v2/bandwidthprofiles/%s}
Hardik Windlassb3147602020-03-09 16:59:15 +053092SADIS_CFG=${SADIS_CFG:-onos-files/onos-sadis-sample.json}
David Bainbridge27790d62019-08-13 22:43:19 +000093INSTALL_ONOS_APPS=${INSTALL_ONOS_APPS:-no}
Test Userba1e7e72019-07-10 22:27:54 +000094JUST_K8S=${JUST_K8S:-no}
95DEPLOY_K8S=${DEPLOY_K8S:-yes}
David K. Bainbridge0e89cb92019-07-17 11:30:10 -070096INSTALL_KUBECTL=${INSTALL_KUBECTL:-yes}
97INSTALL_HELM=${INSTALL_HELM:-yes}
David Bainbridge46505fb2019-10-01 21:13:20 +000098UPDATE_HELM_REPOS=${UPDATE_HELM_REPOS:-yes}
Matteo Scandolofab98622020-01-28 15:17:20 -080099WAIT_ON_DOWN=${WAIT_ON_DOWN:-yes}
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700100WAIT_TIMEOUT=${WAIT_TIMEOUT:-30m}
101VOLTHA_DOWN_ON_TIMEOUT=${VOLTHA_DOWN_ON_TIMEOUT:-no}
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000102VOLTHA_LOG_LEVEL=${VOLTHA_LOG_LEVEL:-WARN}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000103VOLTHA_CHART=${VOLTHA_CHART:-onf/voltha}
104VOLTHA_CHART_VERSION=${VOLTHA_CHART_VERSION:-latest}
105VOLTHA_BBSIM_CHART=${VOLTHA_BBSIM_CHART:-onf/bbsim}
Matteo Scandolodcd29f52019-10-07 15:42:42 -0700106VOLTHA_BBSIM_CHART_VERSION=${VOLTHA_BBSIM_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000107VOLTHA_ADAPTER_SIM_CHART=${VOLTHA_ADAPTER_SIM_CHART:-onf/voltha-adapter-simulated}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000108VOLTHA_ADAPTER_SIM_CHART_VERSION=${VOLTHA_ADAPTER_SIM_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000109VOLTHA_ADAPTER_OPEN_OLT_CHART=${VOLTHA_ADAPTER_OPEN_OLT_CHART:-onf/voltha-adapter-openolt}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000110VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION=${VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000111VOLTHA_ADAPTER_OPEN_ONU_CHART=${VOLTHA_ADAPTER_OPEN_ONU_CHART:-onf/voltha-adapter-openonu}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000112VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION=${VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION:-latest}
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800113ONOS_CHART=${ONOS_CHART:-onf/onos}
Andrea Campanella21323292019-12-18 11:44:19 -0800114ONOS_CHART_VERSION=${ONOS_CHART_VERSION:-latest}
David Bainbridge2eaf2cf2020-03-18 12:54:08 -0700115EXTRA_HELM_INSTALL_ARGS=${EXTRA_HELM_INSTALL_ARGS:-}
116INTERNAL_EXTRA_HELM_INSTALL_ARGS=
uottrembb16d3982020-02-28 08:34:36 +0100117NUM_OF_BBSIM=${NUM_OF_BBSIM:-1}
118MAX_NUM_OF_BBSIM=10
Test Userba1e7e72019-07-10 22:27:54 +0000119
120HAVE_GO=$(which go >/dev/null 2>&1 && echo "yes" || echo "no")
121HOSTOS=$(uname -s | tr "[:upper:]" "[:lower:"])
122HOSTARCH=$(uname -m | tr "[:upper:]" "[:lower:"])
123if [ $HOSTARCH == "x86_64" ]; then
124 HOSTARCH="amd64"
125fi
Test User7d866122019-07-09 17:52:35 +0000126
uottrembb16d3982020-02-28 08:34:36 +0100127# check number (range) of bbsim, max bbsim must not exceed 10 instances!
128# note: instances will be numbered from 0 to 9
129if [ "$1" == "up" ]; then
David K. Bainbridge43422402020-03-06 07:41:22 -0800130 if [ "$NUM_OF_BBSIM" -lt 1 ]; then
131 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid setting of BBSIM instances. NUM_OF_BBSIM is less than 1${NORMAL}"
132 exit 1
133 fi
134 if [ "$NUM_OF_BBSIM" -gt $MAX_NUM_OF_BBSIM ]; then
135 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid setting of BBSIM instances. NUM_OF_BBSIM is greater than $MAX_NUM_OF_BBSIM${NORMAL}"
136 exit 1
137 fi
uottrembb16d3982020-02-28 08:34:36 +0100138fi
Test User7d866122019-07-09 17:52:35 +0000139# Verify TYPE setting
140if [ $(echo ":minimal:full:" | grep -ic ":$TYPE:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700141 >&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 +0000142 exit 1
143fi
144
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700145function parseDuration() {
146 local DUR=$1
147 local RESULT=0
David Bainbridge6cdb6462020-03-25 10:24:38 -0700148 local TERMS=$(echo $DUR | sed -Ee 's/([sSmMhHdD])/\1 /g' -e 's/,$//g')
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700149 for TERM in $TERMS; do
David Bainbridge6cdb6462020-03-25 10:24:38 -0700150 local VALUE=$(echo $TERM | sed -Ee 's/([0-9]+)[sSmMhHdD]/\1/')
151 local UNIT=$(echo $TERM | sed -Ee 's/[0-9]+([sSmMhHdD])/\1/')
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700152 case $UNIT in
153 s|S)
154 RESULT=$(($RESULT + $VALUE)) ;;
155 m|M)
156 RESULT=$(($RESULT + ($VALUE * 60))) ;;
157 h|H)
158 RESULT=$(($RESULT + ($VALUE * 3600))) ;;
159 d|D)
160 RESULT=$(($RESULT + ($VALUE * 86400))) ;;
161 *) ;;
162 esac
163 done
164 echo $RESULT
165}
166
167function doTimeout() {
168 local MSG=$1
169 2>&1 echo -e "\n${RED}${BOLD}${ERROR}TIMEOUT:${NORMAL}${RED} Operation timed out after '$WAIT_TIMEOUT': $MSG"
170 exit 125
171}
172
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800173function get_service_ep() {
174 local NS=$1
175 local NAME=$2
176 kubectl -n $NS get service $NAME -o json | jq -r '.spec.clusterIP + ":" + (.spec.ports[0].port|tostring)'
177}
178
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000179# Used to verify configuration values are set to "yes" or "no" value or convert
180# equivalents to "yes" or "no"
181function verify_yes_no() {
182 local VAR=$1
183 local VAL=$(eval echo \$$VAR)
184 if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$VAL:") -eq 0 ]; then
185 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid '$VAR' value of '$VAL'. Should be 'yes' or 'no'${NORMAL}"
186 echo "INVALID"
187 return 1
188 fi
189 if [ $(echo ":y:yes:true:1:" | grep -ic ":$VAL:") -eq 1 ]; then
190 echo "yes"
191 else
192 echo "no"
193 fi
194 return 0
195}
Test User7d866122019-07-09 17:52:35 +0000196
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000197ALL_YES_NO="\
David K. Bainbridge484d80c2020-03-05 21:44:34 -0800198 ENABLE_ONOS_EXTRANEOUS_RULES \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000199 WITH_TIMINGS \
200 WITH_BBSIM \
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800201 WITH_EAPOL \
202 WITH_DHCP \
203 WITH_IGMP \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000204 WITH_ONOS \
David Bainbridge99ac7a22019-08-31 02:26:43 +0000205 WITH_CHAOS \
David Bainbridge46505fb2019-10-01 21:13:20 +0000206 WITH_ADAPTERS \
207 WITH_SIM_ADAPTERS \
208 WITH_OPEN_ADAPTERS \
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800209 WITH_PORT_FORWARDS \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000210 JUST_K8S \
211 DEPLOY_K8S \
212 INSTALL_ONOS_APPS \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000213 INSTALL_KUBECTL \
214 INSTALL_HELM \
David Bainbridge46505fb2019-10-01 21:13:20 +0000215 UPDATE_HELM_REPOS \
David Bainbridge4f1b5562019-08-19 04:46:52 +0000216 WAIT_ON_DOWN \
David Bainbridge70c0ea82019-11-14 23:25:26 +0000217 ONLY_ONE \
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700218 VOLTHA_DOWN_ON_TIMEOUT \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000219 "
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000220
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000221ALL_OPTIONS="\
222 NAME \
223 TYPE \
224 $ALL_YES_NO \
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700225 WAIT_TIMEOUT \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000226 VOLTHA_LOG_LEVEL \
227 VOLTHA_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000228 VOLTHA_CHART_VERSION \
229 VOLTHA_BBSIM_CHART \
230 VOLTHA_BBSIM_CHART_VERSION \
uottrembd5a20572020-03-06 09:15:01 +0100231 NUM_OF_BBSIM \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000232 VOLTHA_ADAPTER_SIM_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000233 VOLTHA_ADAPTER_SIM_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000234 VOLTHA_ADAPTER_OPEN_OLT_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000235 VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000236 VOLTHA_ADAPTER_OPEN_ONU_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000237 VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION \
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800238 ONOS_CHART \
Andrea Campanella21323292019-12-18 11:44:19 -0800239 ONOS_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000240 ONOS_API_PORT \
241 ONOS_SSH_PORT \
David K. Bainbridgeb859e912020-03-13 14:07:52 -0700242 CONFIG_SADIS \
Hardik Windlassb3147602020-03-09 16:59:15 +0530243 SADIS_CFG \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000244 VOLTHA_API_PORT \
245 VOLTHA_SSH_PORT \
246 VOLTHA_ETCD_PORT \
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800247 VOLTHA_KAFKA_PORT \
David K. Bainbridge8f7f30b2020-01-08 13:06:16 -0800248 VK_RELEASE \
249 KIND_VERSION \
250 VOLTCTL_VERSION \
David Bainbridgea34993d2020-04-01 09:15:42 -0700251 HELM_VERSION \
David Bainbridge696bc632020-04-05 21:49:37 -0700252 WITH_RADIUS \
253 WITH_KAFKA \
254 WITH_ETCD \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000255 "
David Bainbridge01294952019-07-30 19:33:45 +0000256
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000257# Iterate over yes/no configuration options and validate
258for VAR in $ALL_YES_NO; do
259 eval $VAR=$(verify_yes_no $VAR)
260 if [ "$(eval echo \$$VAR)" == "INVALID" ]; then
261 exit 1;
262 fi
263done
David Bainbridgeb270c202019-07-26 01:44:42 +0000264
David Bainbridge15f6f232020-03-30 09:15:43 -0700265# Special case for CONFIG_SADIS
266if [ $(echo ":y:yes:true:1:" | grep -ic ":$CONFIG_SADIS:") -eq 1 ]; then
267 CONFIG_SADIS="yes"
268fi
269if [ $(echo ":n:no:false:0:" | grep -ic ":$CONFIG_SADIS:") -eq 1 ]; then
270 CONFIG_SADIS="no"
271fi
272
David Bainbridge696bc632020-04-05 21:49:37 -0700273# Special case for WITH_KAFKA and WITH_ETCD
274if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_KAFKA:") -eq 1 ]; then
275 WITH_KAFKA="yes"
276fi
277if [ $(echo ":n:no:false:0:" | grep -ic ":$WITH_KAFKA:") -eq 1 ]; then
278 WITH_KAFKA="no"
279fi
280if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_ETCD:") -eq 1 ]; then
281 WITH_ETCD="yes"
282fi
283if [ $(echo ":n:no:false:0:" | grep -ic ":$WITH_ETCD:") -eq 1 ]; then
284 WITH_ETCD="no"
285fi
286
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800287# Check for prerequiste tools
David K. Bainbridge726ff6a2020-03-06 11:09:50 -0800288TOOLS="curl sed jq"
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800289if [ $DEPLOY_K8S == "yes" ]; then
290 TOOLS+=" docker"
291fi
292NOT_FOUND=""
293for T in $TOOLS; do
294 if [ -z "$(which $T)" ]; then
295 NOT_FOUND+=" $T"
296 fi
297done
298
299if [ ! -z "$NOT_FOUND" ]; then
300 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} The following required tools where not found, please install them:$NOT_FOUND"
301 exit 1
302fi
303
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700304TIMEOUT_SECONDS=$(parseDuration $WAIT_TIMEOUT)
305
David Bainbridge0774b232019-08-02 06:37:19 +0000306mkdir -p .voltha
307touch .voltha/ports
308HAVE=$(grep $NAME .voltha/ports)
309if [ "$HAVE X" == " X" ]; then
310 # Find free port prefix
311 START=81
312 while true; do
313 if [ $(grep -c $START .voltha/ports) -eq 0 ]; then
314 break
315 fi
316 START=$(expr $START + 1)
317 done
318 DELTA=$(expr $START - 81)
David Bainbridgea2595422019-10-22 03:54:28 +0000319 ONOS_API_PORT=${ONOS_API_PORT:-${START}81}
320 ONOS_SSH_PORT=${ONOS_SSH_PORT:-${START}01}
321 VOLTHA_API_PORT=${VOLTHA_API_PORT:-5$(expr 55 + $DELTA)55}
322 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$(expr 50 + $DELTA)22}
323 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$(expr 23 + $DELTA)79}
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800324 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(expr 90 + $DELTA)92}
Test User01ed0642019-07-03 20:17:06 +0000325else
David Bainbridge0774b232019-08-02 06:37:19 +0000326 VALUES=$(echo $HAVE | sed -e 's/\s//g' | cut -d= -f2)
David Bainbridgea2595422019-10-22 03:54:28 +0000327 ONOS_API_PORT=${ONOS_API_PORT:-$(echo $VALUES | cut -d, -f1)}
328 ONOS_SSH_PORT=${ONOS_SSH_PORT:-$(echo $VALUES | cut -d, -f2)}
329 VOLTHA_API_PORT=${VOLTHA_API_PORT:-$(echo $VALUES | cut -d, -f3)}
330 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$(echo $VALUES | cut -d, -f4)}
331 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$(echo $VALUES | cut -d, -f5)}
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800332 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(echo $VALUES | cut -d, -f6)}
333
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800334 # A bit of a hueristic required here as the KAFKA port forward was
335 # added after the .voltha/ports files was created. Basically, if
336 # the VOLTHA_KAFKA_PORT isn't in the file then calculate the original
337 # DELTA from the VOLTHA_SSH_PORT and apply it to the VOLTHA_KAFKA_PORT
338 if [ -z "$VOLTHA_KAFKA_PORT" ]; then
339 DELTA=$((VOLTHA_SSH_PORT/100-50))
340 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(expr 90 + $DELTA)92}
341 fi
Test User01ed0642019-07-03 20:17:06 +0000342fi
343
David Bainbridge0774b232019-08-02 06:37:19 +0000344PORTTMP=$(mktemp -u)
345cat .voltha/ports | grep -v $NAME > $PORTTMP
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800346echo "$NAME=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT,$VOLTHA_KAFKA_PORT" >> $PORTTMP
David Bainbridge0774b232019-08-02 06:37:19 +0000347cp $PORTTMP .voltha/ports
348rm -f $PORTTMP
349
David Bainbridge27790d62019-08-13 22:43:19 +0000350export ONOS_API_PORT ONOS_SSH_PORT
David Bainbridge01294952019-07-30 19:33:45 +0000351
Test Userd87942b2019-07-03 07:20:24 +0000352IDX=1
David Bainbridgee87067b2019-08-12 22:00:12 +0000353CLOCK="TIME:"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000354SPIN_PARTS=
355NOT_VERIFIED=
David Bainbridgef858a022019-08-14 21:25:11 +0000356THEX=
357BUILD=
358CROSS=
359ENTER=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000360VERIFIED=
361HELM=
362OLD_KEY=
363BIRD=
364HIGH_VOLTAGE=
365PLUG=
366RESTART=
367FORWARD=
368INSTALL=
369STOP=
370GO=
371DOWNLOAD=
372GEAR=
373NO_ENTRY=
374LOCK=
375
376if [ $FANCY -eq 1 ]; then
377 SPIN_PARTS="\
378 \xe2\xa2\x8e\xe2\xa1\xb0 \
379 \xe2\xa2\x8e\xe2\xa1\xa1 \
380 \xe2\xa2\x8e\xe2\xa1\x91 \
381 \xe2\xa2\x8e\xe2\xa0\xb1 \
382 \xe2\xa0\x8e\xe2\xa1\xb1 \
383 \xe2\xa2\x8a\xe2\xa1\xb1 \
384 \xe2\xa2\x8c\xe2\xa1\xb1 \
385 \xe2\xa2\x86\xe2\xa1\xb1 \
386 "
David Bainbridgee87067b2019-08-12 22:00:12 +0000387 CLOCK="\xe2\x8f\xb1"
David Bainbridgef858a022019-08-14 21:25:11 +0000388 THEX="${RED}${BOLD}\xe2\x9c\x97\x20${NORMAL}"
389 ENTER="${YELLOW}${BOLD}\xe2\x8e\x86${NORMAL}"
390 CROSS="${YELLOW}${BOLD}\xe2\x9c\x9a${NORMAL}"
391 BUILD="${YELLOW}${BOLD}\xf0\x9f\x8f\x97${NORMAL}"
392 NOT_VERIFIED="$BUILD"
393 VERIFIED="${GREEN}${BOLD}\xe2\x9c\x93\x20${NORMAL}"
394 HELM="${BLUE}${BOLD}\xE2\x8E\x88${NORMAL}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000395 OLD_KEY="\xF0\x9F\x97\x9D"
396 BIRD="\xF0\x9F\x90\xA6"
397 HIGH_VOLTAGE="\xE2\x9A\xA1"
398 PLUG="\xF0\x9F\xa7\xa9"
399 RESTART="\xf0\x9f\x94\x84"
400 FORWARD="\xE2\x87\xA8"
401 INSTALL="\xF0\x9F\x8F\x97"
402 STOP="\xf0\x9f\x9b\x91"
403 GO="\xf0\x9f\x9a\x80"
404 DOWNLOAD="\xf0\x9f\x93\xa5"
405 GEAR="\xe2\x9a\x99"
406 NO_ENTRY="\xe2\x9b\x94"
407 LOCK="\xf0\x9f\x94\x92"
408fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700409
David Bainbridge712afb82019-08-14 19:55:58 +0000410duration() {
David Bainbridgee87067b2019-08-12 22:00:12 +0000411 local h=$(expr $1 / 3600)
412 local m=$(expr $1 % 3600 / 60)
413 local s=$(expr $1 % 60)
414 local t=""
415
416 if [ $h -gt 0 ]; then
417 t="$t${h}h"
418 fi
419 if [ $m -gt 0 ]; then
420 t="$t${m}m"
421 fi
David Bainbridge712afb82019-08-14 19:55:58 +0000422 echo "$t${s}s"
423}
424
425printtime() {
426 local INDENT=
427 if [ "$1" == "-" ]; then
428 INDENT=" "
429 shift
430 fi
431 echo -e "$INDENT $CLOCK $(duration $1)"
David Bainbridgee87067b2019-08-12 22:00:12 +0000432}
433
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700434bspin() {
Test Userd87942b2019-07-03 07:20:24 +0000435 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700436 local INDENT=
437 if [ "$1" == "-" ]; then
438 INDENT=" "
439 shift
440 fi
David Bainbridge38dc1e82019-08-12 15:18:45 +0000441 if [ $FANCY -eq 0 ]; then
442 LINE=$(echo $* | sed -e 's/[\s+-]//g')
443 if [ "$LINE X" == " X" ]; then
444 return
445 fi
446 echo -e "$CIVIS$INDENT$*"
447 else
448 echo -en "$CIVIS$INDENT $*"
449 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700450}
451
452sspin() {
453 local INDENT=
454 if [ "$1" == "-" ]; then
455 INDENT=" "
456 shift
457 fi
David Bainbridge38dc1e82019-08-12 15:18:45 +0000458 if [ $FANCY -eq 0 ]; then
459 LINE=$(echo $* | sed -e 's/[\s+-]//g')
460 if [ "$LINE X" == " X" ]; then
461 return
462 fi
463 echo -e "$INDENT$*"
464 else
465 C=$(echo $SPIN_PARTS | cut '-d ' -f $IDX)
466 echo -en "\r$INDENT$C $*"
467 IDX=$(expr $IDX + 1)
468 if [ $IDX -gt 8 ]; then
469 IDX=1
470 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700471 fi
472}
473
474espin() {
475 local INDENT=
476 if [ "$1" == "-" ]; then
477 INDENT=" "
478 shift
479 fi
David Bainbridge38dc1e82019-08-12 15:18:45 +0000480 if [ $FANCY -eq 0 ]; then
481 LINE=$(echo $* | sed -e 's/[\s+-]//g')
482 if [ "$LINE X" == " X" ]; then
483 return
484 fi
485 echo -e "$INDENT$*"
486 else
487 echo -e "\r$INDENT$*$CNORM"
488 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700489}
490
David Bainbridgeac7f8072019-08-01 22:15:33 +0000491if [ "$1" == "get" -a "$2" == "voltconfig" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000492 echo "$HOME/.volt/config-$NAME"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000493 exit
494fi
495
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -0700496if [ $# -ne 1 -o $(echo ":up:down:dump:" | grep -c ":$1:") -ne 1 ]; then
David Bainbridgeac7f8072019-08-01 22:15:33 +0000497 >&2 echo "What wouild you like to do today:"
498 >&2 echo " up - bring up voltha"
499 >&2 echo " down - tear down voltha"
500 >&2 echo " dump - create a debug dump of running system"
501 exit 1
502fi
503
David Bainbridge4f1b5562019-08-19 04:46:52 +0000504push_onos_config() {
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800505 local TYPE=$1
506 local MSG=$2
507 local RESOURCE=$3
508 local DATA=$4
David Bainbridge4f1b5562019-08-19 04:46:52 +0000509
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800510 # Thanks to the latest version of ONOS using the return code 207 this gets a
511 # whole lot nastier. Can't thank them enough for doing this. So in order to
512 # capture the command and the output in the log file as well as capture the
513 # status code to verify it is 200 and not 207 mutltiple files and a bit of
514 # hackery must be used. Thanks again ONOS.
515 local CMD_ECHO=$(mktemp -u)
516 local CMD_OUTPUT=$(mktemp -u)
517 local SC_OUTPUT=$(mktemp -u)
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700518 local WAIT_START=$(date +%s)
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800519
David Bainbridge4f1b5562019-08-19 04:46:52 +0000520 bspin - "$MSG $GEAR"
521 while true; do
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700522 if [ $(($(date +%s) - $WAIT_START)) -gt $TIMEOUT_SECONDS ]; then
523 espin - "$THEX"
David Bainbridge1cecba52020-03-30 09:43:10 -0700524 rm -f $CMD_ECHO $CMD_OUTPUT $SC_OUTPUT
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700525 doTimeout "waiting for ONOS config push on $RESOURCE"
526 fi
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800527 if [ $TYPE == "file" ]; then
David K. Bainbridgeb859e912020-03-13 14:07:52 -0700528 (set -x; curl --fail -sSL --user karaf:karaf -w "%{http_code}" -o $CMD_OUTPUT -X POST -H Content-Type:application/json http://$_ONOS_API_EP/onos/v1/$RESOURCE --data @$DATA >$SC_OUTPUT 2>/dev/null) >>$CMD_ECHO 2>&1
529 RESULT=$?
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800530 fi
531 if [ $TYPE == "json" ]; then
David K. Bainbridgeb859e912020-03-13 14:07:52 -0700532 (set -x; curl --fail -sSL --user karaf:karaf -w "%{http_code}" -o $CMD_OUTPUT -X POST -H Content-Type:application/json http://$_ONOS_API_EP/onos/v1/$RESOURCE --data $DATA >$SC_OUTPUT 2>/dev/null) >>$CMD_ECHO 2>&1
533 RESULT=$?
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800534 fi
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800535 # Dump everything to the log
536 cat $CMD_ECHO >> $LOG
David K. Bainbridgeb859e912020-03-13 14:07:52 -0700537 test -r $CMD_OUTPUT && cat $CMD_OUTPUT >> $LOG
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800538 SC=$(cat $SC_OUTPUT)
David K. Bainbridgeb859e912020-03-13 14:07:52 -0700539 echo "RESPONSE CODE: $SC" >> $LOG
540 echo "ERROR CODE: $RESULT" >> $LOG
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800541
542 # clean up temp files
543 rm -f $CMD_ECHO $CMD_OUTPUT $SC_OUTPUT
544 if [ $RESULT -eq 0 -a "$SC" == "200" ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000545 break
546 fi
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800547 sleep 1
David Bainbridge4f1b5562019-08-19 04:46:52 +0000548 sspin -
549 done
550 espin - $VERIFIED
551}
552
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800553check_onos_app_active() {
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700554 local APP_ID=$1
555 local WAIT_START=$(date +%s)
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800556
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700557 bspin - "Checking that $APP_ID is active $CLOCK"
558 while true; do
559 if [ $(($(date +%s) - $WAIT_START)) -gt $TIMEOUT_SECONDS ]; then
560 espin - "$THEX"
561 doTimeout "waiting for ONOS application activation '$APP_ID'"
562 fi
563 (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
564 if [ $? -eq 0 ]; then
565 break
566 fi
567 sleep 1
568 sspin -
569 done
570 sleep 5 # OSGI components take a little longer that the app to activate
571 espin - $VERIFIED
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800572}
573
David Bainbridge4f1b5562019-08-19 04:46:52 +0000574override_onos_app() {
575 local APP=$1
576 local NAME=$(basename $APP | sed -e 's/^[0-9][0-9]*-//g' -e 's/-.*$//g')
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700577 local WAIT_START=$(date +%s)
578
David Bainbridge4f1b5562019-08-19 04:46:52 +0000579 while true; do
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700580 if [ $(($(date +%s) - $WAIT_START)) -gt $TIMEOUT_SECONDS ]; then
581 espin - "$THEX"
582 doTimeout "waiting to overwrite ONOS application '$APP'"
583 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +0000584 sspin -
585 # Attempt to delete old version (if it exists)
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800586 (set -x; curl --fail -sSL --user karaf:karaf -X DELETE http://$_ONOS_API_EP/onos/v1/applications/$NAME >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridge4f1b5562019-08-19 04:46:52 +0000587 sspin -
588 if [ $? -ne 0 ]; then
589 continue
590 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800591 (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
David Bainbridge4f1b5562019-08-19 04:46:52 +0000592 if [ $? -eq 0 ]; then
593 break
594 fi
595 sleep .2
596 done
597}
598
599activate_onos_app() {
600 local MSG="$1"
601 local APP=$2
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700602 local WAIT_START=$(date +%s)
David Bainbridge4f1b5562019-08-19 04:46:52 +0000603
604 bspin - "$MSG $GO"
605 while true; do
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700606 if [ $(($(date +%s) - $WAIT_START)) -gt $TIMEOUT_SECONDS ]; then
607 espin - "$THEX"
608 doTimeout "waiting to activate ONOS application '$APP'"
609 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +0000610 sspin -
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800611 (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
David Bainbridge4f1b5562019-08-19 04:46:52 +0000612 if [ $? -eq 0 ]; then
613 break
614 fi
615 sleep .2
616 done
617 espin - "$VERIFIED"
618}
619
620count_pods() {
621 local NAMESPACE=$1; shift
622 if [ "$NAMESPACE" == "all-namespaces" ]; then
623 NAMESPACE="--all-namespaces"
624 else
625 NAMESPACE="-n $NAMESPACE"
626 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +0000627 local STATES=$1; shift
David Bainbridge4f1b5562019-08-19 04:46:52 +0000628 local PODS=$(kubectl get $NAMESPACE pod -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}")
629 local COUNT=0
630 local PATTERNS="$*"
631 for POD in $PODS; do
632 local NAME=$(echo $POD | cut -d/ -f 1)
633 local STATE=$(echo $POD | cut -d/ -f 2)
634 local CONTAINERS=$(echo $POD | cut -d/ -f 3 | sed -e 's/_/ /g')
635 if [ "$STATES" == "*" -o $(echo "$STATES" | grep -c ":$STATE:") -ne 0 ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000636 local TOTAL=$(echo $CONTAINERS | wc -w)
637 local FOUND=$(echo $CONTAINERS | grep -o true | wc -l)
638 if [ $TOTAL -eq $FOUND ]; then
639 for PATTERN in $PATTERNS; do
David Bainbridge4f1b5562019-08-19 04:46:52 +0000640 if [[ $NAME =~ $PATTERN ]]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000641 COUNT=$(expr $COUNT + 1)
642 break
643 fi
644 done
645 fi
646 fi
647 done
David Bainbridge4f1b5562019-08-19 04:46:52 +0000648 echo $COUNT
649}
650
651wait_for_pods() {
652 local INDENT=
653 if [ "$1" == "-" ]; then
654 INDENT=$1; shift
655 fi
656 local NAMESPACE=$1; shift
657 local EXPECT=$1; shift
658 local TYPE=$1; shift
659 local RETRY=$1; shift
660 local MESSAGE=$1; shift
661 local PATTERNS=$*
David Bainbridge99ac7a22019-08-31 02:26:43 +0000662 local STATES=":Running:"
663 if [ "$TYPE" == "not" ]; then
664 STATES="*"
665 fi
666 local HAVE=$(count_pods $NAMESPACE "$STATES" $PATTERNS)
David Bainbridge4f1b5562019-08-19 04:46:52 +0000667 local ALL=$HAVE
668 if [ "$TYPE" == "only" ]; then
669 ALL=$(count_pods "all-namespaces" "*" ".*")
670 fi
671 COUNT=$(expr 300 / 15)
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700672 local WAIT_START=$(date +%s)
David Bainbridge4f1b5562019-08-19 04:46:52 +0000673 bspin $INDENT $MESSAGE
674 sspin $INDENT
675 if [ $HAVE -ne $EXPECT -o $ALL -ne $HAVE ]; then
676 while [ $HAVE -ne $EXPECT -o $ALL -ne $HAVE ]; do
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700677 if [ $(($(date +%s) - $WAIT_START)) -gt $TIMEOUT_SECONDS ]; then
678 espin $INDENT "$THEX"
679 doTimeout "waiting for PODs to start"
680 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +0000681 sspin $INDENT
682 COUNT=$(expr $COUNT - 1)
683 if [ $COUNT -eq 0 ]; then
David Bainbridge99ac7a22019-08-31 02:26:43 +0000684 HAVE=$(count_pods $NAMESPACE "$STATES" $PATTERNS)
David Bainbridge4f1b5562019-08-19 04:46:52 +0000685 ALL=$HAVE
686 if [ "$TYPE" == "only" ]; then
687 ALL=$(count_pods "all-namespaces" "*" ".*")
688 fi
689 COUNT=$(expr 300 / 15)
690 fi
691 sleep .15
692 done
693 fi
694 espin $INDENT $VERIFIED
695 if [ $HAVE -ne $EXPECT ]; then
696 return 1
697 fi
698 return 0
699}
700
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800701port_forward() {
702 local NS=$1
703 local SVC=$2
704 local FROM_PORT=$3
705 local TO_PORT=$4
706 local TAG=$SVC-$NAME
707
708 (set -x; _TAG=$TAG bash -c "while true; do kubectl port-forward -n $NS service/$SVC $FROM_PORT:$TO_PORT; done" >>$LOG 2>&1 &) >>$LOG 2>&1
709}
710
711kill_port_forward() {
712 local TAG=$1-$NAME
David Bainbridgec6871d22019-11-13 17:10:31 +0000713 local P_IDS=$(ps e -ww -A | grep "_TAG=$TAG" | grep -v grep | awk '{print $1}')
David Bainbridgebcf235b2019-11-12 21:33:58 +0000714 local PARENTS=
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800715 local KIDS=
David Bainbridgec6871d22019-11-13 17:10:31 +0000716 local UNKNOWN=
717 if [ ! -z "$P_IDS" ]; then
718 for P_ID in $P_IDS; do
719 local PP_ID=$(ps -o ppid $P_ID | tail -n +2)
720 if [ ! -z "$PP_ID" ]; then
721 if [ $PP_ID -eq 1 ]; then
722 PARENTS="$PARENTS $P_ID"
723 else
724 KIDS="$KIDS $P_ID"
725 fi
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800726 else
David Bainbridgec6871d22019-11-13 17:10:31 +0000727 UNKNOWN="$UNKNOWN $P_ID"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800728 fi
729 done
David Bainbridgec6871d22019-11-13 17:10:31 +0000730 (set -x; kill -9 $PARENTS $KIDS $UNKNOWN >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800731 fi
732}
733
David Bainbridgeac7f8072019-08-01 22:15:33 +0000734if [ "$1" == "down" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000735 echo "Tearing down voltha cluster $NAME"
736 LOG="down-$NAME.log"
737 echo $(date -u +"%Y%m%dT%H%M%SZ") >$LOG
David Bainbridge696bc632020-04-05 21:49:37 -0700738 if [ $WITH_ONOS == "yes" ]; then
739 bspin "Remove port-forwards: onos-ui-$NAME"
740 kill_port_forward onos-ui
741 sspin "Remove port-forwards: onos-ssh-$NAME$CEOL"
742 kill_port_forward onos-ssh
743 fi
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800744 sspin "Remove port-forwards: voltha-api-$NAME$CEOL"
745 kill_port_forward voltha-api
David Bainbridge696bc632020-04-05 21:49:37 -0700746 if [ $WITH_ETCD == "yes" ]; then
747 sspin "Remove port-forwards: voltha-etcd-$NAME$CEOL"
748 kill_port_forward voltha-etcd-cluster-client
749 fi
750 if [ $WITH_KAFKA == "yes" ]; then
751 sspin "Remove port-forwards: voltha-kafka-$NAME$CEOL"
752 kill_port_forward voltha-kafka
753 fi
754
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800755 espin "$VERIFIED Remove port-forwards$CEOL"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000756 if [ $DEPLOY_K8S == "yes" ]; then
757 if [ -x ./bin/kind ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000758 bspin "Delete Kubernetes Kind Cluster"
759 (set -x; ./bin/kind delete cluster --name voltha-$NAME >>$LOG 2>&1) >>$LOG 2>&1
760 espin $VERIFIED
David Bainbridgeac7f8072019-08-01 22:15:33 +0000761 else
David Bainbridge0774b232019-08-02 06:37:19 +0000762 espin "$NO_ENTRY Delete Kubernetes Kind Cluster: kind command not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000763 fi
764 else
765 EXISTS=$(helm list -q)
David Bainbridge696bc632020-04-05 21:49:37 -0700766 EXPECT="voltha etcd-operator"
767 if [ $WITH_ONOS == yes ]; then
768 EXPECT+=" onos"
769 fi
770 if [ $WITH_RADIUS == "yes" ]; then
771 EXPECT+=" radius"
772 fi
773 if [ $WITH_BBSIM == "yes" ]; then
774 EXPECT+=" bbsim"
775 fi
776 if [ $WITH_OPEN_ADAPTERS == "yes" ]; then
777 EXPECT+=" open-olt open-onu"
778 fi
779 if [ $WITH_SIM_ADAPTERS == "yes" ]; then
780 EXPECT+=" sim"
781 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000782 bspin "Remove Helm Deployments"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000783 for i in $EXISTS; do
David K. Bainbridge43422402020-03-06 07:41:22 -0800784 for j in $EXPECT; do
785 if [[ $i =~ $j ]]; then
786 sspin "Remove Helm Deployments: $i$CEOL"
787 (set -x; ./bin/helm delete --no-hooks --purge $i >>$LOG 2>&1) >>$LOG 2>&1
788 fi
789 done
uottrembb16d3982020-02-28 08:34:36 +0100790 done
David Bainbridge0774b232019-08-02 06:37:19 +0000791 espin "$VERIFIED Remove Helm Deployments$CEOL"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000792 if [ "$WAIT_ON_DOWN" == "yes" ]; then
David Bainbridge696bc632020-04-05 21:49:37 -0700793 PODS="voltha-kafka.* voltha-ofagent.* voltha-rw-core.* voltha-etcd.* etcd-operator.*"
794 if [ $WITH_RADIUS == "yes" ]; then
795 PODS+=" radius.*"
796 fi
797 if [ $WITH_BBSIM == "yes" ]; then
798 PODS+=" bbsim.*"
799 fi
800 if [ $WITH_OPEN_ADAPTERS -o $WITH_SIM_ADAPTERS ]; then
801 PODS+=" adapter-*"
802 fi
Matteo Scandolo73442f92020-01-29 09:53:22 -0800803 if [ "$WITH_ONOS" == "yes" ]; then
804 ONOS_PODS="onos-.*"
David Bainbridge696bc632020-04-05 21:49:37 -0700805 wait_for_pods "default" 0 "not" -1 "Waiting for ONOS PODs to terminate" $ONOS_PODS
806 fi
807 wait_for_pods "voltha" 0 "not" -1 "Waiting for VOLTHA PODs to terminate" $PODS
David Bainbridge4f1b5562019-08-19 04:46:52 +0000808 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +0000809 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -0700810 exit
David Bainbridgeac7f8072019-08-01 22:15:33 +0000811fi
812
813if [ "$1" == "dump" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000814 LOG="dump-$NAME.log"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000815 TS=$(date -u +"%Y%m%dT%H%M%SZ")
David Bainbridge76514a02019-10-08 01:50:35 +0000816 if [ ! -z "$DUMP_FROM" ]; then
817 TS=$(echo $DUMP_FROM | sed -e 's/[:-]//g')
818 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +0000819 WORK=$(mktemp -u -d)
David Bainbridge0774b232019-08-02 06:37:19 +0000820 DATA=$WORK/voltha-debug-dump-$NAME-$TS
David Bainbridgeac7f8072019-08-01 22:15:33 +0000821 mkdir -p $DATA
822 echo $TS > $LOG
David Bainbridge0774b232019-08-02 06:37:19 +0000823 echo -e "Capturing debug dump to voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000824 bspin - "Copy install log"
David Bainbridge0774b232019-08-02 06:37:19 +0000825 if [ -f install-$NAME.log ]; then
826 (set -x; cp install-$NAME.log $DATA/install-$NAME.log) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000827 espin - $VERIFIED
828 else
David Bainbridge0774b232019-08-02 06:37:19 +0000829 espin - "$NO_ENTRY Copy install log: install-$NAME.log not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000830 fi
831 bspin - "Dumping Kubernetes PODs"
832 (set -x; kubectl get --all-namespaces pods >> $DATA/all-pods.txt 2>&1) >>$LOG 2>&1
833 espin - $VERIFIED
834 bspin - "Dumping Kubernetes SERVICEs"
835 (set -x; kubectl get --all-namespaces svc >> $DATA/all-services.txt 2>&1) >>$LOG 2>&1
836 espin - $VERIFIED
837 bspin - "Dumping Kubernetes EVENTs"
838 (set -x; kubectl get --all-namespaces events >> $DATA/all-events.txt 2>&1) >>$LOG 2>&1
839 espin - $VERIFIED
840 bspin - "Dumping VOLTHA POD details"
Matteo Scandolodcd29f52019-10-07 15:42:42 -0700841 PODS="$(kubectl -n default get pod -o name | grep onos | sed -e 's/^/default:/g') $(kubectl get -n voltha pod -o name | sed -e 's/^/voltha:/g')"
David Bainbridgecfd7ca12019-10-06 03:31:41 +0000842 SINCE=
843 if [ ! -z "$DUMP_FROM" ]; then
844 SINCE="--since-time=$DUMP_FROM"
845 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +0000846 for POD in $PODS; do
David Bainbridge1f0655a2019-10-01 22:08:48 +0000847 NS=$(echo $POD | cut -d: -f1)
848 POD=$(echo $POD | cut -d: -f2)
David Bainbridgeac7f8072019-08-01 22:15:33 +0000849 sspin - "Dumping VOLTHA POD details: $POD$CEOL"
850 mkdir -p $DATA/$POD
David Bainbridge1f0655a2019-10-01 22:08:48 +0000851 (set -x; kubectl describe -n $NS $POD >> $DATA/$POD/describe.txt 2>&1) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000852 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridgecfd7ca12019-10-06 03:31:41 +0000853 (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 +0000854 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridgecfd7ca12019-10-06 03:31:41 +0000855 (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 +0000856 sspin - "Dumping VOLTHA POD details: $POD"
857 done
858 espin - "$VERIFIED Dumping VOLTHA POD details$CEOL"
859 bspin - "Dumping ETCD"
860 if [ "$(which etcdctl) X" != " X" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000861 (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
David Bainbridgeac7f8072019-08-01 22:15:33 +0000862 espin - $VERIFIED
863 else
864 espin - "$NO_ENTRY Dumping ETCD: etcdctl command not available"
865 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000866 bspin - "Creating compressed TAR: voltha-debug-dump-$NAME-$TS.tgz"
867 (set -x; tar -C $WORK -zcf voltha-debug-dump-$NAME-$TS.tgz ./voltha-debug-dump-$NAME-$TS) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000868 espin - $VERIFIED
869 bspin - "Cleanup"
870 (set -x; rm -rf $WORK) >>$LOG 2>&1
871 espin - $VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +0000872 bspin - "$(ls -l voltha-debug-dump-$NAME-$TS.tgz)"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000873 espin - $VERIFIED
874 exit
875fi
876
David Bainbridge0774b232019-08-02 06:37:19 +0000877LOG="install-$NAME.log"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000878date > $LOG
David Bainbridge0774b232019-08-02 06:37:19 +0000879echo "PORTS=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT" >> $LOG
David Bainbridgeac7f8072019-08-01 22:15:33 +0000880
881# Output install options to log
882echo "OPTIONS" >> $LOG
David Bainbridgeac7f8072019-08-01 22:15:33 +0000883for O in $ALL_OPTIONS; do
884 VAL=$(eval echo \$$O)
David Bainbridgeac7f8072019-08-01 22:15:33 +0000885 if [ ! -z "$VAL" ]; then
886 printf " %-30s = %s\n" $O $VAL >> $LOG
887 fi
888done
889
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -0700890helm_install() {
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700891 local INDENT=
892 if [ "$1" == "-" ]; then
893 INDENT=$1; shift
894 fi
895 local NAMESPACE=$1; shift
David Bainbridge0774b232019-08-02 06:37:19 +0000896 local INAME=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700897 local CHART=$1; shift
David Bainbridge90fd8e32019-08-21 23:32:47 +0000898 local CHART_VERSION=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700899 local MESSAGE=$*
900
David Bainbridge90fd8e32019-08-21 23:32:47 +0000901 if [ "$CHART_VERSION X" != " X" -a "$CHART_VERSION" != "latest" ]; then
902 CHART_VERSION="--version $CHART_VERSION"
903 else
904 CHART_VERSION=
905 fi
906
David Bainbridge99ac7a22019-08-31 02:26:43 +0000907 local CHART_ARGS=
908 if [ -r "${INAME}-values.yaml" ]; then
909 CHART_ARGS="-f ${INAME}-values.yaml"
910 fi
911
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700912 local WAIT_START=$(date +%s)
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700913 COUNT=$(expr 300 / 15)
914 bspin $INDENT $MESSAGE
David Bainbridge2eaf2cf2020-03-18 12:54:08 -0700915 (set -x; helm install -f $NAME-values.yaml $CHART_ARGS $INTERNAL_EXTRA_HELM_INSTALL_ARGS $EXTRA_HELM_INSTALL_ARGS --set defaults.log_level=$VOLTHA_LOG_LEVEL --namespace $NAMESPACE --name $INAME $CHART_VERSION $EXTRA_HELM_FLAGS $CHART >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700916 SUCCESS=$?
917 while [ $SUCCESS -ne 0 ]; do
David Bainbridge52e6e9d2020-03-23 13:48:27 -0700918 if [ $(($(date +%s) - $WAIT_START)) -gt $TIMEOUT_SECONDS ]; then
919 espin "$THEX"
920 doTimeout "waiting for helm install $CHART"
921 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700922 sspin $INDENT
923 COUNT=$(expr $COUNT - 1)
924 if [ $COUNT -eq 0 ]; then
Andy Baviere22ff252019-12-19 11:40:31 -0700925 (set -x; helm delete --purge $INAME >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridge2eaf2cf2020-03-18 12:54:08 -0700926 (set -x; helm install -f $NAME-values.yaml $CHART_ARGS $INTERNAL_EXTRA_HELM_INSTALL_ARGS $EXTRA_HELM_INSTALL_ARGS --set defaults.log_level=$VOLTHA_LOG_LEVEL --namespace $NAMESPACE --name $INAME $CHART_VERSION $EXTRA_HELM_FLAGS $CHART >>$LOG 2>&1) >>$LOG 2>&1
Andy Baviere22ff252019-12-19 11:40:31 -0700927 SUCCESS=$?
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700928 COUNT=$(expr 300 / 15)
929 fi
930 sleep .15
931 done
932 espin $INDENT $VERIFIED
933}
934
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700935echo "INSTALL TYPE: $TYPE" >> $LOG
936
937bspin "Verify GOPATH"
938export GOPATH=$(pwd)
Test User3d7ad8e2019-07-03 06:15:44 +0000939mkdir -p $GOPATH/bin
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700940espin $VERIFIED
941
David Bainbridgee87067b2019-08-12 22:00:12 +0000942STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700943if [ "$INSTALL_KUBECTL" == "no" ]; then
944 bspin "Skip kubectl install"
945 espin $NO_ENTRY
Test Userc13bdc92019-07-03 20:57:49 +0000946else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700947 bspin "Verify kubectl $HELM"
948 if [ -x $GOPATH/bin/kubectl ]; then
949 espin $VERIFIED
950 else
951 espin $NOT_VERIFIED
952 bspin - "Download and install Kubernetes/kubectl $DOWNLOAD"
953 (set -x; curl -o $GOPATH/bin/kubectl -sSL https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/$HOSTOS/$HOSTARCH/kubectl >>$LOG 2>&1) >>$LOG 2>&1
954 (set -x; chmod 755 $GOPATH/bin/kubectl >>$LOG 2>&1) >>$LOG 2>&1
955 espin - $VERIFIED
956 fi
Test Userc13bdc92019-07-03 20:57:49 +0000957fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000958if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000959 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000960fi
Test Userc13bdc92019-07-03 20:57:49 +0000961
David Bainbridgee87067b2019-08-12 22:00:12 +0000962STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700963if [ "$DEPLOY_K8S" == "no" ]; then
964 bspin "Skip Kubernetes/Kind Deployment"
965 espin $NO_ENTRY
966else
Test Userba1e7e72019-07-10 22:27:54 +0000967 bspin "Verify Kubernetes/Kind $HELM"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800968 IS_INSTALLED=0
969 OP_TYPE="install"
Test Userba1e7e72019-07-10 22:27:54 +0000970 if [ -x $GOPATH/bin/kind ]; then
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800971 OP_TYPE="upgrade"
972 if [ $($GOPATH/bin/kind --version | grep -c $KIND_VERSION) -eq 1 ]; then
973 IS_INSTALLED=1
974 espin $VERIFIED
975 fi
976 fi
977 if [ $IS_INSTALLED -eq 0 ]; then
Test Userba1e7e72019-07-10 22:27:54 +0000978 espin $NOT_VERIFIED
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800979 bspin - "Download and $OP_TYPE Kubernetes/kind $DOWNLOAD"
David Bainbridge9e2a6662019-07-11 17:07:57 +0000980 (set -x; curl -o $GOPATH/bin/kind -sSL https://github.com/kubernetes-sigs/kind/releases/download/$KIND_VERSION/kind-$HOSTOS-$HOSTARCH >>$LOG 2>&1) >>$LOG 2>&1
Test Userba1e7e72019-07-10 22:27:54 +0000981 (set -x; chmod 755 $GOPATH/bin/kind >>$LOG 2>&1) >>$LOG 2>&1
982 espin - $VERIFIED
983 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700984fi
985
David Bainbridgee87067b2019-08-12 22:00:12 +0000986if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000987 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000988fi
989
990STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700991if [ "$INSTALL_HELM" == "no" ]; then
992 bspin "Skip Helm Install"
993 espin $NO_ENTRY
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700994else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700995 bspin "Verify Helm $HELM"
David Bainbridgea34993d2020-04-01 09:15:42 -0700996 HELM_UPGRADE=0
997 HELM_UPGRADE_DESC="install"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700998 if [ -x $GOPATH/bin/helm ]; then
David Bainbridgea34993d2020-04-01 09:15:42 -0700999 HAVE_VER=$($GOPATH/bin/helm version -c --template '{{.Client.SemVer}}')
1000 HELM_UP_DOWN=$(echo -e "$HAVE_VER\n$HELM_VERSION" | sort -V | head -1)
1001 if [ $HAVE_VER != $HELM_VERSION ]; then
1002 if [ $HELM_UP_DOWN == $HELM_VERSION ]; then
1003 HELM_UPGRADE_DESC="downgrade"
1004 else
1005 HELM_UPGRADE_DESC="upgrade"
1006 fi
1007 HELM_UPGRADE=1
1008 else
1009 espin $VERIFIED
1010 fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001011 else
David Bainbridgea34993d2020-04-01 09:15:42 -07001012 HELM_UPGRADE=1
1013 fi
1014
1015 if [ $HELM_UPGRADE -ne 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001016 espin $NOT_VERIFIED
David Bainbridgea34993d2020-04-01 09:15:42 -07001017 bspin - "Download and $HELM_UPGRADE_DESC Helm $DOWNLOAD"
1018 (set -x; curl -sSL https://git.io/get_helm.sh | DESIRED_VERSION=$HELM_VERSION USE_SUDO=false HELM_INSTALL_DIR=$GOPATH/bin bash >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001019 espin - $VERIFIED
1020 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001021fi
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -08001022
David Bainbridgee87067b2019-08-12 22:00:12 +00001023if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001024 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001025fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001026
David Bainbridgee87067b2019-08-12 22:00:12 +00001027STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +00001028bspin "Verify voltctl $HIGH_VOLTAGE"
David Bainbridged2811972019-12-14 01:14:09 +00001029VOK=0
1030VMESSAGE="install"
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001031export VC_VERSION="$VOLTCTL_VERSION"
1032if [ "$VC_VERSION" == "latest" ]; then
1033 export VC_VERSION=$(curl -sSL https://api.github.com/repos/opencord/voltctl/releases/latest | jq -r .tag_name | sed -e 's/^v//g')
1034fi
Test User3d7ad8e2019-07-03 06:15:44 +00001035if [ -x $GOPATH/bin/voltctl ]; then
David Bainbridge1ba64f12019-12-18 00:40:13 +00001036 VHAVE=$($GOPATH/bin/voltctl version --clientonly -o json | jq -r .version)
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001037 if [ $? -eq 0 -a "$VHAVE" == "$VC_VERSION" ]; then
David Bainbridged2811972019-12-14 01:14:09 +00001038 VOK=1
David Bainbridge1ba64f12019-12-18 00:40:13 +00001039 espin $VERIFIED
1040 else
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001041 VCHECK=$(echo -e "$VHAVE\n$VC_VERSION" | sort -V | head -1)
1042 if [ "$VCHECK" == "$VHAVE" ]; then
1043 VMESSAGE="upgrade"
1044 else
1045 VMESSAGE="downgrade"
1046 fi
David Bainbridged2811972019-12-14 01:14:09 +00001047 fi
1048fi
1049
David Bainbridge1ba64f12019-12-18 00:40:13 +00001050if [ $VOK -eq 0 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001051 espin $NOT_VERIFIED
David Bainbridged2811972019-12-14 01:14:09 +00001052 bspin - "Download and $VMESSAGE voltctl $DOWNLOAD"
David K. Bainbridgeebf38d92020-02-10 10:46:31 -08001053 (set -x; curl -o $GOPATH/bin/voltctl -sSL https://github.com/opencord/voltctl/releases/download/v$VC_VERSION/voltctl-$VC_VERSION-$HOSTOS-$HOSTARCH >>$LOG 2>&1) >>$LOG 2>&1
Test User08ebbd92019-07-03 17:15:39 +00001054 (set -x; chmod 755 $GOPATH/bin/voltctl >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001055 espin - $VERIFIED
1056fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001057if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001058 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001059fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001060
1061bspin "Verify command PATH"
Test Userba1e7e72019-07-10 22:27:54 +00001062export PATH=$GOPATH/bin:$PATH
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001063espin $VERIFIED
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001064
David Bainbridgee87067b2019-08-12 22:00:12 +00001065STIME=$(date +%s)
Test Userba1e7e72019-07-10 22:27:54 +00001066if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001067 HAVE=$(kind get clusters | grep -c voltha-$NAME)
Test Userba1e7e72019-07-10 22:27:54 +00001068 bspin "Verify Kubernetes/Kind Cluster"
1069 sspin
1070 if [ $HAVE -eq 0 ]; then
David Bainbridge491b1bd2019-07-11 17:53:11 +00001071 espin $NOT_VERIFIED
1072 bspin - "Verify cluster configuration"
David Bainbridge0774b232019-08-02 06:37:19 +00001073 if [ ! -r ./$NAME-cluster.cfg ]; then
David Bainbridge491b1bd2019-07-11 17:53:11 +00001074 espin - $NOT_VERIFIED
David K. Bainbridge43422402020-03-06 07:41:22 -08001075 bspin - "Download cluster configuration: $TYPE-cluster.cfg to $NAME-cluster.cfg $DOWNLOAD"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001076 ERR_OUT=$(mktemp)
1077 (set -x; curl --fail -o ./$NAME-cluster.cfg -sSL https://raw.githubusercontent.com/ciena/kind-voltha/$VK_RELEASE/$TYPE-cluster.cfg >>$LOG 2>>$ERR_OUT) >>$LOG 2>&1
1078 if [ $? -ne 0 ]; then
1079 espin - $THEX
1080 echo -e "${RED}${BOLD}${ERROR}ERROR: $NAME-cluster.cfg${NORMAL}${RED} - $(cat $ERR_OUT)${NORMAL}"
1081 echo "ERROR: $(cat $ERR_OUT)" >>$LOG
1082 rm -rf $ERR_OUT ./$NAME-cluster.cfg
1083 exit 1
1084 fi
1085 rm -rf $ERR_OUT
1086 else
David K. Bainbridge43422402020-03-06 07:41:22 -08001087 espin - $VERIFIED
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001088 fi
David Bainbridge0774b232019-08-02 06:37:19 +00001089 kind create cluster --name voltha-$NAME --config $NAME-cluster.cfg
David Bainbridge491b1bd2019-07-11 17:53:11 +00001090 else
1091 espin $VERIFIED
Test Userba1e7e72019-07-10 22:27:54 +00001092 fi
1093
David Bainbridge0774b232019-08-02 06:37:19 +00001094 export KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$NAME")"
Test Userba1e7e72019-07-10 22:27:54 +00001095 P="coredns-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001096 etcd-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +00001097 kindnet-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001098 kube-apiserver-voltha-$NAME-control-plane \
1099 kube-controller-manager-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +00001100 kube-proxy-.* \
David Bainbridge0774b232019-08-02 06:37:19 +00001101 kube-scheduler-voltha-$NAME-control-plane"
Test Userba1e7e72019-07-10 22:27:54 +00001102
1103 EXPECT=$(test "$TYPE" == "minimal" && echo "12" || echo "14")
David Bainbridge4f1b5562019-08-19 04:46:52 +00001104 wait_for_pods - "kube-system" $EXPECT "includes" -1 "Waiting for system PODs to start" $P
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001105fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001106if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001107 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001108fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001109
David Bainbridgee87067b2019-08-12 22:00:12 +00001110STIME=$(date +%s)
David Bainbridge4c6289c2019-09-03 21:11:32 +00001111COUNT=$(count_pods "kube-system" ":Running:" "tiller-deploy-.*")
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001112bspin "Verify Helm"
Test Userba1e7e72019-07-10 22:27:54 +00001113if [ $COUNT -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001114 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +00001115 echo -e "Configuring Helm $GEAR"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001116 if [ "$INSTALL_HELM" == "no" ]; then
1117 bspin - "Skip Helm/Tiller Initialization"
1118 espin - $NO_ENTRY
1119 else
1120 bspin - "Initialize Helm"
1121 (set -x; helm init --upgrade >>$LOG 2>&1) >>$LOG 2>&1
1122 espin - $VERIFIED
David Bainbridge4f1b5562019-08-19 04:46:52 +00001123 wait_for_pods - "kube-system" 1 "includes" -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001124 fi
Test Userb5712372019-07-03 21:52:17 +00001125 bspin - "Add Google Incubator repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001126 (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
1127 espin - $VERIFIED
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001128
Test Userba1e7e72019-07-10 22:27:54 +00001129 # HACK (sort-of) - the config for tiller is about to be patched, which will
1130 # cause the tiller pod to be recreated. This can sometimes cause a timing
1131 # issue with the "wait_for_pods" call on tiller as it may incorrectly
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001132 # identify the running/ready tiller pod that is soon to be terminated as
Test Userba1e7e72019-07-10 22:27:54 +00001133 # what it is waiting for. To avoid this issue we do a clean scale down and
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001134 # scale up of the pod so the script controlls when it should be expecting
Test Userba1e7e72019-07-10 22:27:54 +00001135 # things
1136 (set -x; kubectl -n kube-system scale deploy tiller-deploy --replicas=0 >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001137
Test Userb5712372019-07-03 21:52:17 +00001138 bspin - "Add Google Stable repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001139 (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
1140 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +00001141 bspin - "Add ONF repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001142 (set -x; helm repo add onf https://charts.opencord.org >>$LOG 2>&1) >>$LOG 2>&1
1143 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +00001144 bspin - "Update Helm repository cache"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001145 (set -x; helm repo update >>$LOG 2>&1) >>$LOG 2>&1
1146 espin - $VERIFIED
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001147
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001148 # Create and k8s service account so that Helm can create pods
Test Userb5712372019-07-03 21:52:17 +00001149 bspin - "Create Tiller ServiceAccount"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001150 (set -x; kubectl create serviceaccount --namespace kube-system tiller >>$LOG 2>&1) >>$LOG 2>&1
1151 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +00001152 bspin - "Create Tiller ClusterRoleBinding"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001153 (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>$LOG 2>&1) >>$LOG 2>&1
1154 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +00001155 bspin - "Update Tiller Manifest"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001156 (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 +00001157
1158 # HACK (sort-of) - part to, spin it back up
1159 (set -x; kubectl -n kube-system scale deploy tiller-deploy --replicas=1 >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001160 espin - $VERIFIED
1161else
David Bainbridgea34993d2020-04-01 09:15:42 -07001162 if [ $(helm version -s --template '{{.Server.SemVer}}') != $HELM_VERSION ]; then
1163 espin $NOT_VERIFIED
1164 bspin - "Sync Tiller server version with helm client"
1165 (set -x; helm init --upgrade --force-upgrade --wait >>$LOG 2>&1) >>$LOG 2>&1
1166 espin - $VERIFIED
1167 else
1168 espin $VERIFIED
1169 fi
1170
David Bainbridge46505fb2019-10-01 21:13:20 +00001171 if [ "$UPDATE_HELM_REPOS" == "yes" ]; then
1172 bspin - "Update Helm repository cache"
1173 (set -x; helm repo update >>$LOG 2>&1) >>$LOG 2>&1
1174 espin - $VERIFIED
1175 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001176fi
David Bainbridge4f1b5562019-08-19 04:46:52 +00001177wait_for_pods - "kube-system" 1 "includes" -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001178if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001179 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001180fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001181
David Bainbridgee87067b2019-08-12 22:00:12 +00001182STIME=$(date +%s)
David Bainbridge0774b232019-08-02 06:37:19 +00001183bspin "Verify Helm values file: $NAME-values.yaml"
1184if [ ! -r "./$NAME-values.yaml" ]; then
Test Userba1e7e72019-07-10 22:27:54 +00001185 espin $NOT_VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +00001186 bspin - "Download Helm values file: $TYPE-values.yaml to $NAME-values.yaml $DOWNLOAD"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001187 ERR_OUT=$(mktemp)
1188 (set -x; curl --fail -o ./$NAME-values.yaml -sSL https://raw.githubusercontent.com/ciena/kind-voltha/$VK_RELEASE/$TYPE-values.yaml >>$LOG 2>$ERR_OUT) >>$LOG 2>&1
1189 if [ $? -ne 0 ]; then
1190 espin - $THEX
1191 echo -e "${RED}${BOLD}${ERROR}ERROR: $NAME-values.yaml${NORMAL}${RED} - $(cat $ERR_OUT)${NORMAL}"
1192 echo "ERROR: $(cat $ERR_OUT)" >>$LOG
1193 rm -rf $ERR_OUT ./$NAME-values.yaml
1194 exit 1
1195 fi
1196 rm -rf $ERR_OUT
Test Userba1e7e72019-07-10 22:27:54 +00001197 espin - $VERIFIED
1198else
1199 espin $VERIFIED
1200fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001201if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001202 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001203fi
Test Userba1e7e72019-07-10 22:27:54 +00001204
David Bainbridge99ac7a22019-08-31 02:26:43 +00001205STIME=$(date +%s)
1206bspin "Verify or download chart specific values files $DOWNLOAD"
1207VALUES_FILES="monkey-values.yaml"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001208ERR_OUT=$(mktemp)
David Bainbridge99ac7a22019-08-31 02:26:43 +00001209for i in $VALUES_FILES; do
1210 if [ ! -r ./$i ]; then
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001211 (set -x; curl --fail -o ./$i -sSL https://raw.githubusercontent.com/ciena/kind-voltha/$VK_RELEASE/$i >>$LOG 2>$ERR_OUT) >>$LOG 2>&1
1212 if [ $? -ne 0 ]; then
1213 espin $THEX
1214 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat $ERR_OUT)${NORMAL}"
1215 echo "ERROR: $i - $(cat $ERR_OUT)" >>$LOG
1216 rm -rf $ERR_OUT ./$i
1217 exit 1
1218 fi
1219 rm -rf $ERR_OUT
David Bainbridge99ac7a22019-08-31 02:26:43 +00001220 fi
1221done
David Bainbridge1cecba52020-03-30 09:43:10 -07001222rm -rf $ERR_OUT
David Bainbridge99ac7a22019-08-31 02:26:43 +00001223espin $VERIFIED
1224if [ "$WITH_TIMINGS" == "yes" ]; then
1225 printtime $(expr $(date +%s) - $STIME)
1226fi
1227
1228if [ "$WITH_CHAOS" == "yes" ]; then
1229 bspin "Verify or clone kube-monkey helm chart $DOWNLOAD"
1230 if [ -r ./kube-monkey ]; then
1231 espin $VERIFIED
1232 else
1233 espin $NOT_VERIFIED
1234 bspin - "GIT clone kube-monkey"
1235 (set -x; git clone https://github.com/asobti/kube-monkey kube-monkey >>$LOG 2>&1) >>$LOG 2>&1
1236 espin - $VERIFIED
1237 fi
1238fi
1239
Test Userba1e7e72019-07-10 22:27:54 +00001240if [ "$JUST_K8S" == "yes" ]; then
1241 echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye."
1242 echo ""
1243 echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
1244 echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
1245 echo "tools required by VOLTHA in your command path. " | tee -a $LOG
1246 echo "" | tee -a $LOG
1247 echo -en $BOLD
1248 if [ $DEPLOY_K8S == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001249 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +00001250 fi
1251 echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
1252 echo -en $NORMAL
1253 echo "" | tee -a $LOG
1254 echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
1255 exit 0
1256fi
1257
David Bainbridge696bc632020-04-05 21:49:37 -07001258if [ $WITH_ETCD != "yes" ]; then
1259 bspin "Skip ETCD Operator Deployment"
1260 espin $NO_ENTRY
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001261else
David Bainbridge696bc632020-04-05 21:49:37 -07001262 STIME=$(date +%s)
1263 bspin "Verify ETCD Operator $OLD_KEY"
1264 if [ $(helm list --deployed --short --namespace voltha "^etcd-operator\$" | wc -l) -ne 1 ]; then
1265 espin $NOT_VERIFIED
1266 helm_install - voltha etcd-operator stable/etcd-operator latest "Install ETCD Operator"
1267 else
1268 espin $VERIFIED
1269 fi
1270 EXPECT=$(test "$TYPE" == "minimal" && echo "1" || echo "3")
1271 wait_for_pods - "voltha" $EXPECT "includes" -1 "Waiting for ETCD Operator to start" "etcd-operator-.*"
1272 if [ "$WITH_TIMINGS" == "yes" ]; then
1273 printtime $(expr $(date +%s) - $STIME)
1274 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001275fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001276
David Bainbridgee87067b2019-08-12 22:00:12 +00001277STIME=$(date +%s)
David Bainbridgeb270c202019-07-26 01:44:42 +00001278if [ $WITH_ONOS == "yes" ]; then
1279 bspin "Verify ONOS installed $BIRD"
1280 if [ $(helm list --deployed --short --namespace default "^onos\$" | wc -l) -ne 1 ]; then
1281 espin $NOT_VERIFIED
David K. Bainbridgeda33d652020-03-06 10:31:23 -08001282 EXTRA_HELM_FLAGS="$SET_TAG $EXTRA_HELM_FLAGS" helm_install - default onos $ONOS_CHART $ONOS_CHART_VERSION "Install ONOS"
David Bainbridgeb270c202019-07-26 01:44:42 +00001283 else
1284 espin $VERIFIED
1285 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +00001286 wait_for_pods - "default" 1 "includes" -1 "Waiting for ONOS to start" "onos-.*"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001287
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001288 if [ $WITH_PORT_FORWARDS == "yes" ]; then
1289 bspin - "Forward ONOS API port $FORWARD"
1290 kill_port_forward onos-ui
1291 port_forward default onos-ui $ONOS_API_PORT 8181
1292 espin - $VERIFIED
1293 bspin - "Forward ONOS SSH port $FORWARD"
1294 kill_port_forward onos-ssh
1295 port_forward default onos-ssh $ONOS_SSH_PORT 8101
1296 espin - $VERIFIED
1297 _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT"
1298 else
1299 _ONOS_API_EP=$(get_service_ep default onos-ui)
1300 fi
David Bainbridged31d6122019-08-13 19:37:59 +00001301 bspin - "Verify or download ONOS configuration support files $DOWNLOAD"
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001302 ONOS_FILES="olt-onos-enableExtraneousRules.json onos-aaa.json \
David Bainbridge696bc632020-04-05 21:49:37 -07001303 onos-dhcpl2relay.json onos-sadis-sample.json"
David Bainbridged31d6122019-08-13 19:37:59 +00001304 (set -x; mkdir -p ./onos-files >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001305 ERR_OUT=$(mktemp)
David Bainbridge2b19e832019-08-16 02:40:53 +00001306 for i in $ONOS_FILES; do
David Bainbridged31d6122019-08-13 19:37:59 +00001307 if [ ! -r ./onos-files/$i ]; then
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001308 (set -x; curl --fail -o ./onos-files/$i -sSL https://raw.githubusercontent.com/ciena/kind-voltha/$VK_RELEASE/onos-files/$i >>$LOG 2>$ERR_OUT) >>$LOG 2>&1
1309 if [ $? -ne 0 ]; then
1310 espin - $THEX
1311 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat $ERR_OUT)${NORMAL}"
1312 echo "ERROR: $(cat $ERR_OUT)" >>$LOG
1313 rm -rf $ERR_OUT ./onos-files/$i
1314 exit 1
1315 fi
1316 rm -rf $ERR_OUT
David Bainbridged31d6122019-08-13 19:37:59 +00001317 fi
1318 done
David Bainbridge1cecba52020-03-30 09:43:10 -07001319 rm -rf $ERR_OUT
Test Userba1e7e72019-07-10 22:27:54 +00001320 espin - $VERIFIED
David Bainbridge27790d62019-08-13 22:43:19 +00001321
1322 if [ $INSTALL_ONOS_APPS == "yes" ]; then
1323 bspin - "Installing custom ONOS applications"
1324 if [ -x onos-files/onos-apps -a $(ls -1 onos-files/onos-apps/*.oar 2>/dev/null | wc -l) -gt 0 ]; then
1325 for OAR in $(ls -1 onos-files/onos-apps/*.oar); do
1326 sspin - "Installing custom ONOS applications - $OAR$CEOL"
David Bainbridge2b19e832019-08-16 02:40:53 +00001327 override_onos_app $OAR
David Bainbridge27790d62019-08-13 22:43:19 +00001328 done
1329 espin - "$VERIFIED Installing custom ONOS applications$CEOL"
1330 else
1331 espin - "$NOT_VERIFIED Installing custom ONOS applications - None Found"
1332 fi
1333 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001334
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001335 check_onos_app_active org.opencord.kafka
David Bainbridge696bc632020-04-05 21:49:37 -07001336 if [ $WITH_KAFKA != "no" ]; then
1337 _HOST=$(echo $WITH_KAFKA | cut -d: -f1)
1338 _PORT=$(echo $WITH_KAFKA | cut -s -d: -f2)
1339 _PORT=${_PORT:-9092}
1340 fi
1341 push_onos_config "json" "Push ONOS Kafka Configuration" "network/configuration/apps/org.opencord.sadis" \
1342 "$(echo $(cat <<EOJ
1343{
1344 "kafka": {
1345 "bootstrapServers": "$_HOST:$_PORT"
1346 }
1347}
1348EOJ
1349) | tr -d '[:space:]')"
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001350 check_onos_app_active org.opencord.dhcpl2relay
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001351 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 -08001352 check_onos_app_active org.opencord.olt
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001353 # FIXME use WITH_DHCP and WITH_EAPOL flags to configre OLT App
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001354 # Default value for "enableEapol" is true in OLT App
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001355 if [ $WITH_EAPOL == "yes" ]; then
1356 push_onos_config "json" "Enable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":true}'
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001357 elif [ $WITH_EAPOL == "no" ]; then
1358 push_onos_config "json" "Disable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001359 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001360 # Default value for "enableDhcpOnProvisioning" is false and for "enableDhcpV4" is true in OLT App
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001361 if [ $WITH_DHCP == "yes" ]; then
1362 push_onos_config "json" "Enable VOLTHA ONOS DHCP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableDhcpOnProvisioning":true,"enableDhcpV4":true}'
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001363 elif [ $WITH_DHCP == "no" ]; then
1364 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 -08001365 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001366 # Default value for "enableIgmpOnProvisioning" is false in OLT App
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001367 if [ $WITH_IGMP == "yes" ]; then
1368 push_onos_config "json" "Enable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":true}'
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001369 elif [ $WITH_IGMP == "no" ]; then
1370 push_onos_config "json" "Disable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001371 fi
David K. Bainbridge484d80c2020-03-05 21:44:34 -08001372 if [ $ENABLE_ONOS_EXTRANEOUS_RULES == "yes" ]; then
1373 push_onos_config "file" "Enabling extraneous rules for ONOS" "configuration/org.onosproject.net.flow.impl.FlowRuleManager" "onos-files/olt-onos-enableExtraneousRules.json"
1374 fi
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001375 if [ $(echo ":yes:file:" | grep -c ":$CONFIG_SADIS:") -eq 1 ]; then
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001376 check_onos_app_active org.opencord.sadis
Hardik Windlassb3147602020-03-09 16:59:15 +05301377 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 -07001378 elif [ "$CONFIG_SADIS" == "bbsim" ]; then
1379 push_onos_config "json" \
1380 "[optional] Push ONOS configuration for BBSIM SADIS servers" \
1381 "network/configuration/apps/org.opencord.sadis" \
1382 "$(echo $(cat <<EOJ
1383{
1384 "sadis": {
1385 "integration": {
1386 "url": "http://bbsim.voltha.svc.cluster.local:50074/v2/subscribers/%s",
1387 "cache": {
1388 "enabled": true,
1389 "maxsize": 50,
1390 "ttl": "PT1m"
1391 }
1392 }
1393 },
1394 "bandwidthprofile": {
1395 "integration": {
1396 "url": "http://bbsim.voltha.svc.cluster.local:50074/v2/bandwidthprofiles/%s",
1397 "cache": {
1398 "enabled": true,
1399 "maxsize": 50,
1400 "ttl": "PT1m"
1401 }
1402 }
1403 }
1404}
1405EOJ
1406) | tr -d '[:space:]')"
1407 elif [ "$CONFIG_SADIS" == "url" ]; then
1408 push_onos_config "json" \
1409 "[optional] Push ONOS configuration for custom SADIS and Bandwidth Profile servers" \
1410 "network/configuration/apps/org.opencord.sadis" \
1411 "$(echo $(cat <<EOJ
1412{
1413 "sadis": {
1414 "integration": {
1415 "url": "$SADIS_SUBSCRIBERS",
1416 "cache": {
1417 "enabled": true,
1418 "maxsize": 50,
1419 "ttl": "PT1m"
1420 }
1421 }
1422 },
1423 "bandwidthprofile": {
1424 "integration": {
1425 "url": "$SADIS_BANDWIDTH_PROFILES",
1426 "cache": {
1427 "enabled": true,
1428 "maxsize": 50,
1429 "ttl": "PT1m"
1430 }
1431 }
1432 }
1433}
1434EOJ
1435) | tr -d '[:space:]')"
David Bainbridge2b19e832019-08-16 02:40:53 +00001436 fi
Test Userba1e7e72019-07-10 22:27:54 +00001437fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001438if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001439 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001440fi
Test Userba1e7e72019-07-10 22:27:54 +00001441
David Bainbridgee87067b2019-08-12 22:00:12 +00001442STIME=$(date +%s)
David Bainbridge696bc632020-04-05 21:49:37 -07001443EXPECT=1
1444if [ "$ONLY_ONE" == "yes" ]; then
1445 EXPECT=$((EXPECT+1))
1446 INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set therecanbeonlyone=true"
1447else
1448 EXPECT=$((EXPECT+2))
1449fi
1450if [ $WITH_ETCD != "yes" ]; then
1451 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set private_etcd_cluster=false"
1452 if [ $WITH_ETCD != "no" ]; then
1453 _HOST=$(echo $WITH_ETCD | cut -d: -f1)
1454 _PORT=$(echo $WITH_ETCD | cut -s -d: -f2)
1455 _PORT=${_PORT:-2379}
1456 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
1457 fi
1458else
1459 if [ $TYPE == "minimal" ]; then
1460 EXPECT=$((EXPECT+1))
1461 else
1462 EXPECT=$((EXPECT+3))
1463 fi
1464fi
1465if [ $WITH_KAFKA != "yes" ]; then
1466 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set private_kafka_cluster=false"
1467 if [ $WITH_KAFKA != "no" ]; then
1468 _HOST=$(echo $WITH_KAFKA | cut -d: -f1)
1469 _PORT=$(echo $WITH_KAFKA | cut -s -d: -f2)
1470 _PORT=${_PORT:-9092}
1471 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"
1472 fi
1473else
1474 if [ $TYPE == "minimal" ]; then
1475 EXPECT=$((EXPECT+2))
1476 else
1477 EXPECT=$((EXPECT+6))
1478 fi
1479fi
Test Userb5712372019-07-03 21:52:17 +00001480bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
Test User7d866122019-07-09 17:52:35 +00001481if [ $(helm list --deployed --short --namespace voltha "^voltha\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001482 espin $NOT_VERIFIED
David Bainbridge90fd8e32019-08-21 23:32:47 +00001483 helm_install - voltha voltha $VOLTHA_CHART $VOLTHA_CHART_VERSION "Install VOLTHA Core"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001484else
1485 espin $VERIFIED
1486fi
David Bainbridge696bc632020-04-05 21:49:37 -07001487INTERNAL_EXTRA_HELM_INSTALL_ARGS=
Test Userba1e7e72019-07-10 22:27:54 +00001488
David Bainbridge90fd8e32019-08-21 23:32:47 +00001489VOLTHA="voltha-ofagent-.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001490 ro-core.* \
1491 rw-core.* \
1492 voltha-api-server-.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001493 voltha-etcd-cluster-.* \
1494 voltha-kafka-.* \
1495 voltha-zookeeper-.*"
David Bainbridge4f1b5562019-08-19 04:46:52 +00001496wait_for_pods - "voltha" $EXPECT "includes" -1 "Waiting for VOLTHA Core to start" $VOLTHA
David Bainbridgee87067b2019-08-12 22:00:12 +00001497if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001498 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001499fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001500
David Bainbridge46505fb2019-10-01 21:13:20 +00001501if [ "$WITH_ADAPTERS" == "yes" ]; then
1502 STIME=$(date +%s)
1503 EXPECT=0
David Bainbridge696bc632020-04-05 21:49:37 -07001504 if [ $WITH_ETCD != "yes" ]; then
1505 if [ $WITH_ETCD != "no" ]; then
1506 _HOST=$(echo $WITH_ETCD | cut -d: -f1)
1507 _PORT=$(echo $WITH_ETCD | cut -s -d: -f2)
1508 _PORT=${_PORT:-2379}
1509 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT"
1510 fi
1511 fi
1512 if [ $WITH_KAFKA != "yes" ]; then
1513 if [ $WITH_KAFKA != "no" ]; then
1514 _HOST=$(echo $WITH_KAFKA | cut -d: -f1)
1515 _PORT=$(echo $WITH_KAFKA | cut -s -d: -f2)
1516 _PORT=${_PORT:-9092}
1517 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"
1518 fi
1519 fi
David Bainbridge46505fb2019-10-01 21:13:20 +00001520 echo -e "Verify Adapters $PLUG"
1521 if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then
1522 bspin - "Verify Simulated Adapters installed"
1523 if [ $(helm list --deployed --short --namespace voltha "^sim\$" | wc -l) -ne 1 ]; then
1524 espin - $NOT_VERIFIED
1525 helm_install - voltha sim $VOLTHA_ADAPTER_SIM_CHART $VOLTHA_ADAPTER_SIM_CHART_VERSION "Install Simulated Adapters"
1526 else
1527 espin - $VERIFIED
1528 fi
1529 EXPECT=$(expr $EXPECT + 2)
1530 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001531
David Bainbridge46505fb2019-10-01 21:13:20 +00001532 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
1533 bspin - "Verify OpenOLT Adapter installed"
1534 if [ $(helm list --deployed --short --namespace voltha "^open-olt\$" | wc -l) -ne 1 ]; then
1535 espin - $NOT_VERIFIED
1536 helm_install - voltha open-olt $VOLTHA_ADAPTER_OPEN_OLT_CHART $VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION "Install OpenOLT Adapter"
1537 else
1538 espin - $VERIFIED
1539 fi
1540 bspin - "Verify OpenONU Adapter installed"
1541 if [ $(helm list --deployed --short --namespace voltha "^open-onu\$" | wc -l) -ne 1 ]; then
1542 espin - $NOT_VERIFIED
1543 helm_install - voltha open-onu $VOLTHA_ADAPTER_OPEN_ONU_CHART $VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION "Install OpenONU Adapter"
1544 else
1545 espin - $VERIFIED
1546 fi
1547 EXPECT=$(expr $EXPECT + 2)
1548 fi
David Bainbridge696bc632020-04-05 21:49:37 -07001549 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001550
David Bainbridge46505fb2019-10-01 21:13:20 +00001551 ADAPTERS="adapter-.*"
1552 wait_for_pods - "voltha" $EXPECT "includes" -1 "Waiting for adapters to start" $ADAPTERS
1553 if [ "$WITH_TIMINGS" == "yes" ]; then
1554 printtime $(expr $(date +%s) - $STIME)
1555 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001556fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001557
Test User7d866122019-07-09 17:52:35 +00001558if [ $WITH_BBSIM == "yes" ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +00001559 STIME=$(date +%s)
Test User7d866122019-07-09 17:52:35 +00001560 echo -e "Verify BBSIM $PLUG"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001561 bspin - "Verify BBSIM Installed"
David K. Bainbridge43422402020-03-06 07:41:22 -08001562 for instance in $(seq 0 $(($NUM_OF_BBSIM-1))); do
1563 if [ $instance -eq 0 ]; then
1564 instance_num=""
1565 else
1566 instance_num=$instance
1567 fi
1568 if [ $(helm list --deployed --short --namespace voltha "^bbsim${instance_num}\$" | wc -l) -ne 1 ]; then
1569 espin - $NOT_VERIFIED
Matteo Scandolo5a149572020-04-01 10:14:57 -07001570 S_TAG=$((900+$instance))
1571 INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set olt_id=$instance,s_tag=$S_TAG"
David K. Bainbridge43422402020-03-06 07:41:22 -08001572 helm_install - voltha bbsim${instance_num} $VOLTHA_BBSIM_CHART $VOLTHA_BBSIM_CHART_VERSION "Install BBSIM${instance_num}"
David Bainbridge2eaf2cf2020-03-18 12:54:08 -07001573 INTERNAL_EXTRA_HELM_INSTALL_ARGS=
David K. Bainbridge43422402020-03-06 07:41:22 -08001574 else
1575 espin - $VERIFIED
1576 fi
1577 done
uottrembb16d3982020-02-28 08:34:36 +01001578 wait_for_pods - "voltha" $NUM_OF_BBSIM "includes" -1 "Waiting for BBSIM to start" "bbsim*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001579 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001580 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001581 fi
Test User7d866122019-07-09 17:52:35 +00001582fi
1583
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001584if [ $WITH_RADIUS == "yes" ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +00001585 STIME=$(date +%s)
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001586 echo -e "Verify RADIUS $LOCK"
1587 bspin - "Verify RADIUS Installed"
1588 if [ $(helm list --deployed --short --namespace voltha "^radius\$" | wc -l) -ne 1 ]; then
1589 espin - $NOT_VERIFIED
David Bainbridge90fd8e32019-08-21 23:32:47 +00001590 helm_install - voltha radius onf/freeradius latest "Install RADIUS"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001591 else
1592 espin - $VERIFIED
1593 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +00001594 wait_for_pods - "voltha" 1 "includes" -1 "Waiting for RADIUS to start" "radius-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001595 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001596 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001597 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001598fi
1599
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001600if [ $WITH_PORT_FORWARDS == "yes" ]; then
1601 STIME=$(date +%s)
1602 bspin - "Forward VOLTHA API port $FORWARD"
1603 kill_port_forward voltha-api
1604 port_forward voltha voltha-api $VOLTHA_API_PORT 55555
1605 espin - $VERIFIED
David Bainbridge696bc632020-04-05 21:49:37 -07001606 if [ $WITH_ETCD == "yes" ]; then
1607 bspin - "Forward VOLTHA ETCD port $FORWARD"
1608 kill_port_forward voltha-etcd-cluster-client
1609 port_forward voltha voltha-etcd-cluster-client $VOLTHA_ETCD_PORT 2379
1610 espin - $VERIFIED
1611 fi
1612 if [ $WITH_KAFKA == "yes" ]; then
1613 bspin - "Forward VOLTHA Kafka port $FORWARD"
1614 kill_port_forward voltha-kafka
1615 port_forward voltha voltha-kafka $VOLTHA_KAFKA_PORT 9092
1616 espin - $VERIFIED
1617 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001618 if [ "$WITH_TIMINGS" == "yes" ]; then
1619 printtime $(expr $(date +%s) - $STIME)
1620 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001621fi
Test User3d7ad8e2019-07-03 06:15:44 +00001622
David Bainbridge696bc632020-04-05 21:49:37 -07001623if [ $WITH_ONOS == "yes" -a $WITH_RADIUS != "no" ]; then
1624 _HOST=radius.voltha.svc.cluster.local
1625 _PORT=1812
1626 if [ $WITH_RADIUS != "yes" ]; then
1627 _HOST=$(echo $WITH_RADIUS | cut -d: -f1)
1628 _PORT=$(echo $WITH_RADIUS | cut -s -d: -f2)
1629 _PORT=${_PORT:-1812}
1630 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001631 bspin "Configure ONOS RADIUS Connection $GEAR"
David Bainbridge696bc632020-04-05 21:49:37 -07001632 (set -x; cat onos-files/onos-aaa.json | sed -e "s/:RADIUS_SVC:/$_HOST/g" -e "s/:RADIUS_PORT:/$_PORT/" | 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
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001633 espin $VERIFIED
1634fi
1635
David Bainbridge99ac7a22019-08-31 02:26:43 +00001636if [ "$WITH_CHAOS" == "yes" ]; then
1637 STIME=$(date +%s)
1638 echo -e "Verify kube-monkey $LOCK"
1639 bspin - "Verify kube-monkey Installed"
1640 if [ $(helm list --deployed --short --namespace kube-monkey "^monkey\$" | wc -l) -ne 1 ]; then
1641 espin - $NOT_VERIFIED
1642 helm_install - kube-monkey monkey ./kube-monkey/helm/kubemonkey latest "Install Chaos Monkey"
1643 else
1644 espin - $VERIFIED
1645 fi
1646 wait_for_pods - "kube-monkey" 1 "includes" -1 "Waiting for Chaos to start" "monkey-.*"
1647 if [ "$WITH_TIMINGS" == "yes" ]; then
1648 printtime $(expr $(date +%s) - $STIME)
1649 fi
1650fi
1651
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001652bspin "Create voltctl configuration file"
Test User3d7ad8e2019-07-03 06:15:44 +00001653(set -x; mkdir -p $HOME/.volt >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001654MIN_VC_VERSION=$(echo -e "1.0.15\n$VC_VERSION" | sort -V | head -1)
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001655if [ $WITH_PORT_FORWARDS == "yes" ]; then
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001656 KAFKA_FLAG="-k localhost:$VOLTHA_KAFKA_PORT"
1657 SERVER_FLAG="-s localhost:$VOLTHA_API_PORT"
1658 ETCD_FLAG=
1659 if [ "$MIN_VC_VERSION" == "1.0.15" ]; then
1660 ETCD_FLAG="-e localhost:$VOLTHA_ETCD_PORT"
1661 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001662else
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001663 KAFKA_FLAG="-k $(get_service_ep voltha voltha-kafka)"
1664 SERVER_FLAG="-s $(get_service_ep voltha voltha-api)"
1665 ETCD_FLAG=
1666 if [ "$MIN_VC_VERSION" == "1.0.15" ]; then
1667 ETCD_FLAG="-e $(get_service_ep voltha voltha-etcd-client)"
1668 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001669fi
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001670(set -x; voltctl -a v3 $KAFKA_FLAG $SERVER_FLAG $ETCD_FLAG config > $HOME/.volt/config-$NAME 2>>$LOG) >>$LOG 2>&1
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001671espin $VERIFIED
Test User08ebbd92019-07-03 17:15:39 +00001672
David Bainbridge0774b232019-08-02 06:37:19 +00001673if [ ! -f "$NAME-env.sh" ]; then
1674 touch $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001675fi
1676
David Bainbridge596f30d2019-07-30 17:07:59 +00001677for O in $ALL_OPTIONS; do
1678 VAL=$(eval echo \$$O)
David Bainbridge0774b232019-08-02 06:37:19 +00001679 if [ ! -z "$VAL" -a $(grep -c "^export $O=" $NAME-env.sh) -eq 0 ]; then
1680 echo "export $O=\"$(eval echo \$$O)\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001681 fi
1682done
1683
David Bainbridge0774b232019-08-02 06:37:19 +00001684if [ $DEPLOY_K8S == "yes" -a $(grep -c "^export KUBECONFIG=" $NAME-env.sh) -eq 0 ]; then
1685 echo "export KUBECONFIG=\"$(./bin/kind get kubeconfig-path --name=voltha-$NAME)\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001686fi
1687
David Bainbridge0774b232019-08-02 06:37:19 +00001688if [ $(grep -c "^export VOLTCONFIG=" $NAME-env.sh) -eq 0 ]; then
1689 echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001690fi
1691
David Bainbridge0774b232019-08-02 06:37:19 +00001692if [ $(grep -c "^export PATH=" $NAME-env.sh) -eq 0 ]; then
1693 echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001694fi
1695
Test User7d866122019-07-09 17:52:35 +00001696echo ""
Test User08ebbd92019-07-03 17:15:39 +00001697echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
1698echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
1699echo "tools required by VOLTHA in your command path. " | tee -a $LOG
1700echo "" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +00001701echo -en $BOLD
Test Userba1e7e72019-07-10 22:27:54 +00001702if [ $DEPLOY_K8S == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001703 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +00001704fi
David Bainbridge0774b232019-08-02 06:37:19 +00001705echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +00001706echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +00001707echo -en $NORMAL
Test User08ebbd92019-07-03 17:15:39 +00001708echo "" | tee -a $LOG
1709echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
1710
David Bainbridge712afb82019-08-14 19:55:58 +00001711if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridgef858a022019-08-14 21:25:11 +00001712 echo -e "$CLOCK ${BOLD}TOTAL: $(duration $(expr $(date +%s) - $TOTAL_START_TIME))${NORMAL}"
David Bainbridge712afb82019-08-14 19:55:58 +00001713fi