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 | BLACK=$(tput setaf 0) |
| 32 | RED=$(tput setaf 1) |
| 33 | GREEN=$(tput setaf 2) |
| 34 | YELLOW=$(tput setaf 3) |
| 35 | BLUE=$(tput setaf 4) |
| 36 | MAGENTA=$(tput setaf 5) |
| 37 | CYAN=$(tput setaf 6) |
| 38 | WHITE=$(tput setaf 7) |
| 39 | BOLD=$(tput bold) |
| 40 | NORMAL=$(tput sgr0) |
| 41 | ERROR="\xe2\x9c\x97\x20" |
| 42 | |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 43 | TYPE=${TYPE:-minimal} |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 44 | WITH_BBSIM=${WITH_BBSIM:-no} |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 45 | JUST_K8S=${JUST_K8S:-no} |
| 46 | DEPLOY_K8S=${DEPLOY_K8S:-yes} |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame^] | 47 | SKIP_RESTART_API=${SKIP_RESTART_API:-no} |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 48 | INSTALL_KUBECTL=${INSTALL_KUBECTL:-yes} |
| 49 | INSTALL_HELM=${INSTALL_HELM:-yes} |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame^] | 50 | VOLTHA_CHART=${VOLTHA_CHART:=onf/voltha} |
| 51 | VOLTHA_ADAPTER_SIM_CHART=${VOLTHA_ADAPTER_SIM_CHART:-onf/voltha-adapter-simulated} |
| 52 | VOLTHA_ADAPTER_OPEN_OLT_CHART=${VOLTHA_ADAPTER_OPEN_OLT_CHART:-onf/voltha-adapter-openolt} |
| 53 | VOLTHA_ADAPTER_OPEN_ONU_CHART=${VOLTHA_ADAPTER_OPEN_ONU_CHART:-onf/voltha-adapter-openonu} |
| 54 | VOLTHA_LOG_LEVEL=${VOLTHA_LOG_LEVEL:-WARN} |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 55 | |
| 56 | HAVE_GO=$(which go >/dev/null 2>&1 && echo "yes" || echo "no") |
| 57 | HOSTOS=$(uname -s | tr "[:upper:]" "[:lower:"]) |
| 58 | HOSTARCH=$(uname -m | tr "[:upper:]" "[:lower:"]) |
| 59 | if [ $HOSTARCH == "x86_64" ]; then |
| 60 | HOSTARCH="amd64" |
| 61 | fi |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 62 | |
| 63 | # Verify TYPE setting |
| 64 | if [ $(echo ":minimal:full:" | grep -ic ":$TYPE:") -eq 0 ]; then |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 65 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$TYPE value of '$TYPE'. Should be 'minimal' or 'full'${NORMAL}" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 66 | exit 1 |
| 67 | fi |
| 68 | |
| 69 | # Verify WITH_BBSIM settting and convert uniform value of yes or no |
| 70 | if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_BBSIM:") -eq 0 ]; then |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 71 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_BBSIM value of '$WITH_BBSIM'. Should be 'yes' or 'no'${NORMAL}" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 72 | exit 1 |
| 73 | fi |
| 74 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_BBSIM:") -eq 1 ]; then |
| 75 | WITH_BBSIM=yes |
| 76 | else |
| 77 | WITH_BBSIM=no |
| 78 | fi |
| 79 | |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 80 | # Verify JUST_K8S settting and convert uniform value of yes or no |
| 81 | if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$JUST_K8S:") -eq 0 ]; then |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 82 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$JUST_K8S value of '$JUST_K8S'. Should be 'yes' or 'no'${NORMAL}" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 83 | exit 1 |
| 84 | fi |
| 85 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$JUST_K8S:") -eq 1 ]; then |
| 86 | JUST_K8S=yes |
| 87 | else |
| 88 | JUST_K8S=no |
| 89 | fi |
| 90 | |
| 91 | # Verify DEPLOY_K8S settting and convert uniform value of yes or no |
| 92 | if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$DEPLOY_K8S:") -eq 0 ]; then |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 93 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$DEPLOY_K8S value of '$DEPLOY_K8S'. Should be 'yes' or 'no'${NORMAL}" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 94 | exit 1 |
| 95 | fi |
| 96 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$DEPLOY_K8S:") -eq 1 ]; then |
| 97 | DEPLOY_K8S=yes |
| 98 | else |
| 99 | DEPLOY_K8S=no |
| 100 | fi |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 101 | |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 102 | # Verify INSTALL_KUBECTL settting and convert uniform value of yes or no |
| 103 | if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$INSTALL_KUBECTL:") -eq 0 ]; then |
| 104 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$INSTALL_KUBECTL value of '$INSTALL_KUBECTL'. Should be 'yes' or 'no'${NORMAL}" |
| 105 | exit 1 |
| 106 | fi |
| 107 | |
| 108 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$INSTALL_KUBECTL:") -eq 1 ]; then |
| 109 | INSTALL_KUBECTL=yes |
| 110 | else |
| 111 | INSTALL_KUBECTL=no |
| 112 | fi |
| 113 | |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame^] | 114 | # Verify SKIP_RESTART_API settting and convert uniform value of yes or no |
| 115 | if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$SKIP_RESTART_API:") -eq 0 ]; then |
| 116 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$SKIP_RESTART_API value of '$SKIP_RESTART_API'. Should be 'yes' or 'no'${NORMAL}" |
| 117 | exit 1 |
| 118 | fi |
| 119 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$SKIP_RESTART_API:") -eq 1 ]; then |
| 120 | SKIP_RESTART_API=yes |
| 121 | else |
| 122 | SKIP_RESTART_API=no |
| 123 | fi |
| 124 | |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 125 | # Verify INSTALL_HELM settting and convert uniform value of yes or no |
| 126 | if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$INSTALL_HELM:") -eq 0 ]; then |
| 127 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$INSTALL_HELM value of '$INSTALL_HELM'. Should be 'yes' or 'no'${NORMAL}" |
| 128 | exit 1 |
| 129 | fi |
| 130 | |
| 131 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$INSTALL_HELM:") -eq 1 ]; then |
| 132 | INSTALL_HELM=yes |
| 133 | else |
| 134 | INSTALL_HELM=no |
| 135 | fi |
| 136 | |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 137 | if [ "$TYPE" == "full" ]; then |
| 138 | ONOS_API_PORT=${ONOS_API_PORT:-8182} |
| 139 | ONOS_SSH_PORT=${ONOS_SSH_PORT:-8102} |
| 140 | VOLTHA_API_PORT=${VOLTHA_API_PORT:-55556} |
| 141 | VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-5023} |
| 142 | else |
| 143 | ONOS_API_PORT=${ONOS_API_PORT:-8181} |
| 144 | ONOS_SSH_PORT=${ONOS_SSH_PORT:-8101} |
| 145 | VOLTHA_API_PORT=${VOLTHA_API_PORT:-55555} |
| 146 | VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-5022} |
| 147 | fi |
| 148 | |
| 149 | if [ "$1" == "get" -a "$2" == "voltconfig" ]; then |
| 150 | echo "$HOME/.volt/config-$TYPE" |
| 151 | exit |
| 152 | fi |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 153 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 154 | if [ $# -ne 1 -o $(echo ":up:down:" | grep -c ":$1:") -ne 1 ]; then |
| 155 | >&2 echo "up or down?" |
| 156 | exit 1 |
| 157 | fi |
| 158 | |
| 159 | if [ "$1" == "down" ]; then |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 160 | if [ $DEPLOY_K8S == "yes" ]; then |
| 161 | if [ -x ./bin/kind ]; then |
| 162 | exec ./bin/kind delete cluster --name voltha-$TYPE |
| 163 | else |
| 164 | >&2 echo "Kind doesn't seem to be installed, so nothing to do. Bye." |
| 165 | fi |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 166 | else |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 167 | EXISTS=$(helm list -q) |
| 168 | EXPECT="etcd-operator onos open-olt open-onu sim voltha" |
| 169 | INTERSECT= |
| 170 | for i in $EXISTS; do |
| 171 | if [ $(echo $EXPECT | grep -c $i) -eq 1 ]; then |
| 172 | HAVE="$HAVE $i" |
| 173 | fi |
| 174 | done |
| 175 | ./bin/helm delete --purge $HAVE |
| 176 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 177 | exit |
| 178 | fi |
| 179 | |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 180 | LOG="install-$TYPE.log" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 181 | date > $LOG |
| 182 | |
| 183 | spin() { |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 184 | PARTS="\ |
| 185 | \xe2\xa2\x8e\xe2\xa1\xb0 \ |
| 186 | \xe2\xa2\x8e\xe2\xa1\xa1 \ |
| 187 | \xe2\xa2\x8e\xe2\xa1\x91 \ |
| 188 | \xe2\xa2\x8e\xe2\xa0\xb1 \ |
| 189 | \xe2\xa0\x8e\xe2\xa1\xb1 \ |
| 190 | \xe2\xa2\x8a\xe2\xa1\xb1 \ |
| 191 | \xe2\xa2\x8c\xe2\xa1\xb1 \ |
| 192 | \xe2\xa2\x86\xe2\xa1\xb1 \ |
| 193 | " |
| 194 | IDX=1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 195 | tput civis |
| 196 | while true; do |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 197 | C=$(echo $PARTS | cut '-d ' -f $IDX) |
| 198 | echo -en "$C" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 199 | IDX=$(expr $IDX + 1) |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 200 | if [ $IDX -gt 8 ]; then |
| 201 | IDX=1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 202 | fi |
| 203 | sleep .15 |
| 204 | echo -en "\r" |
| 205 | done |
| 206 | } |
| 207 | |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 208 | SPIN_PARTS="\ |
| 209 | \xe2\xa2\x8e\xe2\xa1\xb0 \ |
| 210 | \xe2\xa2\x8e\xe2\xa1\xa1 \ |
| 211 | \xe2\xa2\x8e\xe2\xa1\x91 \ |
| 212 | \xe2\xa2\x8e\xe2\xa0\xb1 \ |
| 213 | \xe2\xa0\x8e\xe2\xa1\xb1 \ |
| 214 | \xe2\xa2\x8a\xe2\xa1\xb1 \ |
| 215 | \xe2\xa2\x8c\xe2\xa1\xb1 \ |
| 216 | \xe2\xa2\x86\xe2\xa1\xb1 \ |
| 217 | " |
| 218 | IDX=1 |
| 219 | NOT_VERIFIED="\xe2\x9c\x97\x20" |
| 220 | VERIFIED="\xe2\x9c\x93\x20" |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 221 | HELM="\xE2\x8E\x88" |
| 222 | OLD_KEY="\xF0\x9F\x97\x9D" |
| 223 | BIRD="\xF0\x9F\x90\xA6" |
| 224 | HIGH_VOLTAGE="\xE2\x9A\xA1" |
| 225 | PLUG="\xF0\x9F\xa7\xa9" |
| 226 | RESTART="\xf0\x9f\x94\x84" |
| 227 | FORWARD="\xE2\x87\xA8" |
| 228 | INSTALL="\xF0\x9F\x8F\x97" |
| 229 | STOP="\xf0\x9f\x9b\x91" |
| 230 | GO="\xf0\x9f\x9a\x80" |
| 231 | DOWNLOAD="\xf0\x9f\x93\xa5" |
| 232 | GEAR="\xe2\x9a\x99" |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 233 | NO_ENTRY="\xe2\x9b\x94" |
| 234 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 235 | bspin() { |
| 236 | tput civis |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 237 | IDX=1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 238 | local INDENT= |
| 239 | if [ "$1" == "-" ]; then |
| 240 | INDENT=" " |
| 241 | shift |
| 242 | fi |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 243 | echo -en "$INDENT $*" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | sspin() { |
| 247 | local INDENT= |
| 248 | if [ "$1" == "-" ]; then |
| 249 | INDENT=" " |
| 250 | shift |
| 251 | fi |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 252 | C=$(echo $SPIN_PARTS | cut '-d ' -f $IDX) |
| 253 | echo -en "\r$INDENT$C $*" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 254 | IDX=$(expr $IDX + 1) |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 255 | if [ $IDX -gt 8 ]; then |
| 256 | IDX=1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 257 | fi |
| 258 | } |
| 259 | |
| 260 | espin() { |
| 261 | local INDENT= |
| 262 | if [ "$1" == "-" ]; then |
| 263 | INDENT=" " |
| 264 | shift |
| 265 | fi |
| 266 | echo -e "\r$INDENT$*" |
| 267 | tput cnorm |
| 268 | } |
| 269 | |
| 270 | count_pods() { |
| 271 | local NAMESPACE=$1; shift |
| 272 | local PODS=$(kubectl -n $NAMESPACE get pod -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}") |
| 273 | local COUNT=0 |
| 274 | local PATTERNS=$* |
| 275 | for POD in $PODS; do |
| 276 | local NAME=$(echo $POD | cut -d/ -f 1) |
| 277 | local STATE=$(echo $POD | cut -d/ -f 2) |
| 278 | local CONTAINERS=$(echo $POD | cut -d/ -f 3 | sed -e 's/_/ /g') |
| 279 | if [ "$STATE" == "Running" ]; then |
| 280 | local TOTAL=$(echo $CONTAINERS | wc -w) |
| 281 | local FOUND=$(echo $CONTAINERS | grep -o true | wc -l) |
| 282 | if [ $TOTAL -eq $FOUND ]; then |
| 283 | for PATTERN in $PATTERNS; do |
| 284 | if [[ $NAME =~ $PATTERN ]]; then |
| 285 | COUNT=$(expr $COUNT + 1) |
| 286 | fi |
| 287 | done |
| 288 | fi |
| 289 | fi |
| 290 | done |
| 291 | echo $COUNT |
| 292 | } |
| 293 | |
| 294 | wait_for_pods() { |
| 295 | local INDENT= |
| 296 | if [ "$1" == "-" ]; then |
| 297 | INDENT=$1; shift |
| 298 | fi |
| 299 | local NAMESPACE=$1; shift |
| 300 | local EXPECT=$1; shift |
| 301 | local RETRY=$1; shift |
| 302 | local MESSAGE=$1; shift |
| 303 | local PATTERNS=$* |
| 304 | local HAVE=$(count_pods $NAMESPACE $PATTERNS) |
| 305 | COUNT=$(expr 300 / 15) |
| 306 | bspin $INDENT $MESSAGE |
| 307 | sspin $INDENT |
| 308 | if [ $HAVE -ne $EXPECT ]; then |
| 309 | while [ $HAVE -ne $EXPECT ]; do |
| 310 | sspin $INDENT |
| 311 | COUNT=$(expr $COUNT - 1) |
| 312 | if [ $COUNT -eq 0 ]; then |
| 313 | HAVE=$(count_pods $NAMESPACE $PATTERNS) |
| 314 | COUNT=$(expr 300 / 15) |
| 315 | fi |
| 316 | sleep .15 |
| 317 | done |
| 318 | fi |
| 319 | espin $INDENT $VERIFIED |
| 320 | if [ $HAVE -ne $EXPECT ]; then |
| 321 | return 1 |
| 322 | fi |
| 323 | return 0 |
| 324 | } |
| 325 | |
| 326 | helm_install() { |
| 327 | local INDENT= |
| 328 | if [ "$1" == "-" ]; then |
| 329 | INDENT=$1; shift |
| 330 | fi |
| 331 | local NAMESPACE=$1; shift |
| 332 | local NAME=$1; shift |
| 333 | local CHART=$1; shift |
| 334 | local MESSAGE=$* |
| 335 | |
| 336 | COUNT=$(expr 300 / 15) |
| 337 | bspin $INDENT $MESSAGE |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame^] | 338 | (set -x; helm install -f $TYPE-values.yaml --set defaults.log_level=$VOLTHA_LOG_LEVEL --namespace $NAMESPACE --name $NAME $CHART >>$LOG 2>&1) >>$LOG 2>&1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 339 | SUCCESS=$? |
| 340 | while [ $SUCCESS -ne 0 ]; do |
| 341 | sspin $INDENT |
| 342 | COUNT=$(expr $COUNT - 1) |
| 343 | if [ $COUNT -eq 0 ]; then |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame^] | 344 | (set -x; helm install -f $TYPE-values.yaml --set defaults.log_level=$VOLTHA_LOG_LEVEL --namespace $NAMESPACE --name $NAME $CHART >>$LOG 2>&1) >>$LOG 2>&1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 345 | COUNT=$(expr 300 / 15) |
| 346 | fi |
| 347 | sleep .15 |
| 348 | done |
| 349 | espin $INDENT $VERIFIED |
| 350 | } |
| 351 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 352 | echo "INSTALL TYPE: $TYPE" >> $LOG |
| 353 | |
| 354 | bspin "Verify GOPATH" |
| 355 | export GOPATH=$(pwd) |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 356 | mkdir -p $GOPATH/bin |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 357 | espin $VERIFIED |
| 358 | |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 359 | if [ "$INSTALL_KUBECTL" == "no" ]; then |
| 360 | bspin "Skip kubectl install" |
| 361 | espin $NO_ENTRY |
Test User | c13bdc9 | 2019-07-03 20:57:49 +0000 | [diff] [blame] | 362 | else |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 363 | bspin "Verify kubectl $HELM" |
| 364 | if [ -x $GOPATH/bin/kubectl ]; then |
| 365 | espin $VERIFIED |
| 366 | else |
| 367 | espin $NOT_VERIFIED |
| 368 | bspin - "Download and install Kubernetes/kubectl $DOWNLOAD" |
| 369 | (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 |
| 370 | (set -x; chmod 755 $GOPATH/bin/kubectl >>$LOG 2>&1) >>$LOG 2>&1 |
| 371 | espin - $VERIFIED |
| 372 | fi |
Test User | c13bdc9 | 2019-07-03 20:57:49 +0000 | [diff] [blame] | 373 | fi |
| 374 | |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 375 | if [ "$DEPLOY_K8S" == "no" ]; then |
| 376 | bspin "Skip Kubernetes/Kind Deployment" |
| 377 | espin $NO_ENTRY |
| 378 | else |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 379 | bspin "Verify Kubernetes/Kind $HELM" |
| 380 | if [ -x $GOPATH/bin/kind ]; then |
| 381 | espin $VERIFIED |
| 382 | else |
| 383 | espin $NOT_VERIFIED |
| 384 | bspin - "Download and install Kubernetes/kind $DOWNLOAD" |
David Bainbridge | 9e2a666 | 2019-07-11 17:07:57 +0000 | [diff] [blame] | 385 | (set -x; curl -o $GOPATH/bin/kind -sSL https://github.com/kubernetes-sigs/kind/releases/download/$KIND_VERSION/kind-$HOSTOS-$HOSTARCH >>$LOG 2>&1) >>$LOG 2>&1 |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 386 | (set -x; chmod 755 $GOPATH/bin/kind >>$LOG 2>&1) >>$LOG 2>&1 |
| 387 | espin - $VERIFIED |
| 388 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 389 | fi |
| 390 | |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 391 | if [ "$INSTALL_HELM" == "no" ]; then |
| 392 | bspin "Skip Helm Install" |
| 393 | espin $NO_ENTRY |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 394 | else |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 395 | bspin "Verify Helm $HELM" |
| 396 | if [ -x $GOPATH/bin/helm ]; then |
| 397 | espin $VERIFIED |
| 398 | else |
| 399 | espin $NOT_VERIFIED |
| 400 | bspin - "Download and install Helm $DOWNLOAD" |
| 401 | (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 |
| 402 | espin - $VERIFIED |
| 403 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 404 | fi |
| 405 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 406 | bspin "Verify voltctl $HIGH_VOLTAGE" |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 407 | if [ -x $GOPATH/bin/voltctl ]; then |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 408 | espin $VERIFIED |
| 409 | else |
| 410 | espin $NOT_VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 411 | bspin - "Download and build voltctl $DOWNLOAD" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 412 | (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 User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 413 | (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] | 414 | espin - $VERIFIED |
| 415 | fi |
| 416 | |
| 417 | bspin "Verify command PATH" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 418 | export PATH=$GOPATH/bin:$PATH |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 419 | espin $VERIFIED |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 420 | |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 421 | if [ "$DEPLOY_K8S" == "yes" ]; then |
| 422 | HAVE=$(kind get clusters | grep -c voltha-$TYPE) |
| 423 | bspin "Verify Kubernetes/Kind Cluster" |
| 424 | sspin |
| 425 | if [ $HAVE -eq 0 ]; then |
David Bainbridge | 491b1bd | 2019-07-11 17:53:11 +0000 | [diff] [blame] | 426 | espin $NOT_VERIFIED |
| 427 | bspin - "Verify cluster configuration" |
| 428 | if [ ! -r ./$TYPE-cluster.cfg ]; then |
| 429 | espin - $NOT_VERIFIED |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 430 | bspin - "Download cluster configuration: $TYPE-cluster.cfg $DOWNLOAD" |
David Bainbridge | 491b1bd | 2019-07-11 17:53:11 +0000 | [diff] [blame] | 431 | (set -x; curl -o ./$TYPE-cluster.cfg -sSL https://raw.githubusercontent.com/ciena/kind-voltha/master/$TYPE-cluster.cfg >>$LOG 2>&1) >>$LOG 2>&1 |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 432 | espin - $VERIFIED |
| 433 | else |
| 434 | espin - $VERIFIED |
| 435 | fi |
David Bainbridge | 491b1bd | 2019-07-11 17:53:11 +0000 | [diff] [blame] | 436 | kind create cluster --name voltha-$TYPE --config $TYPE-cluster.cfg |
| 437 | else |
| 438 | espin $VERIFIED |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 439 | fi |
| 440 | |
| 441 | export KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$TYPE")" |
| 442 | P="coredns-.* \ |
| 443 | etcd-voltha-$TYPE-control-plane \ |
| 444 | kindnet-.* \ |
| 445 | kube-apiserver-voltha-$TYPE-control-plane \ |
| 446 | kube-controller-manager-voltha-$TYPE-control-plane \ |
| 447 | kube-proxy-.* \ |
| 448 | kube-scheduler-voltha-$TYPE-control-plane" |
| 449 | |
| 450 | EXPECT=$(test "$TYPE" == "minimal" && echo "12" || echo "14") |
| 451 | 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] | 452 | fi |
| 453 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 454 | COUNT=$(count_pods "kube-system" "tiller-deploy-.*") |
| 455 | bspin "Verify Helm" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 456 | if [ $COUNT -ne 1 ]; then |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 457 | espin $NOT_VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 458 | echo -e "Configuring Helm $GEAR" |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 459 | if [ "$INSTALL_HELM" == "no" ]; then |
| 460 | bspin - "Skip Helm/Tiller Initialization" |
| 461 | espin - $NO_ENTRY |
| 462 | else |
| 463 | bspin - "Initialize Helm" |
| 464 | (set -x; helm init --upgrade >>$LOG 2>&1) >>$LOG 2>&1 |
| 465 | espin - $VERIFIED |
| 466 | wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start" "tiller-deploy-.*" |
| 467 | fi |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 468 | bspin - "Add Google Incubator repository to Helm" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 469 | (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1 |
| 470 | espin - $VERIFIED |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 471 | |
| 472 | # HACK (sort-of) - the config for tiller is about to be patched, which will |
| 473 | # cause the tiller pod to be recreated. This can sometimes cause a timing |
| 474 | # issue with the "wait_for_pods" call on tiller as it may incorrectly |
| 475 | # identify the running/ready tiller pod that is soon to be terminated as |
| 476 | # what it is waiting for. To avoid this issue we do a clean scale down and |
| 477 | # scale up of the pod so the script controlls when it should be expecting |
| 478 | # things |
| 479 | (set -x; kubectl -n kube-system scale deploy tiller-deploy --replicas=0 >>$LOG 2>&1) >>$LOG 2>&1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 480 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 481 | bspin - "Add Google Stable repository to Helm" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 482 | (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1 |
| 483 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 484 | bspin - "Add ONF repository to Helm" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 485 | (set -x; helm repo add onf https://charts.opencord.org >>$LOG 2>&1) >>$LOG 2>&1 |
| 486 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 487 | bspin - "Update Helm repository cache" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 488 | (set -x; helm repo update >>$LOG 2>&1) >>$LOG 2>&1 |
| 489 | espin - $VERIFIED |
| 490 | |
| 491 | # Create and k8s service account so that Helm can create pods |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 492 | bspin - "Create Tiller ServiceAccount" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 493 | (set -x; kubectl create serviceaccount --namespace kube-system tiller >>$LOG 2>&1) >>$LOG 2>&1 |
| 494 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 495 | bspin - "Create Tiller ClusterRoleBinding" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 496 | (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>$LOG 2>&1) >>$LOG 2>&1 |
| 497 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 498 | bspin - "Update Tiller Manifest" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 499 | (set -x; kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}' >>$LOG 2>&1) >>$LOG 2>&1 |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 500 | |
| 501 | # HACK (sort-of) - part to, spin it back up |
| 502 | (set -x; kubectl -n kube-system scale deploy tiller-deploy --replicas=1 >>$LOG 2>&1) >>$LOG 2>&1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 503 | espin - $VERIFIED |
| 504 | else |
| 505 | espin $VERIFIED |
| 506 | fi |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 507 | 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] | 508 | |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 509 | bspin "Verify Helm values file: $TYPE-values.yaml" |
| 510 | if [ ! -r "./$TYPE-values.yaml" ]; then |
| 511 | espin $NOT_VERIFIED |
| 512 | bspin - "Download Helm values file: $TYPE-values.yaml $DOWNLOAD" |
| 513 | (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 |
| 514 | espin - $VERIFIED |
| 515 | else |
| 516 | espin $VERIFIED |
| 517 | fi |
| 518 | |
| 519 | if [ "$JUST_K8S" == "yes" ]; then |
| 520 | echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye." |
| 521 | echo "" |
| 522 | echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG |
| 523 | echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG |
| 524 | echo "tools required by VOLTHA in your command path. " | tee -a $LOG |
| 525 | echo "" | tee -a $LOG |
| 526 | echo -en $BOLD |
| 527 | if [ $DEPLOY_K8S == "yes" ]; then |
| 528 | echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$TYPE\")\"" | tee -a $LOG |
| 529 | fi |
| 530 | echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG |
| 531 | echo -en $NORMAL |
| 532 | echo "" | tee -a $LOG |
| 533 | echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG |
| 534 | exit 0 |
| 535 | fi |
| 536 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 537 | bspin "Verify ETCD Operator $OLD_KEY" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 538 | 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] | 539 | espin $NOT_VERIFIED |
| 540 | helm_install - voltha etcd-operator stable/etcd-operator "Install ETCD Operator" |
| 541 | else |
| 542 | espin $VERIFIED |
| 543 | fi |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 544 | EXPECT=$(test "$TYPE" == "minimal" && echo "1" || echo "3") |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 545 | 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] | 546 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 547 | bspin "Verify ONOS installed $BIRD" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 548 | 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] | 549 | espin $NOT_VERIFIED |
| 550 | helm_install - default onos onf/onos "Install ONOS" |
| 551 | else |
| 552 | espin $VERIFIED |
| 553 | fi |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 554 | 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] | 555 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 556 | bspin - "Forward ONOS API port $FORWARD" |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 557 | (set -x; screen -p 0 -X -S onos-ui-$TYPE stuff $'\003' >>$LOG 2>&1) >>$LOG 2>&1 |
| 558 | (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] | 559 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 560 | bspin - "Forward ONOS SSH port $FORWARD" |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 561 | (set -x; screen -p 0 -X -S onos-ssh-$TYPE stuff $'\003' >>$LOG 2>&1) >>$LOG 2>&1 |
| 562 | (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] | 563 | espin - $VERIFIED |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 564 | if [ ! -x ./onos-files/install-onos-applications.sh ]; then |
| 565 | bspin - "Verify or download ONOS configuration support files $DOWNLOAD" |
| 566 | (set -x; mkdir -p ./onos-files >>$LOG 2>&1) >>$LOG 2>&1 |
| 567 | 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 |
| 568 | if [ ! -r ./onos-files/$i ]; then |
| 569 | (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 |
| 570 | fi |
| 571 | done |
| 572 | (set -x; chmod 755 ./onos-files/install-onos-applications.sh >>$LOG 2>&1) >>$LOG 2>&1 |
| 573 | espin - $VERIFIED |
| 574 | fi |
| 575 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 576 | bspin - "Install required ONOS applications $INSTALL" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 577 | (set -x; ./onos-files/install-onos-applications.sh >>$LOG 2>&1) >>$LOG 2>&1 |
| 578 | espin - $VERIFIED |
| 579 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 580 | bspin "Verify VOLTHA installed $HIGH_VOLTAGE" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 581 | 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] | 582 | espin $NOT_VERIFIED |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame^] | 583 | helm_install - voltha voltha $VOLTHA_CHART "Install VOLTHA Core" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 584 | else |
| 585 | espin $VERIFIED |
| 586 | fi |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 587 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 588 | VOLTHA="ofagent-.* \ |
| 589 | ro-core.* \ |
| 590 | rw-core.* \ |
| 591 | voltha-api-server-.* \ |
| 592 | voltha-cli-server-.* \ |
| 593 | voltha-etcd-cluster-.* \ |
| 594 | voltha-kafka-.* \ |
| 595 | voltha-zookeeper-.*" |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 596 | EXPECT=$(test "$TYPE" == "minimal" && echo "9" || echo "11") |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 597 | 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] | 598 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 599 | echo -e "Verify Adapters $PLUG" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 600 | bspin - "Verify Simulated Adapters installed" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 601 | 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] | 602 | espin - $NOT_VERIFIED |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame^] | 603 | helm_install - voltha sim $VOLTHA_ADAPTER_SIM_CHART "Install Simulated Adapters" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 604 | else |
| 605 | espin - $VERIFIED |
| 606 | fi |
| 607 | |
| 608 | bspin - "Verify OpenOLT Adapter installed" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 609 | 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] | 610 | espin - $NOT_VERIFIED |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame^] | 611 | helm_install - voltha open-olt $VOLTHA_ADAPTER_OPEN_OLT_CHART "Install OpenOLT Adapter" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 612 | else |
| 613 | espin - $VERIFIED |
| 614 | fi |
| 615 | bspin - "Verify OpenONU Adapter installed" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 616 | 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] | 617 | espin - $NOT_VERIFIED |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame^] | 618 | helm_install - voltha open-onu $VOLTHA_ADAPTER_OPEN_ONU_CHART "Install OpenONU Adapter" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 619 | else |
| 620 | espin - $VERIFIED |
| 621 | fi |
| 622 | |
| 623 | ADAPTERS="adapter-.*" |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 624 | 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] | 625 | |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 626 | if [ $WITH_BBSIM == "yes" ]; then |
| 627 | echo -e "Verify BBSIM $PLUG" |
| 628 | bspin - "Verify BBSIM Insalled" |
| 629 | if [ $(helm list --deployed --short --namespace voltha "^bbsim\$" | wc -l) -ne 1 ]; then |
| 630 | espin - $NOT_VERIFIED |
| 631 | helm_install - voltha bbsim onf/bbsim "Install BBSIM" |
| 632 | else |
| 633 | espin - $VERIFIED |
| 634 | fi |
| 635 | wait_for_pods - "voltha" 1 -1 "Waiting for BBSIM to start" "bbsim-.*" |
| 636 | fi |
| 637 | |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame^] | 638 | if [ $SKIP_RESTART_API == "no" ]; then |
| 639 | echo -e "Restart VOLTHA API $RESTART" |
| 640 | API="voltha-api-server-.* ofagent-.*" |
| 641 | (set -x; kubectl scale --replicas=0 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1 |
| 642 | wait_for_pods - "voltha" 0 -1 "Wait for API to stop $STOP" $API |
| 643 | (set -x; kubectl scale --replicas=1 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1 |
| 644 | wait_for_pods - "voltha" 2 -1 "Wait for API to re-start $GO" $API |
| 645 | else |
| 646 | bspin "Skip VOLTHA API Restart" |
| 647 | espin $NO_ENTRY |
| 648 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 649 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 650 | bspin - "Forward VOLTHA API port $FORWARD" |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 651 | (set -x; screen -p 0 -X -S voltha-api-$TYPE stuff $'\003' >>$LOG 2>&1) >>$LOG 2>&1 |
| 652 | (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] | 653 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 654 | bspin - "Forward VOLTHA SSH port $FORWARD" |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 655 | (set -x; screen -p 0 -X -S voltha-ssh-$TYPE stuff $'\003' 2>/dev/null >/dev/null >>$LOG 2>&1) >>$LOG 2>&1 |
| 656 | (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] | 657 | espin - $VERIFIED |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 658 | |
| 659 | bspin - "Create voltctl configuration file" |
| 660 | (set -x; mkdir -p $HOME/.volt >>$LOG 2>&1) >>$LOG 2>&1 |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 661 | (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] | 662 | espin - $VERIFIED |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 663 | |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 664 | echo "" |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 665 | echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG |
| 666 | echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG |
| 667 | echo "tools required by VOLTHA in your command path. " | tee -a $LOG |
| 668 | echo "" | tee -a $LOG |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 669 | echo -en $BOLD |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 670 | if [ $DEPLOY_K8S == "yes" ]; then |
| 671 | echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$TYPE\")\"" | tee -a $LOG |
| 672 | fi |
Test User | fa30f7f | 2019-07-03 20:35:19 +0000 | [diff] [blame] | 673 | echo "export VOLTCONFIG=\"$HOME/.volt/config-$TYPE\"" | tee -a $LOG |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 674 | echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 675 | echo -en $NORMAL |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 676 | echo "" | tee -a $LOG |
| 677 | echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG |
| 678 | |