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