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