blob: 80c3721a09a4689309bbced55e5e0c5cd4f4eaea [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 Bainbridge2b19e832019-08-16 02:40:53 +000085CONFIG_SADIS=${CONFIG_SADIS:-no}
Hardik Windlassb3147602020-03-09 16:59:15 +053086SADIS_CFG=${SADIS_CFG:-onos-files/onos-sadis-sample.json}
David Bainbridge27790d62019-08-13 22:43:19 +000087INSTALL_ONOS_APPS=${INSTALL_ONOS_APPS:-no}
Test Userba1e7e72019-07-10 22:27:54 +000088JUST_K8S=${JUST_K8S:-no}
89DEPLOY_K8S=${DEPLOY_K8S:-yes}
David K. Bainbridge0e89cb92019-07-17 11:30:10 -070090INSTALL_KUBECTL=${INSTALL_KUBECTL:-yes}
91INSTALL_HELM=${INSTALL_HELM:-yes}
David Bainbridge46505fb2019-10-01 21:13:20 +000092UPDATE_HELM_REPOS=${UPDATE_HELM_REPOS:-yes}
Matteo Scandolofab98622020-01-28 15:17:20 -080093WAIT_ON_DOWN=${WAIT_ON_DOWN:-yes}
David Bainbridge5b7b96b2019-07-25 20:29:13 +000094VOLTHA_LOG_LEVEL=${VOLTHA_LOG_LEVEL:-WARN}
David Bainbridge90fd8e32019-08-21 23:32:47 +000095VOLTHA_CHART=${VOLTHA_CHART:-onf/voltha}
96VOLTHA_CHART_VERSION=${VOLTHA_CHART_VERSION:-latest}
97VOLTHA_BBSIM_CHART=${VOLTHA_BBSIM_CHART:-onf/bbsim}
Matteo Scandolodcd29f52019-10-07 15:42:42 -070098VOLTHA_BBSIM_CHART_VERSION=${VOLTHA_BBSIM_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +000099VOLTHA_ADAPTER_SIM_CHART=${VOLTHA_ADAPTER_SIM_CHART:-onf/voltha-adapter-simulated}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000100VOLTHA_ADAPTER_SIM_CHART_VERSION=${VOLTHA_ADAPTER_SIM_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000101VOLTHA_ADAPTER_OPEN_OLT_CHART=${VOLTHA_ADAPTER_OPEN_OLT_CHART:-onf/voltha-adapter-openolt}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000102VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION=${VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION:-latest}
David Bainbridgee10f6d52019-07-25 00:28:13 +0000103VOLTHA_ADAPTER_OPEN_ONU_CHART=${VOLTHA_ADAPTER_OPEN_ONU_CHART:-onf/voltha-adapter-openonu}
David Bainbridge90fd8e32019-08-21 23:32:47 +0000104VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION=${VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION:-latest}
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800105ONOS_CHART=${ONOS_CHART:-onf/onos}
Andrea Campanella21323292019-12-18 11:44:19 -0800106ONOS_CHART_VERSION=${ONOS_CHART_VERSION:-latest}
David Bainbridge70c0ea82019-11-14 23:25:26 +0000107EXTRA_HELM_INSTALL_ARGS=
uottrembb16d3982020-02-28 08:34:36 +0100108NUM_OF_BBSIM=${NUM_OF_BBSIM:-1}
109MAX_NUM_OF_BBSIM=10
Test Userba1e7e72019-07-10 22:27:54 +0000110
111HAVE_GO=$(which go >/dev/null 2>&1 && echo "yes" || echo "no")
112HOSTOS=$(uname -s | tr "[:upper:]" "[:lower:"])
113HOSTARCH=$(uname -m | tr "[:upper:]" "[:lower:"])
114if [ $HOSTARCH == "x86_64" ]; then
115 HOSTARCH="amd64"
116fi
Test User7d866122019-07-09 17:52:35 +0000117
uottrembb16d3982020-02-28 08:34:36 +0100118# check number (range) of bbsim, max bbsim must not exceed 10 instances!
119# note: instances will be numbered from 0 to 9
120if [ "$1" == "up" ]; then
David K. Bainbridge43422402020-03-06 07:41:22 -0800121 if [ "$NUM_OF_BBSIM" -lt 1 ]; then
122 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid setting of BBSIM instances. NUM_OF_BBSIM is less than 1${NORMAL}"
123 exit 1
124 fi
125 if [ "$NUM_OF_BBSIM" -gt $MAX_NUM_OF_BBSIM ]; then
126 >&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}"
127 exit 1
128 fi
uottrembb16d3982020-02-28 08:34:36 +0100129fi
Test User7d866122019-07-09 17:52:35 +0000130# Verify TYPE setting
131if [ $(echo ":minimal:full:" | grep -ic ":$TYPE:") -eq 0 ]; then
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700132 >&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 +0000133 exit 1
134fi
135
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800136function get_service_ep() {
137 local NS=$1
138 local NAME=$2
139 kubectl -n $NS get service $NAME -o json | jq -r '.spec.clusterIP + ":" + (.spec.ports[0].port|tostring)'
140}
141
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000142# Used to verify configuration values are set to "yes" or "no" value or convert
143# equivalents to "yes" or "no"
144function verify_yes_no() {
145 local VAR=$1
146 local VAL=$(eval echo \$$VAR)
147 if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$VAL:") -eq 0 ]; then
148 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid '$VAR' value of '$VAL'. Should be 'yes' or 'no'${NORMAL}"
149 echo "INVALID"
150 return 1
151 fi
152 if [ $(echo ":y:yes:true:1:" | grep -ic ":$VAL:") -eq 1 ]; then
153 echo "yes"
154 else
155 echo "no"
156 fi
157 return 0
158}
Test User7d866122019-07-09 17:52:35 +0000159
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000160ALL_YES_NO="\
David K. Bainbridge484d80c2020-03-05 21:44:34 -0800161 ENABLE_ONOS_EXTRANEOUS_RULES \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000162 WITH_TIMINGS \
163 WITH_BBSIM \
164 WITH_RADIUS \
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800165 WITH_EAPOL \
166 WITH_DHCP \
167 WITH_IGMP \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000168 WITH_ONOS \
David Bainbridge99ac7a22019-08-31 02:26:43 +0000169 WITH_CHAOS \
David Bainbridge46505fb2019-10-01 21:13:20 +0000170 WITH_ADAPTERS \
171 WITH_SIM_ADAPTERS \
172 WITH_OPEN_ADAPTERS \
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800173 WITH_PORT_FORWARDS \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000174 CONFIG_SADIS \
175 JUST_K8S \
176 DEPLOY_K8S \
177 INSTALL_ONOS_APPS \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000178 INSTALL_KUBECTL \
179 INSTALL_HELM \
David Bainbridge46505fb2019-10-01 21:13:20 +0000180 UPDATE_HELM_REPOS \
David Bainbridge4f1b5562019-08-19 04:46:52 +0000181 WAIT_ON_DOWN \
David Bainbridge70c0ea82019-11-14 23:25:26 +0000182 ONLY_ONE \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000183 "
David Bainbridge5b7b96b2019-07-25 20:29:13 +0000184
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000185ALL_OPTIONS="\
186 NAME \
187 TYPE \
188 $ALL_YES_NO \
189 VOLTHA_LOG_LEVEL \
190 VOLTHA_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000191 VOLTHA_CHART_VERSION \
192 VOLTHA_BBSIM_CHART \
193 VOLTHA_BBSIM_CHART_VERSION \
uottrembd5a20572020-03-06 09:15:01 +0100194 NUM_OF_BBSIM \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000195 VOLTHA_ADAPTER_SIM_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000196 VOLTHA_ADAPTER_SIM_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000197 VOLTHA_ADAPTER_OPEN_OLT_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000198 VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000199 VOLTHA_ADAPTER_OPEN_ONU_CHART \
David Bainbridge90fd8e32019-08-21 23:32:47 +0000200 VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION \
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800201 ONOS_CHART \
Andrea Campanella21323292019-12-18 11:44:19 -0800202 ONOS_CHART_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000203 ONOS_API_PORT \
204 ONOS_SSH_PORT \
Hardik Windlassb3147602020-03-09 16:59:15 +0530205 SADIS_CFG \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000206 VOLTHA_API_PORT \
207 VOLTHA_SSH_PORT \
208 VOLTHA_ETCD_PORT \
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800209 VOLTHA_KAFKA_PORT \
David K. Bainbridge8f7f30b2020-01-08 13:06:16 -0800210 VK_RELEASE \
211 KIND_VERSION \
212 VOLTCTL_VERSION \
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000213 "
David Bainbridge01294952019-07-30 19:33:45 +0000214
David Bainbridge2a0b8a42019-08-16 17:39:29 +0000215# Iterate over yes/no configuration options and validate
216for VAR in $ALL_YES_NO; do
217 eval $VAR=$(verify_yes_no $VAR)
218 if [ "$(eval echo \$$VAR)" == "INVALID" ]; then
219 exit 1;
220 fi
221done
David Bainbridgeb270c202019-07-26 01:44:42 +0000222
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800223# Check for prerequiste tools
David K. Bainbridge726ff6a2020-03-06 11:09:50 -0800224TOOLS="curl sed jq"
David K. Bainbridgeda33d652020-03-06 10:31:23 -0800225if [ $DEPLOY_K8S == "yes" ]; then
226 TOOLS+=" docker"
227fi
228NOT_FOUND=""
229for T in $TOOLS; do
230 if [ -z "$(which $T)" ]; then
231 NOT_FOUND+=" $T"
232 fi
233done
234
235if [ ! -z "$NOT_FOUND" ]; then
236 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} The following required tools where not found, please install them:$NOT_FOUND"
237 exit 1
238fi
239
David Bainbridge0774b232019-08-02 06:37:19 +0000240mkdir -p .voltha
241touch .voltha/ports
242HAVE=$(grep $NAME .voltha/ports)
243if [ "$HAVE X" == " X" ]; then
244 # Find free port prefix
245 START=81
246 while true; do
247 if [ $(grep -c $START .voltha/ports) -eq 0 ]; then
248 break
249 fi
250 START=$(expr $START + 1)
251 done
252 DELTA=$(expr $START - 81)
David Bainbridgea2595422019-10-22 03:54:28 +0000253 ONOS_API_PORT=${ONOS_API_PORT:-${START}81}
254 ONOS_SSH_PORT=${ONOS_SSH_PORT:-${START}01}
255 VOLTHA_API_PORT=${VOLTHA_API_PORT:-5$(expr 55 + $DELTA)55}
256 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$(expr 50 + $DELTA)22}
257 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$(expr 23 + $DELTA)79}
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800258 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(expr 90 + $DELTA)92}
Test User01ed0642019-07-03 20:17:06 +0000259else
David Bainbridge0774b232019-08-02 06:37:19 +0000260 VALUES=$(echo $HAVE | sed -e 's/\s//g' | cut -d= -f2)
David Bainbridgea2595422019-10-22 03:54:28 +0000261 ONOS_API_PORT=${ONOS_API_PORT:-$(echo $VALUES | cut -d, -f1)}
262 ONOS_SSH_PORT=${ONOS_SSH_PORT:-$(echo $VALUES | cut -d, -f2)}
263 VOLTHA_API_PORT=${VOLTHA_API_PORT:-$(echo $VALUES | cut -d, -f3)}
264 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$(echo $VALUES | cut -d, -f4)}
265 VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$(echo $VALUES | cut -d, -f5)}
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800266 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(echo $VALUES | cut -d, -f6)}
267
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800268 # A bit of a hueristic required here as the KAFKA port forward was
269 # added after the .voltha/ports files was created. Basically, if
270 # the VOLTHA_KAFKA_PORT isn't in the file then calculate the original
271 # DELTA from the VOLTHA_SSH_PORT and apply it to the VOLTHA_KAFKA_PORT
272 if [ -z "$VOLTHA_KAFKA_PORT" ]; then
273 DELTA=$((VOLTHA_SSH_PORT/100-50))
274 VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(expr 90 + $DELTA)92}
275 fi
Test User01ed0642019-07-03 20:17:06 +0000276fi
277
David Bainbridge0774b232019-08-02 06:37:19 +0000278PORTTMP=$(mktemp -u)
279cat .voltha/ports | grep -v $NAME > $PORTTMP
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800280echo "$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 +0000281cp $PORTTMP .voltha/ports
282rm -f $PORTTMP
283
David Bainbridge27790d62019-08-13 22:43:19 +0000284export ONOS_API_PORT ONOS_SSH_PORT
David Bainbridge01294952019-07-30 19:33:45 +0000285
Test Userd87942b2019-07-03 07:20:24 +0000286IDX=1
David Bainbridgee87067b2019-08-12 22:00:12 +0000287CLOCK="TIME:"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000288SPIN_PARTS=
289NOT_VERIFIED=
David Bainbridgef858a022019-08-14 21:25:11 +0000290THEX=
291BUILD=
292CROSS=
293ENTER=
David Bainbridge38dc1e82019-08-12 15:18:45 +0000294VERIFIED=
295HELM=
296OLD_KEY=
297BIRD=
298HIGH_VOLTAGE=
299PLUG=
300RESTART=
301FORWARD=
302INSTALL=
303STOP=
304GO=
305DOWNLOAD=
306GEAR=
307NO_ENTRY=
308LOCK=
309
310if [ $FANCY -eq 1 ]; then
311 SPIN_PARTS="\
312 \xe2\xa2\x8e\xe2\xa1\xb0 \
313 \xe2\xa2\x8e\xe2\xa1\xa1 \
314 \xe2\xa2\x8e\xe2\xa1\x91 \
315 \xe2\xa2\x8e\xe2\xa0\xb1 \
316 \xe2\xa0\x8e\xe2\xa1\xb1 \
317 \xe2\xa2\x8a\xe2\xa1\xb1 \
318 \xe2\xa2\x8c\xe2\xa1\xb1 \
319 \xe2\xa2\x86\xe2\xa1\xb1 \
320 "
David Bainbridgee87067b2019-08-12 22:00:12 +0000321 CLOCK="\xe2\x8f\xb1"
David Bainbridgef858a022019-08-14 21:25:11 +0000322 THEX="${RED}${BOLD}\xe2\x9c\x97\x20${NORMAL}"
323 ENTER="${YELLOW}${BOLD}\xe2\x8e\x86${NORMAL}"
324 CROSS="${YELLOW}${BOLD}\xe2\x9c\x9a${NORMAL}"
325 BUILD="${YELLOW}${BOLD}\xf0\x9f\x8f\x97${NORMAL}"
326 NOT_VERIFIED="$BUILD"
327 VERIFIED="${GREEN}${BOLD}\xe2\x9c\x93\x20${NORMAL}"
328 HELM="${BLUE}${BOLD}\xE2\x8E\x88${NORMAL}"
David Bainbridge38dc1e82019-08-12 15:18:45 +0000329 OLD_KEY="\xF0\x9F\x97\x9D"
330 BIRD="\xF0\x9F\x90\xA6"
331 HIGH_VOLTAGE="\xE2\x9A\xA1"
332 PLUG="\xF0\x9F\xa7\xa9"
333 RESTART="\xf0\x9f\x94\x84"
334 FORWARD="\xE2\x87\xA8"
335 INSTALL="\xF0\x9F\x8F\x97"
336 STOP="\xf0\x9f\x9b\x91"
337 GO="\xf0\x9f\x9a\x80"
338 DOWNLOAD="\xf0\x9f\x93\xa5"
339 GEAR="\xe2\x9a\x99"
340 NO_ENTRY="\xe2\x9b\x94"
341 LOCK="\xf0\x9f\x94\x92"
342fi
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700343
David Bainbridge712afb82019-08-14 19:55:58 +0000344duration() {
David Bainbridgee87067b2019-08-12 22:00:12 +0000345 local h=$(expr $1 / 3600)
346 local m=$(expr $1 % 3600 / 60)
347 local s=$(expr $1 % 60)
348 local t=""
349
350 if [ $h -gt 0 ]; then
351 t="$t${h}h"
352 fi
353 if [ $m -gt 0 ]; then
354 t="$t${m}m"
355 fi
David Bainbridge712afb82019-08-14 19:55:58 +0000356 echo "$t${s}s"
357}
358
359printtime() {
360 local INDENT=
361 if [ "$1" == "-" ]; then
362 INDENT=" "
363 shift
364 fi
365 echo -e "$INDENT $CLOCK $(duration $1)"
David Bainbridgee87067b2019-08-12 22:00:12 +0000366}
367
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700368bspin() {
Test Userd87942b2019-07-03 07:20:24 +0000369 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700370 local INDENT=
371 if [ "$1" == "-" ]; then
372 INDENT=" "
373 shift
374 fi
David Bainbridge38dc1e82019-08-12 15:18:45 +0000375 if [ $FANCY -eq 0 ]; then
376 LINE=$(echo $* | sed -e 's/[\s+-]//g')
377 if [ "$LINE X" == " X" ]; then
378 return
379 fi
380 echo -e "$CIVIS$INDENT$*"
381 else
382 echo -en "$CIVIS$INDENT $*"
383 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700384}
385
386sspin() {
387 local INDENT=
388 if [ "$1" == "-" ]; then
389 INDENT=" "
390 shift
391 fi
David Bainbridge38dc1e82019-08-12 15:18:45 +0000392 if [ $FANCY -eq 0 ]; then
393 LINE=$(echo $* | sed -e 's/[\s+-]//g')
394 if [ "$LINE X" == " X" ]; then
395 return
396 fi
397 echo -e "$INDENT$*"
398 else
399 C=$(echo $SPIN_PARTS | cut '-d ' -f $IDX)
400 echo -en "\r$INDENT$C $*"
401 IDX=$(expr $IDX + 1)
402 if [ $IDX -gt 8 ]; then
403 IDX=1
404 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700405 fi
406}
407
408espin() {
409 local INDENT=
410 if [ "$1" == "-" ]; then
411 INDENT=" "
412 shift
413 fi
David Bainbridge38dc1e82019-08-12 15:18:45 +0000414 if [ $FANCY -eq 0 ]; then
415 LINE=$(echo $* | sed -e 's/[\s+-]//g')
416 if [ "$LINE X" == " X" ]; then
417 return
418 fi
419 echo -e "$INDENT$*"
420 else
421 echo -e "\r$INDENT$*$CNORM"
422 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700423}
424
David Bainbridgeac7f8072019-08-01 22:15:33 +0000425if [ "$1" == "get" -a "$2" == "voltconfig" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000426 echo "$HOME/.volt/config-$NAME"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000427 exit
428fi
429
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -0700430if [ $# -ne 1 -o $(echo ":up:down:dump:" | grep -c ":$1:") -ne 1 ]; then
David Bainbridgeac7f8072019-08-01 22:15:33 +0000431 >&2 echo "What wouild you like to do today:"
432 >&2 echo " up - bring up voltha"
433 >&2 echo " down - tear down voltha"
434 >&2 echo " dump - create a debug dump of running system"
435 exit 1
436fi
437
David Bainbridge4f1b5562019-08-19 04:46:52 +0000438push_onos_config() {
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800439 local TYPE=$1
440 local MSG=$2
441 local RESOURCE=$3
442 local DATA=$4
David Bainbridge4f1b5562019-08-19 04:46:52 +0000443
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800444 # Thanks to the latest version of ONOS using the return code 207 this gets a
445 # whole lot nastier. Can't thank them enough for doing this. So in order to
446 # capture the command and the output in the log file as well as capture the
447 # status code to verify it is 200 and not 207 mutltiple files and a bit of
448 # hackery must be used. Thanks again ONOS.
449 local CMD_ECHO=$(mktemp -u)
450 local CMD_OUTPUT=$(mktemp -u)
451 local SC_OUTPUT=$(mktemp -u)
452
David Bainbridge4f1b5562019-08-19 04:46:52 +0000453 bspin - "$MSG $GEAR"
454 while true; do
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800455 if [ $TYPE == "file" ]; then
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800456 (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
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800457 fi
458 if [ $TYPE == "json" ]; then
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800459 (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
Matteo Scandolo78dfee02020-02-13 16:18:03 -0800460 fi
David K. Bainbridgeb4b163b2020-02-19 15:55:06 -0800461 RESULT=$?
462 # Dump everything to the log
463 cat $CMD_ECHO >> $LOG
464 cat $CMD_OUTPUT >> $LOG
465 SC=$(cat $SC_OUTPUT)
466
467 # clean up temp files
468 rm -f $CMD_ECHO $CMD_OUTPUT $SC_OUTPUT
469 if [ $RESULT -eq 0 -a "$SC" == "200" ]; then
David Bainbridge4f1b5562019-08-19 04:46:52 +0000470 break
471 fi
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800472 sleep 1
David Bainbridge4f1b5562019-08-19 04:46:52 +0000473 sspin -
474 done
475 espin - $VERIFIED
476}
477
Matteo Scandolo9a77a732020-01-09 14:24:12 -0800478check_onos_app_active() {
479 local APP_ID=$1
480
481 bspin - "Checking that $APP_ID is active $CLOCK"
482 while true; do
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800483 (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 -0800484 if [ $? -eq 0 ]; then
485 break
486 fi
487 sleep 1
488 sspin -
489 done
490 sleep 5 # OSGI components take a little longer that the app to activate
491 espin - $VERIFIED
492}
493
David Bainbridge4f1b5562019-08-19 04:46:52 +0000494override_onos_app() {
495 local APP=$1
496 local NAME=$(basename $APP | sed -e 's/^[0-9][0-9]*-//g' -e 's/-.*$//g')
497 while true; do
498 sspin -
499 # Attempt to delete old version (if it exists)
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800500 (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 +0000501 sspin -
502 if [ $? -ne 0 ]; then
503 continue
504 fi
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800505 (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 +0000506 if [ $? -eq 0 ]; then
507 break
508 fi
509 sleep .2
510 done
511}
512
513activate_onos_app() {
514 local MSG="$1"
515 local APP=$2
516
517 bspin - "$MSG $GO"
518 while true; do
519 sspin -
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -0800520 (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 +0000521 if [ $? -eq 0 ]; then
522 break
523 fi
524 sleep .2
525 done
526 espin - "$VERIFIED"
527}
528
529count_pods() {
530 local NAMESPACE=$1; shift
531 if [ "$NAMESPACE" == "all-namespaces" ]; then
532 NAMESPACE="--all-namespaces"
533 else
534 NAMESPACE="-n $NAMESPACE"
535 fi
536 echo "$NAMESPACE" > /tmp/t
537 local STATES=$1; shift
538 echo "$STATES" >> /tmp/t
539 local PODS=$(kubectl get $NAMESPACE pod -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}")
540 local COUNT=0
541 local PATTERNS="$*"
542 for POD in $PODS; do
543 local NAME=$(echo $POD | cut -d/ -f 1)
544 local STATE=$(echo $POD | cut -d/ -f 2)
545 local CONTAINERS=$(echo $POD | cut -d/ -f 3 | sed -e 's/_/ /g')
546 if [ "$STATES" == "*" -o $(echo "$STATES" | grep -c ":$STATE:") -ne 0 ]; then
547 echo "IN WITH $POD" >> /tmp/t
548 local TOTAL=$(echo $CONTAINERS | wc -w)
549 local FOUND=$(echo $CONTAINERS | grep -o true | wc -l)
550 if [ $TOTAL -eq $FOUND ]; then
551 for PATTERN in $PATTERNS; do
552 echo "TEST $PATTERN AGAINST $NAME" >> /tmp/t
553 if [[ $NAME =~ $PATTERN ]]; then
554 echo "COUNT $NAME" >> /tmp/t
555 COUNT=$(expr $COUNT + 1)
556 break
557 fi
558 done
559 fi
560 fi
561 done
562 echo $COUNT >> /tmp/t
563 echo $COUNT
564}
565
566wait_for_pods() {
567 local INDENT=
568 if [ "$1" == "-" ]; then
569 INDENT=$1; shift
570 fi
571 local NAMESPACE=$1; shift
572 local EXPECT=$1; shift
573 local TYPE=$1; shift
574 local RETRY=$1; shift
575 local MESSAGE=$1; shift
576 local PATTERNS=$*
David Bainbridge99ac7a22019-08-31 02:26:43 +0000577 local STATES=":Running:"
578 if [ "$TYPE" == "not" ]; then
579 STATES="*"
580 fi
581 local HAVE=$(count_pods $NAMESPACE "$STATES" $PATTERNS)
David Bainbridge4f1b5562019-08-19 04:46:52 +0000582 local ALL=$HAVE
583 if [ "$TYPE" == "only" ]; then
584 ALL=$(count_pods "all-namespaces" "*" ".*")
585 fi
586 COUNT=$(expr 300 / 15)
587 bspin $INDENT $MESSAGE
588 sspin $INDENT
589 if [ $HAVE -ne $EXPECT -o $ALL -ne $HAVE ]; then
590 while [ $HAVE -ne $EXPECT -o $ALL -ne $HAVE ]; do
591 sspin $INDENT
592 COUNT=$(expr $COUNT - 1)
593 if [ $COUNT -eq 0 ]; then
David Bainbridge99ac7a22019-08-31 02:26:43 +0000594 HAVE=$(count_pods $NAMESPACE "$STATES" $PATTERNS)
David Bainbridge4f1b5562019-08-19 04:46:52 +0000595 ALL=$HAVE
596 if [ "$TYPE" == "only" ]; then
597 ALL=$(count_pods "all-namespaces" "*" ".*")
598 fi
599 COUNT=$(expr 300 / 15)
600 fi
601 sleep .15
602 done
603 fi
604 espin $INDENT $VERIFIED
605 if [ $HAVE -ne $EXPECT ]; then
606 return 1
607 fi
608 return 0
609}
610
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800611port_forward() {
612 local NS=$1
613 local SVC=$2
614 local FROM_PORT=$3
615 local TO_PORT=$4
616 local TAG=$SVC-$NAME
617
618 (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
619}
620
621kill_port_forward() {
622 local TAG=$1-$NAME
David Bainbridgec6871d22019-11-13 17:10:31 +0000623 local P_IDS=$(ps e -ww -A | grep "_TAG=$TAG" | grep -v grep | awk '{print $1}')
David Bainbridgebcf235b2019-11-12 21:33:58 +0000624 local PARENTS=
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800625 local KIDS=
David Bainbridgec6871d22019-11-13 17:10:31 +0000626 local UNKNOWN=
627 if [ ! -z "$P_IDS" ]; then
628 for P_ID in $P_IDS; do
629 local PP_ID=$(ps -o ppid $P_ID | tail -n +2)
630 if [ ! -z "$PP_ID" ]; then
631 if [ $PP_ID -eq 1 ]; then
632 PARENTS="$PARENTS $P_ID"
633 else
634 KIDS="$KIDS $P_ID"
635 fi
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800636 else
David Bainbridgec6871d22019-11-13 17:10:31 +0000637 UNKNOWN="$UNKNOWN $P_ID"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800638 fi
639 done
David Bainbridgec6871d22019-11-13 17:10:31 +0000640 (set -x; kill -9 $PARENTS $KIDS $UNKNOWN >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800641 fi
642}
643
David Bainbridgeac7f8072019-08-01 22:15:33 +0000644if [ "$1" == "down" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000645 echo "Tearing down voltha cluster $NAME"
646 LOG="down-$NAME.log"
647 echo $(date -u +"%Y%m%dT%H%M%SZ") >$LOG
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800648 bspin "Remove port-forwards: onos-ui-$NAME"
649 kill_port_forward onos-ui
650 sspin "Remove port-forwards: onos-ssh-$NAME$CEOL"
651 kill_port_forward onos-ssh
652 sspin "Remove port-forwards: voltha-api-$NAME$CEOL"
653 kill_port_forward voltha-api
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800654 sspin "Remove port-forwards: voltha-etcd-$NAME$CEOL"
655 kill_port_forward voltha-etcd-cluster-client
David K. Bainbridge00ecd382020-02-28 12:31:58 -0800656 sspin "Remove port-forwards: voltha-kafka-$NAME$CEOL"
657 kill_port_forward voltha-kafka
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800658 espin "$VERIFIED Remove port-forwards$CEOL"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000659 if [ $DEPLOY_K8S == "yes" ]; then
660 if [ -x ./bin/kind ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000661 bspin "Delete Kubernetes Kind Cluster"
662 (set -x; ./bin/kind delete cluster --name voltha-$NAME >>$LOG 2>&1) >>$LOG 2>&1
663 espin $VERIFIED
David Bainbridgeac7f8072019-08-01 22:15:33 +0000664 else
David Bainbridge0774b232019-08-02 06:37:19 +0000665 espin "$NO_ENTRY Delete Kubernetes Kind Cluster: kind command not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000666 fi
667 else
668 EXISTS=$(helm list -q)
669 EXPECT="etcd-operator onos open-olt open-onu sim voltha bbsim radius"
David Bainbridge0774b232019-08-02 06:37:19 +0000670 bspin "Remove Helm Deployments"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000671 for i in $EXISTS; do
David K. Bainbridge43422402020-03-06 07:41:22 -0800672 for j in $EXPECT; do
673 if [[ $i =~ $j ]]; then
674 sspin "Remove Helm Deployments: $i$CEOL"
675 (set -x; ./bin/helm delete --no-hooks --purge $i >>$LOG 2>&1) >>$LOG 2>&1
676 fi
677 done
uottrembb16d3982020-02-28 08:34:36 +0100678 done
David Bainbridge0774b232019-08-02 06:37:19 +0000679 espin "$VERIFIED Remove Helm Deployments$CEOL"
David Bainbridge4f1b5562019-08-19 04:46:52 +0000680 if [ "$WAIT_ON_DOWN" == "yes" ]; then
681 # There should only be 13 or 15 PODs in the kube-system name
682 # space and no other PODs
David Bainbridge4f1b5562019-08-19 04:46:52 +0000683 PODS="coredns-.* \
684 etcd-voltha-$NAME-control-plane \
685 kindnet-.* \
686 kube-apiserver-voltha-$NAME-control-plane \
687 kube-controller-manager-voltha-$NAME-control-plane \
688 kube-proxy-.* \
689 kube-scheduler-voltha-$NAME-control-plane \
690 tiller-deploy-.*"
691 EXPECT=$(test "$TYPE" == "minimal" && echo "13" || echo "15")
David Bainbridge99ac7a22019-08-31 02:26:43 +0000692 PODS="adapter-.* \
693 bbsim.* \
694 etcd-operator.* \
695 radius.* \
696 voltha-.*"
Matteo Scandolo73442f92020-01-29 09:53:22 -0800697
David Bainbridge99ac7a22019-08-31 02:26:43 +0000698 EXPECT=0
699
Matteo Scandolo73442f92020-01-29 09:53:22 -0800700 if [ "$WITH_ONOS" == "yes" ]; then
701 ONOS_PODS="onos-.*"
702 wait_for_pods "default" $EXPECT "not" -1 "Waiting for ONOS PODs to terminate" $ONOS_PODS
703 fi
David Bainbridge99ac7a22019-08-31 02:26:43 +0000704 wait_for_pods "voltha" $EXPECT "not" -1 "Waiting for VOLTHA PODs to terminate" $PODS
David Bainbridge4f1b5562019-08-19 04:46:52 +0000705 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +0000706 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -0700707 exit
David Bainbridgeac7f8072019-08-01 22:15:33 +0000708fi
709
710if [ "$1" == "dump" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000711 LOG="dump-$NAME.log"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000712 TS=$(date -u +"%Y%m%dT%H%M%SZ")
David Bainbridge76514a02019-10-08 01:50:35 +0000713 if [ ! -z "$DUMP_FROM" ]; then
714 TS=$(echo $DUMP_FROM | sed -e 's/[:-]//g')
715 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +0000716 WORK=$(mktemp -u -d)
David Bainbridge0774b232019-08-02 06:37:19 +0000717 DATA=$WORK/voltha-debug-dump-$NAME-$TS
David Bainbridgeac7f8072019-08-01 22:15:33 +0000718 mkdir -p $DATA
719 echo $TS > $LOG
David Bainbridge0774b232019-08-02 06:37:19 +0000720 echo -e "Capturing debug dump to voltha-debug-dump-$NAME-$TS.tgz"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000721 bspin - "Copy install log"
David Bainbridge0774b232019-08-02 06:37:19 +0000722 if [ -f install-$NAME.log ]; then
723 (set -x; cp install-$NAME.log $DATA/install-$NAME.log) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000724 espin - $VERIFIED
725 else
David Bainbridge0774b232019-08-02 06:37:19 +0000726 espin - "$NO_ENTRY Copy install log: install-$NAME.log not found"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000727 fi
728 bspin - "Dumping Kubernetes PODs"
729 (set -x; kubectl get --all-namespaces pods >> $DATA/all-pods.txt 2>&1) >>$LOG 2>&1
730 espin - $VERIFIED
731 bspin - "Dumping Kubernetes SERVICEs"
732 (set -x; kubectl get --all-namespaces svc >> $DATA/all-services.txt 2>&1) >>$LOG 2>&1
733 espin - $VERIFIED
734 bspin - "Dumping Kubernetes EVENTs"
735 (set -x; kubectl get --all-namespaces events >> $DATA/all-events.txt 2>&1) >>$LOG 2>&1
736 espin - $VERIFIED
737 bspin - "Dumping VOLTHA POD details"
Matteo Scandolodcd29f52019-10-07 15:42:42 -0700738 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 +0000739 SINCE=
740 if [ ! -z "$DUMP_FROM" ]; then
741 SINCE="--since-time=$DUMP_FROM"
742 fi
David Bainbridgeac7f8072019-08-01 22:15:33 +0000743 for POD in $PODS; do
David Bainbridge1f0655a2019-10-01 22:08:48 +0000744 NS=$(echo $POD | cut -d: -f1)
745 POD=$(echo $POD | cut -d: -f2)
David Bainbridgeac7f8072019-08-01 22:15:33 +0000746 sspin - "Dumping VOLTHA POD details: $POD$CEOL"
747 mkdir -p $DATA/$POD
David Bainbridge1f0655a2019-10-01 22:08:48 +0000748 (set -x; kubectl describe -n $NS $POD >> $DATA/$POD/describe.txt 2>&1) >>$LOG 2>&1
David Bainbridgeac7f8072019-08-01 22:15:33 +0000749 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridgecfd7ca12019-10-06 03:31:41 +0000750 (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 +0000751 sspin - "Dumping VOLTHA POD details: $POD"
David Bainbridgecfd7ca12019-10-06 03:31:41 +0000752 (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 +0000753 sspin - "Dumping VOLTHA POD details: $POD"
754 done
755 espin - "$VERIFIED Dumping VOLTHA POD details$CEOL"
756 bspin - "Dumping ETCD"
757 if [ "$(which etcdctl) X" != " X" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000758 (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 +0000759 espin - $VERIFIED
760 else
761 espin - "$NO_ENTRY Dumping ETCD: etcdctl command not available"
762 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000763 bspin - "Creating compressed TAR: voltha-debug-dump-$NAME-$TS.tgz"
764 (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 +0000765 espin - $VERIFIED
766 bspin - "Cleanup"
767 (set -x; rm -rf $WORK) >>$LOG 2>&1
768 espin - $VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +0000769 bspin - "$(ls -l voltha-debug-dump-$NAME-$TS.tgz)"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000770 espin - $VERIFIED
771 exit
772fi
773
David Bainbridge0774b232019-08-02 06:37:19 +0000774LOG="install-$NAME.log"
David Bainbridgeac7f8072019-08-01 22:15:33 +0000775date > $LOG
David Bainbridge0774b232019-08-02 06:37:19 +0000776echo "PORTS=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT" >> $LOG
David Bainbridgeac7f8072019-08-01 22:15:33 +0000777
778# Output install options to log
779echo "OPTIONS" >> $LOG
David Bainbridgeac7f8072019-08-01 22:15:33 +0000780for O in $ALL_OPTIONS; do
781 VAL=$(eval echo \$$O)
David Bainbridgeac7f8072019-08-01 22:15:33 +0000782 if [ ! -z "$VAL" ]; then
783 printf " %-30s = %s\n" $O $VAL >> $LOG
784 fi
785done
786
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -0700787helm_install() {
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700788 local INDENT=
789 if [ "$1" == "-" ]; then
790 INDENT=$1; shift
791 fi
792 local NAMESPACE=$1; shift
David Bainbridge0774b232019-08-02 06:37:19 +0000793 local INAME=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700794 local CHART=$1; shift
David Bainbridge90fd8e32019-08-21 23:32:47 +0000795 local CHART_VERSION=$1; shift
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700796 local MESSAGE=$*
797
David Bainbridge90fd8e32019-08-21 23:32:47 +0000798 if [ "$CHART_VERSION X" != " X" -a "$CHART_VERSION" != "latest" ]; then
799 CHART_VERSION="--version $CHART_VERSION"
800 else
801 CHART_VERSION=
802 fi
803
David Bainbridge99ac7a22019-08-31 02:26:43 +0000804 local CHART_ARGS=
805 if [ -r "${INAME}-values.yaml" ]; then
806 CHART_ARGS="-f ${INAME}-values.yaml"
807 fi
808
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700809 COUNT=$(expr 300 / 15)
810 bspin $INDENT $MESSAGE
David Bainbridge70c0ea82019-11-14 23:25:26 +0000811 (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 -0700812 SUCCESS=$?
813 while [ $SUCCESS -ne 0 ]; do
814 sspin $INDENT
815 COUNT=$(expr $COUNT - 1)
816 if [ $COUNT -eq 0 ]; then
Andy Baviere22ff252019-12-19 11:40:31 -0700817 (set -x; helm delete --purge $INAME >>$LOG 2>&1) >>$LOG 2>&1
David Bainbridge99ac7a22019-08-31 02:26:43 +0000818 (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 -0700819 SUCCESS=$?
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700820 COUNT=$(expr 300 / 15)
821 fi
822 sleep .15
823 done
824 espin $INDENT $VERIFIED
825}
826
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700827echo "INSTALL TYPE: $TYPE" >> $LOG
828
829bspin "Verify GOPATH"
830export GOPATH=$(pwd)
Test User3d7ad8e2019-07-03 06:15:44 +0000831mkdir -p $GOPATH/bin
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700832espin $VERIFIED
833
David Bainbridgee87067b2019-08-12 22:00:12 +0000834STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700835if [ "$INSTALL_KUBECTL" == "no" ]; then
836 bspin "Skip kubectl install"
837 espin $NO_ENTRY
Test Userc13bdc92019-07-03 20:57:49 +0000838else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700839 bspin "Verify kubectl $HELM"
840 if [ -x $GOPATH/bin/kubectl ]; then
841 espin $VERIFIED
842 else
843 espin $NOT_VERIFIED
844 bspin - "Download and install Kubernetes/kubectl $DOWNLOAD"
845 (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
846 (set -x; chmod 755 $GOPATH/bin/kubectl >>$LOG 2>&1) >>$LOG 2>&1
847 espin - $VERIFIED
848 fi
Test Userc13bdc92019-07-03 20:57:49 +0000849fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000850if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000851 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000852fi
Test Userc13bdc92019-07-03 20:57:49 +0000853
David Bainbridgee87067b2019-08-12 22:00:12 +0000854STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700855if [ "$DEPLOY_K8S" == "no" ]; then
856 bspin "Skip Kubernetes/Kind Deployment"
857 espin $NO_ENTRY
858else
Test Userba1e7e72019-07-10 22:27:54 +0000859 bspin "Verify Kubernetes/Kind $HELM"
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800860 IS_INSTALLED=0
861 OP_TYPE="install"
Test Userba1e7e72019-07-10 22:27:54 +0000862 if [ -x $GOPATH/bin/kind ]; then
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800863 OP_TYPE="upgrade"
864 if [ $($GOPATH/bin/kind --version | grep -c $KIND_VERSION) -eq 1 ]; then
865 IS_INSTALLED=1
866 espin $VERIFIED
867 fi
868 fi
869 if [ $IS_INSTALLED -eq 0 ]; then
Test Userba1e7e72019-07-10 22:27:54 +0000870 espin $NOT_VERIFIED
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800871 bspin - "Download and $OP_TYPE Kubernetes/kind $DOWNLOAD"
David Bainbridge9e2a6662019-07-11 17:07:57 +0000872 (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 +0000873 (set -x; chmod 755 $GOPATH/bin/kind >>$LOG 2>&1) >>$LOG 2>&1
874 espin - $VERIFIED
875 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700876fi
877
David Bainbridgee87067b2019-08-12 22:00:12 +0000878if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000879 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000880fi
881
882STIME=$(date +%s)
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700883if [ "$INSTALL_HELM" == "no" ]; then
884 bspin "Skip Helm Install"
885 espin $NO_ENTRY
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700886else
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700887 bspin "Verify Helm $HELM"
888 if [ -x $GOPATH/bin/helm ]; then
889 espin $VERIFIED
890 else
891 espin $NOT_VERIFIED
892 bspin - "Download and install Helm $DOWNLOAD"
David Bainbridgec6a6eb62019-10-18 22:50:07 +0000893 (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 -0700894 espin - $VERIFIED
895 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700896fi
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -0800897
David Bainbridgee87067b2019-08-12 22:00:12 +0000898if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000899 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000900fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700901
David Bainbridgee87067b2019-08-12 22:00:12 +0000902STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +0000903bspin "Verify voltctl $HIGH_VOLTAGE"
David Bainbridged2811972019-12-14 01:14:09 +0000904VOK=0
905VMESSAGE="install"
David K. Bainbridgeebf38d92020-02-10 10:46:31 -0800906export VC_VERSION="$VOLTCTL_VERSION"
907if [ "$VC_VERSION" == "latest" ]; then
908 export VC_VERSION=$(curl -sSL https://api.github.com/repos/opencord/voltctl/releases/latest | jq -r .tag_name | sed -e 's/^v//g')
909fi
Test User3d7ad8e2019-07-03 06:15:44 +0000910if [ -x $GOPATH/bin/voltctl ]; then
David Bainbridge1ba64f12019-12-18 00:40:13 +0000911 VHAVE=$($GOPATH/bin/voltctl version --clientonly -o json | jq -r .version)
David K. Bainbridgeebf38d92020-02-10 10:46:31 -0800912 if [ $? -eq 0 -a "$VHAVE" == "$VC_VERSION" ]; then
David Bainbridged2811972019-12-14 01:14:09 +0000913 VOK=1
David Bainbridge1ba64f12019-12-18 00:40:13 +0000914 espin $VERIFIED
915 else
David K. Bainbridgeebf38d92020-02-10 10:46:31 -0800916 VCHECK=$(echo -e "$VHAVE\n$VC_VERSION" | sort -V | head -1)
917 if [ "$VCHECK" == "$VHAVE" ]; then
918 VMESSAGE="upgrade"
919 else
920 VMESSAGE="downgrade"
921 fi
David Bainbridged2811972019-12-14 01:14:09 +0000922 fi
923fi
924
David Bainbridge1ba64f12019-12-18 00:40:13 +0000925if [ $VOK -eq 0 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700926 espin $NOT_VERIFIED
David Bainbridged2811972019-12-14 01:14:09 +0000927 bspin - "Download and $VMESSAGE voltctl $DOWNLOAD"
David K. Bainbridgeebf38d92020-02-10 10:46:31 -0800928 (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 +0000929 (set -x; chmod 755 $GOPATH/bin/voltctl >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700930 espin - $VERIFIED
931fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000932if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000933 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000934fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700935
936bspin "Verify command PATH"
Test Userba1e7e72019-07-10 22:27:54 +0000937export PATH=$GOPATH/bin:$PATH
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700938espin $VERIFIED
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700939
David Bainbridgee87067b2019-08-12 22:00:12 +0000940STIME=$(date +%s)
Test Userba1e7e72019-07-10 22:27:54 +0000941if [ "$DEPLOY_K8S" == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +0000942 HAVE=$(kind get clusters | grep -c voltha-$NAME)
Test Userba1e7e72019-07-10 22:27:54 +0000943 bspin "Verify Kubernetes/Kind Cluster"
944 sspin
945 if [ $HAVE -eq 0 ]; then
David Bainbridge491b1bd2019-07-11 17:53:11 +0000946 espin $NOT_VERIFIED
947 bspin - "Verify cluster configuration"
David Bainbridge0774b232019-08-02 06:37:19 +0000948 if [ ! -r ./$NAME-cluster.cfg ]; then
David Bainbridge491b1bd2019-07-11 17:53:11 +0000949 espin - $NOT_VERIFIED
David K. Bainbridge43422402020-03-06 07:41:22 -0800950 bspin - "Download cluster configuration: $TYPE-cluster.cfg to $NAME-cluster.cfg $DOWNLOAD"
David K. Bainbridgea00736b2020-01-08 14:33:17 -0800951 ERR_OUT=$(mktemp)
952 (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
953 if [ $? -ne 0 ]; then
954 espin - $THEX
955 echo -e "${RED}${BOLD}${ERROR}ERROR: $NAME-cluster.cfg${NORMAL}${RED} - $(cat $ERR_OUT)${NORMAL}"
956 echo "ERROR: $(cat $ERR_OUT)" >>$LOG
957 rm -rf $ERR_OUT ./$NAME-cluster.cfg
958 exit 1
959 fi
960 rm -rf $ERR_OUT
961 else
David K. Bainbridge43422402020-03-06 07:41:22 -0800962 espin - $VERIFIED
David K. Bainbridgea00736b2020-01-08 14:33:17 -0800963 fi
David Bainbridge0774b232019-08-02 06:37:19 +0000964 kind create cluster --name voltha-$NAME --config $NAME-cluster.cfg
David Bainbridge491b1bd2019-07-11 17:53:11 +0000965 else
966 espin $VERIFIED
Test Userba1e7e72019-07-10 22:27:54 +0000967 fi
968
David Bainbridge0774b232019-08-02 06:37:19 +0000969 export KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$NAME")"
Test Userba1e7e72019-07-10 22:27:54 +0000970 P="coredns-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000971 etcd-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +0000972 kindnet-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000973 kube-apiserver-voltha-$NAME-control-plane \
974 kube-controller-manager-voltha-$NAME-control-plane \
Test Userba1e7e72019-07-10 22:27:54 +0000975 kube-proxy-.* \
David Bainbridge0774b232019-08-02 06:37:19 +0000976 kube-scheduler-voltha-$NAME-control-plane"
Test Userba1e7e72019-07-10 22:27:54 +0000977
978 EXPECT=$(test "$TYPE" == "minimal" && echo "12" || echo "14")
David Bainbridge4f1b5562019-08-19 04:46:52 +0000979 wait_for_pods - "kube-system" $EXPECT "includes" -1 "Waiting for system PODs to start" $P
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700980fi
David Bainbridgee87067b2019-08-12 22:00:12 +0000981if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +0000982 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +0000983fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700984
David Bainbridgee87067b2019-08-12 22:00:12 +0000985STIME=$(date +%s)
David Bainbridge4c6289c2019-09-03 21:11:32 +0000986COUNT=$(count_pods "kube-system" ":Running:" "tiller-deploy-.*")
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700987bspin "Verify Helm"
Test Userba1e7e72019-07-10 22:27:54 +0000988if [ $COUNT -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700989 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000990 echo -e "Configuring Helm $GEAR"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700991 if [ "$INSTALL_HELM" == "no" ]; then
992 bspin - "Skip Helm/Tiller Initialization"
993 espin - $NO_ENTRY
994 else
995 bspin - "Initialize Helm"
996 (set -x; helm init --upgrade >>$LOG 2>&1) >>$LOG 2>&1
997 espin - $VERIFIED
David Bainbridge4f1b5562019-08-19 04:46:52 +0000998 wait_for_pods - "kube-system" 1 "includes" -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
David K. Bainbridge0e89cb92019-07-17 11:30:10 -0700999 fi
Test Userb5712372019-07-03 21:52:17 +00001000 bspin - "Add Google Incubator repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001001 (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
1002 espin - $VERIFIED
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001003
Test Userba1e7e72019-07-10 22:27:54 +00001004 # HACK (sort-of) - the config for tiller is about to be patched, which will
1005 # cause the tiller pod to be recreated. This can sometimes cause a timing
1006 # issue with the "wait_for_pods" call on tiller as it may incorrectly
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001007 # identify the running/ready tiller pod that is soon to be terminated as
Test Userba1e7e72019-07-10 22:27:54 +00001008 # what it is waiting for. To avoid this issue we do a clean scale down and
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001009 # scale up of the pod so the script controlls when it should be expecting
Test Userba1e7e72019-07-10 22:27:54 +00001010 # things
1011 (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 -07001012
Test Userb5712372019-07-03 21:52:17 +00001013 bspin - "Add Google Stable repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001014 (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
1015 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +00001016 bspin - "Add ONF repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001017 (set -x; helm repo add onf https://charts.opencord.org >>$LOG 2>&1) >>$LOG 2>&1
1018 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +00001019 bspin - "Update Helm repository cache"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001020 (set -x; helm repo update >>$LOG 2>&1) >>$LOG 2>&1
1021 espin - $VERIFIED
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001022
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001023 # Create and k8s service account so that Helm can create pods
Test Userb5712372019-07-03 21:52:17 +00001024 bspin - "Create Tiller ServiceAccount"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001025 (set -x; kubectl create serviceaccount --namespace kube-system tiller >>$LOG 2>&1) >>$LOG 2>&1
1026 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +00001027 bspin - "Create Tiller ClusterRoleBinding"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001028 (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>$LOG 2>&1) >>$LOG 2>&1
1029 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +00001030 bspin - "Update Tiller Manifest"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001031 (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 +00001032
1033 # HACK (sort-of) - part to, spin it back up
1034 (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 -07001035 espin - $VERIFIED
1036else
1037 espin $VERIFIED
David Bainbridge46505fb2019-10-01 21:13:20 +00001038 if [ "$UPDATE_HELM_REPOS" == "yes" ]; then
1039 bspin - "Update Helm repository cache"
1040 (set -x; helm repo update >>$LOG 2>&1) >>$LOG 2>&1
1041 espin - $VERIFIED
1042 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001043fi
David Bainbridge4f1b5562019-08-19 04:46:52 +00001044wait_for_pods - "kube-system" 1 "includes" -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001045if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001046 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001047fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001048
David Bainbridgee87067b2019-08-12 22:00:12 +00001049STIME=$(date +%s)
David Bainbridge0774b232019-08-02 06:37:19 +00001050bspin "Verify Helm values file: $NAME-values.yaml"
1051if [ ! -r "./$NAME-values.yaml" ]; then
Test Userba1e7e72019-07-10 22:27:54 +00001052 espin $NOT_VERIFIED
David Bainbridge0774b232019-08-02 06:37:19 +00001053 bspin - "Download Helm values file: $TYPE-values.yaml to $NAME-values.yaml $DOWNLOAD"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001054 ERR_OUT=$(mktemp)
1055 (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
1056 if [ $? -ne 0 ]; then
1057 espin - $THEX
1058 echo -e "${RED}${BOLD}${ERROR}ERROR: $NAME-values.yaml${NORMAL}${RED} - $(cat $ERR_OUT)${NORMAL}"
1059 echo "ERROR: $(cat $ERR_OUT)" >>$LOG
1060 rm -rf $ERR_OUT ./$NAME-values.yaml
1061 exit 1
1062 fi
1063 rm -rf $ERR_OUT
Test Userba1e7e72019-07-10 22:27:54 +00001064 espin - $VERIFIED
1065else
1066 espin $VERIFIED
1067fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001068if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001069 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001070fi
Test Userba1e7e72019-07-10 22:27:54 +00001071
David Bainbridge99ac7a22019-08-31 02:26:43 +00001072STIME=$(date +%s)
1073bspin "Verify or download chart specific values files $DOWNLOAD"
1074VALUES_FILES="monkey-values.yaml"
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001075ERR_OUT=$(mktemp)
David Bainbridge99ac7a22019-08-31 02:26:43 +00001076for i in $VALUES_FILES; do
1077 if [ ! -r ./$i ]; then
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001078 (set -x; curl --fail -o ./$i -sSL https://raw.githubusercontent.com/ciena/kind-voltha/$VK_RELEASE/$i >>$LOG 2>$ERR_OUT) >>$LOG 2>&1
1079 if [ $? -ne 0 ]; then
1080 espin $THEX
1081 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat $ERR_OUT)${NORMAL}"
1082 echo "ERROR: $i - $(cat $ERR_OUT)" >>$LOG
1083 rm -rf $ERR_OUT ./$i
1084 exit 1
1085 fi
1086 rm -rf $ERR_OUT
David Bainbridge99ac7a22019-08-31 02:26:43 +00001087 fi
1088done
1089espin $VERIFIED
1090if [ "$WITH_TIMINGS" == "yes" ]; then
1091 printtime $(expr $(date +%s) - $STIME)
1092fi
1093
1094if [ "$WITH_CHAOS" == "yes" ]; then
1095 bspin "Verify or clone kube-monkey helm chart $DOWNLOAD"
1096 if [ -r ./kube-monkey ]; then
1097 espin $VERIFIED
1098 else
1099 espin $NOT_VERIFIED
1100 bspin - "GIT clone kube-monkey"
1101 (set -x; git clone https://github.com/asobti/kube-monkey kube-monkey >>$LOG 2>&1) >>$LOG 2>&1
1102 espin - $VERIFIED
1103 fi
1104fi
1105
Test Userba1e7e72019-07-10 22:27:54 +00001106if [ "$JUST_K8S" == "yes" ]; then
1107 echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye."
1108 echo ""
1109 echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
1110 echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
1111 echo "tools required by VOLTHA in your command path. " | tee -a $LOG
1112 echo "" | tee -a $LOG
1113 echo -en $BOLD
1114 if [ $DEPLOY_K8S == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001115 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +00001116 fi
1117 echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
1118 echo -en $NORMAL
1119 echo "" | tee -a $LOG
1120 echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
1121 exit 0
1122fi
1123
David Bainbridgee87067b2019-08-12 22:00:12 +00001124STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +00001125bspin "Verify ETCD Operator $OLD_KEY"
Test User7d866122019-07-09 17:52:35 +00001126if [ $(helm list --deployed --short --namespace voltha "^etcd-operator\$" | wc -l) -ne 1 ]; then
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001127 espin $NOT_VERIFIED
David Bainbridge90fd8e32019-08-21 23:32:47 +00001128 helm_install - voltha etcd-operator stable/etcd-operator latest "Install ETCD Operator"
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001129else
1130 espin $VERIFIED
1131fi
Test User01ed0642019-07-03 20:17:06 +00001132EXPECT=$(test "$TYPE" == "minimal" && echo "1" || echo "3")
David Bainbridge4f1b5562019-08-19 04:46:52 +00001133wait_for_pods - "voltha" $EXPECT "includes" -1 "Waiting for ETCD Operator to start" "etcd-operator-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001134if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001135 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001136fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001137
David Bainbridgee87067b2019-08-12 22:00:12 +00001138STIME=$(date +%s)
David Bainbridgeb270c202019-07-26 01:44:42 +00001139if [ $WITH_ONOS == "yes" ]; then
1140 bspin "Verify ONOS installed $BIRD"
1141 if [ $(helm list --deployed --short --namespace default "^onos\$" | wc -l) -ne 1 ]; then
1142 espin $NOT_VERIFIED
David K. Bainbridgeda33d652020-03-06 10:31:23 -08001143 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 +00001144 else
1145 espin $VERIFIED
1146 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +00001147 wait_for_pods - "default" 1 "includes" -1 "Waiting for ONOS to start" "onos-.*"
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001148
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001149 if [ $WITH_PORT_FORWARDS == "yes" ]; then
1150 bspin - "Forward ONOS API port $FORWARD"
1151 kill_port_forward onos-ui
1152 port_forward default onos-ui $ONOS_API_PORT 8181
1153 espin - $VERIFIED
1154 bspin - "Forward ONOS SSH port $FORWARD"
1155 kill_port_forward onos-ssh
1156 port_forward default onos-ssh $ONOS_SSH_PORT 8101
1157 espin - $VERIFIED
1158 _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT"
1159 else
1160 _ONOS_API_EP=$(get_service_ep default onos-ui)
1161 fi
David Bainbridged31d6122019-08-13 19:37:59 +00001162 bspin - "Verify or download ONOS configuration support files $DOWNLOAD"
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001163 ONOS_FILES="olt-onos-enableExtraneousRules.json onos-aaa.json \
David Bainbridge90fd8e32019-08-21 23:32:47 +00001164 onos-dhcpl2relay.json onos-kafka.json onos-sadis-sample.json"
David Bainbridged31d6122019-08-13 19:37:59 +00001165 (set -x; mkdir -p ./onos-files >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001166 ERR_OUT=$(mktemp)
David Bainbridge2b19e832019-08-16 02:40:53 +00001167 for i in $ONOS_FILES; do
David Bainbridged31d6122019-08-13 19:37:59 +00001168 if [ ! -r ./onos-files/$i ]; then
David K. Bainbridgea00736b2020-01-08 14:33:17 -08001169 (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
1170 if [ $? -ne 0 ]; then
1171 espin - $THEX
1172 echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat $ERR_OUT)${NORMAL}"
1173 echo "ERROR: $(cat $ERR_OUT)" >>$LOG
1174 rm -rf $ERR_OUT ./onos-files/$i
1175 exit 1
1176 fi
1177 rm -rf $ERR_OUT
David Bainbridged31d6122019-08-13 19:37:59 +00001178 fi
1179 done
Test Userba1e7e72019-07-10 22:27:54 +00001180 espin - $VERIFIED
David Bainbridge27790d62019-08-13 22:43:19 +00001181
1182 if [ $INSTALL_ONOS_APPS == "yes" ]; then
1183 bspin - "Installing custom ONOS applications"
1184 if [ -x onos-files/onos-apps -a $(ls -1 onos-files/onos-apps/*.oar 2>/dev/null | wc -l) -gt 0 ]; then
1185 for OAR in $(ls -1 onos-files/onos-apps/*.oar); do
1186 sspin - "Installing custom ONOS applications - $OAR$CEOL"
David Bainbridge2b19e832019-08-16 02:40:53 +00001187 override_onos_app $OAR
David Bainbridge27790d62019-08-13 22:43:19 +00001188 done
1189 espin - "$VERIFIED Installing custom ONOS applications$CEOL"
1190 else
1191 espin - "$NOT_VERIFIED Installing custom ONOS applications - None Found"
1192 fi
1193 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001194
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001195 check_onos_app_active org.opencord.kafka
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001196 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 -08001197 check_onos_app_active org.opencord.dhcpl2relay
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001198 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 -08001199 check_onos_app_active org.opencord.olt
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001200 # FIXME use WITH_DHCP and WITH_EAPOL flags to configre OLT App
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001201 # Default value for "enableEapol" is true in OLT App
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001202 if [ $WITH_EAPOL == "yes" ]; then
1203 push_onos_config "json" "Enable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":true}'
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001204 elif [ $WITH_EAPOL == "no" ]; then
1205 push_onos_config "json" "Disable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001206 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001207 # Default value for "enableDhcpOnProvisioning" is false and for "enableDhcpV4" is true in OLT App
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001208 if [ $WITH_DHCP == "yes" ]; then
1209 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 +00001210 elif [ $WITH_DHCP == "no" ]; then
1211 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 -08001212 fi
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001213 # Default value for "enableIgmpOnProvisioning" is false in OLT App
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001214 if [ $WITH_IGMP == "yes" ]; then
1215 push_onos_config "json" "Enable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":true}'
Hardik Windlassa7501fb2020-02-17 14:28:20 +00001216 elif [ $WITH_IGMP == "no" ]; then
1217 push_onos_config "json" "Disable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":false}'
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001218 fi
David K. Bainbridge484d80c2020-03-05 21:44:34 -08001219 if [ $ENABLE_ONOS_EXTRANEOUS_RULES == "yes" ]; then
1220 push_onos_config "file" "Enabling extraneous rules for ONOS" "configuration/org.onosproject.net.flow.impl.FlowRuleManager" "onos-files/olt-onos-enableExtraneousRules.json"
1221 fi
David Bainbridge2b19e832019-08-16 02:40:53 +00001222 if [ -f onos-files/onos-sadis.json ]; then
Matteo Scandolo78dfee02020-02-13 16:18:03 -08001223 push_onos_config "file" "[optional] Push ONOS SADIS Configuration" "network/configuration/apps/org.opencord.sadis" "onos-files/onos-sadis.json"
David Bainbridge2b19e832019-08-16 02:40:53 +00001224 elif [ "$CONFIG_SADIS" == "yes" ]; then
Matteo Scandolo9a77a732020-01-09 14:24:12 -08001225 check_onos_app_active org.opencord.sadis
Hardik Windlassb3147602020-03-09 16:59:15 +05301226 push_onos_config "file" "[optional] Push ONOS SADIS Configuration: $SADIS_CFG" "network/configuration/apps/org.opencord.sadis" "$SADIS_CFG"
David Bainbridge2b19e832019-08-16 02:40:53 +00001227 fi
Test Userba1e7e72019-07-10 22:27:54 +00001228fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001229if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001230 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001231fi
Test Userba1e7e72019-07-10 22:27:54 +00001232
David Bainbridgee87067b2019-08-12 22:00:12 +00001233STIME=$(date +%s)
Test Userb5712372019-07-03 21:52:17 +00001234bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
Test User7d866122019-07-09 17:52:35 +00001235if [ $(helm list --deployed --short --namespace voltha "^voltha\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001236 espin $NOT_VERIFIED
David Bainbridge70c0ea82019-11-14 23:25:26 +00001237 if [ "$ONLY_ONE" == "yes" ]; then
David K. Bainbridgec8591452020-03-09 18:56:03 -07001238 EXTRA_HELM_INSTALL_ARGS="--set therecanbeonlyone=true"
David Bainbridge70c0ea82019-11-14 23:25:26 +00001239 fi
David Bainbridge90fd8e32019-08-21 23:32:47 +00001240 helm_install - voltha voltha $VOLTHA_CHART $VOLTHA_CHART_VERSION "Install VOLTHA Core"
David Bainbridge70c0ea82019-11-14 23:25:26 +00001241 EXTRA_HELM_INSTALL_ARGS=
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001242else
1243 espin $VERIFIED
1244fi
Test Userba1e7e72019-07-10 22:27:54 +00001245
David Bainbridge90fd8e32019-08-21 23:32:47 +00001246VOLTHA="voltha-ofagent-.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001247 ro-core.* \
1248 rw-core.* \
1249 voltha-api-server-.* \
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001250 voltha-etcd-cluster-.* \
1251 voltha-kafka-.* \
1252 voltha-zookeeper-.*"
David Bainbridge70c0ea82019-11-14 23:25:26 +00001253if [ "$ONLY_ONE" == "yes" ]; then
David Bainbridge1ba64f12019-12-18 00:40:13 +00001254 EXPECT=$(test "$TYPE" == "minimal" && echo "5" || echo "7")
David Bainbridge70c0ea82019-11-14 23:25:26 +00001255else
David Bainbridge1ba64f12019-12-18 00:40:13 +00001256 EXPECT=$(test "$TYPE" == "minimal" && echo "8" || echo "10")
David Bainbridge70c0ea82019-11-14 23:25:26 +00001257fi
David Bainbridge4f1b5562019-08-19 04:46:52 +00001258wait_for_pods - "voltha" $EXPECT "includes" -1 "Waiting for VOLTHA Core to start" $VOLTHA
David Bainbridgee87067b2019-08-12 22:00:12 +00001259if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001260 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001261fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001262
David Bainbridge46505fb2019-10-01 21:13:20 +00001263if [ "$WITH_ADAPTERS" == "yes" ]; then
1264 STIME=$(date +%s)
1265 EXPECT=0
1266 echo -e "Verify Adapters $PLUG"
1267 if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then
1268 bspin - "Verify Simulated Adapters installed"
1269 if [ $(helm list --deployed --short --namespace voltha "^sim\$" | wc -l) -ne 1 ]; then
1270 espin - $NOT_VERIFIED
1271 helm_install - voltha sim $VOLTHA_ADAPTER_SIM_CHART $VOLTHA_ADAPTER_SIM_CHART_VERSION "Install Simulated Adapters"
1272 else
1273 espin - $VERIFIED
1274 fi
1275 EXPECT=$(expr $EXPECT + 2)
1276 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001277
David Bainbridge46505fb2019-10-01 21:13:20 +00001278 if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then
1279 bspin - "Verify OpenOLT Adapter installed"
1280 if [ $(helm list --deployed --short --namespace voltha "^open-olt\$" | wc -l) -ne 1 ]; then
1281 espin - $NOT_VERIFIED
1282 helm_install - voltha open-olt $VOLTHA_ADAPTER_OPEN_OLT_CHART $VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION "Install OpenOLT Adapter"
1283 else
1284 espin - $VERIFIED
1285 fi
1286 bspin - "Verify OpenONU Adapter installed"
1287 if [ $(helm list --deployed --short --namespace voltha "^open-onu\$" | wc -l) -ne 1 ]; then
1288 espin - $NOT_VERIFIED
1289 helm_install - voltha open-onu $VOLTHA_ADAPTER_OPEN_ONU_CHART $VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION "Install OpenONU Adapter"
1290 else
1291 espin - $VERIFIED
1292 fi
1293 EXPECT=$(expr $EXPECT + 2)
1294 fi
Matteo Scandolo7ef6ba52019-10-04 09:20:37 -07001295
David Bainbridge46505fb2019-10-01 21:13:20 +00001296 ADAPTERS="adapter-.*"
1297 wait_for_pods - "voltha" $EXPECT "includes" -1 "Waiting for adapters to start" $ADAPTERS
1298 if [ "$WITH_TIMINGS" == "yes" ]; then
1299 printtime $(expr $(date +%s) - $STIME)
1300 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001301fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -07001302
Test User7d866122019-07-09 17:52:35 +00001303if [ $WITH_BBSIM == "yes" ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +00001304 STIME=$(date +%s)
Test User7d866122019-07-09 17:52:35 +00001305 echo -e "Verify BBSIM $PLUG"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001306 bspin - "Verify BBSIM Installed"
David K. Bainbridge43422402020-03-06 07:41:22 -08001307 for instance in $(seq 0 $(($NUM_OF_BBSIM-1))); do
1308 if [ $instance -eq 0 ]; then
1309 instance_num=""
1310 else
1311 instance_num=$instance
1312 fi
1313 if [ $(helm list --deployed --short --namespace voltha "^bbsim${instance_num}\$" | wc -l) -ne 1 ]; then
1314 espin - $NOT_VERIFIED
David K. Bainbridgec8591452020-03-09 18:56:03 -07001315 SAVED=$EXTRA_HELM_INSTALL_ARGS
1316 EXTRA_HELM_INSTALL_ARGS+=" --set olt_id=$instance"
David K. Bainbridge43422402020-03-06 07:41:22 -08001317 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 -07001318 EXTRA_HELM_INSTALL_ARGS=$SAVED
David K. Bainbridge43422402020-03-06 07:41:22 -08001319 else
1320 espin - $VERIFIED
1321 fi
1322 done
uottrembb16d3982020-02-28 08:34:36 +01001323 wait_for_pods - "voltha" $NUM_OF_BBSIM "includes" -1 "Waiting for BBSIM to start" "bbsim*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001324 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001325 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001326 fi
Test User7d866122019-07-09 17:52:35 +00001327fi
1328
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001329if [ $WITH_RADIUS == "yes" ]; then
David Bainbridgee87067b2019-08-12 22:00:12 +00001330 STIME=$(date +%s)
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001331 echo -e "Verify RADIUS $LOCK"
1332 bspin - "Verify RADIUS Installed"
1333 if [ $(helm list --deployed --short --namespace voltha "^radius\$" | wc -l) -ne 1 ]; then
1334 espin - $NOT_VERIFIED
David Bainbridge90fd8e32019-08-21 23:32:47 +00001335 helm_install - voltha radius onf/freeradius latest "Install RADIUS"
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001336 else
1337 espin - $VERIFIED
1338 fi
David Bainbridge4f1b5562019-08-19 04:46:52 +00001339 wait_for_pods - "voltha" 1 "includes" -1 "Waiting for RADIUS to start" "radius-.*"
David Bainbridgee87067b2019-08-12 22:00:12 +00001340 if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridge712afb82019-08-14 19:55:58 +00001341 printtime $(expr $(date +%s) - $STIME)
David Bainbridgee87067b2019-08-12 22:00:12 +00001342 fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001343fi
1344
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001345if [ $WITH_PORT_FORWARDS == "yes" ]; then
1346 STIME=$(date +%s)
1347 bspin - "Forward VOLTHA API port $FORWARD"
1348 kill_port_forward voltha-api
1349 port_forward voltha voltha-api $VOLTHA_API_PORT 55555
1350 espin - $VERIFIED
1351 bspin - "Forward VOLTHA ETCD port $FORWARD"
1352 kill_port_forward voltha-etcd-cluster-client
1353 port_forward voltha voltha-etcd-cluster-client $VOLTHA_ETCD_PORT 2379
1354 espin - $VERIFIED
1355 bspin - "Forward VOLTHA Kafka port $FORWARD"
1356 kill_port_forward voltha-kafka
1357 port_forward voltha voltha-kafka $VOLTHA_KAFKA_PORT 9092
1358 espin - $VERIFIED
1359 if [ "$WITH_TIMINGS" == "yes" ]; then
1360 printtime $(expr $(date +%s) - $STIME)
1361 fi
David Bainbridgee87067b2019-08-12 22:00:12 +00001362fi
Test User3d7ad8e2019-07-03 06:15:44 +00001363
David Bainbridgeb270c202019-07-26 01:44:42 +00001364if [ $WITH_ONOS == "yes" -a $WITH_RADIUS == "yes" ]; then
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001365 bspin "Configure ONOS RADIUS Connection $GEAR"
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001366 (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 +00001367 espin $VERIFIED
1368fi
1369
David Bainbridge99ac7a22019-08-31 02:26:43 +00001370if [ "$WITH_CHAOS" == "yes" ]; then
1371 STIME=$(date +%s)
1372 echo -e "Verify kube-monkey $LOCK"
1373 bspin - "Verify kube-monkey Installed"
1374 if [ $(helm list --deployed --short --namespace kube-monkey "^monkey\$" | wc -l) -ne 1 ]; then
1375 espin - $NOT_VERIFIED
1376 helm_install - kube-monkey monkey ./kube-monkey/helm/kubemonkey latest "Install Chaos Monkey"
1377 else
1378 espin - $VERIFIED
1379 fi
1380 wait_for_pods - "kube-monkey" 1 "includes" -1 "Waiting for Chaos to start" "monkey-.*"
1381 if [ "$WITH_TIMINGS" == "yes" ]; then
1382 printtime $(expr $(date +%s) - $STIME)
1383 fi
1384fi
1385
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001386bspin "Create voltctl configuration file"
Test User3d7ad8e2019-07-03 06:15:44 +00001387(set -x; mkdir -p $HOME/.volt >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridge4a06a4a2020-03-02 14:15:23 -08001388if [ $WITH_PORT_FORWARDS == "yes" ]; then
1389 (set -x; voltctl -a v3 -k localhost:$VOLTHA_KAFKA_PORT -s localhost:$VOLTHA_API_PORT config > $HOME/.volt/config-$NAME 2>>$LOG) >>$LOG 2>&1
1390else
1391 (set -x; voltctl -a v3 -k $(get_service_ep voltha voltha-kafka) -s $(get_service_ep voltha voltha-api) config > $HOME/.volt/config-$NAME 2>>$LOG) >>$LOG 2>&1
1392fi
David Bainbridge5b7b96b2019-07-25 20:29:13 +00001393espin $VERIFIED
Test User08ebbd92019-07-03 17:15:39 +00001394
David Bainbridge0774b232019-08-02 06:37:19 +00001395if [ ! -f "$NAME-env.sh" ]; then
1396 touch $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001397fi
1398
David Bainbridge596f30d2019-07-30 17:07:59 +00001399for O in $ALL_OPTIONS; do
1400 VAL=$(eval echo \$$O)
David Bainbridge0774b232019-08-02 06:37:19 +00001401 if [ ! -z "$VAL" -a $(grep -c "^export $O=" $NAME-env.sh) -eq 0 ]; then
1402 echo "export $O=\"$(eval echo \$$O)\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001403 fi
1404done
1405
David Bainbridge0774b232019-08-02 06:37:19 +00001406if [ $DEPLOY_K8S == "yes" -a $(grep -c "^export KUBECONFIG=" $NAME-env.sh) -eq 0 ]; then
1407 echo "export KUBECONFIG=\"$(./bin/kind get kubeconfig-path --name=voltha-$NAME)\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001408fi
1409
David Bainbridge0774b232019-08-02 06:37:19 +00001410if [ $(grep -c "^export VOLTCONFIG=" $NAME-env.sh) -eq 0 ]; then
1411 echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001412fi
1413
David Bainbridge0774b232019-08-02 06:37:19 +00001414if [ $(grep -c "^export PATH=" $NAME-env.sh) -eq 0 ]; then
1415 echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> $NAME-env.sh
David Bainbridgeb07fdf72019-07-29 22:51:40 +00001416fi
1417
Test User7d866122019-07-09 17:52:35 +00001418echo ""
Test User08ebbd92019-07-03 17:15:39 +00001419echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
1420echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
1421echo "tools required by VOLTHA in your command path. " | tee -a $LOG
1422echo "" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +00001423echo -en $BOLD
Test Userba1e7e72019-07-10 22:27:54 +00001424if [ $DEPLOY_K8S == "yes" ]; then
David Bainbridge0774b232019-08-02 06:37:19 +00001425 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +00001426fi
David Bainbridge0774b232019-08-02 06:37:19 +00001427echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +00001428echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +00001429echo -en $NORMAL
Test User08ebbd92019-07-03 17:15:39 +00001430echo "" | tee -a $LOG
1431echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
1432
David Bainbridge712afb82019-08-14 19:55:58 +00001433if [ "$WITH_TIMINGS" == "yes" ]; then
David Bainbridgef858a022019-08-14 21:25:11 +00001434 echo -e "$CLOCK ${BOLD}TOTAL: $(duration $(expr $(date +%s) - $TOTAL_START_TIME))${NORMAL}"
David Bainbridge712afb82019-08-14 19:55:58 +00001435fi