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