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 | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame^] | 31 | NOCOLOR="\u001b[0m" |
| 32 | BLACK=$(tput setaf 0) |
| 33 | RED=$(tput setaf 1) |
| 34 | GREEN=$(tput setaf 2) |
| 35 | YELLOW=$(tput setaf 3) |
| 36 | BLUE=$(tput setaf 4) |
| 37 | MAGENTA=$(tput setaf 5) |
| 38 | CYAN=$(tput setaf 6) |
| 39 | WHITE=$(tput setaf 7) |
| 40 | BOLD=$(tput bold) |
| 41 | NORMAL=$(tput sgr0) |
| 42 | ERROR="\xe2\x9c\x97\x20" |
| 43 | |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 44 | TYPE=${TYPE:-minimal} |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame^] | 45 | WITH_BBSIM=${WITH_BBSIM:-no} |
| 46 | |
| 47 | # Verify TYPE setting |
| 48 | if [ $(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 |
| 51 | fi |
| 52 | |
| 53 | # Verify WITH_BBSIM settting and convert uniform value of yes or no |
| 54 | if [ $(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 |
| 57 | fi |
| 58 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_BBSIM:") -eq 1 ]; then |
| 59 | WITH_BBSIM=yes |
| 60 | else |
| 61 | WITH_BBSIM=no |
| 62 | fi |
| 63 | |
| 64 | echo $WITH_BBSIM |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 65 | |
| 66 | if [ "$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} |
| 71 | else |
| 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} |
| 76 | fi |
| 77 | |
| 78 | if [ "$1" == "get" -a "$2" == "voltconfig" ]; then |
| 79 | echo "$HOME/.volt/config-$TYPE" |
| 80 | exit |
| 81 | fi |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 82 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 83 | if [ $# -ne 1 -o $(echo ":up:down:" | grep -c ":$1:") -ne 1 ]; then |
| 84 | >&2 echo "up or down?" |
| 85 | exit 1 |
| 86 | fi |
| 87 | |
| 88 | if [ "$1" == "down" ]; then |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 89 | 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. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 94 | exit |
| 95 | fi |
| 96 | |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 97 | LOG="install-$TYPE.log" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 98 | date > $LOG |
| 99 | |
| 100 | spin() { |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 101 | 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. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 112 | tput civis |
| 113 | while true; do |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 114 | C=$(echo $PARTS | cut '-d ' -f $IDX) |
| 115 | echo -en "$C" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 116 | IDX=$(expr $IDX + 1) |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 117 | if [ $IDX -gt 8 ]; then |
| 118 | IDX=1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 119 | fi |
| 120 | sleep .15 |
| 121 | echo -en "\r" |
| 122 | done |
| 123 | } |
| 124 | |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 125 | SPIN_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 | " |
| 135 | IDX=1 |
| 136 | NOT_VERIFIED="\xe2\x9c\x97\x20" |
| 137 | VERIFIED="\xe2\x9c\x93\x20" |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 138 | HELM="\xE2\x8E\x88" |
| 139 | OLD_KEY="\xF0\x9F\x97\x9D" |
| 140 | BIRD="\xF0\x9F\x90\xA6" |
| 141 | HIGH_VOLTAGE="\xE2\x9A\xA1" |
| 142 | PLUG="\xF0\x9F\xa7\xa9" |
| 143 | RESTART="\xf0\x9f\x94\x84" |
| 144 | FORWARD="\xE2\x87\xA8" |
| 145 | INSTALL="\xF0\x9F\x8F\x97" |
| 146 | STOP="\xf0\x9f\x9b\x91" |
| 147 | GO="\xf0\x9f\x9a\x80" |
| 148 | DOWNLOAD="\xf0\x9f\x93\xa5" |
| 149 | GEAR="\xe2\x9a\x99" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 150 | bspin() { |
| 151 | tput civis |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 152 | IDX=1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 153 | local INDENT= |
| 154 | if [ "$1" == "-" ]; then |
| 155 | INDENT=" " |
| 156 | shift |
| 157 | fi |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 158 | echo -en "$INDENT $*" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | sspin() { |
| 162 | local INDENT= |
| 163 | if [ "$1" == "-" ]; then |
| 164 | INDENT=" " |
| 165 | shift |
| 166 | fi |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 167 | C=$(echo $SPIN_PARTS | cut '-d ' -f $IDX) |
| 168 | echo -en "\r$INDENT$C $*" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 169 | IDX=$(expr $IDX + 1) |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 170 | if [ $IDX -gt 8 ]; then |
| 171 | IDX=1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 172 | fi |
| 173 | } |
| 174 | |
| 175 | espin() { |
| 176 | local INDENT= |
| 177 | if [ "$1" == "-" ]; then |
| 178 | INDENT=" " |
| 179 | shift |
| 180 | fi |
| 181 | echo -e "\r$INDENT$*" |
| 182 | tput cnorm |
| 183 | } |
| 184 | |
| 185 | count_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 | |
| 209 | wait_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 | |
| 241 | helm_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. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 267 | echo "INSTALL TYPE: $TYPE" >> $LOG |
| 268 | |
| 269 | bspin "Verify GOPATH" |
| 270 | export GOPATH=$(pwd) |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 271 | mkdir -p $GOPATH/bin |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 272 | espin $VERIFIED |
| 273 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 274 | bspin "Verify kubectl $HELM" |
Test User | c13bdc9 | 2019-07-03 20:57:49 +0000 | [diff] [blame] | 275 | if [ -x $GOPATH/bin/kubectl ]; then |
| 276 | espin $VERIFIED |
| 277 | else |
| 278 | espin $NOT_VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 279 | bspin - "Download and install Kubernetes/kubectl $DOWNLOAD" |
Test User | c13bdc9 | 2019-07-03 20:57:49 +0000 | [diff] [blame] | 280 | (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 |
| 283 | fi |
| 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 User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 291 | # bspin - "Download and install Kubernetes/kubectl $DOWNLOAD" |
Test User | c13bdc9 | 2019-07-03 20:57:49 +0000 | [diff] [blame] | 292 | # (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 User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 297 | bspin "Verify Kubernetes/Kind $HELM" |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 298 | if [ -x $GOPATH/bin/kind ]; then |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 299 | espin $VERIFIED |
| 300 | else |
| 301 | espin $NOT_VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 302 | bspin - "Download and install Kubernetes/kind $DOWNLOAD" |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 303 | (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] | 304 | (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] | 305 | espin - $VERIFIED |
| 306 | fi |
| 307 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 308 | bspin "Verify Helm $HELM" |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 309 | if [ -x $GOPATH/bin/helm ]; then |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 310 | espin $VERIFIED |
| 311 | else |
| 312 | espin $NOT_VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 313 | bspin - "Download and install Helm $DOWNLOAD" |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 314 | (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] | 315 | espin - $VERIFIED |
| 316 | fi |
| 317 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 318 | bspin "Verify voltctl $HIGH_VOLTAGE" |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 319 | if [ -x $GOPATH/bin/voltctl ]; then |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 320 | espin $VERIFIED |
| 321 | else |
| 322 | espin $NOT_VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 323 | bspin - "Download and build voltctl $DOWNLOAD" |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 324 | (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. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 326 | espin - $VERIFIED |
| 327 | fi |
| 328 | |
| 329 | bspin "Verify command PATH" |
| 330 | export PATH=$(go env GOPATH)/bin:$PATH |
| 331 | espin $VERIFIED |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 332 | |
| 333 | HAVE=$(kind get clusters | grep -c voltha-$TYPE) |
| 334 | bspin "Verify Kubernetes/Kind Cluster" |
| 335 | sspin |
| 336 | if [ $HAVE -eq 0 ]; then |
| 337 | espin $NOT_VERIFIED |
| 338 | kind create cluster --name voltha-$TYPE --config $TYPE-cluster.cfg |
| 339 | else |
| 340 | espin $VERIFIED |
| 341 | fi |
| 342 | |
| 343 | export KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$TYPE")" |
| 344 | P="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 User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 352 | EXPECT=$(test "$TYPE" == "minimal" && echo "12" || echo "14") |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 353 | 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] | 354 | |
| 355 | COUNT=$(count_pods "kube-system" "tiller-deploy-.*") |
| 356 | bspin "Verify Helm" |
| 357 | if [ $(count_pods "kube-system" "tiller-deploy-.*") -ne 1 ]; then |
| 358 | espin $NOT_VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 359 | echo -e "Configuring Helm $GEAR" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 360 | bspin - "Initialize Helm" |
| 361 | (set -x; helm init --upgrade >>$LOG 2>&1) >>$LOG 2>&1 |
| 362 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 363 | bspin - "Add Google Incubator repository to Helm" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 364 | (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1 |
| 365 | espin - $VERIFIED |
| 366 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 367 | bspin - "Add Google Stable repository to Helm" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 368 | (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1 |
| 369 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 370 | bspin - "Add ONF repository to Helm" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 371 | (set -x; helm repo add onf https://charts.opencord.org >>$LOG 2>&1) >>$LOG 2>&1 |
| 372 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 373 | bspin - "Update Helm repository cache" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 374 | (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 User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 378 | bspin - "Create Tiller ServiceAccount" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 379 | (set -x; kubectl create serviceaccount --namespace kube-system tiller >>$LOG 2>&1) >>$LOG 2>&1 |
| 380 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 381 | bspin - "Create Tiller ClusterRoleBinding" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 382 | (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 User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 384 | bspin - "Update Tiller Manifest" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 385 | (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 |
| 387 | else |
| 388 | espin $VERIFIED |
| 389 | fi |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 390 | wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start" "tiller-deploy-.*" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 391 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 392 | bspin "Verify ETCD Operator $OLD_KEY" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame^] | 393 | if [ $(helm list --deployed --short --namespace voltha "^etcd-operator\$" | wc -l) -ne 1 ]; then |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 394 | espin $NOT_VERIFIED |
| 395 | helm_install - voltha etcd-operator stable/etcd-operator "Install ETCD Operator" |
| 396 | else |
| 397 | espin $VERIFIED |
| 398 | fi |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 399 | EXPECT=$(test "$TYPE" == "minimal" && echo "1" || echo "3") |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 400 | 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] | 401 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 402 | bspin "Verify ONOS installed $BIRD" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame^] | 403 | if [ $(helm list --deployed --short --namespace default "^onos\$" | wc -l) -ne 1 ]; then |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 404 | espin $NOT_VERIFIED |
| 405 | helm_install - default onos onf/onos "Install ONOS" |
| 406 | else |
| 407 | espin $VERIFIED |
| 408 | fi |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 409 | wait_for_pods - "default" 1 -1 "Waiting for ONOS to start" "onos-.*" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 410 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 411 | bspin - "Forward ONOS API port $FORWARD" |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 412 | (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. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 414 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 415 | bspin - "Forward ONOS SSH port $FORWARD" |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 416 | (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. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 418 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 419 | bspin - "Install required ONOS applications $INSTALL" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 420 | (set -x; ./onos-files/install-onos-applications.sh >>$LOG 2>&1) >>$LOG 2>&1 |
| 421 | espin - $VERIFIED |
| 422 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 423 | bspin "Verify VOLTHA installed $HIGH_VOLTAGE" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame^] | 424 | if [ $(helm list --deployed --short --namespace voltha "^voltha\$" | wc -l) -ne 1 ]; then |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 425 | espin $NOT_VERIFIED |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 426 | helm_install - voltha voltha onf/voltha "Install VOLTHA Core" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 427 | else |
| 428 | espin $VERIFIED |
| 429 | fi |
| 430 | VOLTHA="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 User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 438 | EXPECT=$(test "$TYPE" == "minimal" && echo "9" || echo "11") |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 439 | 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] | 440 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 441 | echo -e "Verify Adapters $PLUG" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 442 | bspin - "Verify Simulated Adapters installed" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame^] | 443 | if [ $(helm list --deployed --short --namespace voltha "^sim\$" | wc -l) -ne 1 ]; then |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 444 | espin - $NOT_VERIFIED |
| 445 | helm_install - voltha sim onf/voltha-adapter-simulated "Install Simulated Adapters" |
| 446 | else |
| 447 | espin - $VERIFIED |
| 448 | fi |
| 449 | |
| 450 | bspin - "Verify OpenOLT Adapter installed" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame^] | 451 | if [ $(helm list --deployed --short --namespace voltha "^open-olt\$" | wc -l) -ne 1 ]; then |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 452 | espin - $NOT_VERIFIED |
| 453 | helm_install - voltha open-olt onf/voltha-adapter-openolt "Install OpenOLT Adapter" |
| 454 | else |
| 455 | espin - $VERIFIED |
| 456 | fi |
| 457 | bspin - "Verify OpenONU Adapter installed" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame^] | 458 | if [ $(helm list --deployed --short --namespace voltha "^open-onu\$" | wc -l) -ne 1 ]; then |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 459 | espin - $NOT_VERIFIED |
| 460 | helm_install - voltha open-onu onf/voltha-adapter-openonu "Install OpenONU Adapter" |
| 461 | else |
| 462 | espin - $VERIFIED |
| 463 | fi |
| 464 | |
| 465 | ADAPTERS="adapter-.*" |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 466 | wait_for_pods - "voltha" 4 -1 "Waiting for adapters to start" $ADAPTERS |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 467 | |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame^] | 468 | if [ $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-.*" |
| 478 | fi |
| 479 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 480 | echo -e "Restart VOLTHA API $RESTART" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 481 | API="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 User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 483 | wait_for_pods - "voltha" 0 -1 "Wait for API to stop $STOP" $API |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 484 | (set -x; kubectl scale --replicas=1 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1 |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 485 | wait_for_pods - "voltha" 2 -1 "Wait for API to re-start $GO" $API |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 486 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 487 | bspin - "Forward VOLTHA API port $FORWARD" |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 488 | (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. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 490 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 491 | bspin - "Forward VOLTHA SSH port $FORWARD" |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 492 | (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. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 494 | espin - $VERIFIED |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 495 | |
| 496 | bspin - "Create voltctl configuration file" |
| 497 | (set -x; mkdir -p $HOME/.volt >>$LOG 2>&1) >>$LOG 2>&1 |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 498 | (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] | 499 | espin - $VERIFIED |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 500 | |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame^] | 501 | echo "" |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 502 | echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG |
| 503 | echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG |
| 504 | echo "tools required by VOLTHA in your command path. " | tee -a $LOG |
| 505 | echo "" | tee -a $LOG |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame^] | 506 | echo -en $BOLD |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 507 | 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] | 508 | echo "export VOLTCONFIG=\"$HOME/.volt/config-$TYPE\"" | tee -a $LOG |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 509 | echo 'export PATH=$GOPATH/bin:$PATH' | tee -a $LOG |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame^] | 510 | echo -en $NORMAL |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 511 | echo "" | tee -a $LOG |
| 512 | echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG |
| 513 | |