Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 1 | #!/bin/bash |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 2 | # Copyright 2019 Ciena Corporation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
David Bainbridge | d049a61 | 2020-03-16 17:22:54 -0700 | [diff] [blame] | 15 | set -f |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 16 | unalias -a |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 17 | shopt -s extglob |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 18 | TOTAL_START_TIME="$(date +%s)" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 19 | |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 20 | FANCY=${FANCY:-1} |
| 21 | if [ "$TERM X" == " X" ]; then |
| 22 | FANCY=0 |
| 23 | fi |
| 24 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 25 | # trap ctrl-c and call ctrl_c() |
| 26 | trap ctrl_c INT |
| 27 | |
| 28 | function ctrl_c() { |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 29 | echo -en "$CNORM" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 30 | echo "" |
| 31 | echo "ctrl-c trapped" |
David Bainbridge | c6a6eb6 | 2019-10-18 22:50:07 +0000 | [diff] [blame] | 32 | echo "Thank you for trying 'voltha up'" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 33 | exit |
| 34 | } |
| 35 | |
David Bainbridge | a34993d | 2020-04-01 09:15:42 -0700 | [diff] [blame] | 36 | HELM_VERSION=${HELM_VERSION:-v2.14.3} |
David K. Bainbridge | ebf38d9 | 2020-02-10 10:46:31 -0800 | [diff] [blame] | 37 | VOLTCTL_VERSION=${VOLTCTL_VERSION:-latest} |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 38 | KIND_VERSION=${KIND_VERSION:-v0.5.1} |
David K. Bainbridge | b3a9937 | 2020-01-08 14:39:06 -0800 | [diff] [blame] | 39 | VK_RELEASE=${VK_RELEASE:-master} |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 40 | EXTRA_TOOLS= |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 41 | |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 42 | RED= |
| 43 | GREEN= |
| 44 | YELLOW= |
| 45 | BLUE= |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 46 | BOLD= |
| 47 | NORMAL= |
| 48 | ERROR= |
| 49 | CEOL= |
| 50 | CNORM= |
| 51 | CIVIS= |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 52 | if [ "$FANCY" -eq 1 ]; then |
| 53 | RED="$(tput setaf 1)" |
| 54 | GREEN="$(tput setaf 2)" |
| 55 | YELLOW="$(tput setaf 3)" |
| 56 | BLUE="$(tput setaf 4)" |
| 57 | BOLD="$(tput bold)" |
| 58 | NORMAL="$(tput sgr0)" |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 59 | ERROR="\xe2\x9c\x97\x20" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 60 | CEOL="$(tput el)" |
| 61 | CNORM="$(tput cnorm)" |
| 62 | CIVIS="$(tput civis)" |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 63 | fi |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 64 | |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 65 | TYPE=${TYPE:-minimal} |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 66 | NAME=${NAME:-$TYPE} |
David K. Bainbridge | 484d80c | 2020-03-05 21:44:34 -0800 | [diff] [blame] | 67 | |
| 68 | ENABLE_ONOS_EXTRANEOUS_RULES=${ENABLE_ONOS_EXTRANEOUS_RULES:-no} |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 69 | INFRA_NS=${INFRA_NS:-default} |
| 70 | VOLTHA_NS=${VOLTHA_NS:-voltha} |
| 71 | BBSIM_NS=${BBSIM_NS:-voltha} |
| 72 | ADAPTER_NS=${ADAPTER_NS:-voltha} |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 73 | WITH_TIMINGS=${WITH_TIMINGS:-no} |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 74 | WITH_BBSIM=${WITH_BBSIM:-no} |
divyadesai | 59f987a | 2020-05-27 12:11:33 +0000 | [diff] [blame] | 75 | WITH_EFK=${WITH_EFK:-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 | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 81 | NUM_OF_ONOS=${NUM_OF_ONOS:-1} |
| 82 | NUM_OF_ATOMIX=${NUM_OF_ATOMIX:-0} |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 83 | WITH_CHAOS=${WITH_CHAOS:-no} |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 84 | WITH_ADAPTERS=${WITH_ADAPTERS:-yes} |
David K. Bainbridge | da33d65 | 2020-03-06 10:31:23 -0800 | [diff] [blame] | 85 | WITH_SIM_ADAPTERS=${WITH_SIM_ADAPTERS:-no} |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 86 | WITH_OPEN_ADAPTERS=${WITH_OPEN_ADAPTERS:-yes} |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 87 | WITH_PORT_FORWARDS=${WITH_PORT_FORWARDS:-yes} |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 88 | WITH_KAFKA=${WITH_KAFKA:-yes} |
| 89 | WITH_ETCD=${WITH_ETCD:-yes} |
Matteo Scandolo | efee043 | 2020-05-05 13:56:20 -0700 | [diff] [blame] | 90 | WITH_PPROF=${WITH_PPROF:-no} |
Girish Gowdra | 4cc5d8b | 2020-06-11 17:12:00 -0700 | [diff] [blame] | 91 | WITH_INCREMENTAL_EVTO_UPDATE=${WITH_INCREMENTAL_EVTO_UPDATE:-no} |
David Bainbridge | e4d11ca | 2020-05-08 10:21:10 -0700 | [diff] [blame] | 92 | SCHEDULE_ON_CONTROL_NODES=${SCHEDULE_ON_CONTROL_NODES:-no} |
David Bainbridge | 309099c | 2020-05-05 08:47:29 -0700 | [diff] [blame] | 93 | CONFIG_SADIS=${CONFIG_SADIS:-no} # yes | no | file | bbsim | external | URL |
Hardik Windlass | b314760 | 2020-03-09 16:59:15 +0530 | [diff] [blame] | 94 | SADIS_CFG=${SADIS_CFG:-onos-files/onos-sadis-sample.json} |
David Bainbridge | 27790d6 | 2019-08-13 22:43:19 +0000 | [diff] [blame] | 95 | INSTALL_ONOS_APPS=${INSTALL_ONOS_APPS:-no} |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 96 | JUST_K8S=${JUST_K8S:-no} |
| 97 | DEPLOY_K8S=${DEPLOY_K8S:-yes} |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 98 | INSTALL_KUBECTL=${INSTALL_KUBECTL:-yes} |
| 99 | INSTALL_HELM=${INSTALL_HELM:-yes} |
David Bainbridge | 7f8bf99 | 2020-04-08 21:53:22 -0700 | [diff] [blame] | 100 | HELM_USE_UPGRADE=${HELM_USE_UPGRADE:-no} |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 101 | UPDATE_HELM_REPOS=${UPDATE_HELM_REPOS:-yes} |
Matteo Scandolo | fab9862 | 2020-01-28 15:17:20 -0800 | [diff] [blame] | 102 | WAIT_ON_DOWN=${WAIT_ON_DOWN:-yes} |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 103 | WAIT_TIMEOUT=${WAIT_TIMEOUT:-30m} |
| 104 | VOLTHA_DOWN_ON_TIMEOUT=${VOLTHA_DOWN_ON_TIMEOUT:-no} |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 105 | VOLTHA_LOG_LEVEL=${VOLTHA_LOG_LEVEL:-WARN} |
David Bainbridge | 90fd8e3 | 2019-08-21 23:32:47 +0000 | [diff] [blame] | 106 | VOLTHA_CHART=${VOLTHA_CHART:-onf/voltha} |
| 107 | VOLTHA_CHART_VERSION=${VOLTHA_CHART_VERSION:-latest} |
| 108 | VOLTHA_BBSIM_CHART=${VOLTHA_BBSIM_CHART:-onf/bbsim} |
Matteo Scandolo | dcd29f5 | 2019-10-07 15:42:42 -0700 | [diff] [blame] | 109 | VOLTHA_BBSIM_CHART_VERSION=${VOLTHA_BBSIM_CHART_VERSION:-latest} |
divyadesai | 59f987a | 2020-05-27 12:11:33 +0000 | [diff] [blame] | 110 | ELASTICSEARCH_CHART=${ELASTICSEARCH_CHART:-elastic/elasticsearch} |
| 111 | ELASTICSEARCH_CHART_VERSION=${ELASTICSEARCH_CHART_VERSION:-latest} |
| 112 | KIBANA_CHART=${KIBANA_CHART:-elastic/kibana} |
| 113 | KIBANA_CHART_VERSION=${KIBANA_CHART_VERSION:-latest} |
| 114 | FLUENTD_ELASTICSEARCH_CHART=${FLUENTD_ELASTICSEARCH_CHART:-kiwigrid/fluentd-elasticsearch} |
| 115 | FLUENTD_ELASTICSEARCH_CHART_VERSION=${FLUENTD_ELASTICSEARCH_CHART_VERSION:-latest} |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame] | 116 | VOLTHA_ADAPTER_SIM_CHART=${VOLTHA_ADAPTER_SIM_CHART:-onf/voltha-adapter-simulated} |
David Bainbridge | 90fd8e3 | 2019-08-21 23:32:47 +0000 | [diff] [blame] | 117 | VOLTHA_ADAPTER_SIM_CHART_VERSION=${VOLTHA_ADAPTER_SIM_CHART_VERSION:-latest} |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame] | 118 | 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] | 119 | 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] | 120 | 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] | 121 | 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] | 122 | ONOS_CHART=${ONOS_CHART:-onf/onos} |
Andrea Campanella | 2132329 | 2019-12-18 11:44:19 -0800 | [diff] [blame] | 123 | ONOS_CHART_VERSION=${ONOS_CHART_VERSION:-latest} |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 124 | ONOS_CLASSIC_CHART=${ONOS_CLASSIC_CHART:-onos/onos-classic} |
| 125 | ONOS_CLASSIC_CHART_VERSION=${ONOS_CHART_VERSION:-latest} |
David Bainbridge | cf54636 | 2020-04-21 23:18:50 -0700 | [diff] [blame] | 126 | KAFKA_CHART=${KAFKA_CHART:-incubator/kafka} |
David Bainbridge | b909352 | 2020-04-15 14:32:44 -0700 | [diff] [blame] | 127 | KAFKA_CHART_VERSION=${KAFKA_CHART_VERSION:=0.15.3} |
David Bainbridge | 309099c | 2020-05-05 08:47:29 -0700 | [diff] [blame] | 128 | BBSIM_SADIS_SERVER_CHART=${BBSIM_SADIS_SERVER_CHART:-bbsim-sadis/bbsim-sadis-server} |
| 129 | BBSIM_SADIS_SERVER_CHART_VERSION=${BBSIM_SADIS_SERVER_CHART_VERSION:-latest} |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 130 | ETCD_CHART=${ETCD_CHART:-incubator/etcd} |
| 131 | ETCD_CHART_VERSION=${ETCD_CHART_VERSION:-latest} |
David Bainbridge | 879439b | 2020-06-12 15:59:35 -0700 | [diff] [blame] | 132 | RADIUS_CHART=${RADIUS_CHART:-onf/freeradius} |
| 133 | RADIUS_CHART_VERSION=${RADIUS_CHART_VERSION:-latest} |
David Bainbridge | 2eaf2cf | 2020-03-18 12:54:08 -0700 | [diff] [blame] | 134 | EXTRA_HELM_INSTALL_ARGS=${EXTRA_HELM_INSTALL_ARGS:-} |
| 135 | INTERNAL_EXTRA_HELM_INSTALL_ARGS= |
uottremb | b16d398 | 2020-02-28 08:34:36 +0100 | [diff] [blame] | 136 | NUM_OF_BBSIM=${NUM_OF_BBSIM:-1} |
Matteo Scandolo | 67335f0 | 2020-04-09 11:19:53 -0700 | [diff] [blame] | 137 | NUM_OF_OPENONU=${NUM_OF_OPENONU:-1} |
uottremb | b16d398 | 2020-02-28 08:34:36 +0100 | [diff] [blame] | 138 | MAX_NUM_OF_BBSIM=10 |
Matteo Scandolo | 67335f0 | 2020-04-09 11:19:53 -0700 | [diff] [blame] | 139 | MAX_NUM_OF_OPENONU=10 |
Matteo Scandolo | c2eb067 | 2020-05-01 14:43:15 -0700 | [diff] [blame] | 140 | LEGACY_BBSIM_INDEX=${LEGACY_BBSIM_INDEX:-no} |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 141 | |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 142 | HOSTOS="$(uname -s | tr "[:upper:]" "[:lower:"])" |
| 143 | HOSTARCH="$(uname -m | tr "[:upper:]" "[:lower:"])" |
| 144 | if [ "$HOSTARCH" == "x86_64" ]; then |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 145 | HOSTARCH="amd64" |
| 146 | fi |
David Bainbridge | 7db4400 | 2020-04-09 12:54:29 -0700 | [diff] [blame] | 147 | BBSIM_LABEL="-l app=bbsim" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 148 | NO_LABEL= |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 149 | |
uottremb | b16d398 | 2020-02-28 08:34:36 +0100 | [diff] [blame] | 150 | # check number (range) of bbsim, max bbsim must not exceed 10 instances! |
| 151 | # note: instances will be numbered from 0 to 9 |
| 152 | if [ "$1" == "up" ]; then |
David K. Bainbridge | 4342240 | 2020-03-06 07:41:22 -0800 | [diff] [blame] | 153 | if [ "$NUM_OF_BBSIM" -lt 1 ]; then |
Matteo Scandolo | 67335f0 | 2020-04-09 11:19:53 -0700 | [diff] [blame] | 154 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid setting of BBSIM instances. NUM_OF_BBSIM (${NUM_OF_BBSIM}) is less than 1${NORMAL}" |
David K. Bainbridge | 4342240 | 2020-03-06 07:41:22 -0800 | [diff] [blame] | 155 | exit 1 |
| 156 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 157 | if [ "$NUM_OF_BBSIM" -gt "$MAX_NUM_OF_BBSIM" ]; then |
Matteo Scandolo | 67335f0 | 2020-04-09 11:19:53 -0700 | [diff] [blame] | 158 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid setting of BBSIM instances. NUM_OF_BBSIM (${NUM_OF_BBSIM}) is greater than $MAX_NUM_OF_BBSIM${NORMAL}" |
| 159 | exit 1 |
| 160 | fi |
| 161 | |
| 162 | if [ "$NUM_OF_OPENONU" -lt 1 ]; then |
| 163 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid setting of OPENONU instances. NUM_OF_OPENONU (${NUM_OF_OPENONU}) is less than 1${NORMAL}" |
| 164 | exit 1 |
| 165 | fi |
| 166 | if [ "$NUM_OF_OPENONU" -gt "$MAX_NUM_OF_OPENONU" ]; then |
| 167 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid setting of OPENONU instances. NUM_OF_OPENONU (${NUM_OF_OPENONU}) is greater than $MAX_NUM_OF_OPENONU${NORMAL}" |
David K. Bainbridge | 4342240 | 2020-03-06 07:41:22 -0800 | [diff] [blame] | 168 | exit 1 |
| 169 | fi |
uottremb | b16d398 | 2020-02-28 08:34:36 +0100 | [diff] [blame] | 170 | fi |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 171 | # Verify TYPE setting |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 172 | if [ "$(echo ":minimal:full:" | grep -ic ":$TYPE:")" -eq 0 ]; then |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 173 | >&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] | 174 | exit 1 |
| 175 | fi |
| 176 | |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 177 | # checks to see if a given WORD is in the given LIST of words |
| 178 | function is_in() { |
| 179 | local WORD LIST |
| 180 | WORD="$1"; shift |
| 181 | LIST="$*" |
| 182 | LIST=${LIST//+([[:space:],|])/:} |
| 183 | |
| 184 | [ "$(echo ":$LIST:" | grep -ic ":$WORD:")" -ne 0 ] |
| 185 | } |
| 186 | |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 187 | function parseDuration() { |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 188 | local DUR RESULT TERM TERMS VALUE UNIT |
| 189 | DUR=$1 |
| 190 | RESULT=0 |
| 191 | TERMS="$(echo "$DUR" | sed -Ee 's/([sSmMhHdD])/\1 /g' -e 's/,$//g')" |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 192 | for TERM in $TERMS; do |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 193 | VALUE="$(echo "$TERM" | sed -Ee 's/([0-9]+)[sSmMhHdD]/\1/')" |
| 194 | UNIT="$(echo "$TERM" | sed -Ee 's/[0-9]+([sSmMhHdD])/\1/')" |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 195 | case $UNIT in |
| 196 | s|S) |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 197 | RESULT=$((RESULT + VALUE)) ;; |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 198 | m|M) |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 199 | RESULT=$((RESULT + (VALUE * 60))) ;; |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 200 | h|H) |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 201 | RESULT=$((RESULT + (VALUE * 3600))) ;; |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 202 | d|D) |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 203 | RESULT=$((RESULT + (VALUE * 86400))) ;; |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 204 | *) ;; |
| 205 | esac |
| 206 | done |
| 207 | echo $RESULT |
| 208 | } |
| 209 | |
| 210 | function doTimeout() { |
| 211 | local MSG=$1 |
| 212 | 2>&1 echo -e "\n${RED}${BOLD}${ERROR}TIMEOUT:${NORMAL}${RED} Operation timed out after '$WAIT_TIMEOUT': $MSG" |
| 213 | exit 125 |
| 214 | } |
| 215 | |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 216 | function get_service_ep() { |
| 217 | local NS=$1 |
| 218 | local NAME=$2 |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 219 | kubectl -n "$NS" get service "$NAME" -o json | jq -r '.spec.clusterIP + ":" + (.spec.ports[0].port|tostring)' |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 220 | } |
| 221 | |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 222 | # Used to verify configuration values are set to "yes" or "no" value or convert |
| 223 | # equivalents to "yes" or "no" |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 224 | YES="y,yes,t,true,1" |
| 225 | NO="n,no,f,false,0" |
| 226 | YES_OR_NO="$YES,$NO" |
| 227 | |
| 228 | # If the given VAR matches a truth value then normalize that |
| 229 | # value, else return original value |
| 230 | function normalize_yes_no() { |
| 231 | local VAR VAL |
| 232 | VAR=$1 |
| 233 | VAL="$(eval echo "\$$VAR")" |
| 234 | if ! is_in "$VAL" "$YES_OR_NO"; then |
| 235 | echo "$VAL" |
| 236 | return 1 |
| 237 | fi |
| 238 | if is_in "$VAL" "$YES"; then |
| 239 | echo "yes" |
| 240 | else |
| 241 | echo "no" |
| 242 | fi |
| 243 | return 0 |
| 244 | } |
| 245 | |
| 246 | # If the given VAR matches a truth value then normalize that |
| 247 | # value, else display an error |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 248 | function verify_yes_no() { |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 249 | local VAR VAL |
| 250 | VAR=$1 |
| 251 | VAL="$(eval echo "\$$VAR")" |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 252 | if ! is_in "$VAL" "$YES_OR_NO"; then |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 253 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid '$VAR' value of '$VAL'. Should be 'yes' or 'no'${NORMAL}" |
| 254 | echo "INVALID" |
| 255 | return 1 |
| 256 | fi |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 257 | if is_in "$VAL" "$YES"; then |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 258 | echo "yes" |
| 259 | else |
| 260 | echo "no" |
| 261 | fi |
| 262 | return 0 |
| 263 | } |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 264 | |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 265 | ALL_YES_NO="\ |
David K. Bainbridge | 484d80c | 2020-03-05 21:44:34 -0800 | [diff] [blame] | 266 | ENABLE_ONOS_EXTRANEOUS_RULES \ |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 267 | WITH_TIMINGS \ |
| 268 | WITH_BBSIM \ |
divyadesai | 59f987a | 2020-05-27 12:11:33 +0000 | [diff] [blame] | 269 | WITH_EFK \ |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 270 | WITH_EAPOL \ |
| 271 | WITH_DHCP \ |
| 272 | WITH_IGMP \ |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 273 | WITH_CHAOS \ |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 274 | WITH_ADAPTERS \ |
| 275 | WITH_SIM_ADAPTERS \ |
| 276 | WITH_OPEN_ADAPTERS \ |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 277 | WITH_PORT_FORWARDS \ |
Matteo Scandolo | efee043 | 2020-05-05 13:56:20 -0700 | [diff] [blame] | 278 | WITH_PPROF \ |
Girish Gowdra | 4cc5d8b | 2020-06-11 17:12:00 -0700 | [diff] [blame] | 279 | WITH_INCREMENTAL_EVTO_UPDATE \ |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 280 | JUST_K8S \ |
| 281 | DEPLOY_K8S \ |
| 282 | INSTALL_ONOS_APPS \ |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 283 | INSTALL_KUBECTL \ |
| 284 | INSTALL_HELM \ |
David Bainbridge | 7f8bf99 | 2020-04-08 21:53:22 -0700 | [diff] [blame] | 285 | HELM_USE_UPGRADE \ |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 286 | UPDATE_HELM_REPOS \ |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 287 | WAIT_ON_DOWN \ |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 288 | VOLTHA_DOWN_ON_TIMEOUT \ |
Matteo Scandolo | c2eb067 | 2020-05-01 14:43:15 -0700 | [diff] [blame] | 289 | LEGACY_BBSIM_INDEX \ |
David Bainbridge | e4d11ca | 2020-05-08 10:21:10 -0700 | [diff] [blame] | 290 | SCHEDULE_ON_CONTROL_NODES \ |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 291 | " |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 292 | |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 293 | OPT_YES_NO="\ |
| 294 | CONFIG_SADIS \ |
| 295 | WITH_KAFKA \ |
| 296 | WITH_RADIUS \ |
| 297 | WITH_ETCD \ |
| 298 | WITH_ONOS \ |
| 299 | " |
| 300 | |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 301 | ALL_OPTIONS="\ |
| 302 | NAME \ |
| 303 | TYPE \ |
| 304 | $ALL_YES_NO \ |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 305 | $OPT_YES_NO \ |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 306 | WAIT_TIMEOUT \ |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 307 | VOLTHA_LOG_LEVEL \ |
| 308 | VOLTHA_CHART \ |
David Bainbridge | 90fd8e3 | 2019-08-21 23:32:47 +0000 | [diff] [blame] | 309 | VOLTHA_CHART_VERSION \ |
| 310 | VOLTHA_BBSIM_CHART \ |
| 311 | VOLTHA_BBSIM_CHART_VERSION \ |
David Bainbridge | 879439b | 2020-06-12 15:59:35 -0700 | [diff] [blame] | 312 | BBSIM_SADIS_SERVER_CHART \ |
| 313 | BBSIM_SADIS_SERVER_CHART_VERSION \ |
uottremb | d5a2057 | 2020-03-06 09:15:01 +0100 | [diff] [blame] | 314 | NUM_OF_BBSIM \ |
divyadesai | 59f987a | 2020-05-27 12:11:33 +0000 | [diff] [blame] | 315 | ELASTICSEARCH_CHART \ |
| 316 | ELASTICSEARCH_CHART_VERSION \ |
| 317 | KIBANA_CHART \ |
| 318 | KIBANA_CHART_VERSION \ |
| 319 | FLUENTD_ELASTICSEARCH_CHART \ |
| 320 | FLUENTD_ELASTICSEARCH_CHART_VERSION \ |
Matteo Scandolo | 67335f0 | 2020-04-09 11:19:53 -0700 | [diff] [blame] | 321 | NUM_OF_OPENONU \ |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 322 | VOLTHA_ADAPTER_SIM_CHART \ |
David Bainbridge | 90fd8e3 | 2019-08-21 23:32:47 +0000 | [diff] [blame] | 323 | VOLTHA_ADAPTER_SIM_CHART_VERSION \ |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 324 | VOLTHA_ADAPTER_OPEN_OLT_CHART \ |
David Bainbridge | 90fd8e3 | 2019-08-21 23:32:47 +0000 | [diff] [blame] | 325 | VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION \ |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 326 | VOLTHA_ADAPTER_OPEN_ONU_CHART \ |
David Bainbridge | 90fd8e3 | 2019-08-21 23:32:47 +0000 | [diff] [blame] | 327 | VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION \ |
David K. Bainbridge | da33d65 | 2020-03-06 10:31:23 -0800 | [diff] [blame] | 328 | ONOS_CHART \ |
Andrea Campanella | 2132329 | 2019-12-18 11:44:19 -0800 | [diff] [blame] | 329 | ONOS_CHART_VERSION \ |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 330 | ONOS_CLASSIC_CHART \ |
| 331 | ONOS_CLASSIC_CHART_VERSION \ |
David Bainbridge | cf54636 | 2020-04-21 23:18:50 -0700 | [diff] [blame] | 332 | KAFKA_CHART \ |
David Bainbridge | b909352 | 2020-04-15 14:32:44 -0700 | [diff] [blame] | 333 | KAFKA_CHART_VERSION \ |
David Bainbridge | 879439b | 2020-06-12 15:59:35 -0700 | [diff] [blame] | 334 | ETCD_CHART \ |
| 335 | ETCD_CHART_VERSION \ |
| 336 | RADIUS_CHART \ |
| 337 | RADIUS_CHART_VERSION \ |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 338 | ONOS_API_PORT \ |
| 339 | ONOS_SSH_PORT \ |
Hardik Windlass | b314760 | 2020-03-09 16:59:15 +0530 | [diff] [blame] | 340 | SADIS_CFG \ |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 341 | VOLTHA_API_PORT \ |
| 342 | VOLTHA_SSH_PORT \ |
| 343 | VOLTHA_ETCD_PORT \ |
divyadesai | 59f987a | 2020-05-27 12:11:33 +0000 | [diff] [blame] | 344 | ELASTICSEARCH_PORT \ |
| 345 | KIBANA_PORT \ |
David K. Bainbridge | 00ecd38 | 2020-02-28 12:31:58 -0800 | [diff] [blame] | 346 | VOLTHA_KAFKA_PORT \ |
Matteo Scandolo | efee043 | 2020-05-05 13:56:20 -0700 | [diff] [blame] | 347 | VOLTHA_PPROF_PORT \ |
| 348 | OPENOLT_PPROF_PORT \ |
Matteo Scandolo | 65c3519 | 2020-05-13 10:41:21 -0700 | [diff] [blame] | 349 | OFAGENT_PPROF_PORT \ |
David K. Bainbridge | 8f7f30b | 2020-01-08 13:06:16 -0800 | [diff] [blame] | 350 | VK_RELEASE \ |
| 351 | KIND_VERSION \ |
| 352 | VOLTCTL_VERSION \ |
David Bainbridge | a34993d | 2020-04-01 09:15:42 -0700 | [diff] [blame] | 353 | HELM_VERSION \ |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 354 | NUM_OF_ONOS \ |
| 355 | NUM_OF_ATOMIX \ |
David Bainbridge | 6ca4010 | 2020-04-08 11:30:40 -0700 | [diff] [blame] | 356 | VOLTHA_NS \ |
| 357 | ADAPTER_NS \ |
| 358 | INFRA_NS \ |
| 359 | BBSIM_NS \ |
David Bainbridge | 7db4400 | 2020-04-09 12:54:29 -0700 | [diff] [blame] | 360 | SADIS_BANDWIDTH_PROFILES \ |
| 361 | SADIS_SUBSCRIBERS \ |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 362 | " |
David Bainbridge | 0129495 | 2019-07-30 19:33:45 +0000 | [diff] [blame] | 363 | |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 364 | # Iterate over yes/no configuration options and validate |
| 365 | for VAR in $ALL_YES_NO; do |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 366 | eval "$VAR"="$(verify_yes_no "$VAR")" |
| 367 | if [ "$(eval echo "\$$VAR")" == "INVALID" ]; then |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 368 | exit 1; |
| 369 | fi |
| 370 | done |
David Bainbridge | b270c20 | 2019-07-26 01:44:42 +0000 | [diff] [blame] | 371 | |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 372 | # Iterate over optional yes/no configuration options and |
| 373 | # normalize values if they are truth values |
| 374 | for VAR in $OPT_YES_NO; do |
| 375 | eval "$VAR"="$(normalize_yes_no "$VAR")" |
| 376 | done |
David Bainbridge | 15f6f23 | 2020-03-30 09:15:43 -0700 | [diff] [blame] | 377 | |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 378 | # normalize non-truth value options |
| 379 | if is_in "$WITH_KAFKA" "e,external"; then |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 380 | WITH_KAFKA="external" |
| 381 | fi |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 382 | if is_in "$WITH_ETCD" "e,external"; then |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 383 | WITH_ETCD="external" |
| 384 | fi |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 385 | if is_in "$WITH_ONOS" "l,legacy"; then |
| 386 | WITH_ONOS="legacy" |
| 387 | elif is_in "$WITH_ONOS" "c,classic"; then |
| 388 | WITH_ONOS="classic" |
| 389 | elif is_in "$WITH_ONOS" "u,m,micro"; then |
| 390 | WITH_ONOS="micro" |
David Bainbridge | 29c31cb | 2020-04-06 09:45:50 -0700 | [diff] [blame] | 391 | fi |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 392 | |
| 393 | if [ "$WITH_ONOS" == "micro" ]; then |
| 394 | >&2 echo -e "${YELLOW}${BOLD}${ERROR}WARNING:${NORMAL}${YELLOW} The value specified as WITH_ONOS, '$WITH_ONOS', is not valid.${NORMAL}" |
| 395 | exit 1 |
David Bainbridge | 29c31cb | 2020-04-06 09:45:50 -0700 | [diff] [blame] | 396 | fi |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 397 | |
| 398 | if is_in "$WITH_ONOS" "yes,classic"; then |
| 399 | # there is an extra utility required if we are using ONOS CLASSIC as |
| 400 | # the chart for classic specifies images differently |
| 401 | EXTRA_TOOLS+=" yq" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 402 | fi |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 403 | |
David Bainbridge | 22db5dd | 2020-05-26 12:21:21 -0700 | [diff] [blame] | 404 | if [ "$LEGACY_BBSIM_INDEX" == "no" ]; then |
| 405 | BBSIM_SADIS_SVC="bbsim0" |
| 406 | else |
| 407 | BBSIM_SADIS_SVC="bbsim" |
| 408 | fi |
| 409 | |
| 410 | SADIS_SUBSCRIBERS=${SADIS_SUBSCRIBERS:-http://$BBSIM_SADIS_SVC.$VOLTHA_NS.svc:50074/v2/subscribers/%s} |
| 411 | SADIS_BANDWIDTH_PROFILES=${SADIS_BANDWIDTH_PROFILES:-http://$BBSIM_SADIS_SVC.$VOLTHA_NS.svc:50074/v2/bandwidthprofiles/%s} |
| 412 | |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 413 | if [ "$HELM_USE_UPGRADE" == "yes" ]; then |
David Bainbridge | 7f8bf99 | 2020-04-08 21:53:22 -0700 | [diff] [blame] | 414 | _HELM_DESC="Upgrade/Install" |
| 415 | else |
| 416 | _HELM_DESC="Install" |
| 417 | fi |
| 418 | |
David K. Bainbridge | da33d65 | 2020-03-06 10:31:23 -0800 | [diff] [blame] | 419 | # Check for prerequiste tools |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 420 | TOOLS="curl sed jq $EXTRA_TOOLS" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 421 | if [ "$DEPLOY_K8S" == "yes" ]; then |
David K. Bainbridge | da33d65 | 2020-03-06 10:31:23 -0800 | [diff] [blame] | 422 | TOOLS+=" docker" |
| 423 | fi |
| 424 | NOT_FOUND="" |
| 425 | for T in $TOOLS; do |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 426 | if [ -z "$(command -v "$T")" ]; then |
David K. Bainbridge | da33d65 | 2020-03-06 10:31:23 -0800 | [diff] [blame] | 427 | NOT_FOUND+=" $T" |
| 428 | fi |
| 429 | done |
| 430 | |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 431 | if [ -n "$NOT_FOUND" ]; then |
David K. Bainbridge | da33d65 | 2020-03-06 10:31:23 -0800 | [diff] [blame] | 432 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} The following required tools where not found, please install them:$NOT_FOUND" |
| 433 | exit 1 |
| 434 | fi |
| 435 | |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 436 | TIMEOUT_SECONDS="$(parseDuration "$WAIT_TIMEOUT")" |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 437 | |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 438 | mkdir -p .voltha |
| 439 | touch .voltha/ports |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 440 | HAVE="$(grep "$NAME" .voltha/ports)" |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 441 | if [ "$HAVE X" == " X" ]; then |
| 442 | # Find free port prefix |
| 443 | START=81 |
| 444 | while true; do |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 445 | if [ "$(grep -c $START .voltha/ports)" -eq 0 ]; then |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 446 | break |
| 447 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 448 | START="$((START + 1))" |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 449 | done |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 450 | DELTA="$((START - 81))" |
David Bainbridge | a259542 | 2019-10-22 03:54:28 +0000 | [diff] [blame] | 451 | ONOS_API_PORT=${ONOS_API_PORT:-${START}81} |
| 452 | ONOS_SSH_PORT=${ONOS_SSH_PORT:-${START}01} |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 453 | VOLTHA_API_PORT=${VOLTHA_API_PORT:-5$((55 + DELTA))55} |
| 454 | VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$((50 + DELTA))22} |
| 455 | VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$((23 + DELTA))79} |
| 456 | VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$((90 + DELTA))92} |
Matteo Scandolo | efee043 | 2020-05-05 13:56:20 -0700 | [diff] [blame] | 457 | VOLTHA_PPROF_PORT=${VOLTHA_PPROF_PORT:-$((60 + DELTA))60} |
| 458 | OPENOLT_PPROF_PORT=${OPENOLT_PPROF_PORT:-$((60 + DELTA))61} |
Matteo Scandolo | 65c3519 | 2020-05-13 10:41:21 -0700 | [diff] [blame] | 459 | OFAGENT_PPROF_PORT=${OFAGENT_PPROF_PORT:-$((60 + DELTA))62} |
divyadesai | 59f987a | 2020-05-27 12:11:33 +0000 | [diff] [blame] | 460 | ELASTICSEARCH_PORT=${ELASTICSEARCH_PORT:-$((92 + DELTA))00} |
| 461 | KIBANA_PORT=${KIBANA_PORT:-$((56 + DELTA))01} |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 462 | else |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 463 | VALUES="$(echo "$HAVE" | sed -e 's/\s//g' | cut -d= -f2)" |
| 464 | ONOS_API_PORT=${ONOS_API_PORT:-$(echo "$VALUES" | cut -d, -f1)} |
| 465 | ONOS_SSH_PORT=${ONOS_SSH_PORT:-$(echo "$VALUES" | cut -d, -f2)} |
| 466 | VOLTHA_API_PORT=${VOLTHA_API_PORT:-$(echo "$VALUES" | cut -d, -f3)} |
| 467 | VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$(echo "$VALUES" | cut -d, -f4)} |
| 468 | VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$(echo "$VALUES" | cut -d, -f5)} |
| 469 | VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(echo "$VALUES" | cut -d, -f6)} |
Matteo Scandolo | efee043 | 2020-05-05 13:56:20 -0700 | [diff] [blame] | 470 | VOLTHA_PPROF_PORT=${VOLTHA_PPROF_PORT:-$(echo "$VALUES" | cut -d, -f7)} |
| 471 | OPENOLT_PPROF_PORT=${OPENOLT_PPROF_PORT:-$(echo "$VALUES" | cut -d, -f8)} |
Matteo Scandolo | 65c3519 | 2020-05-13 10:41:21 -0700 | [diff] [blame] | 472 | OFAGENT_PPROF_PORT=${OFAGENT_PPROF_PORT:-$(echo "$VALUES" | cut -d, -f9)} |
divyadesai | 59f987a | 2020-05-27 12:11:33 +0000 | [diff] [blame] | 473 | ELASTICSEARCH_PORT=${ELASTICSEARCH_PORT:-$(echo "$VALUES" | cut -d, -f10)} |
| 474 | KIBANA_PORT=${KIBANA_PORT:-$(echo "$VALUES" | cut -d, -f11)} |
David K. Bainbridge | 00ecd38 | 2020-02-28 12:31:58 -0800 | [diff] [blame] | 475 | |
Matteo Scandolo | efee043 | 2020-05-05 13:56:20 -0700 | [diff] [blame] | 476 | # Some ports were added after the .voltha/ports files was created. |
| 477 | # Calculate the original DELTA from the VOLTHA_SSH_PORT so that it can |
| 478 | # be used to set up newer port-forwards. |
| 479 | DELTA="$((VOLTHA_SSH_PORT/100-50))" |
| 480 | |
David K. Bainbridge | 00ecd38 | 2020-02-28 12:31:58 -0800 | [diff] [blame] | 481 | if [ -z "$VOLTHA_KAFKA_PORT" ]; then |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 482 | VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$((90 + DELTA))92} |
David K. Bainbridge | 00ecd38 | 2020-02-28 12:31:58 -0800 | [diff] [blame] | 483 | fi |
Matteo Scandolo | efee043 | 2020-05-05 13:56:20 -0700 | [diff] [blame] | 484 | |
| 485 | if [ -z "$VOLTHA_PPROF_PORT" ]; then |
divyadesai | 59f987a | 2020-05-27 12:11:33 +0000 | [diff] [blame] | 486 | VOLTHA_PPROF_PORT=${VOLTHA_PPROF_PORT:-$((60 + DELTA))60} |
Matteo Scandolo | efee043 | 2020-05-05 13:56:20 -0700 | [diff] [blame] | 487 | fi |
| 488 | if [ -z "$OPENOLT_PPROF_PORT" ]; then |
divyadesai | 59f987a | 2020-05-27 12:11:33 +0000 | [diff] [blame] | 489 | OPENOLT_PPROF_PORT=${OPENOLT_PPROF_PORT:-$((60 + DELTA))61} |
Matteo Scandolo | efee043 | 2020-05-05 13:56:20 -0700 | [diff] [blame] | 490 | fi |
Matteo Scandolo | 65c3519 | 2020-05-13 10:41:21 -0700 | [diff] [blame] | 491 | if [ -z "$OFAGENT_PPROF_PORT" ]; then |
divyadesai | 59f987a | 2020-05-27 12:11:33 +0000 | [diff] [blame] | 492 | OFAGENT_PPROF_PORT=${OFAGENT_PPROF_PORT:-$((60 + DELTA))62} |
| 493 | fi |
| 494 | |
| 495 | if [ -z "$ELASTICSEARCH_PORT" ]; then |
| 496 | ELASTICSEARCH_PORT=${ELASTICSEARCH_PORT:-$((92 + DELTA))00} |
| 497 | fi |
| 498 | |
| 499 | if [ -z "$KIBANA_PORT" ]; then |
| 500 | KIBANA_PORT=${KIBANA_PORT:-$((56 + DELTA))01} |
Matteo Scandolo | 65c3519 | 2020-05-13 10:41:21 -0700 | [diff] [blame] | 501 | fi |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 502 | fi |
| 503 | |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 504 | PORTTMP="$(mktemp -u)" |
| 505 | grep -v "$NAME" .voltha/ports > "$PORTTMP" |
divyadesai | 59f987a | 2020-05-27 12:11:33 +0000 | [diff] [blame] | 506 | echo "$NAME=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT,$VOLTHA_KAFKA_PORT,$VOLTHA_PPROF_PORT,$OPENOLT_PPROF_PORT,$OFAGENT_PPROF_PORT,$ELASTICSEARCH_PORT,$KIBANA_PORT" >> "$PORTTMP" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 507 | cp "$PORTTMP" .voltha/ports |
| 508 | rm -f "$PORTTMP" |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 509 | |
David Bainbridge | 27790d6 | 2019-08-13 22:43:19 +0000 | [diff] [blame] | 510 | export ONOS_API_PORT ONOS_SSH_PORT |
David Bainbridge | 0129495 | 2019-07-30 19:33:45 +0000 | [diff] [blame] | 511 | |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 512 | IDX=1 |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 513 | CLOCK="TIME:" |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 514 | SPIN_PARTS= |
| 515 | NOT_VERIFIED= |
David Bainbridge | f858a02 | 2019-08-14 21:25:11 +0000 | [diff] [blame] | 516 | THEX= |
| 517 | BUILD= |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 518 | VERIFIED= |
| 519 | HELM= |
| 520 | OLD_KEY= |
| 521 | BIRD= |
| 522 | HIGH_VOLTAGE= |
| 523 | PLUG= |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 524 | FORWARD= |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 525 | GO= |
| 526 | DOWNLOAD= |
| 527 | GEAR= |
| 528 | NO_ENTRY= |
| 529 | LOCK= |
| 530 | |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 531 | if [ "$FANCY" -eq 1 ]; then |
| 532 | SPIN_PARTS="\xe2\xa2\x8e\xe2\xa1\xb0 \xe2\xa2\x8e\xe2\xa1\xa1 \xe2\xa2\x8e\xe2\xa1\x91 \xe2\xa2\x8e\xe2\xa0\xb1 \xe2\xa0\x8e\xe2\xa1\xb1 \xe2\xa2\x8a\xe2\xa1\xb1 \xe2\xa2\x8c\xe2\xa1\xb1 \xe2\xa2\x86\xe2\xa1\xb1" |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 533 | CLOCK="\xe2\x8f\xb1" |
David Bainbridge | f858a02 | 2019-08-14 21:25:11 +0000 | [diff] [blame] | 534 | THEX="${RED}${BOLD}\xe2\x9c\x97\x20${NORMAL}" |
David Bainbridge | f858a02 | 2019-08-14 21:25:11 +0000 | [diff] [blame] | 535 | BUILD="${YELLOW}${BOLD}\xf0\x9f\x8f\x97${NORMAL}" |
| 536 | NOT_VERIFIED="$BUILD" |
| 537 | VERIFIED="${GREEN}${BOLD}\xe2\x9c\x93\x20${NORMAL}" |
| 538 | HELM="${BLUE}${BOLD}\xE2\x8E\x88${NORMAL}" |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 539 | OLD_KEY="\xF0\x9F\x97\x9D" |
| 540 | BIRD="\xF0\x9F\x90\xA6" |
| 541 | HIGH_VOLTAGE="\xE2\x9A\xA1" |
| 542 | PLUG="\xF0\x9F\xa7\xa9" |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 543 | FORWARD="\xE2\x87\xA8" |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 544 | GO="\xf0\x9f\x9a\x80" |
| 545 | DOWNLOAD="\xf0\x9f\x93\xa5" |
| 546 | GEAR="\xe2\x9a\x99" |
| 547 | NO_ENTRY="\xe2\x9b\x94" |
| 548 | LOCK="\xf0\x9f\x94\x92" |
| 549 | fi |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 550 | |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 551 | duration() { |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 552 | local h m s t |
| 553 | h="$(($1 / 3600))" |
| 554 | m="$(($1 % 3600 / 60))" |
| 555 | s="$(($1 % 60))" |
| 556 | t="" |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 557 | |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 558 | if [ "$h" -gt 0 ]; then |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 559 | t="$t${h}h" |
| 560 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 561 | if [ "$m" -gt 0 ]; then |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 562 | t="$t${m}m" |
| 563 | fi |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 564 | echo "$t${s}s" |
| 565 | } |
| 566 | |
| 567 | printtime() { |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 568 | local INDENT |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 569 | if [ "$1" == "-" ]; then |
| 570 | INDENT=" " |
| 571 | shift |
| 572 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 573 | echo -e "$INDENT $CLOCK $(duration "$1")" |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 574 | } |
| 575 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 576 | bspin() { |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 577 | IDX=1 |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 578 | local INDENT |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 579 | if [ "$1" == "-" ]; then |
| 580 | INDENT=" " |
| 581 | shift |
| 582 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 583 | if [ "$FANCY" -eq 0 ]; then |
| 584 | LINE="${*//[[:space:]+-]}" |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 585 | if [ "$LINE X" == " X" ]; then |
| 586 | return |
| 587 | fi |
| 588 | echo -e "$CIVIS$INDENT$*" |
| 589 | else |
| 590 | echo -en "$CIVIS$INDENT $*" |
| 591 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 592 | } |
| 593 | |
| 594 | sspin() { |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 595 | local INDENT |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 596 | if [ "$1" == "-" ]; then |
| 597 | INDENT=" " |
| 598 | shift |
| 599 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 600 | if [ "$FANCY" -eq 0 ]; then |
| 601 | LINE="${*//[[:space:]+-]}" |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 602 | if [ "$LINE X" == " X" ]; then |
| 603 | return |
| 604 | fi |
| 605 | echo -e "$INDENT$*" |
| 606 | else |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 607 | C="$(echo "$SPIN_PARTS" | cut '-d ' -f "$IDX")" |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 608 | echo -en "\r$INDENT$C $*" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 609 | IDX="$((IDX + 1))" |
| 610 | if [ "$IDX" -gt 8 ]; then |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 611 | IDX=1 |
| 612 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 613 | fi |
| 614 | } |
| 615 | |
| 616 | espin() { |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 617 | local INDENT |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 618 | if [ "$1" == "-" ]; then |
| 619 | INDENT=" " |
| 620 | shift |
| 621 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 622 | if [ "$FANCY" -eq 0 ]; then |
| 623 | LINE="${*//[[:space:]+-]}" |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 624 | if [ "$LINE X" == " X" ]; then |
| 625 | return |
| 626 | fi |
| 627 | echo -e "$INDENT$*" |
| 628 | else |
| 629 | echo -e "\r$INDENT$*$CNORM" |
| 630 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 631 | } |
| 632 | |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 633 | if [ "$1" == "get" ] && [ "$2" == "voltconfig" ]; then |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 634 | echo "$HOME/.volt/config-$NAME" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 635 | exit |
| 636 | fi |
| 637 | |
David Bainbridge | e4d11ca | 2020-05-08 10:21:10 -0700 | [diff] [blame] | 638 | if [ $# -ne 1 ] || ! is_in "$1" "up,down,dump,clean"; then |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 639 | >&2 echo "What wouild you like to do today:" |
| 640 | >&2 echo " up - bring up voltha" |
| 641 | >&2 echo " down - tear down voltha" |
| 642 | >&2 echo " dump - create a debug dump of running system" |
| 643 | exit 1 |
| 644 | fi |
| 645 | |
divyadesai | 59f987a | 2020-05-27 12:11:33 +0000 | [diff] [blame] | 646 | do_curl() { |
| 647 | local DATA_ARGS CREDS CMD_ECHO CMD_OUTPUT SC_OUTPUT WAIT_START INDENTA EXTRAA NOW |
| 648 | local INDENT=$1 |
| 649 | local OP=$2 |
| 650 | local USER=$3 |
| 651 | local PASS=$4 |
| 652 | local URL=$5 |
| 653 | local DATA_TYPE=$6 |
| 654 | local DATA=$7 |
| 655 | local MSG=$8 |
| 656 | local VALID_RESULTS=$9 |
| 657 | local EXTRA=${10} |
| 658 | local ICON=${11} |
| 659 | |
| 660 | # Turn into an array for passing |
| 661 | INDENTA=() |
| 662 | if [ -n "$INDENT" ]; then |
| 663 | INDENTA=("$INDENT") |
| 664 | fi |
| 665 | IFS=' ' read -r -a EXTRAA <<< "$EXTRA" |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 666 | |
David K. Bainbridge | b4b163b | 2020-02-19 15:55:06 -0800 | [diff] [blame] | 667 | # Thanks to the latest version of ONOS using the return code 207 this gets a |
| 668 | # whole lot nastier. Can't thank them enough for doing this. So in order to |
| 669 | # capture the command and the output in the log file as well as capture the |
| 670 | # status code to verify it is 200 and not 207 mutltiple files and a bit of |
| 671 | # hackery must be used. Thanks again ONOS. |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 672 | CMD_ECHO="$(mktemp -u)" |
| 673 | CMD_OUTPUT="$(mktemp -u)" |
| 674 | SC_OUTPUT="$(mktemp -u)" |
| 675 | WAIT_START="$(date +%s)" |
David K. Bainbridge | b4b163b | 2020-02-19 15:55:06 -0800 | [diff] [blame] | 676 | |
divyadesai | 59f987a | 2020-05-27 12:11:33 +0000 | [diff] [blame] | 677 | CREDS=() |
| 678 | if [ -n "$USER" ]; then |
| 679 | CREDS=("--user" "$USER:$PASS") |
| 680 | fi |
| 681 | |
| 682 | DATA_ARGS=() |
| 683 | if [ -n "$DATA" ]; then |
| 684 | if [ "$DATA_TYPE" == "file" ]; then |
| 685 | DATA_ARGS=("--data" "@$DATA") |
| 686 | elif [ "$DATA_TYPE" == "json" ]; then |
| 687 | DATA_ARGS=("--data" "$DATA") |
| 688 | fi |
| 689 | fi |
| 690 | |
| 691 | bspin "${INDENTA[@]}" "$MSG" "$ICON" |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 692 | while true; do |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 693 | NOW="$(date +%s)" |
| 694 | if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then |
divyadesai | 59f987a | 2020-05-27 12:11:33 +0000 | [diff] [blame] | 695 | espin "${INDENTA[@]}" "$THEX" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 696 | rm -f "$CMD_ECHO" "$CMD_OUTPUT" "$SC_OUTPUT" |
divyadesai | 59f987a | 2020-05-27 12:11:33 +0000 | [diff] [blame] | 697 | doTimeout "$MSG" |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 698 | fi |
divyadesai | 59f987a | 2020-05-27 12:11:33 +0000 | [diff] [blame] | 699 | (set -x; curl -sSL "${CREDS[@]}" -w "%{http_code}" -o "$CMD_OUTPUT" -X "$OP" "${EXTRAA[@]}" "$URL" "${DATA_ARGS[@]}" >"$SC_OUTPUT" 2>/dev/null) >>"$CMD_ECHO" 2>&1 |
| 700 | RESULT=$? |
David K. Bainbridge | b4b163b | 2020-02-19 15:55:06 -0800 | [diff] [blame] | 701 | # Dump everything to the log |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 702 | cat "$CMD_ECHO" >> "$LOG" |
| 703 | test -r "$CMD_OUTPUT" && cat "$CMD_OUTPUT" >> "$LOG" |
| 704 | SC="$(cat "$SC_OUTPUT")" |
| 705 | echo "RESPONSE CODE: $SC" >> "$LOG" |
| 706 | echo "ERROR CODE: $RESULT" >> "$LOG" |
David K. Bainbridge | b4b163b | 2020-02-19 15:55:06 -0800 | [diff] [blame] | 707 | |
| 708 | # clean up temp files |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 709 | rm -f "$CMD_ECHO" "$CMD_OUTPUT" "$SC_OUTPUT" |
divyadesai | 59f987a | 2020-05-27 12:11:33 +0000 | [diff] [blame] | 710 | if [ "$RESULT" -eq 0 ] && is_in "$SC" "$VALID_RESULTS"; then |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 711 | break |
| 712 | fi |
Matteo Scandolo | 9a77a73 | 2020-01-09 14:24:12 -0800 | [diff] [blame] | 713 | sleep 1 |
divyadesai | 59f987a | 2020-05-27 12:11:33 +0000 | [diff] [blame] | 714 | sspin "${INDENTA[@]}" |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 715 | done |
divyadesai | 59f987a | 2020-05-27 12:11:33 +0000 | [diff] [blame] | 716 | espin "${INDENTA[@]}" "$VERIFIED" |
| 717 | } |
| 718 | |
| 719 | push_onos_config() { |
| 720 | local DATA_TYPE=$1 |
| 721 | local MSG=$2 |
| 722 | local RESOURCE=$3 |
| 723 | local DATA=$4 |
| 724 | |
| 725 | do_curl "-" "POST" "karaf" "karaf" "http://$_ONOS_API_EP/onos/v1/$RESOURCE" "$DATA_TYPE" "$DATA" "$MSG" "200" "--fail -H Content-Type:application/json" "$GEAR" |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 726 | } |
| 727 | |
Matteo Scandolo | 9a77a73 | 2020-01-09 14:24:12 -0800 | [diff] [blame] | 728 | check_onos_app_active() { |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 729 | local APP_ID WAIT_START RESULT NOW |
| 730 | APP_ID=$1 |
| 731 | WAIT_START="$(date +%s)" |
Matteo Scandolo | 9a77a73 | 2020-01-09 14:24:12 -0800 | [diff] [blame] | 732 | |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 733 | bspin - "Checking that $APP_ID is active $CLOCK" |
| 734 | while true; do |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 735 | NOW="$(date +%s)" |
| 736 | if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 737 | espin - "$THEX" |
| 738 | doTimeout "waiting for ONOS application activation '$APP_ID'" |
| 739 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 740 | if (set -x; curl --fail -sSL --user karaf:karaf -X GET "http://$_ONOS_API_EP/onos/v1/applications/$APP_ID" | grep ACTIVE >>"$LOG" 2>&1) >>"$LOG" 2>&1; then |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 741 | break |
| 742 | fi |
| 743 | sleep 1 |
| 744 | sspin - |
| 745 | done |
| 746 | sleep 5 # OSGI components take a little longer that the app to activate |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 747 | espin - "$VERIFIED" |
Matteo Scandolo | 9a77a73 | 2020-01-09 14:24:12 -0800 | [diff] [blame] | 748 | } |
| 749 | |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 750 | override_onos_app() { |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 751 | local APP NAME WAIT_START NOW |
| 752 | APP=$1 |
| 753 | NAME="$(basename "$APP" | sed -e 's/^[0-9][0-9]*-//g' -e 's/-.*$//g')" |
| 754 | WAIT_START="$(date +%s)" |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 755 | |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 756 | while true; do |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 757 | NOW="$(date +%s)" |
| 758 | if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 759 | espin - "$THEX" |
| 760 | doTimeout "waiting to overwrite ONOS application '$APP'" |
| 761 | fi |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 762 | sspin - |
| 763 | # Attempt to delete old version (if it exists) |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 764 | (set -x; curl --fail -sSL --user karaf:karaf -X DELETE "http://$_ONOS_API_EP/onos/v1/applications/$NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1 |
| 765 | RESULT=$? |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 766 | sspin - |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 767 | if [ $RESULT -ne 0 ]; then |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 768 | continue |
| 769 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 770 | if (set -x; curl --fail -sSL --user karaf:karaf -X POST -H Content-Type:application/octet-stream "http://$_ONOS_API_EP/onos/v1/applications?activate=true" --data-binary "@$APP" >>"$LOG" 2>&1) >>"$LOG" 2>&1; then |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 771 | break |
| 772 | fi |
| 773 | sleep .2 |
| 774 | done |
| 775 | } |
| 776 | |
| 777 | activate_onos_app() { |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 778 | local MSG APP WAIT_START NOW |
| 779 | MSG="$1" |
| 780 | APP=$2 |
| 781 | WAIT_START="$(date +%s)" |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 782 | |
| 783 | bspin - "$MSG $GO" |
| 784 | while true; do |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 785 | NOW="$(date +%s)" |
| 786 | if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 787 | espin - "$THEX" |
| 788 | doTimeout "waiting to activate ONOS application '$APP'" |
| 789 | fi |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 790 | sspin - |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 791 | if (set -x; curl --fail -sSL --user karaf:karaf -X POST "http://$_ONOS_API_EP/onos/v1/applications/$APP/active" >>"$LOG" 2>&1) >>"$LOG" 2>&1; then |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 792 | break |
| 793 | fi |
| 794 | sleep .2 |
| 795 | done |
| 796 | espin - "$VERIFIED" |
| 797 | } |
| 798 | |
| 799 | count_pods() { |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 800 | local NAMESPACE STATES LABELS CMD PODS |
| 801 | NAMESPACE=$1; shift |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 802 | if [ "$NAMESPACE" == "all-namespaces" ]; then |
| 803 | NAMESPACE="--all-namespaces" |
| 804 | else |
| 805 | NAMESPACE="-n $NAMESPACE" |
| 806 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 807 | STATES=$1; shift |
| 808 | LABELS=$1; shift |
| 809 | CMD=("kubectl get $NAMESPACE $LABELS pod") |
| 810 | PODS=$(${CMD[*]} -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}") |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 811 | local COUNT=0 |
| 812 | local PATTERNS="$*" |
| 813 | for POD in $PODS; do |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 814 | local NAME STATE CONTAINERS TOTAL FOUND |
| 815 | NAME="$(echo "$POD" | cut -d/ -f 1)" |
| 816 | STATE="$(echo "$POD" | cut -d/ -f 2)" |
| 817 | CONTAINERS="$(echo "$POD" | cut -d/ -f 3 | sed -e 's/_/ /g')" |
| 818 | if [ "$STATES" == "*" ] || [ "$(echo "$STATES" | grep -c ":$STATE:")" -ne 0 ]; then |
| 819 | TOTAL="$(echo "$CONTAINERS" | wc -w)" |
| 820 | FOUND="$(echo "$CONTAINERS" | grep -o true | wc -l)" |
| 821 | if [ "$TOTAL" -eq "$FOUND" ]; then |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 822 | for PATTERN in $PATTERNS; do |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 823 | if [[ "$NAME" =~ $PATTERN ]]; then |
| 824 | COUNT="$((COUNT + 1))" |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 825 | break |
| 826 | fi |
| 827 | done |
| 828 | fi |
| 829 | fi |
| 830 | done |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 831 | echo $COUNT |
| 832 | } |
| 833 | |
| 834 | wait_for_pods() { |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 835 | local INDENT NAMESPACE EXPECT TYPE MESSAGE LABELS PATTERNS STATES HAVE ALL WAIT_START NOW |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 836 | if [ "$1" == "-" ]; then |
| 837 | INDENT=$1; shift |
| 838 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 839 | NAMESPACE=$1; shift |
| 840 | EXPECT=$1; shift |
| 841 | TYPE=$1; shift |
| 842 | MESSAGE=$1; shift |
| 843 | LABELS=$1; shift |
| 844 | PATTERNS=("$*") |
| 845 | STATES=":Running:" |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 846 | if [ "$TYPE" == "not" ]; then |
| 847 | STATES="*" |
| 848 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 849 | HAVE="$(count_pods "$NAMESPACE" "$STATES" "$LABELS" "${PATTERNS[@]}")" |
| 850 | ALL=$HAVE |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 851 | if [ "$TYPE" == "only" ]; then |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 852 | ALL="$(count_pods "all-namespaces" "*" ".*")" |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 853 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 854 | COUNT="$((300 / 15))" |
| 855 | WAIT_START="$(date +%s)" |
| 856 | bspin "$INDENT" "$MESSAGE" |
| 857 | sspin "$INDENT" |
| 858 | if [ "$HAVE" -ne "$EXPECT" ] || [ "$ALL" -ne "$HAVE" ]; then |
| 859 | while [ "$HAVE" -ne "$EXPECT" ] || [ "$ALL" -ne "$HAVE" ]; do |
| 860 | NOW="$(date +%s)" |
| 861 | if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then |
| 862 | espin "$INDENT" "$THEX" |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 863 | doTimeout "waiting for PODs to start" |
| 864 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 865 | sspin "$INDENT" |
| 866 | COUNT="$((COUNT - 1))" |
| 867 | if [ "$COUNT" -eq 0 ]; then |
| 868 | HAVE="$(count_pods "$NAMESPACE" "$STATES" "$LABELS" "${PATTERNS[@]}")" |
| 869 | ALL="$HAVE" |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 870 | if [ "$TYPE" == "only" ]; then |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 871 | ALL="$(count_pods "all-namespaces" "*" ".*")" |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 872 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 873 | COUNT="$((300 / 15))" |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 874 | fi |
| 875 | sleep .15 |
| 876 | done |
| 877 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 878 | espin "$INDENT" "$VERIFIED" |
| 879 | if [ "$HAVE" -ne "$EXPECT" ]; then |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 880 | return 1 |
| 881 | fi |
| 882 | return 0 |
| 883 | } |
| 884 | |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 885 | port_forward() { |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 886 | local NS=$1; shift |
| 887 | local SVC=$1; shift |
| 888 | local PORTS="$*" |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 889 | local TAG=$SVC-$NAME |
| 890 | |
David Bainbridge | 1d2c584 | 2020-06-03 15:29:07 -0700 | [diff] [blame] | 891 | (set -x; _TAG="$TAG" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n $NS service/$SVC $PORTS; done" >>"$PFLOG" 2>&1 &) >>"$PFLOG" 2>&1 |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 892 | } |
| 893 | |
| 894 | kill_port_forward() { |
David Bainbridge | 1d2c584 | 2020-06-03 15:29:07 -0700 | [diff] [blame] | 895 | local TAG P_IDS PARENTS KIDS UNKNOWN PP_ID PF |
| 896 | |
| 897 | while [ $# -gt 0 ]; do |
| 898 | PF=$1; shift |
| 899 | TAG= |
| 900 | if [ "$PF" != "__ALL__" ]; then |
| 901 | TAG="$PF-$NAME" |
| 902 | fi |
| 903 | PARENTS= |
| 904 | KIDS= |
| 905 | UNKNOWN= |
| 906 | # shellcheck disable=SC2009 |
| 907 | P_IDS="$(ps e -ww -A | grep "_TAG=$TAG" | grep -v grep | awk '{print $1}')" |
| 908 | if [ -n "$P_IDS" ]; then |
| 909 | for P_ID in $P_IDS; do |
| 910 | PP_ID="$(ps -o ppid "$P_ID" | tail -n +2)" |
| 911 | if [ -n "$PP_ID" ]; then |
| 912 | if [ "$PP_ID" -eq 1 ]; then |
| 913 | PARENTS="$PARENTS $P_ID" |
| 914 | else |
| 915 | KIDS="$KIDS $P_ID" |
| 916 | fi |
David Bainbridge | c6871d2 | 2019-11-13 17:10:31 +0000 | [diff] [blame] | 917 | else |
David Bainbridge | 1d2c584 | 2020-06-03 15:29:07 -0700 | [diff] [blame] | 918 | UNKNOWN="$UNKNOWN $P_ID" |
David Bainbridge | c6871d2 | 2019-11-13 17:10:31 +0000 | [diff] [blame] | 919 | fi |
David Bainbridge | 1d2c584 | 2020-06-03 15:29:07 -0700 | [diff] [blame] | 920 | done |
| 921 | if [ -n "$PARENTS" ]; then |
| 922 | # shellcheck disable=SC2086 |
| 923 | while ps -h $PARENTS >/dev/null 2>&1; do |
| 924 | (set -x; eval "kill -9 $PARENTS" >>"$LOG" 2>&1) >>"$LOG" 2>&1 |
| 925 | done |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 926 | fi |
David Bainbridge | 1d2c584 | 2020-06-03 15:29:07 -0700 | [diff] [blame] | 927 | if [ -n "$KIDS" ]; then |
| 928 | # shellcheck disable=SC2086 |
| 929 | while ps -h $KIDS >/dev/null 2>&1; do |
| 930 | (set -x; eval "kill -9 $KIDS" >>"$LOG" 2>&1) >>"$LOG" 2>&1 |
| 931 | done |
| 932 | fi |
| 933 | if [ -n "$UNKNOWN" ]; then |
| 934 | # shellcheck disable=SC2086 |
| 935 | while ps -h $UNKNOWN >/dev/null 2>&1; do |
| 936 | (set -x; eval "kill -9 $UNKNOWN" >>"$LOG" 2>&1) >>"$LOG" 2>&1 |
| 937 | done |
| 938 | fi |
| 939 | fi |
| 940 | done |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 941 | } |
| 942 | |
David Bainbridge | cf54636 | 2020-04-21 23:18:50 -0700 | [diff] [blame] | 943 | resolve_chart_version() { |
| 944 | [ "$2" != "latest" ] && echo "$2" && return |
| 945 | helm inspect chart "$1" | grep "^version:" | awk '{print $2}' |
| 946 | } |
| 947 | |
Jonathan Hart | 6a91e6c | 2020-04-16 14:28:33 -0700 | [diff] [blame] | 948 | # Compares two semver-formatted version strings (e.g. 2.4.3) |
| 949 | # Returns 0 if $1 == $2, returns 1 if $1 > $2 and returns 2 if $1 < $2 |
| 950 | compare_versions() { |
| 951 | [ "$1" == "$2" ] && return 0 |
Jonathan Hart | 6a91e6c | 2020-04-16 14:28:33 -0700 | [diff] [blame] | 952 | local lowest |
| 953 | lowest=$(echo -e "$1\n$2" | sort -V | head -1) |
| 954 | [ "$lowest" == "$1" ] && return 2 |
| 955 | return 1 |
| 956 | } |
| 957 | |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 958 | if [ "$1" == "down" ]; then |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 959 | echo "Tearing down voltha cluster $NAME" |
| 960 | LOG="down-$NAME.log" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 961 | date -u +"%Y%m%dT%H%M%SZ" >"$LOG" |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 962 | if is_in "$WITH_ONOS" "yes,legacy,classic"; then |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 963 | bspin "Remove port-forwards: onos-ui-$NAME" |
| 964 | kill_port_forward onos-ui |
| 965 | sspin "Remove port-forwards: onos-ssh-$NAME$CEOL" |
| 966 | kill_port_forward onos-ssh |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 967 | bspin "Remove port-forwards: onos-onos-classic-hs-$NAME$CEOL" |
| 968 | kill_port_forward onos-onos-classic-hs |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 969 | fi |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 970 | sspin "Remove port-forwards: voltha-api-$NAME$CEOL" |
David Bainbridge | 1d2c584 | 2020-06-03 15:29:07 -0700 | [diff] [blame] | 971 | kill_port_forward voltha-api voltha-voltha-api |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 972 | if is_in "$WITH_ETCD" "yes,external"; then |
| 973 | sspin "Remove port-forwards: etcd-$NAME$CEOL" |
| 974 | kill_port_forward "etcd" |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 975 | fi |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 976 | if is_in "$WITH_KAFKA" "yes,external"; then |
| 977 | sspin "Remove port-forwards: kafka-$NAME$CEOL" |
| 978 | kill_port_forward "kafka" |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 979 | fi |
Matteo Scandolo | efee043 | 2020-05-05 13:56:20 -0700 | [diff] [blame] | 980 | |
| 981 | if [ "$WITH_PPROF" == "yes" ]; then |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 982 | sspin "Remove port-forwards: *-profiler$CEOL" |
David Bainbridge | 1d2c584 | 2020-06-03 15:29:07 -0700 | [diff] [blame] | 983 | kill_port_forward voltha-rw-core-profiler voltha-voltha-rw-core-profiler |
| 984 | kill_port_forward voltha-of-agent-profiler voltha-voltha-of-agent-profiler |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 985 | if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then |
David Bainbridge | 1d2c584 | 2020-06-03 15:29:07 -0700 | [diff] [blame] | 986 | kill_port_forward adapter-open-olt-profiler open-olt-adapter-open-olt-profiler |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 987 | fi |
Matteo Scandolo | efee043 | 2020-05-05 13:56:20 -0700 | [diff] [blame] | 988 | fi |
| 989 | |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 990 | espin "$VERIFIED Remove port-forwards$CEOL" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 991 | if [ "$DEPLOY_K8S" == "yes" ]; then |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 992 | if [ -x ./bin/kind ]; then |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 993 | bspin "Delete Kubernetes Kind Cluster" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 994 | (set -x; ./bin/kind delete cluster --name "voltha-$NAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1 |
| 995 | espin "$VERIFIED" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 996 | else |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 997 | espin "$NO_ENTRY Delete Kubernetes Kind Cluster: kind command not found" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 998 | fi |
| 999 | else |
David Bainbridge | 309099c | 2020-05-05 08:47:29 -0700 | [diff] [blame] | 1000 | if [ "$CONFIG_SADIS" == "external" ]; then |
| 1001 | bspin "Remove configmap for BBSIM SADIS server" |
| 1002 | (set -x; kubectl -n "$BBSIM_NS" delete --ignore-not-found configmap kube-config >>"$LOG" 2>&1) >>"$LOG" 2>&1 |
| 1003 | espin "$VERIFIED" |
| 1004 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1005 | EXISTS="$(helm list -q)" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1006 | EXPECT="voltha" |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 1007 | if is_in "$WITH_ONOS" "yes,legacy,classic"; then |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 1008 | EXPECT+=" onos" |
| 1009 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1010 | if [ "$WITH_RADIUS" == "yes" ]; then |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 1011 | EXPECT+=" radius" |
| 1012 | fi |
David Bainbridge | 309099c | 2020-05-05 08:47:29 -0700 | [diff] [blame] | 1013 | if [ "$CONFIG_SADIS" == "external" ]; then |
| 1014 | EXPECT+=" bbsim-sadis-server" |
| 1015 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1016 | if [ "$WITH_BBSIM" == "yes" ]; then |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 1017 | EXPECT+=" bbsim" |
| 1018 | fi |
divyadesai | 59f987a | 2020-05-27 12:11:33 +0000 | [diff] [blame] | 1019 | if [ "$WITH_EFK" == "yes" ]; then |
| 1020 | EXPECT+=" elasticsearch kibana fluentd" |
| 1021 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1022 | if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 1023 | EXPECT+=" open-olt open-onu" |
| 1024 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1025 | if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 1026 | EXPECT+=" sim" |
| 1027 | fi |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 1028 | if is_in "$WITH_ETCD" "yes,external"; then |
| 1029 | EXPECT+=" etcd" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1030 | fi |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 1031 | if is_in "$WITH_KAFKA" "yes,external"; then |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1032 | EXPECT+=" kafka" |
| 1033 | fi |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1034 | bspin "Remove Helm Deployments" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 1035 | for i in $EXISTS; do |
David K. Bainbridge | 4342240 | 2020-03-06 07:41:22 -0800 | [diff] [blame] | 1036 | for j in $EXPECT; do |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1037 | if [[ "$i" =~ $j ]]; then |
David K. Bainbridge | 4342240 | 2020-03-06 07:41:22 -0800 | [diff] [blame] | 1038 | sspin "Remove Helm Deployments: $i$CEOL" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1039 | (set -x; ./bin/helm delete --no-hooks --purge "$i" >>"$LOG" 2>&1) >>"$LOG" 2>&1 |
David K. Bainbridge | 4342240 | 2020-03-06 07:41:22 -0800 | [diff] [blame] | 1040 | fi |
| 1041 | done |
uottremb | b16d398 | 2020-02-28 08:34:36 +0100 | [diff] [blame] | 1042 | done |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1043 | espin "$VERIFIED Remove Helm Deployments$CEOL" |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 1044 | if [ "$WAIT_ON_DOWN" == "yes" ]; then |
Matteo Scandolo | e93c9eb | 2020-06-03 12:08:51 -0700 | [diff] [blame] | 1045 | PODS="voltha-ofagent.* voltha-rw-core.*" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1046 | INFRA_PODS= |
| 1047 | ADAPT_PODS= |
| 1048 | SIM_PODS= |
divyadesai | 59f987a | 2020-05-27 12:11:33 +0000 | [diff] [blame] | 1049 | EFK_PODS= |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1050 | if [ "$WITH_RADIUS" == "yes" ]; then |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 1051 | PODS+=" radius.*" |
| 1052 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1053 | if [ "$WITH_BBSIM" == "yes" ]; then |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1054 | SIM_PODS+=" bbsim.*" |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 1055 | fi |
divyadesai | 59f987a | 2020-05-27 12:11:33 +0000 | [diff] [blame] | 1056 | if [ "$WITH_EFK" == "yes" ]; then |
| 1057 | EFK_PODS+=" kibana-* elasticsearch-* fluentd-*" |
| 1058 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1059 | if [ "$WITH_OPEN_ADAPTERS" ] || [ "$WITH_SIM_ADAPTERS" ]; then |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1060 | ADAPT_PODS+=" adapter-*" |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 1061 | fi |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 1062 | if is_in "$WITH_ONOS" "yes,legacy,classic"; then |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1063 | INFRA_PODS+=" onos-.*" |
| 1064 | fi |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 1065 | if is_in "$WITH_ETCD" "yes,external"; then |
| 1066 | INFRA_PODS+=" etcd.*" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1067 | fi |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 1068 | if is_in "$WITH_KAFKA" "yes,external"; then |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1069 | INFRA_PODS+=" kafka.*" |
| 1070 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1071 | if [ -n "$SIM_PODS" ]; then |
| 1072 | wait_for_pods "$BBSIM_NS" 0 "not" "Waiting for BBSIM PODs to terminate" "$BBSIM_LABEL" "$SIM_PODS" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1073 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1074 | if [ -n "$INFRA_PODS" ]; then |
| 1075 | wait_for_pods "$INFRA_NS" 0 "not" "Waiting for infrastructure PODs to terminate" "$NO_LABEL" "$INFRA_PODS" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1076 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1077 | if [ -n "$ADAPT_PODS" ]; then |
| 1078 | wait_for_pods "$ADAPTER_NS" 0 "not" "Waiting for adapter PODs to terminate" "$NO_LABEL" "$ADAPT_PODS" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1079 | fi |
divyadesai | 59f987a | 2020-05-27 12:11:33 +0000 | [diff] [blame] | 1080 | if [ -n "$EFK_PODS" ]; then |
| 1081 | wait_for_pods "$INFRA_NS" 0 "not" "Waiting for EFK PODs to terminate" "$NO_LABEL" "$EFK_PODS" |
| 1082 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1083 | wait_for_pods "$VOLTHA_NS" 0 "not" "Waiting for VOLTHA PODs to terminate" "$NO_LABEL" "$PODS" |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 1084 | fi |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 1085 | fi |
Matteo Scandolo | 7ef6ba5 | 2019-10-04 09:20:37 -0700 | [diff] [blame] | 1086 | exit |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 1087 | fi |
| 1088 | |
| 1089 | if [ "$1" == "dump" ]; then |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1090 | LOG="dump-$NAME.log" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1091 | TS="$(date -u +"%Y%m%dT%H%M%SZ")" |
| 1092 | if [ -n "$DUMP_FROM" ]; then |
| 1093 | TS=${DUMP_FROM//[:-]} |
David Bainbridge | 76514a0 | 2019-10-08 01:50:35 +0000 | [diff] [blame] | 1094 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1095 | WORK="$(mktemp -u -d)" |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1096 | DATA=$WORK/voltha-debug-dump-$NAME-$TS |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1097 | mkdir -p "$DATA" |
| 1098 | echo "$TS" > "$LOG" |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1099 | echo -e "Capturing debug dump to voltha-debug-dump-$NAME-$TS.tgz" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 1100 | bspin - "Copy install log" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1101 | if [ -f "install-$NAME.log" ]; then |
| 1102 | (set -x; cp "install-$NAME.log" "$DATA/install-$NAME.log") >>"$LOG" 2>&1 |
| 1103 | espin - "$VERIFIED" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 1104 | else |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1105 | espin - "$NO_ENTRY Copy install log: install-$NAME.log not found" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 1106 | fi |
| 1107 | bspin - "Dumping Kubernetes PODs" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1108 | (set -x; kubectl get --all-namespaces pods >> "$DATA/all-pods.txt" 2>&1) >>"$LOG" 2>&1 |
| 1109 | espin - "$VERIFIED" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 1110 | bspin - "Dumping Kubernetes SERVICEs" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1111 | (set -x; kubectl get --all-namespaces svc >> "$DATA/all-services.txt" 2>&1) >>"$LOG" 2>&1 |
| 1112 | espin - "$VERIFIED" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 1113 | bspin - "Dumping Kubernetes EVENTs" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1114 | (set -x; kubectl get --all-namespaces events >> "$DATA/all-events.txt" 2>&1) >>"$LOG" 2>&1 |
| 1115 | espin - "$VERIFIED" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 1116 | bspin - "Dumping VOLTHA POD details" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1117 | PODS="$(kubectl -n "$INFRA_NS" get pod -o name | grep onos | sed -e "s/^/$INFRA_NS:/g") $(kubectl get -n "$VOLTHA_NS" pod -o name | sed -e "s/^/$VOLTHA_NS:/g")" |
David Bainbridge | cfd7ca1 | 2019-10-06 03:31:41 +0000 | [diff] [blame] | 1118 | SINCE= |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1119 | if [ -n "$DUMP_FROM" ]; then |
David Bainbridge | cfd7ca1 | 2019-10-06 03:31:41 +0000 | [diff] [blame] | 1120 | SINCE="--since-time=$DUMP_FROM" |
| 1121 | fi |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 1122 | for POD in $PODS; do |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1123 | NS="$(echo "$POD" | cut -d: -f1)" |
| 1124 | POD="$(echo "$POD" | cut -d: -f2)" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 1125 | sspin - "Dumping VOLTHA POD details: $POD$CEOL" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1126 | mkdir -p "$DATA/$POD" |
| 1127 | (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] | 1128 | sspin - "Dumping VOLTHA POD details: $POD" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1129 | (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] | 1130 | sspin - "Dumping VOLTHA POD details: $POD" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1131 | (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] | 1132 | sspin - "Dumping VOLTHA POD details: $POD" |
| 1133 | done |
| 1134 | espin - "$VERIFIED Dumping VOLTHA POD details$CEOL" |
| 1135 | bspin - "Dumping ETCD" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1136 | if [ -n "$(command -v etcdctl)" ]; then |
| 1137 | (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 |
| 1138 | espin - "$VERIFIED" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 1139 | else |
| 1140 | espin - "$NO_ENTRY Dumping ETCD: etcdctl command not available" |
| 1141 | fi |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1142 | bspin - "Creating compressed TAR: voltha-debug-dump-$NAME-$TS.tgz" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1143 | (set -x; tar -C "$WORK" -zcf "voltha-debug-dump-$NAME-$TS.tgz" "./voltha-debug-dump-$NAME-$TS") >>"$LOG" 2>&1 |
| 1144 | espin - "$VERIFIED" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 1145 | bspin - "Cleanup" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1146 | (set -x; rm -rf "$WORK") >>"$LOG" 2>&1 |
| 1147 | espin - "$VERIFIED" |
| 1148 | bspin - "$(ls -l "voltha-debug-dump-$NAME-$TS.tgz")" |
| 1149 | espin - "$VERIFIED" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 1150 | exit |
| 1151 | fi |
| 1152 | |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1153 | LOG="install-$NAME.log" |
David Bainbridge | 1d2c584 | 2020-06-03 15:29:07 -0700 | [diff] [blame] | 1154 | PFLOG="port-forward-$NAME.log" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1155 | date > "$LOG" |
divyadesai | 59f987a | 2020-05-27 12:11:33 +0000 | [diff] [blame] | 1156 | echo "PORTS=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT,$ELASTICSEARCH_PORT,$KIBANA_PORT" >> "$LOG" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 1157 | |
| 1158 | # Output install options to log |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1159 | echo "OPTIONS" >> "$LOG" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 1160 | for O in $ALL_OPTIONS; do |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1161 | VAL="$(eval echo "\$$O")" |
| 1162 | if [ -n "$VAL" ]; then |
| 1163 | printf " %-30s = %s\n" "$O" "$VAL" >> "$LOG" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 1164 | fi |
| 1165 | done |
| 1166 | |
David Bainbridge | e4d11ca | 2020-05-08 10:21:10 -0700 | [diff] [blame] | 1167 | # Force remove any existing k8s port-forward processes. This will |
| 1168 | # remove them for all kind clusters. |
David Bainbridge | e4d11ca | 2020-05-08 10:21:10 -0700 | [diff] [blame] | 1169 | if [ "$1" == "clean" ]; then |
| 1170 | kill_port_forward __ALL__ |
| 1171 | exit |
| 1172 | fi |
| 1173 | |
David Bainbridge | fad5073 | 2020-05-01 17:00:12 -0700 | [diff] [blame] | 1174 | helm_values() { |
| 1175 | local NAMESPACE=$1; shift |
| 1176 | local INAME=$1; shift |
| 1177 | local CHART=$1; shift |
| 1178 | local CHART_VERSION=$1; shift |
| 1179 | |
| 1180 | if [ "$CHART_VERSION X" != " X" ] && [ "$CHART_VERSION" != "latest" ]; then |
| 1181 | CHART_VERSION="--version $CHART_VERSION" |
| 1182 | else |
| 1183 | CHART_VERSION= |
| 1184 | fi |
| 1185 | |
| 1186 | local CHART_ARGS= |
| 1187 | if [ -r "${INAME}-values.yaml" ]; then |
| 1188 | CHART_ARGS="-f ${INAME}-values.yaml" |
| 1189 | fi |
| 1190 | |
| 1191 | if [ "$HELM_USE_UPGRADE" == "yes" ]; then |
| 1192 | _HELM_COMMAND="upgrade --install" |
| 1193 | _HELM_ARGS="xxxdryrunxxx" |
| 1194 | else |
| 1195 | _HELM_COMMAND="install" |
| 1196 | _HELM_ARGS="--name xxxdryrunxxx" |
| 1197 | fi |
| 1198 | CMD=("helm $_HELM_COMMAND --debug --dry-run -f $NAME-values.yaml $CHART_ARGS $INTERNAL_EXTRA_HELM_INSTALL_ARGS $EXTRA_HELM_INSTALL_ARGS --set defaults.log_level=$VOLTHA_LOG_LEVEL --namespace $NAMESPACE $_HELM_ARGS $CHART_VERSION $EXTRA_HELM_FLAGS $CHART") |
| 1199 | ${CMD[*]} 2>/dev/null | awk 'PRINT==1 {print}; /^USER-SUPPLIED VALUES:/ {PRINT = 1}; /^$/ {PRINT = 0}' |
| 1200 | } |
| 1201 | |
Matteo Scandolo | 7ef6ba5 | 2019-10-04 09:20:37 -0700 | [diff] [blame] | 1202 | helm_install() { |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 1203 | local INDENT NOW VALUES_FILE PPROF_ARG |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1204 | if [ "$1" == "-" ]; then |
| 1205 | INDENT=$1; shift |
| 1206 | fi |
| 1207 | local NAMESPACE=$1; shift |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1208 | local INAME=$1; shift |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1209 | local CHART=$1; shift |
David Bainbridge | 90fd8e3 | 2019-08-21 23:32:47 +0000 | [diff] [blame] | 1210 | local CHART_VERSION=$1; shift |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 1211 | local FILTER=$1; shift |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1212 | local MESSAGE=$* |
| 1213 | |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1214 | if [ "$CHART_VERSION X" != " X" ] && [ "$CHART_VERSION" != "latest" ]; then |
David Bainbridge | 90fd8e3 | 2019-08-21 23:32:47 +0000 | [diff] [blame] | 1215 | CHART_VERSION="--version $CHART_VERSION" |
| 1216 | else |
| 1217 | CHART_VERSION= |
| 1218 | fi |
| 1219 | |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 1220 | local CHART_ARGS= |
| 1221 | if [ -r "${INAME}-values.yaml" ]; then |
| 1222 | CHART_ARGS="-f ${INAME}-values.yaml" |
| 1223 | fi |
| 1224 | |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1225 | local WAIT_START CMD |
| 1226 | WAIT_START="$(date +%s)" |
| 1227 | COUNT="$((300 / 15))" |
| 1228 | bspin "$INDENT" "$MESSAGE" |
| 1229 | if [ "$HELM_USE_UPGRADE" == "yes" ]; then |
David Bainbridge | 7f8bf99 | 2020-04-08 21:53:22 -0700 | [diff] [blame] | 1230 | _HELM_COMMAND="upgrade --install" |
| 1231 | _HELM_ARGS="$INAME" |
| 1232 | else |
| 1233 | _HELM_COMMAND="install" |
| 1234 | _HELM_ARGS="--name $INAME" |
| 1235 | fi |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 1236 | |
| 1237 | VALUES_FILE="$(mktemp)" |
| 1238 | if [ "$FILTER" == "-" ]; then |
| 1239 | cp "$NAME-values.yaml" "$VALUES_FILE" |
David Bainbridge | a965ca2 | 2020-06-09 17:45:04 -0700 | [diff] [blame] | 1240 | elif [ "${FILTER:0:1}" == "+" ]; then |
| 1241 | cp "$NAME-values.yaml" "$VALUES_FILE" |
| 1242 | yq r - "${FILTER:1}" <"$NAME-values.yaml" >>"$VALUES_FILE" |
David Bainbridge | 33e56c7 | 2020-06-11 11:39:56 -0700 | [diff] [blame] | 1243 | cat "$VALUES_FILE" >>"$LOG" |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 1244 | else |
David Bainbridge | 43f2df5 | 2020-06-02 15:30:54 -0700 | [diff] [blame] | 1245 | yq r - "$FILTER" <"$NAME-values.yaml" >"$VALUES_FILE" |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 1246 | fi |
| 1247 | if [ "$WITH_PPROF" == "yes" ]; then |
| 1248 | PPROF_ARG="--set profiler.enabled=true" |
| 1249 | fi |
| 1250 | CMD=("helm $_HELM_COMMAND -f $VALUES_FILE $CHART_ARGS $PPROF_ARG $INTERNAL_EXTRA_HELM_INSTALL_ARGS $EXTRA_HELM_INSTALL_ARGS --set defaults.log_level=$VOLTHA_LOG_LEVEL --namespace $NAMESPACE $_HELM_ARGS $CHART_VERSION $EXTRA_HELM_FLAGS $CHART") |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1251 | (set -x; ${CMD[*]} >>"$LOG" 2>&1) >>"$LOG" 2>&1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1252 | SUCCESS=$? |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1253 | while [ "$SUCCESS" -ne 0 ]; do |
| 1254 | NOW="$(date +%s)" |
| 1255 | if [ "$((NOW - WAIT_START))" -gt "$TIMEOUT_SECONDS" ]; then |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 1256 | espin "$THEX" |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 1257 | rm -f "$VALUES_FILE" |
David Bainbridge | 52e6e9d | 2020-03-23 13:48:27 -0700 | [diff] [blame] | 1258 | doTimeout "waiting for helm install $CHART" |
| 1259 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1260 | sspin "$INDENT" |
| 1261 | COUNT="$((COUNT - 1))" |
| 1262 | if [ "$COUNT" -eq 0 ]; then |
| 1263 | if [ "$HELM_USE_UPGRADE" == "no" ]; then |
| 1264 | (set -x; helm delete --purge "$INAME" >>"$LOG" 2>&1) >>"$LOG" 2>&1 |
David Bainbridge | 7f8bf99 | 2020-04-08 21:53:22 -0700 | [diff] [blame] | 1265 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1266 | (set -x; ${CMD[*]} >>"$LOG" 2>&1) >>"$LOG" 2>&1 |
Andy Bavier | e22ff25 | 2019-12-19 11:40:31 -0700 | [diff] [blame] | 1267 | SUCCESS=$? |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1268 | COUNT="$((300 / 15))" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1269 | fi |
| 1270 | sleep .15 |
| 1271 | done |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 1272 | rm -f "$VALUES_FILE" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1273 | espin "$INDENT" "$VERIFIED" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1274 | } |
| 1275 | |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1276 | echo "INSTALL TYPE: $TYPE" >> "$LOG" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1277 | |
| 1278 | bspin "Verify GOPATH" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1279 | GOPATH="$(pwd)"; export GOPATH |
| 1280 | mkdir -p "$GOPATH/bin" |
| 1281 | espin "$VERIFIED" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1282 | |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1283 | STIME="$(date +%s)" |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 1284 | if [ "$INSTALL_KUBECTL" == "no" ]; then |
| 1285 | bspin "Skip kubectl install" |
| 1286 | espin $NO_ENTRY |
Test User | c13bdc9 | 2019-07-03 20:57:49 +0000 | [diff] [blame] | 1287 | else |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 1288 | bspin "Verify kubectl $HELM" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1289 | if [ -x "$GOPATH/bin/kubectl" ]; then |
| 1290 | espin "$VERIFIED" |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 1291 | else |
David Bainbridge | e40e6ef | 2020-04-21 13:15:58 -0700 | [diff] [blame] | 1292 | ERR_OUT="$(mktemp)" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1293 | espin "$NOT_VERIFIED" |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 1294 | bspin - "Download and install Kubernetes/kubectl $DOWNLOAD" |
David Bainbridge | e40e6ef | 2020-04-21 13:15:58 -0700 | [diff] [blame] | 1295 | (set -x; curl --fail -o "$GOPATH/bin/kubectl" -sSL "https://storage.googleapis.com/kubernetes-release/release/$(curl --fail -sSL https://storage.googleapis.com/kubernetes-release/release/stable.txt 2>>"$ERR_OUT")/bin/$HOSTOS/$HOSTARCH/kubectl" >>"$LOG" 2>>"$ERR_OUT") >>"$LOG" 2>&1 |
| 1296 | RESULT=$? |
| 1297 | if [ "$RESULT" -ne 0 ]; then |
| 1298 | espin - "$THEX" |
David Bainbridge | e3fc0c3 | 2020-04-21 15:34:04 -0700 | [diff] [blame] | 1299 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download kubectl: $(tail "$ERR_OUT")${NORMAL}" |
David Bainbridge | e40e6ef | 2020-04-21 13:15:58 -0700 | [diff] [blame] | 1300 | cat "$ERR_OUT" >> "$LOG" |
Zack Williams | ded60cb | 2020-04-13 10:02:20 -0700 | [diff] [blame] | 1301 | rm -rf "$ERR_OUT" "$GOPATH/bin/kubectl" |
David Bainbridge | e40e6ef | 2020-04-21 13:15:58 -0700 | [diff] [blame] | 1302 | exit 1 |
| 1303 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1304 | (set -x; chmod 755 "$GOPATH/bin/kubectl" >>"$LOG" 2>&1) >>"$LOG" 2>&1 |
| 1305 | espin - "$VERIFIED" |
David Bainbridge | e40e6ef | 2020-04-21 13:15:58 -0700 | [diff] [blame] | 1306 | rm -rf "$ERR_OUT" |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 1307 | fi |
Test User | c13bdc9 | 2019-07-03 20:57:49 +0000 | [diff] [blame] | 1308 | fi |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1309 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1310 | NOW="$(date +%s)" |
| 1311 | printtime $((NOW - STIME)) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1312 | fi |
Test User | c13bdc9 | 2019-07-03 20:57:49 +0000 | [diff] [blame] | 1313 | |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1314 | STIME="$(date +%s)" |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 1315 | if [ "$DEPLOY_K8S" == "no" ]; then |
| 1316 | bspin "Skip Kubernetes/Kind Deployment" |
| 1317 | espin $NO_ENTRY |
| 1318 | else |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1319 | bspin "Verify Kubernetes/Kind $HELM" |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 1320 | IS_INSTALLED=0 |
| 1321 | OP_TYPE="install" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1322 | if [ -x "$GOPATH/bin/kind" ]; then |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 1323 | OP_TYPE="upgrade" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1324 | if [ "$("$GOPATH/bin/kind" --version | grep -c "$KIND_VERSION")" -eq 1 ]; then |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 1325 | IS_INSTALLED=1 |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1326 | espin "$VERIFIED" |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 1327 | fi |
| 1328 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1329 | if [ "$IS_INSTALLED" -eq 0 ]; then |
David Bainbridge | e40e6ef | 2020-04-21 13:15:58 -0700 | [diff] [blame] | 1330 | ERR_OUT="$(mktemp)" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1331 | espin "$NOT_VERIFIED" |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 1332 | bspin - "Download and $OP_TYPE Kubernetes/kind $DOWNLOAD" |
David Bainbridge | e40e6ef | 2020-04-21 13:15:58 -0700 | [diff] [blame] | 1333 | (set -x; curl -o "$GOPATH/bin/kind" --fail -sSL "https://github.com/kubernetes-sigs/kind/releases/download/$KIND_VERSION/kind-$HOSTOS-$HOSTARCH" >>"$LOG" 2>"$ERR_OUT") >>"$LOG" 2>&1 |
| 1334 | RESULT=$? |
| 1335 | if [ $RESULT -ne 0 ]; then |
| 1336 | espin - "$THEX" |
David Bainbridge | e3fc0c3 | 2020-04-21 15:34:04 -0700 | [diff] [blame] | 1337 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download kind: $(tail "$ERR_OUT")${NORMAL}" |
David Bainbridge | e40e6ef | 2020-04-21 13:15:58 -0700 | [diff] [blame] | 1338 | cat "$ERR_OUT" >> "$LOG" |
Zack Williams | ded60cb | 2020-04-13 10:02:20 -0700 | [diff] [blame] | 1339 | rm -rf "$ERR_OUT" "$GOPATH/bin/kind" |
David Bainbridge | e40e6ef | 2020-04-21 13:15:58 -0700 | [diff] [blame] | 1340 | exit 1 |
| 1341 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1342 | (set -x; chmod 755 "$GOPATH/bin/kind" >>"$LOG" 2>&1) >>"$LOG" 2>&1 |
David Bainbridge | e40e6ef | 2020-04-21 13:15:58 -0700 | [diff] [blame] | 1343 | rm -rf "$ERR_OUT" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1344 | espin - "$VERIFIED" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1345 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1346 | fi |
| 1347 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1348 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1349 | NOW="$(date +%s)" |
| 1350 | printtime $((NOW - STIME)) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1351 | fi |
| 1352 | |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1353 | STIME="$(date +%s)" |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 1354 | if [ "$INSTALL_HELM" == "no" ]; then |
| 1355 | bspin "Skip Helm Install" |
| 1356 | espin $NO_ENTRY |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1357 | else |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 1358 | bspin "Verify Helm $HELM" |
David Bainbridge | a34993d | 2020-04-01 09:15:42 -0700 | [diff] [blame] | 1359 | HELM_UPGRADE=0 |
| 1360 | HELM_UPGRADE_DESC="install" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1361 | if [ -x "$GOPATH/bin/helm" ]; then |
| 1362 | HAVE_VER="$("$GOPATH/bin/helm" version -c --template '{{.Client.SemVer}}')" |
| 1363 | HELM_UP_DOWN="$(echo -e "$HAVE_VER\n$HELM_VERSION" | sort -V | head -1)" |
| 1364 | if [ "$HAVE_VER" != "$HELM_VERSION" ]; then |
| 1365 | if [ "$HELM_UP_DOWN" == "$HELM_VERSION" ]; then |
David Bainbridge | a34993d | 2020-04-01 09:15:42 -0700 | [diff] [blame] | 1366 | HELM_UPGRADE_DESC="downgrade" |
| 1367 | else |
| 1368 | HELM_UPGRADE_DESC="upgrade" |
| 1369 | fi |
| 1370 | HELM_UPGRADE=1 |
| 1371 | else |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1372 | espin "$VERIFIED" |
David Bainbridge | a34993d | 2020-04-01 09:15:42 -0700 | [diff] [blame] | 1373 | fi |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 1374 | else |
David Bainbridge | a34993d | 2020-04-01 09:15:42 -0700 | [diff] [blame] | 1375 | HELM_UPGRADE=1 |
| 1376 | fi |
| 1377 | |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1378 | if [ "$HELM_UPGRADE" -ne 0 ]; then |
David Bainbridge | e40e6ef | 2020-04-21 13:15:58 -0700 | [diff] [blame] | 1379 | ERR_OUT="$(mktemp)" |
| 1380 | INSTALL_HELM_BIN=$(mktemp) |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1381 | espin "$NOT_VERIFIED" |
David Bainbridge | a34993d | 2020-04-01 09:15:42 -0700 | [diff] [blame] | 1382 | bspin - "Download and $HELM_UPGRADE_DESC Helm $DOWNLOAD" |
David Bainbridge | e40e6ef | 2020-04-21 13:15:58 -0700 | [diff] [blame] | 1383 | (set -x; curl -o "$INSTALL_HELM_BIN" --fail -sSL https://git.io/get_helm.sh >>"$LOG" 2>"$ERR_OUT") >>"$LOG" 2>&1 |
| 1384 | RESULT=$? |
| 1385 | if [ $RESULT -ne 0 ]; then |
| 1386 | espin - "$THEX" |
David Bainbridge | e3fc0c3 | 2020-04-21 15:34:04 -0700 | [diff] [blame] | 1387 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download helm installer: $(tail "$ERR_OUT")${NORMAL}" |
David Bainbridge | e40e6ef | 2020-04-21 13:15:58 -0700 | [diff] [blame] | 1388 | cat "$ERR_OUT" >> "$LOG" |
| 1389 | rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT" "$GOPATH/bin/helm" "$GOPATH/bin/tiller" |
| 1390 | exit 1 |
| 1391 | fi |
| 1392 | rm -rf "$ERR_OUT" |
| 1393 | chmod +x "$INSTALL_HELM_BIN" |
| 1394 | (set -x; PATH="$GOPATH/bin:$PATH" DESIRED_VERSION=$HELM_VERSION USE_SUDO=false HELM_INSTALL_DIR=$GOPATH/bin "$INSTALL_HELM_BIN" >>"$LOG" 2>&1) >>"$LOG" 2>&1 |
| 1395 | RESULT=$? |
| 1396 | if [ $RESULT -ne 0 ]; then |
| 1397 | espin - "$THEX" |
| 1398 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to install helm, see install log for details${NORMAL}" |
| 1399 | rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT" "$GOPATH/bin/helm" "$GOPATH/bin/tiller" |
| 1400 | exit 1 |
| 1401 | fi |
| 1402 | rm -rf "$INSTALL_HELM_BIN" "$ERR_OUT" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1403 | espin - "$VERIFIED" |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 1404 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1405 | fi |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1406 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1407 | NOW="$(date +%s)" |
| 1408 | printtime $((NOW - STIME)) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1409 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1410 | |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1411 | STIME="$(date +%s)" |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 1412 | bspin "Verify voltctl $HIGH_VOLTAGE" |
David Bainbridge | d281197 | 2019-12-14 01:14:09 +0000 | [diff] [blame] | 1413 | VOK=0 |
| 1414 | VMESSAGE="install" |
David Bainbridge | e40e6ef | 2020-04-21 13:15:58 -0700 | [diff] [blame] | 1415 | ERR_OUT=$(mktemp) |
David K. Bainbridge | ebf38d9 | 2020-02-10 10:46:31 -0800 | [diff] [blame] | 1416 | export VC_VERSION="$VOLTCTL_VERSION" |
| 1417 | if [ "$VC_VERSION" == "latest" ]; then |
David Bainbridge | e40e6ef | 2020-04-21 13:15:58 -0700 | [diff] [blame] | 1418 | set -o pipefail # TODO: would be nice to run all in pipefail mode |
| 1419 | VC_VERSION="$(curl --fail -sSL https://api.github.com/repos/opencord/voltctl/releases/latest 2>"$ERR_OUT" | jq -r .tag_name | sed -e 's/^v//g')" |
| 1420 | RESULT=$? |
| 1421 | set +o pipefail |
| 1422 | if [ "$RESULT" -ne 0 ]; then |
| 1423 | espin - "$THEX" |
| 1424 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to determine released version of voltctl: $(cat "$ERR_OUT")${NORMAL}" |
| 1425 | rm -rf "$ERR_OUT" "$GOPATH/bin/voltctl" |
| 1426 | exit 1 |
| 1427 | fi |
| 1428 | export VC_VERSION |
David K. Bainbridge | ebf38d9 | 2020-02-10 10:46:31 -0800 | [diff] [blame] | 1429 | fi |
David Bainbridge | e40e6ef | 2020-04-21 13:15:58 -0700 | [diff] [blame] | 1430 | |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1431 | if [ -x "$GOPATH/bin/voltctl" ]; then |
David Bainbridge | e40e6ef | 2020-04-21 13:15:58 -0700 | [diff] [blame] | 1432 | VHAVE="$("$GOPATH/bin/voltctl" version --clientonly -o json 2>/dev/null | jq -r .version)" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1433 | RESULT=$? |
| 1434 | if [ $RESULT -eq 0 ] && [ "$VHAVE" == "$VC_VERSION" ]; then |
David Bainbridge | d281197 | 2019-12-14 01:14:09 +0000 | [diff] [blame] | 1435 | VOK=1 |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1436 | espin "$VERIFIED" |
David Bainbridge | 1ba64f1 | 2019-12-18 00:40:13 +0000 | [diff] [blame] | 1437 | else |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1438 | VCHECK="$(echo -e "$VHAVE\n$VC_VERSION" | sort -V | head -1)" |
David K. Bainbridge | ebf38d9 | 2020-02-10 10:46:31 -0800 | [diff] [blame] | 1439 | if [ "$VCHECK" == "$VHAVE" ]; then |
| 1440 | VMESSAGE="upgrade" |
| 1441 | else |
| 1442 | VMESSAGE="downgrade" |
| 1443 | fi |
David Bainbridge | d281197 | 2019-12-14 01:14:09 +0000 | [diff] [blame] | 1444 | fi |
| 1445 | fi |
| 1446 | |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1447 | if [ "$VOK" -eq 0 ]; then |
| 1448 | espin "$NOT_VERIFIED" |
David Bainbridge | d281197 | 2019-12-14 01:14:09 +0000 | [diff] [blame] | 1449 | bspin - "Download and $VMESSAGE voltctl $DOWNLOAD" |
David Bainbridge | e40e6ef | 2020-04-21 13:15:58 -0700 | [diff] [blame] | 1450 | (set -x; curl --fail -o "$GOPATH/bin/voltctl" -sSL "https://github.com/opencord/voltctl/releases/download/v$VC_VERSION/voltctl-$VC_VERSION-$HOSTOS-$HOSTARCH" >>"$LOG" 2>"$ERR_OUT") >>"$LOG" 2>&1 |
| 1451 | RESULT=$? |
| 1452 | if [ $RESULT -ne 0 ]; then |
| 1453 | espin - "$THEX" |
| 1454 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR: unable to download voltctl (version $VC_VERSION): $(cat "$ERR_OUT")${NORMAL}" |
| 1455 | rm -rf "$ERR_OUT" "$GOPATH/bin/voltctl" |
| 1456 | exit 1 |
| 1457 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1458 | (set -x; chmod 755 "$GOPATH/bin/voltctl" >>"$LOG" 2>&1) >>"$LOG" 2>&1 |
| 1459 | espin - "$VERIFIED" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1460 | fi |
David Bainbridge | e40e6ef | 2020-04-21 13:15:58 -0700 | [diff] [blame] | 1461 | rm -rf "$ERR_OUT" |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1462 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1463 | NOW="$(date +%s)" |
| 1464 | printtime $((NOW - STIME)) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1465 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1466 | |
| 1467 | bspin "Verify command PATH" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1468 | export PATH=$GOPATH/bin:$PATH |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1469 | espin "$VERIFIED" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1470 | |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1471 | STIME="$(date +%s)" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1472 | if [ "$DEPLOY_K8S" == "yes" ]; then |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1473 | HAVE="$(kind get clusters | grep -c "voltha-$NAME")" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1474 | bspin "Verify Kubernetes/Kind Cluster" |
| 1475 | sspin |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1476 | if [ "$HAVE" -eq 0 ]; then |
| 1477 | espin "$NOT_VERIFIED" |
David Bainbridge | 491b1bd | 2019-07-11 17:53:11 +0000 | [diff] [blame] | 1478 | bspin - "Verify cluster configuration" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1479 | if [ ! -r "./$NAME-cluster.cfg" ]; then |
| 1480 | espin - "$NOT_VERIFIED" |
David K. Bainbridge | 4342240 | 2020-03-06 07:41:22 -0800 | [diff] [blame] | 1481 | bspin - "Download cluster configuration: $TYPE-cluster.cfg to $NAME-cluster.cfg $DOWNLOAD" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1482 | ERR_OUT="$(mktemp)" |
serkant.uluderya | 4d31513 | 2020-04-15 16:25:54 -0700 | [diff] [blame] | 1483 | if ! (set -x; curl --fail -o "./$NAME-cluster.cfg" -sSL "https://raw.githubusercontent.com/opencord/kind-voltha/$VK_RELEASE/$TYPE-cluster.cfg" >>"$LOG" 2>>"$ERR_OUT") >>"$LOG" 2>&1; then |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1484 | espin - "$THEX" |
| 1485 | echo -e "${RED}${BOLD}${ERROR}ERROR: $NAME-cluster.cfg${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}" |
| 1486 | echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG" |
| 1487 | rm -rf "$ERR_OUT" "./$NAME-cluster.cfg" |
David K. Bainbridge | a00736b | 2020-01-08 14:33:17 -0800 | [diff] [blame] | 1488 | exit 1 |
| 1489 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1490 | rm -rf "$ERR_OUT" |
David K. Bainbridge | a00736b | 2020-01-08 14:33:17 -0800 | [diff] [blame] | 1491 | else |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1492 | espin - "$VERIFIED" |
David K. Bainbridge | a00736b | 2020-01-08 14:33:17 -0800 | [diff] [blame] | 1493 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1494 | kind create cluster --name "voltha-$NAME" --config "$NAME-cluster.cfg" |
David Bainbridge | 491b1bd | 2019-07-11 17:53:11 +0000 | [diff] [blame] | 1495 | else |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1496 | espin "$VERIFIED" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1497 | fi |
| 1498 | |
David Bainbridge | 1d2c584 | 2020-06-03 15:29:07 -0700 | [diff] [blame] | 1499 | export KUBECONFIG="./kube-config-$NAME" |
| 1500 | kind get kubeconfig --name="voltha-$NAME" >"$KUBECONFIG" |
| 1501 | # For backward compatibility also copy to old location |
David Bainbridge | dee3f02 | 2020-06-05 07:45:13 -0700 | [diff] [blame] | 1502 | mkdir -p "$HOME/.kube" |
David Bainbridge | 7b3c163 | 2020-06-05 10:04:14 -0700 | [diff] [blame] | 1503 | cp "$KUBECONFIG" "$HOME/.kube/kind-config-voltha-$NAME" |
David Bainbridge | 1d2c584 | 2020-06-03 15:29:07 -0700 | [diff] [blame] | 1504 | |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1505 | P="coredns-.* \ |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1506 | etcd-voltha-$NAME-control-plane \ |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1507 | kindnet-.* \ |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1508 | kube-apiserver-voltha-$NAME-control-plane \ |
| 1509 | kube-controller-manager-voltha-$NAME-control-plane \ |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1510 | kube-proxy-.* \ |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1511 | kube-scheduler-voltha-$NAME-control-plane" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1512 | |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1513 | EXPECT="$(test "$TYPE" == "minimal" && echo "12" || echo "14")" |
| 1514 | wait_for_pods - "kube-system" "$EXPECT" "includes" "Waiting for system PODs to start" "$NO_LABEL" "$P" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1515 | fi |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1516 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1517 | NOW="$(date +%s)" |
| 1518 | printtime $((NOW - STIME)) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1519 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1520 | |
David Bainbridge | e4d11ca | 2020-05-08 10:21:10 -0700 | [diff] [blame] | 1521 | if [ "$SCHEDULE_ON_CONTROL_NODES" == "yes" ]; then |
| 1522 | bspin "Untaint control nodes to allow scheduling $LOCK" |
| 1523 | for MNODE in $(kubectl get node --selector='node-role.kubernetes.io/master' -o json | jq -r '.items[].metadata.name'); do |
| 1524 | (set -x; kubectl taint node "$MNODE" node-role.kubernetes.io/master:NoSchedule- >>"$LOG" 2>&1) >>"$LOG" 2>&1 |
| 1525 | sspin |
| 1526 | done |
| 1527 | espin "$VERIFIED" |
| 1528 | fi |
| 1529 | |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1530 | STIME="$(date +%s)" |
| 1531 | COUNT="$(count_pods "kube-system" ":Running:" "$NO_LABEL" "tiller-deploy-.*")" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1532 | bspin "Verify Helm" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1533 | if [ "$COUNT" -ne 1 ]; then |
| 1534 | espin "$NOT_VERIFIED" |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 1535 | echo -e "Configuring Helm $GEAR" |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 1536 | if [ "$INSTALL_HELM" == "no" ]; then |
| 1537 | bspin - "Skip Helm/Tiller Initialization" |
| 1538 | espin - $NO_ENTRY |
| 1539 | else |
| 1540 | bspin - "Initialize Helm" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1541 | (set -x; helm init --upgrade >>"$LOG" 2>&1) >>"$LOG" 2>&1 |
| 1542 | espin - "$VERIFIED" |
| 1543 | wait_for_pods - "kube-system" 1 "includes" "Waiting for Tiller POD to start" "$NO_LABEL" "tiller-deploy-.*" |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 1544 | fi |
Matteo Scandolo | 7ef6ba5 | 2019-10-04 09:20:37 -0700 | [diff] [blame] | 1545 | |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1546 | # HACK (sort-of) - the config for tiller is about to be patched, which will |
| 1547 | # cause the tiller pod to be recreated. This can sometimes cause a timing |
| 1548 | # 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] | 1549 | # 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] | 1550 | # 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] | 1551 | # 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] | 1552 | # things |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1553 | (set -x; kubectl -n kube-system scale deploy tiller-deploy --replicas=0 >>"$LOG" 2>&1) >>"$LOG" 2>&1 |
David Bainbridge | ddeab48 | 2020-06-24 12:43:40 -0700 | [diff] [blame] | 1554 | wait_for_pods - "kube-system" 0 "not" "Waiting for Tiller POD to shutdown" "$NO_LABEL" "tiller-deploy-.*" |
Matteo Scandolo | 7ef6ba5 | 2019-10-04 09:20:37 -0700 | [diff] [blame] | 1555 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1556 | # Create and k8s service account so that Helm can create pods |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 1557 | bspin - "Create Tiller ServiceAccount" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1558 | (set -x; kubectl create serviceaccount --namespace kube-system tiller >>"$LOG" 2>&1) >>"$LOG" 2>&1 |
| 1559 | espin - "$VERIFIED" |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 1560 | bspin - "Create Tiller ClusterRoleBinding" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1561 | (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>"$LOG" 2>&1) >>"$LOG" 2>&1 |
| 1562 | espin - "$VERIFIED" |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 1563 | bspin - "Update Tiller Manifest" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1564 | (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] | 1565 | |
| 1566 | # HACK (sort-of) - part to, spin it back up |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1567 | (set -x; kubectl -n kube-system scale deploy tiller-deploy --replicas=1 >>"$LOG" 2>&1) >>"$LOG" 2>&1 |
| 1568 | espin - "$VERIFIED" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1569 | else |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1570 | if [ "$(helm version -s --template '{{.Server.SemVer}}')" != "$HELM_VERSION" ]; then |
| 1571 | espin "$NOT_VERIFIED" |
David Bainbridge | a34993d | 2020-04-01 09:15:42 -0700 | [diff] [blame] | 1572 | bspin - "Sync Tiller server version with helm client" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1573 | (set -x; helm init --upgrade --force-upgrade --wait >>"$LOG" 2>&1) >>"$LOG" 2>&1 |
| 1574 | espin - "$VERIFIED" |
David Bainbridge | a34993d | 2020-04-01 09:15:42 -0700 | [diff] [blame] | 1575 | else |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1576 | espin "$VERIFIED" |
David Bainbridge | a34993d | 2020-04-01 09:15:42 -0700 | [diff] [blame] | 1577 | fi |
| 1578 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1579 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1580 | wait_for_pods - "kube-system" 1 "includes" "Waiting for Tiller POD to start" "$NO_LABEL" "tiller-deploy-.*" |
David Bainbridge | ddeab48 | 2020-06-24 12:43:40 -0700 | [diff] [blame] | 1581 | |
| 1582 | REPOS="onf|https://charts.opencord.org|ONF_VOLTHA \ |
| 1583 | stable|https://kubernetes-charts.storage.googleapis.com|Google_Stable \ |
| 1584 | incubator|https://kubernetes-charts-incubator.storage.googleapis.com|Google_Incubator" |
| 1585 | |
| 1586 | if is_in "$WITH_ONOS" "yes,legacy,classic"; then |
| 1587 | REPOS+=" onos|https://charts.onosproject.org|ONF_ONOS \ |
| 1588 | atomix|https://charts.atomix.io|ONF_Atomi" |
| 1589 | fi |
| 1590 | if [ "$CONFIG_SADIS" == "external" ]; then |
| 1591 | REPOS+=" bbsim-sadis|https://ciena.github.io/bbsim-sadis-server/charts|Custom_BBSIM_SADIS_Server" |
| 1592 | fi |
| 1593 | if [ "$WITH_EFK" == "yes" ]; then |
| 1594 | REPOS+=" elastic|https://helm.elastic.co|Elastic \ |
| 1595 | kiwigrid|https://kiwigrid.github.io|Fluentd-ElasticSearch" |
| 1596 | fi |
| 1597 | REPO_UPDATE_REQ="no" |
| 1598 | |
| 1599 | bspin - "Verify Helm Repository" |
| 1600 | for REPO in $REPOS; do |
| 1601 | REPO_NAME="$(echo "$REPO" | cut -d\| -f1)" |
| 1602 | REPO_URL="$(echo "$REPO" | cut -d\| -f2)" |
| 1603 | REPO_LABEL="$(echo "$REPO" | cut -d\| -f3 | sed -e 's/_/ /g')" |
| 1604 | |
| 1605 | sspin - "Verify Helm Repository: $REPO_LABEL$CEOL" |
| 1606 | if [ "$(helm repo list 2>/dev/null | grep -c "$REPO_NAME" 2>/dev/null)" -eq 0 ]; then |
| 1607 | sspin - "Add Helm Repository: $REPO_LABEL$CEOL" |
| 1608 | (set -x; helm repo add "$REPO_NAME" "$REPO_URL" >>"$LOG" 2>&1) >>"$LOG" 2>&1 |
| 1609 | REPO_UPDATE_REQ="yes" |
| 1610 | fi |
| 1611 | done |
| 1612 | sspin - "Verify Helm Repositories$CEOL" |
| 1613 | espin - "$VERIFIED" |
| 1614 | |
| 1615 | if [ "$REPO_UPDATE_REQ" == "yes" ] || [ "$UPDATE_HELM_REPOS" == "yes" ]; then |
| 1616 | bspin - "Update Helm repository cache" |
| 1617 | (set -x; helm repo update >>"$LOG" 2>&1) >>"$LOG" 2>&1 |
| 1618 | espin - "$VERIFIED" |
| 1619 | fi |
| 1620 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1621 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1622 | NOW="$(date +%s)" |
| 1623 | printtime $((NOW - STIME)) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1624 | fi |
David Bainbridge | cf54636 | 2020-04-21 23:18:50 -0700 | [diff] [blame] | 1625 | # Resolve chart versions and log them for debug/support |
| 1626 | RESOLVED_VOLTHA_CHART_VERSION=$(resolve_chart_version "$VOLTHA_CHART" "$VOLTHA_CHART_VERSION") |
| 1627 | RESOLVED_VOLTHA_BBSIM_CHART_VERSION=$(resolve_chart_version "$VOLTHA_BBSIM_CHART" "$VOLTHA_BBSIM_CHART_VERSION") |
| 1628 | RESOLVED_VOLTHA_ADAPTER_SIM_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_SIM_CHART" "$VOLTHA_ADAPTER_SIM_CHART_VERSION") |
| 1629 | RESOLVED_VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_OPEN_OLT_CHART" "$VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION") |
| 1630 | RESOLVED_VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION=$(resolve_chart_version "$VOLTHA_ADAPTER_OPEN_ONU_CHART" "$VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION") |
| 1631 | RESOLVED_ONOS_CHART_VERSION=$(resolve_chart_version "$ONOS_CHART" "$ONOS_CHART_VERSION") |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 1632 | RESOLVED_ONOS_CLASSIC_CHART_VERSION=$(resolve_chart_version "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION") |
David Bainbridge | cf54636 | 2020-04-21 23:18:50 -0700 | [diff] [blame] | 1633 | RESOLVED_KAFKA_CHART_VERSION=$(resolve_chart_version "$KAFKA_CHART" "$KAFKA_CHART_VERSION") |
divyadesai | 59f987a | 2020-05-27 12:11:33 +0000 | [diff] [blame] | 1634 | RESOLVED_ELASTICSEARCH_CHART_VERSION=$(resolve_chart_version "$ELASTICSEARCH_CHART" "$ELASTICSEARCH_CHART_VERSION") |
| 1635 | RESOLVED_KIBANA_CHART_VERSION=$(resolve_chart_version "$KIBANA_CHART" "$KIBANA_CHART_VERSION") |
| 1636 | RESOLVED_FLUENTD_ELASTICSEARCH_CHART_VERSION=$(resolve_chart_version "$FLUENTD_ELASTICSEARCH_CHART" "$FLUENTD_ELASTICSEARCH_CHART_VERSION") |
David K. Bainbridge | 450c15c | 2020-06-29 10:12:06 -0700 | [diff] [blame] | 1637 | RESOLVED_BBSIM_SADIS_SERVER_CHART_VERSION=$(resolve_chart_version "$BBSIM_SADIS_SERVER_CHART" "$BBSIM_SADIS_SERVER_CHART_VERSION") |
| 1638 | RESOLVED_RADIUS_CHART_VERSION=$(resolve_chart_version "$RADIUS_CHART" "$RADIUS_CHART_VERSION") |
David Bainbridge | cf54636 | 2020-04-21 23:18:50 -0700 | [diff] [blame] | 1639 | cat <<EOV >>"$LOG" |
| 1640 | Resolved helm charts and versions: |
| 1641 | $VOLTHA_CHART:$RESOLVED_VOLTHA_CHART_VERSION |
| 1642 | $VOLTHA_BBSIM_CHART:$RESOLVED_VOLTHA_BBSIM_CHART_VERSION |
| 1643 | $VOLTHA_ADAPTER_SIM_CHART:$RESOLVED_VOLTHA_ADAPTER_SIM_CHART_VERSION |
| 1644 | $VOLTHA_ADAPTER_OPEN_OLT_CHART:$RESOLVED_VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION |
| 1645 | $VOLTHA_ADAPTER_OPEN_ONU_CHART:$RESOLVED_VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION |
| 1646 | $ONOS_CHART:$RESOLVED_ONOS_CHART_VERSION |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 1647 | $ONOS_CLASSIC_CHART:$RESOLVED_ONOS_CLASSIC_CHART_VERSION |
David Bainbridge | cf54636 | 2020-04-21 23:18:50 -0700 | [diff] [blame] | 1648 | $KAFKA_CHART:$RESOLVED_KAFKA_CHART_VERSION |
divyadesai | 59f987a | 2020-05-27 12:11:33 +0000 | [diff] [blame] | 1649 | $ELASTICSEARCH_CHART:$RESOLVED_ELASTICSEARCH_CHART_VERSION |
| 1650 | $KIBANA_CHART:$RESOLVED_KIBANA_CHART_VERSION |
| 1651 | $FLUENTD_ELASTICSEARCH_CHART:$RESOLVED_FLUENTD_ELASTICSEARCH_CHART_VERSION |
David K. Bainbridge | 450c15c | 2020-06-29 10:12:06 -0700 | [diff] [blame] | 1652 | $BBSIM_SADIS_SERVER_CHART:$RESOLVED_BBSIM_SADIS_SERVER_CHART_VERSION |
| 1653 | $RADIUS_CHART:$RESOLVED_RADIUS_CHART_VERSION |
David Bainbridge | cf54636 | 2020-04-21 23:18:50 -0700 | [diff] [blame] | 1654 | EOV |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1655 | |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1656 | STIME="$(date +%s)" |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1657 | bspin "Verify Helm values file: $NAME-values.yaml" |
| 1658 | if [ ! -r "./$NAME-values.yaml" ]; then |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1659 | espin "$NOT_VERIFIED" |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1660 | bspin - "Download Helm values file: $TYPE-values.yaml to $NAME-values.yaml $DOWNLOAD" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1661 | ERR_OUT="$(mktemp)" |
serkant.uluderya | 4d31513 | 2020-04-15 16:25:54 -0700 | [diff] [blame] | 1662 | if ! (set -x; curl --fail -o "./$NAME-values.yaml" -sSL "https://raw.githubusercontent.com/opencord/kind-voltha/$VK_RELEASE/$TYPE-values.yaml" >>"$LOG" 2>"$ERR_OUT") >>"$LOG" 2>&1; then |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1663 | espin - "$THEX" |
| 1664 | echo -e "${RED}${BOLD}${ERROR}ERROR: $NAME-values.yaml${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}" |
| 1665 | echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG" |
| 1666 | rm -rf "$ERR_OUT" "./$NAME-values.yaml" |
David K. Bainbridge | a00736b | 2020-01-08 14:33:17 -0800 | [diff] [blame] | 1667 | exit 1 |
| 1668 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1669 | rm -rf "$ERR_OUT" |
| 1670 | espin - "$VERIFIED" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1671 | else |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1672 | espin "$VERIFIED" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1673 | fi |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1674 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1675 | NOW="$(date +%s)" |
| 1676 | printtime $((NOW - STIME)) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1677 | fi |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1678 | |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1679 | STIME="$(date +%s)" |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 1680 | bspin "Verify or download chart specific values files $DOWNLOAD" |
| 1681 | VALUES_FILES="monkey-values.yaml" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1682 | ERR_OUT="$(mktemp)" |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 1683 | for i in $VALUES_FILES; do |
| 1684 | if [ ! -r ./$i ]; then |
serkant.uluderya | 4d31513 | 2020-04-15 16:25:54 -0700 | [diff] [blame] | 1685 | if ! (set -x; curl --fail -o "./$i" -sSL "https://raw.githubusercontent.com/opencord/kind-voltha/$VK_RELEASE/$i" >>"$LOG" 2>"$ERR_OUT") >>"$LOG" 2>&1; then |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1686 | espin "$THEX" |
| 1687 | echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}" |
| 1688 | echo "ERROR: $i - $(cat "$ERR_OUT")" >>"$LOG" |
| 1689 | rm -rf "$ERR_OUT" "./$i" |
David K. Bainbridge | a00736b | 2020-01-08 14:33:17 -0800 | [diff] [blame] | 1690 | exit 1 |
| 1691 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1692 | rm -rf "$ERR_OUT" |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 1693 | fi |
| 1694 | done |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1695 | rm -rf "$ERR_OUT" |
| 1696 | espin "$VERIFIED" |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 1697 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1698 | NOW="$(date +%s)" |
| 1699 | printtime $((NOW - STIME)) |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 1700 | fi |
| 1701 | |
| 1702 | if [ "$WITH_CHAOS" == "yes" ]; then |
| 1703 | bspin "Verify or clone kube-monkey helm chart $DOWNLOAD" |
| 1704 | if [ -r ./kube-monkey ]; then |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1705 | espin "$VERIFIED" |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 1706 | else |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1707 | espin "$NOT_VERIFIED" |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 1708 | bspin - "GIT clone kube-monkey" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1709 | (set -x; git clone https://github.com/asobti/kube-monkey kube-monkey >>"$LOG" 2>&1) >>"$LOG" 2>&1 |
| 1710 | espin - "$VERIFIED" |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 1711 | fi |
| 1712 | fi |
| 1713 | |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1714 | if [ "$JUST_K8S" == "yes" ]; then |
| 1715 | echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye." |
| 1716 | echo "" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1717 | echo "Please issue the following commands in your terminal to ensure that you" | tee -a "$LOG" |
| 1718 | echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a "$LOG" |
| 1719 | echo "tools required by VOLTHA in your command path. " | tee -a "$LOG" |
| 1720 | echo "" | tee -a "$LOG" |
| 1721 | echo -en "$BOLD" |
| 1722 | if [ "$DEPLOY_K8S" == "yes" ]; then |
| 1723 | 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] | 1724 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1725 | echo "export PATH=$GOPATH/bin:\$PATH" | tee -a "$LOG" |
| 1726 | echo -en "$NORMAL" |
| 1727 | echo "" | tee -a "$LOG" |
| 1728 | echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a "$LOG" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1729 | exit 0 |
| 1730 | fi |
| 1731 | |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1732 | STIME="$(date +%s)" |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 1733 | if is_in "$WITH_ONOS" "yes,legacy,classic"; then |
| 1734 | if is_in "$WITH_ONOS" "legacy"; then |
| 1735 | bspin "Verify ONOS LEGACY installed $BIRD" |
| 1736 | if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^onos\$" | wc -l)" -ne 1 ]; then |
| 1737 | espin "$NOT_VERIFIED" |
David Bainbridge | 33e56c7 | 2020-06-11 11:39:56 -0700 | [diff] [blame] | 1738 | INTERNAL_EXTRA_HELM_INSTALL_ARGS="$SET_TAG $EXTRA_HELM_FLAGS" helm_install - "$INFRA_NS" onos "$ONOS_CHART" "$ONOS_CHART_VERSION" "+onos" "$_HELM_DESC ONOS LEGACY" |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 1739 | INTERNAL_EXTRA_HELM_INSTALL_ARGS= |
| 1740 | else |
| 1741 | espin "$VERIFIED" |
| 1742 | fi |
| 1743 | wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for ONOS to start" "$NO_LABEL" "onos-.*" |
Matteo Scandolo | 7ef6ba5 | 2019-10-04 09:20:37 -0700 | [diff] [blame] | 1744 | |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 1745 | if [ "$WITH_PORT_FORWARDS" == "yes" ]; then |
| 1746 | bspin - "Forward ONOS API port $FORWARD" |
| 1747 | kill_port_forward onos-ui |
| 1748 | port_forward "$INFRA_NS" onos-ui "$ONOS_API_PORT:8181" |
| 1749 | espin - "$VERIFIED" |
| 1750 | bspin - "Forward ONOS SSH port $FORWARD" |
| 1751 | kill_port_forward onos-ssh |
| 1752 | port_forward "$INFRA_NS" onos-ssh "$ONOS_SSH_PORT:8101" |
| 1753 | espin - "$VERIFIED" |
| 1754 | _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT" |
| 1755 | else |
| 1756 | _ONOS_API_EP="$(get_service_ep "$INFRA_NS" onos-ui)" |
| 1757 | fi |
| 1758 | elif is_in "$WITH_ONOS" "yes,classic"; then |
| 1759 | bspin "Verify ONOS CLASSIC installed $BIRD" |
| 1760 | if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^onos\$" | wc -l)" -ne 1 ]; then |
| 1761 | espin "$NOT_VERIFIED" |
Matteo Scandolo | e0829b5 | 2020-05-08 14:23:56 -0700 | [diff] [blame] | 1762 | # ONOS CLASSIC identifies its image repo/tag/pullPolicy differently, so yq is used to grab the values from the |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 1763 | # values value |
David Bainbridge | fad5073 | 2020-05-01 17:00:12 -0700 | [diff] [blame] | 1764 | YAML_VALUES=$(INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set replicas=$NUM_OF_ONOS --set atomix.replicas=$NUM_OF_ATOMIX" \ |
| 1765 | helm_values "$INFRA_NS" onos "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION") |
| 1766 | _ONOS_REPO="$(echo "$YAML_VALUES" | yq read - images.onos.repository)" |
David Bainbridge | dee3f02 | 2020-06-05 07:45:13 -0700 | [diff] [blame] | 1767 | if [ -z "$_ONOS_REPO" ]; then |
| 1768 | _ONOS_REPO="voltha/voltha-onos" |
| 1769 | fi |
David Bainbridge | fad5073 | 2020-05-01 17:00:12 -0700 | [diff] [blame] | 1770 | _ONOS_TAG="$(echo "$YAML_VALUES" | yq read - images.onos.tag)" |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 1771 | if [ -z "$_ONOS_TAG" ]; then |
David Bainbridge | dee3f02 | 2020-06-05 07:45:13 -0700 | [diff] [blame] | 1772 | _ONOS_TAG="$(echo "$YAML_VALUES" | yq read - defaults.image_tag)" |
| 1773 | fi |
| 1774 | if [ -z "$_ONOS_TAG" ]; then |
| 1775 | _ONOS_TAG="master" |
| 1776 | fi |
| 1777 | _ONOS_PULL_POLICY="$(echo "$YAML_VALUES" | yq read - images.onos.pullPolicy)" |
| 1778 | if [ -z "$_ONOS_PULL_POLICY" ]; then |
| 1779 | _ONOS_PULL_POLICY="$(echo "$YAML_VALUES" | yq read - defaults.image_pullPolicy)" |
| 1780 | fi |
| 1781 | if [ -z "$_ONOS_PULL_POLICY" ]; then |
| 1782 | _ONOS_PULL_POLICY="Always" |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 1783 | fi |
David Bainbridge | fad5073 | 2020-05-01 17:00:12 -0700 | [diff] [blame] | 1784 | |
Matteo Scandolo | e0829b5 | 2020-05-08 14:23:56 -0700 | [diff] [blame] | 1785 | INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set image.pullPolicy=$_ONOS_PULL_POLICY,image.repository=$_ONOS_REPO,image.tag=$_ONOS_TAG,replicas=$NUM_OF_ONOS,atomix.replicas=$NUM_OF_ATOMIX" \ |
David Bainbridge | 33e56c7 | 2020-06-11 11:39:56 -0700 | [diff] [blame] | 1786 | helm_install - "$INFRA_NS" onos "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION" "+onos" "$_HELM_DESC ONOS CLASSIC" |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 1787 | INTERNAL_EXTRA_HELM_INSTALL_ARGS= |
| 1788 | else |
| 1789 | espin "$VERIFIED" |
| 1790 | fi |
| 1791 | wait_for_pods - "$INFRA_NS" $((NUM_OF_ONOS + NUM_OF_ATOMIX)) "includes" "Waiting for ONOS CLASSIC to start" "$NO_LABEL" "onos-.*" |
| 1792 | if [ "$WITH_PORT_FORWARDS" == "yes" ]; then |
| 1793 | bspin - "Forward ONOS API port $FORWARD" |
| 1794 | kill_port_forward onos-onos-classic-hs |
| 1795 | port_forward "$INFRA_NS" onos-onos-classic-hs "$ONOS_API_PORT:8181" "$ONOS_SSH_PORT:8101" |
| 1796 | espin - "$VERIFIED" |
| 1797 | _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT" |
| 1798 | else |
| 1799 | _ONOS_API_EP="$(get_service_ep "$INFRA_NS" onos-onos-classic-hs)" |
| 1800 | fi |
| 1801 | elif [ "$WITH_ONOS" == "micro" ]; then |
| 1802 | bspin "Verify micro-ONOS installed $BIRD" |
| 1803 | # We should never get here |
| 1804 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Micro ONOS not currently supported${NORMAL}" |
| 1805 | exit 1 |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 1806 | fi |
David Bainbridge | d31d612 | 2019-08-13 19:37:59 +0000 | [diff] [blame] | 1807 | bspin - "Verify or download ONOS configuration support files $DOWNLOAD" |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 1808 | ONOS_FILES="olt-onos-enableExtraneousRules.json onos-aaa.json \ |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 1809 | onos-dhcpl2relay.json onos-sadis-sample.json" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1810 | (set -x; mkdir -p ./onos-files >>"$LOG" 2>&1) >>"$LOG" 2>&1 |
| 1811 | ERR_OUT="$(mktemp)" |
David Bainbridge | 2b19e83 | 2019-08-16 02:40:53 +0000 | [diff] [blame] | 1812 | for i in $ONOS_FILES; do |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1813 | if [ ! -r "./onos-files/$i" ]; then |
serkant.uluderya | 4d31513 | 2020-04-15 16:25:54 -0700 | [diff] [blame] | 1814 | if ! (set -x; curl --fail -o "./onos-files/$i" -sSL "https://raw.githubusercontent.com/opencord/kind-voltha/$VK_RELEASE/onos-files/$i" >>"$LOG" 2>"$ERR_OUT") >>"$LOG" 2>&1; then |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1815 | espin - "$THEX" |
| 1816 | echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat "$ERR_OUT")${NORMAL}" |
| 1817 | echo "ERROR: $(cat "$ERR_OUT")" >>"$LOG" |
| 1818 | rm -rf "$ERR_OUT" "./onos-files/$i" |
David K. Bainbridge | a00736b | 2020-01-08 14:33:17 -0800 | [diff] [blame] | 1819 | exit 1 |
| 1820 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1821 | rm -rf "$ERR_OUT" |
David Bainbridge | d31d612 | 2019-08-13 19:37:59 +0000 | [diff] [blame] | 1822 | fi |
| 1823 | done |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1824 | rm -rf "$ERR_OUT" |
| 1825 | espin - "$VERIFIED" |
David Bainbridge | 27790d6 | 2019-08-13 22:43:19 +0000 | [diff] [blame] | 1826 | |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1827 | if [ "$INSTALL_ONOS_APPS" == "yes" ]; then |
David Bainbridge | 27790d6 | 2019-08-13 22:43:19 +0000 | [diff] [blame] | 1828 | bspin - "Installing custom ONOS applications" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1829 | if [ -x onos-files/onos-apps ] && [ "$(find onos-files/onos-apps -name "*.oar" 2>/dev/null | wc -l)" -gt 0 ]; then |
| 1830 | for OAR in onos-files/onos-apps/*.oar; do |
David Bainbridge | 27790d6 | 2019-08-13 22:43:19 +0000 | [diff] [blame] | 1831 | sspin - "Installing custom ONOS applications - $OAR$CEOL" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1832 | override_onos_app "$OAR" |
David Bainbridge | 27790d6 | 2019-08-13 22:43:19 +0000 | [diff] [blame] | 1833 | done |
| 1834 | espin - "$VERIFIED Installing custom ONOS applications$CEOL" |
| 1835 | else |
| 1836 | espin - "$NOT_VERIFIED Installing custom ONOS applications - None Found" |
| 1837 | fi |
| 1838 | fi |
Matteo Scandolo | 7ef6ba5 | 2019-10-04 09:20:37 -0700 | [diff] [blame] | 1839 | |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1840 | if [ "$WITH_KAFKA" != "no" ]; then |
David Bainbridge | 837e8bd | 2020-04-06 13:17:14 -0700 | [diff] [blame] | 1841 | check_onos_app_active org.opencord.kafka |
David Bainbridge | 879439b | 2020-06-12 15:59:35 -0700 | [diff] [blame] | 1842 | if is_in "$WITH_KAFKA" "yes,external"; then |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 1843 | _HOST=kafka.$INFRA_NS.svc |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1844 | _PORT=9092 |
David Bainbridge | 879439b | 2020-06-12 15:59:35 -0700 | [diff] [blame] | 1845 | elif [ "$WITH_KAFKA" != "no" ]; then |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1846 | _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)" |
| 1847 | _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)" |
David Bainbridge | 837e8bd | 2020-04-06 13:17:14 -0700 | [diff] [blame] | 1848 | _PORT=${_PORT:-9092} |
| 1849 | fi |
| 1850 | push_onos_config "json" "Push ONOS Kafka Configuration" "network/configuration/apps/org.opencord.kafka" \ |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1851 | "$(cat <<EOJ | tr -d '[:space:]' |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 1852 | { |
| 1853 | "kafka": { |
| 1854 | "bootstrapServers": "$_HOST:$_PORT" |
| 1855 | } |
| 1856 | } |
| 1857 | EOJ |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1858 | )" |
David Bainbridge | 837e8bd | 2020-04-06 13:17:14 -0700 | [diff] [blame] | 1859 | fi |
Matteo Scandolo | 9a77a73 | 2020-01-09 14:24:12 -0800 | [diff] [blame] | 1860 | check_onos_app_active org.opencord.dhcpl2relay |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 1861 | 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] | 1862 | check_onos_app_active org.opencord.olt |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 1863 | # FIXME use WITH_DHCP and WITH_EAPOL flags to configre OLT App |
Hardik Windlass | a7501fb | 2020-02-17 14:28:20 +0000 | [diff] [blame] | 1864 | # Default value for "enableEapol" is true in OLT App |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1865 | if [ "$WITH_EAPOL" == "yes" ]; then |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 1866 | push_onos_config "json" "Enable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":true}' |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1867 | elif [ "$WITH_EAPOL" == "no" ]; then |
Hardik Windlass | a7501fb | 2020-02-17 14:28:20 +0000 | [diff] [blame] | 1868 | 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] | 1869 | fi |
Hardik Windlass | a7501fb | 2020-02-17 14:28:20 +0000 | [diff] [blame] | 1870 | # Default value for "enableDhcpOnProvisioning" is false and for "enableDhcpV4" is true in OLT App |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1871 | if [ "$WITH_DHCP" == "yes" ]; then |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 1872 | push_onos_config "json" "Enable VOLTHA ONOS DHCP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableDhcpOnProvisioning":true,"enableDhcpV4":true}' |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1873 | elif [ "$WITH_DHCP" == "no" ]; then |
Hardik Windlass | a7501fb | 2020-02-17 14:28:20 +0000 | [diff] [blame] | 1874 | 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] | 1875 | fi |
Hardik Windlass | a7501fb | 2020-02-17 14:28:20 +0000 | [diff] [blame] | 1876 | # Default value for "enableIgmpOnProvisioning" is false in OLT App |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1877 | if [ "$WITH_IGMP" == "yes" ]; then |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 1878 | push_onos_config "json" "Enable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":true}' |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1879 | elif [ "$WITH_IGMP" == "no" ]; then |
Hardik Windlass | a7501fb | 2020-02-17 14:28:20 +0000 | [diff] [blame] | 1880 | 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] | 1881 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1882 | if [ "$ENABLE_ONOS_EXTRANEOUS_RULES" == "yes" ]; then |
David K. Bainbridge | 484d80c | 2020-03-05 21:44:34 -0800 | [diff] [blame] | 1883 | push_onos_config "file" "Enabling extraneous rules for ONOS" "configuration/org.onosproject.net.flow.impl.FlowRuleManager" "onos-files/olt-onos-enableExtraneousRules.json" |
| 1884 | fi |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 1885 | if is_in "$CONFIG_SADIS" "yes,file"; then |
Matteo Scandolo | 9a77a73 | 2020-01-09 14:24:12 -0800 | [diff] [blame] | 1886 | check_onos_app_active org.opencord.sadis |
Hardik Windlass | b314760 | 2020-03-09 16:59:15 +0530 | [diff] [blame] | 1887 | 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] | 1888 | elif [ "$CONFIG_SADIS" == "bbsim" ]; then |
| 1889 | push_onos_config "json" \ |
| 1890 | "[optional] Push ONOS configuration for BBSIM SADIS servers" \ |
| 1891 | "network/configuration/apps/org.opencord.sadis" \ |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1892 | "$(cat <<EOJ | tr -d '[:space:]' |
David K. Bainbridge | b859e91 | 2020-03-13 14:07:52 -0700 | [diff] [blame] | 1893 | { |
| 1894 | "sadis": { |
| 1895 | "integration": { |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 1896 | "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:50074/v2/subscribers/%s", |
David K. Bainbridge | b859e91 | 2020-03-13 14:07:52 -0700 | [diff] [blame] | 1897 | "cache": { |
| 1898 | "enabled": true, |
| 1899 | "maxsize": 50, |
| 1900 | "ttl": "PT1m" |
| 1901 | } |
| 1902 | } |
| 1903 | }, |
| 1904 | "bandwidthprofile": { |
| 1905 | "integration": { |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 1906 | "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:50074/v2/bandwidthprofiles/%s", |
David K. Bainbridge | b859e91 | 2020-03-13 14:07:52 -0700 | [diff] [blame] | 1907 | "cache": { |
| 1908 | "enabled": true, |
| 1909 | "maxsize": 50, |
| 1910 | "ttl": "PT1m" |
| 1911 | } |
| 1912 | } |
| 1913 | } |
| 1914 | } |
| 1915 | EOJ |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1916 | )" |
David Bainbridge | 309099c | 2020-05-05 08:47:29 -0700 | [diff] [blame] | 1917 | elif [ "$CONFIG_SADIS" == "external" ]; then |
David Bainbridge | 879439b | 2020-06-12 15:59:35 -0700 | [diff] [blame] | 1918 | if kubectl get -n "$BBSIM_NS" svc/bbsim-sadis-server-bbsim-sadis-server >/dev/null 2>&1; then |
| 1919 | BBSIM_SADIS_SVC="bbsim-sadis-server-bbsim-sadis-server" |
| 1920 | else |
| 1921 | BBSIM_SADIS_SVC="bbsim-sadis-server" |
| 1922 | fi |
David Bainbridge | 309099c | 2020-05-05 08:47:29 -0700 | [diff] [blame] | 1923 | push_onos_config "json" \ |
| 1924 | "[optional] Push ONOS configuration for custom SADIS and Bandwidth Profile servers" \ |
| 1925 | "network/configuration/apps/org.opencord.sadis" \ |
| 1926 | "$(cat <<EOJ | tr -d '[:space:]' |
| 1927 | { |
| 1928 | "sadis": { |
| 1929 | "integration": { |
David Bainbridge | 879439b | 2020-06-12 15:59:35 -0700 | [diff] [blame] | 1930 | "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:58080/subscribers/%s", |
David Bainbridge | 309099c | 2020-05-05 08:47:29 -0700 | [diff] [blame] | 1931 | "cache": { |
| 1932 | "enabled": true, |
| 1933 | "maxsize": 50, |
| 1934 | "ttl": "PT1m" |
| 1935 | } |
| 1936 | } |
| 1937 | }, |
| 1938 | "bandwidthprofile": { |
| 1939 | "integration": { |
David Bainbridge | 879439b | 2020-06-12 15:59:35 -0700 | [diff] [blame] | 1940 | "url": "http://$BBSIM_SADIS_SVC.$BBSIM_NS.svc:58080/profiles/%s", |
David Bainbridge | 309099c | 2020-05-05 08:47:29 -0700 | [diff] [blame] | 1941 | "cache": { |
| 1942 | "enabled": true, |
| 1943 | "maxsize": 50, |
| 1944 | "ttl": "PT1m" |
| 1945 | } |
| 1946 | } |
| 1947 | } |
| 1948 | } |
| 1949 | EOJ |
| 1950 | )" |
David K. Bainbridge | b859e91 | 2020-03-13 14:07:52 -0700 | [diff] [blame] | 1951 | elif [ "$CONFIG_SADIS" == "url" ]; then |
| 1952 | push_onos_config "json" \ |
| 1953 | "[optional] Push ONOS configuration for custom SADIS and Bandwidth Profile servers" \ |
| 1954 | "network/configuration/apps/org.opencord.sadis" \ |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1955 | "$(cat <<EOJ | tr -d '[:space:]' |
David K. Bainbridge | b859e91 | 2020-03-13 14:07:52 -0700 | [diff] [blame] | 1956 | { |
| 1957 | "sadis": { |
| 1958 | "integration": { |
| 1959 | "url": "$SADIS_SUBSCRIBERS", |
| 1960 | "cache": { |
| 1961 | "enabled": true, |
| 1962 | "maxsize": 50, |
| 1963 | "ttl": "PT1m" |
| 1964 | } |
| 1965 | } |
| 1966 | }, |
| 1967 | "bandwidthprofile": { |
| 1968 | "integration": { |
| 1969 | "url": "$SADIS_BANDWIDTH_PROFILES", |
| 1970 | "cache": { |
| 1971 | "enabled": true, |
| 1972 | "maxsize": 50, |
| 1973 | "ttl": "PT1m" |
| 1974 | } |
| 1975 | } |
| 1976 | } |
| 1977 | } |
| 1978 | EOJ |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1979 | )" |
David Bainbridge | 2b19e83 | 2019-08-16 02:40:53 +0000 | [diff] [blame] | 1980 | fi |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1981 | fi |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1982 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1983 | NOW="$(date +%s)" |
| 1984 | printtime $((NOW - STIME)) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1985 | fi |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1986 | |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 1987 | if is_in "$WITH_ETCD" "yes,external"; then |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1988 | STIME="$(date +%s)" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1989 | bspin "Verify external ETCD cluster $OLD_KEY" |
David Bainbridge | 43f2df5 | 2020-06-02 15:30:54 -0700 | [diff] [blame] | 1990 | EXPECT="$(yq r - "etcd.replicas" <"$NAME-values.yaml")" |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 1991 | if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^etcd\$" | wc -l)" -ne 1 ]; then |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1992 | espin "$NOT_VERIFIED" |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 1993 | helm_install - "$INFRA_NS" etcd "$ETCD_CHART" "$ETCD_CHART_VERSION" etcd "$_HELM_DESC external ETCD cluster" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1994 | else |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1995 | espin "$VERIFIED" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1996 | fi |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 1997 | wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for ETCD cluster to start" "$NO_LABEL" "etcd-.*" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 1998 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 1999 | NOW="$(date +%s)" |
| 2000 | printtime $((NOW - STIME)) |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 2001 | fi |
| 2002 | fi |
| 2003 | |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 2004 | if is_in "$WITH_KAFKA" "yes,external"; then |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2005 | _TMP="$(mktemp -u)" |
| 2006 | _COUNT="$(test "$TYPE" == "minimal" && echo "1" || echo "3")" |
| 2007 | cat << EOC > "$_TMP" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 2008 | configurationOverrides: |
| 2009 | "default.replication.factor": $_COUNT |
| 2010 | "offsets.topic.replication.factor": $_COUNT |
| 2011 | "log.retention.hours": 4 |
| 2012 | "log.message.timestamp.type": "LogAppendTime" |
| 2013 | persistence: |
| 2014 | enabled: false |
| 2015 | zookeeper: |
| 2016 | replicaCount: 1 |
| 2017 | persistence: |
| 2018 | enabled: false |
| 2019 | replicas: $_COUNT |
| 2020 | EOC |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2021 | STIME="$(date +%s)" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 2022 | bspin "Verify external Kafka cluster $OLD_KEY" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2023 | EXPECT="$(test "$TYPE" == "minimal" && echo "2" || echo "4")" |
| 2024 | if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^kafka\$" | wc -l)" -ne 1 ]; then |
| 2025 | espin "$NOT_VERIFIED" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 2026 | INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" -f $_TMP" |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 2027 | helm_install - "$INFRA_NS" kafka "$KAFKA_CHART" "$KAFKA_CHART_VERSION" kafka "$_HELM_DESC external Kafka cluster" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 2028 | else |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2029 | espin "$VERIFIED" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 2030 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2031 | wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for Kafka cluster to start" "$NO_LABEL" "kafka-.*" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 2032 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2033 | NOW="$(date +%s)" |
| 2034 | printtime $((NOW - STIME)) |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 2035 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2036 | rm -rf "$_TMP" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 2037 | fi |
| 2038 | |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2039 | STIME="$(date +%s)" |
David Bainbridge | ed47657 | 2020-06-02 14:05:45 -0700 | [diff] [blame] | 2040 | EXPECT=2 |
| 2041 | # therecanbeonlyone set hardcoded to true for backward compatibility |
| 2042 | INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set therecanbeonlyone=true" |
Matteo Scandolo | 67335f0 | 2020-04-09 11:19:53 -0700 | [diff] [blame] | 2043 | case $WITH_ETCD in |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 2044 | no) |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 2045 | ;; |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 2046 | yes|external) |
| 2047 | _HOST="etcd.$INFRA_NS.svc" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 2048 | _PORT=2379 |
| 2049 | INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 2050 | ;; |
| 2051 | *) |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2052 | _HOST="$(echo "$WITH_ETCD" | cut -d: -f1)" |
| 2053 | _PORT="$(echo "$WITH_ETCD" | cut -s -d: -f2)" |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 2054 | _PORT=${_PORT:-2379} |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 2055 | INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 2056 | ;; |
| 2057 | esac |
| 2058 | case $WITH_KAFKA in |
| 2059 | no) |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 2060 | ;; |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 2061 | yes|external) |
| 2062 | _HOST=kafka.$INFRA_NS.svc |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 2063 | _PORT=9092 |
| 2064 | INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafka_broker=$_HOST:$_PORT --set services.kafka.adapter.service=$_HOST --set services.kafka.adapter.port=$_PORT --set services.kafka.cluster.service=$_HOST --set services.kafka.cluster.port=$_PORT" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 2065 | ;; |
| 2066 | *) |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2067 | _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)" |
| 2068 | _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)" |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 2069 | _PORT=${_PORT:-9092} |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 2070 | INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafka_broker=$_HOST:$_PORT --set services.kafka.adapter.service=$_HOST --set services.kafka.adapter.port=$_PORT --set services.kafka.cluster.service=$_HOST --set services.kafka.cluster.port=$_PORT" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 2071 | ;; |
| 2072 | esac |
| 2073 | |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 2074 | if is_in "$WITH_ONOS" "legacy"; then |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 2075 | _HOST=onos-openflow.$INFRA_NS.svc |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 2076 | _PORT=6653 |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 2077 | elif is_in "$WITH_ONOS" "yes,classic"; then |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 2078 | _HOST=onos-onos-classic-hs.$INFRA_NS.svc |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 2079 | _PORT=6653 |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2080 | elif [ "$WITH_ONOS" != "no" ]; then |
| 2081 | _HOST="$(echo "$WITH_ONOS" | cut -d: -f1)" |
| 2082 | _PORT="$(echo "$WITH_ONOS" | cut -s -d: -f2)" |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 2083 | _PORT=${_PORT:-6653} |
Jonathan Hart | 6a91e6c | 2020-04-16 14:28:33 -0700 | [diff] [blame] | 2084 | fi |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 2085 | |
David Bainbridge | cf54636 | 2020-04-21 23:18:50 -0700 | [diff] [blame] | 2086 | compare_versions "$RESOLVED_VOLTHA_CHART_VERSION" 2.4.2 |
Jonathan Hart | 6a91e6c | 2020-04-16 14:28:33 -0700 | [diff] [blame] | 2087 | if [ "$?" == "1" ]; then |
| 2088 | # voltha chart > 2.4.2 uses list of controllers |
David Bainbridge | e4d11ca | 2020-05-08 10:21:10 -0700 | [diff] [blame] | 2089 | for NUM in $(seq 0 $((NUM_OF_ONOS-1))); do |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 2090 | INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.controller[$NUM].service=onos-onos-classic-$NUM.onos-onos-classic-hs.$INFRA_NS.svc --set services.controller[$NUM].port=6653" |
David Bainbridge | e4d11ca | 2020-05-08 10:21:10 -0700 | [diff] [blame] | 2091 | done |
Jonathan Hart | 6a91e6c | 2020-04-16 14:28:33 -0700 | [diff] [blame] | 2092 | else |
| 2093 | # voltha chart <= 2.4.2 uses single controller |
David Bainbridge | 76afd81 | 2020-04-06 09:53:52 -0700 | [diff] [blame] | 2094 | INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.controller.service=$_HOST --set services.controller.port=$_PORT" |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 2095 | fi |
Jonathan Hart | 6a91e6c | 2020-04-16 14:28:33 -0700 | [diff] [blame] | 2096 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 2097 | bspin "Verify VOLTHA installed $HIGH_VOLTAGE" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2098 | if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$VOLTHA_NS" "^voltha\$" | wc -l)" -ne 1 ]; then |
| 2099 | espin "$NOT_VERIFIED" |
David Bainbridge | a965ca2 | 2020-06-09 17:45:04 -0700 | [diff] [blame] | 2100 | helm_install - "$VOLTHA_NS" voltha "$VOLTHA_CHART" "$VOLTHA_CHART_VERSION" "+voltha" "$_HELM_DESC VOLTHA Core" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 2101 | else |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2102 | espin "$VERIFIED" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 2103 | fi |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 2104 | INTERNAL_EXTRA_HELM_INSTALL_ARGS= |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 2105 | |
David Bainbridge | 90fd8e3 | 2019-08-21 23:32:47 +0000 | [diff] [blame] | 2106 | VOLTHA="voltha-ofagent-.* \ |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 2107 | rw-core.* \ |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 2108 | voltha-zookeeper-.*" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2109 | wait_for_pods - "$VOLTHA_NS" "$EXPECT" "includes" "Waiting for VOLTHA Core to start" "$NO_LABEL" "$VOLTHA" |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 2110 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2111 | NOW="$(date +%s)" |
| 2112 | printtime $((NOW - STIME)) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 2113 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 2114 | |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 2115 | if [ "$WITH_ADAPTERS" == "yes" ]; then |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2116 | STIME="$(date +%s)" |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 2117 | EXPECT=0 |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 2118 | if is_in "$WITH_ETCD" "yes,external"; then |
| 2119 | _HOST=etcd.$INFRA_NS.svc |
David Bainbridge | 3517f6c | 2020-04-08 12:14:08 -0700 | [diff] [blame] | 2120 | _PORT=2379 |
| 2121 | INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2122 | elif [ "$WITH_ETCD" != "no" ]; then |
| 2123 | _HOST="$(echo "$WITH_ETCD" | cut -d: -f1)" |
| 2124 | _PORT="$(echo "$WITH_ETCD" | cut -s -d: -f2)" |
David Bainbridge | 3517f6c | 2020-04-08 12:14:08 -0700 | [diff] [blame] | 2125 | _PORT=${_PORT:-2379} |
| 2126 | INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set services.etcd.service=$_HOST --set services.etcd.port=$_PORT" |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 2127 | fi |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 2128 | if is_in "$WITH_KAFKA" "yes,external"; then |
| 2129 | _HOST=kafka.$INFRA_NS.svc |
David Bainbridge | 3517f6c | 2020-04-08 12:14:08 -0700 | [diff] [blame] | 2130 | _PORT=9092 |
| 2131 | INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafka_broker=$_HOST:$_PORT --set services.kafka.adapter.service=$_HOST --set services.kafka.adapter.port=$_PORT --set services.kafka.cluster.service=$_HOST --set services.kafka.cluster.port=$_PORT" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2132 | elif [ "$WITH_KAFKA" != "no" ]; then |
| 2133 | _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)" |
| 2134 | _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)" |
David Bainbridge | 3517f6c | 2020-04-08 12:14:08 -0700 | [diff] [blame] | 2135 | _PORT=${_PORT:-9092} |
| 2136 | INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafka_broker=$_HOST:$_PORT --set services.kafka.adapter.service=$_HOST --set services.kafka.adapter.port=$_PORT --set services.kafka.cluster.service=$_HOST --set services.kafka.cluster.port=$_PORT" |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 2137 | fi |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 2138 | echo -e "Verify Adapters $PLUG" |
| 2139 | if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then |
| 2140 | bspin - "Verify Simulated Adapters installed" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2141 | if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$ADAPTER_NS" "^sim\$" | wc -l)" -ne 1 ]; then |
| 2142 | espin - "$NOT_VERIFIED" |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 2143 | helm_install - "$ADAPTER_NS" sim "$VOLTHA_ADAPTER_SIM_CHART" "$VOLTHA_ADAPTER_SIM_CHART_VERSION" - "$_HELM_DESC Simulated Adapters" |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 2144 | else |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2145 | espin - "$VERIFIED" |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 2146 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2147 | EXPECT="$((EXPECT + 2))" |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 2148 | fi |
Matteo Scandolo | 7ef6ba5 | 2019-10-04 09:20:37 -0700 | [diff] [blame] | 2149 | |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 2150 | if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then |
| 2151 | bspin - "Verify OpenOLT Adapter installed" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2152 | if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$ADAPTER_NS" "^open-olt\$" | wc -l)" -ne 1 ]; then |
| 2153 | espin - "$NOT_VERIFIED" |
David Bainbridge | a965ca2 | 2020-06-09 17:45:04 -0700 | [diff] [blame] | 2154 | helm_install - "$ADAPTER_NS" open-olt "$VOLTHA_ADAPTER_OPEN_OLT_CHART" "$VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION" "+open-olt" "$_HELM_DESC OpenOLT Adapter" |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 2155 | else |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2156 | espin - "$VERIFIED" |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 2157 | fi |
Matteo Scandolo | 67335f0 | 2020-04-09 11:19:53 -0700 | [diff] [blame] | 2158 | EXPECT="$((EXPECT + 1))" |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 2159 | bspin - "Verify OpenONU Adapter installed" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2160 | if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$ADAPTER_NS" "^open-onu\$" | wc -l)" -ne 1 ]; then |
Matteo Scandolo | 67335f0 | 2020-04-09 11:19:53 -0700 | [diff] [blame] | 2161 | _ORIGINAL_EXTRA_HELM_INSTALL_ARGS="$INTERNAL_EXTRA_HELM_INSTALL_ARGS" |
| 2162 | INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set replicas.adapter_open_onu=$NUM_OF_OPENONU" |
Girish Gowdra | 4cc5d8b | 2020-06-11 17:12:00 -0700 | [diff] [blame] | 2163 | if [ "$WITH_INCREMENTAL_EVTO_UPDATE" == "yes" ]; then |
Girish Gowdra | 1c7ad4c | 2020-06-26 13:35:16 -0700 | [diff] [blame] | 2164 | INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set defaults.incremental_evto_update=true" |
Girish Gowdra | 4cc5d8b | 2020-06-11 17:12:00 -0700 | [diff] [blame] | 2165 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2166 | espin - "$NOT_VERIFIED" |
David Bainbridge | a965ca2 | 2020-06-09 17:45:04 -0700 | [diff] [blame] | 2167 | helm_install - "$ADAPTER_NS" open-onu "$VOLTHA_ADAPTER_OPEN_ONU_CHART" "$VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION" "+open-onu" "$_HELM_DESC OpenONU Adapter" |
Matteo Scandolo | 67335f0 | 2020-04-09 11:19:53 -0700 | [diff] [blame] | 2168 | INTERNAL_EXTRA_HELM_INSTALL_ARGS="$_ORIGINAL_EXTRA_HELM_INSTALL_ARGS" |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 2169 | else |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2170 | espin - "$VERIFIED" |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 2171 | fi |
Matteo Scandolo | 67335f0 | 2020-04-09 11:19:53 -0700 | [diff] [blame] | 2172 | EXPECT=$((EXPECT + NUM_OF_OPENONU)) |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 2173 | fi |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 2174 | INTERNAL_EXTRA_HELM_INSTALL_ARGS= |
Matteo Scandolo | 7ef6ba5 | 2019-10-04 09:20:37 -0700 | [diff] [blame] | 2175 | |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 2176 | ADAPTERS="adapter-.*" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2177 | wait_for_pods - "$ADAPTER_NS" "$EXPECT" "includes" "Waiting for adapters to start" "$NO_LABEL" "$ADAPTERS" |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 2178 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2179 | NOW="$(date +%s)" |
| 2180 | printtime $((NOW - STIME)) |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 2181 | fi |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 2182 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 2183 | |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2184 | if [ "$WITH_BBSIM" == "yes" ]; then |
| 2185 | STIME="$(date +%s)" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 2186 | echo -e "Verify BBSIM $PLUG" |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 2187 | bspin - "Verify BBSIM Installed" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2188 | for instance in $(seq 0 $((NUM_OF_BBSIM-1))); do |
Matteo Scandolo | c2eb067 | 2020-05-01 14:43:15 -0700 | [diff] [blame] | 2189 | |
| 2190 | if [ "$LEGACY_BBSIM_INDEX" == "yes" ]; then |
| 2191 | if [ "$instance" -eq 0 ]; then |
| 2192 | instance_num="" |
| 2193 | else |
| 2194 | instance_num=$instance |
| 2195 | fi |
David K. Bainbridge | 4342240 | 2020-03-06 07:41:22 -0800 | [diff] [blame] | 2196 | else |
| 2197 | instance_num=$instance |
| 2198 | fi |
Matteo Scandolo | c2eb067 | 2020-05-01 14:43:15 -0700 | [diff] [blame] | 2199 | |
| 2200 | |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2201 | if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$BBSIM_NS" "^bbsim${instance_num}\$" | wc -l)" -ne 1 ]; then |
| 2202 | espin - "$NOT_VERIFIED" |
| 2203 | S_TAG="$((900+instance))" |
Matteo Scandolo | 5a14957 | 2020-04-01 10:14:57 -0700 | [diff] [blame] | 2204 | INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set olt_id=$instance,s_tag=$S_TAG" |
David Bainbridge | d9329af | 2020-05-01 11:58:52 -0700 | [diff] [blame] | 2205 | if [ "$WITH_EAPOL" == "yes" ]; then |
| 2206 | INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set auth=true" |
| 2207 | else |
| 2208 | INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set auth=false" |
| 2209 | fi |
| 2210 | if [ "$WITH_DHCP" == "yes" ]; then |
| 2211 | INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set dhcp=true" |
| 2212 | else |
| 2213 | INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set dhcp=false" |
| 2214 | fi |
David Bainbridge | 33e56c7 | 2020-06-11 11:39:56 -0700 | [diff] [blame] | 2215 | if is_in "$WITH_KAFKA" "yes,external"; then |
| 2216 | _HOST=kafka.$INFRA_NS.svc |
| 2217 | _PORT=9092 |
| 2218 | INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafkaAddress=$_HOST:$_PORT" |
| 2219 | elif [ "$WITH_KAFKA" != "no" ]; then |
| 2220 | _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)" |
| 2221 | _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)" |
| 2222 | _PORT=${_PORT:-9092} |
| 2223 | INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafkaAddress=$_HOST:$_PORT" |
| 2224 | fi |
| 2225 | helm_install - "$BBSIM_NS" "bbsim${instance_num}" "$VOLTHA_BBSIM_CHART" "$VOLTHA_BBSIM_CHART_VERSION" "+bbsim" "$_HELM_DESC BBSIM${instance_num}" |
David Bainbridge | 2eaf2cf | 2020-03-18 12:54:08 -0700 | [diff] [blame] | 2226 | INTERNAL_EXTRA_HELM_INSTALL_ARGS= |
David K. Bainbridge | 4342240 | 2020-03-06 07:41:22 -0800 | [diff] [blame] | 2227 | else |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2228 | espin - "$VERIFIED" |
David K. Bainbridge | 4342240 | 2020-03-06 07:41:22 -0800 | [diff] [blame] | 2229 | fi |
| 2230 | done |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2231 | wait_for_pods - "$BBSIM_NS" "$NUM_OF_BBSIM" "includes" "Waiting for BBSIM to start" "$BBSIM_LABEL" "bbsim*" |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 2232 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2233 | NOW="$(date +%s)" |
| 2234 | printtime $((NOW - STIME)) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 2235 | fi |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 2236 | fi |
| 2237 | |
divyadesai | 59f987a | 2020-05-27 12:11:33 +0000 | [diff] [blame] | 2238 | if [ "$WITH_EFK" == "yes" ]; then |
| 2239 | STIME="$(date +%s)" |
| 2240 | echo -e "Verify EFK $PLUG" |
| 2241 | bspin - "Verify EFK Installed" |
| 2242 | if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^elasticsearch\$" | wc -l)" -ne 1 ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^kibana\$" | wc -l)" -ne 1 ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^fluentd\$" | wc -l)" -ne 1 ]; then |
| 2243 | espin - "$NOT_VERIFIED" |
| 2244 | if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^elasticsearch\$" | wc -l)" -ne 1 ]; then |
| 2245 | helm_install - "$INFRA_NS" elasticsearch "$ELASTICSEARCH_CHART" "$ELASTICSEARCH_CHART_VERSION" elasticsearch "$_HELM_DESC elasticsearch" |
| 2246 | fi |
| 2247 | if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^kibana\$" | wc -l)" -ne 1 ]; then |
| 2248 | helm_install - "$INFRA_NS" kibana "$KIBANA_CHART" "$KIBANA_CHART_VERSION" kibana "$_HELM_DESC kibana" |
| 2249 | fi |
| 2250 | if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^fluentd\$" | wc -l)" -ne 1 ]; then |
| 2251 | helm_install - "$INFRA_NS" fluentd "$FLUENTD_ELASTICSEARCH_CHART" "$FLUENTD_ELASTICSEARCH_CHART_VERSION" fluentd-elasticsearch "$_HELM_DESC fluentd-elasticsearch" |
| 2252 | fi |
| 2253 | else |
| 2254 | espin - "$VERIFIED" |
| 2255 | fi |
| 2256 | EXPECT=2 # for elastic and kibana |
| 2257 | if [ "$TYPE" == "minimal" ]; then |
| 2258 | EXPECT=$((EXPECT + 2)) # for fluentd on worker 2 worker nodes |
| 2259 | else |
| 2260 | EXPECT=$((EXPECT + 3)) # for fluentd on worker 3 worker nodes |
| 2261 | fi |
| 2262 | if [ "$SCHEDULE_ON_CONTROL_NODES" == "yes" ]; then |
| 2263 | EXPECT=$((EXPECT + 1)) # for fluentd on the control plan node |
| 2264 | fi |
| 2265 | |
| 2266 | wait_for_pods - "$INFRA_NS" "$EXPECT" "includes" "Waiting for EFK to start" "$NO_LABEL" "fluentd-* elasticsearch-* kibana-*" |
| 2267 | if [ "$WITH_TIMINGS" == "yes" ]; then |
| 2268 | NOW="$(date +%s)" |
| 2269 | printtime $((NOW - STIME)) |
| 2270 | fi |
| 2271 | fi |
| 2272 | |
David Bainbridge | 309099c | 2020-05-05 08:47:29 -0700 | [diff] [blame] | 2273 | if [ "$CONFIG_SADIS" == "external" ]; then |
| 2274 | STIME="$(date +%s)" |
| 2275 | echo -e "Verify BBSIM SADIS Service $PLUG" |
| 2276 | bspin - "Verify required configmap" |
| 2277 | (set -x; kubectl -n "$BBSIM_NS" delete --ignore-not-found configmap kube-config >>"$LOG" 2>&1) >>"$LOG" 2>&1 |
| 2278 | (set -x; kubectl -n "$BBSIM_NS" create configmap kube-config "--from-file=kube_config=$KUBECONFIG" >>"$LOG" 2>&1) >>"$LOG" 2>&1 |
| 2279 | espin - "$VERIFIED" |
| 2280 | bspin - "Verify BBSIM SADIS Service Installed" |
divyadesai | 59f987a | 2020-05-27 12:11:33 +0000 | [diff] [blame] | 2281 | if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$BBSIM_NS" "^bbsim-sadis-server\$" | wc -l)" -ne 1 ]; then |
David Bainbridge | 309099c | 2020-05-05 08:47:29 -0700 | [diff] [blame] | 2282 | espin - "$NOT_VERIFIED" |
David Bainbridge | 879439b | 2020-06-12 15:59:35 -0700 | [diff] [blame] | 2283 | helm_install - "$BBSIM_NS" bbsim-sadis-server "$BBSIM_SADIS_SERVER_CHART" "$BBSIM_SADIS_SERVER_CHART_VERSION" "+sadis" "$_HELM_DESC BBSIM SADIS Server" |
David Bainbridge | 309099c | 2020-05-05 08:47:29 -0700 | [diff] [blame] | 2284 | else |
| 2285 | espin - "$VERIFIED" |
| 2286 | fi |
| 2287 | wait_for_pods - "$BBSIM_NS" 1 "includes" "Waiting for BBSIM SADIS Server to start" "$NO_LABEL" "bbsim-sadis-server-.*" |
| 2288 | if [ "$WITH_TIMINGS" == "yes" ]; then |
| 2289 | NOW="$(date +%s)" |
| 2290 | printtime $((NOW - STIME)) |
| 2291 | fi |
| 2292 | fi |
| 2293 | |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2294 | if [ "$WITH_RADIUS" == "yes" ]; then |
| 2295 | STIME="$(date +%s)" |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 2296 | echo -e "Verify RADIUS $LOCK" |
| 2297 | bspin - "Verify RADIUS Installed" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2298 | if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^radius\$" | wc -l)" -ne 1 ]; then |
| 2299 | espin - "$NOT_VERIFIED" |
David Bainbridge | 879439b | 2020-06-12 15:59:35 -0700 | [diff] [blame] | 2300 | helm_install - "$INFRA_NS" radius "$RADIUS_CHART" "$RADIUS_CHART_VERSION" "+radius" "$_HELM_DESC RADIUS" |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 2301 | else |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2302 | espin - "$VERIFIED" |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 2303 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2304 | wait_for_pods - "$INFRA_NS" 1 "includes" "Waiting for RADIUS to start" "$NO_LABEL" "radius-.*" |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 2305 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2306 | NOW="$(date +%s)" |
| 2307 | printtime $((NOW - STIME)) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 2308 | fi |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 2309 | fi |
| 2310 | |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2311 | if [ "$WITH_PORT_FORWARDS" == "yes" ]; then |
| 2312 | STIME="$(date +%s)" |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 2313 | bspin - "Forward VOLTHA API port $FORWARD" |
David Bainbridge | 1d2c584 | 2020-06-03 15:29:07 -0700 | [diff] [blame] | 2314 | kill_port_forward voltha-api voltha-voltha-api |
| 2315 | VOLTHA_PREFIX= |
| 2316 | if kubectl get -n "$VOLTHA_NS" "svc/voltha-voltha-api" >/dev/null 2>&1; then |
| 2317 | VOLTHA_PREFIX="voltha-" |
| 2318 | fi |
| 2319 | |
| 2320 | port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-api" "$VOLTHA_API_PORT:55555" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2321 | espin - "$VERIFIED" |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 2322 | if is_in "$WITH_ETCD" "yes,external"; then |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 2323 | bspin - "Forward VOLTHA ETCD port $FORWARD" |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 2324 | kill_port_forward "etcd" |
| 2325 | port_forward "$INFRA_NS" "etcd" "$VOLTHA_ETCD_PORT:2379" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2326 | espin - "$VERIFIED" |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 2327 | fi |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 2328 | if is_in "$WITH_KAFKA" "yes,external"; then |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 2329 | bspin - "Forward VOLTHA Kafka port $FORWARD" |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 2330 | kill_port_forward "kafka" |
| 2331 | port_forward "$INFRA_NS" kafka "$VOLTHA_KAFKA_PORT:9092" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2332 | espin - "$VERIFIED" |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 2333 | fi |
divyadesai | 59f987a | 2020-05-27 12:11:33 +0000 | [diff] [blame] | 2334 | if [ "$WITH_EFK" == "yes" ]; then |
| 2335 | bspin - "Forward EFK port $FORWARD" |
| 2336 | kill_port_forward elasticsearch-master |
| 2337 | kill_port_forward kibana-kibana |
| 2338 | port_forward "$INFRA_NS" elasticsearch-master "$ELASTICSEARCH_PORT:9200" |
| 2339 | port_forward "$INFRA_NS" kibana-kibana "$KIBANA_PORT:5601" |
| 2340 | espin - "$VERIFIED" |
| 2341 | fi |
Matteo Scandolo | efee043 | 2020-05-05 13:56:20 -0700 | [diff] [blame] | 2342 | if [ "$WITH_PPROF" == "yes" ]; then |
David Bainbridge | 1d2c584 | 2020-06-03 15:29:07 -0700 | [diff] [blame] | 2343 | VOLTHA_OPENOLT_PREFIX= |
| 2344 | if kubectl get -n "$ADAPTER_NS" "svc/open-olt-adapter-open-olt-profiler" >/dev/null 2>&1; then |
| 2345 | VOLTHA_OPENOLT_PREFIX="open-olt-" |
| 2346 | fi |
David Bainbridge | 879439b | 2020-06-12 15:59:35 -0700 | [diff] [blame] | 2347 | bspin - "Forward PProf ports port $FORWARD" |
| 2348 | kill_port_forward voltha-rw-core-profiler voltha-voltha-rw-core-profiler |
| 2349 | kill_port_forward adapter-open-olt-profiler open-olt-adapter-open-olt-profiler |
| 2350 | kill_port_forward voltha-of-agent-profiler voltha-voltha-of-agent-profiler |
| 2351 | port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-rw-core-profiler" "$VOLTHA_PPROF_PORT:6060" |
| 2352 | port_forward "$ADAPTER_NS" "${VOLTHA_OPENOLT_PREFIX}adapter-open-olt-profiler" "$OPENOLT_PPROF_PORT:6060" |
| 2353 | port_forward "$VOLTHA_NS" "${VOLTHA_PREFIX}voltha-of-agent-profiler" "$OFAGENT_PPROF_PORT:6060" |
| 2354 | espin - "$VERIFIED" |
Matteo Scandolo | efee043 | 2020-05-05 13:56:20 -0700 | [diff] [blame] | 2355 | fi |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 2356 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2357 | NOW="$(date +%s)" |
| 2358 | printtime $((NOW - STIME)) |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 2359 | fi |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 2360 | fi |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 2361 | |
David Bainbridge | 60ffc0f | 2020-04-27 22:13:22 -0700 | [diff] [blame] | 2362 | if is_in "$WITH_ONOS" "yes,legacy,classic" && [ "$WITH_RADIUS" != "no" ]; then |
David Bainbridge | 879439b | 2020-06-12 15:59:35 -0700 | [diff] [blame] | 2363 | SVC_NAME=radius |
| 2364 | if kubectl get -n "$INFRA_NS" "svc/radius-freeradius" >/dev/null 2>&1; then |
| 2365 | SVC_NAME="radius-freeradius" |
| 2366 | fi |
| 2367 | _HOST="$SVC_NAME.$INFRA_NS.svc" |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 2368 | _PORT=1812 |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2369 | if [ "$WITH_RADIUS" != "yes" ]; then |
| 2370 | _HOST="$(echo "$WITH_RADIUS" | cut -d: -f1)" |
| 2371 | _PORT="$(echo "$WITH_RADIUS" | cut -s -d: -f2)" |
David Bainbridge | 696bc63 | 2020-04-05 21:49:37 -0700 | [diff] [blame] | 2372 | _PORT=${_PORT:-1812} |
| 2373 | fi |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 2374 | bspin "Configure ONOS RADIUS Connection $GEAR" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2375 | (set -x; sed -e "s/:RADIUS_SVC:/$_HOST/g" -e "s/:RADIUS_PORT:/$_PORT/" onos-files/onos-aaa.json | curl --fail -sSL --user karaf:karaf -X POST "http://$_ONOS_API_EP/onos/v1/network/configuration/apps/org.opencord.aaa" -H Content-type:application/json -d@- >>"$LOG" 2>&1) >>"$LOG" 2>&1 |
| 2376 | espin "$VERIFIED" |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 2377 | fi |
| 2378 | |
divyadesai | 59f987a | 2020-05-27 12:11:33 +0000 | [diff] [blame] | 2379 | if [ "$WITH_EFK" == "yes" ]; then |
| 2380 | do_curl "" "POST" "" "" "http://localhost:$KIBANA_PORT/api/saved_objects/index-pattern/logst*" "json" '{"attributes":{"title":"logst*","timeFieldName":"@timestamp"}}' "Verify logging index in EFK" "409,200" "-H Content-type:application/json -H kbn-xsrf:true" "$GEAR" |
| 2381 | # fi |
| 2382 | fi |
| 2383 | |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 2384 | if [ "$WITH_CHAOS" == "yes" ]; then |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2385 | STIME="$(date +%s)" |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 2386 | echo -e "Verify kube-monkey $LOCK" |
| 2387 | bspin - "Verify kube-monkey Installed" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2388 | if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace kube-monkey "^monkey\$" | wc -l)" -ne 1 ]; then |
| 2389 | espin - "$NOT_VERIFIED" |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 2390 | helm_install - kube-monkey monkey ./kube-monkey/helm/kubemonkey latest - "$_HELM_DESC Chaos Monkey" |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 2391 | else |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2392 | espin - "$VERIFIED" |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 2393 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2394 | wait_for_pods - "kube-monkey" 1 "includes" "Waiting for Chaos to start" "$NO_LABEL" "monkey-.*" |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 2395 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2396 | NOW="$(date +%s)" |
| 2397 | printtime $((NOW - STIME)) |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 2398 | fi |
| 2399 | fi |
| 2400 | |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 2401 | bspin "Create voltctl configuration file" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2402 | (set -x; mkdir -p "$HOME/.volt" >>"$LOG" 2>&1) >>"$LOG" 2>&1 |
| 2403 | MIN_VC_VERSION="$(echo -e "1.0.15\n$VC_VERSION" | sort -V | head -1)" |
| 2404 | if [ "$WITH_PORT_FORWARDS" == "yes" ]; then |
David K. Bainbridge | b859e91 | 2020-03-13 14:07:52 -0700 | [diff] [blame] | 2405 | KAFKA_FLAG="-k localhost:$VOLTHA_KAFKA_PORT" |
| 2406 | SERVER_FLAG="-s localhost:$VOLTHA_API_PORT" |
| 2407 | ETCD_FLAG= |
| 2408 | if [ "$MIN_VC_VERSION" == "1.0.15" ]; then |
| 2409 | ETCD_FLAG="-e localhost:$VOLTHA_ETCD_PORT" |
| 2410 | fi |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 2411 | else |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 2412 | KAFKA_FLAG="-k $(get_service_ep "$INFRA_NS" kafka)" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2413 | SERVER_FLAG="-s $(get_service_ep "$VOLTHA_NS" voltha-api)" |
David K. Bainbridge | b859e91 | 2020-03-13 14:07:52 -0700 | [diff] [blame] | 2414 | ETCD_FLAG= |
| 2415 | if [ "$MIN_VC_VERSION" == "1.0.15" ]; then |
David Bainbridge | c722062 | 2020-05-28 12:31:47 -0700 | [diff] [blame] | 2416 | ETCD_FLAG="-e $(get_service_ep "$INFRA_NS" etcd)" |
David K. Bainbridge | b859e91 | 2020-03-13 14:07:52 -0700 | [diff] [blame] | 2417 | fi |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 2418 | fi |
David Bainbridge | a965ca2 | 2020-06-09 17:45:04 -0700 | [diff] [blame] | 2419 | CMD=("voltctl $KAFKA_FLAG $SERVER_FLAG $ETCD_FLAG config") |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2420 | (set -x; ${CMD[*]} > "$HOME/.volt/config-$NAME" 2>>"$LOG") >>"$LOG" 2>&1 |
David Bainbridge | a965ca2 | 2020-06-09 17:45:04 -0700 | [diff] [blame] | 2421 | #(set -x; voltctl "$KAFKA_FLAG" "$SERVER_FLAG" "$ETCD_FLAG" config > "$HOME/.volt/config-$NAME" 2>>"$LOG") >>"$LOG" 2>&1 |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2422 | espin "$VERIFIED" |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 2423 | |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 2424 | if [ ! -f "$NAME-env.sh" ]; then |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2425 | touch "$NAME-env.sh" |
David Bainbridge | b07fdf7 | 2019-07-29 22:51:40 +0000 | [diff] [blame] | 2426 | fi |
| 2427 | |
David Bainbridge | 596f30d | 2019-07-30 17:07:59 +0000 | [diff] [blame] | 2428 | for O in $ALL_OPTIONS; do |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2429 | VAL="$(eval echo "\$$O")" |
| 2430 | if [ -n "$VAL" ] && [ "$(grep -c "^export $O=" "$NAME-env.sh")" -eq 0 ]; then |
| 2431 | echo "export $O=\"$(eval echo "\$$O")\"" >> "$NAME-env.sh" |
David Bainbridge | b07fdf7 | 2019-07-29 22:51:40 +0000 | [diff] [blame] | 2432 | fi |
| 2433 | done |
| 2434 | |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2435 | if [ "$DEPLOY_K8S" == "yes" ] && [ "$(grep -c "^export KUBECONFIG=" "$NAME-env.sh")" -eq 0 ]; then |
| 2436 | 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] | 2437 | fi |
| 2438 | |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2439 | if [ "$(grep -c "^export VOLTCONFIG=" "$NAME-env.sh")" -eq 0 ]; then |
| 2440 | echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" >> "$NAME-env.sh" |
David Bainbridge | b07fdf7 | 2019-07-29 22:51:40 +0000 | [diff] [blame] | 2441 | fi |
| 2442 | |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2443 | if [ "$(grep -c "^export PATH=" "$NAME-env.sh")" -eq 0 ]; then |
| 2444 | echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> "$NAME-env.sh" |
David Bainbridge | b07fdf7 | 2019-07-29 22:51:40 +0000 | [diff] [blame] | 2445 | fi |
| 2446 | |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 2447 | echo "" |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2448 | echo "Please issue the following commands in your terminal to ensure that you" | tee -a "$LOG" |
| 2449 | echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a "$LOG" |
| 2450 | echo "tools required by VOLTHA in your command path. " | tee -a "$LOG" |
| 2451 | echo "" | tee -a "$LOG" |
| 2452 | echo -en "$BOLD" |
| 2453 | if [ "$DEPLOY_K8S" == "yes" ]; then |
| 2454 | 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] | 2455 | fi |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2456 | echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" | tee -a "$LOG" |
| 2457 | echo "export PATH=$GOPATH/bin:\$PATH" | tee -a "$LOG" |
| 2458 | echo -en "$NORMAL" |
| 2459 | echo "" | tee -a "$LOG" |
| 2460 | echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a "$LOG" |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 2461 | |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 2462 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | d18f494 | 2020-04-14 16:46:13 -0700 | [diff] [blame] | 2463 | NOW="$(date +%s)" |
| 2464 | echo -e "$CLOCK ${BOLD}TOTAL: $(duration $((NOW - TOTAL_START_TIME)))${NORMAL}" |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 2465 | fi |