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