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 | d049a61 | 2020-03-16 17:22:54 -0700 | [diff] [blame] | 15 | set -f |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 16 | TOTAL_START_TIME=$(date +%s) |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 17 | |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 18 | FANCY=${FANCY:-1} |
| 19 | if [ "$TERM X" == " X" ]; then |
| 20 | FANCY=0 |
| 21 | fi |
| 22 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 23 | # trap ctrl-c and call ctrl_c() |
| 24 | trap ctrl_c INT |
| 25 | |
| 26 | function ctrl_c() { |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 27 | echo -en $CNORM |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 28 | echo "" |
| 29 | echo "ctrl-c trapped" |
David Bainbridge | c6a6eb6 | 2019-10-18 22:50:07 +0000 | [diff] [blame] | 30 | echo "Thank you for trying 'voltha up'" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 31 | exit |
| 32 | } |
| 33 | |
David Bainbridge | a34993d | 2020-04-01 09:15:42 -0700 | [diff] [blame] | 34 | HELM_VERSION=${HELM_VERSION:-v2.14.3} |
David K. Bainbridge | ebf38d9 | 2020-02-10 10:46:31 -0800 | [diff] [blame] | 35 | VOLTCTL_VERSION=${VOLTCTL_VERSION:-latest} |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 36 | KIND_VERSION=${KIND_VERSION:-v0.5.1} |
David K. Bainbridge | b3a9937 | 2020-01-08 14:39:06 -0800 | [diff] [blame] | 37 | VK_RELEASE=${VK_RELEASE:-master} |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 38 | |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 39 | BLACK= |
| 40 | RED= |
| 41 | GREEN= |
| 42 | YELLOW= |
| 43 | BLUE= |
| 44 | MAGENTA= |
| 45 | CYAN= |
| 46 | WHITE= |
| 47 | BOLD= |
| 48 | NORMAL= |
| 49 | ERROR= |
| 50 | CEOL= |
| 51 | CNORM= |
| 52 | CIVIS= |
| 53 | if [ $FANCY -eq 1 ]; then |
| 54 | BLACK=$(tput setaf 0) |
| 55 | RED=$(tput setaf 1) |
| 56 | GREEN=$(tput setaf 2) |
| 57 | YELLOW=$(tput setaf 3) |
| 58 | BLUE=$(tput setaf 4) |
| 59 | MAGENTA=$(tput setaf 5) |
| 60 | CYAN=$(tput setaf 6) |
| 61 | WHITE=$(tput setaf 7) |
| 62 | BOLD=$(tput bold) |
| 63 | NORMAL=$(tput sgr0) |
| 64 | ERROR="\xe2\x9c\x97\x20" |
| 65 | CEOL=$(tput el) |
| 66 | CNORM=$(tput cnorm) |
| 67 | CIVIS=$(tput civis) |
| 68 | fi |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 69 | |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 70 | TYPE=${TYPE:-minimal} |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 71 | NAME=${NAME:-$TYPE} |
David K. Bainbridge | 484d80c | 2020-03-05 21:44:34 -0800 | [diff] [blame] | 72 | |
| 73 | ENABLE_ONOS_EXTRANEOUS_RULES=${ENABLE_ONOS_EXTRANEOUS_RULES:-no} |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 74 | INFRA_NS=${INFRA_NS:-default} |
| 75 | VOLTHA_NS=${VOLTHA_NS:-voltha} |
| 76 | BBSIM_NS=${BBSIM_NS:-voltha} |
| 77 | ADAPTER_NS=${ADAPTER_NS:-voltha} |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 78 | WITH_TIMINGS=${WITH_TIMINGS:-no} |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 79 | WITH_BBSIM=${WITH_BBSIM:-no} |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 80 | WITH_RADIUS=${WITH_RADIUS:-no} |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 81 | WITH_EAPOL=${WITH_EAPOL:-yes} |
| 82 | WITH_DHCP=${WITH_DHCP:-yes} |
| 83 | WITH_IGMP=${WITH_IGMP:-no} |
David Bainbridge | b270c20 | 2019-07-26 01:44:42 +0000 | [diff] [blame] | 84 | WITH_ONOS=${WITH_ONOS:-yes} |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 85 | WITH_CHAOS=${WITH_CHAOS:-no} |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 86 | WITH_ADAPTERS=${WITH_ADAPTERS:-yes} |
David K. Bainbridge | da33d65 | 2020-03-06 10:31:23 -0800 | [diff] [blame] | 87 | WITH_SIM_ADAPTERS=${WITH_SIM_ADAPTERS:-no} |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 88 | WITH_OPEN_ADAPTERS=${WITH_OPEN_ADAPTERS:-yes} |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 89 | WITH_PORT_FORWARDS=${WITH_PORT_FORWARDS:-yes} |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 90 | WITH_KAFKA=${WITH_KAFKA:-yes} |
| 91 | WITH_ETCD=${WITH_ETCD:-yes} |
David Bainbridge | 05cd882 | 2019-11-19 17:43:53 +0000 | [diff] [blame] | 92 | ONLY_ONE=${ONLY_ONE:-yes} |
David K. Bainbridge | b859e91 | 2020-03-13 14:07:52 -0700 | [diff] [blame] | 93 | CONFIG_SADIS=${CONFIG_SADIS:-no} # yes | no | file | bbsim | URL |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 94 | SADIS_SUBSCRIBERS=${SADIS_SUBSCRIBERS:-http://bbsim.$VOLTHA_NS.svc:50074/v2/subscribers/%s} |
| 95 | SADIS_BANDWIDTH_PROFILES=${SADIS_BANDWIDTH_PROFILES:-http://bbsim.$VOLTHA_NS.svc:50074/v2/bandwidthprofiles/%s} |
Hardik Windlass | b314760 | 2020-03-09 16:59:15 +0530 | [diff] [blame] | 96 | SADIS_CFG=${SADIS_CFG:-onos-files/onos-sadis-sample.json} |
David Bainbridge | 27790d6 | 2019-08-13 22:43:19 +0000 | [diff] [blame] | 97 | INSTALL_ONOS_APPS=${INSTALL_ONOS_APPS:-no} |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 98 | JUST_K8S=${JUST_K8S:-no} |
| 99 | DEPLOY_K8S=${DEPLOY_K8S:-yes} |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 100 | INSTALL_KUBECTL=${INSTALL_KUBECTL:-yes} |
| 101 | INSTALL_HELM=${INSTALL_HELM:-yes} |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 102 | UPDATE_HELM_REPOS=${UPDATE_HELM_REPOS:-yes} |
Matteo Scandolo | fab9862 | 2020-01-28 15:17:20 -0800 | [diff] [blame] | 103 | WAIT_ON_DOWN=${WAIT_ON_DOWN:-yes} |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 104 | WAIT_TIMEOUT=${WAIT_TIMEOUT:-30m} |
| 105 | VOLTHA_DOWN_ON_TIMEOUT=${VOLTHA_DOWN_ON_TIMEOUT:-no} |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 106 | VOLTHA_LOG_LEVEL=${VOLTHA_LOG_LEVEL:-WARN} |
David Bainbridge | 90fd8e3 | 2019-08-21 23:32:47 +0000 | [diff] [blame] | 107 | VOLTHA_CHART=${VOLTHA_CHART:-onf/voltha} |
| 108 | VOLTHA_CHART_VERSION=${VOLTHA_CHART_VERSION:-latest} |
| 109 | VOLTHA_BBSIM_CHART=${VOLTHA_BBSIM_CHART:-onf/bbsim} |
Matteo Scandolo | dcd29f5 | 2019-10-07 15:42:42 -0700 | [diff] [blame] | 110 | VOLTHA_BBSIM_CHART_VERSION=${VOLTHA_BBSIM_CHART_VERSION:-latest} |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame] | 111 | VOLTHA_ADAPTER_SIM_CHART=${VOLTHA_ADAPTER_SIM_CHART:-onf/voltha-adapter-simulated} |
David Bainbridge | 90fd8e3 | 2019-08-21 23:32:47 +0000 | [diff] [blame] | 112 | VOLTHA_ADAPTER_SIM_CHART_VERSION=${VOLTHA_ADAPTER_SIM_CHART_VERSION:-latest} |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame] | 113 | 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] | 114 | 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] | 115 | 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] | 116 | VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION=${VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION:-latest} |
David K. Bainbridge | da33d65 | 2020-03-06 10:31:23 -0800 | [diff] [blame] | 117 | ONOS_CHART=${ONOS_CHART:-onf/onos} |
Andrea Campanella | 2132329 | 2019-12-18 11:44:19 -0800 | [diff] [blame] | 118 | ONOS_CHART_VERSION=${ONOS_CHART_VERSION:-latest} |
David Bainbridge | 2eaf2cf | 2020-03-18 12:54:08 -0700 | [diff] [blame] | 119 | EXTRA_HELM_INSTALL_ARGS=${EXTRA_HELM_INSTALL_ARGS:-} |
| 120 | INTERNAL_EXTRA_HELM_INSTALL_ARGS= |
uottremb | b16d398 | 2020-02-28 08:34:36 +0100 | [diff] [blame] | 121 | NUM_OF_BBSIM=${NUM_OF_BBSIM:-1} |
| 122 | MAX_NUM_OF_BBSIM=10 |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 123 | |
| 124 | HAVE_GO=$(which go >/dev/null 2>&1 && echo "yes" || echo "no") |
| 125 | HOSTOS=$(uname -s | tr "[:upper:]" "[:lower:"]) |
| 126 | HOSTARCH=$(uname -m | tr "[:upper:]" "[:lower:"]) |
| 127 | if [ $HOSTARCH == "x86_64" ]; then |
| 128 | HOSTARCH="amd64" |
| 129 | fi |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 130 | |
uottremb | b16d398 | 2020-02-28 08:34:36 +0100 | [diff] [blame] | 131 | # check number (range) of bbsim, max bbsim must not exceed 10 instances! |
| 132 | # note: instances will be numbered from 0 to 9 |
| 133 | if [ "$1" == "up" ]; then |
David K. Bainbridge | 4342240 | 2020-03-06 07:41:22 -0800 | [diff] [blame] | 134 | if [ "$NUM_OF_BBSIM" -lt 1 ]; then |
| 135 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid setting of BBSIM instances. NUM_OF_BBSIM is less than 1${NORMAL}" |
| 136 | exit 1 |
| 137 | fi |
| 138 | if [ "$NUM_OF_BBSIM" -gt $MAX_NUM_OF_BBSIM ]; then |
| 139 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid setting of BBSIM instances. NUM_OF_BBSIM is greater than $MAX_NUM_OF_BBSIM${NORMAL}" |
| 140 | exit 1 |
| 141 | fi |
uottremb | b16d398 | 2020-02-28 08:34:36 +0100 | [diff] [blame] | 142 | fi |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 143 | # Verify TYPE setting |
| 144 | if [ $(echo ":minimal:full:" | grep -ic ":$TYPE:") -eq 0 ]; then |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 145 | >&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] | 146 | exit 1 |
| 147 | fi |
| 148 | |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 149 | function parseDuration() { |
| 150 | local DUR=$1 |
| 151 | local RESULT=0 |
David Bainbridge | 6cdb646 | 2020-03-25 10:24:38 -0700 | [diff] [blame] | 152 | local TERMS=$(echo $DUR | sed -Ee 's/([sSmMhHdD])/\1 /g' -e 's/,$//g') |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 153 | for TERM in $TERMS; do |
David Bainbridge | 6cdb646 | 2020-03-25 10:24:38 -0700 | [diff] [blame] | 154 | local VALUE=$(echo $TERM | sed -Ee 's/([0-9]+)[sSmMhHdD]/\1/') |
| 155 | local UNIT=$(echo $TERM | sed -Ee 's/[0-9]+([sSmMhHdD])/\1/') |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 156 | case $UNIT in |
| 157 | s|S) |
| 158 | RESULT=$(($RESULT + $VALUE)) ;; |
| 159 | m|M) |
| 160 | RESULT=$(($RESULT + ($VALUE * 60))) ;; |
| 161 | h|H) |
| 162 | RESULT=$(($RESULT + ($VALUE * 3600))) ;; |
| 163 | d|D) |
| 164 | RESULT=$(($RESULT + ($VALUE * 86400))) ;; |
| 165 | *) ;; |
| 166 | esac |
| 167 | done |
| 168 | echo $RESULT |
| 169 | } |
| 170 | |
| 171 | function doTimeout() { |
| 172 | local MSG=$1 |
| 173 | 2>&1 echo -e "\n${RED}${BOLD}${ERROR}TIMEOUT:${NORMAL}${RED} Operation timed out after '$WAIT_TIMEOUT': $MSG" |
| 174 | exit 125 |
| 175 | } |
| 176 | |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 177 | function get_service_ep() { |
| 178 | local NS=$1 |
| 179 | local NAME=$2 |
| 180 | kubectl -n $NS get service $NAME -o json | jq -r '.spec.clusterIP + ":" + (.spec.ports[0].port|tostring)' |
| 181 | } |
| 182 | |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 183 | # Used to verify configuration values are set to "yes" or "no" value or convert |
| 184 | # equivalents to "yes" or "no" |
| 185 | function verify_yes_no() { |
| 186 | local VAR=$1 |
| 187 | local VAL=$(eval echo \$$VAR) |
| 188 | if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$VAL:") -eq 0 ]; then |
| 189 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid '$VAR' value of '$VAL'. Should be 'yes' or 'no'${NORMAL}" |
| 190 | echo "INVALID" |
| 191 | return 1 |
| 192 | fi |
| 193 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$VAL:") -eq 1 ]; then |
| 194 | echo "yes" |
| 195 | else |
| 196 | echo "no" |
| 197 | fi |
| 198 | return 0 |
| 199 | } |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 200 | |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 201 | ALL_YES_NO="\ |
David K. Bainbridge | 484d80c | 2020-03-05 21:44:34 -0800 | [diff] [blame] | 202 | ENABLE_ONOS_EXTRANEOUS_RULES \ |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 203 | WITH_TIMINGS \ |
| 204 | WITH_BBSIM \ |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 205 | WITH_EAPOL \ |
| 206 | WITH_DHCP \ |
| 207 | WITH_IGMP \ |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 208 | WITH_CHAOS \ |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 209 | WITH_ADAPTERS \ |
| 210 | WITH_SIM_ADAPTERS \ |
| 211 | WITH_OPEN_ADAPTERS \ |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 212 | WITH_PORT_FORWARDS \ |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 213 | JUST_K8S \ |
| 214 | DEPLOY_K8S \ |
| 215 | INSTALL_ONOS_APPS \ |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 216 | INSTALL_KUBECTL \ |
| 217 | INSTALL_HELM \ |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 218 | UPDATE_HELM_REPOS \ |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 219 | WAIT_ON_DOWN \ |
David Bainbridge | 70c0ea8 | 2019-11-14 23:25:26 +0000 | [diff] [blame] | 220 | ONLY_ONE \ |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 221 | VOLTHA_DOWN_ON_TIMEOUT \ |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 222 | " |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 223 | |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 224 | ALL_OPTIONS="\ |
| 225 | NAME \ |
| 226 | TYPE \ |
| 227 | $ALL_YES_NO \ |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 228 | WAIT_TIMEOUT \ |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 229 | VOLTHA_LOG_LEVEL \ |
| 230 | VOLTHA_CHART \ |
David Bainbridge | 90fd8e3 | 2019-08-21 23:32:47 +0000 | [diff] [blame] | 231 | VOLTHA_CHART_VERSION \ |
| 232 | VOLTHA_BBSIM_CHART \ |
| 233 | VOLTHA_BBSIM_CHART_VERSION \ |
uottremb | d5a2057 | 2020-03-06 09:15:01 +0100 | [diff] [blame] | 234 | NUM_OF_BBSIM \ |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 235 | VOLTHA_ADAPTER_SIM_CHART \ |
David Bainbridge | 90fd8e3 | 2019-08-21 23:32:47 +0000 | [diff] [blame] | 236 | VOLTHA_ADAPTER_SIM_CHART_VERSION \ |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 237 | VOLTHA_ADAPTER_OPEN_OLT_CHART \ |
David Bainbridge | 90fd8e3 | 2019-08-21 23:32:47 +0000 | [diff] [blame] | 238 | VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION \ |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 239 | VOLTHA_ADAPTER_OPEN_ONU_CHART \ |
David Bainbridge | 90fd8e3 | 2019-08-21 23:32:47 +0000 | [diff] [blame] | 240 | VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION \ |
David K. Bainbridge | da33d65 | 2020-03-06 10:31:23 -0800 | [diff] [blame] | 241 | ONOS_CHART \ |
Andrea Campanella | 2132329 | 2019-12-18 11:44:19 -0800 | [diff] [blame] | 242 | ONOS_CHART_VERSION \ |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 243 | ONOS_API_PORT \ |
| 244 | ONOS_SSH_PORT \ |
David K. Bainbridge | b859e91 | 2020-03-13 14:07:52 -0700 | [diff] [blame] | 245 | CONFIG_SADIS \ |
Hardik Windlass | b314760 | 2020-03-09 16:59:15 +0530 | [diff] [blame] | 246 | SADIS_CFG \ |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 247 | VOLTHA_API_PORT \ |
| 248 | VOLTHA_SSH_PORT \ |
| 249 | VOLTHA_ETCD_PORT \ |
David K. Bainbridge | 00ecd38 | 2020-02-28 12:31:58 -0800 | [diff] [blame] | 250 | VOLTHA_KAFKA_PORT \ |
David K. Bainbridge | 8f7f30b | 2020-01-08 13:06:16 -0800 | [diff] [blame] | 251 | VK_RELEASE \ |
| 252 | KIND_VERSION \ |
| 253 | VOLTCTL_VERSION \ |
David Bainbridge | a34993d | 2020-04-01 09:15:42 -0700 | [diff] [blame] | 254 | HELM_VERSION \ |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 255 | WITH_RADIUS \ |
| 256 | WITH_KAFKA \ |
| 257 | WITH_ETCD \ |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 258 | WITH_ONOS \ |
David Bainbridge | 6ca4010 | 2020-04-08 11:30:40 -0700 | [diff] [blame^] | 259 | VOLTHA_NS \ |
| 260 | ADAPTER_NS \ |
| 261 | INFRA_NS \ |
| 262 | BBSIM_NS \ |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 263 | " |
David Bainbridge | 0129495 | 2019-07-30 19:33:45 +0000 | [diff] [blame] | 264 | |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 265 | # Iterate over yes/no configuration options and validate |
| 266 | for VAR in $ALL_YES_NO; do |
| 267 | eval $VAR=$(verify_yes_no $VAR) |
| 268 | if [ "$(eval echo \$$VAR)" == "INVALID" ]; then |
| 269 | exit 1; |
| 270 | fi |
| 271 | done |
David Bainbridge | b270c20 | 2019-07-26 01:44:42 +0000 | [diff] [blame] | 272 | |
David Bainbridge | 15f6f23 | 2020-03-30 09:15:43 -0700 | [diff] [blame] | 273 | # Special case for CONFIG_SADIS |
| 274 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$CONFIG_SADIS:") -eq 1 ]; then |
| 275 | CONFIG_SADIS="yes" |
| 276 | fi |
| 277 | if [ $(echo ":n:no:false:0:" | grep -ic ":$CONFIG_SADIS:") -eq 1 ]; then |
| 278 | CONFIG_SADIS="no" |
| 279 | fi |
| 280 | |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 281 | # Special case for WITH_ONOS, WITH_RADIUS, WITH_KAFKA, and WITH_ETCD |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 282 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_KAFKA:") -eq 1 ]; then |
| 283 | WITH_KAFKA="yes" |
| 284 | fi |
| 285 | if [ $(echo ":n:no:false:0:" | grep -ic ":$WITH_KAFKA:") -eq 1 ]; then |
| 286 | WITH_KAFKA="no" |
| 287 | fi |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 288 | if [ $(echo ":external:" | grep -ic ":$WITH_KAFKA:") -eq 1 ]; then |
| 289 | WITH_KAFKA="external" |
| 290 | fi |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 291 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_ETCD:") -eq 1 ]; then |
| 292 | WITH_ETCD="yes" |
| 293 | fi |
| 294 | if [ $(echo ":n:no:false:0:" | grep -ic ":$WITH_ETCD:") -eq 1 ]; then |
| 295 | WITH_ETCD="no" |
| 296 | fi |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 297 | if [ $(echo ":external:" | grep -ic ":$WITH_ETCD:") -eq 1 ]; then |
| 298 | WITH_ETCD="external" |
| 299 | fi |
David Bainbridge | 29c31cb | 2020-04-06 09:45:50 -0700 | [diff] [blame] | 300 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_RADIUS:") -eq 1 ]; then |
| 301 | WITH_RADIUS="yes" |
| 302 | fi |
| 303 | if [ $(echo ":n:no:false:0:" | grep -ic ":$WITH_RADIUS:") -eq 1 ]; then |
| 304 | WITH_RADIUS="no" |
| 305 | fi |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 306 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_ONOS:") -eq 1 ]; then |
| 307 | WITH_ONOS="yes" |
| 308 | fi |
| 309 | if [ $(echo ":n:no:false:0:" | grep -ic ":$WITH_ONOS:") -eq 1 ]; then |
| 310 | WITH_ONOS="no" |
| 311 | fi |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 312 | |
David K. Bainbridge | da33d65 | 2020-03-06 10:31:23 -0800 | [diff] [blame] | 313 | # Check for prerequiste tools |
David K. Bainbridge | 726ff6a | 2020-03-06 11:09:50 -0800 | [diff] [blame] | 314 | TOOLS="curl sed jq" |
David K. Bainbridge | da33d65 | 2020-03-06 10:31:23 -0800 | [diff] [blame] | 315 | if [ $DEPLOY_K8S == "yes" ]; then |
| 316 | TOOLS+=" docker" |
| 317 | fi |
| 318 | NOT_FOUND="" |
| 319 | for T in $TOOLS; do |
| 320 | if [ -z "$(which $T)" ]; then |
| 321 | NOT_FOUND+=" $T" |
| 322 | fi |
| 323 | done |
| 324 | |
| 325 | if [ ! -z "$NOT_FOUND" ]; then |
| 326 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} The following required tools where not found, please install them:$NOT_FOUND" |
| 327 | exit 1 |
| 328 | fi |
| 329 | |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 330 | TIMEOUT_SECONDS=$(parseDuration $WAIT_TIMEOUT) |
| 331 | |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 332 | mkdir -p .voltha |
| 333 | touch .voltha/ports |
| 334 | HAVE=$(grep $NAME .voltha/ports) |
| 335 | if [ "$HAVE X" == " X" ]; then |
| 336 | # Find free port prefix |
| 337 | START=81 |
| 338 | while true; do |
| 339 | if [ $(grep -c $START .voltha/ports) -eq 0 ]; then |
| 340 | break |
| 341 | fi |
| 342 | START=$(expr $START + 1) |
| 343 | done |
| 344 | DELTA=$(expr $START - 81) |
David Bainbridge | a259542 | 2019-10-22 03:54:28 +0000 | [diff] [blame] | 345 | ONOS_API_PORT=${ONOS_API_PORT:-${START}81} |
| 346 | ONOS_SSH_PORT=${ONOS_SSH_PORT:-${START}01} |
| 347 | VOLTHA_API_PORT=${VOLTHA_API_PORT:-5$(expr 55 + $DELTA)55} |
| 348 | VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$(expr 50 + $DELTA)22} |
| 349 | VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$(expr 23 + $DELTA)79} |
David K. Bainbridge | 00ecd38 | 2020-02-28 12:31:58 -0800 | [diff] [blame] | 350 | VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(expr 90 + $DELTA)92} |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 351 | else |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 352 | VALUES=$(echo $HAVE | sed -e 's/\s//g' | cut -d= -f2) |
David Bainbridge | a259542 | 2019-10-22 03:54:28 +0000 | [diff] [blame] | 353 | ONOS_API_PORT=${ONOS_API_PORT:-$(echo $VALUES | cut -d, -f1)} |
| 354 | ONOS_SSH_PORT=${ONOS_SSH_PORT:-$(echo $VALUES | cut -d, -f2)} |
| 355 | VOLTHA_API_PORT=${VOLTHA_API_PORT:-$(echo $VALUES | cut -d, -f3)} |
| 356 | VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$(echo $VALUES | cut -d, -f4)} |
| 357 | VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$(echo $VALUES | cut -d, -f5)} |
David K. Bainbridge | 00ecd38 | 2020-02-28 12:31:58 -0800 | [diff] [blame] | 358 | VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(echo $VALUES | cut -d, -f6)} |
| 359 | |
David K. Bainbridge | 00ecd38 | 2020-02-28 12:31:58 -0800 | [diff] [blame] | 360 | # A bit of a hueristic required here as the KAFKA port forward was |
| 361 | # added after the .voltha/ports files was created. Basically, if |
| 362 | # the VOLTHA_KAFKA_PORT isn't in the file then calculate the original |
| 363 | # DELTA from the VOLTHA_SSH_PORT and apply it to the VOLTHA_KAFKA_PORT |
| 364 | if [ -z "$VOLTHA_KAFKA_PORT" ]; then |
| 365 | DELTA=$((VOLTHA_SSH_PORT/100-50)) |
| 366 | VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(expr 90 + $DELTA)92} |
| 367 | fi |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 368 | fi |
| 369 | |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 370 | PORTTMP=$(mktemp -u) |
| 371 | cat .voltha/ports | grep -v $NAME > $PORTTMP |
David K. Bainbridge | 00ecd38 | 2020-02-28 12:31:58 -0800 | [diff] [blame] | 372 | echo "$NAME=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT,$VOLTHA_KAFKA_PORT" >> $PORTTMP |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 373 | cp $PORTTMP .voltha/ports |
| 374 | rm -f $PORTTMP |
| 375 | |
David Bainbridge | 27790d6 | 2019-08-13 22:43:19 +0000 | [diff] [blame] | 376 | export ONOS_API_PORT ONOS_SSH_PORT |
David Bainbridge | 0129495 | 2019-07-30 19:33:45 +0000 | [diff] [blame] | 377 | |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 378 | IDX=1 |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 379 | CLOCK="TIME:" |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 380 | SPIN_PARTS= |
| 381 | NOT_VERIFIED= |
David Bainbridge | f858a02 | 2019-08-14 21:25:11 +0000 | [diff] [blame] | 382 | THEX= |
| 383 | BUILD= |
| 384 | CROSS= |
| 385 | ENTER= |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 386 | VERIFIED= |
| 387 | HELM= |
| 388 | OLD_KEY= |
| 389 | BIRD= |
| 390 | HIGH_VOLTAGE= |
| 391 | PLUG= |
| 392 | RESTART= |
| 393 | FORWARD= |
| 394 | INSTALL= |
| 395 | STOP= |
| 396 | GO= |
| 397 | DOWNLOAD= |
| 398 | GEAR= |
| 399 | NO_ENTRY= |
| 400 | LOCK= |
| 401 | |
| 402 | if [ $FANCY -eq 1 ]; then |
| 403 | SPIN_PARTS="\ |
| 404 | \xe2\xa2\x8e\xe2\xa1\xb0 \ |
| 405 | \xe2\xa2\x8e\xe2\xa1\xa1 \ |
| 406 | \xe2\xa2\x8e\xe2\xa1\x91 \ |
| 407 | \xe2\xa2\x8e\xe2\xa0\xb1 \ |
| 408 | \xe2\xa0\x8e\xe2\xa1\xb1 \ |
| 409 | \xe2\xa2\x8a\xe2\xa1\xb1 \ |
| 410 | \xe2\xa2\x8c\xe2\xa1\xb1 \ |
| 411 | \xe2\xa2\x86\xe2\xa1\xb1 \ |
| 412 | " |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 413 | CLOCK="\xe2\x8f\xb1" |
David Bainbridge | f858a02 | 2019-08-14 21:25:11 +0000 | [diff] [blame] | 414 | THEX="${RED}${BOLD}\xe2\x9c\x97\x20${NORMAL}" |
| 415 | ENTER="${YELLOW}${BOLD}\xe2\x8e\x86${NORMAL}" |
| 416 | CROSS="${YELLOW}${BOLD}\xe2\x9c\x9a${NORMAL}" |
| 417 | BUILD="${YELLOW}${BOLD}\xf0\x9f\x8f\x97${NORMAL}" |
| 418 | NOT_VERIFIED="$BUILD" |
| 419 | VERIFIED="${GREEN}${BOLD}\xe2\x9c\x93\x20${NORMAL}" |
| 420 | HELM="${BLUE}${BOLD}\xE2\x8E\x88${NORMAL}" |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 421 | OLD_KEY="\xF0\x9F\x97\x9D" |
| 422 | BIRD="\xF0\x9F\x90\xA6" |
| 423 | HIGH_VOLTAGE="\xE2\x9A\xA1" |
| 424 | PLUG="\xF0\x9F\xa7\xa9" |
| 425 | RESTART="\xf0\x9f\x94\x84" |
| 426 | FORWARD="\xE2\x87\xA8" |
| 427 | INSTALL="\xF0\x9F\x8F\x97" |
| 428 | STOP="\xf0\x9f\x9b\x91" |
| 429 | GO="\xf0\x9f\x9a\x80" |
| 430 | DOWNLOAD="\xf0\x9f\x93\xa5" |
| 431 | GEAR="\xe2\x9a\x99" |
| 432 | NO_ENTRY="\xe2\x9b\x94" |
| 433 | LOCK="\xf0\x9f\x94\x92" |
| 434 | fi |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 435 | |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 436 | duration() { |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 437 | local h=$(expr $1 / 3600) |
| 438 | local m=$(expr $1 % 3600 / 60) |
| 439 | local s=$(expr $1 % 60) |
| 440 | local t="" |
| 441 | |
| 442 | if [ $h -gt 0 ]; then |
| 443 | t="$t${h}h" |
| 444 | fi |
| 445 | if [ $m -gt 0 ]; then |
| 446 | t="$t${m}m" |
| 447 | fi |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 448 | echo "$t${s}s" |
| 449 | } |
| 450 | |
| 451 | printtime() { |
| 452 | local INDENT= |
| 453 | if [ "$1" == "-" ]; then |
| 454 | INDENT=" " |
| 455 | shift |
| 456 | fi |
| 457 | echo -e "$INDENT $CLOCK $(duration $1)" |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 458 | } |
| 459 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 460 | bspin() { |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 461 | IDX=1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 462 | local INDENT= |
| 463 | if [ "$1" == "-" ]; then |
| 464 | INDENT=" " |
| 465 | shift |
| 466 | fi |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 467 | if [ $FANCY -eq 0 ]; then |
| 468 | LINE=$(echo $* | sed -e 's/[\s+-]//g') |
| 469 | if [ "$LINE X" == " X" ]; then |
| 470 | return |
| 471 | fi |
| 472 | echo -e "$CIVIS$INDENT$*" |
| 473 | else |
| 474 | echo -en "$CIVIS$INDENT $*" |
| 475 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 476 | } |
| 477 | |
| 478 | sspin() { |
| 479 | local INDENT= |
| 480 | if [ "$1" == "-" ]; then |
| 481 | INDENT=" " |
| 482 | shift |
| 483 | fi |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 484 | if [ $FANCY -eq 0 ]; then |
| 485 | LINE=$(echo $* | sed -e 's/[\s+-]//g') |
| 486 | if [ "$LINE X" == " X" ]; then |
| 487 | return |
| 488 | fi |
| 489 | echo -e "$INDENT$*" |
| 490 | else |
| 491 | C=$(echo $SPIN_PARTS | cut '-d ' -f $IDX) |
| 492 | echo -en "\r$INDENT$C $*" |
| 493 | IDX=$(expr $IDX + 1) |
| 494 | if [ $IDX -gt 8 ]; then |
| 495 | IDX=1 |
| 496 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 497 | fi |
| 498 | } |
| 499 | |
| 500 | espin() { |
| 501 | local INDENT= |
| 502 | if [ "$1" == "-" ]; then |
| 503 | INDENT=" " |
| 504 | shift |
| 505 | fi |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 506 | if [ $FANCY -eq 0 ]; then |
| 507 | LINE=$(echo $* | sed -e 's/[\s+-]//g') |
| 508 | if [ "$LINE X" == " X" ]; then |
| 509 | return |
| 510 | fi |
| 511 | echo -e "$INDENT$*" |
| 512 | else |
| 513 | echo -e "\r$INDENT$*$CNORM" |
| 514 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 515 | } |
| 516 | |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 517 | if [ "$1" == "get" -a "$2" == "voltconfig" ]; then |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 518 | echo "$HOME/.volt/config-$NAME" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 519 | exit |
| 520 | fi |
| 521 | |
Matteo Scandolo | 7ef6ba5 | 2019-10-04 09:20:37 -0700 | [diff] [blame] | 522 | 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] | 523 | >&2 echo "What wouild you like to do today:" |
| 524 | >&2 echo " up - bring up voltha" |
| 525 | >&2 echo " down - tear down voltha" |
| 526 | >&2 echo " dump - create a debug dump of running system" |
| 527 | exit 1 |
| 528 | fi |
| 529 | |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 530 | push_onos_config() { |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 531 | local TYPE=$1 |
| 532 | local MSG=$2 |
| 533 | local RESOURCE=$3 |
| 534 | local DATA=$4 |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 535 | |
David K. Bainbridge | b4b163b | 2020-02-19 15:55:06 -0800 | [diff] [blame] | 536 | # Thanks to the latest version of ONOS using the return code 207 this gets a |
| 537 | # whole lot nastier. Can't thank them enough for doing this. So in order to |
| 538 | # capture the command and the output in the log file as well as capture the |
| 539 | # status code to verify it is 200 and not 207 mutltiple files and a bit of |
| 540 | # hackery must be used. Thanks again ONOS. |
| 541 | local CMD_ECHO=$(mktemp -u) |
| 542 | local CMD_OUTPUT=$(mktemp -u) |
| 543 | local SC_OUTPUT=$(mktemp -u) |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 544 | local WAIT_START=$(date +%s) |
David K. Bainbridge | b4b163b | 2020-02-19 15:55:06 -0800 | [diff] [blame] | 545 | |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 546 | bspin - "$MSG $GEAR" |
| 547 | while true; do |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 548 | if [ $(($(date +%s) - $WAIT_START)) -gt $TIMEOUT_SECONDS ]; then |
| 549 | espin - "$THEX" |
David Bainbridge | 1cecba5 | 2020-03-30 09:43:10 -0700 | [diff] [blame] | 550 | rm -f $CMD_ECHO $CMD_OUTPUT $SC_OUTPUT |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 551 | doTimeout "waiting for ONOS config push on $RESOURCE" |
| 552 | fi |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 553 | if [ $TYPE == "file" ]; then |
David K. Bainbridge | b859e91 | 2020-03-13 14:07:52 -0700 | [diff] [blame] | 554 | (set -x; curl --fail -sSL --user karaf:karaf -w "%{http_code}" -o $CMD_OUTPUT -X POST -H Content-Type:application/json http://$_ONOS_API_EP/onos/v1/$RESOURCE --data @$DATA >$SC_OUTPUT 2>/dev/null) >>$CMD_ECHO 2>&1 |
| 555 | RESULT=$? |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 556 | fi |
| 557 | if [ $TYPE == "json" ]; then |
David K. Bainbridge | b859e91 | 2020-03-13 14:07:52 -0700 | [diff] [blame] | 558 | (set -x; curl --fail -sSL --user karaf:karaf -w "%{http_code}" -o $CMD_OUTPUT -X POST -H Content-Type:application/json http://$_ONOS_API_EP/onos/v1/$RESOURCE --data $DATA >$SC_OUTPUT 2>/dev/null) >>$CMD_ECHO 2>&1 |
| 559 | RESULT=$? |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 560 | fi |
David K. Bainbridge | b4b163b | 2020-02-19 15:55:06 -0800 | [diff] [blame] | 561 | # Dump everything to the log |
| 562 | cat $CMD_ECHO >> $LOG |
David K. Bainbridge | b859e91 | 2020-03-13 14:07:52 -0700 | [diff] [blame] | 563 | test -r $CMD_OUTPUT && cat $CMD_OUTPUT >> $LOG |
David K. Bainbridge | b4b163b | 2020-02-19 15:55:06 -0800 | [diff] [blame] | 564 | SC=$(cat $SC_OUTPUT) |
David K. Bainbridge | b859e91 | 2020-03-13 14:07:52 -0700 | [diff] [blame] | 565 | echo "RESPONSE CODE: $SC" >> $LOG |
| 566 | echo "ERROR CODE: $RESULT" >> $LOG |
David K. Bainbridge | b4b163b | 2020-02-19 15:55:06 -0800 | [diff] [blame] | 567 | |
| 568 | # clean up temp files |
| 569 | rm -f $CMD_ECHO $CMD_OUTPUT $SC_OUTPUT |
| 570 | if [ $RESULT -eq 0 -a "$SC" == "200" ]; then |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 571 | break |
| 572 | fi |
Matteo Scandolo | 9a77a73 | 2020-01-09 14:24:12 -0800 | [diff] [blame] | 573 | sleep 1 |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 574 | sspin - |
| 575 | done |
| 576 | espin - $VERIFIED |
| 577 | } |
| 578 | |
Matteo Scandolo | 9a77a73 | 2020-01-09 14:24:12 -0800 | [diff] [blame] | 579 | check_onos_app_active() { |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 580 | local APP_ID=$1 |
| 581 | local WAIT_START=$(date +%s) |
Matteo Scandolo | 9a77a73 | 2020-01-09 14:24:12 -0800 | [diff] [blame] | 582 | |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 583 | bspin - "Checking that $APP_ID is active $CLOCK" |
| 584 | while true; do |
| 585 | if [ $(($(date +%s) - $WAIT_START)) -gt $TIMEOUT_SECONDS ]; then |
| 586 | espin - "$THEX" |
| 587 | doTimeout "waiting for ONOS application activation '$APP_ID'" |
| 588 | fi |
| 589 | (set -x; curl --fail -sSL --user karaf:karaf -X GET http://$_ONOS_API_EP/onos/v1/applications/$APP_ID | grep ACTIVE >>$LOG 2>&1) >>$LOG 2>&1 |
| 590 | if [ $? -eq 0 ]; then |
| 591 | break |
| 592 | fi |
| 593 | sleep 1 |
| 594 | sspin - |
| 595 | done |
| 596 | sleep 5 # OSGI components take a little longer that the app to activate |
| 597 | espin - $VERIFIED |
Matteo Scandolo | 9a77a73 | 2020-01-09 14:24:12 -0800 | [diff] [blame] | 598 | } |
| 599 | |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 600 | override_onos_app() { |
| 601 | local APP=$1 |
| 602 | local NAME=$(basename $APP | sed -e 's/^[0-9][0-9]*-//g' -e 's/-.*$//g') |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 603 | local WAIT_START=$(date +%s) |
| 604 | |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 605 | while true; do |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 606 | if [ $(($(date +%s) - $WAIT_START)) -gt $TIMEOUT_SECONDS ]; then |
| 607 | espin - "$THEX" |
| 608 | doTimeout "waiting to overwrite ONOS application '$APP'" |
| 609 | fi |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 610 | sspin - |
| 611 | # Attempt to delete old version (if it exists) |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 612 | (set -x; curl --fail -sSL --user karaf:karaf -X DELETE http://$_ONOS_API_EP/onos/v1/applications/$NAME >>$LOG 2>&1) >>$LOG 2>&1 |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 613 | sspin - |
| 614 | if [ $? -ne 0 ]; then |
| 615 | continue |
| 616 | fi |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 617 | (set -x; curl --fail -sSL --user karaf:karaf -X POST -H Content-Type:application/octet-stream http://$_ONOS_API_EP/onos/v1/applications?activate=true --data-binary @$APP >>$LOG 2>&1) >>$LOG 2>&1 |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 618 | if [ $? -eq 0 ]; then |
| 619 | break |
| 620 | fi |
| 621 | sleep .2 |
| 622 | done |
| 623 | } |
| 624 | |
| 625 | activate_onos_app() { |
| 626 | local MSG="$1" |
| 627 | local APP=$2 |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 628 | local WAIT_START=$(date +%s) |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 629 | |
| 630 | bspin - "$MSG $GO" |
| 631 | while true; do |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 632 | if [ $(($(date +%s) - $WAIT_START)) -gt $TIMEOUT_SECONDS ]; then |
| 633 | espin - "$THEX" |
| 634 | doTimeout "waiting to activate ONOS application '$APP'" |
| 635 | fi |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 636 | sspin - |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 637 | (set -x; curl --fail -sSL --user karaf:karaf -X POST http://$_ONOS_API_EP/onos/v1/applications/$APP/active >>$LOG 2>&1) >>$LOG 2>&1 |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 638 | if [ $? -eq 0 ]; then |
| 639 | break |
| 640 | fi |
| 641 | sleep .2 |
| 642 | done |
| 643 | espin - "$VERIFIED" |
| 644 | } |
| 645 | |
| 646 | count_pods() { |
| 647 | local NAMESPACE=$1; shift |
| 648 | if [ "$NAMESPACE" == "all-namespaces" ]; then |
| 649 | NAMESPACE="--all-namespaces" |
| 650 | else |
| 651 | NAMESPACE="-n $NAMESPACE" |
| 652 | fi |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 653 | local STATES=$1; shift |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 654 | local PODS=$(kubectl get $NAMESPACE pod -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}") |
| 655 | local COUNT=0 |
| 656 | local PATTERNS="$*" |
| 657 | for POD in $PODS; do |
| 658 | local NAME=$(echo $POD | cut -d/ -f 1) |
| 659 | local STATE=$(echo $POD | cut -d/ -f 2) |
| 660 | local CONTAINERS=$(echo $POD | cut -d/ -f 3 | sed -e 's/_/ /g') |
| 661 | if [ "$STATES" == "*" -o $(echo "$STATES" | grep -c ":$STATE:") -ne 0 ]; then |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 662 | local TOTAL=$(echo $CONTAINERS | wc -w) |
| 663 | local FOUND=$(echo $CONTAINERS | grep -o true | wc -l) |
| 664 | if [ $TOTAL -eq $FOUND ]; then |
| 665 | for PATTERN in $PATTERNS; do |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 666 | if [[ $NAME =~ $PATTERN ]]; then |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 667 | COUNT=$(expr $COUNT + 1) |
| 668 | break |
| 669 | fi |
| 670 | done |
| 671 | fi |
| 672 | fi |
| 673 | done |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 674 | echo $COUNT |
| 675 | } |
| 676 | |
| 677 | wait_for_pods() { |
| 678 | local INDENT= |
| 679 | if [ "$1" == "-" ]; then |
| 680 | INDENT=$1; shift |
| 681 | fi |
| 682 | local NAMESPACE=$1; shift |
| 683 | local EXPECT=$1; shift |
| 684 | local TYPE=$1; shift |
| 685 | local RETRY=$1; shift |
| 686 | local MESSAGE=$1; shift |
| 687 | local PATTERNS=$* |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 688 | local STATES=":Running:" |
| 689 | if [ "$TYPE" == "not" ]; then |
| 690 | STATES="*" |
| 691 | fi |
| 692 | local HAVE=$(count_pods $NAMESPACE "$STATES" $PATTERNS) |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 693 | local ALL=$HAVE |
| 694 | if [ "$TYPE" == "only" ]; then |
| 695 | ALL=$(count_pods "all-namespaces" "*" ".*") |
| 696 | fi |
| 697 | COUNT=$(expr 300 / 15) |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 698 | local WAIT_START=$(date +%s) |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 699 | bspin $INDENT $MESSAGE |
| 700 | sspin $INDENT |
| 701 | if [ $HAVE -ne $EXPECT -o $ALL -ne $HAVE ]; then |
| 702 | while [ $HAVE -ne $EXPECT -o $ALL -ne $HAVE ]; do |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 703 | if [ $(($(date +%s) - $WAIT_START)) -gt $TIMEOUT_SECONDS ]; then |
| 704 | espin $INDENT "$THEX" |
| 705 | doTimeout "waiting for PODs to start" |
| 706 | fi |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 707 | sspin $INDENT |
| 708 | COUNT=$(expr $COUNT - 1) |
| 709 | if [ $COUNT -eq 0 ]; then |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 710 | HAVE=$(count_pods $NAMESPACE "$STATES" $PATTERNS) |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 711 | ALL=$HAVE |
| 712 | if [ "$TYPE" == "only" ]; then |
| 713 | ALL=$(count_pods "all-namespaces" "*" ".*") |
| 714 | fi |
| 715 | COUNT=$(expr 300 / 15) |
| 716 | fi |
| 717 | sleep .15 |
| 718 | done |
| 719 | fi |
| 720 | espin $INDENT $VERIFIED |
| 721 | if [ $HAVE -ne $EXPECT ]; then |
| 722 | return 1 |
| 723 | fi |
| 724 | return 0 |
| 725 | } |
| 726 | |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 727 | port_forward() { |
| 728 | local NS=$1 |
| 729 | local SVC=$2 |
| 730 | local FROM_PORT=$3 |
| 731 | local TO_PORT=$4 |
| 732 | local TAG=$SVC-$NAME |
| 733 | |
David Bainbridge | 70cc33a | 2020-04-07 11:06:59 -0700 | [diff] [blame] | 734 | (set -x; _TAG=$TAG bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n $NS service/$SVC $FROM_PORT:$TO_PORT; done" >>$LOG 2>&1 &) >>$LOG 2>&1 |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 735 | } |
| 736 | |
| 737 | kill_port_forward() { |
| 738 | local TAG=$1-$NAME |
David Bainbridge | c6871d2 | 2019-11-13 17:10:31 +0000 | [diff] [blame] | 739 | 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] | 740 | local PARENTS= |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 741 | local KIDS= |
David Bainbridge | c6871d2 | 2019-11-13 17:10:31 +0000 | [diff] [blame] | 742 | local UNKNOWN= |
| 743 | if [ ! -z "$P_IDS" ]; then |
| 744 | for P_ID in $P_IDS; do |
| 745 | local PP_ID=$(ps -o ppid $P_ID | tail -n +2) |
| 746 | if [ ! -z "$PP_ID" ]; then |
| 747 | if [ $PP_ID -eq 1 ]; then |
| 748 | PARENTS="$PARENTS $P_ID" |
| 749 | else |
| 750 | KIDS="$KIDS $P_ID" |
| 751 | fi |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 752 | else |
David Bainbridge | c6871d2 | 2019-11-13 17:10:31 +0000 | [diff] [blame] | 753 | UNKNOWN="$UNKNOWN $P_ID" |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 754 | fi |
| 755 | done |
David Bainbridge | c6871d2 | 2019-11-13 17:10:31 +0000 | [diff] [blame] | 756 | (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] | 757 | fi |
| 758 | } |
| 759 | |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 760 | if [ "$1" == "down" ]; then |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 761 | echo "Tearing down voltha cluster $NAME" |
| 762 | LOG="down-$NAME.log" |
| 763 | echo $(date -u +"%Y%m%dT%H%M%SZ") >$LOG |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 764 | if [ $WITH_ONOS == "yes" ]; then |
| 765 | bspin "Remove port-forwards: onos-ui-$NAME" |
| 766 | kill_port_forward onos-ui |
| 767 | sspin "Remove port-forwards: onos-ssh-$NAME$CEOL" |
| 768 | kill_port_forward onos-ssh |
| 769 | fi |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 770 | sspin "Remove port-forwards: voltha-api-$NAME$CEOL" |
| 771 | kill_port_forward voltha-api |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 772 | if [ $WITH_ETCD == "yes" -o $WITH_ETCD == "external" ]; then |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 773 | sspin "Remove port-forwards: voltha-etcd-$NAME$CEOL" |
| 774 | kill_port_forward voltha-etcd-cluster-client |
| 775 | fi |
| 776 | if [ $WITH_KAFKA == "yes" ]; then |
| 777 | sspin "Remove port-forwards: voltha-kafka-$NAME$CEOL" |
| 778 | kill_port_forward voltha-kafka |
| 779 | fi |
| 780 | |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 781 | espin "$VERIFIED Remove port-forwards$CEOL" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 782 | if [ $DEPLOY_K8S == "yes" ]; then |
| 783 | if [ -x ./bin/kind ]; then |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 784 | bspin "Delete Kubernetes Kind Cluster" |
| 785 | (set -x; ./bin/kind delete cluster --name voltha-$NAME >>$LOG 2>&1) >>$LOG 2>&1 |
| 786 | espin $VERIFIED |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 787 | else |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 788 | espin "$NO_ENTRY Delete Kubernetes Kind Cluster: kind command not found" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 789 | fi |
| 790 | else |
| 791 | EXISTS=$(helm list -q) |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 792 | EXPECT="voltha" |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 793 | if [ $WITH_ONOS == yes ]; then |
| 794 | EXPECT+=" onos" |
| 795 | fi |
| 796 | if [ $WITH_RADIUS == "yes" ]; then |
| 797 | EXPECT+=" radius" |
| 798 | fi |
| 799 | if [ $WITH_BBSIM == "yes" ]; then |
| 800 | EXPECT+=" bbsim" |
| 801 | fi |
| 802 | if [ $WITH_OPEN_ADAPTERS == "yes" ]; then |
| 803 | EXPECT+=" open-olt open-onu" |
| 804 | fi |
| 805 | if [ $WITH_SIM_ADAPTERS == "yes" ]; then |
| 806 | EXPECT+=" sim" |
| 807 | fi |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 808 | if [ $WITH_ETCD == "external" ]; then |
| 809 | EXPECT+=" etcd-operator etcd-cluster" |
| 810 | elif [ $WITH_ETCD == "yes" ]; then |
| 811 | EXPECT+=" etcd-operator" |
| 812 | fi |
| 813 | if [ $WITH_KAFKA == "external" ]; then |
| 814 | EXPECT+=" kafka" |
| 815 | fi |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 816 | bspin "Remove Helm Deployments" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 817 | for i in $EXISTS; do |
David K. Bainbridge | 4342240 | 2020-03-06 07:41:22 -0800 | [diff] [blame] | 818 | for j in $EXPECT; do |
| 819 | if [[ $i =~ $j ]]; then |
| 820 | sspin "Remove Helm Deployments: $i$CEOL" |
| 821 | (set -x; ./bin/helm delete --no-hooks --purge $i >>$LOG 2>&1) >>$LOG 2>&1 |
| 822 | fi |
| 823 | done |
uottremb | b16d398 | 2020-02-28 08:34:36 +0100 | [diff] [blame] | 824 | done |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 825 | espin "$VERIFIED Remove Helm Deployments$CEOL" |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 826 | if [ "$WAIT_ON_DOWN" == "yes" ]; then |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 827 | PODS="voltha-kafka.* voltha-ofagent.* voltha-rw-core.* voltha-etcd.*" |
| 828 | INFRA_PODS= |
| 829 | ADAPT_PODS= |
| 830 | SIM_PODS= |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 831 | if [ $WITH_RADIUS == "yes" ]; then |
| 832 | PODS+=" radius.*" |
| 833 | fi |
| 834 | if [ $WITH_BBSIM == "yes" ]; then |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 835 | SIM_PODS+=" bbsim.*" |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 836 | fi |
| 837 | if [ $WITH_OPEN_ADAPTERS -o $WITH_SIM_ADAPTERS ]; then |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 838 | ADAPT_PODS+=" adapter-*" |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 839 | fi |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 840 | if [ $WITH_ONOS == "yes" ]; then |
| 841 | INFRA_PODS+=" onos-.*" |
| 842 | fi |
| 843 | if [ $WITH_ETCD == "external" ]; then |
| 844 | INFRA_PODS+=" etcd-operator.* etcd-cluster.*" |
| 845 | elif [ $WITH_ETCD == "yes" ]; then |
| 846 | PODS+=" etcd-operator.*" |
| 847 | fi |
| 848 | if [ $WITH_KAFKA == "external" ]; then |
| 849 | INFRA_PODS+=" kafka.*" |
| 850 | fi |
| 851 | if [ ! -z "$SIM_PODS" ]; then |
| 852 | wait_for_pods "$BBSIM_NS" 0 "not" -1 "Waiting for BBSIM PODs to terminate" $SIM_PODS |
| 853 | fi |
| 854 | if [ ! -z "$INFRA_PODS" ]; then |
| 855 | wait_for_pods "$INFRA_NS" 0 "not" -1 "Waiting for infrastructure PODs to terminate" $INFRA_PODS |
| 856 | fi |
| 857 | if [ ! -z "$ADAPT_PODS" ]; then |
| 858 | wait_for_pods "$ADAPTER_NS" 0 "not" -1 "Waiting for adapter PODs to terminate" $ADAPT_PODS |
| 859 | fi |
| 860 | wait_for_pods "$VOLTHA_NS" 0 "not" -1 "Waiting for VOLTHA PODs to terminate" $PODS |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 861 | fi |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 862 | fi |
Matteo Scandolo | 7ef6ba5 | 2019-10-04 09:20:37 -0700 | [diff] [blame] | 863 | exit |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 864 | fi |
| 865 | |
| 866 | if [ "$1" == "dump" ]; then |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 867 | LOG="dump-$NAME.log" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 868 | TS=$(date -u +"%Y%m%dT%H%M%SZ") |
David Bainbridge | 76514a0 | 2019-10-08 01:50:35 +0000 | [diff] [blame] | 869 | if [ ! -z "$DUMP_FROM" ]; then |
| 870 | TS=$(echo $DUMP_FROM | sed -e 's/[:-]//g') |
| 871 | fi |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 872 | WORK=$(mktemp -u -d) |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 873 | DATA=$WORK/voltha-debug-dump-$NAME-$TS |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 874 | mkdir -p $DATA |
| 875 | echo $TS > $LOG |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 876 | echo -e "Capturing debug dump to voltha-debug-dump-$NAME-$TS.tgz" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 877 | bspin - "Copy install log" |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 878 | if [ -f install-$NAME.log ]; then |
| 879 | (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] | 880 | espin - $VERIFIED |
| 881 | else |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 882 | espin - "$NO_ENTRY Copy install log: install-$NAME.log not found" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 883 | fi |
| 884 | bspin - "Dumping Kubernetes PODs" |
| 885 | (set -x; kubectl get --all-namespaces pods >> $DATA/all-pods.txt 2>&1) >>$LOG 2>&1 |
| 886 | espin - $VERIFIED |
| 887 | bspin - "Dumping Kubernetes SERVICEs" |
| 888 | (set -x; kubectl get --all-namespaces svc >> $DATA/all-services.txt 2>&1) >>$LOG 2>&1 |
| 889 | espin - $VERIFIED |
| 890 | bspin - "Dumping Kubernetes EVENTs" |
| 891 | (set -x; kubectl get --all-namespaces events >> $DATA/all-events.txt 2>&1) >>$LOG 2>&1 |
| 892 | espin - $VERIFIED |
| 893 | bspin - "Dumping VOLTHA POD details" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 894 | PODS="$(kubectl -n $INFRA_NS get pod -o name | grep onos | sed -e 's/^/$INFRA_NS:/g') $(kubectl get -n $VOLTHA_NS pod -o name | sed -e 's/^/$VOLTHA_NS:/g')" |
David Bainbridge | cfd7ca1 | 2019-10-06 03:31:41 +0000 | [diff] [blame] | 895 | SINCE= |
| 896 | if [ ! -z "$DUMP_FROM" ]; then |
| 897 | SINCE="--since-time=$DUMP_FROM" |
| 898 | fi |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 899 | for POD in $PODS; do |
David Bainbridge | 1f0655a | 2019-10-01 22:08:48 +0000 | [diff] [blame] | 900 | NS=$(echo $POD | cut -d: -f1) |
| 901 | POD=$(echo $POD | cut -d: -f2) |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 902 | sspin - "Dumping VOLTHA POD details: $POD$CEOL" |
| 903 | mkdir -p $DATA/$POD |
David Bainbridge | 1f0655a | 2019-10-01 22:08:48 +0000 | [diff] [blame] | 904 | (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] | 905 | sspin - "Dumping VOLTHA POD details: $POD" |
David Bainbridge | cfd7ca1 | 2019-10-06 03:31:41 +0000 | [diff] [blame] | 906 | (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] | 907 | sspin - "Dumping VOLTHA POD details: $POD" |
David Bainbridge | cfd7ca1 | 2019-10-06 03:31:41 +0000 | [diff] [blame] | 908 | (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] | 909 | sspin - "Dumping VOLTHA POD details: $POD" |
| 910 | done |
| 911 | espin - "$VERIFIED Dumping VOLTHA POD details$CEOL" |
| 912 | bspin - "Dumping ETCD" |
| 913 | if [ "$(which etcdctl) X" != " X" ]; then |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 914 | (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] | 915 | espin - $VERIFIED |
| 916 | else |
| 917 | espin - "$NO_ENTRY Dumping ETCD: etcdctl command not available" |
| 918 | fi |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 919 | bspin - "Creating compressed TAR: voltha-debug-dump-$NAME-$TS.tgz" |
| 920 | (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] | 921 | espin - $VERIFIED |
| 922 | bspin - "Cleanup" |
| 923 | (set -x; rm -rf $WORK) >>$LOG 2>&1 |
| 924 | espin - $VERIFIED |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 925 | bspin - "$(ls -l voltha-debug-dump-$NAME-$TS.tgz)" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 926 | espin - $VERIFIED |
| 927 | exit |
| 928 | fi |
| 929 | |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 930 | LOG="install-$NAME.log" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 931 | date > $LOG |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 932 | 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] | 933 | |
| 934 | # Output install options to log |
| 935 | echo "OPTIONS" >> $LOG |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 936 | for O in $ALL_OPTIONS; do |
| 937 | VAL=$(eval echo \$$O) |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 938 | if [ ! -z "$VAL" ]; then |
| 939 | printf " %-30s = %s\n" $O $VAL >> $LOG |
| 940 | fi |
| 941 | done |
| 942 | |
Matteo Scandolo | 7ef6ba5 | 2019-10-04 09:20:37 -0700 | [diff] [blame] | 943 | helm_install() { |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 944 | local INDENT= |
| 945 | if [ "$1" == "-" ]; then |
| 946 | INDENT=$1; shift |
| 947 | fi |
| 948 | local NAMESPACE=$1; shift |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 949 | local INAME=$1; shift |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 950 | local CHART=$1; shift |
David Bainbridge | 90fd8e3 | 2019-08-21 23:32:47 +0000 | [diff] [blame] | 951 | local CHART_VERSION=$1; shift |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 952 | local MESSAGE=$* |
| 953 | |
David Bainbridge | 90fd8e3 | 2019-08-21 23:32:47 +0000 | [diff] [blame] | 954 | if [ "$CHART_VERSION X" != " X" -a "$CHART_VERSION" != "latest" ]; then |
| 955 | CHART_VERSION="--version $CHART_VERSION" |
| 956 | else |
| 957 | CHART_VERSION= |
| 958 | fi |
| 959 | |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 960 | local CHART_ARGS= |
| 961 | if [ -r "${INAME}-values.yaml" ]; then |
| 962 | CHART_ARGS="-f ${INAME}-values.yaml" |
| 963 | fi |
| 964 | |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 965 | local WAIT_START=$(date +%s) |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 966 | COUNT=$(expr 300 / 15) |
| 967 | bspin $INDENT $MESSAGE |
David Bainbridge | 2eaf2cf | 2020-03-18 12:54:08 -0700 | [diff] [blame] | 968 | (set -x; helm install -f $NAME-values.yaml $CHART_ARGS $INTERNAL_EXTRA_HELM_INSTALL_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] | 969 | SUCCESS=$? |
| 970 | while [ $SUCCESS -ne 0 ]; do |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 971 | if [ $(($(date +%s) - $WAIT_START)) -gt $TIMEOUT_SECONDS ]; then |
| 972 | espin "$THEX" |
| 973 | doTimeout "waiting for helm install $CHART" |
| 974 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 975 | sspin $INDENT |
| 976 | COUNT=$(expr $COUNT - 1) |
| 977 | if [ $COUNT -eq 0 ]; then |
Andy Bavier | e22ff25 | 2019-12-19 11:40:31 -0700 | [diff] [blame] | 978 | (set -x; helm delete --purge $INAME >>$LOG 2>&1) >>$LOG 2>&1 |
David Bainbridge | 2eaf2cf | 2020-03-18 12:54:08 -0700 | [diff] [blame] | 979 | (set -x; helm install -f $NAME-values.yaml $CHART_ARGS $INTERNAL_EXTRA_HELM_INSTALL_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 |
Andy Bavier | e22ff25 | 2019-12-19 11:40:31 -0700 | [diff] [blame] | 980 | SUCCESS=$? |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 981 | COUNT=$(expr 300 / 15) |
| 982 | fi |
| 983 | sleep .15 |
| 984 | done |
| 985 | espin $INDENT $VERIFIED |
| 986 | } |
| 987 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 988 | echo "INSTALL TYPE: $TYPE" >> $LOG |
| 989 | |
| 990 | bspin "Verify GOPATH" |
| 991 | export GOPATH=$(pwd) |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 992 | mkdir -p $GOPATH/bin |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 993 | espin $VERIFIED |
| 994 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 995 | STIME=$(date +%s) |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 996 | if [ "$INSTALL_KUBECTL" == "no" ]; then |
| 997 | bspin "Skip kubectl install" |
| 998 | espin $NO_ENTRY |
Test User | c13bdc9 | 2019-07-03 20:57:49 +0000 | [diff] [blame] | 999 | else |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 1000 | bspin "Verify kubectl $HELM" |
| 1001 | if [ -x $GOPATH/bin/kubectl ]; then |
| 1002 | espin $VERIFIED |
| 1003 | else |
| 1004 | espin $NOT_VERIFIED |
| 1005 | bspin - "Download and install Kubernetes/kubectl $DOWNLOAD" |
| 1006 | (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 |
| 1007 | (set -x; chmod 755 $GOPATH/bin/kubectl >>$LOG 2>&1) >>$LOG 2>&1 |
| 1008 | espin - $VERIFIED |
| 1009 | fi |
Test User | c13bdc9 | 2019-07-03 20:57:49 +0000 | [diff] [blame] | 1010 | fi |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1011 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 1012 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1013 | fi |
Test User | c13bdc9 | 2019-07-03 20:57:49 +0000 | [diff] [blame] | 1014 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1015 | STIME=$(date +%s) |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 1016 | if [ "$DEPLOY_K8S" == "no" ]; then |
| 1017 | bspin "Skip Kubernetes/Kind Deployment" |
| 1018 | espin $NO_ENTRY |
| 1019 | else |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1020 | bspin "Verify Kubernetes/Kind $HELM" |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 1021 | IS_INSTALLED=0 |
| 1022 | OP_TYPE="install" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1023 | if [ -x $GOPATH/bin/kind ]; then |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 1024 | OP_TYPE="upgrade" |
| 1025 | if [ $($GOPATH/bin/kind --version | grep -c $KIND_VERSION) -eq 1 ]; then |
| 1026 | IS_INSTALLED=1 |
| 1027 | espin $VERIFIED |
| 1028 | fi |
| 1029 | fi |
| 1030 | if [ $IS_INSTALLED -eq 0 ]; then |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1031 | espin $NOT_VERIFIED |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 1032 | bspin - "Download and $OP_TYPE Kubernetes/kind $DOWNLOAD" |
David Bainbridge | 9e2a666 | 2019-07-11 17:07:57 +0000 | [diff] [blame] | 1033 | (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] | 1034 | (set -x; chmod 755 $GOPATH/bin/kind >>$LOG 2>&1) >>$LOG 2>&1 |
| 1035 | espin - $VERIFIED |
| 1036 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1037 | fi |
| 1038 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1039 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 1040 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1041 | fi |
| 1042 | |
| 1043 | STIME=$(date +%s) |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 1044 | if [ "$INSTALL_HELM" == "no" ]; then |
| 1045 | bspin "Skip Helm Install" |
| 1046 | espin $NO_ENTRY |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1047 | else |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 1048 | bspin "Verify Helm $HELM" |
David Bainbridge | a34993d | 2020-04-01 09:15:42 -0700 | [diff] [blame] | 1049 | HELM_UPGRADE=0 |
| 1050 | HELM_UPGRADE_DESC="install" |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 1051 | if [ -x $GOPATH/bin/helm ]; then |
David Bainbridge | a34993d | 2020-04-01 09:15:42 -0700 | [diff] [blame] | 1052 | HAVE_VER=$($GOPATH/bin/helm version -c --template '{{.Client.SemVer}}') |
| 1053 | HELM_UP_DOWN=$(echo -e "$HAVE_VER\n$HELM_VERSION" | sort -V | head -1) |
| 1054 | if [ $HAVE_VER != $HELM_VERSION ]; then |
| 1055 | if [ $HELM_UP_DOWN == $HELM_VERSION ]; then |
| 1056 | HELM_UPGRADE_DESC="downgrade" |
| 1057 | else |
| 1058 | HELM_UPGRADE_DESC="upgrade" |
| 1059 | fi |
| 1060 | HELM_UPGRADE=1 |
| 1061 | else |
| 1062 | espin $VERIFIED |
| 1063 | fi |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 1064 | else |
David Bainbridge | a34993d | 2020-04-01 09:15:42 -0700 | [diff] [blame] | 1065 | HELM_UPGRADE=1 |
| 1066 | fi |
| 1067 | |
| 1068 | if [ $HELM_UPGRADE -ne 0 ]; then |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 1069 | espin $NOT_VERIFIED |
David Bainbridge | a34993d | 2020-04-01 09:15:42 -0700 | [diff] [blame] | 1070 | bspin - "Download and $HELM_UPGRADE_DESC Helm $DOWNLOAD" |
| 1071 | (set -x; curl -sSL https://git.io/get_helm.sh | DESIRED_VERSION=$HELM_VERSION 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] | 1072 | espin - $VERIFIED |
| 1073 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1074 | fi |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 1075 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1076 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 1077 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1078 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1079 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1080 | STIME=$(date +%s) |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 1081 | bspin "Verify voltctl $HIGH_VOLTAGE" |
David Bainbridge | d281197 | 2019-12-14 01:14:09 +0000 | [diff] [blame] | 1082 | VOK=0 |
| 1083 | VMESSAGE="install" |
David K. Bainbridge | ebf38d9 | 2020-02-10 10:46:31 -0800 | [diff] [blame] | 1084 | export VC_VERSION="$VOLTCTL_VERSION" |
| 1085 | if [ "$VC_VERSION" == "latest" ]; then |
| 1086 | export VC_VERSION=$(curl -sSL https://api.github.com/repos/opencord/voltctl/releases/latest | jq -r .tag_name | sed -e 's/^v//g') |
| 1087 | fi |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 1088 | if [ -x $GOPATH/bin/voltctl ]; then |
David Bainbridge | 1ba64f1 | 2019-12-18 00:40:13 +0000 | [diff] [blame] | 1089 | VHAVE=$($GOPATH/bin/voltctl version --clientonly -o json | jq -r .version) |
David K. Bainbridge | ebf38d9 | 2020-02-10 10:46:31 -0800 | [diff] [blame] | 1090 | if [ $? -eq 0 -a "$VHAVE" == "$VC_VERSION" ]; then |
David Bainbridge | d281197 | 2019-12-14 01:14:09 +0000 | [diff] [blame] | 1091 | VOK=1 |
David Bainbridge | 1ba64f1 | 2019-12-18 00:40:13 +0000 | [diff] [blame] | 1092 | espin $VERIFIED |
| 1093 | else |
David K. Bainbridge | ebf38d9 | 2020-02-10 10:46:31 -0800 | [diff] [blame] | 1094 | VCHECK=$(echo -e "$VHAVE\n$VC_VERSION" | sort -V | head -1) |
| 1095 | if [ "$VCHECK" == "$VHAVE" ]; then |
| 1096 | VMESSAGE="upgrade" |
| 1097 | else |
| 1098 | VMESSAGE="downgrade" |
| 1099 | fi |
David Bainbridge | d281197 | 2019-12-14 01:14:09 +0000 | [diff] [blame] | 1100 | fi |
| 1101 | fi |
| 1102 | |
David Bainbridge | 1ba64f1 | 2019-12-18 00:40:13 +0000 | [diff] [blame] | 1103 | if [ $VOK -eq 0 ]; then |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1104 | espin $NOT_VERIFIED |
David Bainbridge | d281197 | 2019-12-14 01:14:09 +0000 | [diff] [blame] | 1105 | bspin - "Download and $VMESSAGE voltctl $DOWNLOAD" |
David K. Bainbridge | ebf38d9 | 2020-02-10 10:46:31 -0800 | [diff] [blame] | 1106 | (set -x; curl -o $GOPATH/bin/voltctl -sSL https://github.com/opencord/voltctl/releases/download/v$VC_VERSION/voltctl-$VC_VERSION-$HOSTOS-$HOSTARCH >>$LOG 2>&1) >>$LOG 2>&1 |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 1107 | (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] | 1108 | espin - $VERIFIED |
| 1109 | fi |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1110 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 1111 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1112 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1113 | |
| 1114 | bspin "Verify command PATH" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1115 | export PATH=$GOPATH/bin:$PATH |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1116 | espin $VERIFIED |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1117 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1118 | STIME=$(date +%s) |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1119 | if [ "$DEPLOY_K8S" == "yes" ]; then |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1120 | HAVE=$(kind get clusters | grep -c voltha-$NAME) |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1121 | bspin "Verify Kubernetes/Kind Cluster" |
| 1122 | sspin |
| 1123 | if [ $HAVE -eq 0 ]; then |
David Bainbridge | 491b1bd | 2019-07-11 17:53:11 +0000 | [diff] [blame] | 1124 | espin $NOT_VERIFIED |
| 1125 | bspin - "Verify cluster configuration" |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1126 | if [ ! -r ./$NAME-cluster.cfg ]; then |
David Bainbridge | 491b1bd | 2019-07-11 17:53:11 +0000 | [diff] [blame] | 1127 | espin - $NOT_VERIFIED |
David K. Bainbridge | 4342240 | 2020-03-06 07:41:22 -0800 | [diff] [blame] | 1128 | 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] | 1129 | ERR_OUT=$(mktemp) |
| 1130 | (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 |
| 1131 | if [ $? -ne 0 ]; then |
| 1132 | espin - $THEX |
| 1133 | echo -e "${RED}${BOLD}${ERROR}ERROR: $NAME-cluster.cfg${NORMAL}${RED} - $(cat $ERR_OUT)${NORMAL}" |
| 1134 | echo "ERROR: $(cat $ERR_OUT)" >>$LOG |
| 1135 | rm -rf $ERR_OUT ./$NAME-cluster.cfg |
| 1136 | exit 1 |
| 1137 | fi |
| 1138 | rm -rf $ERR_OUT |
| 1139 | else |
David K. Bainbridge | 4342240 | 2020-03-06 07:41:22 -0800 | [diff] [blame] | 1140 | espin - $VERIFIED |
David K. Bainbridge | a00736b | 2020-01-08 14:33:17 -0800 | [diff] [blame] | 1141 | fi |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1142 | kind create cluster --name voltha-$NAME --config $NAME-cluster.cfg |
David Bainbridge | 491b1bd | 2019-07-11 17:53:11 +0000 | [diff] [blame] | 1143 | else |
| 1144 | espin $VERIFIED |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1145 | fi |
| 1146 | |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1147 | export KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$NAME")" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1148 | P="coredns-.* \ |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1149 | etcd-voltha-$NAME-control-plane \ |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1150 | kindnet-.* \ |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1151 | kube-apiserver-voltha-$NAME-control-plane \ |
| 1152 | kube-controller-manager-voltha-$NAME-control-plane \ |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1153 | kube-proxy-.* \ |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1154 | kube-scheduler-voltha-$NAME-control-plane" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1155 | |
| 1156 | EXPECT=$(test "$TYPE" == "minimal" && echo "12" || echo "14") |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 1157 | 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] | 1158 | fi |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1159 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 1160 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1161 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1162 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1163 | STIME=$(date +%s) |
David Bainbridge | 4c6289c | 2019-09-03 21:11:32 +0000 | [diff] [blame] | 1164 | COUNT=$(count_pods "kube-system" ":Running:" "tiller-deploy-.*") |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1165 | bspin "Verify Helm" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1166 | if [ $COUNT -ne 1 ]; then |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1167 | espin $NOT_VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 1168 | echo -e "Configuring Helm $GEAR" |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 1169 | if [ "$INSTALL_HELM" == "no" ]; then |
| 1170 | bspin - "Skip Helm/Tiller Initialization" |
| 1171 | espin - $NO_ENTRY |
| 1172 | else |
| 1173 | bspin - "Initialize Helm" |
| 1174 | (set -x; helm init --upgrade >>$LOG 2>&1) >>$LOG 2>&1 |
| 1175 | espin - $VERIFIED |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 1176 | 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] | 1177 | fi |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 1178 | bspin - "Add Google Incubator repository to Helm" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1179 | (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1 |
| 1180 | espin - $VERIFIED |
Matteo Scandolo | 7ef6ba5 | 2019-10-04 09:20:37 -0700 | [diff] [blame] | 1181 | |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1182 | # HACK (sort-of) - the config for tiller is about to be patched, which will |
| 1183 | # cause the tiller pod to be recreated. This can sometimes cause a timing |
| 1184 | # 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] | 1185 | # 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] | 1186 | # 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] | 1187 | # 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] | 1188 | # things |
| 1189 | (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] | 1190 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 1191 | bspin - "Add Google Stable repository to Helm" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1192 | (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1 |
| 1193 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 1194 | bspin - "Add ONF repository to Helm" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1195 | (set -x; helm repo add onf https://charts.opencord.org >>$LOG 2>&1) >>$LOG 2>&1 |
| 1196 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 1197 | bspin - "Update Helm repository cache" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1198 | (set -x; helm repo update >>$LOG 2>&1) >>$LOG 2>&1 |
| 1199 | espin - $VERIFIED |
Matteo Scandolo | 7ef6ba5 | 2019-10-04 09:20:37 -0700 | [diff] [blame] | 1200 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1201 | # Create and k8s service account so that Helm can create pods |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 1202 | bspin - "Create Tiller ServiceAccount" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1203 | (set -x; kubectl create serviceaccount --namespace kube-system tiller >>$LOG 2>&1) >>$LOG 2>&1 |
| 1204 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 1205 | bspin - "Create Tiller ClusterRoleBinding" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1206 | (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>$LOG 2>&1) >>$LOG 2>&1 |
| 1207 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 1208 | bspin - "Update Tiller Manifest" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1209 | (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] | 1210 | |
| 1211 | # HACK (sort-of) - part to, spin it back up |
| 1212 | (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] | 1213 | espin - $VERIFIED |
| 1214 | else |
David Bainbridge | a34993d | 2020-04-01 09:15:42 -0700 | [diff] [blame] | 1215 | if [ $(helm version -s --template '{{.Server.SemVer}}') != $HELM_VERSION ]; then |
| 1216 | espin $NOT_VERIFIED |
| 1217 | bspin - "Sync Tiller server version with helm client" |
| 1218 | (set -x; helm init --upgrade --force-upgrade --wait >>$LOG 2>&1) >>$LOG 2>&1 |
| 1219 | espin - $VERIFIED |
| 1220 | else |
| 1221 | espin $VERIFIED |
| 1222 | fi |
| 1223 | |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 1224 | if [ "$UPDATE_HELM_REPOS" == "yes" ]; then |
| 1225 | bspin - "Update Helm repository cache" |
| 1226 | (set -x; helm repo update >>$LOG 2>&1) >>$LOG 2>&1 |
| 1227 | espin - $VERIFIED |
| 1228 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1229 | fi |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 1230 | 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] | 1231 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 1232 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1233 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1234 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1235 | STIME=$(date +%s) |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1236 | bspin "Verify Helm values file: $NAME-values.yaml" |
| 1237 | if [ ! -r "./$NAME-values.yaml" ]; then |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1238 | espin $NOT_VERIFIED |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1239 | 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] | 1240 | ERR_OUT=$(mktemp) |
| 1241 | (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 |
| 1242 | if [ $? -ne 0 ]; then |
| 1243 | espin - $THEX |
| 1244 | echo -e "${RED}${BOLD}${ERROR}ERROR: $NAME-values.yaml${NORMAL}${RED} - $(cat $ERR_OUT)${NORMAL}" |
| 1245 | echo "ERROR: $(cat $ERR_OUT)" >>$LOG |
| 1246 | rm -rf $ERR_OUT ./$NAME-values.yaml |
| 1247 | exit 1 |
| 1248 | fi |
| 1249 | rm -rf $ERR_OUT |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1250 | espin - $VERIFIED |
| 1251 | else |
| 1252 | espin $VERIFIED |
| 1253 | fi |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1254 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 1255 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1256 | fi |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1257 | |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 1258 | STIME=$(date +%s) |
| 1259 | bspin "Verify or download chart specific values files $DOWNLOAD" |
| 1260 | VALUES_FILES="monkey-values.yaml" |
David K. Bainbridge | a00736b | 2020-01-08 14:33:17 -0800 | [diff] [blame] | 1261 | ERR_OUT=$(mktemp) |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 1262 | for i in $VALUES_FILES; do |
| 1263 | if [ ! -r ./$i ]; then |
David K. Bainbridge | a00736b | 2020-01-08 14:33:17 -0800 | [diff] [blame] | 1264 | (set -x; curl --fail -o ./$i -sSL https://raw.githubusercontent.com/ciena/kind-voltha/$VK_RELEASE/$i >>$LOG 2>$ERR_OUT) >>$LOG 2>&1 |
| 1265 | if [ $? -ne 0 ]; then |
| 1266 | espin $THEX |
| 1267 | echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat $ERR_OUT)${NORMAL}" |
| 1268 | echo "ERROR: $i - $(cat $ERR_OUT)" >>$LOG |
| 1269 | rm -rf $ERR_OUT ./$i |
| 1270 | exit 1 |
| 1271 | fi |
| 1272 | rm -rf $ERR_OUT |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 1273 | fi |
| 1274 | done |
David Bainbridge | 1cecba5 | 2020-03-30 09:43:10 -0700 | [diff] [blame] | 1275 | rm -rf $ERR_OUT |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 1276 | espin $VERIFIED |
| 1277 | if [ "$WITH_TIMINGS" == "yes" ]; then |
| 1278 | printtime $(expr $(date +%s) - $STIME) |
| 1279 | fi |
| 1280 | |
| 1281 | if [ "$WITH_CHAOS" == "yes" ]; then |
| 1282 | bspin "Verify or clone kube-monkey helm chart $DOWNLOAD" |
| 1283 | if [ -r ./kube-monkey ]; then |
| 1284 | espin $VERIFIED |
| 1285 | else |
| 1286 | espin $NOT_VERIFIED |
| 1287 | bspin - "GIT clone kube-monkey" |
| 1288 | (set -x; git clone https://github.com/asobti/kube-monkey kube-monkey >>$LOG 2>&1) >>$LOG 2>&1 |
| 1289 | espin - $VERIFIED |
| 1290 | fi |
| 1291 | fi |
| 1292 | |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1293 | if [ "$JUST_K8S" == "yes" ]; then |
| 1294 | echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye." |
| 1295 | echo "" |
| 1296 | echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG |
| 1297 | echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG |
| 1298 | echo "tools required by VOLTHA in your command path. " | tee -a $LOG |
| 1299 | echo "" | tee -a $LOG |
| 1300 | echo -en $BOLD |
| 1301 | if [ $DEPLOY_K8S == "yes" ]; then |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1302 | 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] | 1303 | fi |
| 1304 | echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG |
| 1305 | echo -en $NORMAL |
| 1306 | echo "" | tee -a $LOG |
| 1307 | echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG |
| 1308 | exit 0 |
| 1309 | fi |
| 1310 | |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1311 | if [ $WITH_ETCD != "yes" -a $WITH_ETCD != "external" ]; then |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 1312 | bspin "Skip ETCD Operator Deployment" |
| 1313 | espin $NO_ENTRY |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1314 | else |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 1315 | STIME=$(date +%s) |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1316 | NS=$VOLTHA_NS |
| 1317 | if [ $WITH_ETCD == "external" ]; then |
| 1318 | NS=$INFRA_NS |
| 1319 | fi |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 1320 | bspin "Verify ETCD Operator $OLD_KEY" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1321 | if [ $(helm list --deployed --short --namespace $NS "^etcd-operator\$" | wc -l) -ne 1 ]; then |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 1322 | espin $NOT_VERIFIED |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1323 | helm_install - $NS etcd-operator stable/etcd-operator latest "Install ETCD Operator" |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 1324 | else |
| 1325 | espin $VERIFIED |
| 1326 | fi |
| 1327 | EXPECT=$(test "$TYPE" == "minimal" && echo "1" || echo "3") |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1328 | wait_for_pods - "$NS" $EXPECT "includes" -1 "Waiting for ETCD Operator to start" "etcd-operator-.*" |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 1329 | if [ "$WITH_TIMINGS" == "yes" ]; then |
| 1330 | printtime $(expr $(date +%s) - $STIME) |
| 1331 | fi |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1332 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1333 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1334 | STIME=$(date +%s) |
David Bainbridge | b270c20 | 2019-07-26 01:44:42 +0000 | [diff] [blame] | 1335 | if [ $WITH_ONOS == "yes" ]; then |
| 1336 | bspin "Verify ONOS installed $BIRD" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1337 | if [ $(helm list --deployed --short --namespace $INFRA_NS "^onos\$" | wc -l) -ne 1 ]; then |
David Bainbridge | b270c20 | 2019-07-26 01:44:42 +0000 | [diff] [blame] | 1338 | espin $NOT_VERIFIED |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1339 | EXTRA_HELM_FLAGS="$SET_TAG $EXTRA_HELM_FLAGS" helm_install - $INFRA_NS onos $ONOS_CHART $ONOS_CHART_VERSION "Install ONOS" |
David Bainbridge | b270c20 | 2019-07-26 01:44:42 +0000 | [diff] [blame] | 1340 | else |
| 1341 | espin $VERIFIED |
| 1342 | fi |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1343 | wait_for_pods - "$INFRA_NS" 1 "includes" -1 "Waiting for ONOS to start" "onos-.*" |
Matteo Scandolo | 7ef6ba5 | 2019-10-04 09:20:37 -0700 | [diff] [blame] | 1344 | |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 1345 | if [ $WITH_PORT_FORWARDS == "yes" ]; then |
| 1346 | bspin - "Forward ONOS API port $FORWARD" |
| 1347 | kill_port_forward onos-ui |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1348 | port_forward $INFRA_NS onos-ui $ONOS_API_PORT 8181 |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 1349 | espin - $VERIFIED |
| 1350 | bspin - "Forward ONOS SSH port $FORWARD" |
| 1351 | kill_port_forward onos-ssh |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1352 | port_forward $INFRA_NS onos-ssh $ONOS_SSH_PORT 8101 |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 1353 | espin - $VERIFIED |
| 1354 | _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT" |
| 1355 | else |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1356 | _ONOS_API_EP=$(get_service_ep $INFRA_NS onos-ui) |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 1357 | fi |
David Bainbridge | d31d612 | 2019-08-13 19:37:59 +0000 | [diff] [blame] | 1358 | bspin - "Verify or download ONOS configuration support files $DOWNLOAD" |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 1359 | ONOS_FILES="olt-onos-enableExtraneousRules.json onos-aaa.json \ |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 1360 | onos-dhcpl2relay.json onos-sadis-sample.json" |
David Bainbridge | d31d612 | 2019-08-13 19:37:59 +0000 | [diff] [blame] | 1361 | (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] | 1362 | ERR_OUT=$(mktemp) |
David Bainbridge | 2b19e83 | 2019-08-16 02:40:53 +0000 | [diff] [blame] | 1363 | for i in $ONOS_FILES; do |
David Bainbridge | d31d612 | 2019-08-13 19:37:59 +0000 | [diff] [blame] | 1364 | if [ ! -r ./onos-files/$i ]; then |
David K. Bainbridge | a00736b | 2020-01-08 14:33:17 -0800 | [diff] [blame] | 1365 | (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 |
| 1366 | if [ $? -ne 0 ]; then |
| 1367 | espin - $THEX |
| 1368 | echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat $ERR_OUT)${NORMAL}" |
| 1369 | echo "ERROR: $(cat $ERR_OUT)" >>$LOG |
| 1370 | rm -rf $ERR_OUT ./onos-files/$i |
| 1371 | exit 1 |
| 1372 | fi |
| 1373 | rm -rf $ERR_OUT |
David Bainbridge | d31d612 | 2019-08-13 19:37:59 +0000 | [diff] [blame] | 1374 | fi |
| 1375 | done |
David Bainbridge | 1cecba5 | 2020-03-30 09:43:10 -0700 | [diff] [blame] | 1376 | rm -rf $ERR_OUT |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1377 | espin - $VERIFIED |
David Bainbridge | 27790d6 | 2019-08-13 22:43:19 +0000 | [diff] [blame] | 1378 | |
| 1379 | if [ $INSTALL_ONOS_APPS == "yes" ]; then |
| 1380 | bspin - "Installing custom ONOS applications" |
| 1381 | if [ -x onos-files/onos-apps -a $(ls -1 onos-files/onos-apps/*.oar 2>/dev/null | wc -l) -gt 0 ]; then |
| 1382 | for OAR in $(ls -1 onos-files/onos-apps/*.oar); do |
| 1383 | sspin - "Installing custom ONOS applications - $OAR$CEOL" |
David Bainbridge | 2b19e83 | 2019-08-16 02:40:53 +0000 | [diff] [blame] | 1384 | override_onos_app $OAR |
David Bainbridge | 27790d6 | 2019-08-13 22:43:19 +0000 | [diff] [blame] | 1385 | done |
| 1386 | espin - "$VERIFIED Installing custom ONOS applications$CEOL" |
| 1387 | else |
| 1388 | espin - "$NOT_VERIFIED Installing custom ONOS applications - None Found" |
| 1389 | fi |
| 1390 | fi |
Matteo Scandolo | 7ef6ba5 | 2019-10-04 09:20:37 -0700 | [diff] [blame] | 1391 | |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 1392 | if [ $WITH_KAFKA != "no" ]; then |
David Bainbridge | 837e8bd | 2020-04-06 13:17:14 -0700 | [diff] [blame] | 1393 | check_onos_app_active org.opencord.kafka |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1394 | _HOST=voltha-kafka.$INFRA_NS.svc.cluster.local |
David Bainbridge | 837e8bd | 2020-04-06 13:17:14 -0700 | [diff] [blame] | 1395 | _PORT=9092 |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1396 | if [ $WITH_KAFKA == "yes" ]; then |
| 1397 | _HOST=voltha-kafka.$VOLTHA_NS.svc.cluster.local |
| 1398 | _PORT=9092 |
| 1399 | elif [ $WITH_KAFKA == "external" ]; then |
| 1400 | _HOST=kafka.$INFRA_NS.svc.cluster.local |
| 1401 | _PORT=9092 |
| 1402 | else |
David Bainbridge | 837e8bd | 2020-04-06 13:17:14 -0700 | [diff] [blame] | 1403 | _HOST=$(echo $WITH_KAFKA | cut -d: -f1) |
| 1404 | _PORT=$(echo $WITH_KAFKA | cut -s -d: -f2) |
| 1405 | _PORT=${_PORT:-9092} |
| 1406 | fi |
| 1407 | push_onos_config "json" "Push ONOS Kafka Configuration" "network/configuration/apps/org.opencord.kafka" \ |
| 1408 | "$(echo $(cat <<EOJ |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 1409 | { |
| 1410 | "kafka": { |
| 1411 | "bootstrapServers": "$_HOST:$_PORT" |
| 1412 | } |
| 1413 | } |
| 1414 | EOJ |
| 1415 | ) | tr -d '[:space:]')" |
David Bainbridge | 837e8bd | 2020-04-06 13:17:14 -0700 | [diff] [blame] | 1416 | fi |
Matteo Scandolo | 9a77a73 | 2020-01-09 14:24:12 -0800 | [diff] [blame] | 1417 | check_onos_app_active org.opencord.dhcpl2relay |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 1418 | push_onos_config "file" "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] | 1419 | check_onos_app_active org.opencord.olt |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 1420 | # FIXME use WITH_DHCP and WITH_EAPOL flags to configre OLT App |
Hardik Windlass | a7501fb | 2020-02-17 14:28:20 +0000 | [diff] [blame] | 1421 | # Default value for "enableEapol" is true in OLT App |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 1422 | if [ $WITH_EAPOL == "yes" ]; then |
| 1423 | push_onos_config "json" "Enable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":true}' |
Hardik Windlass | a7501fb | 2020-02-17 14:28:20 +0000 | [diff] [blame] | 1424 | elif [ $WITH_EAPOL == "no" ]; then |
| 1425 | push_onos_config "json" "Disable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":false}' |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 1426 | fi |
Hardik Windlass | a7501fb | 2020-02-17 14:28:20 +0000 | [diff] [blame] | 1427 | # Default value for "enableDhcpOnProvisioning" is false and for "enableDhcpV4" is true in OLT App |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 1428 | if [ $WITH_DHCP == "yes" ]; then |
| 1429 | push_onos_config "json" "Enable VOLTHA ONOS DHCP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableDhcpOnProvisioning":true,"enableDhcpV4":true}' |
Hardik Windlass | a7501fb | 2020-02-17 14:28:20 +0000 | [diff] [blame] | 1430 | elif [ $WITH_DHCP == "no" ]; then |
| 1431 | push_onos_config "json" "Disable VOLTHA ONOS DHCP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableDhcpOnProvisioning":false,"enableDhcpV4":false}' |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 1432 | fi |
Hardik Windlass | a7501fb | 2020-02-17 14:28:20 +0000 | [diff] [blame] | 1433 | # Default value for "enableIgmpOnProvisioning" is false in OLT App |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 1434 | if [ $WITH_IGMP == "yes" ]; then |
| 1435 | push_onos_config "json" "Enable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":true}' |
Hardik Windlass | a7501fb | 2020-02-17 14:28:20 +0000 | [diff] [blame] | 1436 | elif [ $WITH_IGMP == "no" ]; then |
| 1437 | push_onos_config "json" "Disable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":false}' |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 1438 | fi |
David K. Bainbridge | 484d80c | 2020-03-05 21:44:34 -0800 | [diff] [blame] | 1439 | if [ $ENABLE_ONOS_EXTRANEOUS_RULES == "yes" ]; then |
| 1440 | push_onos_config "file" "Enabling extraneous rules for ONOS" "configuration/org.onosproject.net.flow.impl.FlowRuleManager" "onos-files/olt-onos-enableExtraneousRules.json" |
| 1441 | fi |
David K. Bainbridge | b859e91 | 2020-03-13 14:07:52 -0700 | [diff] [blame] | 1442 | if [ $(echo ":yes:file:" | grep -c ":$CONFIG_SADIS:") -eq 1 ]; then |
Matteo Scandolo | 9a77a73 | 2020-01-09 14:24:12 -0800 | [diff] [blame] | 1443 | check_onos_app_active org.opencord.sadis |
Hardik Windlass | b314760 | 2020-03-09 16:59:15 +0530 | [diff] [blame] | 1444 | push_onos_config "file" "[optional] Push ONOS SADIS Configuration: $SADIS_CFG" "network/configuration/apps/org.opencord.sadis" "$SADIS_CFG" |
David K. Bainbridge | b859e91 | 2020-03-13 14:07:52 -0700 | [diff] [blame] | 1445 | elif [ "$CONFIG_SADIS" == "bbsim" ]; then |
| 1446 | push_onos_config "json" \ |
| 1447 | "[optional] Push ONOS configuration for BBSIM SADIS servers" \ |
| 1448 | "network/configuration/apps/org.opencord.sadis" \ |
| 1449 | "$(echo $(cat <<EOJ |
| 1450 | { |
| 1451 | "sadis": { |
| 1452 | "integration": { |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1453 | "url": "http://bbsim.$BBSIM_NS.svc.cluster.local:50074/v2/subscribers/%s", |
David K. Bainbridge | b859e91 | 2020-03-13 14:07:52 -0700 | [diff] [blame] | 1454 | "cache": { |
| 1455 | "enabled": true, |
| 1456 | "maxsize": 50, |
| 1457 | "ttl": "PT1m" |
| 1458 | } |
| 1459 | } |
| 1460 | }, |
| 1461 | "bandwidthprofile": { |
| 1462 | "integration": { |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1463 | "url": "http://bbsim.$BBSIM_NS.svc.cluster.local:50074/v2/bandwidthprofiles/%s", |
David K. Bainbridge | b859e91 | 2020-03-13 14:07:52 -0700 | [diff] [blame] | 1464 | "cache": { |
| 1465 | "enabled": true, |
| 1466 | "maxsize": 50, |
| 1467 | "ttl": "PT1m" |
| 1468 | } |
| 1469 | } |
| 1470 | } |
| 1471 | } |
| 1472 | EOJ |
| 1473 | ) | tr -d '[:space:]')" |
| 1474 | elif [ "$CONFIG_SADIS" == "url" ]; then |
| 1475 | push_onos_config "json" \ |
| 1476 | "[optional] Push ONOS configuration for custom SADIS and Bandwidth Profile servers" \ |
| 1477 | "network/configuration/apps/org.opencord.sadis" \ |
| 1478 | "$(echo $(cat <<EOJ |
| 1479 | { |
| 1480 | "sadis": { |
| 1481 | "integration": { |
| 1482 | "url": "$SADIS_SUBSCRIBERS", |
| 1483 | "cache": { |
| 1484 | "enabled": true, |
| 1485 | "maxsize": 50, |
| 1486 | "ttl": "PT1m" |
| 1487 | } |
| 1488 | } |
| 1489 | }, |
| 1490 | "bandwidthprofile": { |
| 1491 | "integration": { |
| 1492 | "url": "$SADIS_BANDWIDTH_PROFILES", |
| 1493 | "cache": { |
| 1494 | "enabled": true, |
| 1495 | "maxsize": 50, |
| 1496 | "ttl": "PT1m" |
| 1497 | } |
| 1498 | } |
| 1499 | } |
| 1500 | } |
| 1501 | EOJ |
| 1502 | ) | tr -d '[:space:]')" |
David Bainbridge | 2b19e83 | 2019-08-16 02:40:53 +0000 | [diff] [blame] | 1503 | fi |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1504 | fi |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1505 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 1506 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1507 | fi |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1508 | |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1509 | if [ $WITH_ETCD == "external" ]; then |
| 1510 | STIME=$(date +%s) |
| 1511 | bspin "Verify external ETCD cluster $OLD_KEY" |
| 1512 | EXPECT=$(test "$TYPE" == "minimal" && echo "1" || echo "3") |
| 1513 | if [ $(helm list --deployed --short --namespace $INFRA_NS "^etcd-cluster\$" | wc -l) -ne 1 ]; then |
| 1514 | espin $NOT_VERIFIED |
| 1515 | INTERNAL_EXTRA_HELM_INSTALL_ARGS+="--set clusterName=etcd-cluster --set autoCompactionRetention=1 --set clusterSize=$EXPECT" |
| 1516 | helm_install - $INFRA_NS etcd-cluster onf/voltha-etcd-cluster latest "Install eternal ETCD cluster" |
| 1517 | else |
| 1518 | espin $VERIFIED |
| 1519 | fi |
| 1520 | wait_for_pods - "$INFRA_NS" $EXPECT "includes" -1 "Waiting for ETCD cluster to start" "etcd-cluster-.*" |
| 1521 | if [ "$WITH_TIMINGS" == "yes" ]; then |
| 1522 | printtime $(expr $(date +%s) - $STIME) |
| 1523 | fi |
| 1524 | fi |
| 1525 | |
| 1526 | if [ $WITH_KAFKA == "external" ]; then |
| 1527 | _TMP=$(mktemp -u) |
| 1528 | _COUNT=$(test $TYPE == "minimal" && echo "1" || echo "3") |
| 1529 | cat << EOC > $_TMP |
| 1530 | configurationOverrides: |
| 1531 | "default.replication.factor": $_COUNT |
| 1532 | "offsets.topic.replication.factor": $_COUNT |
| 1533 | "log.retention.hours": 4 |
| 1534 | "log.message.timestamp.type": "LogAppendTime" |
| 1535 | persistence: |
| 1536 | enabled: false |
| 1537 | zookeeper: |
| 1538 | replicaCount: 1 |
| 1539 | persistence: |
| 1540 | enabled: false |
| 1541 | replicas: $_COUNT |
| 1542 | EOC |
| 1543 | STIME=$(date +%s) |
| 1544 | bspin "Verify external Kafka cluster $OLD_KEY" |
| 1545 | EXPECT=$(test "$TYPE" == "minimal" && echo "2" || echo "4") |
| 1546 | if [ $(helm list --deployed --short --namespace $INFRA_NS "^kafka\$" | wc -l) -ne 1 ]; then |
| 1547 | espin $NOT_VERIFIED |
| 1548 | INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" -f $_TMP" |
| 1549 | helm_install - $INFRA_NS kafka incubator/kafka latest "Install eternal Kafka cluster" |
| 1550 | else |
| 1551 | espin $VERIFIED |
| 1552 | fi |
| 1553 | # DKB |
| 1554 | wait_for_pods - "$INFRA_NS" $EXPECT "includes" -1 "Waiting for Kafka cluster to start" "kafka-.*" |
| 1555 | if [ "$WITH_TIMINGS" == "yes" ]; then |
| 1556 | printtime $(expr $(date +%s) - $STIME) |
| 1557 | fi |
| 1558 | rm -rf $_TMP |
| 1559 | fi |
| 1560 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1561 | STIME=$(date +%s) |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 1562 | EXPECT=1 |
| 1563 | if [ "$ONLY_ONE" == "yes" ]; then |
| 1564 | EXPECT=$((EXPECT+1)) |
| 1565 | INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set therecanbeonlyone=true" |
| 1566 | else |
| 1567 | EXPECT=$((EXPECT+2)) |
| 1568 | fi |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1569 | case $WITH_ETCD in |
| 1570 | no) |
| 1571 | INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set private_etcd_cluster=false" |
| 1572 | ;; |
| 1573 | yes) |
| 1574 | _HOST="voltha-etcd-cluster-client.$VOLTHA_NS.svc.cluster.local" |
| 1575 | _PORT=2379 |
| 1576 | INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT" |
| 1577 | EXPECT=$((EXPECT+$(test "$TYPE" == "minimal" && echo "1" || echo "3"))) |
| 1578 | ;; |
| 1579 | external) |
| 1580 | _HOST="etcd-cluster-client.$INFRA_NS.svc.cluster.local" |
| 1581 | _PORT=2379 |
| 1582 | INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set private_etcd_cluster=false --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT" |
| 1583 | ;; |
| 1584 | *) |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 1585 | _HOST=$(echo $WITH_ETCD | cut -d: -f1) |
| 1586 | _PORT=$(echo $WITH_ETCD | cut -s -d: -f2) |
| 1587 | _PORT=${_PORT:-2379} |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1588 | INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set private_etcd_cluster=false --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT" |
| 1589 | ;; |
| 1590 | esac |
| 1591 | case $WITH_KAFKA in |
| 1592 | no) |
| 1593 | INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set private_kafka_cluster=false" |
| 1594 | ;; |
| 1595 | yes) |
| 1596 | _HOST=voltha-kafka.$VOLTHA_NS.svc.cluster.local |
| 1597 | _PORT=9092 |
| 1598 | INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafka_broker=$_HOST:$_PORT --set services.kafka.adapter.service=$_HOST --set services.kafka.adapter.port=$_PORT --set services.kafka.cluster.service=$_HOST --set services.kafka.cluster.port=$_PORT" |
| 1599 | EXPECT=$((EXPECT+$(test "$TYPE" == "minimal" && echo "2" || echo "4"))) |
| 1600 | ;; |
| 1601 | external) |
| 1602 | _HOST=kafka.$INFRA_NS.svc.cluster.local |
| 1603 | _PORT=9092 |
| 1604 | INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set private_kafka_cluster=false --set kafka_broker=$_HOST:$_PORT --set services.kafka.adapter.service=$_HOST --set services.kafka.adapter.port=$_PORT --set services.kafka.cluster.service=$_HOST --set services.kafka.cluster.port=$_PORT" |
| 1605 | ;; |
| 1606 | *) |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 1607 | _HOST=$(echo $WITH_KAFKA | cut -d: -f1) |
| 1608 | _PORT=$(echo $WITH_KAFKA | cut -s -d: -f2) |
| 1609 | _PORT=${_PORT:-9092} |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1610 | INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set private_kafka_cluster=false --set kafka_broker=$_HOST:$_PORT --set services.kafka.adapter.service=$_HOST --set services.kafka.adapter.port=$_PORT --set services.kafka.cluster.service=$_HOST --set services.kafka.cluster.port=$_PORT" |
| 1611 | ;; |
| 1612 | esac |
| 1613 | |
| 1614 | if [ $WITH_ONOS == "yes" ]; then |
| 1615 | _HOST=onos-openflow.$INFRA_NS.svc.cluster.local |
| 1616 | _PORT=6653 |
| 1617 | INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.controller.service=$_HOST --set services.controller.port=$_PORT" |
| 1618 | elif [ $WITH_ONOS != "no" ]; then |
| 1619 | _HOST=$(echo $WITH_ONOS | cut -d: -f1) |
| 1620 | _PORT=$(echo $WITH_ONOS | cut -s -d: -f2) |
| 1621 | _PORT=${_PORT:-6653} |
| 1622 | INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.controller.service=$_HOST --set services.controller.port=$_PORT" |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 1623 | fi |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 1624 | bspin "Verify VOLTHA installed $HIGH_VOLTAGE" |
David Bainbridge | 6ca4010 | 2020-04-08 11:30:40 -0700 | [diff] [blame^] | 1625 | if [ $(helm list --deployed --short --namespace $VOLTHA_NS "^voltha\$" | wc -l) -ne 1 ]; then |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1626 | espin $NOT_VERIFIED |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1627 | helm_install - $VOLTHA_NS voltha $VOLTHA_CHART $VOLTHA_CHART_VERSION "Install VOLTHA Core" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1628 | else |
| 1629 | espin $VERIFIED |
| 1630 | fi |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 1631 | INTERNAL_EXTRA_HELM_INSTALL_ARGS= |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1632 | |
David Bainbridge | 90fd8e3 | 2019-08-21 23:32:47 +0000 | [diff] [blame] | 1633 | VOLTHA="voltha-ofagent-.* \ |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1634 | rw-core.* \ |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1635 | voltha-etcd-cluster-.* \ |
| 1636 | voltha-kafka-.* \ |
| 1637 | voltha-zookeeper-.*" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1638 | wait_for_pods - "$VOLTHA_NS" $EXPECT "includes" -1 "Waiting for VOLTHA Core to start" $VOLTHA |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1639 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 1640 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1641 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1642 | |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 1643 | if [ "$WITH_ADAPTERS" == "yes" ]; then |
| 1644 | STIME=$(date +%s) |
| 1645 | EXPECT=0 |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 1646 | if [ $WITH_ETCD != "yes" ]; then |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1647 | if [ $WITH_ETCD == "external" ]; then |
| 1648 | _HOST=etcd-cluster-client.$INFRA_NS.svc.cluster.local |
| 1649 | _PORT=2379 |
| 1650 | INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT" |
| 1651 | elif [ $WITH_ETCD != "no" ]; then |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 1652 | _HOST=$(echo $WITH_ETCD | cut -d: -f1) |
| 1653 | _PORT=$(echo $WITH_ETCD | cut -s -d: -f2) |
| 1654 | _PORT=${_PORT:-2379} |
| 1655 | INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT" |
| 1656 | fi |
| 1657 | fi |
| 1658 | if [ $WITH_KAFKA != "yes" ]; then |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1659 | if [ $WITH_KAFKA == "external" ]; then |
| 1660 | _HOST=kafka.$INFRA_NS.svc.cluster.local |
| 1661 | _PORT=9092 |
| 1662 | INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafka_broker=$_HOST:$_PORT --set services.kafka.adapter.service=$_HOST --set services.kafka.adapter.port=$_PORT --set services.kafka.cluster.service=$_HOST --set services.kafka.cluster.port=$_PORT" |
| 1663 | elif [ $WITH_KAFKA != "no" ]; then |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 1664 | _HOST=$(echo $WITH_KAFKA | cut -d: -f1) |
| 1665 | _PORT=$(echo $WITH_KAFKA | cut -s -d: -f2) |
| 1666 | _PORT=${_PORT:-9092} |
| 1667 | INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafka_broker=$_HOST:$_PORT --set services.kafka.adapter.service=$_HOST --set services.kafka.adapter.port=$_PORT --set services.kafka.cluster.service=$_HOST --set services.kafka.cluster.port=$_PORT" |
| 1668 | fi |
| 1669 | fi |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 1670 | echo -e "Verify Adapters $PLUG" |
| 1671 | if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then |
| 1672 | bspin - "Verify Simulated Adapters installed" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1673 | if [ $(helm list --deployed --short --namespace $ADAPTER_NS "^sim\$" | wc -l) -ne 1 ]; then |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 1674 | espin - $NOT_VERIFIED |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1675 | helm_install - $ADAPTER_NS sim $VOLTHA_ADAPTER_SIM_CHART $VOLTHA_ADAPTER_SIM_CHART_VERSION "Install Simulated Adapters" |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 1676 | else |
| 1677 | espin - $VERIFIED |
| 1678 | fi |
| 1679 | EXPECT=$(expr $EXPECT + 2) |
| 1680 | fi |
Matteo Scandolo | 7ef6ba5 | 2019-10-04 09:20:37 -0700 | [diff] [blame] | 1681 | |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 1682 | if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then |
| 1683 | bspin - "Verify OpenOLT Adapter installed" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1684 | if [ $(helm list --deployed --short --namespace $ADAPTER_NS "^open-olt\$" | wc -l) -ne 1 ]; then |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 1685 | espin - $NOT_VERIFIED |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1686 | helm_install - $ADAPTER_NS open-olt $VOLTHA_ADAPTER_OPEN_OLT_CHART $VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION "Install OpenOLT Adapter" |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 1687 | else |
| 1688 | espin - $VERIFIED |
| 1689 | fi |
| 1690 | bspin - "Verify OpenONU Adapter installed" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1691 | if [ $(helm list --deployed --short --namespace $ADAPTER_NS "^open-onu\$" | wc -l) -ne 1 ]; then |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 1692 | espin - $NOT_VERIFIED |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1693 | helm_install - $ADAPTER_NS open-onu $VOLTHA_ADAPTER_OPEN_ONU_CHART $VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION "Install OpenONU Adapter" |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 1694 | else |
| 1695 | espin - $VERIFIED |
| 1696 | fi |
| 1697 | EXPECT=$(expr $EXPECT + 2) |
| 1698 | fi |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 1699 | INTERNAL_EXTRA_HELM_INSTALL_ARGS= |
Matteo Scandolo | 7ef6ba5 | 2019-10-04 09:20:37 -0700 | [diff] [blame] | 1700 | |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 1701 | ADAPTERS="adapter-.*" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1702 | wait_for_pods - "$ADAPTER_NS " $EXPECT "includes" -1 "Waiting for adapters to start" $ADAPTERS |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 1703 | if [ "$WITH_TIMINGS" == "yes" ]; then |
| 1704 | printtime $(expr $(date +%s) - $STIME) |
| 1705 | fi |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1706 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1707 | |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 1708 | if [ $WITH_BBSIM == "yes" ]; then |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1709 | STIME=$(date +%s) |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 1710 | echo -e "Verify BBSIM $PLUG" |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 1711 | bspin - "Verify BBSIM Installed" |
David K. Bainbridge | 4342240 | 2020-03-06 07:41:22 -0800 | [diff] [blame] | 1712 | for instance in $(seq 0 $(($NUM_OF_BBSIM-1))); do |
| 1713 | if [ $instance -eq 0 ]; then |
| 1714 | instance_num="" |
| 1715 | else |
| 1716 | instance_num=$instance |
| 1717 | fi |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1718 | if [ $(helm list --deployed --short --namespace $BBSIM_NS "^bbsim${instance_num}\$" | wc -l) -ne 1 ]; then |
David K. Bainbridge | 4342240 | 2020-03-06 07:41:22 -0800 | [diff] [blame] | 1719 | espin - $NOT_VERIFIED |
Matteo Scandolo | 5a14957 | 2020-04-01 10:14:57 -0700 | [diff] [blame] | 1720 | S_TAG=$((900+$instance)) |
| 1721 | INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set olt_id=$instance,s_tag=$S_TAG" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1722 | helm_install - $BBSIM_NS bbsim${instance_num} $VOLTHA_BBSIM_CHART $VOLTHA_BBSIM_CHART_VERSION "Install BBSIM${instance_num}" |
David Bainbridge | 2eaf2cf | 2020-03-18 12:54:08 -0700 | [diff] [blame] | 1723 | INTERNAL_EXTRA_HELM_INSTALL_ARGS= |
David K. Bainbridge | 4342240 | 2020-03-06 07:41:22 -0800 | [diff] [blame] | 1724 | else |
| 1725 | espin - $VERIFIED |
| 1726 | fi |
| 1727 | done |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1728 | wait_for_pods - "$BBSIM_NS" $NUM_OF_BBSIM "includes" -1 "Waiting for BBSIM to start" "bbsim*" |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1729 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 1730 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1731 | fi |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 1732 | fi |
| 1733 | |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 1734 | if [ $WITH_RADIUS == "yes" ]; then |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1735 | STIME=$(date +%s) |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 1736 | echo -e "Verify RADIUS $LOCK" |
| 1737 | bspin - "Verify RADIUS Installed" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1738 | if [ $(helm list --deployed --short --namespace $INFRA_NS "^radius\$" | wc -l) -ne 1 ]; then |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 1739 | espin - $NOT_VERIFIED |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1740 | helm_install - $INFRA_NS radius onf/freeradius latest "Install RADIUS" |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 1741 | else |
| 1742 | espin - $VERIFIED |
| 1743 | fi |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1744 | wait_for_pods - "$INFRA_NS" 1 "includes" -1 "Waiting for RADIUS to start" "radius-.*" |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1745 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 1746 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1747 | fi |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 1748 | fi |
| 1749 | |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 1750 | if [ $WITH_PORT_FORWARDS == "yes" ]; then |
| 1751 | STIME=$(date +%s) |
| 1752 | bspin - "Forward VOLTHA API port $FORWARD" |
| 1753 | kill_port_forward voltha-api |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1754 | port_forward $VOLTHA_NS voltha-api $VOLTHA_API_PORT 55555 |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 1755 | espin - $VERIFIED |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1756 | if [ $WITH_ETCD == "yes" -o $WITH_ETCD == "external" ]; then |
| 1757 | _NS=$(test $WITH_ETCD == "yes" && echo $VOLTHA_NS || echo $INFRA_NS) |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 1758 | bspin - "Forward VOLTHA ETCD port $FORWARD" |
| 1759 | kill_port_forward voltha-etcd-cluster-client |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1760 | port_forward $_NS voltha-etcd-cluster-client $VOLTHA_ETCD_PORT 2379 |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 1761 | espin - $VERIFIED |
| 1762 | fi |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1763 | if [ $WITH_KAFKA == "yes" -o $WITH_KAFKA == "external" ]; then |
| 1764 | _NS=$(test $WITH_ETCD == "yes" && echo $VOLTHA_NS || echo $INFRA_NS) |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 1765 | bspin - "Forward VOLTHA Kafka port $FORWARD" |
| 1766 | kill_port_forward voltha-kafka |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1767 | port_forward $_NS voltha-kafka $VOLTHA_KAFKA_PORT 9092 |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 1768 | espin - $VERIFIED |
| 1769 | fi |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 1770 | if [ "$WITH_TIMINGS" == "yes" ]; then |
| 1771 | printtime $(expr $(date +%s) - $STIME) |
| 1772 | fi |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1773 | fi |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 1774 | |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 1775 | if [ $WITH_ONOS == "yes" -a $WITH_RADIUS != "no" ]; then |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1776 | _HOST=radius.$INFRA_NS.svc.cluster.local |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 1777 | _PORT=1812 |
| 1778 | if [ $WITH_RADIUS != "yes" ]; then |
| 1779 | _HOST=$(echo $WITH_RADIUS | cut -d: -f1) |
| 1780 | _PORT=$(echo $WITH_RADIUS | cut -s -d: -f2) |
| 1781 | _PORT=${_PORT:-1812} |
| 1782 | fi |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 1783 | bspin "Configure ONOS RADIUS Connection $GEAR" |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 1784 | (set -x; cat onos-files/onos-aaa.json | sed -e "s/:RADIUS_SVC:/$_HOST/g" -e "s/:RADIUS_PORT:/$_PORT/" | curl --fail -sSL --user karaf:karaf -X POST http://$_ONOS_API_EP/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] | 1785 | espin $VERIFIED |
| 1786 | fi |
| 1787 | |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 1788 | if [ "$WITH_CHAOS" == "yes" ]; then |
| 1789 | STIME=$(date +%s) |
| 1790 | echo -e "Verify kube-monkey $LOCK" |
| 1791 | bspin - "Verify kube-monkey Installed" |
| 1792 | if [ $(helm list --deployed --short --namespace kube-monkey "^monkey\$" | wc -l) -ne 1 ]; then |
| 1793 | espin - $NOT_VERIFIED |
| 1794 | helm_install - kube-monkey monkey ./kube-monkey/helm/kubemonkey latest "Install Chaos Monkey" |
| 1795 | else |
| 1796 | espin - $VERIFIED |
| 1797 | fi |
| 1798 | wait_for_pods - "kube-monkey" 1 "includes" -1 "Waiting for Chaos to start" "monkey-.*" |
| 1799 | if [ "$WITH_TIMINGS" == "yes" ]; then |
| 1800 | printtime $(expr $(date +%s) - $STIME) |
| 1801 | fi |
| 1802 | fi |
| 1803 | |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 1804 | bspin "Create voltctl configuration file" |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 1805 | (set -x; mkdir -p $HOME/.volt >>$LOG 2>&1) >>$LOG 2>&1 |
David K. Bainbridge | b859e91 | 2020-03-13 14:07:52 -0700 | [diff] [blame] | 1806 | MIN_VC_VERSION=$(echo -e "1.0.15\n$VC_VERSION" | sort -V | head -1) |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 1807 | if [ $WITH_PORT_FORWARDS == "yes" ]; then |
David K. Bainbridge | b859e91 | 2020-03-13 14:07:52 -0700 | [diff] [blame] | 1808 | KAFKA_FLAG="-k localhost:$VOLTHA_KAFKA_PORT" |
| 1809 | SERVER_FLAG="-s localhost:$VOLTHA_API_PORT" |
| 1810 | ETCD_FLAG= |
| 1811 | if [ "$MIN_VC_VERSION" == "1.0.15" ]; then |
| 1812 | ETCD_FLAG="-e localhost:$VOLTHA_ETCD_PORT" |
| 1813 | fi |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 1814 | else |
David K. Bainbridge | b859e91 | 2020-03-13 14:07:52 -0700 | [diff] [blame] | 1815 | KAFKA_FLAG="-k $(get_service_ep voltha voltha-kafka)" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1816 | SERVER_FLAG="-s $(get_service_ep $VOLTHA_NS voltha-api)" |
David K. Bainbridge | b859e91 | 2020-03-13 14:07:52 -0700 | [diff] [blame] | 1817 | ETCD_FLAG= |
| 1818 | if [ "$MIN_VC_VERSION" == "1.0.15" ]; then |
| 1819 | ETCD_FLAG="-e $(get_service_ep voltha voltha-etcd-client)" |
| 1820 | fi |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 1821 | fi |
David K. Bainbridge | b859e91 | 2020-03-13 14:07:52 -0700 | [diff] [blame] | 1822 | (set -x; voltctl -a v3 $KAFKA_FLAG $SERVER_FLAG $ETCD_FLAG config > $HOME/.volt/config-$NAME 2>>$LOG) >>$LOG 2>&1 |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 1823 | espin $VERIFIED |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 1824 | |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1825 | if [ ! -f "$NAME-env.sh" ]; then |
| 1826 | touch $NAME-env.sh |
David Bainbridge | b07fdf7 | 2019-07-29 22:51:40 +0000 | [diff] [blame] | 1827 | fi |
| 1828 | |
David Bainbridge | 596f30d | 2019-07-30 17:07:59 +0000 | [diff] [blame] | 1829 | for O in $ALL_OPTIONS; do |
| 1830 | VAL=$(eval echo \$$O) |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1831 | if [ ! -z "$VAL" -a $(grep -c "^export $O=" $NAME-env.sh) -eq 0 ]; then |
| 1832 | echo "export $O=\"$(eval echo \$$O)\"" >> $NAME-env.sh |
David Bainbridge | b07fdf7 | 2019-07-29 22:51:40 +0000 | [diff] [blame] | 1833 | fi |
| 1834 | done |
| 1835 | |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1836 | if [ $DEPLOY_K8S == "yes" -a $(grep -c "^export KUBECONFIG=" $NAME-env.sh) -eq 0 ]; then |
| 1837 | 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] | 1838 | fi |
| 1839 | |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1840 | if [ $(grep -c "^export VOLTCONFIG=" $NAME-env.sh) -eq 0 ]; then |
| 1841 | echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" >> $NAME-env.sh |
David Bainbridge | b07fdf7 | 2019-07-29 22:51:40 +0000 | [diff] [blame] | 1842 | fi |
| 1843 | |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1844 | if [ $(grep -c "^export PATH=" $NAME-env.sh) -eq 0 ]; then |
| 1845 | echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> $NAME-env.sh |
David Bainbridge | b07fdf7 | 2019-07-29 22:51:40 +0000 | [diff] [blame] | 1846 | fi |
| 1847 | |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 1848 | echo "" |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 1849 | echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG |
| 1850 | echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG |
| 1851 | echo "tools required by VOLTHA in your command path. " | tee -a $LOG |
| 1852 | echo "" | tee -a $LOG |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 1853 | echo -en $BOLD |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1854 | if [ $DEPLOY_K8S == "yes" ]; then |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1855 | 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] | 1856 | fi |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1857 | echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" | tee -a $LOG |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1858 | echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 1859 | echo -en $NORMAL |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 1860 | echo "" | tee -a $LOG |
| 1861 | echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG |
| 1862 | |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 1863 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | f858a02 | 2019-08-14 21:25:11 +0000 | [diff] [blame] | 1864 | 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] | 1865 | fi |