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