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