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