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. |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame^] | 15 | TOTAL_START_TIME=$(date +%s) |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 16 | |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 17 | FANCY=${FANCY:-1} |
| 18 | if [ "$TERM X" == " X" ]; then |
| 19 | FANCY=0 |
| 20 | fi |
| 21 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 22 | # trap ctrl-c and call ctrl_c() |
| 23 | trap ctrl_c INT |
| 24 | |
| 25 | function ctrl_c() { |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 26 | echo -en $CNORM |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 27 | echo "" |
| 28 | echo "ctrl-c trapped" |
| 29 | echo "Thank you for trying 'votlha up'" |
| 30 | exit |
| 31 | } |
| 32 | |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 33 | VOLTCTL_VERSION=${VOLTCTL_VERSION:-0.0.5-dev} |
| 34 | KIND_VERSION=${KIND_VERSION:-v0.4.0} |
| 35 | _VOLTCTL_VERSION=$(echo $VOLTCTL_VERSION | sed -e 's/-/_/g') |
| 36 | |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 37 | BLACK= |
| 38 | RED= |
| 39 | GREEN= |
| 40 | YELLOW= |
| 41 | BLUE= |
| 42 | MAGENTA= |
| 43 | CYAN= |
| 44 | WHITE= |
| 45 | BOLD= |
| 46 | NORMAL= |
| 47 | ERROR= |
| 48 | CEOL= |
| 49 | CNORM= |
| 50 | CIVIS= |
| 51 | if [ $FANCY -eq 1 ]; then |
| 52 | BLACK=$(tput setaf 0) |
| 53 | RED=$(tput setaf 1) |
| 54 | GREEN=$(tput setaf 2) |
| 55 | YELLOW=$(tput setaf 3) |
| 56 | BLUE=$(tput setaf 4) |
| 57 | MAGENTA=$(tput setaf 5) |
| 58 | CYAN=$(tput setaf 6) |
| 59 | WHITE=$(tput setaf 7) |
| 60 | BOLD=$(tput bold) |
| 61 | NORMAL=$(tput sgr0) |
| 62 | ERROR="\xe2\x9c\x97\x20" |
| 63 | CEOL=$(tput el) |
| 64 | CNORM=$(tput cnorm) |
| 65 | CIVIS=$(tput civis) |
| 66 | fi |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 67 | |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 68 | TYPE=${TYPE:-minimal} |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 69 | NAME=${NAME:-$TYPE} |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 70 | WITH_TIMINGS=${WITH_TIMINGS:-no} |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 71 | WITH_BBSIM=${WITH_BBSIM:-no} |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 72 | WITH_RADIUS=${WITH_RADIUS:-no} |
David Bainbridge | b270c20 | 2019-07-26 01:44:42 +0000 | [diff] [blame] | 73 | WITH_ONOS=${WITH_ONOS:-yes} |
David Bainbridge | 27790d6 | 2019-08-13 22:43:19 +0000 | [diff] [blame] | 74 | INSTALL_ONOS_APPS=${INSTALL_ONOS_APPS:-no} |
David Bainbridge | 0129495 | 2019-07-30 19:33:45 +0000 | [diff] [blame] | 75 | WITH_TP=${WITH_TP:-yes} |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 76 | JUST_K8S=${JUST_K8S:-no} |
| 77 | DEPLOY_K8S=${DEPLOY_K8S:-yes} |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame] | 78 | SKIP_RESTART_API=${SKIP_RESTART_API:-no} |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 79 | INSTALL_KUBECTL=${INSTALL_KUBECTL:-yes} |
| 80 | INSTALL_HELM=${INSTALL_HELM:-yes} |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 81 | USE_GO=${USE_GO:-yes} |
| 82 | VOLTHA_LOG_LEVEL=${VOLTHA_LOG_LEVEL:-WARN} |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame] | 83 | VOLTHA_CHART=${VOLTHA_CHART:=onf/voltha} |
| 84 | VOLTHA_ADAPTER_SIM_CHART=${VOLTHA_ADAPTER_SIM_CHART:-onf/voltha-adapter-simulated} |
| 85 | VOLTHA_ADAPTER_OPEN_OLT_CHART=${VOLTHA_ADAPTER_OPEN_OLT_CHART:-onf/voltha-adapter-openolt} |
| 86 | 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] | 87 | |
| 88 | HAVE_GO=$(which go >/dev/null 2>&1 && echo "yes" || echo "no") |
| 89 | HOSTOS=$(uname -s | tr "[:upper:]" "[:lower:"]) |
| 90 | HOSTARCH=$(uname -m | tr "[:upper:]" "[:lower:"]) |
| 91 | if [ $HOSTARCH == "x86_64" ]; then |
| 92 | HOSTARCH="amd64" |
| 93 | fi |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 94 | |
| 95 | # Verify TYPE setting |
| 96 | if [ $(echo ":minimal:full:" | grep -ic ":$TYPE:") -eq 0 ]; then |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 97 | >&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] | 98 | exit 1 |
| 99 | fi |
| 100 | |
| 101 | # Verify WITH_BBSIM settting and convert uniform value of yes or no |
| 102 | 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] | 103 | >&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] | 104 | exit 1 |
| 105 | fi |
| 106 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_BBSIM:") -eq 1 ]; then |
| 107 | WITH_BBSIM=yes |
| 108 | else |
| 109 | WITH_BBSIM=no |
| 110 | fi |
| 111 | |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 112 | # Verify WITH_RADIUS settting and convert uniform value of yes or no |
| 113 | if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_RADIUS:") -eq 0 ]; then |
| 114 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_RADIUS value of '$WITH_RADIUS'. Should be 'yes' or 'no'${NORMAL}" |
| 115 | exit 1 |
| 116 | fi |
| 117 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_RADIUS:") -eq 1 ]; then |
| 118 | WITH_RADIUS=yes |
| 119 | else |
| 120 | WITH_RADIUS=no |
| 121 | fi |
| 122 | |
David Bainbridge | 0129495 | 2019-07-30 19:33:45 +0000 | [diff] [blame] | 123 | # Verify WITH_TP settting and convert uniform value of yes or no |
| 124 | if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_TP:") -eq 0 ]; then |
| 125 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_TP value of '$WITH_TP'. Should be 'yes' or 'no'${NORMAL}" |
| 126 | exit 1 |
| 127 | fi |
| 128 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_TP:") -eq 1 ]; then |
| 129 | WITH_TP=yes |
| 130 | else |
| 131 | WITH_TP=no |
| 132 | fi |
| 133 | |
David Bainbridge | b270c20 | 2019-07-26 01:44:42 +0000 | [diff] [blame] | 134 | # Verify WITH_ONOS settting and convert uniform value of yes or no |
| 135 | if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_ONOS:") -eq 0 ]; then |
| 136 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_ONOS value of '$WITH_ONOS'. Should be 'yes' or 'no'${NORMAL}" |
| 137 | exit 1 |
| 138 | fi |
| 139 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_ONOS:") -eq 1 ]; then |
| 140 | WITH_ONOS=yes |
| 141 | else |
| 142 | WITH_ONOS=no |
| 143 | fi |
| 144 | |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 145 | # Verify JUST_K8S settting and convert uniform value of yes or no |
| 146 | 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] | 147 | >&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] | 148 | exit 1 |
| 149 | fi |
| 150 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$JUST_K8S:") -eq 1 ]; then |
| 151 | JUST_K8S=yes |
| 152 | else |
| 153 | JUST_K8S=no |
| 154 | fi |
| 155 | |
| 156 | # Verify DEPLOY_K8S settting and convert uniform value of yes or no |
| 157 | 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] | 158 | >&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] | 159 | exit 1 |
| 160 | fi |
| 161 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$DEPLOY_K8S:") -eq 1 ]; then |
| 162 | DEPLOY_K8S=yes |
| 163 | else |
| 164 | DEPLOY_K8S=no |
| 165 | fi |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 166 | |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 167 | # Verify INSTALL_KUBECTL settting and convert uniform value of yes or no |
| 168 | if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$INSTALL_KUBECTL:") -eq 0 ]; then |
| 169 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$INSTALL_KUBECTL value of '$INSTALL_KUBECTL'. Should be 'yes' or 'no'${NORMAL}" |
| 170 | exit 1 |
| 171 | fi |
| 172 | |
| 173 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$INSTALL_KUBECTL:") -eq 1 ]; then |
| 174 | INSTALL_KUBECTL=yes |
| 175 | else |
| 176 | INSTALL_KUBECTL=no |
| 177 | fi |
| 178 | |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame] | 179 | # Verify SKIP_RESTART_API settting and convert uniform value of yes or no |
| 180 | if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$SKIP_RESTART_API:") -eq 0 ]; then |
| 181 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$SKIP_RESTART_API value of '$SKIP_RESTART_API'. Should be 'yes' or 'no'${NORMAL}" |
| 182 | exit 1 |
| 183 | fi |
| 184 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$SKIP_RESTART_API:") -eq 1 ]; then |
| 185 | SKIP_RESTART_API=yes |
| 186 | else |
| 187 | SKIP_RESTART_API=no |
| 188 | fi |
| 189 | |
David Bainbridge | 1ceabc1 | 2019-07-25 17:21:05 +0000 | [diff] [blame] | 190 | # Verify USE_GO settting and convert uniform value of yes or no |
| 191 | if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$USE_GO:") -eq 0 ]; then |
| 192 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$USE_GO value of '$USE_GO'. Should be 'yes' or 'no'${NORMAL}" |
| 193 | exit 1 |
| 194 | fi |
| 195 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$USE_GO:") -eq 1 ]; then |
| 196 | USE_GO=true |
| 197 | else |
| 198 | USE_GO=false |
| 199 | fi |
| 200 | |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 201 | # Verify INSTALL_HELM settting and convert uniform value of yes or no |
| 202 | if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$INSTALL_HELM:") -eq 0 ]; then |
| 203 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$INSTALL_HELM value of '$INSTALL_HELM'. Should be 'yes' or 'no'${NORMAL}" |
| 204 | exit 1 |
| 205 | fi |
| 206 | |
| 207 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$INSTALL_HELM:") -eq 1 ]; then |
| 208 | INSTALL_HELM=yes |
| 209 | else |
| 210 | INSTALL_HELM=no |
| 211 | fi |
| 212 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 213 | # Verify WITH_TIMINGS settting and convert uniform value of yes or no |
| 214 | if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_TIMINGS:") -eq 0 ]; then |
| 215 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_TIMINGS value of '$WITH_TIMINGS'. Should be 'yes' or 'no'${NORMAL}" |
| 216 | exit 1 |
| 217 | fi |
| 218 | |
| 219 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_TIMINGS:") -eq 1 ]; then |
| 220 | WITH_TIMINGS=yes |
| 221 | else |
| 222 | WITH_TIMINGS=no |
| 223 | fi |
| 224 | |
David Bainbridge | 27790d6 | 2019-08-13 22:43:19 +0000 | [diff] [blame] | 225 | # Verify INSTALL_ONOS_APPS settting and convert uniform value of yes or no |
| 226 | if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$INSTALL_ONOS_APPS:") -eq 0 ]; then |
| 227 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$INSTALL_ONOS_APPS value of '$INSTALL_ONOS_APPS'. Should be 'yes' or 'no'${NORMAL}" |
| 228 | exit 1 |
| 229 | fi |
| 230 | |
| 231 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$INSTALL_ONOS_APPS:") -eq 1 ]; then |
| 232 | INSTALL_ONOS_APPS=yes |
| 233 | else |
| 234 | INSTALL_ONOS_APPS=no |
| 235 | fi |
| 236 | |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 237 | mkdir -p .voltha |
| 238 | touch .voltha/ports |
| 239 | HAVE=$(grep $NAME .voltha/ports) |
| 240 | if [ "$HAVE X" == " X" ]; then |
| 241 | # Find free port prefix |
| 242 | START=81 |
| 243 | while true; do |
| 244 | if [ $(grep -c $START .voltha/ports) -eq 0 ]; then |
| 245 | break |
| 246 | fi |
| 247 | START=$(expr $START + 1) |
| 248 | done |
| 249 | DELTA=$(expr $START - 81) |
| 250 | ONOS_API_PORT=${START}81 |
| 251 | ONOS_SSH_PORT=${START}01 |
| 252 | VOLTHA_API_PORT=5$(expr 55 + $DELTA)55 |
| 253 | VOLTHA_SSH_PORT=$(expr 50 + $DELTA)22 |
| 254 | VOLTHA_ETCD_PORT=$(expr 23 + $DELTA)79 |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 255 | else |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 256 | VALUES=$(echo $HAVE | sed -e 's/\s//g' | cut -d= -f2) |
| 257 | ONOS_API_PORT=$(echo $VALUES | cut -d, -f1) |
| 258 | ONOS_SSH_PORT=$(echo $VALUES | cut -d, -f2) |
| 259 | VOLTHA_API_PORT=$(echo $VALUES | cut -d, -f3) |
| 260 | VOLTHA_SSH_PORT=$(echo $VALUES | cut -d, -f4) |
| 261 | VOLTHA_ETCD_PORT=$(echo $VALUES | cut -d, -f5) |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 262 | fi |
| 263 | |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 264 | PORTTMP=$(mktemp -u) |
| 265 | cat .voltha/ports | grep -v $NAME > $PORTTMP |
| 266 | echo "$NAME=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT" >> $PORTTMP |
| 267 | cp $PORTTMP .voltha/ports |
| 268 | rm -f $PORTTMP |
| 269 | |
David Bainbridge | 27790d6 | 2019-08-13 22:43:19 +0000 | [diff] [blame] | 270 | ONOS_TAG=${ONOS_TAG:-} |
| 271 | if [ "$WITH_TP" == "yes" -a "$ONOS_TAG X" == " X" ]; then |
| 272 | ONOS_TAG="voltha-1.7" |
David Bainbridge | 0129495 | 2019-07-30 19:33:45 +0000 | [diff] [blame] | 273 | fi |
David Bainbridge | 27790d6 | 2019-08-13 22:43:19 +0000 | [diff] [blame] | 274 | export ONOS_API_PORT ONOS_SSH_PORT |
David Bainbridge | 0129495 | 2019-07-30 19:33:45 +0000 | [diff] [blame] | 275 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 276 | spin() { |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 277 | PARTS="\ |
| 278 | \xe2\xa2\x8e\xe2\xa1\xb0 \ |
| 279 | \xe2\xa2\x8e\xe2\xa1\xa1 \ |
| 280 | \xe2\xa2\x8e\xe2\xa1\x91 \ |
| 281 | \xe2\xa2\x8e\xe2\xa0\xb1 \ |
| 282 | \xe2\xa0\x8e\xe2\xa1\xb1 \ |
| 283 | \xe2\xa2\x8a\xe2\xa1\xb1 \ |
| 284 | \xe2\xa2\x8c\xe2\xa1\xb1 \ |
| 285 | \xe2\xa2\x86\xe2\xa1\xb1 \ |
| 286 | " |
| 287 | IDX=1 |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 288 | echo -en $CIVIS |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 289 | while true; do |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 290 | C=$(echo $PARTS | cut '-d ' -f $IDX) |
| 291 | echo -en "$C" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 292 | IDX=$(expr $IDX + 1) |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 293 | if [ $IDX -gt 8 ]; then |
| 294 | IDX=1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 295 | fi |
| 296 | sleep .15 |
| 297 | echo -en "\r" |
| 298 | done |
| 299 | } |
| 300 | |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 301 | IDX=1 |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 302 | CLOCK="TIME:" |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 303 | SPIN_PARTS= |
| 304 | NOT_VERIFIED= |
| 305 | VERIFIED= |
| 306 | HELM= |
| 307 | OLD_KEY= |
| 308 | BIRD= |
| 309 | HIGH_VOLTAGE= |
| 310 | PLUG= |
| 311 | RESTART= |
| 312 | FORWARD= |
| 313 | INSTALL= |
| 314 | STOP= |
| 315 | GO= |
| 316 | DOWNLOAD= |
| 317 | GEAR= |
| 318 | NO_ENTRY= |
| 319 | LOCK= |
| 320 | |
| 321 | if [ $FANCY -eq 1 ]; then |
| 322 | SPIN_PARTS="\ |
| 323 | \xe2\xa2\x8e\xe2\xa1\xb0 \ |
| 324 | \xe2\xa2\x8e\xe2\xa1\xa1 \ |
| 325 | \xe2\xa2\x8e\xe2\xa1\x91 \ |
| 326 | \xe2\xa2\x8e\xe2\xa0\xb1 \ |
| 327 | \xe2\xa0\x8e\xe2\xa1\xb1 \ |
| 328 | \xe2\xa2\x8a\xe2\xa1\xb1 \ |
| 329 | \xe2\xa2\x8c\xe2\xa1\xb1 \ |
| 330 | \xe2\xa2\x86\xe2\xa1\xb1 \ |
| 331 | " |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 332 | CLOCK="\xe2\x8f\xb1" |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 333 | NOT_VERIFIED="\xe2\x9c\x97\x20" |
| 334 | VERIFIED="\xe2\x9c\x93\x20" |
| 335 | HELM="\xE2\x8E\x88" |
| 336 | OLD_KEY="\xF0\x9F\x97\x9D" |
| 337 | BIRD="\xF0\x9F\x90\xA6" |
| 338 | HIGH_VOLTAGE="\xE2\x9A\xA1" |
| 339 | PLUG="\xF0\x9F\xa7\xa9" |
| 340 | RESTART="\xf0\x9f\x94\x84" |
| 341 | FORWARD="\xE2\x87\xA8" |
| 342 | INSTALL="\xF0\x9F\x8F\x97" |
| 343 | STOP="\xf0\x9f\x9b\x91" |
| 344 | GO="\xf0\x9f\x9a\x80" |
| 345 | DOWNLOAD="\xf0\x9f\x93\xa5" |
| 346 | GEAR="\xe2\x9a\x99" |
| 347 | NO_ENTRY="\xe2\x9b\x94" |
| 348 | LOCK="\xf0\x9f\x94\x92" |
| 349 | fi |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 350 | |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame^] | 351 | duration() { |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 352 | local h=$(expr $1 / 3600) |
| 353 | local m=$(expr $1 % 3600 / 60) |
| 354 | local s=$(expr $1 % 60) |
| 355 | local t="" |
| 356 | |
| 357 | if [ $h -gt 0 ]; then |
| 358 | t="$t${h}h" |
| 359 | fi |
| 360 | if [ $m -gt 0 ]; then |
| 361 | t="$t${m}m" |
| 362 | fi |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame^] | 363 | echo "$t${s}s" |
| 364 | } |
| 365 | |
| 366 | printtime() { |
| 367 | local INDENT= |
| 368 | if [ "$1" == "-" ]; then |
| 369 | INDENT=" " |
| 370 | shift |
| 371 | fi |
| 372 | echo -e "$INDENT $CLOCK $(duration $1)" |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 373 | } |
| 374 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 375 | bspin() { |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 376 | IDX=1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 377 | local INDENT= |
| 378 | if [ "$1" == "-" ]; then |
| 379 | INDENT=" " |
| 380 | shift |
| 381 | fi |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 382 | if [ $FANCY -eq 0 ]; then |
| 383 | LINE=$(echo $* | sed -e 's/[\s+-]//g') |
| 384 | if [ "$LINE X" == " X" ]; then |
| 385 | return |
| 386 | fi |
| 387 | echo -e "$CIVIS$INDENT$*" |
| 388 | else |
| 389 | echo -en "$CIVIS$INDENT $*" |
| 390 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 391 | } |
| 392 | |
| 393 | sspin() { |
| 394 | local INDENT= |
| 395 | if [ "$1" == "-" ]; then |
| 396 | INDENT=" " |
| 397 | shift |
| 398 | fi |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 399 | if [ $FANCY -eq 0 ]; then |
| 400 | LINE=$(echo $* | sed -e 's/[\s+-]//g') |
| 401 | if [ "$LINE X" == " X" ]; then |
| 402 | return |
| 403 | fi |
| 404 | echo -e "$INDENT$*" |
| 405 | else |
| 406 | C=$(echo $SPIN_PARTS | cut '-d ' -f $IDX) |
| 407 | echo -en "\r$INDENT$C $*" |
| 408 | IDX=$(expr $IDX + 1) |
| 409 | if [ $IDX -gt 8 ]; then |
| 410 | IDX=1 |
| 411 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 412 | fi |
| 413 | } |
| 414 | |
| 415 | espin() { |
| 416 | local INDENT= |
| 417 | if [ "$1" == "-" ]; then |
| 418 | INDENT=" " |
| 419 | shift |
| 420 | fi |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 421 | if [ $FANCY -eq 0 ]; then |
| 422 | LINE=$(echo $* | sed -e 's/[\s+-]//g') |
| 423 | if [ "$LINE X" == " X" ]; then |
| 424 | return |
| 425 | fi |
| 426 | echo -e "$INDENT$*" |
| 427 | else |
| 428 | echo -e "\r$INDENT$*$CNORM" |
| 429 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 430 | } |
| 431 | |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 432 | if [ "$1" == "get" -a "$2" == "voltconfig" ]; then |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 433 | echo "$HOME/.volt/config-$NAME" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 434 | exit |
| 435 | fi |
| 436 | |
| 437 | if [ $# -ne 1 -o $(echo ":up:down:dump:" | grep -c ":$1:") -ne 1 ]; then |
| 438 | >&2 echo "What wouild you like to do today:" |
| 439 | >&2 echo " up - bring up voltha" |
| 440 | >&2 echo " down - tear down voltha" |
| 441 | >&2 echo " dump - create a debug dump of running system" |
| 442 | exit 1 |
| 443 | fi |
| 444 | |
| 445 | if [ "$1" == "down" ]; then |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 446 | echo "Tearing down voltha cluster $NAME" |
| 447 | LOG="down-$NAME.log" |
| 448 | echo $(date -u +"%Y%m%dT%H%M%SZ") >$LOG |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 449 | if [ $DEPLOY_K8S == "yes" ]; then |
| 450 | if [ -x ./bin/kind ]; then |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 451 | bspin "Delete Kubernetes Kind Cluster" |
| 452 | (set -x; ./bin/kind delete cluster --name voltha-$NAME >>$LOG 2>&1) >>$LOG 2>&1 |
| 453 | espin $VERIFIED |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 454 | else |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 455 | espin "$NO_ENTRY Delete Kubernetes Kind Cluster: kind command not found" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 456 | fi |
| 457 | else |
| 458 | EXISTS=$(helm list -q) |
| 459 | EXPECT="etcd-operator onos open-olt open-onu sim voltha bbsim radius" |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 460 | bspin "Remove Helm Deployments" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 461 | for i in $EXISTS; do |
| 462 | if [ $(echo $EXPECT | grep -c $i) -eq 1 ]; then |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 463 | sspin "Remove Helm Deployments: $i$CEOL" |
| 464 | (set -x; ./bin/helm delete --purge $i >>$LOG 2>&1) >>$LOG 2>&1 |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 465 | fi |
| 466 | done |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 467 | espin "$VERIFIED Remove Helm Deployments$CEOL" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 468 | fi |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 469 | bspin "Remove port-forwards: onos-ui-$NAME" |
| 470 | for i in $(screen -ls | grep onos-ui-$NAME | awk '{print $1}'); do |
| 471 | sspin |
| 472 | (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1 |
| 473 | done |
| 474 | sspin "Remove port-forwards: onos-ssh-$NAME$CEOL" |
| 475 | for i in $(screen -ls | grep onos-ssh-$NAME | awk '{print $1}'); do |
| 476 | sspin |
| 477 | (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1 |
| 478 | done |
| 479 | sspin "Remove port-forwards: voltha-api-$NAME$CEOL" |
| 480 | for i in $(screen -ls | grep voltha-api-$NAME | awk '{print $1}'); do |
| 481 | sspin |
| 482 | (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1 |
| 483 | done |
| 484 | sspin "Remove port-forwards: voltha-ssh-$NAME$CEOL" |
| 485 | for i in $(screen -ls | grep voltha-ssh-$NAME | awk '{print $1}'); do |
| 486 | sspin |
| 487 | (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1 |
| 488 | done |
| 489 | sspin "Remove port-forwards: voltha-etcd-$NAME$CEOL" |
| 490 | for i in $(screen -ls | grep voltha-etcd-$NAME | awk '{print $1}'); do |
| 491 | sspin |
| 492 | (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1 |
| 493 | done |
| 494 | espin "$VERIFIED Remove port-forwards$CEOL" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 495 | exit |
| 496 | fi |
| 497 | |
| 498 | if [ "$1" == "dump" ]; then |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 499 | LOG="dump-$NAME.log" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 500 | TS=$(date -u +"%Y%m%dT%H%M%SZ") |
| 501 | WORK=$(mktemp -u -d) |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 502 | DATA=$WORK/voltha-debug-dump-$NAME-$TS |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 503 | mkdir -p $DATA |
| 504 | echo $TS > $LOG |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 505 | echo -e "Capturing debug dump to voltha-debug-dump-$NAME-$TS.tgz" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 506 | bspin - "Copy install log" |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 507 | if [ -f install-$NAME.log ]; then |
| 508 | (set -x; cp install-$NAME.log $DATA/install-$NAME.log) >>$LOG 2>&1 |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 509 | espin - $VERIFIED |
| 510 | else |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 511 | espin - "$NO_ENTRY Copy install log: install-$NAME.log not found" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 512 | fi |
| 513 | bspin - "Dumping Kubernetes PODs" |
| 514 | (set -x; kubectl get --all-namespaces pods >> $DATA/all-pods.txt 2>&1) >>$LOG 2>&1 |
| 515 | espin - $VERIFIED |
| 516 | bspin - "Dumping Kubernetes SERVICEs" |
| 517 | (set -x; kubectl get --all-namespaces svc >> $DATA/all-services.txt 2>&1) >>$LOG 2>&1 |
| 518 | espin - $VERIFIED |
| 519 | bspin - "Dumping Kubernetes EVENTs" |
| 520 | (set -x; kubectl get --all-namespaces events >> $DATA/all-events.txt 2>&1) >>$LOG 2>&1 |
| 521 | espin - $VERIFIED |
| 522 | bspin - "Dumping VOLTHA POD details" |
| 523 | PODS=$(kubectl get -n voltha pod -o name) |
| 524 | for POD in $PODS; do |
| 525 | sspin - "Dumping VOLTHA POD details: $POD$CEOL" |
| 526 | mkdir -p $DATA/$POD |
| 527 | (set -x; kubectl describe -n voltha $POD >> $DATA/$POD/describe.txt 2>&1) >>$LOG 2>&1 |
| 528 | sspin - "Dumping VOLTHA POD details: $POD" |
| 529 | (set -x; kubectl logs -n voltha --all-containers --previous $LOG_ARGS $POD >> $DATA/$POD/logs-previous.txt 2>&1) >>$LOG 2>&1 |
| 530 | sspin - "Dumping VOLTHA POD details: $POD" |
| 531 | (set -x; kubectl logs -n voltha --all-containers $LOG_ARGS $POD >> $DATA/$POD/logs-current.txt 2>&1) >>$LOG 2>&1 |
| 532 | sspin - "Dumping VOLTHA POD details: $POD" |
| 533 | done |
| 534 | espin - "$VERIFIED Dumping VOLTHA POD details$CEOL" |
| 535 | bspin - "Dumping ETCD" |
| 536 | if [ "$(which etcdctl) X" != " X" ]; then |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 537 | (set -x; ETCDCTL_API=3 etcdctl --endpoints localhost:$VOLTHA_ETCD_PORT get --prefix service/voltha | hexdump -C >> $DATA/etcd.hex 2>&1) >>$LOG 2>&1 |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 538 | espin - $VERIFIED |
| 539 | else |
| 540 | espin - "$NO_ENTRY Dumping ETCD: etcdctl command not available" |
| 541 | fi |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 542 | bspin - "Creating compressed TAR: voltha-debug-dump-$NAME-$TS.tgz" |
| 543 | (set -x; tar -C $WORK -zcf voltha-debug-dump-$NAME-$TS.tgz ./voltha-debug-dump-$NAME-$TS) >>$LOG 2>&1 |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 544 | espin - $VERIFIED |
| 545 | bspin - "Cleanup" |
| 546 | (set -x; rm -rf $WORK) >>$LOG 2>&1 |
| 547 | espin - $VERIFIED |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 548 | bspin - "$(ls -l voltha-debug-dump-$NAME-$TS.tgz)" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 549 | espin - $VERIFIED |
| 550 | exit |
| 551 | fi |
| 552 | |
| 553 | |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 554 | LOG="install-$NAME.log" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 555 | date > $LOG |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 556 | echo "PORTS=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT" >> $LOG |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 557 | |
| 558 | # Output install options to log |
| 559 | echo "OPTIONS" >> $LOG |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 560 | ALL_OPTIONS="NAME TYPE WITH_TIMINGS WITH_BBSIM WITH_RADIUS WITH_ONOS WITH_TP JUST_K8S DEPLOY_K8S \ |
David Bainbridge | 27790d6 | 2019-08-13 22:43:19 +0000 | [diff] [blame] | 561 | INSTALL_ONOS_APPS SKIP_RESTART_API INSTALL_KUBECTL INSTALL_HELM USE_GO VOLTHA_LOG_LEVEL \ |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 562 | VOLTHA_CHART VOLTHA_ADAPTER_SIM_CHART VOLTHA_ADAPTER_OPEN_OLT_CHART \ |
David Bainbridge | 27790d6 | 2019-08-13 22:43:19 +0000 | [diff] [blame] | 563 | VOLTHA_ADAPTER_OPEN_ONU_CHART ONOS_TAG \ |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 564 | ONOS_API_PORT ONOS_SSH_PORT VOLTHA_API_PORT VOLTHA_SSH_PORT VOLTHA_ETCD_PORT" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 565 | for O in $ALL_OPTIONS; do |
| 566 | VAL=$(eval echo \$$O) |
| 567 | if [ $O == "USE_GO" ]; then |
| 568 | VAL="$(echo $VAL| test $(grep -c true) -eq 1 && echo yes || echo no)" |
| 569 | fi |
| 570 | if [ ! -z "$VAL" ]; then |
| 571 | printf " %-30s = %s\n" $O $VAL >> $LOG |
| 572 | fi |
| 573 | done |
| 574 | |
David Bainbridge | d31d612 | 2019-08-13 19:37:59 +0000 | [diff] [blame] | 575 | push_onos_config() { |
| 576 | local MSG=$1 |
| 577 | local RESOURCE=$2 |
| 578 | local DATA=$3 |
| 579 | |
| 580 | bspin - "$MSG $GEAR" |
| 581 | until test; do |
| 582 | (set -x; curl --fail -sSL --user karaf:karaf -X POST -H Content-Type:application/json http://127.0.0.1:$ONOS_API_PORT/onos/v1/$RESOURCE --data @$DATA >>$LOG 2>&1) >>$LOG 2>&1 |
| 583 | if [ $? -eq 0 ]; then |
| 584 | break |
| 585 | fi |
| 586 | sleep .2 |
| 587 | sspin - |
| 588 | done |
| 589 | espin - $VERIFIED |
| 590 | } |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 591 | |
David Bainbridge | 27790d6 | 2019-08-13 22:43:19 +0000 | [diff] [blame] | 592 | override_onos_app() { |
| 593 | local APP=$1 |
| 594 | local NAME=$(basename $APP | sed -e 's/-.*$//g') |
| 595 | until test; do |
| 596 | sspin - |
| 597 | # Attempt to delete old version (if it exists) |
| 598 | (set -x; curl --fail -sSL --user karaf:karaf -X DELETE http://127.0.0.1:$ONOS_API_PORT/onos/v1/applications/$NAME >>$LOG 2>&1) >>$LOG 2>&1 |
| 599 | sspin - |
| 600 | (set -x; curl --fail -sSL --user karaf:karaf -X POST -H Content-Type:application/octet-stream http://127.0.0.1:$ONOS_API_PORT/onos/v1/applications?activate=true --data-binary @$APP >>$LOG 2>&1) >>$LOG 2>&1 |
| 601 | if [ $? -eq 0 ]; then |
| 602 | break |
| 603 | fi |
| 604 | sleep .2 |
| 605 | done |
| 606 | } |
| 607 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 608 | count_pods() { |
| 609 | local NAMESPACE=$1; shift |
| 610 | local PODS=$(kubectl -n $NAMESPACE get pod -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}") |
| 611 | local COUNT=0 |
| 612 | local PATTERNS=$* |
| 613 | for POD in $PODS; do |
| 614 | local NAME=$(echo $POD | cut -d/ -f 1) |
| 615 | local STATE=$(echo $POD | cut -d/ -f 2) |
| 616 | local CONTAINERS=$(echo $POD | cut -d/ -f 3 | sed -e 's/_/ /g') |
| 617 | if [ "$STATE" == "Running" ]; then |
| 618 | local TOTAL=$(echo $CONTAINERS | wc -w) |
| 619 | local FOUND=$(echo $CONTAINERS | grep -o true | wc -l) |
| 620 | if [ $TOTAL -eq $FOUND ]; then |
| 621 | for PATTERN in $PATTERNS; do |
| 622 | if [[ $NAME =~ $PATTERN ]]; then |
| 623 | COUNT=$(expr $COUNT + 1) |
| 624 | fi |
| 625 | done |
| 626 | fi |
| 627 | fi |
| 628 | done |
| 629 | echo $COUNT |
| 630 | } |
| 631 | |
| 632 | wait_for_pods() { |
| 633 | local INDENT= |
| 634 | if [ "$1" == "-" ]; then |
| 635 | INDENT=$1; shift |
| 636 | fi |
| 637 | local NAMESPACE=$1; shift |
| 638 | local EXPECT=$1; shift |
| 639 | local RETRY=$1; shift |
| 640 | local MESSAGE=$1; shift |
| 641 | local PATTERNS=$* |
| 642 | local HAVE=$(count_pods $NAMESPACE $PATTERNS) |
| 643 | COUNT=$(expr 300 / 15) |
| 644 | bspin $INDENT $MESSAGE |
| 645 | sspin $INDENT |
| 646 | if [ $HAVE -ne $EXPECT ]; then |
| 647 | while [ $HAVE -ne $EXPECT ]; do |
| 648 | sspin $INDENT |
| 649 | COUNT=$(expr $COUNT - 1) |
| 650 | if [ $COUNT -eq 0 ]; then |
| 651 | HAVE=$(count_pods $NAMESPACE $PATTERNS) |
| 652 | COUNT=$(expr 300 / 15) |
| 653 | fi |
| 654 | sleep .15 |
| 655 | done |
| 656 | fi |
| 657 | espin $INDENT $VERIFIED |
| 658 | if [ $HAVE -ne $EXPECT ]; then |
| 659 | return 1 |
| 660 | fi |
| 661 | return 0 |
| 662 | } |
| 663 | |
| 664 | helm_install() { |
| 665 | local INDENT= |
| 666 | if [ "$1" == "-" ]; then |
| 667 | INDENT=$1; shift |
| 668 | fi |
| 669 | local NAMESPACE=$1; shift |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 670 | local INAME=$1; shift |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 671 | local CHART=$1; shift |
| 672 | local MESSAGE=$* |
| 673 | |
| 674 | COUNT=$(expr 300 / 15) |
| 675 | bspin $INDENT $MESSAGE |
David Bainbridge | 458bb66 | 2019-08-02 20:04:23 +0000 | [diff] [blame] | 676 | (set -x; helm install -f $NAME-values.yaml --set use_go=$USE_GO --set defaults.log_level=$VOLTHA_LOG_LEVEL --namespace $NAMESPACE --name $INAME $EXTRA_HELM_FLAGS $CHART >>$LOG 2>&1) >>$LOG 2>&1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 677 | SUCCESS=$? |
| 678 | while [ $SUCCESS -ne 0 ]; do |
| 679 | sspin $INDENT |
| 680 | COUNT=$(expr $COUNT - 1) |
| 681 | if [ $COUNT -eq 0 ]; then |
David Bainbridge | 458bb66 | 2019-08-02 20:04:23 +0000 | [diff] [blame] | 682 | (set -x; helm install -f $NAME-values.yaml --set use_go=$USE_GO --set defaults.log_level=$VOLTHA_LOG_LEVEL --namespace $NAMESPACE --name $INAME $EXTRA_HELM_FLAGS $CHART >>$LOG 2>&1) >>$LOG 2>&1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 683 | COUNT=$(expr 300 / 15) |
| 684 | fi |
| 685 | sleep .15 |
| 686 | done |
| 687 | espin $INDENT $VERIFIED |
| 688 | } |
| 689 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 690 | echo "INSTALL TYPE: $TYPE" >> $LOG |
| 691 | |
| 692 | bspin "Verify GOPATH" |
| 693 | export GOPATH=$(pwd) |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 694 | mkdir -p $GOPATH/bin |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 695 | espin $VERIFIED |
| 696 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 697 | STIME=$(date +%s) |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 698 | if [ "$INSTALL_KUBECTL" == "no" ]; then |
| 699 | bspin "Skip kubectl install" |
| 700 | espin $NO_ENTRY |
Test User | c13bdc9 | 2019-07-03 20:57:49 +0000 | [diff] [blame] | 701 | else |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 702 | bspin "Verify kubectl $HELM" |
| 703 | if [ -x $GOPATH/bin/kubectl ]; then |
| 704 | espin $VERIFIED |
| 705 | else |
| 706 | espin $NOT_VERIFIED |
| 707 | bspin - "Download and install Kubernetes/kubectl $DOWNLOAD" |
| 708 | (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 |
| 709 | (set -x; chmod 755 $GOPATH/bin/kubectl >>$LOG 2>&1) >>$LOG 2>&1 |
| 710 | espin - $VERIFIED |
| 711 | fi |
Test User | c13bdc9 | 2019-07-03 20:57:49 +0000 | [diff] [blame] | 712 | fi |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 713 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame^] | 714 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 715 | fi |
Test User | c13bdc9 | 2019-07-03 20:57:49 +0000 | [diff] [blame] | 716 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 717 | STIME=$(date +%s) |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 718 | if [ "$DEPLOY_K8S" == "no" ]; then |
| 719 | bspin "Skip Kubernetes/Kind Deployment" |
| 720 | espin $NO_ENTRY |
| 721 | else |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 722 | bspin "Verify Kubernetes/Kind $HELM" |
| 723 | if [ -x $GOPATH/bin/kind ]; then |
| 724 | espin $VERIFIED |
| 725 | else |
| 726 | espin $NOT_VERIFIED |
| 727 | bspin - "Download and install Kubernetes/kind $DOWNLOAD" |
David Bainbridge | 9e2a666 | 2019-07-11 17:07:57 +0000 | [diff] [blame] | 728 | (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] | 729 | (set -x; chmod 755 $GOPATH/bin/kind >>$LOG 2>&1) >>$LOG 2>&1 |
| 730 | espin - $VERIFIED |
| 731 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 732 | fi |
| 733 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 734 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame^] | 735 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 736 | fi |
| 737 | |
| 738 | STIME=$(date +%s) |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 739 | if [ "$INSTALL_HELM" == "no" ]; then |
| 740 | bspin "Skip Helm Install" |
| 741 | espin $NO_ENTRY |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 742 | else |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 743 | bspin "Verify Helm $HELM" |
| 744 | if [ -x $GOPATH/bin/helm ]; then |
| 745 | espin $VERIFIED |
| 746 | else |
| 747 | espin $NOT_VERIFIED |
| 748 | bspin - "Download and install Helm $DOWNLOAD" |
| 749 | (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 |
| 750 | espin - $VERIFIED |
| 751 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 752 | fi |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 753 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame^] | 754 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 755 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 756 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 757 | STIME=$(date +%s) |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 758 | bspin "Verify voltctl $HIGH_VOLTAGE" |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 759 | if [ -x $GOPATH/bin/voltctl ]; then |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 760 | espin $VERIFIED |
| 761 | else |
| 762 | espin $NOT_VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 763 | bspin - "Download and build voltctl $DOWNLOAD" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 764 | (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] | 765 | (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] | 766 | espin - $VERIFIED |
| 767 | fi |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 768 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame^] | 769 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 770 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 771 | |
| 772 | bspin "Verify command PATH" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 773 | export PATH=$GOPATH/bin:$PATH |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 774 | espin $VERIFIED |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 775 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 776 | STIME=$(date +%s) |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 777 | if [ "$DEPLOY_K8S" == "yes" ]; then |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 778 | HAVE=$(kind get clusters | grep -c voltha-$NAME) |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 779 | bspin "Verify Kubernetes/Kind Cluster" |
| 780 | sspin |
| 781 | if [ $HAVE -eq 0 ]; then |
David Bainbridge | 491b1bd | 2019-07-11 17:53:11 +0000 | [diff] [blame] | 782 | espin $NOT_VERIFIED |
| 783 | bspin - "Verify cluster configuration" |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 784 | if [ ! -r ./$NAME-cluster.cfg ]; then |
David Bainbridge | 491b1bd | 2019-07-11 17:53:11 +0000 | [diff] [blame] | 785 | espin - $NOT_VERIFIED |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 786 | bspin - "Download cluster configuration: $TYPE-cluster.cfg to $NAME-cluster.cfg $DOWNLOAD" |
| 787 | (set -x; curl -o ./$NAME-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] | 788 | espin - $VERIFIED |
| 789 | else |
| 790 | espin - $VERIFIED |
| 791 | fi |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 792 | kind create cluster --name voltha-$NAME --config $NAME-cluster.cfg |
David Bainbridge | 491b1bd | 2019-07-11 17:53:11 +0000 | [diff] [blame] | 793 | else |
| 794 | espin $VERIFIED |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 795 | fi |
| 796 | |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 797 | export KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$NAME")" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 798 | P="coredns-.* \ |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 799 | etcd-voltha-$NAME-control-plane \ |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 800 | kindnet-.* \ |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 801 | kube-apiserver-voltha-$NAME-control-plane \ |
| 802 | kube-controller-manager-voltha-$NAME-control-plane \ |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 803 | kube-proxy-.* \ |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 804 | kube-scheduler-voltha-$NAME-control-plane" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 805 | |
| 806 | EXPECT=$(test "$TYPE" == "minimal" && echo "12" || echo "14") |
| 807 | 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] | 808 | fi |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 809 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame^] | 810 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 811 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 812 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 813 | STIME=$(date +%s) |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 814 | COUNT=$(count_pods "kube-system" "tiller-deploy-.*") |
| 815 | bspin "Verify Helm" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 816 | if [ $COUNT -ne 1 ]; then |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 817 | espin $NOT_VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 818 | echo -e "Configuring Helm $GEAR" |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 819 | if [ "$INSTALL_HELM" == "no" ]; then |
| 820 | bspin - "Skip Helm/Tiller Initialization" |
| 821 | espin - $NO_ENTRY |
| 822 | else |
| 823 | bspin - "Initialize Helm" |
| 824 | (set -x; helm init --upgrade >>$LOG 2>&1) >>$LOG 2>&1 |
| 825 | espin - $VERIFIED |
| 826 | wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start" "tiller-deploy-.*" |
| 827 | fi |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 828 | bspin - "Add Google Incubator repository to Helm" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 829 | (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1 |
| 830 | espin - $VERIFIED |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 831 | |
| 832 | # HACK (sort-of) - the config for tiller is about to be patched, which will |
| 833 | # cause the tiller pod to be recreated. This can sometimes cause a timing |
| 834 | # issue with the "wait_for_pods" call on tiller as it may incorrectly |
| 835 | # identify the running/ready tiller pod that is soon to be terminated as |
| 836 | # what it is waiting for. To avoid this issue we do a clean scale down and |
| 837 | # scale up of the pod so the script controlls when it should be expecting |
| 838 | # things |
| 839 | (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] | 840 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 841 | bspin - "Add Google Stable repository to Helm" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 842 | (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1 |
| 843 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 844 | bspin - "Add ONF repository to Helm" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 845 | (set -x; helm repo add onf https://charts.opencord.org >>$LOG 2>&1) >>$LOG 2>&1 |
| 846 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 847 | bspin - "Update Helm repository cache" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 848 | (set -x; helm repo update >>$LOG 2>&1) >>$LOG 2>&1 |
| 849 | espin - $VERIFIED |
| 850 | |
| 851 | # Create and k8s service account so that Helm can create pods |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 852 | bspin - "Create Tiller ServiceAccount" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 853 | (set -x; kubectl create serviceaccount --namespace kube-system tiller >>$LOG 2>&1) >>$LOG 2>&1 |
| 854 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 855 | bspin - "Create Tiller ClusterRoleBinding" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 856 | (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>$LOG 2>&1) >>$LOG 2>&1 |
| 857 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 858 | bspin - "Update Tiller Manifest" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 859 | (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] | 860 | |
| 861 | # HACK (sort-of) - part to, spin it back up |
| 862 | (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] | 863 | espin - $VERIFIED |
| 864 | else |
| 865 | espin $VERIFIED |
| 866 | fi |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 867 | wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start" "tiller-deploy-.*" |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 868 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame^] | 869 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 870 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 871 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 872 | STIME=$(date +%s) |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 873 | bspin "Verify Helm values file: $NAME-values.yaml" |
| 874 | if [ ! -r "./$NAME-values.yaml" ]; then |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 875 | espin $NOT_VERIFIED |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 876 | bspin - "Download Helm values file: $TYPE-values.yaml to $NAME-values.yaml $DOWNLOAD" |
| 877 | (set -x; curl -o ./$NAME-values.yaml -sSL https://raw.githubusercontent.com/ciena/kind-voltha/master/$TYPE-values.yaml >>$LOG 2>&1) >>$LOG 2>&1 |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 878 | espin - $VERIFIED |
| 879 | else |
| 880 | espin $VERIFIED |
| 881 | fi |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 882 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame^] | 883 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 884 | fi |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 885 | |
| 886 | if [ "$JUST_K8S" == "yes" ]; then |
| 887 | echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye." |
| 888 | echo "" |
| 889 | echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG |
| 890 | echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG |
| 891 | echo "tools required by VOLTHA in your command path. " | tee -a $LOG |
| 892 | echo "" | tee -a $LOG |
| 893 | echo -en $BOLD |
| 894 | if [ $DEPLOY_K8S == "yes" ]; then |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 895 | echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a $LOG |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 896 | fi |
| 897 | echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG |
| 898 | echo -en $NORMAL |
| 899 | echo "" | tee -a $LOG |
| 900 | echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG |
| 901 | exit 0 |
| 902 | fi |
| 903 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 904 | STIME=$(date +%s) |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 905 | bspin "Verify ETCD Operator $OLD_KEY" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 906 | 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] | 907 | espin $NOT_VERIFIED |
| 908 | helm_install - voltha etcd-operator stable/etcd-operator "Install ETCD Operator" |
| 909 | else |
| 910 | espin $VERIFIED |
| 911 | fi |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 912 | EXPECT=$(test "$TYPE" == "minimal" && echo "1" || echo "3") |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 913 | wait_for_pods - "voltha" $EXPECT -1 "Waiting for ETCD Operator to start" "etcd-operator-.*" |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 914 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame^] | 915 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 916 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 917 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 918 | STIME=$(date +%s) |
David Bainbridge | b270c20 | 2019-07-26 01:44:42 +0000 | [diff] [blame] | 919 | if [ $WITH_ONOS == "yes" ]; then |
| 920 | bspin "Verify ONOS installed $BIRD" |
| 921 | if [ $(helm list --deployed --short --namespace default "^onos\$" | wc -l) -ne 1 ]; then |
| 922 | espin $NOT_VERIFIED |
David Bainbridge | 27790d6 | 2019-08-13 22:43:19 +0000 | [diff] [blame] | 923 | SET_TAG= |
| 924 | if [ "$ONOS_TAG X" != " X" ]; then |
| 925 | SET_TAG="--set images.onos.tag=$ONOS_TAG" |
| 926 | fi |
| 927 | EXTRA_HELM_FLAGS="$SET_TAG $EXTRA_HELM_FLAGS" helm_install - default onos onf/onos "Install ONOS" |
David Bainbridge | b270c20 | 2019-07-26 01:44:42 +0000 | [diff] [blame] | 928 | else |
| 929 | espin $VERIFIED |
| 930 | fi |
| 931 | wait_for_pods - "default" 1 -1 "Waiting for ONOS to start" "onos-.*" |
| 932 | |
| 933 | bspin - "Forward ONOS API port $FORWARD" |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 934 | for i in $(screen -ls | grep onos-ui-$NAME | awk '{print $1}'); do |
David Bainbridge | 82bd121 | 2019-07-29 19:19:31 +0000 | [diff] [blame] | 935 | (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1 |
| 936 | done |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 937 | (set -x; screen -dmS onos-ui-$NAME bash -c "while true; do kubectl port-forward service/onos-ui $ONOS_API_PORT:8181; done" >>$LOG 2>&1) >>$LOG 2>&1 |
David Bainbridge | b270c20 | 2019-07-26 01:44:42 +0000 | [diff] [blame] | 938 | espin - $VERIFIED |
| 939 | bspin - "Forward ONOS SSH port $FORWARD" |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 940 | for i in $(screen -ls | grep onos-ssh-$NAME | awk '{print $1}'); do |
David Bainbridge | 82bd121 | 2019-07-29 19:19:31 +0000 | [diff] [blame] | 941 | (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1 |
| 942 | done |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 943 | (set -x; screen -dmS onos-ssh-$NAME bash -c "while true; do kubectl port-forward service/onos-ssh $ONOS_SSH_PORT:8101; done" >>$LOG 2>&1) >>$LOG 2>&1 |
David Bainbridge | b270c20 | 2019-07-26 01:44:42 +0000 | [diff] [blame] | 944 | espin - $VERIFIED |
David Bainbridge | d31d612 | 2019-08-13 19:37:59 +0000 | [diff] [blame] | 945 | bspin - "Verify or download ONOS configuration support files $DOWNLOAD" |
| 946 | (set -x; mkdir -p ./onos-files >>$LOG 2>&1) >>$LOG 2>&1 |
| 947 | for i in dhcp-to-controller-flow.json olt-onos-enableExtraneousRules.json olt-onos-netcfg.json olt-onos-olt-settings.json radius-config.json; do |
| 948 | if [ ! -r ./onos-files/$i ]; then |
| 949 | (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 |
| 950 | fi |
| 951 | done |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 952 | espin - $VERIFIED |
David Bainbridge | 27790d6 | 2019-08-13 22:43:19 +0000 | [diff] [blame] | 953 | |
| 954 | if [ $INSTALL_ONOS_APPS == "yes" ]; then |
| 955 | bspin - "Installing custom ONOS applications" |
| 956 | if [ -x onos-files/onos-apps -a $(ls -1 onos-files/onos-apps/*.oar 2>/dev/null | wc -l) -gt 0 ]; then |
| 957 | for OAR in $(ls -1 onos-files/onos-apps/*.oar); do |
| 958 | sspin - "Installing custom ONOS applications - $OAR$CEOL" |
| 959 | override_onos_app $OAR |
| 960 | done |
| 961 | espin - "$VERIFIED Installing custom ONOS applications$CEOL" |
| 962 | else |
| 963 | espin - "$NOT_VERIFIED Installing custom ONOS applications - None Found" |
| 964 | fi |
| 965 | fi |
David Bainbridge | d31d612 | 2019-08-13 19:37:59 +0000 | [diff] [blame] | 966 | |
| 967 | push_onos_config "Push ONOS Network Configuration" "network/configuration" "onos-files/olt-onos-netcfg.json" |
| 968 | push_onos_config "Enable VOLTHA ONOS DHCP provisioning" "configuration/org.opencord.olt.impl.Olt" "onos-files/olt-onos-olt-settings.json" |
| 969 | push_onos_config "Enabling extraneous rules for ONOS" "configuration/org.onosproject.net.flow.impl.FlowRuleManager" "onos-files/olt-onos-enableExtraneousRules.json" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 970 | fi |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 971 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame^] | 972 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 973 | fi |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 974 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 975 | STIME=$(date +%s) |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 976 | bspin "Verify VOLTHA installed $HIGH_VOLTAGE" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 977 | 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] | 978 | espin $NOT_VERIFIED |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame] | 979 | helm_install - voltha voltha $VOLTHA_CHART "Install VOLTHA Core" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 980 | else |
| 981 | espin $VERIFIED |
| 982 | fi |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 983 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 984 | VOLTHA="ofagent-.* \ |
| 985 | ro-core.* \ |
| 986 | rw-core.* \ |
| 987 | voltha-api-server-.* \ |
| 988 | voltha-cli-server-.* \ |
| 989 | voltha-etcd-cluster-.* \ |
| 990 | voltha-kafka-.* \ |
| 991 | voltha-zookeeper-.*" |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 992 | EXPECT=$(test "$TYPE" == "minimal" && echo "9" || echo "11") |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 993 | wait_for_pods - "voltha" $EXPECT -1 "Waiting for VOLTHA Core to start" $VOLTHA |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 994 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame^] | 995 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 996 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 997 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 998 | STIME=$(date +%s) |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 999 | echo -e "Verify Adapters $PLUG" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1000 | bspin - "Verify Simulated Adapters installed" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 1001 | 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] | 1002 | espin - $NOT_VERIFIED |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame] | 1003 | helm_install - voltha sim $VOLTHA_ADAPTER_SIM_CHART "Install Simulated Adapters" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1004 | else |
| 1005 | espin - $VERIFIED |
| 1006 | fi |
| 1007 | |
| 1008 | bspin - "Verify OpenOLT Adapter installed" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 1009 | 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] | 1010 | espin - $NOT_VERIFIED |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame] | 1011 | 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] | 1012 | else |
| 1013 | espin - $VERIFIED |
| 1014 | fi |
| 1015 | bspin - "Verify OpenONU Adapter installed" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 1016 | 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] | 1017 | espin - $NOT_VERIFIED |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame] | 1018 | 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] | 1019 | else |
| 1020 | espin - $VERIFIED |
| 1021 | fi |
| 1022 | |
| 1023 | ADAPTERS="adapter-.*" |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 1024 | wait_for_pods - "voltha" 4 -1 "Waiting for adapters to start" $ADAPTERS |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1025 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame^] | 1026 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1027 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1028 | |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 1029 | if [ $WITH_BBSIM == "yes" ]; then |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1030 | STIME=$(date +%s) |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 1031 | echo -e "Verify BBSIM $PLUG" |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 1032 | bspin - "Verify BBSIM Installed" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 1033 | if [ $(helm list --deployed --short --namespace voltha "^bbsim\$" | wc -l) -ne 1 ]; then |
| 1034 | espin - $NOT_VERIFIED |
| 1035 | helm_install - voltha bbsim onf/bbsim "Install BBSIM" |
| 1036 | else |
| 1037 | espin - $VERIFIED |
| 1038 | fi |
| 1039 | wait_for_pods - "voltha" 1 -1 "Waiting for BBSIM to start" "bbsim-.*" |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1040 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame^] | 1041 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1042 | fi |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 1043 | fi |
| 1044 | |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 1045 | if [ $WITH_RADIUS == "yes" ]; then |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1046 | STIME=$(date +%s) |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 1047 | echo -e "Verify RADIUS $LOCK" |
| 1048 | bspin - "Verify RADIUS Installed" |
| 1049 | if [ $(helm list --deployed --short --namespace voltha "^radius\$" | wc -l) -ne 1 ]; then |
| 1050 | espin - $NOT_VERIFIED |
| 1051 | helm_install - voltha radius onf/freeradius "Install RADIUS" |
| 1052 | else |
| 1053 | espin - $VERIFIED |
| 1054 | fi |
| 1055 | wait_for_pods - "voltha" 1 -1 "Waiting for RADIUS to start" "radius-.*" |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1056 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame^] | 1057 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1058 | fi |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 1059 | fi |
| 1060 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1061 | STIME=$(date +%s) |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame] | 1062 | if [ $SKIP_RESTART_API == "no" ]; then |
| 1063 | echo -e "Restart VOLTHA API $RESTART" |
| 1064 | API="voltha-api-server-.* ofagent-.*" |
| 1065 | (set -x; kubectl scale --replicas=0 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1 |
| 1066 | wait_for_pods - "voltha" 0 -1 "Wait for API to stop $STOP" $API |
| 1067 | (set -x; kubectl scale --replicas=1 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1 |
| 1068 | wait_for_pods - "voltha" 2 -1 "Wait for API to re-start $GO" $API |
| 1069 | else |
| 1070 | bspin "Skip VOLTHA API Restart" |
| 1071 | espin $NO_ENTRY |
| 1072 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1073 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 1074 | bspin - "Forward VOLTHA API port $FORWARD" |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1075 | for i in $(screen -ls | grep voltha-api-$NAME | awk '{print $1}'); do |
David Bainbridge | 82bd121 | 2019-07-29 19:19:31 +0000 | [diff] [blame] | 1076 | (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1 |
| 1077 | done |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1078 | (set -x; screen -dmS voltha-api-$NAME bash -c "while true; do kubectl port-forward -n voltha service/voltha-api $VOLTHA_API_PORT:55555; done" >>$LOG 2>&1) >>$LOG 2>&1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1079 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 1080 | bspin - "Forward VOLTHA SSH port $FORWARD" |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1081 | for i in $(screen -ls | grep voltha-ssh-$NAME | awk '{print $1}'); do |
David Bainbridge | 82bd121 | 2019-07-29 19:19:31 +0000 | [diff] [blame] | 1082 | (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1 |
| 1083 | done |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1084 | (set -x; screen -dmS voltha-ssh-$NAME bash -c "while true; do kubectl port-forward -n voltha service/voltha-cli $VOLTHA_SSH_PORT:5022; done" >>$LOG 2>&1) >>$LOG 2>&1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1085 | espin - $VERIFIED |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 1086 | bspin - "Forward VOLTHA ETCD port $FORWARD" |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1087 | for i in $(screen -ls | grep voltha-etcd-$NAME | awk '{print $1}'); do |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 1088 | (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1 |
| 1089 | done |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1090 | (set -x; screen -dmS voltha-etcd-$NAME bash -c "while true; do kubectl port-forward -n voltha service/voltha-etcd-cluster-client $VOLTHA_ETCD_PORT:2379; done" >>$LOG 2>&1) >>$LOG 2>&1 |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 1091 | espin - $VERIFIED |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1092 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame^] | 1093 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1094 | fi |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 1095 | |
David Bainbridge | b270c20 | 2019-07-26 01:44:42 +0000 | [diff] [blame] | 1096 | if [ $WITH_ONOS == "yes" -a $WITH_RADIUS == "yes" ]; then |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 1097 | bspin "Configure ONOS RADIUS Connection $GEAR" |
| 1098 | (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 |
| 1099 | espin $VERIFIED |
| 1100 | fi |
| 1101 | |
| 1102 | bspin "Create voltctl configuration file" |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 1103 | (set -x; mkdir -p $HOME/.volt >>$LOG 2>&1) >>$LOG 2>&1 |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1104 | (set -x; voltctl -a v2 -s localhost:$VOLTHA_API_PORT config > $HOME/.volt/config-$NAME 2>>$LOG) >>$LOG 2>&1 |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 1105 | espin $VERIFIED |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 1106 | |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1107 | if [ ! -f "$NAME-env.sh" ]; then |
| 1108 | touch $NAME-env.sh |
David Bainbridge | b07fdf7 | 2019-07-29 22:51:40 +0000 | [diff] [blame] | 1109 | fi |
| 1110 | |
David Bainbridge | 596f30d | 2019-07-30 17:07:59 +0000 | [diff] [blame] | 1111 | for O in $ALL_OPTIONS; do |
| 1112 | VAL=$(eval echo \$$O) |
| 1113 | if [ $O == "USE_GO" ]; then |
| 1114 | VAL="$(echo $VAL| test $(grep -c true) -eq 1 && echo yes || echo no)" |
| 1115 | fi |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1116 | if [ ! -z "$VAL" -a $(grep -c "^export $O=" $NAME-env.sh) -eq 0 ]; then |
| 1117 | echo "export $O=\"$(eval echo \$$O)\"" >> $NAME-env.sh |
David Bainbridge | b07fdf7 | 2019-07-29 22:51:40 +0000 | [diff] [blame] | 1118 | fi |
| 1119 | done |
| 1120 | |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1121 | if [ $DEPLOY_K8S == "yes" -a $(grep -c "^export KUBECONFIG=" $NAME-env.sh) -eq 0 ]; then |
| 1122 | echo "export KUBECONFIG=\"$(./bin/kind get kubeconfig-path --name=voltha-$NAME)\"" >> $NAME-env.sh |
David Bainbridge | b07fdf7 | 2019-07-29 22:51:40 +0000 | [diff] [blame] | 1123 | fi |
| 1124 | |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1125 | if [ $(grep -c "^export VOLTCONFIG=" $NAME-env.sh) -eq 0 ]; then |
| 1126 | echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" >> $NAME-env.sh |
David Bainbridge | b07fdf7 | 2019-07-29 22:51:40 +0000 | [diff] [blame] | 1127 | fi |
| 1128 | |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1129 | if [ $(grep -c "^export PATH=" $NAME-env.sh) -eq 0 ]; then |
| 1130 | echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> $NAME-env.sh |
David Bainbridge | b07fdf7 | 2019-07-29 22:51:40 +0000 | [diff] [blame] | 1131 | fi |
| 1132 | |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 1133 | echo "" |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 1134 | echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG |
| 1135 | echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG |
| 1136 | echo "tools required by VOLTHA in your command path. " | tee -a $LOG |
| 1137 | echo "" | tee -a $LOG |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 1138 | echo -en $BOLD |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1139 | if [ $DEPLOY_K8S == "yes" ]; then |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1140 | echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$NAME\")\"" | tee -a $LOG |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1141 | fi |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1142 | echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" | tee -a $LOG |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1143 | echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 1144 | echo -en $NORMAL |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 1145 | echo "" | tee -a $LOG |
| 1146 | echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG |
| 1147 | |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame^] | 1148 | if [ "$WITH_TIMINGS" == "yes" ]; then |
| 1149 | echo -e "$CLOCK TOTAL: $(duration $(expr $(date +%s) - $TOTAL_START_TIME))" |
| 1150 | fi |
| 1151 | |