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