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