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 | 0774b23 | 2019-08-02 06:37:19 +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 $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 | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame^] | 539 | (set -x; helm install -f $NAME-values.yaml --set |
| 540 | defaults.log_level=$VOLTHA_LOG_LEVEL --namespace $NAMESPACE --name $INAME $CHART >>$LOG 2>&1) >>$LOG 2>&1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 541 | COUNT=$(expr 300 / 15) |
| 542 | fi |
| 543 | sleep .15 |
| 544 | done |
| 545 | espin $INDENT $VERIFIED |
| 546 | } |
| 547 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 548 | echo "INSTALL TYPE: $TYPE" >> $LOG |
| 549 | |
| 550 | bspin "Verify GOPATH" |
| 551 | export GOPATH=$(pwd) |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 552 | mkdir -p $GOPATH/bin |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 553 | espin $VERIFIED |
| 554 | |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 555 | if [ "$INSTALL_KUBECTL" == "no" ]; then |
| 556 | bspin "Skip kubectl install" |
| 557 | espin $NO_ENTRY |
Test User | c13bdc9 | 2019-07-03 20:57:49 +0000 | [diff] [blame] | 558 | else |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 559 | bspin "Verify kubectl $HELM" |
| 560 | if [ -x $GOPATH/bin/kubectl ]; then |
| 561 | espin $VERIFIED |
| 562 | else |
| 563 | espin $NOT_VERIFIED |
| 564 | bspin - "Download and install Kubernetes/kubectl $DOWNLOAD" |
| 565 | (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 |
| 566 | (set -x; chmod 755 $GOPATH/bin/kubectl >>$LOG 2>&1) >>$LOG 2>&1 |
| 567 | espin - $VERIFIED |
| 568 | fi |
Test User | c13bdc9 | 2019-07-03 20:57:49 +0000 | [diff] [blame] | 569 | fi |
| 570 | |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 571 | if [ "$DEPLOY_K8S" == "no" ]; then |
| 572 | bspin "Skip Kubernetes/Kind Deployment" |
| 573 | espin $NO_ENTRY |
| 574 | else |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 575 | bspin "Verify Kubernetes/Kind $HELM" |
| 576 | if [ -x $GOPATH/bin/kind ]; then |
| 577 | espin $VERIFIED |
| 578 | else |
| 579 | espin $NOT_VERIFIED |
| 580 | bspin - "Download and install Kubernetes/kind $DOWNLOAD" |
David Bainbridge | 9e2a666 | 2019-07-11 17:07:57 +0000 | [diff] [blame] | 581 | (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] | 582 | (set -x; chmod 755 $GOPATH/bin/kind >>$LOG 2>&1) >>$LOG 2>&1 |
| 583 | espin - $VERIFIED |
| 584 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 585 | fi |
| 586 | |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 587 | if [ "$INSTALL_HELM" == "no" ]; then |
| 588 | bspin "Skip Helm Install" |
| 589 | espin $NO_ENTRY |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 590 | else |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 591 | bspin "Verify Helm $HELM" |
| 592 | if [ -x $GOPATH/bin/helm ]; then |
| 593 | espin $VERIFIED |
| 594 | else |
| 595 | espin $NOT_VERIFIED |
| 596 | bspin - "Download and install Helm $DOWNLOAD" |
| 597 | (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 |
| 598 | espin - $VERIFIED |
| 599 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 600 | fi |
| 601 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 602 | bspin "Verify voltctl $HIGH_VOLTAGE" |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 603 | if [ -x $GOPATH/bin/voltctl ]; then |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 604 | espin $VERIFIED |
| 605 | else |
| 606 | espin $NOT_VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 607 | bspin - "Download and build voltctl $DOWNLOAD" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 608 | (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] | 609 | (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] | 610 | espin - $VERIFIED |
| 611 | fi |
| 612 | |
| 613 | bspin "Verify command PATH" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 614 | export PATH=$GOPATH/bin:$PATH |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 615 | espin $VERIFIED |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 616 | |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 617 | if [ "$DEPLOY_K8S" == "yes" ]; then |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame^] | 618 | HAVE=$(kind get clusters | grep -c voltha-$NAME) |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 619 | bspin "Verify Kubernetes/Kind Cluster" |
| 620 | sspin |
| 621 | if [ $HAVE -eq 0 ]; then |
David Bainbridge | 491b1bd | 2019-07-11 17:53:11 +0000 | [diff] [blame] | 622 | espin $NOT_VERIFIED |
| 623 | bspin - "Verify cluster configuration" |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame^] | 624 | if [ ! -r ./$NAME-cluster.cfg ]; then |
David Bainbridge | 491b1bd | 2019-07-11 17:53:11 +0000 | [diff] [blame] | 625 | espin - $NOT_VERIFIED |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame^] | 626 | bspin - "Download cluster configuration: $TYPE-cluster.cfg to $NAME-cluster.cfg $DOWNLOAD" |
| 627 | (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] | 628 | espin - $VERIFIED |
| 629 | else |
| 630 | espin - $VERIFIED |
| 631 | fi |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame^] | 632 | kind create cluster --name voltha-$NAME --config $NAME-cluster.cfg |
David Bainbridge | 491b1bd | 2019-07-11 17:53:11 +0000 | [diff] [blame] | 633 | else |
| 634 | espin $VERIFIED |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 635 | fi |
| 636 | |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame^] | 637 | export KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$NAME")" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 638 | P="coredns-.* \ |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame^] | 639 | etcd-voltha-$NAME-control-plane \ |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 640 | kindnet-.* \ |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame^] | 641 | kube-apiserver-voltha-$NAME-control-plane \ |
| 642 | kube-controller-manager-voltha-$NAME-control-plane \ |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 643 | kube-proxy-.* \ |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame^] | 644 | kube-scheduler-voltha-$NAME-control-plane" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 645 | |
| 646 | EXPECT=$(test "$TYPE" == "minimal" && echo "12" || echo "14") |
| 647 | 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] | 648 | fi |
| 649 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 650 | COUNT=$(count_pods "kube-system" "tiller-deploy-.*") |
| 651 | bspin "Verify Helm" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 652 | if [ $COUNT -ne 1 ]; then |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 653 | espin $NOT_VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 654 | echo -e "Configuring Helm $GEAR" |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 655 | if [ "$INSTALL_HELM" == "no" ]; then |
| 656 | bspin - "Skip Helm/Tiller Initialization" |
| 657 | espin - $NO_ENTRY |
| 658 | else |
| 659 | bspin - "Initialize Helm" |
| 660 | (set -x; helm init --upgrade >>$LOG 2>&1) >>$LOG 2>&1 |
| 661 | espin - $VERIFIED |
| 662 | wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start" "tiller-deploy-.*" |
| 663 | fi |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 664 | bspin - "Add Google Incubator repository to Helm" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 665 | (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1 |
| 666 | espin - $VERIFIED |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 667 | |
| 668 | # HACK (sort-of) - the config for tiller is about to be patched, which will |
| 669 | # cause the tiller pod to be recreated. This can sometimes cause a timing |
| 670 | # issue with the "wait_for_pods" call on tiller as it may incorrectly |
| 671 | # identify the running/ready tiller pod that is soon to be terminated as |
| 672 | # what it is waiting for. To avoid this issue we do a clean scale down and |
| 673 | # scale up of the pod so the script controlls when it should be expecting |
| 674 | # things |
| 675 | (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] | 676 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 677 | bspin - "Add Google Stable repository to Helm" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 678 | (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1 |
| 679 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 680 | bspin - "Add ONF repository to Helm" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 681 | (set -x; helm repo add onf https://charts.opencord.org >>$LOG 2>&1) >>$LOG 2>&1 |
| 682 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 683 | bspin - "Update Helm repository cache" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 684 | (set -x; helm repo update >>$LOG 2>&1) >>$LOG 2>&1 |
| 685 | espin - $VERIFIED |
| 686 | |
| 687 | # Create and k8s service account so that Helm can create pods |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 688 | bspin - "Create Tiller ServiceAccount" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 689 | (set -x; kubectl create serviceaccount --namespace kube-system tiller >>$LOG 2>&1) >>$LOG 2>&1 |
| 690 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 691 | bspin - "Create Tiller ClusterRoleBinding" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 692 | (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>$LOG 2>&1) >>$LOG 2>&1 |
| 693 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 694 | bspin - "Update Tiller Manifest" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 695 | (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] | 696 | |
| 697 | # HACK (sort-of) - part to, spin it back up |
| 698 | (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] | 699 | espin - $VERIFIED |
| 700 | else |
| 701 | espin $VERIFIED |
| 702 | fi |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 703 | 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] | 704 | |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame^] | 705 | bspin "Verify Helm values file: $NAME-values.yaml" |
| 706 | if [ ! -r "./$NAME-values.yaml" ]; then |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 707 | espin $NOT_VERIFIED |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame^] | 708 | bspin - "Download Helm values file: $TYPE-values.yaml to $NAME-values.yaml $DOWNLOAD" |
| 709 | (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] | 710 | espin - $VERIFIED |
| 711 | else |
| 712 | espin $VERIFIED |
| 713 | fi |
| 714 | |
| 715 | if [ "$JUST_K8S" == "yes" ]; then |
| 716 | echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye." |
| 717 | echo "" |
| 718 | echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG |
| 719 | echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG |
| 720 | echo "tools required by VOLTHA in your command path. " | tee -a $LOG |
| 721 | echo "" | tee -a $LOG |
| 722 | echo -en $BOLD |
| 723 | if [ $DEPLOY_K8S == "yes" ]; then |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame^] | 724 | 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] | 725 | fi |
| 726 | echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG |
| 727 | echo -en $NORMAL |
| 728 | echo "" | tee -a $LOG |
| 729 | echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG |
| 730 | exit 0 |
| 731 | fi |
| 732 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 733 | bspin "Verify ETCD Operator $OLD_KEY" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 734 | 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] | 735 | espin $NOT_VERIFIED |
| 736 | helm_install - voltha etcd-operator stable/etcd-operator "Install ETCD Operator" |
| 737 | else |
| 738 | espin $VERIFIED |
| 739 | fi |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 740 | EXPECT=$(test "$TYPE" == "minimal" && echo "1" || echo "3") |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 741 | 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] | 742 | |
David Bainbridge | b270c20 | 2019-07-26 01:44:42 +0000 | [diff] [blame] | 743 | if [ $WITH_ONOS == "yes" ]; then |
| 744 | bspin "Verify ONOS installed $BIRD" |
| 745 | if [ $(helm list --deployed --short --namespace default "^onos\$" | wc -l) -ne 1 ]; then |
| 746 | espin $NOT_VERIFIED |
| 747 | helm_install - default onos onf/onos "Install ONOS" |
| 748 | else |
| 749 | espin $VERIFIED |
| 750 | fi |
| 751 | wait_for_pods - "default" 1 -1 "Waiting for ONOS to start" "onos-.*" |
| 752 | |
| 753 | bspin - "Forward ONOS API port $FORWARD" |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame^] | 754 | 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] | 755 | (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1 |
| 756 | done |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame^] | 757 | (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] | 758 | espin - $VERIFIED |
| 759 | bspin - "Forward ONOS SSH port $FORWARD" |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame^] | 760 | 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] | 761 | (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1 |
| 762 | done |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame^] | 763 | (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] | 764 | espin - $VERIFIED |
| 765 | if [ ! -x ./onos-files/install-onos-applications.sh ]; then |
| 766 | bspin - "Verify or download ONOS configuration support files $DOWNLOAD" |
| 767 | (set -x; mkdir -p ./onos-files >>$LOG 2>&1) >>$LOG 2>&1 |
| 768 | 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 |
| 769 | if [ ! -r ./onos-files/$i ]; then |
| 770 | (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 |
| 771 | fi |
| 772 | done |
| 773 | (set -x; chmod 755 ./onos-files/install-onos-applications.sh >>$LOG 2>&1) >>$LOG 2>&1 |
| 774 | espin - $VERIFIED |
| 775 | fi |
| 776 | |
| 777 | bspin - "Install required ONOS applications $INSTALL" |
| 778 | (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] | 779 | espin - $VERIFIED |
| 780 | fi |
| 781 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 782 | bspin "Verify VOLTHA installed $HIGH_VOLTAGE" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 783 | 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] | 784 | espin $NOT_VERIFIED |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame] | 785 | helm_install - voltha voltha $VOLTHA_CHART "Install VOLTHA Core" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 786 | else |
| 787 | espin $VERIFIED |
| 788 | fi |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 789 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 790 | VOLTHA="ofagent-.* \ |
| 791 | ro-core.* \ |
| 792 | rw-core.* \ |
| 793 | voltha-api-server-.* \ |
| 794 | voltha-cli-server-.* \ |
| 795 | voltha-etcd-cluster-.* \ |
| 796 | voltha-kafka-.* \ |
| 797 | voltha-zookeeper-.*" |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 798 | EXPECT=$(test "$TYPE" == "minimal" && echo "9" || echo "11") |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 799 | 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] | 800 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 801 | echo -e "Verify Adapters $PLUG" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 802 | bspin - "Verify Simulated Adapters installed" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 803 | 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] | 804 | espin - $NOT_VERIFIED |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame] | 805 | helm_install - voltha sim $VOLTHA_ADAPTER_SIM_CHART "Install Simulated Adapters" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 806 | else |
| 807 | espin - $VERIFIED |
| 808 | fi |
| 809 | |
| 810 | bspin - "Verify OpenOLT Adapter installed" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 811 | 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] | 812 | espin - $NOT_VERIFIED |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame] | 813 | 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] | 814 | else |
| 815 | espin - $VERIFIED |
| 816 | fi |
| 817 | bspin - "Verify OpenONU Adapter installed" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 818 | 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] | 819 | espin - $NOT_VERIFIED |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame] | 820 | 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] | 821 | else |
| 822 | espin - $VERIFIED |
| 823 | fi |
| 824 | |
| 825 | ADAPTERS="adapter-.*" |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 826 | 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] | 827 | |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 828 | if [ $WITH_BBSIM == "yes" ]; then |
| 829 | echo -e "Verify BBSIM $PLUG" |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 830 | bspin - "Verify BBSIM Installed" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 831 | if [ $(helm list --deployed --short --namespace voltha "^bbsim\$" | wc -l) -ne 1 ]; then |
| 832 | espin - $NOT_VERIFIED |
| 833 | helm_install - voltha bbsim onf/bbsim "Install BBSIM" |
| 834 | else |
| 835 | espin - $VERIFIED |
| 836 | fi |
| 837 | wait_for_pods - "voltha" 1 -1 "Waiting for BBSIM to start" "bbsim-.*" |
| 838 | fi |
| 839 | |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 840 | if [ $WITH_RADIUS == "yes" ]; then |
| 841 | echo -e "Verify RADIUS $LOCK" |
| 842 | bspin - "Verify RADIUS Installed" |
| 843 | if [ $(helm list --deployed --short --namespace voltha "^radius\$" | wc -l) -ne 1 ]; then |
| 844 | espin - $NOT_VERIFIED |
| 845 | helm_install - voltha radius onf/freeradius "Install RADIUS" |
| 846 | else |
| 847 | espin - $VERIFIED |
| 848 | fi |
| 849 | wait_for_pods - "voltha" 1 -1 "Waiting for RADIUS to start" "radius-.*" |
| 850 | fi |
| 851 | |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame] | 852 | if [ $SKIP_RESTART_API == "no" ]; then |
| 853 | echo -e "Restart VOLTHA API $RESTART" |
| 854 | API="voltha-api-server-.* ofagent-.*" |
| 855 | (set -x; kubectl scale --replicas=0 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1 |
| 856 | wait_for_pods - "voltha" 0 -1 "Wait for API to stop $STOP" $API |
| 857 | (set -x; kubectl scale --replicas=1 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1 |
| 858 | wait_for_pods - "voltha" 2 -1 "Wait for API to re-start $GO" $API |
| 859 | else |
| 860 | bspin "Skip VOLTHA API Restart" |
| 861 | espin $NO_ENTRY |
| 862 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 863 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 864 | bspin - "Forward VOLTHA API port $FORWARD" |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame^] | 865 | 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] | 866 | (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1 |
| 867 | done |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame^] | 868 | (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] | 869 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 870 | bspin - "Forward VOLTHA SSH port $FORWARD" |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame^] | 871 | 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] | 872 | (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1 |
| 873 | done |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame^] | 874 | (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] | 875 | espin - $VERIFIED |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 876 | bspin - "Forward VOLTHA ETCD port $FORWARD" |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame^] | 877 | 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] | 878 | (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1 |
| 879 | done |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame^] | 880 | (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] | 881 | espin - $VERIFIED |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 882 | |
David Bainbridge | b270c20 | 2019-07-26 01:44:42 +0000 | [diff] [blame] | 883 | if [ $WITH_ONOS == "yes" -a $WITH_RADIUS == "yes" ]; then |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 884 | bspin "Configure ONOS RADIUS Connection $GEAR" |
| 885 | (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 |
| 886 | espin $VERIFIED |
| 887 | fi |
| 888 | |
| 889 | bspin "Create voltctl configuration file" |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 890 | (set -x; mkdir -p $HOME/.volt >>$LOG 2>&1) >>$LOG 2>&1 |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame^] | 891 | (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] | 892 | espin $VERIFIED |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 893 | |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame^] | 894 | if [ ! -f "$NAME-env.sh" ]; then |
| 895 | touch $NAME-env.sh |
David Bainbridge | b07fdf7 | 2019-07-29 22:51:40 +0000 | [diff] [blame] | 896 | fi |
| 897 | |
David Bainbridge | 596f30d | 2019-07-30 17:07:59 +0000 | [diff] [blame] | 898 | for O in $ALL_OPTIONS; do |
| 899 | VAL=$(eval echo \$$O) |
| 900 | if [ $O == "USE_GO" ]; then |
| 901 | VAL="$(echo $VAL| test $(grep -c true) -eq 1 && echo yes || echo no)" |
| 902 | fi |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame^] | 903 | if [ ! -z "$VAL" -a $(grep -c "^export $O=" $NAME-env.sh) -eq 0 ]; then |
| 904 | echo "export $O=\"$(eval echo \$$O)\"" >> $NAME-env.sh |
David Bainbridge | b07fdf7 | 2019-07-29 22:51:40 +0000 | [diff] [blame] | 905 | fi |
| 906 | done |
| 907 | |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame^] | 908 | if [ $DEPLOY_K8S == "yes" -a $(grep -c "^export KUBECONFIG=" $NAME-env.sh) -eq 0 ]; then |
| 909 | 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] | 910 | fi |
| 911 | |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame^] | 912 | if [ $(grep -c "^export VOLTCONFIG=" $NAME-env.sh) -eq 0 ]; then |
| 913 | echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" >> $NAME-env.sh |
David Bainbridge | b07fdf7 | 2019-07-29 22:51:40 +0000 | [diff] [blame] | 914 | fi |
| 915 | |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame^] | 916 | if [ $(grep -c "^export PATH=" $NAME-env.sh) -eq 0 ]; then |
| 917 | echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> $NAME-env.sh |
David Bainbridge | b07fdf7 | 2019-07-29 22:51:40 +0000 | [diff] [blame] | 918 | fi |
| 919 | |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 920 | echo "" |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 921 | echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG |
| 922 | echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG |
| 923 | echo "tools required by VOLTHA in your command path. " | tee -a $LOG |
| 924 | echo "" | tee -a $LOG |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 925 | echo -en $BOLD |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 926 | if [ $DEPLOY_K8S == "yes" ]; then |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame^] | 927 | 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] | 928 | fi |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame^] | 929 | echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" | tee -a $LOG |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 930 | echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 931 | echo -en $NORMAL |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 932 | echo "" | tee -a $LOG |
| 933 | echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG |
| 934 | |