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