Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 1 | #!/bin/bash |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 2 | # 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() |
| 17 | trap ctrl_c INT |
| 18 | |
| 19 | function 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 User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 27 | VOLTCTL_VERSION=${VOLTCTL_VERSION:-0.0.5-dev} |
| 28 | KIND_VERSION=${KIND_VERSION:-v0.4.0} |
| 29 | _VOLTCTL_VERSION=$(echo $VOLTCTL_VERSION | sed -e 's/-/_/g') |
| 30 | |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 31 | TYPE=${TYPE:-minimal} |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 32 | |
| 33 | if [ "$TYPE" == "full" ]; then |
| 34 | ONOS_API_PORT=${ONOS_API_PORT:-8182} |
| 35 | ONOS_SSH_PORT=${ONOS_SSH_PORT:-8102} |
| 36 | VOLTHA_API_PORT=${VOLTHA_API_PORT:-55556} |
| 37 | VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-5023} |
| 38 | else |
| 39 | ONOS_API_PORT=${ONOS_API_PORT:-8181} |
| 40 | ONOS_SSH_PORT=${ONOS_SSH_PORT:-8101} |
| 41 | VOLTHA_API_PORT=${VOLTHA_API_PORT:-55555} |
| 42 | VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-5022} |
| 43 | fi |
| 44 | |
| 45 | if [ "$1" == "get" -a "$2" == "voltconfig" ]; then |
| 46 | echo "$HOME/.volt/config-$TYPE" |
| 47 | exit |
| 48 | fi |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 49 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 50 | if [ $# -ne 1 -o $(echo ":up:down:" | grep -c ":$1:") -ne 1 ]; then |
| 51 | >&2 echo "up or down?" |
| 52 | exit 1 |
| 53 | fi |
| 54 | |
| 55 | if [ "$1" == "down" ]; then |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 56 | if [ -x ./bin/kind ]; then |
| 57 | exec ./bin/kind delete cluster --name voltha-$TYPE |
| 58 | else |
| 59 | >&2 echo "Kind doesn't seem to be installed, so nothing to do. Bye." |
| 60 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 61 | exit |
| 62 | fi |
| 63 | |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 64 | LOG="install-$TYPE.log" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 65 | date > $LOG |
| 66 | |
| 67 | spin() { |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 68 | PARTS="\ |
| 69 | \xe2\xa2\x8e\xe2\xa1\xb0 \ |
| 70 | \xe2\xa2\x8e\xe2\xa1\xa1 \ |
| 71 | \xe2\xa2\x8e\xe2\xa1\x91 \ |
| 72 | \xe2\xa2\x8e\xe2\xa0\xb1 \ |
| 73 | \xe2\xa0\x8e\xe2\xa1\xb1 \ |
| 74 | \xe2\xa2\x8a\xe2\xa1\xb1 \ |
| 75 | \xe2\xa2\x8c\xe2\xa1\xb1 \ |
| 76 | \xe2\xa2\x86\xe2\xa1\xb1 \ |
| 77 | " |
| 78 | IDX=1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 79 | tput civis |
| 80 | while true; do |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 81 | C=$(echo $PARTS | cut '-d ' -f $IDX) |
| 82 | echo -en "$C" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 83 | IDX=$(expr $IDX + 1) |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 84 | if [ $IDX -gt 8 ]; then |
| 85 | IDX=1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 86 | fi |
| 87 | sleep .15 |
| 88 | echo -en "\r" |
| 89 | done |
| 90 | } |
| 91 | |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 92 | SPIN_PARTS="\ |
| 93 | \xe2\xa2\x8e\xe2\xa1\xb0 \ |
| 94 | \xe2\xa2\x8e\xe2\xa1\xa1 \ |
| 95 | \xe2\xa2\x8e\xe2\xa1\x91 \ |
| 96 | \xe2\xa2\x8e\xe2\xa0\xb1 \ |
| 97 | \xe2\xa0\x8e\xe2\xa1\xb1 \ |
| 98 | \xe2\xa2\x8a\xe2\xa1\xb1 \ |
| 99 | \xe2\xa2\x8c\xe2\xa1\xb1 \ |
| 100 | \xe2\xa2\x86\xe2\xa1\xb1 \ |
| 101 | " |
| 102 | IDX=1 |
| 103 | NOT_VERIFIED="\xe2\x9c\x97\x20" |
| 104 | VERIFIED="\xe2\x9c\x93\x20" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 105 | bspin() { |
| 106 | tput civis |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 107 | IDX=1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 108 | local INDENT= |
| 109 | if [ "$1" == "-" ]; then |
| 110 | INDENT=" " |
| 111 | shift |
| 112 | fi |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 113 | echo -en "$INDENT $*" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | sspin() { |
| 117 | local INDENT= |
| 118 | if [ "$1" == "-" ]; then |
| 119 | INDENT=" " |
| 120 | shift |
| 121 | fi |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 122 | C=$(echo $SPIN_PARTS | cut '-d ' -f $IDX) |
| 123 | echo -en "\r$INDENT$C $*" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 124 | IDX=$(expr $IDX + 1) |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 125 | if [ $IDX -gt 8 ]; then |
| 126 | IDX=1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 127 | fi |
| 128 | } |
| 129 | |
| 130 | espin() { |
| 131 | local INDENT= |
| 132 | if [ "$1" == "-" ]; then |
| 133 | INDENT=" " |
| 134 | shift |
| 135 | fi |
| 136 | echo -e "\r$INDENT$*" |
| 137 | tput cnorm |
| 138 | } |
| 139 | |
| 140 | count_pods() { |
| 141 | local NAMESPACE=$1; shift |
| 142 | local PODS=$(kubectl -n $NAMESPACE get pod -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}") |
| 143 | local COUNT=0 |
| 144 | local PATTERNS=$* |
| 145 | for POD in $PODS; do |
| 146 | local NAME=$(echo $POD | cut -d/ -f 1) |
| 147 | local STATE=$(echo $POD | cut -d/ -f 2) |
| 148 | local CONTAINERS=$(echo $POD | cut -d/ -f 3 | sed -e 's/_/ /g') |
| 149 | if [ "$STATE" == "Running" ]; then |
| 150 | local TOTAL=$(echo $CONTAINERS | wc -w) |
| 151 | local FOUND=$(echo $CONTAINERS | grep -o true | wc -l) |
| 152 | if [ $TOTAL -eq $FOUND ]; then |
| 153 | for PATTERN in $PATTERNS; do |
| 154 | if [[ $NAME =~ $PATTERN ]]; then |
| 155 | COUNT=$(expr $COUNT + 1) |
| 156 | fi |
| 157 | done |
| 158 | fi |
| 159 | fi |
| 160 | done |
| 161 | echo $COUNT |
| 162 | } |
| 163 | |
| 164 | wait_for_pods() { |
| 165 | local INDENT= |
| 166 | if [ "$1" == "-" ]; then |
| 167 | INDENT=$1; shift |
| 168 | fi |
| 169 | local NAMESPACE=$1; shift |
| 170 | local EXPECT=$1; shift |
| 171 | local RETRY=$1; shift |
| 172 | local MESSAGE=$1; shift |
| 173 | local PATTERNS=$* |
| 174 | local HAVE=$(count_pods $NAMESPACE $PATTERNS) |
| 175 | COUNT=$(expr 300 / 15) |
| 176 | bspin $INDENT $MESSAGE |
| 177 | sspin $INDENT |
| 178 | if [ $HAVE -ne $EXPECT ]; then |
| 179 | while [ $HAVE -ne $EXPECT ]; do |
| 180 | sspin $INDENT |
| 181 | COUNT=$(expr $COUNT - 1) |
| 182 | if [ $COUNT -eq 0 ]; then |
| 183 | HAVE=$(count_pods $NAMESPACE $PATTERNS) |
| 184 | COUNT=$(expr 300 / 15) |
| 185 | fi |
| 186 | sleep .15 |
| 187 | done |
| 188 | fi |
| 189 | espin $INDENT $VERIFIED |
| 190 | if [ $HAVE -ne $EXPECT ]; then |
| 191 | return 1 |
| 192 | fi |
| 193 | return 0 |
| 194 | } |
| 195 | |
| 196 | helm_install() { |
| 197 | local INDENT= |
| 198 | if [ "$1" == "-" ]; then |
| 199 | INDENT=$1; shift |
| 200 | fi |
| 201 | local NAMESPACE=$1; shift |
| 202 | local NAME=$1; shift |
| 203 | local CHART=$1; shift |
| 204 | local MESSAGE=$* |
| 205 | |
| 206 | COUNT=$(expr 300 / 15) |
| 207 | bspin $INDENT $MESSAGE |
| 208 | (set -x; helm install -f $TYPE-values.yaml --namespace $NAMESPACE --name $NAME $CHART >>$LOG 2>&1) >>$LOG 2>&1 |
| 209 | SUCCESS=$? |
| 210 | while [ $SUCCESS -ne 0 ]; do |
| 211 | sspin $INDENT |
| 212 | COUNT=$(expr $COUNT - 1) |
| 213 | if [ $COUNT -eq 0 ]; then |
| 214 | (set -x; helm install -f $TYPE-values.yaml --namespace $NAMESPACE --name $NAME $CHART >>$LOG 2>&1) >>$LOG 2>&1 |
| 215 | COUNT=$(expr 300 / 15) |
| 216 | fi |
| 217 | sleep .15 |
| 218 | done |
| 219 | espin $INDENT $VERIFIED |
| 220 | } |
| 221 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 222 | echo "INSTALL TYPE: $TYPE" >> $LOG |
| 223 | |
| 224 | bspin "Verify GOPATH" |
| 225 | export GOPATH=$(pwd) |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 226 | mkdir -p $GOPATH/bin |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 227 | espin $VERIFIED |
| 228 | |
Test User | c13bdc9 | 2019-07-03 20:57:49 +0000 | [diff] [blame^] | 229 | bspin "Verify kubectl" |
| 230 | if [ -x $GOPATH/bin/kubectl ]; then |
| 231 | espin $VERIFIED |
| 232 | else |
| 233 | espin $NOT_VERIFIED |
| 234 | bspin - "Download and install Kubernetes/kubectl" |
| 235 | (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 |
| 236 | (set -x; chmod 755 $GOPATH/bin/kubectl >>$LOG 2>&1) >>$LOG 2>&1 |
| 237 | espin - $VERIFIED |
| 238 | fi |
| 239 | |
| 240 | # Unclear if kubeadm is required. Leave out for now |
| 241 | #bspin "Verify Kubernetes/kubectl" |
| 242 | #if [ -x $GOPATH/bin/kubeadm ]; then |
| 243 | # espin $VERIFIED |
| 244 | #else |
| 245 | # espin $NOT_VERIFIED |
| 246 | # bspin - "Download and install Kubernetes/kubectl" |
| 247 | # (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 |
| 248 | # (set -x; chmod 755 $GOPATH/bin/kubeadm >>$LOG 2>&1) >>$LOG 2>&1 |
| 249 | # espin - $VERIFIED |
| 250 | #fi |
| 251 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 252 | bspin "Verify Kubernetes/Kind" |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 253 | if [ -x $GOPATH/bin/kind ]; then |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 254 | espin $VERIFIED |
| 255 | else |
| 256 | espin $NOT_VERIFIED |
Test User | c13bdc9 | 2019-07-03 20:57:49 +0000 | [diff] [blame^] | 257 | bspin - "Download and install Kubernetes/kind" |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 258 | (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 User | 7c2be41 | 2019-07-03 06:20:30 +0000 | [diff] [blame] | 259 | (set -x; chmod 755 $GOPATH/bin/kind >>$LOG 2>&1) >>$LOG 2>&1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 260 | espin - $VERIFIED |
| 261 | fi |
| 262 | |
| 263 | bspin "Verify Helm" |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 264 | if [ -x $GOPATH/bin/helm ]; then |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 265 | espin $VERIFIED |
| 266 | else |
| 267 | espin $NOT_VERIFIED |
| 268 | bspin - "Download and install Helm" |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 269 | (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. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 270 | espin - $VERIFIED |
| 271 | fi |
| 272 | |
| 273 | bspin "Verify voltctl" |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 274 | if [ -x $GOPATH/bin/voltctl ]; then |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 275 | espin $VERIFIED |
| 276 | else |
| 277 | espin $NOT_VERIFIED |
| 278 | bspin - "Download and build voltctl" |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 279 | (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 |
| 280 | (set -x; chmod 755 $GOPATH/bin/voltctl >>$LOG 2>&1) >>$LOG 2>&1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 281 | espin - $VERIFIED |
| 282 | fi |
| 283 | |
| 284 | bspin "Verify command PATH" |
| 285 | export PATH=$(go env GOPATH)/bin:$PATH |
| 286 | espin $VERIFIED |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 287 | |
| 288 | HAVE=$(kind get clusters | grep -c voltha-$TYPE) |
| 289 | bspin "Verify Kubernetes/Kind Cluster" |
| 290 | sspin |
| 291 | if [ $HAVE -eq 0 ]; then |
| 292 | espin $NOT_VERIFIED |
| 293 | kind create cluster --name voltha-$TYPE --config $TYPE-cluster.cfg |
| 294 | else |
| 295 | espin $VERIFIED |
| 296 | fi |
| 297 | |
| 298 | export KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$TYPE")" |
| 299 | P="coredns-.* \ |
| 300 | etcd-voltha-$TYPE-control-plane \ |
| 301 | kindnet-.* \ |
| 302 | kube-apiserver-voltha-$TYPE-control-plane \ |
| 303 | kube-controller-manager-voltha-$TYPE-control-plane \ |
| 304 | kube-proxy-.* \ |
| 305 | kube-scheduler-voltha-$TYPE-control-plane" |
| 306 | |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 307 | EXPECT=$(test "$TYPE" == "minimal" && echo "12" || echo "14") |
| 308 | wait_for_pods - "kube-system" $EXPECT -1 "Waiting for system PODs to start..." $P |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 309 | |
| 310 | COUNT=$(count_pods "kube-system" "tiller-deploy-.*") |
| 311 | bspin "Verify Helm" |
| 312 | if [ $(count_pods "kube-system" "tiller-deploy-.*") -ne 1 ]; then |
| 313 | espin $NOT_VERIFIED |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 314 | echo "Configuring Helm ..." |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 315 | bspin - "Initialize Helm" |
| 316 | (set -x; helm init --upgrade >>$LOG 2>&1) >>$LOG 2>&1 |
| 317 | espin - $VERIFIED |
| 318 | bspin - "Add Google Incubator repository to Helm ..." |
| 319 | (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1 |
| 320 | espin - $VERIFIED |
| 321 | |
| 322 | bspin - "Add Google Stable repository to Helm ..." |
| 323 | (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1 |
| 324 | espin - $VERIFIED |
| 325 | bspin - "Add ONF repository to Helm ..." |
| 326 | (set -x; helm repo add onf https://charts.opencord.org >>$LOG 2>&1) >>$LOG 2>&1 |
| 327 | espin - $VERIFIED |
| 328 | bspin - "Update Helm repository cache ..." |
| 329 | (set -x; helm repo update >>$LOG 2>&1) >>$LOG 2>&1 |
| 330 | espin - $VERIFIED |
| 331 | |
| 332 | # Create and k8s service account so that Helm can create pods |
| 333 | bspin - "Create Tiller ServiceAccount ..." |
| 334 | (set -x; kubectl create serviceaccount --namespace kube-system tiller >>$LOG 2>&1) >>$LOG 2>&1 |
| 335 | espin - $VERIFIED |
| 336 | bspin - "Create Tiller ClusterRoleBinding ..." |
| 337 | (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>$LOG 2>&1) >>$LOG 2>&1 |
| 338 | espin - $VERIFIED |
| 339 | bspin - "Update Tiller Manifest ..." |
| 340 | (set -x; kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}' >>$LOG 2>&1) >>$LOG 2>&1 |
| 341 | espin - $VERIFIED |
| 342 | else |
| 343 | espin $VERIFIED |
| 344 | fi |
| 345 | wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start..." "tiller-deploy-.*" |
| 346 | |
| 347 | bspin "Verify ETCD Operator" |
| 348 | if [ $(helm list etcd-operator | grep -c DEPLOYED) -ne 1 ]; then |
| 349 | espin $NOT_VERIFIED |
| 350 | helm_install - voltha etcd-operator stable/etcd-operator "Install ETCD Operator" |
| 351 | else |
| 352 | espin $VERIFIED |
| 353 | fi |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 354 | EXPECT=$(test "$TYPE" == "minimal" && echo "1" || echo "3") |
| 355 | wait_for_pods - "voltha" $EXPECT -1 "Waiting for ETCD Operator to start..." "etcd-operator-.*" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 356 | |
| 357 | bspin "Verify ONOS installed" |
| 358 | if [ $(helm list onos | grep -c DEPLOYED) -ne 1 ]; then |
| 359 | espin $NOT_VERIFIED |
| 360 | helm_install - default onos onf/onos "Install ONOS" |
| 361 | else |
| 362 | espin $VERIFIED |
| 363 | fi |
| 364 | wait_for_pods - "default" 1 -1 "Waiting for ONOS to start..." "onos-.*" |
| 365 | |
| 366 | bspin - "Forward ONOS API port" |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 367 | (set -x; screen -p 0 -X -S onos-ui-$TYPE stuff $'\003' >>$LOG 2>&1) >>$LOG 2>&1 |
| 368 | (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. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 369 | espin - $VERIFIED |
| 370 | bspin - "Forward ONOS SSH port" |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 371 | (set -x; screen -p 0 -X -S onos-ssh-$TYPE stuff $'\003' >>$LOG 2>&1) >>$LOG 2>&1 |
| 372 | (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. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 373 | espin - $VERIFIED |
| 374 | bspin - "Install required ONOS applications" |
| 375 | (set -x; ./onos-files/install-onos-applications.sh >>$LOG 2>&1) >>$LOG 2>&1 |
| 376 | espin - $VERIFIED |
| 377 | |
| 378 | bspin "Verify VOLTHA installed" |
| 379 | if [ $(helm list voltha | grep -c DEPLOYED) -ne 1 ]; then |
| 380 | espin $NOT_VERIFIED |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 381 | helm_install - voltha voltha onf/voltha "Install VOLTHA Core" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 382 | else |
| 383 | espin $VERIFIED |
| 384 | fi |
| 385 | VOLTHA="ofagent-.* \ |
| 386 | ro-core.* \ |
| 387 | rw-core.* \ |
| 388 | voltha-api-server-.* \ |
| 389 | voltha-cli-server-.* \ |
| 390 | voltha-etcd-cluster-.* \ |
| 391 | voltha-kafka-.* \ |
| 392 | voltha-zookeeper-.*" |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 393 | EXPECT=$(test "$TYPE" == "minimal" && echo "9" || echo "11") |
| 394 | wait_for_pods - "voltha" $EXPECT -1 "Waiting for VOLTHA Core to start..." $VOLTHA |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 395 | |
| 396 | echo "Verify Adapters" |
| 397 | bspin - "Verify Simulated Adapters installed" |
| 398 | if [ $(helm list sim | grep -c DEPLOYED) -ne 1 ]; then |
| 399 | espin - $NOT_VERIFIED |
| 400 | helm_install - voltha sim onf/voltha-adapter-simulated "Install Simulated Adapters" |
| 401 | else |
| 402 | espin - $VERIFIED |
| 403 | fi |
| 404 | |
| 405 | bspin - "Verify OpenOLT Adapter installed" |
| 406 | if [ $(helm list open-olt | grep -c DEPLOYED) -ne 1 ]; then |
| 407 | espin - $NOT_VERIFIED |
| 408 | helm_install - voltha open-olt onf/voltha-adapter-openolt "Install OpenOLT Adapter" |
| 409 | else |
| 410 | espin - $VERIFIED |
| 411 | fi |
| 412 | bspin - "Verify OpenONU Adapter installed" |
| 413 | if [ $(helm list open-onu | grep -c DEPLOYED) -ne 1 ]; then |
| 414 | espin - $NOT_VERIFIED |
| 415 | helm_install - voltha open-onu onf/voltha-adapter-openonu "Install OpenONU Adapter" |
| 416 | else |
| 417 | espin - $VERIFIED |
| 418 | fi |
| 419 | |
| 420 | ADAPTERS="adapter-.*" |
| 421 | wait_for_pods - "voltha" 4 -1 "Waiting for adapters to start..." $ADAPTERS |
| 422 | |
| 423 | echo "Restart VOLTHA API" |
| 424 | API="voltha-api-server-.* ofagent-.*" |
| 425 | (set -x; kubectl scale --replicas=0 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1 |
| 426 | wait_for_pods - "voltha" 0 -1 "Wait for API to stop" $API |
| 427 | (set -x; kubectl scale --replicas=1 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1 |
| 428 | wait_for_pods - "voltha" 2 -1 "Wait for API to re-start ..." $API |
| 429 | |
| 430 | bspin - "Forward VOLTHA API port" |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 431 | (set -x; screen -p 0 -X -S voltha-api-$TYPE stuff $'\003' >>$LOG 2>&1) >>$LOG 2>&1 |
| 432 | (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. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 433 | espin - $VERIFIED |
| 434 | bspin - "Forward VOLTHA SSH port" |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 435 | (set -x; screen -p 0 -X -S voltha-ssh-$TYPE stuff $'\003' 2>/dev/null >/dev/null >>$LOG 2>&1) >>$LOG 2>&1 |
| 436 | (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. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 437 | espin - $VERIFIED |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 438 | |
| 439 | bspin - "Create voltctl configuration file" |
| 440 | (set -x; mkdir -p $HOME/.volt >>$LOG 2>&1) >>$LOG 2>&1 |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 441 | (set -x; voltctl -a v2 -s localhost:$VOLTHA_API_PORT config > $HOME/.volt/config-$TYPE 2>>$LOG) >>$LOG 2>&1 |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 442 | espin - $VERIFIED |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 443 | |
| 444 | echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG |
| 445 | echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG |
| 446 | echo "tools required by VOLTHA in your command path. " | tee -a $LOG |
| 447 | echo "" | tee -a $LOG |
| 448 | echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$TYPE\")\"" | tee -a $LOG |
Test User | fa30f7f | 2019-07-03 20:35:19 +0000 | [diff] [blame] | 449 | echo "export VOLTCONFIG=\"$HOME/.volt/config-$TYPE\"" | tee -a $LOG |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 450 | echo 'export PATH=$GOPATH/bin:$PATH' | tee -a $LOG |
| 451 | echo "" | tee -a $LOG |
| 452 | echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG |
| 453 | |