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