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