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