blob: 2880bb7ff24cc6eec11a08193ecde5b808773156 [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.
15
16# trap ctrl-c and call ctrl_c()
17trap ctrl_c INT
18
19function ctrl_c() {
20 tput cnorm
21 echo ""
22 echo "ctrl-c trapped"
23 echo "Thank you for trying 'votlha up'"
24 exit
25}
26
Test User08ebbd92019-07-03 17:15:39 +000027VOLTCTL_VERSION=${VOLTCTL_VERSION:-0.0.5-dev}
28KIND_VERSION=${KIND_VERSION:-v0.4.0}
29_VOLTCTL_VERSION=$(echo $VOLTCTL_VERSION | sed -e 's/-/_/g')
30
Test User7d866122019-07-09 17:52:35 +000031NOCOLOR="\u001b[0m"
32BLACK=$(tput setaf 0)
33RED=$(tput setaf 1)
34GREEN=$(tput setaf 2)
35YELLOW=$(tput setaf 3)
36BLUE=$(tput setaf 4)
37MAGENTA=$(tput setaf 5)
38CYAN=$(tput setaf 6)
39WHITE=$(tput setaf 7)
40BOLD=$(tput bold)
41NORMAL=$(tput sgr0)
42ERROR="\xe2\x9c\x97\x20"
43
Test User3d7ad8e2019-07-03 06:15:44 +000044TYPE=${TYPE:-minimal}
Test User7d866122019-07-09 17:52:35 +000045WITH_BBSIM=${WITH_BBSIM:-no}
Test Userba1e7e72019-07-10 22:27:54 +000046JUST_K8S=${JUST_K8S:-no}
47DEPLOY_K8S=${DEPLOY_K8S:-yes}
48
49HAVE_GO=$(which go >/dev/null 2>&1 && echo "yes" || echo "no")
50HOSTOS=$(uname -s | tr "[:upper:]" "[:lower:"])
51HOSTARCH=$(uname -m | tr "[:upper:]" "[:lower:"])
52if [ $HOSTARCH == "x86_64" ]; then
53 HOSTARCH="amd64"
54fi
Test User7d866122019-07-09 17:52:35 +000055
56# Verify TYPE setting
57if [ $(echo ":minimal:full:" | grep -ic ":$TYPE:") -eq 0 ]; then
58 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$TYPE value of '$TYPE'. Should be 'minimal' or 'full'${NOCOLOR}"
59 exit 1
60fi
61
62# Verify WITH_BBSIM settting and convert uniform value of yes or no
63if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_BBSIM:") -eq 0 ]; then
64 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_BBSIM value of '$WITH_BBSIM'. Should be 'yes' or 'no'${NOCOLOR}"
65 exit 1
66fi
67if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_BBSIM:") -eq 1 ]; then
68 WITH_BBSIM=yes
69else
70 WITH_BBSIM=no
71fi
72
Test Userba1e7e72019-07-10 22:27:54 +000073# Verify JUST_K8S settting and convert uniform value of yes or no
74if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$JUST_K8S:") -eq 0 ]; then
75 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$JUST_K8S value of '$JUST_K8S'. Should be 'yes' or 'no'${NOCOLOR}"
76 exit 1
77fi
78if [ $(echo ":y:yes:true:1:" | grep -ic ":$JUST_K8S:") -eq 1 ]; then
79 JUST_K8S=yes
80else
81 JUST_K8S=no
82fi
83
84# Verify DEPLOY_K8S settting and convert uniform value of yes or no
85if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$DEPLOY_K8S:") -eq 0 ]; then
86 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$DEPLOY_K8S value of '$DEPLOY_K8S'. Should be 'yes' or 'no'${NOCOLOR}"
87 exit 1
88fi
89if [ $(echo ":y:yes:true:1:" | grep -ic ":$DEPLOY_K8S:") -eq 1 ]; then
90 DEPLOY_K8S=yes
91else
92 DEPLOY_K8S=no
93fi
Test User01ed0642019-07-03 20:17:06 +000094
95if [ "$TYPE" == "full" ]; then
96 ONOS_API_PORT=${ONOS_API_PORT:-8182}
97 ONOS_SSH_PORT=${ONOS_SSH_PORT:-8102}
98 VOLTHA_API_PORT=${VOLTHA_API_PORT:-55556}
99 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-5023}
100else
101 ONOS_API_PORT=${ONOS_API_PORT:-8181}
102 ONOS_SSH_PORT=${ONOS_SSH_PORT:-8101}
103 VOLTHA_API_PORT=${VOLTHA_API_PORT:-55555}
104 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-5022}
105fi
106
107if [ "$1" == "get" -a "$2" == "voltconfig" ]; then
108 echo "$HOME/.volt/config-$TYPE"
109 exit
110fi
Test User3d7ad8e2019-07-03 06:15:44 +0000111
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700112if [ $# -ne 1 -o $(echo ":up:down:" | grep -c ":$1:") -ne 1 ]; then
113 >&2 echo "up or down?"
114 exit 1
115fi
116
117if [ "$1" == "down" ]; then
Test Userba1e7e72019-07-10 22:27:54 +0000118 if [ $DEPLOY_K8S == "yes" ]; then
119 if [ -x ./bin/kind ]; then
120 exec ./bin/kind delete cluster --name voltha-$TYPE
121 else
122 >&2 echo "Kind doesn't seem to be installed, so nothing to do. Bye."
123 fi
Test User08ebbd92019-07-03 17:15:39 +0000124 else
Test Userba1e7e72019-07-10 22:27:54 +0000125 EXISTS=$(helm list -q)
126 EXPECT="etcd-operator onos open-olt open-onu sim voltha"
127 INTERSECT=
128 for i in $EXISTS; do
129 if [ $(echo $EXPECT | grep -c $i) -eq 1 ]; then
130 HAVE="$HAVE $i"
131 fi
132 done
133 ./bin/helm delete --purge $HAVE
134fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700135 exit
136fi
137
Test User01ed0642019-07-03 20:17:06 +0000138LOG="install-$TYPE.log"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700139date > $LOG
140
141spin() {
Test Userd87942b2019-07-03 07:20:24 +0000142 PARTS="\
143 \xe2\xa2\x8e\xe2\xa1\xb0 \
144 \xe2\xa2\x8e\xe2\xa1\xa1 \
145 \xe2\xa2\x8e\xe2\xa1\x91 \
146 \xe2\xa2\x8e\xe2\xa0\xb1 \
147 \xe2\xa0\x8e\xe2\xa1\xb1 \
148 \xe2\xa2\x8a\xe2\xa1\xb1 \
149 \xe2\xa2\x8c\xe2\xa1\xb1 \
150 \xe2\xa2\x86\xe2\xa1\xb1 \
151 "
152 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700153 tput civis
154 while true; do
Test Userd87942b2019-07-03 07:20:24 +0000155 C=$(echo $PARTS | cut '-d ' -f $IDX)
156 echo -en "$C"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700157 IDX=$(expr $IDX + 1)
Test Userd87942b2019-07-03 07:20:24 +0000158 if [ $IDX -gt 8 ]; then
159 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700160 fi
161 sleep .15
162 echo -en "\r"
163 done
164}
165
Test Userd87942b2019-07-03 07:20:24 +0000166SPIN_PARTS="\
167 \xe2\xa2\x8e\xe2\xa1\xb0 \
168 \xe2\xa2\x8e\xe2\xa1\xa1 \
169 \xe2\xa2\x8e\xe2\xa1\x91 \
170 \xe2\xa2\x8e\xe2\xa0\xb1 \
171 \xe2\xa0\x8e\xe2\xa1\xb1 \
172 \xe2\xa2\x8a\xe2\xa1\xb1 \
173 \xe2\xa2\x8c\xe2\xa1\xb1 \
174 \xe2\xa2\x86\xe2\xa1\xb1 \
175 "
176IDX=1
177NOT_VERIFIED="\xe2\x9c\x97\x20"
178VERIFIED="\xe2\x9c\x93\x20"
Test Userb5712372019-07-03 21:52:17 +0000179HELM="\xE2\x8E\x88"
180OLD_KEY="\xF0\x9F\x97\x9D"
181BIRD="\xF0\x9F\x90\xA6"
182HIGH_VOLTAGE="\xE2\x9A\xA1"
183PLUG="\xF0\x9F\xa7\xa9"
184RESTART="\xf0\x9f\x94\x84"
185FORWARD="\xE2\x87\xA8"
186INSTALL="\xF0\x9F\x8F\x97"
187STOP="\xf0\x9f\x9b\x91"
188GO="\xf0\x9f\x9a\x80"
189DOWNLOAD="\xf0\x9f\x93\xa5"
190GEAR="\xe2\x9a\x99"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700191bspin() {
192 tput civis
Test Userd87942b2019-07-03 07:20:24 +0000193 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700194 local INDENT=
195 if [ "$1" == "-" ]; then
196 INDENT=" "
197 shift
198 fi
Test Userd87942b2019-07-03 07:20:24 +0000199 echo -en "$INDENT $*"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700200}
201
202sspin() {
203 local INDENT=
204 if [ "$1" == "-" ]; then
205 INDENT=" "
206 shift
207 fi
Test Userd87942b2019-07-03 07:20:24 +0000208 C=$(echo $SPIN_PARTS | cut '-d ' -f $IDX)
209 echo -en "\r$INDENT$C $*"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700210 IDX=$(expr $IDX + 1)
Test Userd87942b2019-07-03 07:20:24 +0000211 if [ $IDX -gt 8 ]; then
212 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700213 fi
214}
215
216espin() {
217 local INDENT=
218 if [ "$1" == "-" ]; then
219 INDENT=" "
220 shift
221 fi
222 echo -e "\r$INDENT$*"
223 tput cnorm
224}
225
226count_pods() {
227 local NAMESPACE=$1; shift
228 local PODS=$(kubectl -n $NAMESPACE get pod -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}")
229 local COUNT=0
230 local PATTERNS=$*
231 for POD in $PODS; do
232 local NAME=$(echo $POD | cut -d/ -f 1)
233 local STATE=$(echo $POD | cut -d/ -f 2)
234 local CONTAINERS=$(echo $POD | cut -d/ -f 3 | sed -e 's/_/ /g')
235 if [ "$STATE" == "Running" ]; then
236 local TOTAL=$(echo $CONTAINERS | wc -w)
237 local FOUND=$(echo $CONTAINERS | grep -o true | wc -l)
238 if [ $TOTAL -eq $FOUND ]; then
239 for PATTERN in $PATTERNS; do
240 if [[ $NAME =~ $PATTERN ]]; then
241 COUNT=$(expr $COUNT + 1)
242 fi
243 done
244 fi
245 fi
246 done
247 echo $COUNT
248}
249
250wait_for_pods() {
251 local INDENT=
252 if [ "$1" == "-" ]; then
253 INDENT=$1; shift
254 fi
255 local NAMESPACE=$1; shift
256 local EXPECT=$1; shift
257 local RETRY=$1; shift
258 local MESSAGE=$1; shift
259 local PATTERNS=$*
260 local HAVE=$(count_pods $NAMESPACE $PATTERNS)
261 COUNT=$(expr 300 / 15)
262 bspin $INDENT $MESSAGE
263 sspin $INDENT
264 if [ $HAVE -ne $EXPECT ]; then
265 while [ $HAVE -ne $EXPECT ]; do
266 sspin $INDENT
267 COUNT=$(expr $COUNT - 1)
268 if [ $COUNT -eq 0 ]; then
269 HAVE=$(count_pods $NAMESPACE $PATTERNS)
270 COUNT=$(expr 300 / 15)
271 fi
272 sleep .15
273 done
274 fi
275 espin $INDENT $VERIFIED
276 if [ $HAVE -ne $EXPECT ]; then
277 return 1
278 fi
279 return 0
280}
281
282helm_install() {
283 local INDENT=
284 if [ "$1" == "-" ]; then
285 INDENT=$1; shift
286 fi
287 local NAMESPACE=$1; shift
288 local NAME=$1; shift
289 local CHART=$1; shift
290 local MESSAGE=$*
291
292 COUNT=$(expr 300 / 15)
293 bspin $INDENT $MESSAGE
294 (set -x; helm install -f $TYPE-values.yaml --namespace $NAMESPACE --name $NAME $CHART >>$LOG 2>&1) >>$LOG 2>&1
295 SUCCESS=$?
296 while [ $SUCCESS -ne 0 ]; do
297 sspin $INDENT
298 COUNT=$(expr $COUNT - 1)
299 if [ $COUNT -eq 0 ]; then
300 (set -x; helm install -f $TYPE-values.yaml --namespace $NAMESPACE --name $NAME $CHART >>$LOG 2>&1) >>$LOG 2>&1
301 COUNT=$(expr 300 / 15)
302 fi
303 sleep .15
304 done
305 espin $INDENT $VERIFIED
306}
307
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700308echo "INSTALL TYPE: $TYPE" >> $LOG
309
310bspin "Verify GOPATH"
311export GOPATH=$(pwd)
Test User3d7ad8e2019-07-03 06:15:44 +0000312mkdir -p $GOPATH/bin
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700313espin $VERIFIED
314
Test Userb5712372019-07-03 21:52:17 +0000315bspin "Verify kubectl $HELM"
Test Userc13bdc92019-07-03 20:57:49 +0000316if [ -x $GOPATH/bin/kubectl ]; then
317 espin $VERIFIED
318else
319 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000320 bspin - "Download and install Kubernetes/kubectl $DOWNLOAD"
Test Userba1e7e72019-07-10 22:27:54 +0000321 (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
Test Userc13bdc92019-07-03 20:57:49 +0000322 (set -x; chmod 755 $GOPATH/bin/kubectl >>$LOG 2>&1) >>$LOG 2>&1
323 espin - $VERIFIED
324fi
325
Test Userba1e7e72019-07-10 22:27:54 +0000326if [ "$DEPLOY_K8S" == "yes" ]; then
327 bspin "Verify Kubernetes/Kind $HELM"
328 if [ -x $GOPATH/bin/kind ]; then
329 espin $VERIFIED
330 else
331 espin $NOT_VERIFIED
332 bspin - "Download and install Kubernetes/kind $DOWNLOAD"
David Bainbridge9e2a6662019-07-11 17:07:57 +0000333 (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 +0000334 (set -x; chmod 755 $GOPATH/bin/kind >>$LOG 2>&1) >>$LOG 2>&1
335 espin - $VERIFIED
336 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700337fi
338
Test Userb5712372019-07-03 21:52:17 +0000339bspin "Verify Helm $HELM"
Test User3d7ad8e2019-07-03 06:15:44 +0000340if [ -x $GOPATH/bin/helm ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700341 espin $VERIFIED
342else
343 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000344 bspin - "Download and install Helm $DOWNLOAD"
Test Userba1e7e72019-07-10 22:27:54 +0000345 (set -x; curl -sSL https://git.io/get_helm.sh | USE_SUDO=false HELM_INSTALL_DIR=$GOPATH/bin bash >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700346 espin - $VERIFIED
347fi
348
Test Userb5712372019-07-03 21:52:17 +0000349bspin "Verify voltctl $HIGH_VOLTAGE"
Test User3d7ad8e2019-07-03 06:15:44 +0000350if [ -x $GOPATH/bin/voltctl ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700351 espin $VERIFIED
352else
353 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000354 bspin - "Download and build voltctl $DOWNLOAD"
Test Userba1e7e72019-07-10 22:27:54 +0000355 (set -x; curl -o $GOPATH/bin/voltctl -sSL https://github.com/ciena/voltctl/releases/download/$VOLTCTL_VERSION/voltctl-$_VOLTCTL_VERSION-$HOSTOS-$HOSTARCH >>$LOG 2>&1) >>$LOG 2>&1
Test User08ebbd92019-07-03 17:15:39 +0000356 (set -x; chmod 755 $GOPATH/bin/voltctl >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700357 espin - $VERIFIED
358fi
359
360bspin "Verify command PATH"
Test Userba1e7e72019-07-10 22:27:54 +0000361export PATH=$GOPATH/bin:$PATH
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700362espin $VERIFIED
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700363
Test Userba1e7e72019-07-10 22:27:54 +0000364if [ "$DEPLOY_K8S" == "yes" ]; then
365 HAVE=$(kind get clusters | grep -c voltha-$TYPE)
366 bspin "Verify Kubernetes/Kind Cluster"
367 sspin
368 if [ $HAVE -eq 0 ]; then
David Bainbridge491b1bd2019-07-11 17:53:11 +0000369 espin $NOT_VERIFIED
370 bspin - "Verify cluster configuration"
371 if [ ! -r ./$TYPE-cluster.cfg ]; then
372 espin - $NOT_VERIFIED
373 bspin - "Download cluster configuration: $TYPE-cluster.cfg $DOWNLOAD"
374 (set -x; curl -o ./$TYPE-cluster.cfg -sSL https://raw.githubusercontent.com/ciena/kind-voltha/master/$TYPE-cluster.cfg >>$LOG 2>&1) >>$LOG 2>&1
375 espin - $VERIFIED
376 else
377 espin - $VERFIED
378 fi
379 kind create cluster --name voltha-$TYPE --config $TYPE-cluster.cfg
380 else
381 espin $VERIFIED
Test Userba1e7e72019-07-10 22:27:54 +0000382 fi
383
384 export KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$TYPE")"
385 P="coredns-.* \
386 etcd-voltha-$TYPE-control-plane \
387 kindnet-.* \
388 kube-apiserver-voltha-$TYPE-control-plane \
389 kube-controller-manager-voltha-$TYPE-control-plane \
390 kube-proxy-.* \
391 kube-scheduler-voltha-$TYPE-control-plane"
392
393 EXPECT=$(test "$TYPE" == "minimal" && echo "12" || echo "14")
394 wait_for_pods - "kube-system" $EXPECT -1 "Waiting for system PODs to start" $P
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700395fi
396
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700397COUNT=$(count_pods "kube-system" "tiller-deploy-.*")
398bspin "Verify Helm"
Test Userba1e7e72019-07-10 22:27:54 +0000399if [ $COUNT -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700400 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000401 echo -e "Configuring Helm $GEAR"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700402 bspin - "Initialize Helm"
403 (set -x; helm init --upgrade >>$LOG 2>&1) >>$LOG 2>&1
404 espin - $VERIFIED
David Bainbridge491b1bd2019-07-11 17:53:11 +0000405 wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
Test Userb5712372019-07-03 21:52:17 +0000406 bspin - "Add Google Incubator repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700407 (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
408 espin - $VERIFIED
Test Userba1e7e72019-07-10 22:27:54 +0000409
410 # HACK (sort-of) - the config for tiller is about to be patched, which will
411 # cause the tiller pod to be recreated. This can sometimes cause a timing
412 # issue with the "wait_for_pods" call on tiller as it may incorrectly
413 # identify the running/ready tiller pod that is soon to be terminated as
414 # what it is waiting for. To avoid this issue we do a clean scale down and
415 # scale up of the pod so the script controlls when it should be expecting
416 # things
417 (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 -0700418
Test Userb5712372019-07-03 21:52:17 +0000419 bspin - "Add Google Stable repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700420 (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
421 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000422 bspin - "Add ONF repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700423 (set -x; helm repo add onf https://charts.opencord.org >>$LOG 2>&1) >>$LOG 2>&1
424 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000425 bspin - "Update Helm repository cache"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700426 (set -x; helm repo update >>$LOG 2>&1) >>$LOG 2>&1
427 espin - $VERIFIED
428
429 # Create and k8s service account so that Helm can create pods
Test Userb5712372019-07-03 21:52:17 +0000430 bspin - "Create Tiller ServiceAccount"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700431 (set -x; kubectl create serviceaccount --namespace kube-system tiller >>$LOG 2>&1) >>$LOG 2>&1
432 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000433 bspin - "Create Tiller ClusterRoleBinding"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700434 (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>$LOG 2>&1) >>$LOG 2>&1
435 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000436 bspin - "Update Tiller Manifest"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700437 (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 +0000438
439 # HACK (sort-of) - part to, spin it back up
440 (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 -0700441 espin - $VERIFIED
442else
443 espin $VERIFIED
444fi
Test Userb5712372019-07-03 21:52:17 +0000445wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700446
Test Userba1e7e72019-07-10 22:27:54 +0000447bspin "Verify Helm values file: $TYPE-values.yaml"
448if [ ! -r "./$TYPE-values.yaml" ]; then
449 espin $NOT_VERIFIED
450 bspin - "Download Helm values file: $TYPE-values.yaml $DOWNLOAD"
451 (set -x; curl -o ./$TYPE-values.yaml -sSL https://raw.githubusercontent.com/ciena/kind-voltha/master/$TYPE-values.yaml >>$LOG 2>&1) >>$LOG 2>&1
452 espin - $VERIFIED
453else
454 espin $VERIFIED
455fi
456
457if [ "$JUST_K8S" == "yes" ]; then
458 echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye."
459 echo ""
460 echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
461 echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
462 echo "tools required by VOLTHA in your command path. " | tee -a $LOG
463 echo "" | tee -a $LOG
464 echo -en $BOLD
465 if [ $DEPLOY_K8S == "yes" ]; then
466 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$TYPE\")\"" | tee -a $LOG
467 fi
468 echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
469 echo -en $NORMAL
470 echo "" | tee -a $LOG
471 echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
472 exit 0
473fi
474
Test Userb5712372019-07-03 21:52:17 +0000475bspin "Verify ETCD Operator $OLD_KEY"
Test User7d866122019-07-09 17:52:35 +0000476if [ $(helm list --deployed --short --namespace voltha "^etcd-operator\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700477 espin $NOT_VERIFIED
478 helm_install - voltha etcd-operator stable/etcd-operator "Install ETCD Operator"
479else
480 espin $VERIFIED
481fi
Test User01ed0642019-07-03 20:17:06 +0000482EXPECT=$(test "$TYPE" == "minimal" && echo "1" || echo "3")
Test Userb5712372019-07-03 21:52:17 +0000483wait_for_pods - "voltha" $EXPECT -1 "Waiting for ETCD Operator to start" "etcd-operator-.*"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700484
Test Userb5712372019-07-03 21:52:17 +0000485bspin "Verify ONOS installed $BIRD"
Test User7d866122019-07-09 17:52:35 +0000486if [ $(helm list --deployed --short --namespace default "^onos\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700487 espin $NOT_VERIFIED
488 helm_install - default onos onf/onos "Install ONOS"
489else
490 espin $VERIFIED
491fi
Test Userb5712372019-07-03 21:52:17 +0000492wait_for_pods - "default" 1 -1 "Waiting for ONOS to start" "onos-.*"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700493
Test Userb5712372019-07-03 21:52:17 +0000494bspin - "Forward ONOS API port $FORWARD"
Test User01ed0642019-07-03 20:17:06 +0000495(set -x; screen -p 0 -X -S onos-ui-$TYPE stuff $'\003' >>$LOG 2>&1) >>$LOG 2>&1
496(set -x; screen -dmS onos-ui-$TYPE kubectl port-forward service/onos-ui $ONOS_API_PORT:8181 >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700497espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000498bspin - "Forward ONOS SSH port $FORWARD"
Test User01ed0642019-07-03 20:17:06 +0000499(set -x; screen -p 0 -X -S onos-ssh-$TYPE stuff $'\003' >>$LOG 2>&1) >>$LOG 2>&1
500(set -x; screen -dmS onos-ssh-$TYPE kubectl port-forward service/onos-ssh $ONOS_SSH_PORT:8101 >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700501espin - $VERIFIED
Test Userba1e7e72019-07-10 22:27:54 +0000502if [ ! -x ./onos-files/install-onos-applications.sh ]; then
503 bspin - "Verify or download ONOS configuration support files $DOWNLOAD"
504 (set -x; mkdir -p ./onos-files >>$LOG 2>&1) >>$LOG 2>&1
505 for i in dhcp-to-controller-flow.json install-onos-applications.sh olt-onos-enableExtraneousRules.json olt-onos-netcfg.json olt-onos-olt-settings.json; do
506 if [ ! -r ./onos-files/$i ]; then
507 (set -x; curl -o ./onos-files/$i -sSL https://raw.githubusercontent.com/ciena/kind-voltha/master/onos-files/$i >>$LOG 2>&1) >>$LOG 2>&1
508 fi
509 done
510 (set -x; chmod 755 ./onos-files/install-onos-applications.sh >>$LOG 2>&1) >>$LOG 2>&1
511 espin - $VERIFIED
512fi
513
Test Userb5712372019-07-03 21:52:17 +0000514bspin - "Install required ONOS applications $INSTALL"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700515(set -x; ./onos-files/install-onos-applications.sh >>$LOG 2>&1) >>$LOG 2>&1
516espin - $VERIFIED
517
Test Userb5712372019-07-03 21:52:17 +0000518bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
Test User7d866122019-07-09 17:52:35 +0000519if [ $(helm list --deployed --short --namespace voltha "^voltha\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700520 espin $NOT_VERIFIED
Test Userd87942b2019-07-03 07:20:24 +0000521 helm_install - voltha voltha onf/voltha "Install VOLTHA Core"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700522else
523 espin $VERIFIED
524fi
Test Userba1e7e72019-07-10 22:27:54 +0000525
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700526VOLTHA="ofagent-.* \
527 ro-core.* \
528 rw-core.* \
529 voltha-api-server-.* \
530 voltha-cli-server-.* \
531 voltha-etcd-cluster-.* \
532 voltha-kafka-.* \
533 voltha-zookeeper-.*"
Test User01ed0642019-07-03 20:17:06 +0000534EXPECT=$(test "$TYPE" == "minimal" && echo "9" || echo "11")
Test Userb5712372019-07-03 21:52:17 +0000535wait_for_pods - "voltha" $EXPECT -1 "Waiting for VOLTHA Core to start" $VOLTHA
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700536
Test Userb5712372019-07-03 21:52:17 +0000537echo -e "Verify Adapters $PLUG"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700538bspin - "Verify Simulated Adapters installed"
Test User7d866122019-07-09 17:52:35 +0000539if [ $(helm list --deployed --short --namespace voltha "^sim\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700540 espin - $NOT_VERIFIED
541 helm_install - voltha sim onf/voltha-adapter-simulated "Install Simulated Adapters"
542else
543 espin - $VERIFIED
544fi
545
546bspin - "Verify OpenOLT Adapter installed"
Test User7d866122019-07-09 17:52:35 +0000547if [ $(helm list --deployed --short --namespace voltha "^open-olt\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700548 espin - $NOT_VERIFIED
549 helm_install - voltha open-olt onf/voltha-adapter-openolt "Install OpenOLT Adapter"
550else
551 espin - $VERIFIED
552fi
553bspin - "Verify OpenONU Adapter installed"
Test User7d866122019-07-09 17:52:35 +0000554if [ $(helm list --deployed --short --namespace voltha "^open-onu\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700555 espin - $NOT_VERIFIED
556 helm_install - voltha open-onu onf/voltha-adapter-openonu "Install OpenONU Adapter"
557else
558 espin - $VERIFIED
559fi
560
561ADAPTERS="adapter-.*"
Test Userb5712372019-07-03 21:52:17 +0000562wait_for_pods - "voltha" 4 -1 "Waiting for adapters to start" $ADAPTERS
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700563
Test User7d866122019-07-09 17:52:35 +0000564if [ $WITH_BBSIM == "yes" ]; then
565 echo -e "Verify BBSIM $PLUG"
566 bspin - "Verify BBSIM Insalled"
567 if [ $(helm list --deployed --short --namespace voltha "^bbsim\$" | wc -l) -ne 1 ]; then
568 espin - $NOT_VERIFIED
569 helm_install - voltha bbsim onf/bbsim "Install BBSIM"
570 else
571 espin - $VERIFIED
572 fi
573 wait_for_pods - "voltha" 1 -1 "Waiting for BBSIM to start" "bbsim-.*"
574fi
575
Test Userb5712372019-07-03 21:52:17 +0000576echo -e "Restart VOLTHA API $RESTART"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700577API="voltha-api-server-.* ofagent-.*"
578(set -x; kubectl scale --replicas=0 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1
Test Userb5712372019-07-03 21:52:17 +0000579wait_for_pods - "voltha" 0 -1 "Wait for API to stop $STOP" $API
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700580(set -x; kubectl scale --replicas=1 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1
Test Userb5712372019-07-03 21:52:17 +0000581wait_for_pods - "voltha" 2 -1 "Wait for API to re-start $GO" $API
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700582
Test Userb5712372019-07-03 21:52:17 +0000583bspin - "Forward VOLTHA API port $FORWARD"
Test User01ed0642019-07-03 20:17:06 +0000584(set -x; screen -p 0 -X -S voltha-api-$TYPE stuff $'\003' >>$LOG 2>&1) >>$LOG 2>&1
585(set -x; screen -dmS voltha-api-$TYPE kubectl port-forward -n voltha service/voltha-api $VOLTHA_API_PORT:55555 >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700586espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000587bspin - "Forward VOLTHA SSH port $FORWARD"
Test User01ed0642019-07-03 20:17:06 +0000588(set -x; screen -p 0 -X -S voltha-ssh-$TYPE stuff $'\003' 2>/dev/null >/dev/null >>$LOG 2>&1) >>$LOG 2>&1
589(set -x; screen -dmS voltha-ssh-$TYPE kubectl port-forward -n voltha service/voltha-cli $VOLTHA_SSH_PORT:5022 >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700590espin - $VERIFIED
Test User3d7ad8e2019-07-03 06:15:44 +0000591
592bspin - "Create voltctl configuration file"
593(set -x; mkdir -p $HOME/.volt >>$LOG 2>&1) >>$LOG 2>&1
Test User01ed0642019-07-03 20:17:06 +0000594(set -x; voltctl -a v2 -s localhost:$VOLTHA_API_PORT config > $HOME/.volt/config-$TYPE 2>>$LOG) >>$LOG 2>&1
Test User3d7ad8e2019-07-03 06:15:44 +0000595espin - $VERIFIED
Test User08ebbd92019-07-03 17:15:39 +0000596
Test User7d866122019-07-09 17:52:35 +0000597echo ""
Test User08ebbd92019-07-03 17:15:39 +0000598echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
599echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
600echo "tools required by VOLTHA in your command path. " | tee -a $LOG
601echo "" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +0000602echo -en $BOLD
Test Userba1e7e72019-07-10 22:27:54 +0000603if [ $DEPLOY_K8S == "yes" ]; then
604 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$TYPE\")\"" | tee -a $LOG
605fi
Test Userfa30f7f2019-07-03 20:35:19 +0000606echo "export VOLTCONFIG=\"$HOME/.volt/config-$TYPE\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +0000607echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +0000608echo -en $NORMAL
Test User08ebbd92019-07-03 17:15:39 +0000609echo "" | tee -a $LOG
610echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
611