blob: 3a8178bb97a66b70ff88f45d9ca0c01ca109454d [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"
333 (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
334 (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
369 espin $NOT_VERIFIED
370 kind create cluster --name voltha-$TYPE --config $TYPE-cluster.cfg
371 else
372 espin $VERIFIED
373 fi
374
375 export KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$TYPE")"
376 P="coredns-.* \
377 etcd-voltha-$TYPE-control-plane \
378 kindnet-.* \
379 kube-apiserver-voltha-$TYPE-control-plane \
380 kube-controller-manager-voltha-$TYPE-control-plane \
381 kube-proxy-.* \
382 kube-scheduler-voltha-$TYPE-control-plane"
383
384 EXPECT=$(test "$TYPE" == "minimal" && echo "12" || echo "14")
385 wait_for_pods - "kube-system" $EXPECT -1 "Waiting for system PODs to start" $P
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700386fi
387
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700388COUNT=$(count_pods "kube-system" "tiller-deploy-.*")
389bspin "Verify Helm"
Test Userba1e7e72019-07-10 22:27:54 +0000390if [ $COUNT -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700391 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000392 echo -e "Configuring Helm $GEAR"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700393 bspin - "Initialize Helm"
394 (set -x; helm init --upgrade >>$LOG 2>&1) >>$LOG 2>&1
395 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000396 bspin - "Add Google Incubator repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700397 (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
398 espin - $VERIFIED
Test Userba1e7e72019-07-10 22:27:54 +0000399
400 # HACK (sort-of) - the config for tiller is about to be patched, which will
401 # cause the tiller pod to be recreated. This can sometimes cause a timing
402 # issue with the "wait_for_pods" call on tiller as it may incorrectly
403 # identify the running/ready tiller pod that is soon to be terminated as
404 # what it is waiting for. To avoid this issue we do a clean scale down and
405 # scale up of the pod so the script controlls when it should be expecting
406 # things
407 (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 -0700408
Test Userb5712372019-07-03 21:52:17 +0000409 bspin - "Add Google Stable repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700410 (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
411 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000412 bspin - "Add ONF repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700413 (set -x; helm repo add onf https://charts.opencord.org >>$LOG 2>&1) >>$LOG 2>&1
414 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000415 bspin - "Update Helm repository cache"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700416 (set -x; helm repo update >>$LOG 2>&1) >>$LOG 2>&1
417 espin - $VERIFIED
418
419 # Create and k8s service account so that Helm can create pods
Test Userb5712372019-07-03 21:52:17 +0000420 bspin - "Create Tiller ServiceAccount"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700421 (set -x; kubectl create serviceaccount --namespace kube-system tiller >>$LOG 2>&1) >>$LOG 2>&1
422 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000423 bspin - "Create Tiller ClusterRoleBinding"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700424 (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>$LOG 2>&1) >>$LOG 2>&1
425 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000426 bspin - "Update Tiller Manifest"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700427 (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 +0000428
429 # HACK (sort-of) - part to, spin it back up
430 (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 -0700431 espin - $VERIFIED
432else
433 espin $VERIFIED
434fi
Test Userb5712372019-07-03 21:52:17 +0000435wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700436
Test Userba1e7e72019-07-10 22:27:54 +0000437bspin "Verify Helm values file: $TYPE-values.yaml"
438if [ ! -r "./$TYPE-values.yaml" ]; then
439 espin $NOT_VERIFIED
440 bspin - "Download Helm values file: $TYPE-values.yaml $DOWNLOAD"
441 (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
442 espin - $VERIFIED
443else
444 espin $VERIFIED
445fi
446
447if [ "$JUST_K8S" == "yes" ]; then
448 echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye."
449 echo ""
450 echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
451 echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
452 echo "tools required by VOLTHA in your command path. " | tee -a $LOG
453 echo "" | tee -a $LOG
454 echo -en $BOLD
455 if [ $DEPLOY_K8S == "yes" ]; then
456 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$TYPE\")\"" | tee -a $LOG
457 fi
458 echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
459 echo -en $NORMAL
460 echo "" | tee -a $LOG
461 echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
462 exit 0
463fi
464
Test Userb5712372019-07-03 21:52:17 +0000465bspin "Verify ETCD Operator $OLD_KEY"
Test User7d866122019-07-09 17:52:35 +0000466if [ $(helm list --deployed --short --namespace voltha "^etcd-operator\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700467 espin $NOT_VERIFIED
468 helm_install - voltha etcd-operator stable/etcd-operator "Install ETCD Operator"
469else
470 espin $VERIFIED
471fi
Test User01ed0642019-07-03 20:17:06 +0000472EXPECT=$(test "$TYPE" == "minimal" && echo "1" || echo "3")
Test Userb5712372019-07-03 21:52:17 +0000473wait_for_pods - "voltha" $EXPECT -1 "Waiting for ETCD Operator to start" "etcd-operator-.*"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700474
Test Userb5712372019-07-03 21:52:17 +0000475bspin "Verify ONOS installed $BIRD"
Test User7d866122019-07-09 17:52:35 +0000476if [ $(helm list --deployed --short --namespace default "^onos\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700477 espin $NOT_VERIFIED
478 helm_install - default onos onf/onos "Install ONOS"
479else
480 espin $VERIFIED
481fi
Test Userb5712372019-07-03 21:52:17 +0000482wait_for_pods - "default" 1 -1 "Waiting for ONOS to start" "onos-.*"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700483
Test Userb5712372019-07-03 21:52:17 +0000484bspin - "Forward ONOS API port $FORWARD"
Test User01ed0642019-07-03 20:17:06 +0000485(set -x; screen -p 0 -X -S onos-ui-$TYPE stuff $'\003' >>$LOG 2>&1) >>$LOG 2>&1
486(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 -0700487espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000488bspin - "Forward ONOS SSH port $FORWARD"
Test User01ed0642019-07-03 20:17:06 +0000489(set -x; screen -p 0 -X -S onos-ssh-$TYPE stuff $'\003' >>$LOG 2>&1) >>$LOG 2>&1
490(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 -0700491espin - $VERIFIED
Test Userba1e7e72019-07-10 22:27:54 +0000492if [ ! -x ./onos-files/install-onos-applications.sh ]; then
493 bspin - "Verify or download ONOS configuration support files $DOWNLOAD"
494 (set -x; mkdir -p ./onos-files >>$LOG 2>&1) >>$LOG 2>&1
495 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
496 if [ ! -r ./onos-files/$i ]; then
497 (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
498 fi
499 done
500 (set -x; chmod 755 ./onos-files/install-onos-applications.sh >>$LOG 2>&1) >>$LOG 2>&1
501 espin - $VERIFIED
502fi
503
Test Userb5712372019-07-03 21:52:17 +0000504bspin - "Install required ONOS applications $INSTALL"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700505(set -x; ./onos-files/install-onos-applications.sh >>$LOG 2>&1) >>$LOG 2>&1
506espin - $VERIFIED
507
Test Userb5712372019-07-03 21:52:17 +0000508bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
Test User7d866122019-07-09 17:52:35 +0000509if [ $(helm list --deployed --short --namespace voltha "^voltha\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700510 espin $NOT_VERIFIED
Test Userd87942b2019-07-03 07:20:24 +0000511 helm_install - voltha voltha onf/voltha "Install VOLTHA Core"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700512else
513 espin $VERIFIED
514fi
Test Userba1e7e72019-07-10 22:27:54 +0000515
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700516VOLTHA="ofagent-.* \
517 ro-core.* \
518 rw-core.* \
519 voltha-api-server-.* \
520 voltha-cli-server-.* \
521 voltha-etcd-cluster-.* \
522 voltha-kafka-.* \
523 voltha-zookeeper-.*"
Test User01ed0642019-07-03 20:17:06 +0000524EXPECT=$(test "$TYPE" == "minimal" && echo "9" || echo "11")
Test Userb5712372019-07-03 21:52:17 +0000525wait_for_pods - "voltha" $EXPECT -1 "Waiting for VOLTHA Core to start" $VOLTHA
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700526
Test Userb5712372019-07-03 21:52:17 +0000527echo -e "Verify Adapters $PLUG"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700528bspin - "Verify Simulated Adapters installed"
Test User7d866122019-07-09 17:52:35 +0000529if [ $(helm list --deployed --short --namespace voltha "^sim\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700530 espin - $NOT_VERIFIED
531 helm_install - voltha sim onf/voltha-adapter-simulated "Install Simulated Adapters"
532else
533 espin - $VERIFIED
534fi
535
536bspin - "Verify OpenOLT Adapter installed"
Test User7d866122019-07-09 17:52:35 +0000537if [ $(helm list --deployed --short --namespace voltha "^open-olt\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700538 espin - $NOT_VERIFIED
539 helm_install - voltha open-olt onf/voltha-adapter-openolt "Install OpenOLT Adapter"
540else
541 espin - $VERIFIED
542fi
543bspin - "Verify OpenONU Adapter installed"
Test User7d866122019-07-09 17:52:35 +0000544if [ $(helm list --deployed --short --namespace voltha "^open-onu\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700545 espin - $NOT_VERIFIED
546 helm_install - voltha open-onu onf/voltha-adapter-openonu "Install OpenONU Adapter"
547else
548 espin - $VERIFIED
549fi
550
551ADAPTERS="adapter-.*"
Test Userb5712372019-07-03 21:52:17 +0000552wait_for_pods - "voltha" 4 -1 "Waiting for adapters to start" $ADAPTERS
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700553
Test User7d866122019-07-09 17:52:35 +0000554if [ $WITH_BBSIM == "yes" ]; then
555 echo -e "Verify BBSIM $PLUG"
556 bspin - "Verify BBSIM Insalled"
557 if [ $(helm list --deployed --short --namespace voltha "^bbsim\$" | wc -l) -ne 1 ]; then
558 espin - $NOT_VERIFIED
559 helm_install - voltha bbsim onf/bbsim "Install BBSIM"
560 else
561 espin - $VERIFIED
562 fi
563 wait_for_pods - "voltha" 1 -1 "Waiting for BBSIM to start" "bbsim-.*"
564fi
565
Test Userb5712372019-07-03 21:52:17 +0000566echo -e "Restart VOLTHA API $RESTART"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700567API="voltha-api-server-.* ofagent-.*"
568(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 +0000569wait_for_pods - "voltha" 0 -1 "Wait for API to stop $STOP" $API
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700570(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 +0000571wait_for_pods - "voltha" 2 -1 "Wait for API to re-start $GO" $API
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700572
Test Userb5712372019-07-03 21:52:17 +0000573bspin - "Forward VOLTHA API port $FORWARD"
Test User01ed0642019-07-03 20:17:06 +0000574(set -x; screen -p 0 -X -S voltha-api-$TYPE stuff $'\003' >>$LOG 2>&1) >>$LOG 2>&1
575(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 -0700576espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000577bspin - "Forward VOLTHA SSH port $FORWARD"
Test User01ed0642019-07-03 20:17:06 +0000578(set -x; screen -p 0 -X -S voltha-ssh-$TYPE stuff $'\003' 2>/dev/null >/dev/null >>$LOG 2>&1) >>$LOG 2>&1
579(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 -0700580espin - $VERIFIED
Test User3d7ad8e2019-07-03 06:15:44 +0000581
582bspin - "Create voltctl configuration file"
583(set -x; mkdir -p $HOME/.volt >>$LOG 2>&1) >>$LOG 2>&1
Test User01ed0642019-07-03 20:17:06 +0000584(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 +0000585espin - $VERIFIED
Test User08ebbd92019-07-03 17:15:39 +0000586
Test User7d866122019-07-09 17:52:35 +0000587echo ""
Test User08ebbd92019-07-03 17:15:39 +0000588echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
589echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
590echo "tools required by VOLTHA in your command path. " | tee -a $LOG
591echo "" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +0000592echo -en $BOLD
Test Userba1e7e72019-07-10 22:27:54 +0000593if [ $DEPLOY_K8S == "yes" ]; then
594 echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$TYPE\")\"" | tee -a $LOG
595fi
Test Userfa30f7f2019-07-03 20:35:19 +0000596echo "export VOLTCONFIG=\"$HOME/.volt/config-$TYPE\"" | tee -a $LOG
Test Userba1e7e72019-07-10 22:27:54 +0000597echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +0000598echo -en $NORMAL
Test User08ebbd92019-07-03 17:15:39 +0000599echo "" | tee -a $LOG
600echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
601