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