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