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