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