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