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 | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 15 | TOTAL_START_TIME=$(date +%s) |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 16 | |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 17 | FANCY=${FANCY:-1} |
| 18 | if [ "$TERM X" == " X" ]; then |
| 19 | FANCY=0 |
| 20 | fi |
| 21 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 22 | # trap ctrl-c and call ctrl_c() |
| 23 | trap ctrl_c INT |
| 24 | |
| 25 | function ctrl_c() { |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 26 | echo -en $CNORM |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 27 | echo "" |
| 28 | echo "ctrl-c trapped" |
David Bainbridge | c6a6eb6 | 2019-10-18 22:50:07 +0000 | [diff] [blame] | 29 | echo "Thank you for trying 'voltha up'" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 30 | exit |
| 31 | } |
| 32 | |
David K. Bainbridge | ebf38d9 | 2020-02-10 10:46:31 -0800 | [diff] [blame] | 33 | VOLTCTL_VERSION=${VOLTCTL_VERSION:-latest} |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 34 | KIND_VERSION=${KIND_VERSION:-v0.5.1} |
David K. Bainbridge | b3a9937 | 2020-01-08 14:39:06 -0800 | [diff] [blame] | 35 | VK_RELEASE=${VK_RELEASE:-master} |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 36 | |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 37 | BLACK= |
| 38 | RED= |
| 39 | GREEN= |
| 40 | YELLOW= |
| 41 | BLUE= |
| 42 | MAGENTA= |
| 43 | CYAN= |
| 44 | WHITE= |
| 45 | BOLD= |
| 46 | NORMAL= |
| 47 | ERROR= |
| 48 | CEOL= |
| 49 | CNORM= |
| 50 | CIVIS= |
| 51 | if [ $FANCY -eq 1 ]; then |
| 52 | BLACK=$(tput setaf 0) |
| 53 | RED=$(tput setaf 1) |
| 54 | GREEN=$(tput setaf 2) |
| 55 | YELLOW=$(tput setaf 3) |
| 56 | BLUE=$(tput setaf 4) |
| 57 | MAGENTA=$(tput setaf 5) |
| 58 | CYAN=$(tput setaf 6) |
| 59 | WHITE=$(tput setaf 7) |
| 60 | BOLD=$(tput bold) |
| 61 | NORMAL=$(tput sgr0) |
| 62 | ERROR="\xe2\x9c\x97\x20" |
| 63 | CEOL=$(tput el) |
| 64 | CNORM=$(tput cnorm) |
| 65 | CIVIS=$(tput civis) |
| 66 | fi |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 67 | |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 68 | TYPE=${TYPE:-minimal} |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 69 | NAME=${NAME:-$TYPE} |
David K. Bainbridge | 484d80c | 2020-03-05 21:44:34 -0800 | [diff] [blame] | 70 | |
| 71 | ENABLE_ONOS_EXTRANEOUS_RULES=${ENABLE_ONOS_EXTRANEOUS_RULES:-no} |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 72 | WITH_TIMINGS=${WITH_TIMINGS:-no} |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 73 | WITH_BBSIM=${WITH_BBSIM:-no} |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 74 | WITH_RADIUS=${WITH_RADIUS:-no} |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 75 | WITH_EAPOL=${WITH_EAPOL:-yes} |
| 76 | WITH_DHCP=${WITH_DHCP:-yes} |
| 77 | WITH_IGMP=${WITH_IGMP:-no} |
David Bainbridge | b270c20 | 2019-07-26 01:44:42 +0000 | [diff] [blame] | 78 | WITH_ONOS=${WITH_ONOS:-yes} |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 79 | WITH_CHAOS=${WITH_CHAOS:-no} |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 80 | WITH_ADAPTERS=${WITH_ADAPTERS:-yes} |
| 81 | WITH_SIM_ADAPTERS=${WITH_SIM_ADAPTERS:-yes} |
| 82 | WITH_OPEN_ADAPTERS=${WITH_OPEN_ADAPTERS:-yes} |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 83 | WITH_PORT_FORWARDS=${WITH_PORT_FORWARDS:-yes} |
David Bainbridge | 05cd882 | 2019-11-19 17:43:53 +0000 | [diff] [blame] | 84 | ONLY_ONE=${ONLY_ONE:-yes} |
David Bainbridge | 2b19e83 | 2019-08-16 02:40:53 +0000 | [diff] [blame] | 85 | CONFIG_SADIS=${CONFIG_SADIS:-no} |
David Bainbridge | 27790d6 | 2019-08-13 22:43:19 +0000 | [diff] [blame] | 86 | INSTALL_ONOS_APPS=${INSTALL_ONOS_APPS:-no} |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 87 | JUST_K8S=${JUST_K8S:-no} |
| 88 | DEPLOY_K8S=${DEPLOY_K8S:-yes} |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 89 | INSTALL_KUBECTL=${INSTALL_KUBECTL:-yes} |
| 90 | INSTALL_HELM=${INSTALL_HELM:-yes} |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 91 | UPDATE_HELM_REPOS=${UPDATE_HELM_REPOS:-yes} |
Matteo Scandolo | fab9862 | 2020-01-28 15:17:20 -0800 | [diff] [blame] | 92 | WAIT_ON_DOWN=${WAIT_ON_DOWN:-yes} |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 93 | VOLTHA_LOG_LEVEL=${VOLTHA_LOG_LEVEL:-WARN} |
David Bainbridge | 90fd8e3 | 2019-08-21 23:32:47 +0000 | [diff] [blame] | 94 | VOLTHA_CHART=${VOLTHA_CHART:-onf/voltha} |
| 95 | VOLTHA_CHART_VERSION=${VOLTHA_CHART_VERSION:-latest} |
| 96 | VOLTHA_BBSIM_CHART=${VOLTHA_BBSIM_CHART:-onf/bbsim} |
Matteo Scandolo | dcd29f5 | 2019-10-07 15:42:42 -0700 | [diff] [blame] | 97 | VOLTHA_BBSIM_CHART_VERSION=${VOLTHA_BBSIM_CHART_VERSION:-latest} |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame] | 98 | VOLTHA_ADAPTER_SIM_CHART=${VOLTHA_ADAPTER_SIM_CHART:-onf/voltha-adapter-simulated} |
David Bainbridge | 90fd8e3 | 2019-08-21 23:32:47 +0000 | [diff] [blame] | 99 | VOLTHA_ADAPTER_SIM_CHART_VERSION=${VOLTHA_ADAPTER_SIM_CHART_VERSION:-latest} |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame] | 100 | 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] | 101 | 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] | 102 | 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] | 103 | VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION=${VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION:-latest} |
Andrea Campanella | 2132329 | 2019-12-18 11:44:19 -0800 | [diff] [blame] | 104 | ONOS_CHART_VERSION=${ONOS_CHART_VERSION:-latest} |
David Bainbridge | 70c0ea8 | 2019-11-14 23:25:26 +0000 | [diff] [blame] | 105 | EXTRA_HELM_INSTALL_ARGS= |
uottremb | b16d398 | 2020-02-28 08:34:36 +0100 | [diff] [blame] | 106 | NUM_OF_BBSIM=${NUM_OF_BBSIM:-1} |
| 107 | MAX_NUM_OF_BBSIM=10 |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 108 | |
| 109 | HAVE_GO=$(which go >/dev/null 2>&1 && echo "yes" || echo "no") |
| 110 | HOSTOS=$(uname -s | tr "[:upper:]" "[:lower:"]) |
| 111 | HOSTARCH=$(uname -m | tr "[:upper:]" "[:lower:"]) |
| 112 | if [ $HOSTARCH == "x86_64" ]; then |
| 113 | HOSTARCH="amd64" |
| 114 | fi |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 115 | |
uottremb | b16d398 | 2020-02-28 08:34:36 +0100 | [diff] [blame] | 116 | # check number (range) of bbsim, max bbsim must not exceed 10 instances! |
| 117 | # note: instances will be numbered from 0 to 9 |
| 118 | if [ "$1" == "up" ]; then |
David K. Bainbridge | 4342240 | 2020-03-06 07:41:22 -0800 | [diff] [blame^] | 119 | if [ "$NUM_OF_BBSIM" -lt 1 ]; then |
| 120 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid setting of BBSIM instances. NUM_OF_BBSIM is less than 1${NORMAL}" |
| 121 | exit 1 |
| 122 | fi |
| 123 | if [ "$NUM_OF_BBSIM" -gt $MAX_NUM_OF_BBSIM ]; then |
| 124 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid setting of BBSIM instances. NUM_OF_BBSIM is greater than $MAX_NUM_OF_BBSIM${NORMAL}" |
| 125 | exit 1 |
| 126 | fi |
uottremb | b16d398 | 2020-02-28 08:34:36 +0100 | [diff] [blame] | 127 | fi |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 128 | # Verify TYPE setting |
| 129 | if [ $(echo ":minimal:full:" | grep -ic ":$TYPE:") -eq 0 ]; then |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 130 | >&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] | 131 | exit 1 |
| 132 | fi |
| 133 | |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 134 | function get_service_ep() { |
| 135 | local NS=$1 |
| 136 | local NAME=$2 |
| 137 | kubectl -n $NS get service $NAME -o json | jq -r '.spec.clusterIP + ":" + (.spec.ports[0].port|tostring)' |
| 138 | } |
| 139 | |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 140 | # Used to verify configuration values are set to "yes" or "no" value or convert |
| 141 | # equivalents to "yes" or "no" |
| 142 | function verify_yes_no() { |
| 143 | local VAR=$1 |
| 144 | local VAL=$(eval echo \$$VAR) |
| 145 | if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$VAL:") -eq 0 ]; then |
| 146 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid '$VAR' value of '$VAL'. Should be 'yes' or 'no'${NORMAL}" |
| 147 | echo "INVALID" |
| 148 | return 1 |
| 149 | fi |
| 150 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$VAL:") -eq 1 ]; then |
| 151 | echo "yes" |
| 152 | else |
| 153 | echo "no" |
| 154 | fi |
| 155 | return 0 |
| 156 | } |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 157 | |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 158 | ALL_YES_NO="\ |
David K. Bainbridge | 484d80c | 2020-03-05 21:44:34 -0800 | [diff] [blame] | 159 | ENABLE_ONOS_EXTRANEOUS_RULES \ |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 160 | WITH_TIMINGS \ |
| 161 | WITH_BBSIM \ |
| 162 | WITH_RADIUS \ |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 163 | WITH_EAPOL \ |
| 164 | WITH_DHCP \ |
| 165 | WITH_IGMP \ |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 166 | WITH_ONOS \ |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 167 | WITH_CHAOS \ |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 168 | WITH_ADAPTERS \ |
| 169 | WITH_SIM_ADAPTERS \ |
| 170 | WITH_OPEN_ADAPTERS \ |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 171 | WITH_PORT_FORWARDS \ |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 172 | CONFIG_SADIS \ |
| 173 | JUST_K8S \ |
| 174 | DEPLOY_K8S \ |
| 175 | INSTALL_ONOS_APPS \ |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 176 | INSTALL_KUBECTL \ |
| 177 | INSTALL_HELM \ |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 178 | UPDATE_HELM_REPOS \ |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 179 | WAIT_ON_DOWN \ |
David Bainbridge | 70c0ea8 | 2019-11-14 23:25:26 +0000 | [diff] [blame] | 180 | ONLY_ONE \ |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 181 | " |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 182 | |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 183 | ALL_OPTIONS="\ |
| 184 | NAME \ |
| 185 | TYPE \ |
| 186 | $ALL_YES_NO \ |
| 187 | VOLTHA_LOG_LEVEL \ |
| 188 | VOLTHA_CHART \ |
David Bainbridge | 90fd8e3 | 2019-08-21 23:32:47 +0000 | [diff] [blame] | 189 | VOLTHA_CHART_VERSION \ |
| 190 | VOLTHA_BBSIM_CHART \ |
| 191 | VOLTHA_BBSIM_CHART_VERSION \ |
uottremb | d5a2057 | 2020-03-06 09:15:01 +0100 | [diff] [blame] | 192 | NUM_OF_BBSIM \ |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 193 | VOLTHA_ADAPTER_SIM_CHART \ |
David Bainbridge | 90fd8e3 | 2019-08-21 23:32:47 +0000 | [diff] [blame] | 194 | VOLTHA_ADAPTER_SIM_CHART_VERSION \ |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 195 | VOLTHA_ADAPTER_OPEN_OLT_CHART \ |
David Bainbridge | 90fd8e3 | 2019-08-21 23:32:47 +0000 | [diff] [blame] | 196 | VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION \ |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 197 | VOLTHA_ADAPTER_OPEN_ONU_CHART \ |
David Bainbridge | 90fd8e3 | 2019-08-21 23:32:47 +0000 | [diff] [blame] | 198 | VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION \ |
Andrea Campanella | 2132329 | 2019-12-18 11:44:19 -0800 | [diff] [blame] | 199 | ONOS_CHART_VERSION \ |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 200 | ONOS_API_PORT \ |
| 201 | ONOS_SSH_PORT \ |
| 202 | VOLTHA_API_PORT \ |
| 203 | VOLTHA_SSH_PORT \ |
| 204 | VOLTHA_ETCD_PORT \ |
David K. Bainbridge | 00ecd38 | 2020-02-28 12:31:58 -0800 | [diff] [blame] | 205 | VOLTHA_KAFKA_PORT \ |
David K. Bainbridge | 8f7f30b | 2020-01-08 13:06:16 -0800 | [diff] [blame] | 206 | VK_RELEASE \ |
| 207 | KIND_VERSION \ |
| 208 | VOLTCTL_VERSION \ |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 209 | " |
David Bainbridge | 0129495 | 2019-07-30 19:33:45 +0000 | [diff] [blame] | 210 | |
David Bainbridge | 2a0b8a4 | 2019-08-16 17:39:29 +0000 | [diff] [blame] | 211 | # Iterate over yes/no configuration options and validate |
| 212 | for VAR in $ALL_YES_NO; do |
| 213 | eval $VAR=$(verify_yes_no $VAR) |
| 214 | if [ "$(eval echo \$$VAR)" == "INVALID" ]; then |
| 215 | exit 1; |
| 216 | fi |
| 217 | done |
David Bainbridge | b270c20 | 2019-07-26 01:44:42 +0000 | [diff] [blame] | 218 | |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 219 | mkdir -p .voltha |
| 220 | touch .voltha/ports |
| 221 | HAVE=$(grep $NAME .voltha/ports) |
| 222 | if [ "$HAVE X" == " X" ]; then |
| 223 | # Find free port prefix |
| 224 | START=81 |
| 225 | while true; do |
| 226 | if [ $(grep -c $START .voltha/ports) -eq 0 ]; then |
| 227 | break |
| 228 | fi |
| 229 | START=$(expr $START + 1) |
| 230 | done |
| 231 | DELTA=$(expr $START - 81) |
David Bainbridge | a259542 | 2019-10-22 03:54:28 +0000 | [diff] [blame] | 232 | ONOS_API_PORT=${ONOS_API_PORT:-${START}81} |
| 233 | ONOS_SSH_PORT=${ONOS_SSH_PORT:-${START}01} |
| 234 | VOLTHA_API_PORT=${VOLTHA_API_PORT:-5$(expr 55 + $DELTA)55} |
| 235 | VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$(expr 50 + $DELTA)22} |
| 236 | VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$(expr 23 + $DELTA)79} |
David K. Bainbridge | 00ecd38 | 2020-02-28 12:31:58 -0800 | [diff] [blame] | 237 | VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(expr 90 + $DELTA)92} |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 238 | else |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 239 | VALUES=$(echo $HAVE | sed -e 's/\s//g' | cut -d= -f2) |
David Bainbridge | a259542 | 2019-10-22 03:54:28 +0000 | [diff] [blame] | 240 | ONOS_API_PORT=${ONOS_API_PORT:-$(echo $VALUES | cut -d, -f1)} |
| 241 | ONOS_SSH_PORT=${ONOS_SSH_PORT:-$(echo $VALUES | cut -d, -f2)} |
| 242 | VOLTHA_API_PORT=${VOLTHA_API_PORT:-$(echo $VALUES | cut -d, -f3)} |
| 243 | VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$(echo $VALUES | cut -d, -f4)} |
| 244 | VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$(echo $VALUES | cut -d, -f5)} |
David K. Bainbridge | 00ecd38 | 2020-02-28 12:31:58 -0800 | [diff] [blame] | 245 | VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(echo $VALUES | cut -d, -f6)} |
| 246 | |
David K. Bainbridge | 00ecd38 | 2020-02-28 12:31:58 -0800 | [diff] [blame] | 247 | # A bit of a hueristic required here as the KAFKA port forward was |
| 248 | # added after the .voltha/ports files was created. Basically, if |
| 249 | # the VOLTHA_KAFKA_PORT isn't in the file then calculate the original |
| 250 | # DELTA from the VOLTHA_SSH_PORT and apply it to the VOLTHA_KAFKA_PORT |
| 251 | if [ -z "$VOLTHA_KAFKA_PORT" ]; then |
| 252 | DELTA=$((VOLTHA_SSH_PORT/100-50)) |
| 253 | VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(expr 90 + $DELTA)92} |
| 254 | fi |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 255 | fi |
| 256 | |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 257 | PORTTMP=$(mktemp -u) |
| 258 | cat .voltha/ports | grep -v $NAME > $PORTTMP |
David K. Bainbridge | 00ecd38 | 2020-02-28 12:31:58 -0800 | [diff] [blame] | 259 | echo "$NAME=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT,$VOLTHA_KAFKA_PORT" >> $PORTTMP |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 260 | cp $PORTTMP .voltha/ports |
| 261 | rm -f $PORTTMP |
| 262 | |
David Bainbridge | 27790d6 | 2019-08-13 22:43:19 +0000 | [diff] [blame] | 263 | export ONOS_API_PORT ONOS_SSH_PORT |
David Bainbridge | 0129495 | 2019-07-30 19:33:45 +0000 | [diff] [blame] | 264 | |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 265 | IDX=1 |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 266 | CLOCK="TIME:" |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 267 | SPIN_PARTS= |
| 268 | NOT_VERIFIED= |
David Bainbridge | f858a02 | 2019-08-14 21:25:11 +0000 | [diff] [blame] | 269 | THEX= |
| 270 | BUILD= |
| 271 | CROSS= |
| 272 | ENTER= |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 273 | VERIFIED= |
| 274 | HELM= |
| 275 | OLD_KEY= |
| 276 | BIRD= |
| 277 | HIGH_VOLTAGE= |
| 278 | PLUG= |
| 279 | RESTART= |
| 280 | FORWARD= |
| 281 | INSTALL= |
| 282 | STOP= |
| 283 | GO= |
| 284 | DOWNLOAD= |
| 285 | GEAR= |
| 286 | NO_ENTRY= |
| 287 | LOCK= |
| 288 | |
| 289 | if [ $FANCY -eq 1 ]; then |
| 290 | SPIN_PARTS="\ |
| 291 | \xe2\xa2\x8e\xe2\xa1\xb0 \ |
| 292 | \xe2\xa2\x8e\xe2\xa1\xa1 \ |
| 293 | \xe2\xa2\x8e\xe2\xa1\x91 \ |
| 294 | \xe2\xa2\x8e\xe2\xa0\xb1 \ |
| 295 | \xe2\xa0\x8e\xe2\xa1\xb1 \ |
| 296 | \xe2\xa2\x8a\xe2\xa1\xb1 \ |
| 297 | \xe2\xa2\x8c\xe2\xa1\xb1 \ |
| 298 | \xe2\xa2\x86\xe2\xa1\xb1 \ |
| 299 | " |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 300 | CLOCK="\xe2\x8f\xb1" |
David Bainbridge | f858a02 | 2019-08-14 21:25:11 +0000 | [diff] [blame] | 301 | THEX="${RED}${BOLD}\xe2\x9c\x97\x20${NORMAL}" |
| 302 | ENTER="${YELLOW}${BOLD}\xe2\x8e\x86${NORMAL}" |
| 303 | CROSS="${YELLOW}${BOLD}\xe2\x9c\x9a${NORMAL}" |
| 304 | BUILD="${YELLOW}${BOLD}\xf0\x9f\x8f\x97${NORMAL}" |
| 305 | NOT_VERIFIED="$BUILD" |
| 306 | VERIFIED="${GREEN}${BOLD}\xe2\x9c\x93\x20${NORMAL}" |
| 307 | HELM="${BLUE}${BOLD}\xE2\x8E\x88${NORMAL}" |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 308 | OLD_KEY="\xF0\x9F\x97\x9D" |
| 309 | BIRD="\xF0\x9F\x90\xA6" |
| 310 | HIGH_VOLTAGE="\xE2\x9A\xA1" |
| 311 | PLUG="\xF0\x9F\xa7\xa9" |
| 312 | RESTART="\xf0\x9f\x94\x84" |
| 313 | FORWARD="\xE2\x87\xA8" |
| 314 | INSTALL="\xF0\x9F\x8F\x97" |
| 315 | STOP="\xf0\x9f\x9b\x91" |
| 316 | GO="\xf0\x9f\x9a\x80" |
| 317 | DOWNLOAD="\xf0\x9f\x93\xa5" |
| 318 | GEAR="\xe2\x9a\x99" |
| 319 | NO_ENTRY="\xe2\x9b\x94" |
| 320 | LOCK="\xf0\x9f\x94\x92" |
| 321 | fi |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 322 | |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 323 | duration() { |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 324 | local h=$(expr $1 / 3600) |
| 325 | local m=$(expr $1 % 3600 / 60) |
| 326 | local s=$(expr $1 % 60) |
| 327 | local t="" |
| 328 | |
| 329 | if [ $h -gt 0 ]; then |
| 330 | t="$t${h}h" |
| 331 | fi |
| 332 | if [ $m -gt 0 ]; then |
| 333 | t="$t${m}m" |
| 334 | fi |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 335 | echo "$t${s}s" |
| 336 | } |
| 337 | |
| 338 | printtime() { |
| 339 | local INDENT= |
| 340 | if [ "$1" == "-" ]; then |
| 341 | INDENT=" " |
| 342 | shift |
| 343 | fi |
| 344 | echo -e "$INDENT $CLOCK $(duration $1)" |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 345 | } |
| 346 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 347 | bspin() { |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 348 | IDX=1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 349 | local INDENT= |
| 350 | if [ "$1" == "-" ]; then |
| 351 | INDENT=" " |
| 352 | shift |
| 353 | fi |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 354 | if [ $FANCY -eq 0 ]; then |
| 355 | LINE=$(echo $* | sed -e 's/[\s+-]//g') |
| 356 | if [ "$LINE X" == " X" ]; then |
| 357 | return |
| 358 | fi |
| 359 | echo -e "$CIVIS$INDENT$*" |
| 360 | else |
| 361 | echo -en "$CIVIS$INDENT $*" |
| 362 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 363 | } |
| 364 | |
| 365 | sspin() { |
| 366 | local INDENT= |
| 367 | if [ "$1" == "-" ]; then |
| 368 | INDENT=" " |
| 369 | shift |
| 370 | fi |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 371 | if [ $FANCY -eq 0 ]; then |
| 372 | LINE=$(echo $* | sed -e 's/[\s+-]//g') |
| 373 | if [ "$LINE X" == " X" ]; then |
| 374 | return |
| 375 | fi |
| 376 | echo -e "$INDENT$*" |
| 377 | else |
| 378 | C=$(echo $SPIN_PARTS | cut '-d ' -f $IDX) |
| 379 | echo -en "\r$INDENT$C $*" |
| 380 | IDX=$(expr $IDX + 1) |
| 381 | if [ $IDX -gt 8 ]; then |
| 382 | IDX=1 |
| 383 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 384 | fi |
| 385 | } |
| 386 | |
| 387 | espin() { |
| 388 | local INDENT= |
| 389 | if [ "$1" == "-" ]; then |
| 390 | INDENT=" " |
| 391 | shift |
| 392 | fi |
David Bainbridge | 38dc1e8 | 2019-08-12 15:18:45 +0000 | [diff] [blame] | 393 | if [ $FANCY -eq 0 ]; then |
| 394 | LINE=$(echo $* | sed -e 's/[\s+-]//g') |
| 395 | if [ "$LINE X" == " X" ]; then |
| 396 | return |
| 397 | fi |
| 398 | echo -e "$INDENT$*" |
| 399 | else |
| 400 | echo -e "\r$INDENT$*$CNORM" |
| 401 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 402 | } |
| 403 | |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 404 | if [ "$1" == "get" -a "$2" == "voltconfig" ]; then |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 405 | echo "$HOME/.volt/config-$NAME" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 406 | exit |
| 407 | fi |
| 408 | |
Matteo Scandolo | 7ef6ba5 | 2019-10-04 09:20:37 -0700 | [diff] [blame] | 409 | if [ $# -ne 1 -o $(echo ":up:down:dump:" | grep -c ":$1:") -ne 1 ]; then |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 410 | >&2 echo "What wouild you like to do today:" |
| 411 | >&2 echo " up - bring up voltha" |
| 412 | >&2 echo " down - tear down voltha" |
| 413 | >&2 echo " dump - create a debug dump of running system" |
| 414 | exit 1 |
| 415 | fi |
| 416 | |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 417 | push_onos_config() { |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 418 | local TYPE=$1 |
| 419 | local MSG=$2 |
| 420 | local RESOURCE=$3 |
| 421 | local DATA=$4 |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 422 | |
David K. Bainbridge | b4b163b | 2020-02-19 15:55:06 -0800 | [diff] [blame] | 423 | # Thanks to the latest version of ONOS using the return code 207 this gets a |
| 424 | # whole lot nastier. Can't thank them enough for doing this. So in order to |
| 425 | # capture the command and the output in the log file as well as capture the |
| 426 | # status code to verify it is 200 and not 207 mutltiple files and a bit of |
| 427 | # hackery must be used. Thanks again ONOS. |
| 428 | local CMD_ECHO=$(mktemp -u) |
| 429 | local CMD_OUTPUT=$(mktemp -u) |
| 430 | local SC_OUTPUT=$(mktemp -u) |
| 431 | |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 432 | bspin - "$MSG $GEAR" |
| 433 | while true; do |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 434 | if [ $TYPE == "file" ]; then |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 435 | (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 |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 436 | fi |
| 437 | if [ $TYPE == "json" ]; then |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 438 | (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 |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 439 | fi |
David K. Bainbridge | b4b163b | 2020-02-19 15:55:06 -0800 | [diff] [blame] | 440 | RESULT=$? |
| 441 | # Dump everything to the log |
| 442 | cat $CMD_ECHO >> $LOG |
| 443 | cat $CMD_OUTPUT >> $LOG |
| 444 | SC=$(cat $SC_OUTPUT) |
| 445 | |
| 446 | # clean up temp files |
| 447 | rm -f $CMD_ECHO $CMD_OUTPUT $SC_OUTPUT |
| 448 | if [ $RESULT -eq 0 -a "$SC" == "200" ]; then |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 449 | break |
| 450 | fi |
Matteo Scandolo | 9a77a73 | 2020-01-09 14:24:12 -0800 | [diff] [blame] | 451 | sleep 1 |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 452 | sspin - |
| 453 | done |
| 454 | espin - $VERIFIED |
| 455 | } |
| 456 | |
Matteo Scandolo | 9a77a73 | 2020-01-09 14:24:12 -0800 | [diff] [blame] | 457 | check_onos_app_active() { |
| 458 | local APP_ID=$1 |
| 459 | |
| 460 | bspin - "Checking that $APP_ID is active $CLOCK" |
| 461 | while true; do |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 462 | (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 |
Matteo Scandolo | 9a77a73 | 2020-01-09 14:24:12 -0800 | [diff] [blame] | 463 | if [ $? -eq 0 ]; then |
| 464 | break |
| 465 | fi |
| 466 | sleep 1 |
| 467 | sspin - |
| 468 | done |
| 469 | sleep 5 # OSGI components take a little longer that the app to activate |
| 470 | espin - $VERIFIED |
| 471 | } |
| 472 | |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 473 | override_onos_app() { |
| 474 | local APP=$1 |
| 475 | local NAME=$(basename $APP | sed -e 's/^[0-9][0-9]*-//g' -e 's/-.*$//g') |
| 476 | while true; do |
| 477 | sspin - |
| 478 | # Attempt to delete old version (if it exists) |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 479 | (set -x; curl --fail -sSL --user karaf:karaf -X DELETE http://$_ONOS_API_EP/onos/v1/applications/$NAME >>$LOG 2>&1) >>$LOG 2>&1 |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 480 | sspin - |
| 481 | if [ $? -ne 0 ]; then |
| 482 | continue |
| 483 | fi |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 484 | (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 |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 485 | if [ $? -eq 0 ]; then |
| 486 | break |
| 487 | fi |
| 488 | sleep .2 |
| 489 | done |
| 490 | } |
| 491 | |
| 492 | activate_onos_app() { |
| 493 | local MSG="$1" |
| 494 | local APP=$2 |
| 495 | |
| 496 | bspin - "$MSG $GO" |
| 497 | while true; do |
| 498 | sspin - |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 499 | (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 |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 500 | if [ $? -eq 0 ]; then |
| 501 | break |
| 502 | fi |
| 503 | sleep .2 |
| 504 | done |
| 505 | espin - "$VERIFIED" |
| 506 | } |
| 507 | |
| 508 | count_pods() { |
| 509 | local NAMESPACE=$1; shift |
| 510 | if [ "$NAMESPACE" == "all-namespaces" ]; then |
| 511 | NAMESPACE="--all-namespaces" |
| 512 | else |
| 513 | NAMESPACE="-n $NAMESPACE" |
| 514 | fi |
| 515 | echo "$NAMESPACE" > /tmp/t |
| 516 | local STATES=$1; shift |
| 517 | echo "$STATES" >> /tmp/t |
| 518 | local PODS=$(kubectl get $NAMESPACE pod -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}") |
| 519 | local COUNT=0 |
| 520 | local PATTERNS="$*" |
| 521 | for POD in $PODS; do |
| 522 | local NAME=$(echo $POD | cut -d/ -f 1) |
| 523 | local STATE=$(echo $POD | cut -d/ -f 2) |
| 524 | local CONTAINERS=$(echo $POD | cut -d/ -f 3 | sed -e 's/_/ /g') |
| 525 | if [ "$STATES" == "*" -o $(echo "$STATES" | grep -c ":$STATE:") -ne 0 ]; then |
| 526 | echo "IN WITH $POD" >> /tmp/t |
| 527 | local TOTAL=$(echo $CONTAINERS | wc -w) |
| 528 | local FOUND=$(echo $CONTAINERS | grep -o true | wc -l) |
| 529 | if [ $TOTAL -eq $FOUND ]; then |
| 530 | for PATTERN in $PATTERNS; do |
| 531 | echo "TEST $PATTERN AGAINST $NAME" >> /tmp/t |
| 532 | if [[ $NAME =~ $PATTERN ]]; then |
| 533 | echo "COUNT $NAME" >> /tmp/t |
| 534 | COUNT=$(expr $COUNT + 1) |
| 535 | break |
| 536 | fi |
| 537 | done |
| 538 | fi |
| 539 | fi |
| 540 | done |
| 541 | echo $COUNT >> /tmp/t |
| 542 | echo $COUNT |
| 543 | } |
| 544 | |
| 545 | wait_for_pods() { |
| 546 | local INDENT= |
| 547 | if [ "$1" == "-" ]; then |
| 548 | INDENT=$1; shift |
| 549 | fi |
| 550 | local NAMESPACE=$1; shift |
| 551 | local EXPECT=$1; shift |
| 552 | local TYPE=$1; shift |
| 553 | local RETRY=$1; shift |
| 554 | local MESSAGE=$1; shift |
| 555 | local PATTERNS=$* |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 556 | local STATES=":Running:" |
| 557 | if [ "$TYPE" == "not" ]; then |
| 558 | STATES="*" |
| 559 | fi |
| 560 | local HAVE=$(count_pods $NAMESPACE "$STATES" $PATTERNS) |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 561 | local ALL=$HAVE |
| 562 | if [ "$TYPE" == "only" ]; then |
| 563 | ALL=$(count_pods "all-namespaces" "*" ".*") |
| 564 | fi |
| 565 | COUNT=$(expr 300 / 15) |
| 566 | bspin $INDENT $MESSAGE |
| 567 | sspin $INDENT |
| 568 | if [ $HAVE -ne $EXPECT -o $ALL -ne $HAVE ]; then |
| 569 | while [ $HAVE -ne $EXPECT -o $ALL -ne $HAVE ]; do |
| 570 | sspin $INDENT |
| 571 | COUNT=$(expr $COUNT - 1) |
| 572 | if [ $COUNT -eq 0 ]; then |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 573 | HAVE=$(count_pods $NAMESPACE "$STATES" $PATTERNS) |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 574 | ALL=$HAVE |
| 575 | if [ "$TYPE" == "only" ]; then |
| 576 | ALL=$(count_pods "all-namespaces" "*" ".*") |
| 577 | fi |
| 578 | COUNT=$(expr 300 / 15) |
| 579 | fi |
| 580 | sleep .15 |
| 581 | done |
| 582 | fi |
| 583 | espin $INDENT $VERIFIED |
| 584 | if [ $HAVE -ne $EXPECT ]; then |
| 585 | return 1 |
| 586 | fi |
| 587 | return 0 |
| 588 | } |
| 589 | |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 590 | port_forward() { |
| 591 | local NS=$1 |
| 592 | local SVC=$2 |
| 593 | local FROM_PORT=$3 |
| 594 | local TO_PORT=$4 |
| 595 | local TAG=$SVC-$NAME |
| 596 | |
| 597 | (set -x; _TAG=$TAG bash -c "while true; do kubectl port-forward -n $NS service/$SVC $FROM_PORT:$TO_PORT; done" >>$LOG 2>&1 &) >>$LOG 2>&1 |
| 598 | } |
| 599 | |
| 600 | kill_port_forward() { |
| 601 | local TAG=$1-$NAME |
David Bainbridge | c6871d2 | 2019-11-13 17:10:31 +0000 | [diff] [blame] | 602 | local P_IDS=$(ps e -ww -A | grep "_TAG=$TAG" | grep -v grep | awk '{print $1}') |
David Bainbridge | bcf235b | 2019-11-12 21:33:58 +0000 | [diff] [blame] | 603 | local PARENTS= |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 604 | local KIDS= |
David Bainbridge | c6871d2 | 2019-11-13 17:10:31 +0000 | [diff] [blame] | 605 | local UNKNOWN= |
| 606 | if [ ! -z "$P_IDS" ]; then |
| 607 | for P_ID in $P_IDS; do |
| 608 | local PP_ID=$(ps -o ppid $P_ID | tail -n +2) |
| 609 | if [ ! -z "$PP_ID" ]; then |
| 610 | if [ $PP_ID -eq 1 ]; then |
| 611 | PARENTS="$PARENTS $P_ID" |
| 612 | else |
| 613 | KIDS="$KIDS $P_ID" |
| 614 | fi |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 615 | else |
David Bainbridge | c6871d2 | 2019-11-13 17:10:31 +0000 | [diff] [blame] | 616 | UNKNOWN="$UNKNOWN $P_ID" |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 617 | fi |
| 618 | done |
David Bainbridge | c6871d2 | 2019-11-13 17:10:31 +0000 | [diff] [blame] | 619 | (set -x; kill -9 $PARENTS $KIDS $UNKNOWN >>$LOG 2>&1) >>$LOG 2>&1 |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 620 | fi |
| 621 | } |
| 622 | |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 623 | if [ "$1" == "down" ]; then |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 624 | echo "Tearing down voltha cluster $NAME" |
| 625 | LOG="down-$NAME.log" |
| 626 | echo $(date -u +"%Y%m%dT%H%M%SZ") >$LOG |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 627 | bspin "Remove port-forwards: onos-ui-$NAME" |
| 628 | kill_port_forward onos-ui |
| 629 | sspin "Remove port-forwards: onos-ssh-$NAME$CEOL" |
| 630 | kill_port_forward onos-ssh |
| 631 | sspin "Remove port-forwards: voltha-api-$NAME$CEOL" |
| 632 | kill_port_forward voltha-api |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 633 | sspin "Remove port-forwards: voltha-etcd-$NAME$CEOL" |
| 634 | kill_port_forward voltha-etcd-cluster-client |
David K. Bainbridge | 00ecd38 | 2020-02-28 12:31:58 -0800 | [diff] [blame] | 635 | sspin "Remove port-forwards: voltha-kafka-$NAME$CEOL" |
| 636 | kill_port_forward voltha-kafka |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 637 | espin "$VERIFIED Remove port-forwards$CEOL" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 638 | if [ $DEPLOY_K8S == "yes" ]; then |
| 639 | if [ -x ./bin/kind ]; then |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 640 | bspin "Delete Kubernetes Kind Cluster" |
| 641 | (set -x; ./bin/kind delete cluster --name voltha-$NAME >>$LOG 2>&1) >>$LOG 2>&1 |
| 642 | espin $VERIFIED |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 643 | else |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 644 | espin "$NO_ENTRY Delete Kubernetes Kind Cluster: kind command not found" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 645 | fi |
| 646 | else |
| 647 | EXISTS=$(helm list -q) |
| 648 | EXPECT="etcd-operator onos open-olt open-onu sim voltha bbsim radius" |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 649 | bspin "Remove Helm Deployments" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 650 | for i in $EXISTS; do |
David K. Bainbridge | 4342240 | 2020-03-06 07:41:22 -0800 | [diff] [blame^] | 651 | for j in $EXPECT; do |
| 652 | if [[ $i =~ $j ]]; then |
| 653 | sspin "Remove Helm Deployments: $i$CEOL" |
| 654 | (set -x; ./bin/helm delete --no-hooks --purge $i >>$LOG 2>&1) >>$LOG 2>&1 |
| 655 | fi |
| 656 | done |
uottremb | b16d398 | 2020-02-28 08:34:36 +0100 | [diff] [blame] | 657 | done |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 658 | espin "$VERIFIED Remove Helm Deployments$CEOL" |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 659 | if [ "$WAIT_ON_DOWN" == "yes" ]; then |
| 660 | # There should only be 13 or 15 PODs in the kube-system name |
| 661 | # space and no other PODs |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 662 | PODS="coredns-.* \ |
| 663 | etcd-voltha-$NAME-control-plane \ |
| 664 | kindnet-.* \ |
| 665 | kube-apiserver-voltha-$NAME-control-plane \ |
| 666 | kube-controller-manager-voltha-$NAME-control-plane \ |
| 667 | kube-proxy-.* \ |
| 668 | kube-scheduler-voltha-$NAME-control-plane \ |
| 669 | tiller-deploy-.*" |
| 670 | EXPECT=$(test "$TYPE" == "minimal" && echo "13" || echo "15") |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 671 | PODS="adapter-.* \ |
| 672 | bbsim.* \ |
| 673 | etcd-operator.* \ |
| 674 | radius.* \ |
| 675 | voltha-.*" |
Matteo Scandolo | 73442f9 | 2020-01-29 09:53:22 -0800 | [diff] [blame] | 676 | |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 677 | EXPECT=0 |
| 678 | |
Matteo Scandolo | 73442f9 | 2020-01-29 09:53:22 -0800 | [diff] [blame] | 679 | if [ "$WITH_ONOS" == "yes" ]; then |
| 680 | ONOS_PODS="onos-.*" |
| 681 | wait_for_pods "default" $EXPECT "not" -1 "Waiting for ONOS PODs to terminate" $ONOS_PODS |
| 682 | fi |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 683 | wait_for_pods "voltha" $EXPECT "not" -1 "Waiting for VOLTHA PODs to terminate" $PODS |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 684 | fi |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 685 | fi |
Matteo Scandolo | 7ef6ba5 | 2019-10-04 09:20:37 -0700 | [diff] [blame] | 686 | exit |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 687 | fi |
| 688 | |
| 689 | if [ "$1" == "dump" ]; then |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 690 | LOG="dump-$NAME.log" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 691 | TS=$(date -u +"%Y%m%dT%H%M%SZ") |
David Bainbridge | 76514a0 | 2019-10-08 01:50:35 +0000 | [diff] [blame] | 692 | if [ ! -z "$DUMP_FROM" ]; then |
| 693 | TS=$(echo $DUMP_FROM | sed -e 's/[:-]//g') |
| 694 | fi |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 695 | WORK=$(mktemp -u -d) |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 696 | DATA=$WORK/voltha-debug-dump-$NAME-$TS |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 697 | mkdir -p $DATA |
| 698 | echo $TS > $LOG |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 699 | echo -e "Capturing debug dump to voltha-debug-dump-$NAME-$TS.tgz" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 700 | bspin - "Copy install log" |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 701 | if [ -f install-$NAME.log ]; then |
| 702 | (set -x; cp install-$NAME.log $DATA/install-$NAME.log) >>$LOG 2>&1 |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 703 | espin - $VERIFIED |
| 704 | else |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 705 | espin - "$NO_ENTRY Copy install log: install-$NAME.log not found" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 706 | fi |
| 707 | bspin - "Dumping Kubernetes PODs" |
| 708 | (set -x; kubectl get --all-namespaces pods >> $DATA/all-pods.txt 2>&1) >>$LOG 2>&1 |
| 709 | espin - $VERIFIED |
| 710 | bspin - "Dumping Kubernetes SERVICEs" |
| 711 | (set -x; kubectl get --all-namespaces svc >> $DATA/all-services.txt 2>&1) >>$LOG 2>&1 |
| 712 | espin - $VERIFIED |
| 713 | bspin - "Dumping Kubernetes EVENTs" |
| 714 | (set -x; kubectl get --all-namespaces events >> $DATA/all-events.txt 2>&1) >>$LOG 2>&1 |
| 715 | espin - $VERIFIED |
| 716 | bspin - "Dumping VOLTHA POD details" |
Matteo Scandolo | dcd29f5 | 2019-10-07 15:42:42 -0700 | [diff] [blame] | 717 | PODS="$(kubectl -n default get pod -o name | grep onos | sed -e 's/^/default:/g') $(kubectl get -n voltha pod -o name | sed -e 's/^/voltha:/g')" |
David Bainbridge | cfd7ca1 | 2019-10-06 03:31:41 +0000 | [diff] [blame] | 718 | SINCE= |
| 719 | if [ ! -z "$DUMP_FROM" ]; then |
| 720 | SINCE="--since-time=$DUMP_FROM" |
| 721 | fi |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 722 | for POD in $PODS; do |
David Bainbridge | 1f0655a | 2019-10-01 22:08:48 +0000 | [diff] [blame] | 723 | NS=$(echo $POD | cut -d: -f1) |
| 724 | POD=$(echo $POD | cut -d: -f2) |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 725 | sspin - "Dumping VOLTHA POD details: $POD$CEOL" |
| 726 | mkdir -p $DATA/$POD |
David Bainbridge | 1f0655a | 2019-10-01 22:08:48 +0000 | [diff] [blame] | 727 | (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] | 728 | sspin - "Dumping VOLTHA POD details: $POD" |
David Bainbridge | cfd7ca1 | 2019-10-06 03:31:41 +0000 | [diff] [blame] | 729 | (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] | 730 | sspin - "Dumping VOLTHA POD details: $POD" |
David Bainbridge | cfd7ca1 | 2019-10-06 03:31:41 +0000 | [diff] [blame] | 731 | (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] | 732 | sspin - "Dumping VOLTHA POD details: $POD" |
| 733 | done |
| 734 | espin - "$VERIFIED Dumping VOLTHA POD details$CEOL" |
| 735 | bspin - "Dumping ETCD" |
| 736 | if [ "$(which etcdctl) X" != " X" ]; then |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 737 | (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 |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 738 | espin - $VERIFIED |
| 739 | else |
| 740 | espin - "$NO_ENTRY Dumping ETCD: etcdctl command not available" |
| 741 | fi |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 742 | bspin - "Creating compressed TAR: voltha-debug-dump-$NAME-$TS.tgz" |
| 743 | (set -x; tar -C $WORK -zcf voltha-debug-dump-$NAME-$TS.tgz ./voltha-debug-dump-$NAME-$TS) >>$LOG 2>&1 |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 744 | espin - $VERIFIED |
| 745 | bspin - "Cleanup" |
| 746 | (set -x; rm -rf $WORK) >>$LOG 2>&1 |
| 747 | espin - $VERIFIED |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 748 | bspin - "$(ls -l voltha-debug-dump-$NAME-$TS.tgz)" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 749 | espin - $VERIFIED |
| 750 | exit |
| 751 | fi |
| 752 | |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 753 | LOG="install-$NAME.log" |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 754 | date > $LOG |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 755 | 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] | 756 | |
| 757 | # Output install options to log |
| 758 | echo "OPTIONS" >> $LOG |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 759 | for O in $ALL_OPTIONS; do |
| 760 | VAL=$(eval echo \$$O) |
David Bainbridge | ac7f807 | 2019-08-01 22:15:33 +0000 | [diff] [blame] | 761 | if [ ! -z "$VAL" ]; then |
| 762 | printf " %-30s = %s\n" $O $VAL >> $LOG |
| 763 | fi |
| 764 | done |
| 765 | |
Matteo Scandolo | 7ef6ba5 | 2019-10-04 09:20:37 -0700 | [diff] [blame] | 766 | helm_install() { |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 767 | local INDENT= |
| 768 | if [ "$1" == "-" ]; then |
| 769 | INDENT=$1; shift |
| 770 | fi |
| 771 | local NAMESPACE=$1; shift |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 772 | local INAME=$1; shift |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 773 | local CHART=$1; shift |
David Bainbridge | 90fd8e3 | 2019-08-21 23:32:47 +0000 | [diff] [blame] | 774 | local CHART_VERSION=$1; shift |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 775 | local MESSAGE=$* |
| 776 | |
David Bainbridge | 90fd8e3 | 2019-08-21 23:32:47 +0000 | [diff] [blame] | 777 | if [ "$CHART_VERSION X" != " X" -a "$CHART_VERSION" != "latest" ]; then |
| 778 | CHART_VERSION="--version $CHART_VERSION" |
| 779 | else |
| 780 | CHART_VERSION= |
| 781 | fi |
| 782 | |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 783 | local CHART_ARGS= |
| 784 | if [ -r "${INAME}-values.yaml" ]; then |
| 785 | CHART_ARGS="-f ${INAME}-values.yaml" |
| 786 | fi |
| 787 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 788 | COUNT=$(expr 300 / 15) |
| 789 | bspin $INDENT $MESSAGE |
David Bainbridge | 70c0ea8 | 2019-11-14 23:25:26 +0000 | [diff] [blame] | 790 | (set -x; helm install -f $NAME-values.yaml $CHART_ARGS $EXTRA_HELM_INSTALL_ARGS --set defaults.log_level=$VOLTHA_LOG_LEVEL --namespace $NAMESPACE --name $INAME $CHART_VERSION $EXTRA_HELM_FLAGS $CHART >>$LOG 2>&1) >>$LOG 2>&1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 791 | SUCCESS=$? |
| 792 | while [ $SUCCESS -ne 0 ]; do |
| 793 | sspin $INDENT |
| 794 | COUNT=$(expr $COUNT - 1) |
| 795 | if [ $COUNT -eq 0 ]; then |
Andy Bavier | e22ff25 | 2019-12-19 11:40:31 -0700 | [diff] [blame] | 796 | (set -x; helm delete --purge $INAME >>$LOG 2>&1) >>$LOG 2>&1 |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 797 | (set -x; helm install -f $NAME-values.yaml $CHART_ARGS --set defaults.log_level=$VOLTHA_LOG_LEVEL --namespace $NAMESPACE --name $INAME $CHART_VERSION $EXTRA_HELM_FLAGS $CHART >>$LOG 2>&1) >>$LOG 2>&1 |
Andy Bavier | e22ff25 | 2019-12-19 11:40:31 -0700 | [diff] [blame] | 798 | SUCCESS=$? |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 799 | COUNT=$(expr 300 / 15) |
| 800 | fi |
| 801 | sleep .15 |
| 802 | done |
| 803 | espin $INDENT $VERIFIED |
| 804 | } |
| 805 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 806 | echo "INSTALL TYPE: $TYPE" >> $LOG |
| 807 | |
| 808 | bspin "Verify GOPATH" |
| 809 | export GOPATH=$(pwd) |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 810 | mkdir -p $GOPATH/bin |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 811 | espin $VERIFIED |
| 812 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 813 | STIME=$(date +%s) |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 814 | if [ "$INSTALL_KUBECTL" == "no" ]; then |
| 815 | bspin "Skip kubectl install" |
| 816 | espin $NO_ENTRY |
Test User | c13bdc9 | 2019-07-03 20:57:49 +0000 | [diff] [blame] | 817 | else |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 818 | bspin "Verify kubectl $HELM" |
| 819 | if [ -x $GOPATH/bin/kubectl ]; then |
| 820 | espin $VERIFIED |
| 821 | else |
| 822 | espin $NOT_VERIFIED |
| 823 | bspin - "Download and install Kubernetes/kubectl $DOWNLOAD" |
| 824 | (set -x; curl -o $GOPATH/bin/kubectl -sSL https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/$HOSTOS/$HOSTARCH/kubectl >>$LOG 2>&1) >>$LOG 2>&1 |
| 825 | (set -x; chmod 755 $GOPATH/bin/kubectl >>$LOG 2>&1) >>$LOG 2>&1 |
| 826 | espin - $VERIFIED |
| 827 | fi |
Test User | c13bdc9 | 2019-07-03 20:57:49 +0000 | [diff] [blame] | 828 | fi |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 829 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 830 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 831 | fi |
Test User | c13bdc9 | 2019-07-03 20:57:49 +0000 | [diff] [blame] | 832 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 833 | STIME=$(date +%s) |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 834 | if [ "$DEPLOY_K8S" == "no" ]; then |
| 835 | bspin "Skip Kubernetes/Kind Deployment" |
| 836 | espin $NO_ENTRY |
| 837 | else |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 838 | bspin "Verify Kubernetes/Kind $HELM" |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 839 | IS_INSTALLED=0 |
| 840 | OP_TYPE="install" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 841 | if [ -x $GOPATH/bin/kind ]; then |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 842 | OP_TYPE="upgrade" |
| 843 | if [ $($GOPATH/bin/kind --version | grep -c $KIND_VERSION) -eq 1 ]; then |
| 844 | IS_INSTALLED=1 |
| 845 | espin $VERIFIED |
| 846 | fi |
| 847 | fi |
| 848 | if [ $IS_INSTALLED -eq 0 ]; then |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 849 | espin $NOT_VERIFIED |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 850 | bspin - "Download and $OP_TYPE Kubernetes/kind $DOWNLOAD" |
David Bainbridge | 9e2a666 | 2019-07-11 17:07:57 +0000 | [diff] [blame] | 851 | (set -x; curl -o $GOPATH/bin/kind -sSL https://github.com/kubernetes-sigs/kind/releases/download/$KIND_VERSION/kind-$HOSTOS-$HOSTARCH >>$LOG 2>&1) >>$LOG 2>&1 |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 852 | (set -x; chmod 755 $GOPATH/bin/kind >>$LOG 2>&1) >>$LOG 2>&1 |
| 853 | espin - $VERIFIED |
| 854 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 855 | fi |
| 856 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 857 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 858 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 859 | fi |
| 860 | |
| 861 | STIME=$(date +%s) |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 862 | if [ "$INSTALL_HELM" == "no" ]; then |
| 863 | bspin "Skip Helm Install" |
| 864 | espin $NO_ENTRY |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 865 | else |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 866 | bspin "Verify Helm $HELM" |
| 867 | if [ -x $GOPATH/bin/helm ]; then |
| 868 | espin $VERIFIED |
| 869 | else |
| 870 | espin $NOT_VERIFIED |
| 871 | bspin - "Download and install Helm $DOWNLOAD" |
David Bainbridge | c6a6eb6 | 2019-10-18 22:50:07 +0000 | [diff] [blame] | 872 | (set -x; curl -sSL https://git.io/get_helm.sh | DESIRED_VERSION=v2.14.3 USE_SUDO=false HELM_INSTALL_DIR=$GOPATH/bin bash >>$LOG 2>&1) >>$LOG 2>&1 |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 873 | espin - $VERIFIED |
| 874 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 875 | fi |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 876 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 877 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 878 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 879 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 880 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 881 | STIME=$(date +%s) |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 882 | bspin "Verify voltctl $HIGH_VOLTAGE" |
David Bainbridge | d281197 | 2019-12-14 01:14:09 +0000 | [diff] [blame] | 883 | VOK=0 |
| 884 | VMESSAGE="install" |
David K. Bainbridge | ebf38d9 | 2020-02-10 10:46:31 -0800 | [diff] [blame] | 885 | export VC_VERSION="$VOLTCTL_VERSION" |
| 886 | if [ "$VC_VERSION" == "latest" ]; then |
| 887 | export VC_VERSION=$(curl -sSL https://api.github.com/repos/opencord/voltctl/releases/latest | jq -r .tag_name | sed -e 's/^v//g') |
| 888 | fi |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 889 | if [ -x $GOPATH/bin/voltctl ]; then |
David Bainbridge | 1ba64f1 | 2019-12-18 00:40:13 +0000 | [diff] [blame] | 890 | VHAVE=$($GOPATH/bin/voltctl version --clientonly -o json | jq -r .version) |
David K. Bainbridge | ebf38d9 | 2020-02-10 10:46:31 -0800 | [diff] [blame] | 891 | if [ $? -eq 0 -a "$VHAVE" == "$VC_VERSION" ]; then |
David Bainbridge | d281197 | 2019-12-14 01:14:09 +0000 | [diff] [blame] | 892 | VOK=1 |
David Bainbridge | 1ba64f1 | 2019-12-18 00:40:13 +0000 | [diff] [blame] | 893 | espin $VERIFIED |
| 894 | else |
David K. Bainbridge | ebf38d9 | 2020-02-10 10:46:31 -0800 | [diff] [blame] | 895 | VCHECK=$(echo -e "$VHAVE\n$VC_VERSION" | sort -V | head -1) |
| 896 | if [ "$VCHECK" == "$VHAVE" ]; then |
| 897 | VMESSAGE="upgrade" |
| 898 | else |
| 899 | VMESSAGE="downgrade" |
| 900 | fi |
David Bainbridge | d281197 | 2019-12-14 01:14:09 +0000 | [diff] [blame] | 901 | fi |
| 902 | fi |
| 903 | |
David Bainbridge | 1ba64f1 | 2019-12-18 00:40:13 +0000 | [diff] [blame] | 904 | if [ $VOK -eq 0 ]; then |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 905 | espin $NOT_VERIFIED |
David Bainbridge | d281197 | 2019-12-14 01:14:09 +0000 | [diff] [blame] | 906 | bspin - "Download and $VMESSAGE voltctl $DOWNLOAD" |
David K. Bainbridge | ebf38d9 | 2020-02-10 10:46:31 -0800 | [diff] [blame] | 907 | (set -x; curl -o $GOPATH/bin/voltctl -sSL https://github.com/opencord/voltctl/releases/download/v$VC_VERSION/voltctl-$VC_VERSION-$HOSTOS-$HOSTARCH >>$LOG 2>&1) >>$LOG 2>&1 |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 908 | (set -x; chmod 755 $GOPATH/bin/voltctl >>$LOG 2>&1) >>$LOG 2>&1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 909 | espin - $VERIFIED |
| 910 | fi |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 911 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 912 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 913 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 914 | |
| 915 | bspin "Verify command PATH" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 916 | export PATH=$GOPATH/bin:$PATH |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 917 | espin $VERIFIED |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 918 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 919 | STIME=$(date +%s) |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 920 | if [ "$DEPLOY_K8S" == "yes" ]; then |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 921 | HAVE=$(kind get clusters | grep -c voltha-$NAME) |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 922 | bspin "Verify Kubernetes/Kind Cluster" |
| 923 | sspin |
| 924 | if [ $HAVE -eq 0 ]; then |
David Bainbridge | 491b1bd | 2019-07-11 17:53:11 +0000 | [diff] [blame] | 925 | espin $NOT_VERIFIED |
| 926 | bspin - "Verify cluster configuration" |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 927 | if [ ! -r ./$NAME-cluster.cfg ]; then |
David Bainbridge | 491b1bd | 2019-07-11 17:53:11 +0000 | [diff] [blame] | 928 | espin - $NOT_VERIFIED |
David K. Bainbridge | 4342240 | 2020-03-06 07:41:22 -0800 | [diff] [blame^] | 929 | bspin - "Download cluster configuration: $TYPE-cluster.cfg to $NAME-cluster.cfg $DOWNLOAD" |
David K. Bainbridge | a00736b | 2020-01-08 14:33:17 -0800 | [diff] [blame] | 930 | ERR_OUT=$(mktemp) |
| 931 | (set -x; curl --fail -o ./$NAME-cluster.cfg -sSL https://raw.githubusercontent.com/ciena/kind-voltha/$VK_RELEASE/$TYPE-cluster.cfg >>$LOG 2>>$ERR_OUT) >>$LOG 2>&1 |
| 932 | if [ $? -ne 0 ]; then |
| 933 | espin - $THEX |
| 934 | echo -e "${RED}${BOLD}${ERROR}ERROR: $NAME-cluster.cfg${NORMAL}${RED} - $(cat $ERR_OUT)${NORMAL}" |
| 935 | echo "ERROR: $(cat $ERR_OUT)" >>$LOG |
| 936 | rm -rf $ERR_OUT ./$NAME-cluster.cfg |
| 937 | exit 1 |
| 938 | fi |
| 939 | rm -rf $ERR_OUT |
| 940 | else |
David K. Bainbridge | 4342240 | 2020-03-06 07:41:22 -0800 | [diff] [blame^] | 941 | espin - $VERIFIED |
David K. Bainbridge | a00736b | 2020-01-08 14:33:17 -0800 | [diff] [blame] | 942 | fi |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 943 | kind create cluster --name voltha-$NAME --config $NAME-cluster.cfg |
David Bainbridge | 491b1bd | 2019-07-11 17:53:11 +0000 | [diff] [blame] | 944 | else |
| 945 | espin $VERIFIED |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 946 | fi |
| 947 | |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 948 | export KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$NAME")" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 949 | P="coredns-.* \ |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 950 | etcd-voltha-$NAME-control-plane \ |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 951 | kindnet-.* \ |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 952 | kube-apiserver-voltha-$NAME-control-plane \ |
| 953 | kube-controller-manager-voltha-$NAME-control-plane \ |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 954 | kube-proxy-.* \ |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 955 | kube-scheduler-voltha-$NAME-control-plane" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 956 | |
| 957 | EXPECT=$(test "$TYPE" == "minimal" && echo "12" || echo "14") |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 958 | wait_for_pods - "kube-system" $EXPECT "includes" -1 "Waiting for system PODs to start" $P |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 959 | fi |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 960 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 961 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 962 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 963 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 964 | STIME=$(date +%s) |
David Bainbridge | 4c6289c | 2019-09-03 21:11:32 +0000 | [diff] [blame] | 965 | COUNT=$(count_pods "kube-system" ":Running:" "tiller-deploy-.*") |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 966 | bspin "Verify Helm" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 967 | if [ $COUNT -ne 1 ]; then |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 968 | espin $NOT_VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 969 | echo -e "Configuring Helm $GEAR" |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 970 | if [ "$INSTALL_HELM" == "no" ]; then |
| 971 | bspin - "Skip Helm/Tiller Initialization" |
| 972 | espin - $NO_ENTRY |
| 973 | else |
| 974 | bspin - "Initialize Helm" |
| 975 | (set -x; helm init --upgrade >>$LOG 2>&1) >>$LOG 2>&1 |
| 976 | espin - $VERIFIED |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 977 | wait_for_pods - "kube-system" 1 "includes" -1 "Waiting for Tiller POD to start" "tiller-deploy-.*" |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 978 | fi |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 979 | bspin - "Add Google Incubator repository to Helm" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 980 | (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1 |
| 981 | espin - $VERIFIED |
Matteo Scandolo | 7ef6ba5 | 2019-10-04 09:20:37 -0700 | [diff] [blame] | 982 | |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 983 | # HACK (sort-of) - the config for tiller is about to be patched, which will |
| 984 | # cause the tiller pod to be recreated. This can sometimes cause a timing |
| 985 | # 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] | 986 | # 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] | 987 | # 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] | 988 | # 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] | 989 | # things |
| 990 | (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] | 991 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 992 | bspin - "Add Google Stable repository to Helm" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 993 | (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1 |
| 994 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 995 | bspin - "Add ONF repository to Helm" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 996 | (set -x; helm repo add onf https://charts.opencord.org >>$LOG 2>&1) >>$LOG 2>&1 |
| 997 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 998 | bspin - "Update Helm repository cache" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 999 | (set -x; helm repo update >>$LOG 2>&1) >>$LOG 2>&1 |
| 1000 | espin - $VERIFIED |
Matteo Scandolo | 7ef6ba5 | 2019-10-04 09:20:37 -0700 | [diff] [blame] | 1001 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1002 | # Create and k8s service account so that Helm can create pods |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 1003 | bspin - "Create Tiller ServiceAccount" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1004 | (set -x; kubectl create serviceaccount --namespace kube-system tiller >>$LOG 2>&1) >>$LOG 2>&1 |
| 1005 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 1006 | bspin - "Create Tiller ClusterRoleBinding" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1007 | (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>$LOG 2>&1) >>$LOG 2>&1 |
| 1008 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 1009 | bspin - "Update Tiller Manifest" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1010 | (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] | 1011 | |
| 1012 | # HACK (sort-of) - part to, spin it back up |
| 1013 | (set -x; kubectl -n kube-system scale deploy tiller-deploy --replicas=1 >>$LOG 2>&1) >>$LOG 2>&1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1014 | espin - $VERIFIED |
| 1015 | else |
| 1016 | espin $VERIFIED |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 1017 | if [ "$UPDATE_HELM_REPOS" == "yes" ]; then |
| 1018 | bspin - "Update Helm repository cache" |
| 1019 | (set -x; helm repo update >>$LOG 2>&1) >>$LOG 2>&1 |
| 1020 | espin - $VERIFIED |
| 1021 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1022 | fi |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 1023 | wait_for_pods - "kube-system" 1 "includes" -1 "Waiting for Tiller POD to start" "tiller-deploy-.*" |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1024 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 1025 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1026 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1027 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1028 | STIME=$(date +%s) |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1029 | bspin "Verify Helm values file: $NAME-values.yaml" |
| 1030 | if [ ! -r "./$NAME-values.yaml" ]; then |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1031 | espin $NOT_VERIFIED |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1032 | bspin - "Download Helm values file: $TYPE-values.yaml to $NAME-values.yaml $DOWNLOAD" |
David K. Bainbridge | a00736b | 2020-01-08 14:33:17 -0800 | [diff] [blame] | 1033 | ERR_OUT=$(mktemp) |
| 1034 | (set -x; curl --fail -o ./$NAME-values.yaml -sSL https://raw.githubusercontent.com/ciena/kind-voltha/$VK_RELEASE/$TYPE-values.yaml >>$LOG 2>$ERR_OUT) >>$LOG 2>&1 |
| 1035 | if [ $? -ne 0 ]; then |
| 1036 | espin - $THEX |
| 1037 | echo -e "${RED}${BOLD}${ERROR}ERROR: $NAME-values.yaml${NORMAL}${RED} - $(cat $ERR_OUT)${NORMAL}" |
| 1038 | echo "ERROR: $(cat $ERR_OUT)" >>$LOG |
| 1039 | rm -rf $ERR_OUT ./$NAME-values.yaml |
| 1040 | exit 1 |
| 1041 | fi |
| 1042 | rm -rf $ERR_OUT |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1043 | espin - $VERIFIED |
| 1044 | else |
| 1045 | espin $VERIFIED |
| 1046 | fi |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1047 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 1048 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1049 | fi |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1050 | |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 1051 | STIME=$(date +%s) |
| 1052 | bspin "Verify or download chart specific values files $DOWNLOAD" |
| 1053 | VALUES_FILES="monkey-values.yaml" |
David K. Bainbridge | a00736b | 2020-01-08 14:33:17 -0800 | [diff] [blame] | 1054 | ERR_OUT=$(mktemp) |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 1055 | for i in $VALUES_FILES; do |
| 1056 | if [ ! -r ./$i ]; then |
David K. Bainbridge | a00736b | 2020-01-08 14:33:17 -0800 | [diff] [blame] | 1057 | (set -x; curl --fail -o ./$i -sSL https://raw.githubusercontent.com/ciena/kind-voltha/$VK_RELEASE/$i >>$LOG 2>$ERR_OUT) >>$LOG 2>&1 |
| 1058 | if [ $? -ne 0 ]; then |
| 1059 | espin $THEX |
| 1060 | echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat $ERR_OUT)${NORMAL}" |
| 1061 | echo "ERROR: $i - $(cat $ERR_OUT)" >>$LOG |
| 1062 | rm -rf $ERR_OUT ./$i |
| 1063 | exit 1 |
| 1064 | fi |
| 1065 | rm -rf $ERR_OUT |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 1066 | fi |
| 1067 | done |
| 1068 | espin $VERIFIED |
| 1069 | if [ "$WITH_TIMINGS" == "yes" ]; then |
| 1070 | printtime $(expr $(date +%s) - $STIME) |
| 1071 | fi |
| 1072 | |
| 1073 | if [ "$WITH_CHAOS" == "yes" ]; then |
| 1074 | bspin "Verify or clone kube-monkey helm chart $DOWNLOAD" |
| 1075 | if [ -r ./kube-monkey ]; then |
| 1076 | espin $VERIFIED |
| 1077 | else |
| 1078 | espin $NOT_VERIFIED |
| 1079 | bspin - "GIT clone kube-monkey" |
| 1080 | (set -x; git clone https://github.com/asobti/kube-monkey kube-monkey >>$LOG 2>&1) >>$LOG 2>&1 |
| 1081 | espin - $VERIFIED |
| 1082 | fi |
| 1083 | fi |
| 1084 | |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1085 | if [ "$JUST_K8S" == "yes" ]; then |
| 1086 | echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye." |
| 1087 | echo "" |
| 1088 | echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG |
| 1089 | echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG |
| 1090 | echo "tools required by VOLTHA in your command path. " | tee -a $LOG |
| 1091 | echo "" | tee -a $LOG |
| 1092 | echo -en $BOLD |
| 1093 | if [ $DEPLOY_K8S == "yes" ]; then |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1094 | 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] | 1095 | fi |
| 1096 | echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG |
| 1097 | echo -en $NORMAL |
| 1098 | echo "" | tee -a $LOG |
| 1099 | echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG |
| 1100 | exit 0 |
| 1101 | fi |
| 1102 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1103 | STIME=$(date +%s) |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 1104 | bspin "Verify ETCD Operator $OLD_KEY" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 1105 | if [ $(helm list --deployed --short --namespace voltha "^etcd-operator\$" | wc -l) -ne 1 ]; then |
Matteo Scandolo | 7ef6ba5 | 2019-10-04 09:20:37 -0700 | [diff] [blame] | 1106 | espin $NOT_VERIFIED |
David Bainbridge | 90fd8e3 | 2019-08-21 23:32:47 +0000 | [diff] [blame] | 1107 | helm_install - voltha etcd-operator stable/etcd-operator latest "Install ETCD Operator" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1108 | else |
| 1109 | espin $VERIFIED |
| 1110 | fi |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 1111 | EXPECT=$(test "$TYPE" == "minimal" && echo "1" || echo "3") |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 1112 | wait_for_pods - "voltha" $EXPECT "includes" -1 "Waiting for ETCD Operator to start" "etcd-operator-.*" |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1113 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 1114 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1115 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1116 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1117 | STIME=$(date +%s) |
David Bainbridge | b270c20 | 2019-07-26 01:44:42 +0000 | [diff] [blame] | 1118 | if [ $WITH_ONOS == "yes" ]; then |
| 1119 | bspin "Verify ONOS installed $BIRD" |
| 1120 | if [ $(helm list --deployed --short --namespace default "^onos\$" | wc -l) -ne 1 ]; then |
| 1121 | espin $NOT_VERIFIED |
Andrea Campanella | 6afcb08 | 2019-12-18 16:51:30 -0800 | [diff] [blame] | 1122 | EXTRA_HELM_FLAGS="$SET_TAG $EXTRA_HELM_FLAGS" helm_install - default onos onf/onos $ONOS_CHART_VERSION "Install ONOS" |
David Bainbridge | b270c20 | 2019-07-26 01:44:42 +0000 | [diff] [blame] | 1123 | else |
| 1124 | espin $VERIFIED |
| 1125 | fi |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 1126 | wait_for_pods - "default" 1 "includes" -1 "Waiting for ONOS to start" "onos-.*" |
Matteo Scandolo | 7ef6ba5 | 2019-10-04 09:20:37 -0700 | [diff] [blame] | 1127 | |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 1128 | if [ $WITH_PORT_FORWARDS == "yes" ]; then |
| 1129 | bspin - "Forward ONOS API port $FORWARD" |
| 1130 | kill_port_forward onos-ui |
| 1131 | port_forward default onos-ui $ONOS_API_PORT 8181 |
| 1132 | espin - $VERIFIED |
| 1133 | bspin - "Forward ONOS SSH port $FORWARD" |
| 1134 | kill_port_forward onos-ssh |
| 1135 | port_forward default onos-ssh $ONOS_SSH_PORT 8101 |
| 1136 | espin - $VERIFIED |
| 1137 | _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT" |
| 1138 | else |
| 1139 | _ONOS_API_EP=$(get_service_ep default onos-ui) |
| 1140 | fi |
David Bainbridge | d31d612 | 2019-08-13 19:37:59 +0000 | [diff] [blame] | 1141 | bspin - "Verify or download ONOS configuration support files $DOWNLOAD" |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 1142 | ONOS_FILES="olt-onos-enableExtraneousRules.json onos-aaa.json \ |
David Bainbridge | 90fd8e3 | 2019-08-21 23:32:47 +0000 | [diff] [blame] | 1143 | onos-dhcpl2relay.json onos-kafka.json onos-sadis-sample.json" |
David Bainbridge | d31d612 | 2019-08-13 19:37:59 +0000 | [diff] [blame] | 1144 | (set -x; mkdir -p ./onos-files >>$LOG 2>&1) >>$LOG 2>&1 |
David K. Bainbridge | a00736b | 2020-01-08 14:33:17 -0800 | [diff] [blame] | 1145 | ERR_OUT=$(mktemp) |
David Bainbridge | 2b19e83 | 2019-08-16 02:40:53 +0000 | [diff] [blame] | 1146 | for i in $ONOS_FILES; do |
David Bainbridge | d31d612 | 2019-08-13 19:37:59 +0000 | [diff] [blame] | 1147 | if [ ! -r ./onos-files/$i ]; then |
David K. Bainbridge | a00736b | 2020-01-08 14:33:17 -0800 | [diff] [blame] | 1148 | (set -x; curl --fail -o ./onos-files/$i -sSL https://raw.githubusercontent.com/ciena/kind-voltha/$VK_RELEASE/onos-files/$i >>$LOG 2>$ERR_OUT) >>$LOG 2>&1 |
| 1149 | if [ $? -ne 0 ]; then |
| 1150 | espin - $THEX |
| 1151 | echo -e "${RED}${BOLD}${ERROR}ERROR: $i${NORMAL}${RED} - $(cat $ERR_OUT)${NORMAL}" |
| 1152 | echo "ERROR: $(cat $ERR_OUT)" >>$LOG |
| 1153 | rm -rf $ERR_OUT ./onos-files/$i |
| 1154 | exit 1 |
| 1155 | fi |
| 1156 | rm -rf $ERR_OUT |
David Bainbridge | d31d612 | 2019-08-13 19:37:59 +0000 | [diff] [blame] | 1157 | fi |
| 1158 | done |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1159 | espin - $VERIFIED |
David Bainbridge | 27790d6 | 2019-08-13 22:43:19 +0000 | [diff] [blame] | 1160 | |
| 1161 | if [ $INSTALL_ONOS_APPS == "yes" ]; then |
| 1162 | bspin - "Installing custom ONOS applications" |
| 1163 | if [ -x onos-files/onos-apps -a $(ls -1 onos-files/onos-apps/*.oar 2>/dev/null | wc -l) -gt 0 ]; then |
| 1164 | for OAR in $(ls -1 onos-files/onos-apps/*.oar); do |
| 1165 | sspin - "Installing custom ONOS applications - $OAR$CEOL" |
David Bainbridge | 2b19e83 | 2019-08-16 02:40:53 +0000 | [diff] [blame] | 1166 | override_onos_app $OAR |
David Bainbridge | 27790d6 | 2019-08-13 22:43:19 +0000 | [diff] [blame] | 1167 | done |
| 1168 | espin - "$VERIFIED Installing custom ONOS applications$CEOL" |
| 1169 | else |
| 1170 | espin - "$NOT_VERIFIED Installing custom ONOS applications - None Found" |
| 1171 | fi |
| 1172 | fi |
Matteo Scandolo | 7ef6ba5 | 2019-10-04 09:20:37 -0700 | [diff] [blame] | 1173 | |
Matteo Scandolo | 9a77a73 | 2020-01-09 14:24:12 -0800 | [diff] [blame] | 1174 | check_onos_app_active org.opencord.kafka |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 1175 | push_onos_config "file" "Push ONOS Kafka Configuration" "network/configuration/apps/org.opencord.kafka" "onos-files/onos-kafka.json" |
Matteo Scandolo | 9a77a73 | 2020-01-09 14:24:12 -0800 | [diff] [blame] | 1176 | check_onos_app_active org.opencord.dhcpl2relay |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 1177 | 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] | 1178 | check_onos_app_active org.opencord.olt |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 1179 | # FIXME use WITH_DHCP and WITH_EAPOL flags to configre OLT App |
Hardik Windlass | a7501fb | 2020-02-17 14:28:20 +0000 | [diff] [blame] | 1180 | # Default value for "enableEapol" is true in OLT App |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 1181 | if [ $WITH_EAPOL == "yes" ]; then |
| 1182 | push_onos_config "json" "Enable VOLTHA ONOS EAPOL provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableEapol":true}' |
Hardik Windlass | a7501fb | 2020-02-17 14:28:20 +0000 | [diff] [blame] | 1183 | elif [ $WITH_EAPOL == "no" ]; then |
| 1184 | 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] | 1185 | fi |
Hardik Windlass | a7501fb | 2020-02-17 14:28:20 +0000 | [diff] [blame] | 1186 | # Default value for "enableDhcpOnProvisioning" is false and for "enableDhcpV4" is true in OLT App |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 1187 | if [ $WITH_DHCP == "yes" ]; then |
| 1188 | push_onos_config "json" "Enable VOLTHA ONOS DHCP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableDhcpOnProvisioning":true,"enableDhcpV4":true}' |
Hardik Windlass | a7501fb | 2020-02-17 14:28:20 +0000 | [diff] [blame] | 1189 | elif [ $WITH_DHCP == "no" ]; then |
| 1190 | 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] | 1191 | fi |
Hardik Windlass | a7501fb | 2020-02-17 14:28:20 +0000 | [diff] [blame] | 1192 | # Default value for "enableIgmpOnProvisioning" is false in OLT App |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 1193 | if [ $WITH_IGMP == "yes" ]; then |
| 1194 | push_onos_config "json" "Enable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":true}' |
Hardik Windlass | a7501fb | 2020-02-17 14:28:20 +0000 | [diff] [blame] | 1195 | elif [ $WITH_IGMP == "no" ]; then |
| 1196 | 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] | 1197 | fi |
David K. Bainbridge | 484d80c | 2020-03-05 21:44:34 -0800 | [diff] [blame] | 1198 | if [ $ENABLE_ONOS_EXTRANEOUS_RULES == "yes" ]; then |
| 1199 | push_onos_config "file" "Enabling extraneous rules for ONOS" "configuration/org.onosproject.net.flow.impl.FlowRuleManager" "onos-files/olt-onos-enableExtraneousRules.json" |
| 1200 | fi |
David Bainbridge | 2b19e83 | 2019-08-16 02:40:53 +0000 | [diff] [blame] | 1201 | if [ -f onos-files/onos-sadis.json ]; then |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 1202 | push_onos_config "file" "[optional] Push ONOS SADIS Configuration" "network/configuration/apps/org.opencord.sadis" "onos-files/onos-sadis.json" |
David Bainbridge | 2b19e83 | 2019-08-16 02:40:53 +0000 | [diff] [blame] | 1203 | elif [ "$CONFIG_SADIS" == "yes" ]; then |
David Bainbridge | 90fd8e3 | 2019-08-21 23:32:47 +0000 | [diff] [blame] | 1204 | SADIS_CFG=onos-files/onos-sadis-sample.json |
Matteo Scandolo | 9a77a73 | 2020-01-09 14:24:12 -0800 | [diff] [blame] | 1205 | check_onos_app_active org.opencord.sadis |
Matteo Scandolo | 78dfee0 | 2020-02-13 16:18:03 -0800 | [diff] [blame] | 1206 | push_onos_config "file" "[optional] Push ONOS SADIS Configuration" "network/configuration/apps/org.opencord.sadis" "$SADIS_CFG" |
David Bainbridge | 2b19e83 | 2019-08-16 02:40:53 +0000 | [diff] [blame] | 1207 | fi |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1208 | fi |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1209 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 1210 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1211 | fi |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1212 | |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1213 | STIME=$(date +%s) |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 1214 | bspin "Verify VOLTHA installed $HIGH_VOLTAGE" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 1215 | if [ $(helm list --deployed --short --namespace voltha "^voltha\$" | wc -l) -ne 1 ]; then |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1216 | espin $NOT_VERIFIED |
David Bainbridge | 70c0ea8 | 2019-11-14 23:25:26 +0000 | [diff] [blame] | 1217 | if [ "$ONLY_ONE" == "yes" ]; then |
| 1218 | EXTRA_HELM_INSTALL_ARGS="--set therecanbeonlyone=true"= |
| 1219 | fi |
David Bainbridge | 90fd8e3 | 2019-08-21 23:32:47 +0000 | [diff] [blame] | 1220 | helm_install - voltha voltha $VOLTHA_CHART $VOLTHA_CHART_VERSION "Install VOLTHA Core" |
David Bainbridge | 70c0ea8 | 2019-11-14 23:25:26 +0000 | [diff] [blame] | 1221 | EXTRA_HELM_INSTALL_ARGS= |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1222 | else |
| 1223 | espin $VERIFIED |
| 1224 | fi |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1225 | |
David Bainbridge | 90fd8e3 | 2019-08-21 23:32:47 +0000 | [diff] [blame] | 1226 | VOLTHA="voltha-ofagent-.* \ |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1227 | ro-core.* \ |
| 1228 | rw-core.* \ |
| 1229 | voltha-api-server-.* \ |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1230 | voltha-etcd-cluster-.* \ |
| 1231 | voltha-kafka-.* \ |
| 1232 | voltha-zookeeper-.*" |
David Bainbridge | 70c0ea8 | 2019-11-14 23:25:26 +0000 | [diff] [blame] | 1233 | if [ "$ONLY_ONE" == "yes" ]; then |
David Bainbridge | 1ba64f1 | 2019-12-18 00:40:13 +0000 | [diff] [blame] | 1234 | EXPECT=$(test "$TYPE" == "minimal" && echo "5" || echo "7") |
David Bainbridge | 70c0ea8 | 2019-11-14 23:25:26 +0000 | [diff] [blame] | 1235 | else |
David Bainbridge | 1ba64f1 | 2019-12-18 00:40:13 +0000 | [diff] [blame] | 1236 | EXPECT=$(test "$TYPE" == "minimal" && echo "8" || echo "10") |
David Bainbridge | 70c0ea8 | 2019-11-14 23:25:26 +0000 | [diff] [blame] | 1237 | fi |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 1238 | wait_for_pods - "voltha" $EXPECT "includes" -1 "Waiting for VOLTHA Core to start" $VOLTHA |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1239 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 1240 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1241 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1242 | |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 1243 | if [ "$WITH_ADAPTERS" == "yes" ]; then |
| 1244 | STIME=$(date +%s) |
| 1245 | EXPECT=0 |
| 1246 | echo -e "Verify Adapters $PLUG" |
| 1247 | if [ "$WITH_SIM_ADAPTERS" == "yes" ]; then |
| 1248 | bspin - "Verify Simulated Adapters installed" |
| 1249 | if [ $(helm list --deployed --short --namespace voltha "^sim\$" | wc -l) -ne 1 ]; then |
| 1250 | espin - $NOT_VERIFIED |
| 1251 | helm_install - voltha sim $VOLTHA_ADAPTER_SIM_CHART $VOLTHA_ADAPTER_SIM_CHART_VERSION "Install Simulated Adapters" |
| 1252 | else |
| 1253 | espin - $VERIFIED |
| 1254 | fi |
| 1255 | EXPECT=$(expr $EXPECT + 2) |
| 1256 | fi |
Matteo Scandolo | 7ef6ba5 | 2019-10-04 09:20:37 -0700 | [diff] [blame] | 1257 | |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 1258 | if [ "$WITH_OPEN_ADAPTERS" == "yes" ]; then |
| 1259 | bspin - "Verify OpenOLT Adapter installed" |
| 1260 | if [ $(helm list --deployed --short --namespace voltha "^open-olt\$" | wc -l) -ne 1 ]; then |
| 1261 | espin - $NOT_VERIFIED |
| 1262 | helm_install - voltha open-olt $VOLTHA_ADAPTER_OPEN_OLT_CHART $VOLTHA_ADAPTER_OPEN_OLT_CHART_VERSION "Install OpenOLT Adapter" |
| 1263 | else |
| 1264 | espin - $VERIFIED |
| 1265 | fi |
| 1266 | bspin - "Verify OpenONU Adapter installed" |
| 1267 | if [ $(helm list --deployed --short --namespace voltha "^open-onu\$" | wc -l) -ne 1 ]; then |
| 1268 | espin - $NOT_VERIFIED |
| 1269 | helm_install - voltha open-onu $VOLTHA_ADAPTER_OPEN_ONU_CHART $VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION "Install OpenONU Adapter" |
| 1270 | else |
| 1271 | espin - $VERIFIED |
| 1272 | fi |
| 1273 | EXPECT=$(expr $EXPECT + 2) |
| 1274 | fi |
Matteo Scandolo | 7ef6ba5 | 2019-10-04 09:20:37 -0700 | [diff] [blame] | 1275 | |
David Bainbridge | 46505fb | 2019-10-01 21:13:20 +0000 | [diff] [blame] | 1276 | ADAPTERS="adapter-.*" |
| 1277 | wait_for_pods - "voltha" $EXPECT "includes" -1 "Waiting for adapters to start" $ADAPTERS |
| 1278 | if [ "$WITH_TIMINGS" == "yes" ]; then |
| 1279 | printtime $(expr $(date +%s) - $STIME) |
| 1280 | fi |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1281 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 1282 | |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 1283 | if [ $WITH_BBSIM == "yes" ]; then |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1284 | STIME=$(date +%s) |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 1285 | echo -e "Verify BBSIM $PLUG" |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 1286 | bspin - "Verify BBSIM Installed" |
David K. Bainbridge | 4342240 | 2020-03-06 07:41:22 -0800 | [diff] [blame^] | 1287 | for instance in $(seq 0 $(($NUM_OF_BBSIM-1))); do |
| 1288 | if [ $instance -eq 0 ]; then |
| 1289 | instance_num="" |
| 1290 | else |
| 1291 | instance_num=$instance |
| 1292 | fi |
| 1293 | if [ $(helm list --deployed --short --namespace voltha "^bbsim${instance_num}\$" | wc -l) -ne 1 ]; then |
| 1294 | espin - $NOT_VERIFIED |
| 1295 | helm_install - voltha bbsim${instance_num} $VOLTHA_BBSIM_CHART $VOLTHA_BBSIM_CHART_VERSION "Install BBSIM${instance_num}" |
| 1296 | else |
| 1297 | espin - $VERIFIED |
| 1298 | fi |
| 1299 | done |
uottremb | b16d398 | 2020-02-28 08:34:36 +0100 | [diff] [blame] | 1300 | wait_for_pods - "voltha" $NUM_OF_BBSIM "includes" -1 "Waiting for BBSIM to start" "bbsim*" |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1301 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 1302 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1303 | fi |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 1304 | fi |
| 1305 | |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 1306 | if [ $WITH_RADIUS == "yes" ]; then |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1307 | STIME=$(date +%s) |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 1308 | echo -e "Verify RADIUS $LOCK" |
| 1309 | bspin - "Verify RADIUS Installed" |
| 1310 | if [ $(helm list --deployed --short --namespace voltha "^radius\$" | wc -l) -ne 1 ]; then |
| 1311 | espin - $NOT_VERIFIED |
David Bainbridge | 90fd8e3 | 2019-08-21 23:32:47 +0000 | [diff] [blame] | 1312 | helm_install - voltha radius onf/freeradius latest "Install RADIUS" |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 1313 | else |
| 1314 | espin - $VERIFIED |
| 1315 | fi |
David Bainbridge | 4f1b556 | 2019-08-19 04:46:52 +0000 | [diff] [blame] | 1316 | wait_for_pods - "voltha" 1 "includes" -1 "Waiting for RADIUS to start" "radius-.*" |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1317 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 1318 | printtime $(expr $(date +%s) - $STIME) |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1319 | fi |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 1320 | fi |
| 1321 | |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 1322 | if [ $WITH_PORT_FORWARDS == "yes" ]; then |
| 1323 | STIME=$(date +%s) |
| 1324 | bspin - "Forward VOLTHA API port $FORWARD" |
| 1325 | kill_port_forward voltha-api |
| 1326 | port_forward voltha voltha-api $VOLTHA_API_PORT 55555 |
| 1327 | espin - $VERIFIED |
| 1328 | bspin - "Forward VOLTHA ETCD port $FORWARD" |
| 1329 | kill_port_forward voltha-etcd-cluster-client |
| 1330 | port_forward voltha voltha-etcd-cluster-client $VOLTHA_ETCD_PORT 2379 |
| 1331 | espin - $VERIFIED |
| 1332 | bspin - "Forward VOLTHA Kafka port $FORWARD" |
| 1333 | kill_port_forward voltha-kafka |
| 1334 | port_forward voltha voltha-kafka $VOLTHA_KAFKA_PORT 9092 |
| 1335 | espin - $VERIFIED |
| 1336 | if [ "$WITH_TIMINGS" == "yes" ]; then |
| 1337 | printtime $(expr $(date +%s) - $STIME) |
| 1338 | fi |
David Bainbridge | e87067b | 2019-08-12 22:00:12 +0000 | [diff] [blame] | 1339 | fi |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 1340 | |
David Bainbridge | b270c20 | 2019-07-26 01:44:42 +0000 | [diff] [blame] | 1341 | if [ $WITH_ONOS == "yes" -a $WITH_RADIUS == "yes" ]; then |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 1342 | bspin "Configure ONOS RADIUS Connection $GEAR" |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 1343 | (set -x; cat onos-files/onos-aaa.json | sed -e "s/:RADIUS_IP:/$(kubectl -n voltha get service/radius -o jsonpath={.spec.clusterIP})/g" | 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 |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 1344 | espin $VERIFIED |
| 1345 | fi |
| 1346 | |
David Bainbridge | 99ac7a2 | 2019-08-31 02:26:43 +0000 | [diff] [blame] | 1347 | if [ "$WITH_CHAOS" == "yes" ]; then |
| 1348 | STIME=$(date +%s) |
| 1349 | echo -e "Verify kube-monkey $LOCK" |
| 1350 | bspin - "Verify kube-monkey Installed" |
| 1351 | if [ $(helm list --deployed --short --namespace kube-monkey "^monkey\$" | wc -l) -ne 1 ]; then |
| 1352 | espin - $NOT_VERIFIED |
| 1353 | helm_install - kube-monkey monkey ./kube-monkey/helm/kubemonkey latest "Install Chaos Monkey" |
| 1354 | else |
| 1355 | espin - $VERIFIED |
| 1356 | fi |
| 1357 | wait_for_pods - "kube-monkey" 1 "includes" -1 "Waiting for Chaos to start" "monkey-.*" |
| 1358 | if [ "$WITH_TIMINGS" == "yes" ]; then |
| 1359 | printtime $(expr $(date +%s) - $STIME) |
| 1360 | fi |
| 1361 | fi |
| 1362 | |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 1363 | bspin "Create voltctl configuration file" |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 1364 | (set -x; mkdir -p $HOME/.volt >>$LOG 2>&1) >>$LOG 2>&1 |
David K. Bainbridge | 4a06a4a | 2020-03-02 14:15:23 -0800 | [diff] [blame] | 1365 | if [ $WITH_PORT_FORWARDS == "yes" ]; then |
| 1366 | (set -x; voltctl -a v3 -k localhost:$VOLTHA_KAFKA_PORT -s localhost:$VOLTHA_API_PORT config > $HOME/.volt/config-$NAME 2>>$LOG) >>$LOG 2>&1 |
| 1367 | else |
| 1368 | (set -x; voltctl -a v3 -k $(get_service_ep voltha voltha-kafka) -s $(get_service_ep voltha voltha-api) config > $HOME/.volt/config-$NAME 2>>$LOG) >>$LOG 2>&1 |
| 1369 | fi |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 1370 | espin $VERIFIED |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 1371 | |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1372 | if [ ! -f "$NAME-env.sh" ]; then |
| 1373 | touch $NAME-env.sh |
David Bainbridge | b07fdf7 | 2019-07-29 22:51:40 +0000 | [diff] [blame] | 1374 | fi |
| 1375 | |
David Bainbridge | 596f30d | 2019-07-30 17:07:59 +0000 | [diff] [blame] | 1376 | for O in $ALL_OPTIONS; do |
| 1377 | VAL=$(eval echo \$$O) |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1378 | if [ ! -z "$VAL" -a $(grep -c "^export $O=" $NAME-env.sh) -eq 0 ]; then |
| 1379 | echo "export $O=\"$(eval echo \$$O)\"" >> $NAME-env.sh |
David Bainbridge | b07fdf7 | 2019-07-29 22:51:40 +0000 | [diff] [blame] | 1380 | fi |
| 1381 | done |
| 1382 | |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1383 | if [ $DEPLOY_K8S == "yes" -a $(grep -c "^export KUBECONFIG=" $NAME-env.sh) -eq 0 ]; then |
| 1384 | 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] | 1385 | fi |
| 1386 | |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1387 | if [ $(grep -c "^export VOLTCONFIG=" $NAME-env.sh) -eq 0 ]; then |
| 1388 | echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" >> $NAME-env.sh |
David Bainbridge | b07fdf7 | 2019-07-29 22:51:40 +0000 | [diff] [blame] | 1389 | fi |
| 1390 | |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1391 | if [ $(grep -c "^export PATH=" $NAME-env.sh) -eq 0 ]; then |
| 1392 | echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> $NAME-env.sh |
David Bainbridge | b07fdf7 | 2019-07-29 22:51:40 +0000 | [diff] [blame] | 1393 | fi |
| 1394 | |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 1395 | echo "" |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 1396 | echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG |
| 1397 | echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG |
| 1398 | echo "tools required by VOLTHA in your command path. " | tee -a $LOG |
| 1399 | echo "" | tee -a $LOG |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 1400 | echo -en $BOLD |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1401 | if [ $DEPLOY_K8S == "yes" ]; then |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1402 | 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] | 1403 | fi |
David Bainbridge | 0774b23 | 2019-08-02 06:37:19 +0000 | [diff] [blame] | 1404 | echo "export VOLTCONFIG=\"$HOME/.volt/config-$NAME\"" | tee -a $LOG |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 1405 | echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 1406 | echo -en $NORMAL |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 1407 | echo "" | tee -a $LOG |
| 1408 | echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG |
| 1409 | |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 1410 | if [ "$WITH_TIMINGS" == "yes" ]; then |
David Bainbridge | f858a02 | 2019-08-14 21:25:11 +0000 | [diff] [blame] | 1411 | echo -e "$CLOCK ${BOLD}TOTAL: $(duration $(expr $(date +%s) - $TOTAL_START_TIME))${NORMAL}" |
David Bainbridge | 712afb8 | 2019-08-14 19:55:58 +0000 | [diff] [blame] | 1412 | fi |