blob: 1ffb0b0aead5096781fbffe622f3f59245ed23d5 [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}
46
47# Verify TYPE setting
48if [ $(echo ":minimal:full:" | grep -ic ":$TYPE:") -eq 0 ]; then
49 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$TYPE value of '$TYPE'. Should be 'minimal' or 'full'${NOCOLOR}"
50 exit 1
51fi
52
53# Verify WITH_BBSIM settting and convert uniform value of yes or no
54if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_BBSIM:") -eq 0 ]; then
55 >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_BBSIM value of '$WITH_BBSIM'. Should be 'yes' or 'no'${NOCOLOR}"
56 exit 1
57fi
58if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_BBSIM:") -eq 1 ]; then
59 WITH_BBSIM=yes
60else
61 WITH_BBSIM=no
62fi
63
64echo $WITH_BBSIM
Test User01ed0642019-07-03 20:17:06 +000065
66if [ "$TYPE" == "full" ]; then
67 ONOS_API_PORT=${ONOS_API_PORT:-8182}
68 ONOS_SSH_PORT=${ONOS_SSH_PORT:-8102}
69 VOLTHA_API_PORT=${VOLTHA_API_PORT:-55556}
70 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-5023}
71else
72 ONOS_API_PORT=${ONOS_API_PORT:-8181}
73 ONOS_SSH_PORT=${ONOS_SSH_PORT:-8101}
74 VOLTHA_API_PORT=${VOLTHA_API_PORT:-55555}
75 VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-5022}
76fi
77
78if [ "$1" == "get" -a "$2" == "voltconfig" ]; then
79 echo "$HOME/.volt/config-$TYPE"
80 exit
81fi
Test User3d7ad8e2019-07-03 06:15:44 +000082
David K. Bainbridgeb7285432019-07-02 22:05:24 -070083if [ $# -ne 1 -o $(echo ":up:down:" | grep -c ":$1:") -ne 1 ]; then
84 >&2 echo "up or down?"
85 exit 1
86fi
87
88if [ "$1" == "down" ]; then
Test User08ebbd92019-07-03 17:15:39 +000089 if [ -x ./bin/kind ]; then
90 exec ./bin/kind delete cluster --name voltha-$TYPE
91 else
92 >&2 echo "Kind doesn't seem to be installed, so nothing to do. Bye."
93 fi
David K. Bainbridgeb7285432019-07-02 22:05:24 -070094 exit
95fi
96
Test User01ed0642019-07-03 20:17:06 +000097LOG="install-$TYPE.log"
David K. Bainbridgeb7285432019-07-02 22:05:24 -070098date > $LOG
99
100spin() {
Test Userd87942b2019-07-03 07:20:24 +0000101 PARTS="\
102 \xe2\xa2\x8e\xe2\xa1\xb0 \
103 \xe2\xa2\x8e\xe2\xa1\xa1 \
104 \xe2\xa2\x8e\xe2\xa1\x91 \
105 \xe2\xa2\x8e\xe2\xa0\xb1 \
106 \xe2\xa0\x8e\xe2\xa1\xb1 \
107 \xe2\xa2\x8a\xe2\xa1\xb1 \
108 \xe2\xa2\x8c\xe2\xa1\xb1 \
109 \xe2\xa2\x86\xe2\xa1\xb1 \
110 "
111 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700112 tput civis
113 while true; do
Test Userd87942b2019-07-03 07:20:24 +0000114 C=$(echo $PARTS | cut '-d ' -f $IDX)
115 echo -en "$C"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700116 IDX=$(expr $IDX + 1)
Test Userd87942b2019-07-03 07:20:24 +0000117 if [ $IDX -gt 8 ]; then
118 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700119 fi
120 sleep .15
121 echo -en "\r"
122 done
123}
124
Test Userd87942b2019-07-03 07:20:24 +0000125SPIN_PARTS="\
126 \xe2\xa2\x8e\xe2\xa1\xb0 \
127 \xe2\xa2\x8e\xe2\xa1\xa1 \
128 \xe2\xa2\x8e\xe2\xa1\x91 \
129 \xe2\xa2\x8e\xe2\xa0\xb1 \
130 \xe2\xa0\x8e\xe2\xa1\xb1 \
131 \xe2\xa2\x8a\xe2\xa1\xb1 \
132 \xe2\xa2\x8c\xe2\xa1\xb1 \
133 \xe2\xa2\x86\xe2\xa1\xb1 \
134 "
135IDX=1
136NOT_VERIFIED="\xe2\x9c\x97\x20"
137VERIFIED="\xe2\x9c\x93\x20"
Test Userb5712372019-07-03 21:52:17 +0000138HELM="\xE2\x8E\x88"
139OLD_KEY="\xF0\x9F\x97\x9D"
140BIRD="\xF0\x9F\x90\xA6"
141HIGH_VOLTAGE="\xE2\x9A\xA1"
142PLUG="\xF0\x9F\xa7\xa9"
143RESTART="\xf0\x9f\x94\x84"
144FORWARD="\xE2\x87\xA8"
145INSTALL="\xF0\x9F\x8F\x97"
146STOP="\xf0\x9f\x9b\x91"
147GO="\xf0\x9f\x9a\x80"
148DOWNLOAD="\xf0\x9f\x93\xa5"
149GEAR="\xe2\x9a\x99"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700150bspin() {
151 tput civis
Test Userd87942b2019-07-03 07:20:24 +0000152 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700153 local INDENT=
154 if [ "$1" == "-" ]; then
155 INDENT=" "
156 shift
157 fi
Test Userd87942b2019-07-03 07:20:24 +0000158 echo -en "$INDENT $*"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700159}
160
161sspin() {
162 local INDENT=
163 if [ "$1" == "-" ]; then
164 INDENT=" "
165 shift
166 fi
Test Userd87942b2019-07-03 07:20:24 +0000167 C=$(echo $SPIN_PARTS | cut '-d ' -f $IDX)
168 echo -en "\r$INDENT$C $*"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700169 IDX=$(expr $IDX + 1)
Test Userd87942b2019-07-03 07:20:24 +0000170 if [ $IDX -gt 8 ]; then
171 IDX=1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700172 fi
173}
174
175espin() {
176 local INDENT=
177 if [ "$1" == "-" ]; then
178 INDENT=" "
179 shift
180 fi
181 echo -e "\r$INDENT$*"
182 tput cnorm
183}
184
185count_pods() {
186 local NAMESPACE=$1; shift
187 local PODS=$(kubectl -n $NAMESPACE get pod -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}")
188 local COUNT=0
189 local PATTERNS=$*
190 for POD in $PODS; do
191 local NAME=$(echo $POD | cut -d/ -f 1)
192 local STATE=$(echo $POD | cut -d/ -f 2)
193 local CONTAINERS=$(echo $POD | cut -d/ -f 3 | sed -e 's/_/ /g')
194 if [ "$STATE" == "Running" ]; then
195 local TOTAL=$(echo $CONTAINERS | wc -w)
196 local FOUND=$(echo $CONTAINERS | grep -o true | wc -l)
197 if [ $TOTAL -eq $FOUND ]; then
198 for PATTERN in $PATTERNS; do
199 if [[ $NAME =~ $PATTERN ]]; then
200 COUNT=$(expr $COUNT + 1)
201 fi
202 done
203 fi
204 fi
205 done
206 echo $COUNT
207}
208
209wait_for_pods() {
210 local INDENT=
211 if [ "$1" == "-" ]; then
212 INDENT=$1; shift
213 fi
214 local NAMESPACE=$1; shift
215 local EXPECT=$1; shift
216 local RETRY=$1; shift
217 local MESSAGE=$1; shift
218 local PATTERNS=$*
219 local HAVE=$(count_pods $NAMESPACE $PATTERNS)
220 COUNT=$(expr 300 / 15)
221 bspin $INDENT $MESSAGE
222 sspin $INDENT
223 if [ $HAVE -ne $EXPECT ]; then
224 while [ $HAVE -ne $EXPECT ]; do
225 sspin $INDENT
226 COUNT=$(expr $COUNT - 1)
227 if [ $COUNT -eq 0 ]; then
228 HAVE=$(count_pods $NAMESPACE $PATTERNS)
229 COUNT=$(expr 300 / 15)
230 fi
231 sleep .15
232 done
233 fi
234 espin $INDENT $VERIFIED
235 if [ $HAVE -ne $EXPECT ]; then
236 return 1
237 fi
238 return 0
239}
240
241helm_install() {
242 local INDENT=
243 if [ "$1" == "-" ]; then
244 INDENT=$1; shift
245 fi
246 local NAMESPACE=$1; shift
247 local NAME=$1; shift
248 local CHART=$1; shift
249 local MESSAGE=$*
250
251 COUNT=$(expr 300 / 15)
252 bspin $INDENT $MESSAGE
253 (set -x; helm install -f $TYPE-values.yaml --namespace $NAMESPACE --name $NAME $CHART >>$LOG 2>&1) >>$LOG 2>&1
254 SUCCESS=$?
255 while [ $SUCCESS -ne 0 ]; do
256 sspin $INDENT
257 COUNT=$(expr $COUNT - 1)
258 if [ $COUNT -eq 0 ]; then
259 (set -x; helm install -f $TYPE-values.yaml --namespace $NAMESPACE --name $NAME $CHART >>$LOG 2>&1) >>$LOG 2>&1
260 COUNT=$(expr 300 / 15)
261 fi
262 sleep .15
263 done
264 espin $INDENT $VERIFIED
265}
266
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700267echo "INSTALL TYPE: $TYPE" >> $LOG
268
269bspin "Verify GOPATH"
270export GOPATH=$(pwd)
Test User3d7ad8e2019-07-03 06:15:44 +0000271mkdir -p $GOPATH/bin
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700272espin $VERIFIED
273
Test Userb5712372019-07-03 21:52:17 +0000274bspin "Verify kubectl $HELM"
Test Userc13bdc92019-07-03 20:57:49 +0000275if [ -x $GOPATH/bin/kubectl ]; then
276 espin $VERIFIED
277else
278 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000279 bspin - "Download and install Kubernetes/kubectl $DOWNLOAD"
Test Userc13bdc92019-07-03 20:57:49 +0000280 (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/$(go env GOHOSTOS)/$(go env GOARCH)/kubectl >>$LOG 2>&1) >>$LOG 2>&1
281 (set -x; chmod 755 $GOPATH/bin/kubectl >>$LOG 2>&1) >>$LOG 2>&1
282 espin - $VERIFIED
283fi
284
285# Unclear if kubeadm is required. Leave out for now
286#bspin "Verify Kubernetes/kubectl"
287#if [ -x $GOPATH/bin/kubeadm ]; then
288# espin $VERIFIED
289#else
290# espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000291# bspin - "Download and install Kubernetes/kubectl $DOWNLOAD"
Test Userc13bdc92019-07-03 20:57:49 +0000292# (set -x; curl -o $GOPATH/bin/kubeadm -sSL https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/$(go env GOHOSTOS)/$(go env GOARCH)/kubeadm >>$LOG 2>&1) >>$LOG 2>&1
293# (set -x; chmod 755 $GOPATH/bin/kubeadm >>$LOG 2>&1) >>$LOG 2>&1
294# espin - $VERIFIED
295#fi
296
Test Userb5712372019-07-03 21:52:17 +0000297bspin "Verify Kubernetes/Kind $HELM"
Test User3d7ad8e2019-07-03 06:15:44 +0000298if [ -x $GOPATH/bin/kind ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700299 espin $VERIFIED
300else
301 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000302 bspin - "Download and install Kubernetes/kind $DOWNLOAD"
Test User08ebbd92019-07-03 17:15:39 +0000303 (set -x; curl -o $GOPATH/bin/kind -sSL https://github.com/kubernetes-sigs/kind/releases/download/$KIND_VERSION/kind-$(go env GOHOSTOS)-$(go env GOARCH) >>$LOG 2>&1) >>$LOG 2>&1
Test User7c2be412019-07-03 06:20:30 +0000304 (set -x; chmod 755 $GOPATH/bin/kind >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700305 espin - $VERIFIED
306fi
307
Test Userb5712372019-07-03 21:52:17 +0000308bspin "Verify Helm $HELM"
Test User3d7ad8e2019-07-03 06:15:44 +0000309if [ -x $GOPATH/bin/helm ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700310 espin $VERIFIED
311else
312 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000313 bspin - "Download and install Helm $DOWNLOAD"
Test User08ebbd92019-07-03 17:15:39 +0000314 (set -x; curl -sSL https://git.io/get_helm.sh | USE_SUDO=false HELM_INSTALL_DIR=$(go env GOPATH)/bin bash >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700315 espin - $VERIFIED
316fi
317
Test Userb5712372019-07-03 21:52:17 +0000318bspin "Verify voltctl $HIGH_VOLTAGE"
Test User3d7ad8e2019-07-03 06:15:44 +0000319if [ -x $GOPATH/bin/voltctl ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700320 espin $VERIFIED
321else
322 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000323 bspin - "Download and build voltctl $DOWNLOAD"
Test User08ebbd92019-07-03 17:15:39 +0000324 (set -x; curl -o $GOPATH/bin/voltctl -sSL https://github.com/ciena/voltctl/releases/download/$VOLTCTL_VERSION/voltctl-$_VOLTCTL_VERSION-$(go env GOHOSTOS)-$(go env GOARCH) >>$LOG 2>&1) >>$LOG 2>&1
325 (set -x; chmod 755 $GOPATH/bin/voltctl >>$LOG 2>&1) >>$LOG 2>&1
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700326 espin - $VERIFIED
327fi
328
329bspin "Verify command PATH"
330export PATH=$(go env GOPATH)/bin:$PATH
331espin $VERIFIED
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700332
333HAVE=$(kind get clusters | grep -c voltha-$TYPE)
334bspin "Verify Kubernetes/Kind Cluster"
335sspin
336if [ $HAVE -eq 0 ]; then
337 espin $NOT_VERIFIED
338 kind create cluster --name voltha-$TYPE --config $TYPE-cluster.cfg
339else
340 espin $VERIFIED
341fi
342
343export KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$TYPE")"
344P="coredns-.* \
345 etcd-voltha-$TYPE-control-plane \
346 kindnet-.* \
347 kube-apiserver-voltha-$TYPE-control-plane \
348 kube-controller-manager-voltha-$TYPE-control-plane \
349 kube-proxy-.* \
350 kube-scheduler-voltha-$TYPE-control-plane"
351
Test User01ed0642019-07-03 20:17:06 +0000352EXPECT=$(test "$TYPE" == "minimal" && echo "12" || echo "14")
Test Userb5712372019-07-03 21:52:17 +0000353wait_for_pods - "kube-system" $EXPECT -1 "Waiting for system PODs to start" $P
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700354
355COUNT=$(count_pods "kube-system" "tiller-deploy-.*")
356bspin "Verify Helm"
357if [ $(count_pods "kube-system" "tiller-deploy-.*") -ne 1 ]; then
358 espin $NOT_VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000359 echo -e "Configuring Helm $GEAR"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700360 bspin - "Initialize Helm"
361 (set -x; helm init --upgrade >>$LOG 2>&1) >>$LOG 2>&1
362 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000363 bspin - "Add Google Incubator repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700364 (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
365 espin - $VERIFIED
366
Test Userb5712372019-07-03 21:52:17 +0000367 bspin - "Add Google Stable repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700368 (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1
369 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000370 bspin - "Add ONF repository to Helm"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700371 (set -x; helm repo add onf https://charts.opencord.org >>$LOG 2>&1) >>$LOG 2>&1
372 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000373 bspin - "Update Helm repository cache"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700374 (set -x; helm repo update >>$LOG 2>&1) >>$LOG 2>&1
375 espin - $VERIFIED
376
377 # Create and k8s service account so that Helm can create pods
Test Userb5712372019-07-03 21:52:17 +0000378 bspin - "Create Tiller ServiceAccount"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700379 (set -x; kubectl create serviceaccount --namespace kube-system tiller >>$LOG 2>&1) >>$LOG 2>&1
380 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000381 bspin - "Create Tiller ClusterRoleBinding"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700382 (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>$LOG 2>&1) >>$LOG 2>&1
383 espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000384 bspin - "Update Tiller Manifest"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700385 (set -x; kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}' >>$LOG 2>&1) >>$LOG 2>&1
386 espin - $VERIFIED
387else
388 espin $VERIFIED
389fi
Test Userb5712372019-07-03 21:52:17 +0000390wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start" "tiller-deploy-.*"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700391
Test Userb5712372019-07-03 21:52:17 +0000392bspin "Verify ETCD Operator $OLD_KEY"
Test User7d866122019-07-09 17:52:35 +0000393if [ $(helm list --deployed --short --namespace voltha "^etcd-operator\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700394 espin $NOT_VERIFIED
395 helm_install - voltha etcd-operator stable/etcd-operator "Install ETCD Operator"
396else
397 espin $VERIFIED
398fi
Test User01ed0642019-07-03 20:17:06 +0000399EXPECT=$(test "$TYPE" == "minimal" && echo "1" || echo "3")
Test Userb5712372019-07-03 21:52:17 +0000400wait_for_pods - "voltha" $EXPECT -1 "Waiting for ETCD Operator to start" "etcd-operator-.*"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700401
Test Userb5712372019-07-03 21:52:17 +0000402bspin "Verify ONOS installed $BIRD"
Test User7d866122019-07-09 17:52:35 +0000403if [ $(helm list --deployed --short --namespace default "^onos\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700404 espin $NOT_VERIFIED
405 helm_install - default onos onf/onos "Install ONOS"
406else
407 espin $VERIFIED
408fi
Test Userb5712372019-07-03 21:52:17 +0000409wait_for_pods - "default" 1 -1 "Waiting for ONOS to start" "onos-.*"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700410
Test Userb5712372019-07-03 21:52:17 +0000411bspin - "Forward ONOS API port $FORWARD"
Test User01ed0642019-07-03 20:17:06 +0000412(set -x; screen -p 0 -X -S onos-ui-$TYPE stuff $'\003' >>$LOG 2>&1) >>$LOG 2>&1
413(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 -0700414espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000415bspin - "Forward ONOS SSH port $FORWARD"
Test User01ed0642019-07-03 20:17:06 +0000416(set -x; screen -p 0 -X -S onos-ssh-$TYPE stuff $'\003' >>$LOG 2>&1) >>$LOG 2>&1
417(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 -0700418espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000419bspin - "Install required ONOS applications $INSTALL"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700420(set -x; ./onos-files/install-onos-applications.sh >>$LOG 2>&1) >>$LOG 2>&1
421espin - $VERIFIED
422
Test Userb5712372019-07-03 21:52:17 +0000423bspin "Verify VOLTHA installed $HIGH_VOLTAGE"
Test User7d866122019-07-09 17:52:35 +0000424if [ $(helm list --deployed --short --namespace voltha "^voltha\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700425 espin $NOT_VERIFIED
Test Userd87942b2019-07-03 07:20:24 +0000426 helm_install - voltha voltha onf/voltha "Install VOLTHA Core"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700427else
428 espin $VERIFIED
429fi
430VOLTHA="ofagent-.* \
431 ro-core.* \
432 rw-core.* \
433 voltha-api-server-.* \
434 voltha-cli-server-.* \
435 voltha-etcd-cluster-.* \
436 voltha-kafka-.* \
437 voltha-zookeeper-.*"
Test User01ed0642019-07-03 20:17:06 +0000438EXPECT=$(test "$TYPE" == "minimal" && echo "9" || echo "11")
Test Userb5712372019-07-03 21:52:17 +0000439wait_for_pods - "voltha" $EXPECT -1 "Waiting for VOLTHA Core to start" $VOLTHA
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700440
Test Userb5712372019-07-03 21:52:17 +0000441echo -e "Verify Adapters $PLUG"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700442bspin - "Verify Simulated Adapters installed"
Test User7d866122019-07-09 17:52:35 +0000443if [ $(helm list --deployed --short --namespace voltha "^sim\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700444 espin - $NOT_VERIFIED
445 helm_install - voltha sim onf/voltha-adapter-simulated "Install Simulated Adapters"
446else
447 espin - $VERIFIED
448fi
449
450bspin - "Verify OpenOLT Adapter installed"
Test User7d866122019-07-09 17:52:35 +0000451if [ $(helm list --deployed --short --namespace voltha "^open-olt\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700452 espin - $NOT_VERIFIED
453 helm_install - voltha open-olt onf/voltha-adapter-openolt "Install OpenOLT Adapter"
454else
455 espin - $VERIFIED
456fi
457bspin - "Verify OpenONU Adapter installed"
Test User7d866122019-07-09 17:52:35 +0000458if [ $(helm list --deployed --short --namespace voltha "^open-onu\$" | wc -l) -ne 1 ]; then
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700459 espin - $NOT_VERIFIED
460 helm_install - voltha open-onu onf/voltha-adapter-openonu "Install OpenONU Adapter"
461else
462 espin - $VERIFIED
463fi
464
465ADAPTERS="adapter-.*"
Test Userb5712372019-07-03 21:52:17 +0000466wait_for_pods - "voltha" 4 -1 "Waiting for adapters to start" $ADAPTERS
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700467
Test User7d866122019-07-09 17:52:35 +0000468if [ $WITH_BBSIM == "yes" ]; then
469 echo -e "Verify BBSIM $PLUG"
470 bspin - "Verify BBSIM Insalled"
471 if [ $(helm list --deployed --short --namespace voltha "^bbsim\$" | wc -l) -ne 1 ]; then
472 espin - $NOT_VERIFIED
473 helm_install - voltha bbsim onf/bbsim "Install BBSIM"
474 else
475 espin - $VERIFIED
476 fi
477 wait_for_pods - "voltha" 1 -1 "Waiting for BBSIM to start" "bbsim-.*"
478fi
479
Test Userb5712372019-07-03 21:52:17 +0000480echo -e "Restart VOLTHA API $RESTART"
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700481API="voltha-api-server-.* ofagent-.*"
482(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 +0000483wait_for_pods - "voltha" 0 -1 "Wait for API to stop $STOP" $API
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700484(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 +0000485wait_for_pods - "voltha" 2 -1 "Wait for API to re-start $GO" $API
David K. Bainbridgeb7285432019-07-02 22:05:24 -0700486
Test Userb5712372019-07-03 21:52:17 +0000487bspin - "Forward VOLTHA API port $FORWARD"
Test User01ed0642019-07-03 20:17:06 +0000488(set -x; screen -p 0 -X -S voltha-api-$TYPE stuff $'\003' >>$LOG 2>&1) >>$LOG 2>&1
489(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 -0700490espin - $VERIFIED
Test Userb5712372019-07-03 21:52:17 +0000491bspin - "Forward VOLTHA SSH port $FORWARD"
Test User01ed0642019-07-03 20:17:06 +0000492(set -x; screen -p 0 -X -S voltha-ssh-$TYPE stuff $'\003' 2>/dev/null >/dev/null >>$LOG 2>&1) >>$LOG 2>&1
493(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 -0700494espin - $VERIFIED
Test User3d7ad8e2019-07-03 06:15:44 +0000495
496bspin - "Create voltctl configuration file"
497(set -x; mkdir -p $HOME/.volt >>$LOG 2>&1) >>$LOG 2>&1
Test User01ed0642019-07-03 20:17:06 +0000498(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 +0000499espin - $VERIFIED
Test User08ebbd92019-07-03 17:15:39 +0000500
Test User7d866122019-07-09 17:52:35 +0000501echo ""
Test User08ebbd92019-07-03 17:15:39 +0000502echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG
503echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG
504echo "tools required by VOLTHA in your command path. " | tee -a $LOG
505echo "" | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +0000506echo -en $BOLD
Test User08ebbd92019-07-03 17:15:39 +0000507echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$TYPE\")\"" | tee -a $LOG
Test Userfa30f7f2019-07-03 20:35:19 +0000508echo "export VOLTCONFIG=\"$HOME/.volt/config-$TYPE\"" | tee -a $LOG
Test User08ebbd92019-07-03 17:15:39 +0000509echo 'export PATH=$GOPATH/bin:$PATH' | tee -a $LOG
Test User7d866122019-07-09 17:52:35 +0000510echo -en $NORMAL
Test User08ebbd92019-07-03 17:15:39 +0000511echo "" | tee -a $LOG
512echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG
513