blob: f4c1610b8ebb64feb8e05851e9da7f8eff23430f [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 Bainbridge712afb82019-08-14 19:55:58 +000015TOTAL_START_TIME=$(date +%s)
David K. Bainbridgeb7285432019-07-02 22:05:24 -070016
David Bainbridge38dc1e82019-08-12 15:18:45 +000017FANCY=${FANCY:-1}
18if [ "$TERM X" == " X" ]; then
19 FANCY=0
20fi
21
David K. Bainbridgeb7285432019-07-02 22:05:24 -070022# trap ctrl-c and call ctrl_c()
23trap ctrl_c INT
24
25function ctrl_c() {
David Bainbridge38dc1e82019-08-12 15:18:45 +000026 echo -en $CNORM
David K. Bainbridgeb7285432019-07-02 22:05:24 -070027 echo ""
28 echo "ctrl-c trapped"
David Bainbridgec6a6eb62019-10-18 22:50:07 +000029 echo "Thank you for trying 'voltha up'"
David K. Bainbridgeb7285432019-07-02 22:05:24 -070030 exit
31}
32
David K. Bainbridgeebf38d92020-02-10 10:46:31 -080033VOLTCTL_VERSION=${VOLTCTL_VERSION:-latest}
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -080034KIND_VERSION=${KIND_VERSION:-v0.5.1}
David K. Bainbridgeb3a99372020-01-08 14:39:06 -080035VK_RELEASE=${VK_RELEASE:-master}
Test User08ebbd92019-07-03 17:15:39 +000036
David Bainbridge38dc1e82019-08-12 15:18:45 +000037BLACK=
38RED=
39GREEN=
40YELLOW=
41BLUE=
42MAGENTA=
43CYAN=
44WHITE=
45BOLD=
46NORMAL=
47ERROR=
48CEOL=
49CNORM=
50CIVIS=
51if [ $FANCY -eq 1 ]; then
52 BLACK=$(tput setaf 0)
53 RED=$(tput setaf 1)
54 GREEN=$(tput setaf 2)
55 YELLOW=$(tput setaf 3)
56 BLUE=$(tput setaf 4)
57 MAGENTA=$(tput setaf 5)
58 CYAN=$(tput setaf 6)
59 WHITE=$(tput setaf 7)
60 BOLD=$(tput bold)
61 NORMAL=$(tput sgr0)
62 ERROR="\xe2\x9c\x97\x20"
63 CEOL=$(tput el)
64 CNORM=$(tput cnorm)
65 CIVIS=$(tput civis)
66fi
Test User7d866122019-07-09 17:52:35 +000067
Test User3d7ad8e2019-07-03 06:15:44 +000068TYPE=${TYPE:-minimal}
David Bainbridge0774b232019-08-02 06:37:19 +000069NAME=${NAME:-$TYPE}
David K. Bainbridge484d80c2020-03-05 21:44:34 -080070
71ENABLE_ONOS_EXTRANEOUS_RULES=${ENABLE_ONOS_EXTRANEOUS_RULES:-no}
David Bainbridgee87067b2019-08-12 22:00:12 +000072WITH_TIMINGS=${WITH_TIMINGS:-no}
Test User7d866122019-07-09 17:52:35 +000073WITH_BBSIM=${WITH_BBSIM:-no}
David Bainbridge5b7b96b2019-07-25 20:29:13 +000074WITH_RADIUS=${WITH_RADIUS:-no}
Matteo Scandolo78dfee02020-02-13 16:18:03 -080075WITH_EAPOL=${WITH_EAPOL:-yes}
76WITH_DHCP=${WITH_DHCP:-yes}
77WITH_IGMP=${WITH_IGMP:-no}
David Bainbridgeb270c202019-07-26 01:44:42 +000078WITH_ONOS=${WITH_ONOS:-yes}
David Bainbridge99ac7a22019-08-31 02:26:43 +000079WITH_CHAOS=${WITH_CHAOS:-no}
David Bainbridge46505fb2019-10-01 21:13:20 +000080WITH_ADAPTERS=${WITH_ADAPTERS:-yes}
David K. Bainbridgeda33d652020-03-06 10:31:23 -080081WITH_SIM_ADAPTERS=${WITH_SIM_ADAPTERS:-no}
David Bainbridge46505fb2019-10-01 21:13:20 +000082WITH_OPEN_ADAPTERS=${WITH_OPEN_ADAPTERS:-yes}
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -080083WITH_PORT_FORWARDS=${WITH_PORT_FORWARDS:-yes}
David Bainbridge05cd8822019-11-19 17:43:53 +000084ONLY_ONE=${ONLY_ONE:-yes}
David K. Bainbridgeb859e912020-03-13 14:07:52 -070085CONFIG_SADIS=${CONFIG_SADIS:-no} # yes | no | file | bbsim | URL
86SADIS_SUBSCRIBERS=${SADIS_SUBSCRIBERS:-http://bbsim.voltha.svc:50074/v2/subscribers/%s}
87SADIS_BANDWIDTH_PROFILES=${SADIS_BANDWIDTH_PROFILES:-http://bbsim.voltha.svc:50074/v2/bandwidthprofiles/%s}
Hardik Windlassb3147602020-03-09 16:59:15 +053088SADIS_CFG=${SADIS_CFG:-onos-files/onos-sadis-sample.json}
David Bainbridge27790d62019-08-13 22:43:19 +000089INSTALL_ONOS_APPS=${INSTALL_ONOS_APPS:-no}
Test Userba1e7e72019-07-10 22:27:54 +000090JUST_K8S=${JUST_K8S:-no}
91DEPLOY_K8S=${DEPLOY_K8S:-yes}
David K. Bainbridge0e89cb92019-07-17 11:30:10 -070092INSTALL_KUBECTL=${INSTALL_KUBECTL:-yes}
93INSTALL_HELM=${INSTALL_HELM:-yes}
David Bainbridge46505fb2019-10-01 21:13:20 +000094UPDATE_HELM_REPOS=${UPDATE_HELM_REPOS:-yes}
Matteo Scandolofab98622020-01-28 15:17:20 -080095WAIT_ON_DOWN=${WAIT_ON_DOWN:-yes}
David Bainbridge5b7b96b2019-07-25 20:29:13 +000096VOLTHA_LOG_LEVEL=${VOLTHA_LOG_LEVEL:-WARN}
David Bainbridge90fd8e32019-08-21 23:32:47 +000097VOLTHA_CHART=${VOLTHA_CHART:-onf/voltha}
98VOLTHA_CHART_VERSION=${VOLTHA_CHART_VERSION:-latest}
99VOLTHA_BBSIM_CHART=${VOLTHA_BBSIM_CHART:-onf/bbsim}
Matteo Scandolodcd29f52019-10-07 15:42:42 -0700100VOLTHA_BBSIM_CHART_VERSION=${VOLTHA_BBSIM_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000101VOLTHA_ADAPTER_SIM_CHART=${VOLTHA_ADAPTER_SIM_CHART:-onf/voltha-adapter-simulated}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000102VOLTHA_ADAPTER_SIM_CHART_VERSION=${VOLTHA_ADAPTER_SIM_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000103VOLTHA_ADAPTER_OPEN_OLT_CHART=${VOLTHA_ADAPTER_OPEN_OLT_CHART:-onf/voltha-adapter-openolt}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000104VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION=${VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000105VOLTHA_ADAPTER_OPEN_ONU_CHART=${VOLTHA_ADAPTER_OPEN_ONU_CHART:-onf/voltha-adapter-openonu}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000106VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION=${VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION:-latest}
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800107ONOS_CHART=${ONOS_CHART:-onf/onos}
Andrea Campanella21323292019-12-18 11:44:19 -0800108ONOS_CHART_VERSION=${ONOS_CHART_VERSION:-latest}
David Bainbridge70c0ea82019-11-14 23:25:26 +0000109EXTRA_HELM_INSTALL_ARGS=
uottrembb16d3982020-02-28 08:34:36 +0100110NUM_OF_BBSIM=${NUM_OF_BBSIM:-1}
111MAX_NUM_OF_BBSIM=10
Test Userba1e7e72019-07-10 22:27:54 +0000112
113HAVE_GO=$(which go >/dev/null 2>&1 && echo "yes" || echo "no")
114HOSTOS=$(uname -s | tr "[:upper:]" "[:lower:"])
115HOSTARCH=$(uname -m | tr "[:upper:]" "[:lower:"])
116if [ $HOSTARCH == "x86_64" ]; then
117 HOSTARCH="amd64"
118fi
Test User7d866122019-07-09 17:52:35 +0000119
uottrembb16d3982020-02-28 08:34:36 +0100120# check number (range) of bbsim, max bbsim must not exceed 10 instances!
121# note: instances will be numbered from 0 to 9
122if [ "$1" == "up" ]; then
David K. Bainbridge43422402020-03-06 07:41:22 -0800123 if [ "$NUM_OF_BBSIM" -lt 1 ]; then
124 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid setting of BBSIM instances. NUM_OF_BBSIM is less than 1${NORMAL}"
125 exit 1
126 fi
127 if [ "$NUM_OF_BBSIM" -gt $MAX_NUM_OF_BBSIM ]; then
128 >&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}"
129 exit 1
130 fi
uottrembb16d3982020-02-28 08:34:36 +0100131fi
Test User7d866122019-07-09 17:52:35 +0000132# Verify TYPE setting
133if [ $(echo ":minimal:full:" | grep -ic ":$TYPE:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700134 >&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 +0000135 exit 1
136fi
137
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800138function get_service_ep() {
139 local NS=$1
140 local NAME=$2
141 kubectl -n $NS get service $NAME -o json | jq -r '.spec.clusterIP + ":" + (.spec.ports[0].port|tostring)'
142}
143
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000144# Used to verify configuration values are set to "yes" or "no" value or convert
145# equivalents to "yes" or "no"
146function verify_yes_no() {
147 local VAR=$1
148 local VAL=$(eval echo \$$VAR)
149 if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$VAL:") -eq 0 ]; then
150 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid '$VAR' value of '$VAL'. Should be 'yes' or 'no'${NORMAL}"
151 echo "INVALID"
152 return 1
153 fi
154 if [ $(echo ":y:yes:true:1:" | grep -ic ":$VAL:") -eq 1 ]; then
155 echo "yes"
156 else
157 echo "no"
158 fi
159 return 0
160}
Test User7d866122019-07-09 17:52:35 +0000161
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000162ALL_YES_NO="\
David K. Bainbridge484d80c2020-03-05 21:44:34 -0800163 ENABLE_ONOS_EXTRANEOUS_RULES \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000164 WITH_TIMINGS \
165 WITH_BBSIM \
166 WITH_RADIUS \
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800167 WITH_EAPOL \
168 WITH_DHCP \
169 WITH_IGMP \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000170 WITH_ONOS \
David Bainbridge99ac7a22019-08-31 02:26:43 +0000171 WITH_CHAOS \
David Bainbridge46505fb2019-10-01 21:13:20 +0000172 WITH_ADAPTERS \
173 WITH_SIM_ADAPTERS \
174 WITH_OPEN_ADAPTERS \
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800175 WITH_PORT_FORWARDS \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000176 JUST_K8S \
177 DEPLOY_K8S \
178 INSTALL_ONOS_APPS \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000179 INSTALL_KUBECTL \
180 INSTALL_HELM \
David Bainbridge46505fb2019-10-01 21:13:20 +0000181 UPDATE_HELM_REPOS \
David Bainbridge4f1b5562019-08-19 04:46:52 +0000182 WAIT_ON_DOWN \
David Bainbridge70c0ea82019-11-14 23:25:26 +0000183 ONLY_ONE \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000184 "
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000185
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000186ALL_OPTIONS="\
187 NAME \
188 TYPE \
189 $ALL_YES_NO \
190 VOLTHA_LOG_LEVEL \
191 VOLTHA_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000192 VOLTHA_CHART_VERSION \
193 VOLTHA_BBSIM_CHART \
194 VOLTHA_BBSIM_CHART_VERSION \
uottrembd5a20572020-03-06 09:15:01 +0100195 NUM_OF_BBSIM \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000196 VOLTHA_ADAPTER_SIM_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000197 VOLTHA_ADAPTER_SIM_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000198 VOLTHA_ADAPTER_OPEN_OLT_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000199 VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000200 VOLTHA_ADAPTER_OPEN_ONU_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000201 VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION \
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800202 ONOS_CHART \
Andrea Campanella21323292019-12-18 11:44:19 -0800203 ONOS_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000204 ONOS_API_PORT \
205 ONOS_SSH_PORT \
David K. Bainbridgeb859e912020-03-13 14:07:52 -0700206 CONFIG_SADIS \
Hardik Windlassb3147602020-03-09 16:59:15 +0530207 SADIS_CFG \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000208 VOLTHA_API_PORT \
209 VOLTHA_SSH_PORT \
210 VOLTHA_ETCD_PORT \
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800211 VOLTHA_KAFKA_PORT \
David K. Bainbridge8f7f30b2020-01-08 13:06:16 -0800212 VK_RELEASE \
213 KIND_VERSION \
214 VOLTCTL_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000215 "
David Bainbridge01294952019-07-30 19:33:45 +0000216
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000217# Iterate over yes/no configuration options and validate
218for VAR in $ALL_YES_NO; do
219 eval $VAR=$(verify_yes_no $VAR)
220 if [ "$(eval echo \$$VAR)" == "INVALID" ]; then
221 exit 1;
222 fi
223done
David Bainbridgeb270c202019-07-26 01:44:42 +0000224
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800225# Check for prerequiste tools
David K. Bainbridge726ff6a2020-03-06 11:09:50 -0800226TOOLS="curl sed jq"
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800227if [ $DEPLOY_K8S == "yes" ]; then
228 TOOLS+=" docker"
229fi
230NOT_FOUND=""
231for T in $TOOLS; do
232 if [ -z "$(which $T)" ]; then
233 NOT_FOUND+=" $T"
234 fi
235done
236
237if [ ! -z "$NOT_FOUND" ]; then
238 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} The following required tools where not found, please install them:$NOT_FOUND"
239 exit 1
240fi
241
David Bainbridge0774b232019-08-02 06:37:19 +0000242mkdir -p .voltha
243touch .voltha/ports
244HAVE=$(grep $NAME .voltha/ports)
245if [ "$HAVE X" == " X" ]; then
246 # Find free port prefix
247 START=81
248 while true; do
249 if [ $(grep -c $START .voltha/ports) -eq 0 ]; then
250 break
251 fi
252 START=$(expr $START + 1)
253 done
254 DELTA=$(expr $START - 81)
David Bainbridgea2595422019-10-22 03:54:28 +0000255 ONOS_API_PORT=${ONOS_API_PORT:-${START}81}
256 ONOS_SSH_PORT=${ONOS_SSH_PORT:-${START}01}
257 VOLTHA_API_PORT=${VOLTHA_API_PORT:-5$(expr 55 + $DELTA)55}
258 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$(expr 50 + $DELTA)22}
259 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$(expr 23 + $DELTA)79}
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800260 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(expr 90 + $DELTA)92}
Test User01ed0642019-07-03 20:17:06 +0000261else
David Bainbridge0774b232019-08-02 06:37:19 +0000262 VALUES=$(echo $HAVE | sed -e 's/\s//g' | cut -d= -f2)
David Bainbridgea2595422019-10-22 03:54:28 +0000263 ONOS_API_PORT=${ONOS_API_PORT:-$(echo $VALUES | cut -d, -f1)}
264 ONOS_SSH_PORT=${ONOS_SSH_PORT:-$(echo $VALUES | cut -d, -f2)}
265 VOLTHA_API_PORT=${VOLTHA_API_PORT:-$(echo $VALUES | cut -d, -f3)}
266 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$(echo $VALUES | cut -d, -f4)}
267 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$(echo $VALUES | cut -d, -f5)}
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800268 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(echo $VALUES | cut -d, -f6)}
269
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800270 # A bit of a hueristic required here as the KAFKA port forward was
271 # added after the .voltha/ports files was created. Basically, if
272 # the VOLTHA_KAFKA_PORT isn't in the file then calculate the original
273 # DELTA from the VOLTHA_SSH_PORT and apply it to the VOLTHA_KAFKA_PORT
274 if [ -z "$VOLTHA_KAFKA_PORT" ]; then
275 DELTA=$((VOLTHA_SSH_PORT/100-50))
276 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(expr 90 + $DELTA)92}
277 fi
Test User01ed0642019-07-03 20:17:06 +0000278fi
279
David Bainbridge0774b232019-08-02 06:37:19 +0000280PORTTMP=$(mktemp -u)
281cat .voltha/ports | grep -v $NAME > $PORTTMP
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800282echo "$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 +0000283cp $PORTTMP .voltha/ports
284rm -f $PORTTMP
285
David Bainbridge27790d62019-08-13 22:43:19 +0000286export ONOS_API_PORT ONOS_SSH_PORT
David Bainbridge01294952019-07-30 19:33:45 +0000287
Test Userd87942b2019-07-03 07:20:24 +0000288IDX=1
David Bainbridgee87067b2019-08-12 22:00:12 +0000289CLOCK="TIME:"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000290SPIN_PARTS=
291NOT_VERIFIED=
David Bainbridgef858a022019-08-14 21:25:11 +0000292THEX=
293BUILD=
294CROSS=
295ENTER=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000296VERIFIED=
297HELM=
298OLD_KEY=
299BIRD=
300HIGH_VOLTAGE=
301PLUG=
302RESTART=
303FORWARD=
304INSTALL=
305STOP=
306GO=
307DOWNLOAD=
308GEAR=
309NO_ENTRY=
310LOCK=
311
312if [ $FANCY -eq 1 ]; then
313 SPIN_PARTS="\
314 \xe2\xa2\x8e\xe2\xa1\xb0 \
315 \xe2\xa2\x8e\xe2\xa1\xa1 \
316 \xe2\xa2\x8e\xe2\xa1\x91 \
317 \xe2\xa2\x8e\xe2\xa0\xb1 \
318 \xe2\xa0\x8e\xe2\xa1\xb1 \
319 \xe2\xa2\x8a\xe2\xa1\xb1 \
320 \xe2\xa2\x8c\xe2\xa1\xb1 \
321 \xe2\xa2\x86\xe2\xa1\xb1 \
322 "
David Bainbridgee87067b2019-08-12 22:00:12 +0000323 CLOCK="\xe2\x8f\xb1"
David Bainbridgef858a022019-08-14 21:25:11 +0000324 THEX="${RED}${BOLD}\xe2\x9c\x97\x20${NORMAL}"
325 ENTER="${YELLOW}${BOLD}\xe2\x8e\x86${NORMAL}"
326 CROSS="${YELLOW}${BOLD}\xe2\x9c\x9a${NORMAL}"
327 BUILD="${YELLOW}${BOLD}\xf0\x9f\x8f\x97${NORMAL}"
328 NOT_VERIFIED="$BUILD"
329 VERIFIED="${GREEN}${BOLD}\xe2\x9c\x93\x20${NORMAL}"
330 HELM="${BLUE}${BOLD}\xE2\x8E\x88${NORMAL}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000331 OLD_KEY="\xF0\x9F\x97\x9D"
332 BIRD="\xF0\x9F\x90\xA6"
333 HIGH_VOLTAGE="\xE2\x9A\xA1"
334 PLUG="\xF0\x9F\xa7\xa9"
335 RESTART="\xf0\x9f\x94\x84"
336 FORWARD="\xE2\x87\xA8"
337 INSTALL="\xF0\x9F\x8F\x97"
338 STOP="\xf0\x9f\x9b\x91"
339 GO="\xf0\x9f\x9a\x80"
340 DOWNLOAD="\xf0\x9f\x93\xa5"
341 GEAR="\xe2\x9a\x99"
342 NO_ENTRY="\xe2\x9b\x94"
343 LOCK="\xf0\x9f\x94\x92"
344fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700345
David Bainbridge712afb82019-08-14 19:55:58 +0000346duration() {
David Bainbridgee87067b2019-08-12 22:00:12 +0000347 local h=$(expr $1 / 3600)
348 local m=$(expr $1 % 3600 / 60)
349 local s=$(expr $1 % 60)
350 local t=""
351
352 if [ $h -gt 0 ]; then
353 t="$t${h}h"
354 fi
355 if [ $m -gt 0 ]; then
356 t="$t${m}m"
357 fi
David Bainbridge712afb82019-08-14 19:55:58 +0000358 echo "$t${s}s"
359}
360
361printtime() {
362 local INDENT=
363 if [ "$1" == "-" ]; then
364 INDENT=" "
365 shift
366 fi
367 echo -e "$INDENT $CLOCK $(duration $1)"
David Bainbridgee87067b2019-08-12 22:00:12 +0000368}
369
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700370bspin() {
Test Userd87942b2019-07-03 07:20:24 +0000371 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700372 local INDENT=
373 if [ "$1" == "-" ]; then
374 INDENT=" "
375 shift
376 fi
David Bainbridge38dc1e82019-08-12 15:18:45 +0000377 if [ $FANCY -eq 0 ]; then
378 LINE=$(echo $* | sed -e 's/[\s+-]//g')
379 if [ "$LINE X" == " X" ]; then
380 return
381 fi
382 echo -e "$CIVIS$INDENT$*"
383 else
384 echo -en "$CIVIS$INDENT $*"
385 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700386}
387
388sspin() {
389 local INDENT=
390 if [ "$1" == "-" ]; then
391 INDENT=" "
392 shift
393 fi
David Bainbridge38dc1e82019-08-12 15:18:45 +0000394 if [ $FANCY -eq 0 ]; then
395 LINE=$(echo $* | sed -e 's/[\s+-]//g')
396 if [ "$LINE X" == " X" ]; then
397 return
398 fi
399 echo -e "$INDENT$*"
400 else
401 C=$(echo $SPIN_PARTS | cut '-d ' -f $IDX)
402 echo -en "\r$INDENT$C $*"
403 IDX=$(expr $IDX + 1)
404 if [ $IDX -gt 8 ]; then
405 IDX=1
406 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700407 fi
408}
409
410espin() {
411 local INDENT=
412 if [ "$1" == "-" ]; then
413 INDENT=" "
414 shift
415 fi
David Bainbridge38dc1e82019-08-12 15:18:45 +0000416 if [ $FANCY -eq 0 ]; then
417 LINE=$(echo $* | sed -e 's/[\s+-]//g')
418 if [ "$LINE X" == " X" ]; then
419 return
420 fi
421 echo -e "$INDENT$*"
422 else
423 echo -e "\r$INDENT$*$CNORM"
424 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700425}
426
David Bainbridgeac7f8072019-08-01 22:15:33 +0000427if [ "$1" == "get" -a "$2" == "voltconfig" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000428 echo "$HOME/.volt/config-$NAME"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000429 exit
430fi
431
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -0700432if [ $# -ne 1 -o $(echo ":up:down:dump:" | grep -c ":$1:") -ne 1 ]; then
David Bainbridgeac7f8072019-08-01 22:15:33 +0000433 >&2 echo "What wouild you like to do today:"
434 >&2 echo " up - bring up voltha"
435 >&2 echo " down - tear down voltha"
436 >&2 echo " dump - create a debug dump of running system"
437 exit 1
438fi
439
David Bainbridge4f1b5562019-08-19 04:46:52 +0000440push_onos_config() {
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800441 local TYPE=$1
442 local MSG=$2
443 local RESOURCE=$3
444 local DATA=$4
David Bainbridge4f1b5562019-08-19 04:46:52 +0000445
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800446 # Thanks to the latest version of ONOS using the return code 207 this gets a
447 # whole lot nastier. Can't thank them enough for doing this. So in order to
448 # capture the command and the output in the log file as well as capture the
449 # status code to verify it is 200 and not 207 mutltiple files and a bit of
450 # hackery must be used. Thanks again ONOS.
451 local CMD_ECHO=$(mktemp -u)
452 local CMD_OUTPUT=$(mktemp -u)
453 local SC_OUTPUT=$(mktemp -u)
454
David Bainbridge4f1b5562019-08-19 04:46:52 +0000455 bspin - "$MSG $GEAR"
456 while true; do
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800457 if [ $TYPE == "file" ]; then
David K. Bainbridgeb859e912020-03-13 14:07:52 -0700458 (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
459 RESULT=$?
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800460 fi
461 if [ $TYPE == "json" ]; then
David K. Bainbridgeb859e912020-03-13 14:07:52 -0700462 (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
463 RESULT=$?
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800464 fi
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800465 # Dump everything to the log
466 cat $CMD_ECHO >> $LOG
David K. Bainbridgeb859e912020-03-13 14:07:52 -0700467 test -r $CMD_OUTPUT && cat $CMD_OUTPUT >> $LOG
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800468 SC=$(cat $SC_OUTPUT)
David K. Bainbridgeb859e912020-03-13 14:07:52 -0700469 echo "RESPONSE CODE: $SC" >> $LOG
470 echo "ERROR CODE: $RESULT" >> $LOG
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800471
472 # clean up temp files
473 rm -f $CMD_ECHO $CMD_OUTPUT $SC_OUTPUT
474 if [ $RESULT -eq 0 -a "$SC" == "200" ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000475 break
476 fi
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800477 sleep 1
David Bainbridge4f1b5562019-08-19 04:46:52 +0000478 sspin -
479 done
480 espin - $VERIFIED
481}
482
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800483check_onos_app_active() {
484 local APP_ID=$1
485
486 bspin - "Checking that $APP_ID is active $CLOCK"
487 while true; do
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800488 (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
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800489 if [ $? -eq 0 ]; then
490 break
491 fi
492 sleep 1
493 sspin -
494 done
495 sleep 5 # OSGI components take a little longer that the app to activate
496 espin - $VERIFIED
497}
498
David Bainbridge4f1b5562019-08-19 04:46:52 +0000499override_onos_app() {
500 local APP=$1
501 local NAME=$(basename $APP | sed -e 's/^[0-9][0-9]*-//g' -e 's/-.*$//g')
502 while true; do
503 sspin -
504 # Attempt to delete old version (if it exists)
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800505 (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 +0000506 sspin -
507 if [ $? -ne 0 ]; then
508 continue
509 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800510 (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 +0000511 if [ $? -eq 0 ]; then
512 break
513 fi
514 sleep .2
515 done
516}
517
518activate_onos_app() {
519 local MSG="$1"
520 local APP=$2
521
522 bspin - "$MSG $GO"
523 while true; do
524 sspin -
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800525 (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 +0000526 if [ $? -eq 0 ]; then
527 break
528 fi
529 sleep .2
530 done
531 espin - "$VERIFIED"
532}
533
534count_pods() {
535 local NAMESPACE=$1; shift
536 if [ "$NAMESPACE" == "all-namespaces" ]; then
537 NAMESPACE="--all-namespaces"
538 else
539 NAMESPACE="-n $NAMESPACE"
540 fi
541 echo "$NAMESPACE" > /tmp/t
542 local STATES=$1; shift
543 echo "$STATES" >> /tmp/t
544 local PODS=$(kubectl get $NAMESPACE pod -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}")
545 local COUNT=0
546 local PATTERNS="$*"
547 for POD in $PODS; do
548 local NAME=$(echo $POD | cut -d/ -f 1)
549 local STATE=$(echo $POD | cut -d/ -f 2)
550 local CONTAINERS=$(echo $POD | cut -d/ -f 3 | sed -e 's/_/ /g')
551 if [ "$STATES" == "*" -o $(echo "$STATES" | grep -c ":$STATE:") -ne 0 ]; then
552 echo "IN WITH $POD" >> /tmp/t
553 local TOTAL=$(echo $CONTAINERS | wc -w)
554 local FOUND=$(echo $CONTAINERS | grep -o true | wc -l)
555 if [ $TOTAL -eq $FOUND ]; then
556 for PATTERN in $PATTERNS; do
557 echo "TEST $PATTERN AGAINST $NAME" >> /tmp/t
558 if [[ $NAME =~ $PATTERN ]]; then
559 echo "COUNT $NAME" >> /tmp/t
560 COUNT=$(expr $COUNT + 1)
561 break
562 fi
563 done
564 fi
565 fi
566 done
567 echo $COUNT >> /tmp/t
568 echo $COUNT
569}
570
571wait_for_pods() {
572 local INDENT=
573 if [ "$1" == "-" ]; then
574 INDENT=$1; shift
575 fi
576 local NAMESPACE=$1; shift
577 local EXPECT=$1; shift
578 local TYPE=$1; shift
579 local RETRY=$1; shift
580 local MESSAGE=$1; shift
581 local PATTERNS=$*
David Bainbridge99ac7a22019-08-31 02:26:43 +0000582 local STATES=":Running:"
583 if [ "$TYPE" == "not" ]; then
584 STATES="*"
585 fi
586 local HAVE=$(count_pods $NAMESPACE "$STATES" $PATTERNS)
David Bainbridge4f1b5562019-08-19 04:46:52 +0000587 local ALL=$HAVE
588 if [ "$TYPE" == "only" ]; then
589 ALL=$(count_pods "all-namespaces" "*" ".*")
590 fi
591 COUNT=$(expr 300 / 15)
592 bspin $INDENT $MESSAGE
593 sspin $INDENT
594 if [ $HAVE -ne $EXPECT -o $ALL -ne $HAVE ]; then
595 while [ $HAVE -ne $EXPECT -o $ALL -ne $HAVE ]; do
596 sspin $INDENT
597 COUNT=$(expr $COUNT - 1)
598 if [ $COUNT -eq 0 ]; then
David Bainbridge99ac7a22019-08-31 02:26:43 +0000599 HAVE=$(count_pods $NAMESPACE "$STATES" $PATTERNS)
David Bainbridge4f1b5562019-08-19 04:46:52 +0000600 ALL=$HAVE
601 if [ "$TYPE" == "only" ]; then
602 ALL=$(count_pods "all-namespaces" "*" ".*")
603 fi
604 COUNT=$(expr 300 / 15)
605 fi
606 sleep .15
607 done
608 fi
609 espin $INDENT $VERIFIED
610 if [ $HAVE -ne $EXPECT ]; then
611 return 1
612 fi
613 return 0
614}
615
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800616port_forward() {
617 local NS=$1
618 local SVC=$2
619 local FROM_PORT=$3
620 local TO_PORT=$4
621 local TAG=$SVC-$NAME
622
623 (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
624}
625
626kill_port_forward() {
627 local TAG=$1-$NAME
David Bainbridgec6871d22019-11-13 17:10:31 +0000628 local P_IDS=$(ps e -ww -A | grep "_TAG=$TAG" | grep -v grep | awk '{print $1}')
David Bainbridgebcf235b2019-11-12 21:33:58 +0000629 local PARENTS=
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800630 local KIDS=
David Bainbridgec6871d22019-11-13 17:10:31 +0000631 local UNKNOWN=
632 if [ ! -z "$P_IDS" ]; then
633 for P_ID in $P_IDS; do
634 local PP_ID=$(ps -o ppid $P_ID | tail -n +2)
635 if [ ! -z "$PP_ID" ]; then
636 if [ $PP_ID -eq 1 ]; then
637 PARENTS="$PARENTS $P_ID"
638 else
639 KIDS="$KIDS $P_ID"
640 fi
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800641 else
David Bainbridgec6871d22019-11-13 17:10:31 +0000642 UNKNOWN="$UNKNOWN $P_ID"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800643 fi
644 done
David Bainbridgec6871d22019-11-13 17:10:31 +0000645 (set -x; kill -9 $PARENTS $KIDS $UNKNOWN >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800646 fi
647}
648
David Bainbridgeac7f8072019-08-01 22:15:33 +0000649if [ "$1" == "down" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000650 echo "Tearing down voltha cluster $NAME"
651 LOG="down-$NAME.log"
652 echo $(date -u +"%Y%m%dT%H%M%SZ") >$LOG
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800653 bspin "Remove port-forwards: onos-ui-$NAME"
654 kill_port_forward onos-ui
655 sspin "Remove port-forwards: onos-ssh-$NAME$CEOL"
656 kill_port_forward onos-ssh
657 sspin "Remove port-forwards: voltha-api-$NAME$CEOL"
658 kill_port_forward voltha-api
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800659 sspin "Remove port-forwards: voltha-etcd-$NAME$CEOL"
660 kill_port_forward voltha-etcd-cluster-client
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800661 sspin "Remove port-forwards: voltha-kafka-$NAME$CEOL"
662 kill_port_forward voltha-kafka
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800663 espin "$VERIFIED Remove port-forwards$CEOL"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000664 if [ $DEPLOY_K8S == "yes" ]; then
665 if [ -x ./bin/kind ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000666 bspin "Delete Kubernetes Kind Cluster"
667 (set -x; ./bin/kind delete cluster --name voltha-$NAME >>$LOG 2>&1) >>$LOG 2>&1
668 espin $VERIFIED
David Bainbridgeac7f8072019-08-01 22:15:33 +0000669 else
David Bainbridge0774b232019-08-02 06:37:19 +0000670 espin "$NO_ENTRY Delete Kubernetes Kind Cluster: kind command not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000671 fi
672 else
673 EXISTS=$(helm list -q)
674 EXPECT="etcd-operator onos open-olt open-onu sim voltha bbsim radius"
David Bainbridge0774b232019-08-02 06:37:19 +0000675 bspin "Remove Helm Deployments"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000676 for i in $EXISTS; do
David K. Bainbridge43422402020-03-06 07:41:22 -0800677 for j in $EXPECT; do
678 if [[ $i =~ $j ]]; then
679 sspin "Remove Helm Deployments: $i$CEOL"
680 (set -x; ./bin/helm delete --no-hooks --purge $i >>$LOG 2>&1) >>$LOG 2>&1
681 fi
682 done
uottrembb16d3982020-02-28 08:34:36 +0100683 done
David Bainbridge0774b232019-08-02 06:37:19 +0000684 espin "$VERIFIED Remove Helm Deployments$CEOL"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000685 if [ "$WAIT_ON_DOWN" == "yes" ]; then
686 # There should only be 13 or 15 PODs in the kube-system name
687 # space and no other PODs
David Bainbridge4f1b5562019-08-19 04:46:52 +0000688 PODS="coredns-.* \
689 etcd-voltha-$NAME-control-plane \
690 kindnet-.* \
691 kube-apiserver-voltha-$NAME-control-plane \
692 kube-controller-manager-voltha-$NAME-control-plane \
693 kube-proxy-.* \
694 kube-scheduler-voltha-$NAME-control-plane \
695 tiller-deploy-.*"
696 EXPECT=$(test "$TYPE" == "minimal" && echo "13" || echo "15")
David Bainbridge99ac7a22019-08-31 02:26:43 +0000697 PODS="adapter-.* \
698 bbsim.* \
699 etcd-operator.* \
700 radius.* \
701 voltha-.*"
Matteo Scandolo73442f92020-01-29 09:53:22 -0800702
David Bainbridge99ac7a22019-08-31 02:26:43 +0000703 EXPECT=0
704
Matteo Scandolo73442f92020-01-29 09:53:22 -0800705 if [ "$WITH_ONOS" == "yes" ]; then
706 ONOS_PODS="onos-.*"
707 wait_for_pods "default" $EXPECT "not" -1 "Waiting for ONOS PODs to terminate" $ONOS_PODS
708 fi
David Bainbridge99ac7a22019-08-31 02:26:43 +0000709 wait_for_pods "voltha" $EXPECT "not" -1 "Waiting for VOLTHA PODs to terminate" $PODS
David Bainbridge4f1b5562019-08-19 04:46:52 +0000710 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +0000711 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -0700712 exit
David Bainbridgeac7f8072019-08-01 22:15:33 +0000713fi
714
715if [ "$1" == "dump" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000716 LOG="dump-$NAME.log"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000717 TS=$(date -u +"%Y%m%dT%H%M%SZ")
David Bainbridge76514a02019-10-08 01:50:35 +0000718 if [ ! -z "$DUMP_FROM" ]; then
719 TS=$(echo $DUMP_FROM | sed -e 's/[:-]//g')
720 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +0000721 WORK=$(mktemp -u -d)
David Bainbridge0774b232019-08-02 06:37:19 +0000722 DATA=$WORK/voltha-debug-dump-$NAME-$TS
David Bainbridgeac7f8072019-08-01 22:15:33 +0000723 mkdir -p $DATA
724 echo $TS > $LOG
David Bainbridge0774b232019-08-02 06:37:19 +0000725 echo -e "Capturing debug dump to voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000726 bspin - "Copy install log"
David Bainbridge0774b232019-08-02 06:37:19 +0000727 if [ -f install-$NAME.log ]; then
728 (set -x; cp install-$NAME.log $DATA/install-$NAME.log) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000729 espin - $VERIFIED
730 else
David Bainbridge0774b232019-08-02 06:37:19 +0000731 espin - "$NO_ENTRY Copy install log: install-$NAME.log not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000732 fi
733 bspin - "Dumping Kubernetes PODs"
734 (set -x; kubectl get --all-namespaces pods >> $DATA/all-pods.txt 2>&1) >>$LOG 2>&1
735 espin - $VERIFIED
736 bspin - "Dumping Kubernetes SERVICEs"
737 (set -x; kubectl get --all-namespaces svc >> $DATA/all-services.txt 2>&1) >>$LOG 2>&1
738 espin - $VERIFIED
739 bspin - "Dumping Kubernetes EVENTs"
740 (set -x; kubectl get --all-namespaces events >> $DATA/all-events.txt 2>&1) >>$LOG 2>&1
741 espin - $VERIFIED
742 bspin - "Dumping VOLTHA POD details"
Matteo Scandolodcd29f52019-10-07 15:42:42 -0700743 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 +0000744 SINCE=
745 if [ ! -z "$DUMP_FROM" ]; then
746 SINCE="--since-time=$DUMP_FROM"
747 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +0000748 for POD in $PODS; do
David Bainbridge1f0655a2019-10-01 22:08:48 +0000749 NS=$(echo $POD | cut -d: -f1)
750 POD=$(echo $POD | cut -d: -f2)
David Bainbridgeac7f8072019-08-01 22:15:33 +0000751 sspin - "Dumping VOLTHA POD details: $POD$CEOL"
752 mkdir -p $DATA/$POD
David Bainbridge1f0655a2019-10-01 22:08:48 +0000753 (set -x; kubectl describe -n $NS $POD >> $DATA/$POD/describe.txt 2>&1) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000754 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridgecfd7ca12019-10-06 03:31:41 +0000755 (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 +0000756 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridgecfd7ca12019-10-06 03:31:41 +0000757 (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 +0000758 sspin - "Dumping VOLTHA POD details: $POD"
759 done
760 espin - "$VERIFIED Dumping VOLTHA POD details$CEOL"
761 bspin - "Dumping ETCD"
762 if [ "$(which etcdctl) X" != " X" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000763 (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 +0000764 espin - $VERIFIED
765 else
766 espin - "$NO_ENTRY Dumping ETCD: etcdctl command not available"
767 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000768 bspin - "Creating compressed TAR: voltha-debug-dump-$NAME-$TS.tgz"
769 (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 +0000770 espin - $VERIFIED
771 bspin - "Cleanup"
772 (set -x; rm -rf $WORK) >>$LOG 2>&1
773 espin - $VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +0000774 bspin - "$(ls -l voltha-debug-dump-$NAME-$TS.tgz)"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000775 espin - $VERIFIED
776 exit
777fi
778
David Bainbridge0774b232019-08-02 06:37:19 +0000779LOG="install-$NAME.log"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000780date > $LOG
David Bainbridge0774b232019-08-02 06:37:19 +0000781echo "PORTS=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT" >> $LOG
David Bainbridgeac7f8072019-08-01 22:15:33 +0000782
783# Output install options to log
784echo "OPTIONS" >> $LOG
David Bainbridgeac7f8072019-08-01 22:15:33 +0000785for O in $ALL_OPTIONS; do
786 VAL=$(eval echo \$$O)
David Bainbridgeac7f8072019-08-01 22:15:33 +0000787 if [ ! -z "$VAL" ]; then
788 printf " %-30s = %s\n" $O $VAL >> $LOG
789 fi
790done
791
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -0700792helm_install() {
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700793 local INDENT=
794 if [ "$1" == "-" ]; then
795 INDENT=$1; shift
796 fi
797 local NAMESPACE=$1; shift
David Bainbridge0774b232019-08-02 06:37:19 +0000798 local INAME=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700799 local CHART=$1; shift
David Bainbridge90fd8e32019-08-21 23:32:47 +0000800 local CHART_VERSION=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700801 local MESSAGE=$*
802
David Bainbridge90fd8e32019-08-21 23:32:47 +0000803 if [ "$CHART_VERSION X" != " X" -a "$CHART_VERSION" != "latest" ]; then
804 CHART_VERSION="--version $CHART_VERSION"
805 else
806 CHART_VERSION=
807 fi
808
David Bainbridge99ac7a22019-08-31 02:26:43 +0000809 local CHART_ARGS=
810 if [ -r "${INAME}-values.yaml" ]; then
811 CHART_ARGS="-f ${INAME}-values.yaml"
812 fi
813
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700814 COUNT=$(expr 300 / 15)
815 bspin $INDENT $MESSAGE
David Bainbridge70c0ea82019-11-14 23:25:26 +0000816 (set -x; helm install -f $NAME-values.yaml $CHART_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 -0700817 SUCCESS=$?
818 while [ $SUCCESS -ne 0 ]; do
819 sspin $INDENT
820 COUNT=$(expr $COUNT - 1)
821 if [ $COUNT -eq 0 ]; then
Andy Baviere22ff252019-12-19 11:40:31 -0700822 (set -x; helm delete --purge $INAME >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridge99ac7a22019-08-31 02:26:43 +0000823 (set -x; helm install -f $NAME-values.yaml $CHART_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 -0700824 SUCCESS=$?
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700825 COUNT=$(expr 300 / 15)
826 fi
827 sleep .15
828 done
829 espin $INDENT $VERIFIED
830}
831
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700832echo "INSTALL TYPE: $TYPE" >> $LOG
833
834bspin "Verify GOPATH"
835export GOPATH=$(pwd)
Test User3d7ad8e2019-07-03 06:15:44 +0000836mkdir -p $GOPATH/bin
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700837espin $VERIFIED
838
David Bainbridgee87067b2019-08-12 22:00:12 +0000839STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700840if [ "$INSTALL_KUBECTL" == "no" ]; then
841 bspin "Skip kubectl install"
842 espin $NO_ENTRY
Test Userc13bdc92019-07-03 20:57:49 +0000843else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700844 bspin "Verify kubectl $HELM"
845 if [ -x $GOPATH/bin/kubectl ]; then
846 espin $VERIFIED
847 else
848 espin $NOT_VERIFIED
849 bspin - "Download and install Kubernetes/kubectl $DOWNLOAD"
850 (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
851 (set -x; chmod 755 $GOPATH/bin/kubectl >>$LOG 2>&1) >>$LOG 2>&1
852 espin - $VERIFIED
853 fi
Test Userc13bdc92019-07-03 20:57:49 +0000854fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000855if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000856 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000857fi
Test Userc13bdc92019-07-03 20:57:49 +0000858
David Bainbridgee87067b2019-08-12 22:00:12 +0000859STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700860if [ "$DEPLOY_K8S" == "no" ]; then
861 bspin "Skip Kubernetes/Kind Deployment"
862 espin $NO_ENTRY
863else
Test Userba1e7e72019-07-10 22:27:54 +0000864 bspin "Verify Kubernetes/Kind $HELM"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800865 IS_INSTALLED=0
866 OP_TYPE="install"
Test Userba1e7e72019-07-10 22:27:54 +0000867 if [ -x $GOPATH/bin/kind ]; then
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800868 OP_TYPE="upgrade"
869 if [ $($GOPATH/bin/kind --version | grep -c $KIND_VERSION) -eq 1 ]; then
870 IS_INSTALLED=1
871 espin $VERIFIED
872 fi
873 fi
874 if [ $IS_INSTALLED -eq 0 ]; then
Test Userba1e7e72019-07-10 22:27:54 +0000875 espin $NOT_VERIFIED
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800876 bspin - "Download and $OP_TYPE Kubernetes/kind $DOWNLOAD"
David Bainbridge9e2a6662019-07-11 17:07:57 +0000877 (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 +0000878 (set -x; chmod 755 $GOPATH/bin/kind >>$LOG 2>&1) >>$LOG 2>&1
879 espin - $VERIFIED
880 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700881fi
882
David Bainbridgee87067b2019-08-12 22:00:12 +0000883if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000884 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000885fi
886
887STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700888if [ "$INSTALL_HELM" == "no" ]; then
889 bspin "Skip Helm Install"
890 espin $NO_ENTRY
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700891else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700892 bspin "Verify Helm $HELM"
893 if [ -x $GOPATH/bin/helm ]; then
894 espin $VERIFIED
895 else
896 espin $NOT_VERIFIED
897 bspin - "Download and install Helm $DOWNLOAD"
David Bainbridgec6a6eb62019-10-18 22:50:07 +0000898 (set -x; curl -sSL https://git.io/get_helm.sh | DESIRED_VERSION=v2.14.3 USE_SUDO=false HELM_INSTALL_DIR=$GOPATH/bin bash >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700899 espin - $VERIFIED
900 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700901fi
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800902
David Bainbridgee87067b2019-08-12 22:00:12 +0000903if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000904 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000905fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700906
David Bainbridgee87067b2019-08-12 22:00:12 +0000907STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +0000908bspin "Verify voltctl $HIGH_VOLTAGE"
David Bainbridged2811972019-12-14 01:14:09 +0000909VOK=0
910VMESSAGE="install"
David K. Bainbridgeebf38d92020-02-10 10:46:31 -0800911export VC_VERSION="$VOLTCTL_VERSION"
912if [ "$VC_VERSION" == "latest" ]; then
913 export VC_VERSION=$(curl -sSL https://api.github.com/repos/opencord/voltctl/releases/latest | jq -r .tag_name | sed -e 's/^v//g')
914fi
Test User3d7ad8e2019-07-03 06:15:44 +0000915if [ -x $GOPATH/bin/voltctl ]; then
David Bainbridge1ba64f12019-12-18 00:40:13 +0000916 VHAVE=$($GOPATH/bin/voltctl version --clientonly -o json | jq -r .version)
David K. Bainbridgeebf38d92020-02-10 10:46:31 -0800917 if [ $? -eq 0 -a "$VHAVE" == "$VC_VERSION" ]; then
David Bainbridged2811972019-12-14 01:14:09 +0000918 VOK=1
David Bainbridge1ba64f12019-12-18 00:40:13 +0000919 espin $VERIFIED
920 else
David K. Bainbridgeebf38d92020-02-10 10:46:31 -0800921 VCHECK=$(echo -e "$VHAVE\n$VC_VERSION" | sort -V | head -1)
922 if [ "$VCHECK" == "$VHAVE" ]; then
923 VMESSAGE="upgrade"
924 else
925 VMESSAGE="downgrade"
926 fi
David Bainbridged2811972019-12-14 01:14:09 +0000927 fi
928fi
929
David Bainbridge1ba64f12019-12-18 00:40:13 +0000930if [ $VOK -eq 0 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700931 espin $NOT_VERIFIED
David Bainbridged2811972019-12-14 01:14:09 +0000932 bspin - "Download and $VMESSAGE voltctl $DOWNLOAD"
David K. Bainbridgeebf38d92020-02-10 10:46:31 -0800933 (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 +0000934 (set -x; chmod 755 $GOPATH/bin/voltctl >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700935 espin - $VERIFIED
936fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000937if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000938 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000939fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700940
941bspin "Verify command PATH"
Test Userba1e7e72019-07-10 22:27:54 +0000942export PATH=$GOPATH/bin:$PATH
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700943espin $VERIFIED
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700944
David Bainbridgee87067b2019-08-12 22:00:12 +0000945STIME=$(date +%s)
Test Userba1e7e72019-07-10 22:27:54 +0000946if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000947 HAVE=$(kind get clusters | grep -c voltha-$NAME)
Test Userba1e7e72019-07-10 22:27:54 +0000948 bspin "Verify Kubernetes/Kind Cluster"
949 sspin
950 if [ $HAVE -eq 0 ]; then
David Bainbridge491b1bd2019-07-11 17:53:11 +0000951 espin $NOT_VERIFIED
952 bspin - "Verify cluster configuration"
David Bainbridge0774b232019-08-02 06:37:19 +0000953 if [ ! -r ./$NAME-cluster.cfg ]; then
David Bainbridge491b1bd2019-07-11 17:53:11 +0000954 espin - $NOT_VERIFIED
David K. Bainbridge43422402020-03-06 07:41:22 -0800955 bspin - "Download cluster configuration: $TYPE-cluster.cfg to $NAME-cluster.cfg $DOWNLOAD"
David K. Bainbridgea00736b2020-01-08 14:33:17 -0800956 ERR_OUT=$(mktemp)
957 (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
958 if [ $? -ne 0 ]; then
959 espin - $THEX
960 echo -e "${RED}${BOLD}${ERROR}ERROR: $NAME-cluster.cfg${NORMAL}${RED} - $(cat $ERR_OUT)${NORMAL}"
961 echo "ERROR: $(cat $ERR_OUT)" >>$LOG
962 rm -rf $ERR_OUT ./$NAME-cluster.cfg
963 exit 1
964 fi
965 rm -rf $ERR_OUT
966 else
David K. Bainbridge43422402020-03-06 07:41:22 -0800967 espin - $VERIFIED
David K. Bainbridgea00736b2020-01-08 14:33:17 -0800968 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000969 kind create cluster --name voltha-$NAME --config $NAME-cluster.cfg
David Bainbridge491b1bd2019-07-11 17:53:11 +0000970 else
971 espin $VERIFIED
Test Userba1e7e72019-07-10 22:27:54 +0000972 fi
973
David Bainbridge0774b232019-08-02 06:37:19 +0000974 export KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$NAME")"
Test Userba1e7e72019-07-10 22:27:54 +0000975 P="coredns-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000976 etcd-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +0000977 kindnet-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000978 kube-apiserver-voltha-$NAME-control-plane \
979 kube-controller-manager-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +0000980 kube-proxy-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000981 kube-scheduler-voltha-$NAME-control-plane"
Test Userba1e7e72019-07-10 22:27:54 +0000982
983 EXPECT=$(test "$TYPE" == "minimal" && echo "12" || echo "14")
David Bainbridge4f1b5562019-08-19 04:46:52 +0000984 wait_for_pods - "kube-system" $EXPECT "includes" -1 "Waiting for system PODs to start" $P
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700985fi
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
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700989
David Bainbridgee87067b2019-08-12 22:00:12 +0000990STIME=$(date +%s)
David Bainbridge4c6289c2019-09-03 21:11:32 +0000991COUNT=$(count_pods "kube-system" ":Running:" "tiller-deploy-.*")
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700992bspin "Verify Helm"
Test Userba1e7e72019-07-10 22:27:54 +0000993if [ $COUNT -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700994 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000995 echo -e "Configuring Helm $GEAR"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700996 if [ "$INSTALL_HELM" == "no" ]; then
997 bspin - "Skip Helm/Tiller Initialization"
998 espin - $NO_ENTRY
999 else
1000 bspin - "Initialize Helm"
1001 (set -x; helm init --upgrade >>$LOG 2>&1) >>$LOG 2>&1
1002 espin - $VERIFIED
David Bainbridge4f1b5562019-08-19 04:46:52 +00001003 wait_for_pods - "kube-system" 1 "includes" -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -07001004 fi
Test Userb5712372019-07-03 21:52:17 +00001005 bspin - "Add Google Incubator repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001006 (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
1007 espin - $VERIFIED
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001008
Test Userba1e7e72019-07-10 22:27:54 +00001009 # HACK (sort-of) - the config for tiller is about to be patched, which will
1010 # cause the tiller pod to be recreated. This can sometimes cause a timing
1011 # issue with the "wait_for_pods" call on tiller as it may incorrectly
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001012 # identify the running/ready tiller pod that is soon to be terminated as
Test Userba1e7e72019-07-10 22:27:54 +00001013 # what it is waiting for. To avoid this issue we do a clean scale down and
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001014 # scale up of the pod so the script controlls when it should be expecting
Test Userba1e7e72019-07-10 22:27:54 +00001015 # things
1016 (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 -07001017
Test Userb5712372019-07-03 21:52:17 +00001018 bspin - "Add Google Stable repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001019 (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
1020 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +00001021 bspin - "Add ONF repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001022 (set -x; helm repo add onf https://charts.opencord.org >>$LOG 2>&1) >>$LOG 2>&1
1023 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +00001024 bspin - "Update Helm repository cache"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001025 (set -x; helm repo update >>$LOG 2>&1) >>$LOG 2>&1
1026 espin - $VERIFIED
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001027
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001028 # Create and k8s service account so that Helm can create pods
Test Userb5712372019-07-03 21:52:17 +00001029 bspin - "Create Tiller ServiceAccount"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001030 (set -x; kubectl create serviceaccount --namespace kube-system tiller >>$LOG 2>&1) >>$LOG 2>&1
1031 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +00001032 bspin - "Create Tiller ClusterRoleBinding"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001033 (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>$LOG 2>&1) >>$LOG 2>&1
1034 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +00001035 bspin - "Update Tiller Manifest"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001036 (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 +00001037
1038 # HACK (sort-of) - part to, spin it back up
1039 (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 -07001040 espin - $VERIFIED
1041else
1042 espin $VERIFIED
David Bainbridge46505fb2019-10-01 21:13:20 +00001043 if [ "$UPDATE_HELM_REPOS" == "yes" ]; then
1044 bspin - "Update Helm repository cache"
1045 (set -x; helm repo update >>$LOG 2>&1) >>$LOG 2>&1
1046 espin - $VERIFIED
1047 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001048fi
David Bainbridge4f1b5562019-08-19 04:46:52 +00001049wait_for_pods - "kube-system" 1 "includes" -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001050if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001051 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001052fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001053
David Bainbridgee87067b2019-08-12 22:00:12 +00001054STIME=$(date +%s)
David Bainbridge0774b232019-08-02 06:37:19 +00001055bspin "Verify Helm values file: $NAME-values.yaml"
1056if [ ! -r "./$NAME-values.yaml" ]; then
Test Userba1e7e72019-07-10 22:27:54 +00001057 espin $NOT_VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +00001058 bspin - "Download Helm values file: $TYPE-values.yaml to $NAME-values.yaml $DOWNLOAD"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001059 ERR_OUT=$(mktemp)
1060 (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
1061 if [ $? -ne 0 ]; then
1062 espin - $THEX
1063 echo -e "${RED}${BOLD}${ERROR}ERROR: $NAME-values.yaml${NORMAL}${RED} - $(cat $ERR_OUT)${NORMAL}"
1064 echo "ERROR: $(cat $ERR_OUT)" >>$LOG
1065 rm -rf $ERR_OUT ./$NAME-values.yaml
1066 exit 1
1067 fi
1068 rm -rf $ERR_OUT
Test Userba1e7e72019-07-10 22:27:54 +00001069 espin - $VERIFIED
1070else
1071 espin $VERIFIED
1072fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001073if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001074 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001075fi
Test Userba1e7e72019-07-10 22:27:54 +00001076
David Bainbridge99ac7a22019-08-31 02:26:43 +00001077STIME=$(date +%s)
1078bspin "Verify or download chart specific values files $DOWNLOAD"
1079VALUES_FILES="monkey-values.yaml"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001080ERR_OUT=$(mktemp)
David Bainbridge99ac7a22019-08-31 02:26:43 +00001081for i in $VALUES_FILES; do
1082 if [ ! -r ./$i ]; then
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001083 (set -x; curl --fail -o ./$i -sSL https://raw.githubusercontent.com/ciena/kind-voltha/$VK_RELEASE/$i >>$LOG 2>$ERR_OUT) >>$LOG 2>&1
1084 if [ $? -ne 0 ]; then
1085 espin $THEX
1086 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat $ERR_OUT)${NORMAL}"
1087 echo "ERROR: $i - $(cat $ERR_OUT)" >>$LOG
1088 rm -rf $ERR_OUT ./$i
1089 exit 1
1090 fi
1091 rm -rf $ERR_OUT
David Bainbridge99ac7a22019-08-31 02:26:43 +00001092 fi
1093done
1094espin $VERIFIED
1095if [ "$WITH_TIMINGS" == "yes" ]; then
1096 printtime $(expr $(date +%s) - $STIME)
1097fi
1098
1099if [ "$WITH_CHAOS" == "yes" ]; then
1100 bspin "Verify or clone kube-monkey helm chart $DOWNLOAD"
1101 if [ -r ./kube-monkey ]; then
1102 espin $VERIFIED
1103 else
1104 espin $NOT_VERIFIED
1105 bspin - "GIT clone kube-monkey"
1106 (set -x; git clone https://github.com/asobti/kube-monkey kube-monkey >>$LOG 2>&1) >>$LOG 2>&1
1107 espin - $VERIFIED
1108 fi
1109fi
1110
Test Userba1e7e72019-07-10 22:27:54 +00001111if [ "$JUST_K8S" == "yes" ]; then
1112 echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye."
1113 echo ""
1114 echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
1115 echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
1116 echo "tools required by VOLTHA in your command path. " | tee -a $LOG
1117 echo "" | tee -a $LOG
1118 echo -en $BOLD
1119 if [ $DEPLOY_K8S == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001120 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +00001121 fi
1122 echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
1123 echo -en $NORMAL
1124 echo "" | tee -a $LOG
1125 echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
1126 exit 0
1127fi
1128
David Bainbridgee87067b2019-08-12 22:00:12 +00001129STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +00001130bspin "Verify ETCD Operator $OLD_KEY"
Test User7d866122019-07-09 17:52:35 +00001131if [ $(helm list --deployed --short --namespace voltha "^etcd-operator\$" | wc -l) -ne 1 ]; then
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001132 espin $NOT_VERIFIED
David Bainbridge90fd8e32019-08-21 23:32:47 +00001133 helm_install - voltha etcd-operator stable/etcd-operator latest "Install ETCD Operator"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001134else
1135 espin $VERIFIED
1136fi
Test User01ed0642019-07-03 20:17:06 +00001137EXPECT=$(test "$TYPE" == "minimal" && echo "1" || echo "3")
David Bainbridge4f1b5562019-08-19 04:46:52 +00001138wait_for_pods - "voltha" $EXPECT "includes" -1 "Waiting for ETCD Operator to start" "etcd-operator-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001139if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001140 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001141fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001142
David Bainbridgee87067b2019-08-12 22:00:12 +00001143STIME=$(date +%s)
David Bainbridgeb270c202019-07-26 01:44:42 +00001144if [ $WITH_ONOS == "yes" ]; then
1145 bspin "Verify ONOS installed $BIRD"
1146 if [ $(helm list --deployed --short --namespace default "^onos\$" | wc -l) -ne 1 ]; then
1147 espin $NOT_VERIFIED
David K. Bainbridgeda33d652020-03-06 10:31:23 -08001148 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 +00001149 else
1150 espin $VERIFIED
1151 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +00001152 wait_for_pods - "default" 1 "includes" -1 "Waiting for ONOS to start" "onos-.*"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001153
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001154 if [ $WITH_PORT_FORWARDS == "yes" ]; then
1155 bspin - "Forward ONOS API port $FORWARD"
1156 kill_port_forward onos-ui
1157 port_forward default onos-ui $ONOS_API_PORT 8181
1158 espin - $VERIFIED
1159 bspin - "Forward ONOS SSH port $FORWARD"
1160 kill_port_forward onos-ssh
1161 port_forward default onos-ssh $ONOS_SSH_PORT 8101
1162 espin - $VERIFIED
1163 _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT"
1164 else
1165 _ONOS_API_EP=$(get_service_ep default onos-ui)
1166 fi
David Bainbridged31d6122019-08-13 19:37:59 +00001167 bspin - "Verify or download ONOS configuration support files $DOWNLOAD"
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001168 ONOS_FILES="olt-onos-enableExtraneousRules.json onos-aaa.json \
David Bainbridge90fd8e32019-08-21 23:32:47 +00001169 onos-dhcpl2relay.json onos-kafka.json onos-sadis-sample.json"
David Bainbridged31d6122019-08-13 19:37:59 +00001170 (set -x; mkdir -p ./onos-files >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001171 ERR_OUT=$(mktemp)
David Bainbridge2b19e832019-08-16 02:40:53 +00001172 for i in $ONOS_FILES; do
David Bainbridged31d6122019-08-13 19:37:59 +00001173 if [ ! -r ./onos-files/$i ]; then
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001174 (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
1175 if [ $? -ne 0 ]; then
1176 espin - $THEX
1177 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat $ERR_OUT)${NORMAL}"
1178 echo "ERROR: $(cat $ERR_OUT)" >>$LOG
1179 rm -rf $ERR_OUT ./onos-files/$i
1180 exit 1
1181 fi
1182 rm -rf $ERR_OUT
David Bainbridged31d6122019-08-13 19:37:59 +00001183 fi
1184 done
Test Userba1e7e72019-07-10 22:27:54 +00001185 espin - $VERIFIED
David Bainbridge27790d62019-08-13 22:43:19 +00001186
1187 if [ $INSTALL_ONOS_APPS == "yes" ]; then
1188 bspin - "Installing custom ONOS applications"
1189 if [ -x onos-files/onos-apps -a $(ls -1 onos-files/onos-apps/*.oar 2>/dev/null | wc -l) -gt 0 ]; then
1190 for OAR in $(ls -1 onos-files/onos-apps/*.oar); do
1191 sspin - "Installing custom ONOS applications - $OAR$CEOL"
David Bainbridge2b19e832019-08-16 02:40:53 +00001192 override_onos_app $OAR
David Bainbridge27790d62019-08-13 22:43:19 +00001193 done
1194 espin - "$VERIFIED Installing custom ONOS applications$CEOL"
1195 else
1196 espin - "$NOT_VERIFIED Installing custom ONOS applications - None Found"
1197 fi
1198 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001199
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001200 check_onos_app_active org.opencord.kafka
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001201 push_onos_config "file" "Push ONOS Kafka Configuration" "network/configuration/apps/org.opencord.kafka" "onos-files/onos-kafka.json"
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001202 check_onos_app_active org.opencord.dhcpl2relay
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001203 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 -08001204 check_onos_app_active org.opencord.olt
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001205 # FIXME use WITH_DHCP and WITH_EAPOL flags to configre OLT App
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001206 # Default value for "enableEapol" is true in OLT App
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001207 if [ $WITH_EAPOL == "yes" ]; then
1208 push_onos_config "json" "Enable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":true}'
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001209 elif [ $WITH_EAPOL == "no" ]; then
1210 push_onos_config "json" "Disable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001211 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001212 # Default value for "enableDhcpOnProvisioning" is false and for "enableDhcpV4" is true in OLT App
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001213 if [ $WITH_DHCP == "yes" ]; then
1214 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 +00001215 elif [ $WITH_DHCP == "no" ]; then
1216 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 -08001217 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001218 # Default value for "enableIgmpOnProvisioning" is false in OLT App
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001219 if [ $WITH_IGMP == "yes" ]; then
1220 push_onos_config "json" "Enable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":true}'
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001221 elif [ $WITH_IGMP == "no" ]; then
1222 push_onos_config "json" "Disable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001223 fi
David K. Bainbridge484d80c2020-03-05 21:44:34 -08001224 if [ $ENABLE_ONOS_EXTRANEOUS_RULES == "yes" ]; then
1225 push_onos_config "file" "Enabling extraneous rules for ONOS" "configuration/org.onosproject.net.flow.impl.FlowRuleManager" "onos-files/olt-onos-enableExtraneousRules.json"
1226 fi
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001227 if [ $(echo ":yes:file:" | grep -c ":$CONFIG_SADIS:") -eq 1 ]; then
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001228 check_onos_app_active org.opencord.sadis
Hardik Windlassb3147602020-03-09 16:59:15 +05301229 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 -07001230 elif [ "$CONFIG_SADIS" == "bbsim" ]; then
1231 push_onos_config "json" \
1232 "[optional] Push ONOS configuration for BBSIM SADIS servers" \
1233 "network/configuration/apps/org.opencord.sadis" \
1234 "$(echo $(cat <<EOJ
1235{
1236 "sadis": {
1237 "integration": {
1238 "url": "http://bbsim.voltha.svc.cluster.local:50074/v2/subscribers/%s",
1239 "cache": {
1240 "enabled": true,
1241 "maxsize": 50,
1242 "ttl": "PT1m"
1243 }
1244 }
1245 },
1246 "bandwidthprofile": {
1247 "integration": {
1248 "url": "http://bbsim.voltha.svc.cluster.local:50074/v2/bandwidthprofiles/%s",
1249 "cache": {
1250 "enabled": true,
1251 "maxsize": 50,
1252 "ttl": "PT1m"
1253 }
1254 }
1255 }
1256}
1257EOJ
1258) | tr -d '[:space:]')"
1259 elif [ "$CONFIG_SADIS" == "url" ]; then
1260 push_onos_config "json" \
1261 "[optional] Push ONOS configuration for custom SADIS and Bandwidth Profile servers" \
1262 "network/configuration/apps/org.opencord.sadis" \
1263 "$(echo $(cat <<EOJ
1264{
1265 "sadis": {
1266 "integration": {
1267 "url": "$SADIS_SUBSCRIBERS",
1268 "cache": {
1269 "enabled": true,
1270 "maxsize": 50,
1271 "ttl": "PT1m"
1272 }
1273 }
1274 },
1275 "bandwidthprofile": {
1276 "integration": {
1277 "url": "$SADIS_BANDWIDTH_PROFILES",
1278 "cache": {
1279 "enabled": true,
1280 "maxsize": 50,
1281 "ttl": "PT1m"
1282 }
1283 }
1284 }
1285}
1286EOJ
1287) | tr -d '[:space:]')"
David Bainbridge2b19e832019-08-16 02:40:53 +00001288 fi
Test Userba1e7e72019-07-10 22:27:54 +00001289fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001290if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001291 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001292fi
Test Userba1e7e72019-07-10 22:27:54 +00001293
David Bainbridgee87067b2019-08-12 22:00:12 +00001294STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +00001295bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
Test User7d866122019-07-09 17:52:35 +00001296if [ $(helm list --deployed --short --namespace voltha "^voltha\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001297 espin $NOT_VERIFIED
David Bainbridge70c0ea82019-11-14 23:25:26 +00001298 if [ "$ONLY_ONE" == "yes" ]; then
David K. Bainbridgec8591452020-03-09 18:56:03 -07001299 EXTRA_HELM_INSTALL_ARGS="--set therecanbeonlyone=true"
David Bainbridge70c0ea82019-11-14 23:25:26 +00001300 fi
David Bainbridge90fd8e32019-08-21 23:32:47 +00001301 helm_install - voltha voltha $VOLTHA_CHART $VOLTHA_CHART_VERSION "Install VOLTHA Core"
David Bainbridge70c0ea82019-11-14 23:25:26 +00001302 EXTRA_HELM_INSTALL_ARGS=
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001303else
1304 espin $VERIFIED
1305fi
Test Userba1e7e72019-07-10 22:27:54 +00001306
David Bainbridge90fd8e32019-08-21 23:32:47 +00001307VOLTHA="voltha-ofagent-.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001308 ro-core.* \
1309 rw-core.* \
1310 voltha-api-server-.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001311 voltha-etcd-cluster-.* \
1312 voltha-kafka-.* \
1313 voltha-zookeeper-.*"
David Bainbridge70c0ea82019-11-14 23:25:26 +00001314if [ "$ONLY_ONE" == "yes" ]; then
David Bainbridge1ba64f12019-12-18 00:40:13 +00001315 EXPECT=$(test "$TYPE" == "minimal" && echo "5" || echo "7")
David Bainbridge70c0ea82019-11-14 23:25:26 +00001316else
David Bainbridge1ba64f12019-12-18 00:40:13 +00001317 EXPECT=$(test "$TYPE" == "minimal" && echo "8" || echo "10")
David Bainbridge70c0ea82019-11-14 23:25:26 +00001318fi
David Bainbridge4f1b5562019-08-19 04:46:52 +00001319wait_for_pods - "voltha" $EXPECT "includes" -1 "Waiting for VOLTHA Core to start" $VOLTHA
David Bainbridgee87067b2019-08-12 22:00:12 +00001320if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001321 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001322fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001323
David Bainbridge46505fb2019-10-01 21:13:20 +00001324if [ "$WITH_ADAPTERS" == "yes" ]; then
1325 STIME=$(date +%s)
1326 EXPECT=0
1327 echo -e "Verify Adapters $PLUG"
1328 if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then
1329 bspin - "Verify Simulated Adapters installed"
1330 if [ $(helm list --deployed --short --namespace voltha "^sim\$" | wc -l) -ne 1 ]; then
1331 espin - $NOT_VERIFIED
1332 helm_install - voltha sim $VOLTHA_ADAPTER_SIM_CHART $VOLTHA_ADAPTER_SIM_CHART_VERSION "Install Simulated Adapters"
1333 else
1334 espin - $VERIFIED
1335 fi
1336 EXPECT=$(expr $EXPECT + 2)
1337 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001338
David Bainbridge46505fb2019-10-01 21:13:20 +00001339 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
1340 bspin - "Verify OpenOLT Adapter installed"
1341 if [ $(helm list --deployed --short --namespace voltha "^open-olt\$" | wc -l) -ne 1 ]; then
1342 espin - $NOT_VERIFIED
1343 helm_install - voltha open-olt $VOLTHA_ADAPTER_OPEN_OLT_CHART $VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION "Install OpenOLT Adapter"
1344 else
1345 espin - $VERIFIED
1346 fi
1347 bspin - "Verify OpenONU Adapter installed"
1348 if [ $(helm list --deployed --short --namespace voltha "^open-onu\$" | wc -l) -ne 1 ]; then
1349 espin - $NOT_VERIFIED
1350 helm_install - voltha open-onu $VOLTHA_ADAPTER_OPEN_ONU_CHART $VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION "Install OpenONU Adapter"
1351 else
1352 espin - $VERIFIED
1353 fi
1354 EXPECT=$(expr $EXPECT + 2)
1355 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001356
David Bainbridge46505fb2019-10-01 21:13:20 +00001357 ADAPTERS="adapter-.*"
1358 wait_for_pods - "voltha" $EXPECT "includes" -1 "Waiting for adapters to start" $ADAPTERS
1359 if [ "$WITH_TIMINGS" == "yes" ]; then
1360 printtime $(expr $(date +%s) - $STIME)
1361 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001362fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001363
Test User7d866122019-07-09 17:52:35 +00001364if [ $WITH_BBSIM == "yes" ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +00001365 STIME=$(date +%s)
Test User7d866122019-07-09 17:52:35 +00001366 echo -e "Verify BBSIM $PLUG"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001367 bspin - "Verify BBSIM Installed"
David K. Bainbridge43422402020-03-06 07:41:22 -08001368 for instance in $(seq 0 $(($NUM_OF_BBSIM-1))); do
1369 if [ $instance -eq 0 ]; then
1370 instance_num=""
1371 else
1372 instance_num=$instance
1373 fi
1374 if [ $(helm list --deployed --short --namespace voltha "^bbsim${instance_num}\$" | wc -l) -ne 1 ]; then
1375 espin - $NOT_VERIFIED
David K. Bainbridgec8591452020-03-09 18:56:03 -07001376 SAVED=$EXTRA_HELM_INSTALL_ARGS
1377 EXTRA_HELM_INSTALL_ARGS+=" --set olt_id=$instance"
David K. Bainbridge43422402020-03-06 07:41:22 -08001378 helm_install - voltha bbsim${instance_num} $VOLTHA_BBSIM_CHART $VOLTHA_BBSIM_CHART_VERSION "Install BBSIM${instance_num}"
David K. Bainbridgec8591452020-03-09 18:56:03 -07001379 EXTRA_HELM_INSTALL_ARGS=$SAVED
David K. Bainbridge43422402020-03-06 07:41:22 -08001380 else
1381 espin - $VERIFIED
1382 fi
1383 done
uottrembb16d3982020-02-28 08:34:36 +01001384 wait_for_pods - "voltha" $NUM_OF_BBSIM "includes" -1 "Waiting for BBSIM to start" "bbsim*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001385 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001386 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001387 fi
Test User7d866122019-07-09 17:52:35 +00001388fi
1389
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001390if [ $WITH_RADIUS == "yes" ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +00001391 STIME=$(date +%s)
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001392 echo -e "Verify RADIUS $LOCK"
1393 bspin - "Verify RADIUS Installed"
1394 if [ $(helm list --deployed --short --namespace voltha "^radius\$" | wc -l) -ne 1 ]; then
1395 espin - $NOT_VERIFIED
David Bainbridge90fd8e32019-08-21 23:32:47 +00001396 helm_install - voltha radius onf/freeradius latest "Install RADIUS"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001397 else
1398 espin - $VERIFIED
1399 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +00001400 wait_for_pods - "voltha" 1 "includes" -1 "Waiting for RADIUS to start" "radius-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001401 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001402 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001403 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001404fi
1405
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001406if [ $WITH_PORT_FORWARDS == "yes" ]; then
1407 STIME=$(date +%s)
1408 bspin - "Forward VOLTHA API port $FORWARD"
1409 kill_port_forward voltha-api
1410 port_forward voltha voltha-api $VOLTHA_API_PORT 55555
1411 espin - $VERIFIED
1412 bspin - "Forward VOLTHA ETCD port $FORWARD"
1413 kill_port_forward voltha-etcd-cluster-client
1414 port_forward voltha voltha-etcd-cluster-client $VOLTHA_ETCD_PORT 2379
1415 espin - $VERIFIED
1416 bspin - "Forward VOLTHA Kafka port $FORWARD"
1417 kill_port_forward voltha-kafka
1418 port_forward voltha voltha-kafka $VOLTHA_KAFKA_PORT 9092
1419 espin - $VERIFIED
1420 if [ "$WITH_TIMINGS" == "yes" ]; then
1421 printtime $(expr $(date +%s) - $STIME)
1422 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001423fi
Test User3d7ad8e2019-07-03 06:15:44 +00001424
David Bainbridgeb270c202019-07-26 01:44:42 +00001425if [ $WITH_ONOS == "yes" -a $WITH_RADIUS == "yes" ]; then
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001426 bspin "Configure ONOS RADIUS Connection $GEAR"
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001427 (set -x; cat onos-files/onos-aaa.json | sed -e "s/:RADIUS_IP:/$(kubectl -n voltha get service/radius -o jsonpath={.spec.clusterIP})/g" | 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 +00001428 espin $VERIFIED
1429fi
1430
David Bainbridge99ac7a22019-08-31 02:26:43 +00001431if [ "$WITH_CHAOS" == "yes" ]; then
1432 STIME=$(date +%s)
1433 echo -e "Verify kube-monkey $LOCK"
1434 bspin - "Verify kube-monkey Installed"
1435 if [ $(helm list --deployed --short --namespace kube-monkey "^monkey\$" | wc -l) -ne 1 ]; then
1436 espin - $NOT_VERIFIED
1437 helm_install - kube-monkey monkey ./kube-monkey/helm/kubemonkey latest "Install Chaos Monkey"
1438 else
1439 espin - $VERIFIED
1440 fi
1441 wait_for_pods - "kube-monkey" 1 "includes" -1 "Waiting for Chaos to start" "monkey-.*"
1442 if [ "$WITH_TIMINGS" == "yes" ]; then
1443 printtime $(expr $(date +%s) - $STIME)
1444 fi
1445fi
1446
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001447bspin "Create voltctl configuration file"
Test User3d7ad8e2019-07-03 06:15:44 +00001448(set -x; mkdir -p $HOME/.volt >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001449MIN_VC_VERSION=$(echo -e "1.0.15\n$VC_VERSION" | sort -V | head -1)
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001450if [ $WITH_PORT_FORWARDS == "yes" ]; then
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001451 KAFKA_FLAG="-k localhost:$VOLTHA_KAFKA_PORT"
1452 SERVER_FLAG="-s localhost:$VOLTHA_API_PORT"
1453 ETCD_FLAG=
1454 if [ "$MIN_VC_VERSION" == "1.0.15" ]; then
1455 ETCD_FLAG="-e localhost:$VOLTHA_ETCD_PORT"
1456 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001457else
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001458 KAFKA_FLAG="-k $(get_service_ep voltha voltha-kafka)"
1459 SERVER_FLAG="-s $(get_service_ep voltha voltha-api)"
1460 ETCD_FLAG=
1461 if [ "$MIN_VC_VERSION" == "1.0.15" ]; then
1462 ETCD_FLAG="-e $(get_service_ep voltha voltha-etcd-client)"
1463 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001464fi
David K. Bainbridgeb859e912020-03-13 14:07:52 -07001465(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 +00001466espin $VERIFIED
Test User08ebbd92019-07-03 17:15:39 +00001467
David Bainbridge0774b232019-08-02 06:37:19 +00001468if [ ! -f "$NAME-env.sh" ]; then
1469 touch $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001470fi
1471
David Bainbridge596f30d2019-07-30 17:07:59 +00001472for O in $ALL_OPTIONS; do
1473 VAL=$(eval echo \$$O)
David Bainbridge0774b232019-08-02 06:37:19 +00001474 if [ ! -z "$VAL" -a $(grep -c "^export $O=" $NAME-env.sh) -eq 0 ]; then
1475 echo "export $O=\"$(eval echo \$$O)\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001476 fi
1477done
1478
David Bainbridge0774b232019-08-02 06:37:19 +00001479if [ $DEPLOY_K8S == "yes" -a $(grep -c "^export KUBECONFIG=" $NAME-env.sh) -eq 0 ]; then
1480 echo "export KUBECONFIG=\"$(./bin/kind get kubeconfig-path --name=voltha-$NAME)\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001481fi
1482
David Bainbridge0774b232019-08-02 06:37:19 +00001483if [ $(grep -c "^export VOLTCONFIG=" $NAME-env.sh) -eq 0 ]; then
1484 echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001485fi
1486
David Bainbridge0774b232019-08-02 06:37:19 +00001487if [ $(grep -c "^export PATH=" $NAME-env.sh) -eq 0 ]; then
1488 echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001489fi
1490
Test User7d866122019-07-09 17:52:35 +00001491echo ""
Test User08ebbd92019-07-03 17:15:39 +00001492echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
1493echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
1494echo "tools required by VOLTHA in your command path. " | tee -a $LOG
1495echo "" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +00001496echo -en $BOLD
Test Userba1e7e72019-07-10 22:27:54 +00001497if [ $DEPLOY_K8S == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001498 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +00001499fi
David Bainbridge0774b232019-08-02 06:37:19 +00001500echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +00001501echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +00001502echo -en $NORMAL
Test User08ebbd92019-07-03 17:15:39 +00001503echo "" | tee -a $LOG
1504echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
1505
David Bainbridge712afb82019-08-14 19:55:58 +00001506if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridgef858a022019-08-14 21:25:11 +00001507 echo -e "$CLOCK ${BOLD}TOTAL: $(duration $(expr $(date +%s) - $TOTAL_START_TIME))${NORMAL}"
David Bainbridge712afb82019-08-14 19:55:58 +00001508fi