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. |
| 15 | |
| 16 | # trap ctrl-c and call ctrl_c() |
| 17 | trap ctrl_c INT |
| 18 | |
| 19 | function ctrl_c() { |
| 20 | tput cnorm |
| 21 | echo "" |
| 22 | echo "ctrl-c trapped" |
| 23 | echo "Thank you for trying 'votlha up'" |
| 24 | exit |
| 25 | } |
| 26 | |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 27 | VOLTCTL_VERSION=${VOLTCTL_VERSION:-0.0.5-dev} |
| 28 | KIND_VERSION=${KIND_VERSION:-v0.4.0} |
| 29 | _VOLTCTL_VERSION=$(echo $VOLTCTL_VERSION | sed -e 's/-/_/g') |
| 30 | |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 31 | BLACK=$(tput setaf 0) |
| 32 | RED=$(tput setaf 1) |
| 33 | GREEN=$(tput setaf 2) |
| 34 | YELLOW=$(tput setaf 3) |
| 35 | BLUE=$(tput setaf 4) |
| 36 | MAGENTA=$(tput setaf 5) |
| 37 | CYAN=$(tput setaf 6) |
| 38 | WHITE=$(tput setaf 7) |
| 39 | BOLD=$(tput bold) |
| 40 | NORMAL=$(tput sgr0) |
| 41 | ERROR="\xe2\x9c\x97\x20" |
| 42 | |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 43 | TYPE=${TYPE:-minimal} |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 44 | WITH_BBSIM=${WITH_BBSIM:-no} |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 45 | WITH_RADIUS=${WITH_RADIUS:-no} |
David Bainbridge | b270c20 | 2019-07-26 01:44:42 +0000 | [diff] [blame] | 46 | WITH_ONOS=${WITH_ONOS:-yes} |
David Bainbridge | 0129495 | 2019-07-30 19:33:45 +0000 | [diff] [blame^] | 47 | WITH_TP=${WITH_TP:-yes} |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 48 | JUST_K8S=${JUST_K8S:-no} |
| 49 | DEPLOY_K8S=${DEPLOY_K8S:-yes} |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame] | 50 | SKIP_RESTART_API=${SKIP_RESTART_API:-no} |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 51 | INSTALL_KUBECTL=${INSTALL_KUBECTL:-yes} |
| 52 | INSTALL_HELM=${INSTALL_HELM:-yes} |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 53 | USE_GO=${USE_GO:-yes} |
| 54 | VOLTHA_LOG_LEVEL=${VOLTHA_LOG_LEVEL:-WARN} |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame] | 55 | VOLTHA_CHART=${VOLTHA_CHART:=onf/voltha} |
| 56 | VOLTHA_ADAPTER_SIM_CHART=${VOLTHA_ADAPTER_SIM_CHART:-onf/voltha-adapter-simulated} |
| 57 | VOLTHA_ADAPTER_OPEN_OLT_CHART=${VOLTHA_ADAPTER_OPEN_OLT_CHART:-onf/voltha-adapter-openolt} |
| 58 | VOLTHA_ADAPTER_OPEN_ONU_CHART=${VOLTHA_ADAPTER_OPEN_ONU_CHART:-onf/voltha-adapter-openonu} |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 59 | |
| 60 | HAVE_GO=$(which go >/dev/null 2>&1 && echo "yes" || echo "no") |
| 61 | HOSTOS=$(uname -s | tr "[:upper:]" "[:lower:"]) |
| 62 | HOSTARCH=$(uname -m | tr "[:upper:]" "[:lower:"]) |
| 63 | if [ $HOSTARCH == "x86_64" ]; then |
| 64 | HOSTARCH="amd64" |
| 65 | fi |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 66 | |
| 67 | # Verify TYPE setting |
| 68 | if [ $(echo ":minimal:full:" | grep -ic ":$TYPE:") -eq 0 ]; then |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 69 | >&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] | 70 | exit 1 |
| 71 | fi |
| 72 | |
| 73 | # Verify WITH_BBSIM settting and convert uniform value of yes or no |
| 74 | if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_BBSIM:") -eq 0 ]; then |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 75 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_BBSIM value of '$WITH_BBSIM'. Should be 'yes' or 'no'${NORMAL}" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 76 | exit 1 |
| 77 | fi |
| 78 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_BBSIM:") -eq 1 ]; then |
| 79 | WITH_BBSIM=yes |
| 80 | else |
| 81 | WITH_BBSIM=no |
| 82 | fi |
| 83 | |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 84 | # Verify WITH_RADIUS settting and convert uniform value of yes or no |
| 85 | if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_RADIUS:") -eq 0 ]; then |
| 86 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_RADIUS value of '$WITH_RADIUS'. Should be 'yes' or 'no'${NORMAL}" |
| 87 | exit 1 |
| 88 | fi |
| 89 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_RADIUS:") -eq 1 ]; then |
| 90 | WITH_RADIUS=yes |
| 91 | else |
| 92 | WITH_RADIUS=no |
| 93 | fi |
| 94 | |
David Bainbridge | 0129495 | 2019-07-30 19:33:45 +0000 | [diff] [blame^] | 95 | # Verify WITH_TP settting and convert uniform value of yes or no |
| 96 | if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_TP:") -eq 0 ]; then |
| 97 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_TP value of '$WITH_TP'. Should be 'yes' or 'no'${NORMAL}" |
| 98 | exit 1 |
| 99 | fi |
| 100 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_TP:") -eq 1 ]; then |
| 101 | WITH_TP=yes |
| 102 | else |
| 103 | WITH_TP=no |
| 104 | fi |
| 105 | |
David Bainbridge | b270c20 | 2019-07-26 01:44:42 +0000 | [diff] [blame] | 106 | # Verify WITH_ONOS settting and convert uniform value of yes or no |
| 107 | if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$WITH_ONOS:") -eq 0 ]; then |
| 108 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$WITH_ONOS value of '$WITH_ONOS'. Should be 'yes' or 'no'${NORMAL}" |
| 109 | exit 1 |
| 110 | fi |
| 111 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$WITH_ONOS:") -eq 1 ]; then |
| 112 | WITH_ONOS=yes |
| 113 | else |
| 114 | WITH_ONOS=no |
| 115 | fi |
| 116 | |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 117 | # Verify JUST_K8S settting and convert uniform value of yes or no |
| 118 | if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$JUST_K8S:") -eq 0 ]; then |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 119 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$JUST_K8S value of '$JUST_K8S'. Should be 'yes' or 'no'${NORMAL}" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 120 | exit 1 |
| 121 | fi |
| 122 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$JUST_K8S:") -eq 1 ]; then |
| 123 | JUST_K8S=yes |
| 124 | else |
| 125 | JUST_K8S=no |
| 126 | fi |
| 127 | |
| 128 | # Verify DEPLOY_K8S settting and convert uniform value of yes or no |
| 129 | if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$DEPLOY_K8S:") -eq 0 ]; then |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 130 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$DEPLOY_K8S value of '$DEPLOY_K8S'. Should be 'yes' or 'no'${NORMAL}" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 131 | exit 1 |
| 132 | fi |
| 133 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$DEPLOY_K8S:") -eq 1 ]; then |
| 134 | DEPLOY_K8S=yes |
| 135 | else |
| 136 | DEPLOY_K8S=no |
| 137 | fi |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 138 | |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 139 | # Verify INSTALL_KUBECTL settting and convert uniform value of yes or no |
| 140 | if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$INSTALL_KUBECTL:") -eq 0 ]; then |
| 141 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$INSTALL_KUBECTL value of '$INSTALL_KUBECTL'. Should be 'yes' or 'no'${NORMAL}" |
| 142 | exit 1 |
| 143 | fi |
| 144 | |
| 145 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$INSTALL_KUBECTL:") -eq 1 ]; then |
| 146 | INSTALL_KUBECTL=yes |
| 147 | else |
| 148 | INSTALL_KUBECTL=no |
| 149 | fi |
| 150 | |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame] | 151 | # Verify SKIP_RESTART_API settting and convert uniform value of yes or no |
| 152 | if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$SKIP_RESTART_API:") -eq 0 ]; then |
| 153 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$SKIP_RESTART_API value of '$SKIP_RESTART_API'. Should be 'yes' or 'no'${NORMAL}" |
| 154 | exit 1 |
| 155 | fi |
| 156 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$SKIP_RESTART_API:") -eq 1 ]; then |
| 157 | SKIP_RESTART_API=yes |
| 158 | else |
| 159 | SKIP_RESTART_API=no |
| 160 | fi |
| 161 | |
David Bainbridge | 1ceabc1 | 2019-07-25 17:21:05 +0000 | [diff] [blame] | 162 | # Verify USE_GO settting and convert uniform value of yes or no |
| 163 | if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$USE_GO:") -eq 0 ]; then |
| 164 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$USE_GO value of '$USE_GO'. Should be 'yes' or 'no'${NORMAL}" |
| 165 | exit 1 |
| 166 | fi |
| 167 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$USE_GO:") -eq 1 ]; then |
| 168 | USE_GO=true |
| 169 | else |
| 170 | USE_GO=false |
| 171 | fi |
| 172 | |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 173 | # Verify INSTALL_HELM settting and convert uniform value of yes or no |
| 174 | if [ $(echo ":y:yes:true:n:no:false:1:0:" | grep -ic ":$INSTALL_HELM:") -eq 0 ]; then |
| 175 | >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$INSTALL_HELM value of '$INSTALL_HELM'. Should be 'yes' or 'no'${NORMAL}" |
| 176 | exit 1 |
| 177 | fi |
| 178 | |
| 179 | if [ $(echo ":y:yes:true:1:" | grep -ic ":$INSTALL_HELM:") -eq 1 ]; then |
| 180 | INSTALL_HELM=yes |
| 181 | else |
| 182 | INSTALL_HELM=no |
| 183 | fi |
| 184 | |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 185 | if [ "$TYPE" == "full" ]; then |
David Bainbridge | 0129495 | 2019-07-30 19:33:45 +0000 | [diff] [blame^] | 186 | ONOS_API_PORT=${ONOS_API_PORT:-8182} |
| 187 | ONOS_SSH_PORT=${ONOS_SSH_PORT:-8102} |
| 188 | VOLTHA_API_PORT=${VOLTHA_API_PORT:-55556} |
| 189 | VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-5023} |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 190 | else |
| 191 | ONOS_API_PORT=${ONOS_API_PORT:-8181} |
| 192 | ONOS_SSH_PORT=${ONOS_SSH_PORT:-8101} |
| 193 | VOLTHA_API_PORT=${VOLTHA_API_PORT:-55555} |
| 194 | VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-5022} |
| 195 | fi |
| 196 | |
David Bainbridge | 0129495 | 2019-07-30 19:33:45 +0000 | [diff] [blame^] | 197 | if [ "$WITH_TP" == "yes" ]; then |
| 198 | SADIS_VER=3.1.0 |
| 199 | OLT_VER=3.0.1 |
| 200 | AAA_VER=1.9.0 |
| 201 | DHCP_VER=1.6.0 |
| 202 | else |
| 203 | SADIS_VER=2.2.0 |
| 204 | OLT_VER=2.1.0 |
| 205 | AAA_VER=1.8.0 |
| 206 | DHCP_VER=1.5.0 |
| 207 | fi |
| 208 | |
| 209 | export SADIS_VER OLT_VER AAA_VER DHCP_VER |
| 210 | |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 211 | if [ "$1" == "get" -a "$2" == "voltconfig" ]; then |
| 212 | echo "$HOME/.volt/config-$TYPE" |
| 213 | exit |
| 214 | fi |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 215 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 216 | if [ $# -ne 1 -o $(echo ":up:down:" | grep -c ":$1:") -ne 1 ]; then |
| 217 | >&2 echo "up or down?" |
| 218 | exit 1 |
| 219 | fi |
| 220 | |
| 221 | if [ "$1" == "down" ]; then |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 222 | if [ $DEPLOY_K8S == "yes" ]; then |
| 223 | if [ -x ./bin/kind ]; then |
| 224 | exec ./bin/kind delete cluster --name voltha-$TYPE |
| 225 | else |
| 226 | >&2 echo "Kind doesn't seem to be installed, so nothing to do. Bye." |
| 227 | fi |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 228 | else |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 229 | EXISTS=$(helm list -q) |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 230 | EXPECT="etcd-operator onos open-olt open-onu sim voltha bbsim radius" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 231 | INTERSECT= |
| 232 | for i in $EXISTS; do |
| 233 | if [ $(echo $EXPECT | grep -c $i) -eq 1 ]; then |
| 234 | HAVE="$HAVE $i" |
| 235 | fi |
| 236 | done |
David Bainbridge | 7831a66 | 2019-07-25 18:12:25 +0000 | [diff] [blame] | 237 | if [ "$HAVE X" != " X" ]; then |
| 238 | ./bin/helm delete --purge $HAVE |
| 239 | fi |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 240 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 241 | exit |
| 242 | fi |
| 243 | |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 244 | LOG="install-$TYPE.log" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 245 | date > $LOG |
| 246 | |
David Bainbridge | 1ceabc1 | 2019-07-25 17:21:05 +0000 | [diff] [blame] | 247 | # Output install options to log |
| 248 | echo "OPTIONS" >> $LOG |
David Bainbridge | 0129495 | 2019-07-30 19:33:45 +0000 | [diff] [blame^] | 249 | ALL_OPTIONS="TYPE WITH_BBSIM WITH_RADIUS WITH_ONOS WITH_TP JUST_K8S DEPLOY_K8S \ |
David Bainbridge | 596f30d | 2019-07-30 17:07:59 +0000 | [diff] [blame] | 250 | SKIP_RESTART_API INSTALL_KUBECTL INSTALL_HELM USE_GO VOLTHA_LOG_LEVEL \ |
| 251 | VOLTHA_CHART VOLTHA_ADAPTER_SIM_CHART VOLTHA_ADAPTER_OPEN_OLT_CHART \ |
David Bainbridge | abd5a4b | 2019-07-30 18:33:09 +0000 | [diff] [blame] | 252 | VOLTHA_ADAPTER_OPEN_ONU_CHART SADIS_VER OLT_VER AAA_VER DHCP_VER" |
David Bainbridge | 596f30d | 2019-07-30 17:07:59 +0000 | [diff] [blame] | 253 | for O in $ALL_OPTIONS; do |
| 254 | VAL=$(eval echo \$$O) |
| 255 | if [ $O == "USE_GO" ]; then |
| 256 | VAL="$(echo $VAL| test $(grep -c true) -eq 1 && echo yes || echo no)" |
| 257 | fi |
| 258 | if [ ! -z "$VAL" ]; then |
| 259 | printf " %-30s = %s\n" $O $VAL >> $LOG |
| 260 | fi |
| 261 | done |
David Bainbridge | 1ceabc1 | 2019-07-25 17:21:05 +0000 | [diff] [blame] | 262 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 263 | spin() { |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 264 | PARTS="\ |
| 265 | \xe2\xa2\x8e\xe2\xa1\xb0 \ |
| 266 | \xe2\xa2\x8e\xe2\xa1\xa1 \ |
| 267 | \xe2\xa2\x8e\xe2\xa1\x91 \ |
| 268 | \xe2\xa2\x8e\xe2\xa0\xb1 \ |
| 269 | \xe2\xa0\x8e\xe2\xa1\xb1 \ |
| 270 | \xe2\xa2\x8a\xe2\xa1\xb1 \ |
| 271 | \xe2\xa2\x8c\xe2\xa1\xb1 \ |
| 272 | \xe2\xa2\x86\xe2\xa1\xb1 \ |
| 273 | " |
| 274 | IDX=1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 275 | tput civis |
| 276 | while true; do |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 277 | C=$(echo $PARTS | cut '-d ' -f $IDX) |
| 278 | echo -en "$C" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 279 | IDX=$(expr $IDX + 1) |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 280 | if [ $IDX -gt 8 ]; then |
| 281 | IDX=1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 282 | fi |
| 283 | sleep .15 |
| 284 | echo -en "\r" |
| 285 | done |
| 286 | } |
| 287 | |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 288 | SPIN_PARTS="\ |
| 289 | \xe2\xa2\x8e\xe2\xa1\xb0 \ |
| 290 | \xe2\xa2\x8e\xe2\xa1\xa1 \ |
| 291 | \xe2\xa2\x8e\xe2\xa1\x91 \ |
| 292 | \xe2\xa2\x8e\xe2\xa0\xb1 \ |
| 293 | \xe2\xa0\x8e\xe2\xa1\xb1 \ |
| 294 | \xe2\xa2\x8a\xe2\xa1\xb1 \ |
| 295 | \xe2\xa2\x8c\xe2\xa1\xb1 \ |
| 296 | \xe2\xa2\x86\xe2\xa1\xb1 \ |
| 297 | " |
| 298 | IDX=1 |
| 299 | NOT_VERIFIED="\xe2\x9c\x97\x20" |
| 300 | VERIFIED="\xe2\x9c\x93\x20" |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 301 | HELM="\xE2\x8E\x88" |
| 302 | OLD_KEY="\xF0\x9F\x97\x9D" |
| 303 | BIRD="\xF0\x9F\x90\xA6" |
| 304 | HIGH_VOLTAGE="\xE2\x9A\xA1" |
| 305 | PLUG="\xF0\x9F\xa7\xa9" |
| 306 | RESTART="\xf0\x9f\x94\x84" |
| 307 | FORWARD="\xE2\x87\xA8" |
| 308 | INSTALL="\xF0\x9F\x8F\x97" |
| 309 | STOP="\xf0\x9f\x9b\x91" |
| 310 | GO="\xf0\x9f\x9a\x80" |
| 311 | DOWNLOAD="\xf0\x9f\x93\xa5" |
| 312 | GEAR="\xe2\x9a\x99" |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 313 | NO_ENTRY="\xe2\x9b\x94" |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 314 | LOCK="\xf0\x9f\x94\x92" |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 315 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 316 | bspin() { |
| 317 | tput civis |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 318 | IDX=1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 319 | local INDENT= |
| 320 | if [ "$1" == "-" ]; then |
| 321 | INDENT=" " |
| 322 | shift |
| 323 | fi |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 324 | echo -en "$INDENT $*" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 325 | } |
| 326 | |
| 327 | sspin() { |
| 328 | local INDENT= |
| 329 | if [ "$1" == "-" ]; then |
| 330 | INDENT=" " |
| 331 | shift |
| 332 | fi |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 333 | C=$(echo $SPIN_PARTS | cut '-d ' -f $IDX) |
| 334 | echo -en "\r$INDENT$C $*" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 335 | IDX=$(expr $IDX + 1) |
Test User | d87942b | 2019-07-03 07:20:24 +0000 | [diff] [blame] | 336 | if [ $IDX -gt 8 ]; then |
| 337 | IDX=1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 338 | fi |
| 339 | } |
| 340 | |
| 341 | espin() { |
| 342 | local INDENT= |
| 343 | if [ "$1" == "-" ]; then |
| 344 | INDENT=" " |
| 345 | shift |
| 346 | fi |
| 347 | echo -e "\r$INDENT$*" |
| 348 | tput cnorm |
| 349 | } |
| 350 | |
| 351 | count_pods() { |
| 352 | local NAMESPACE=$1; shift |
| 353 | local PODS=$(kubectl -n $NAMESPACE get pod -o go-template="{{range .items}}{{.metadata.name}}/{{.status.phase}}/_{{range .status.containerStatuses}}{{.ready}}_{{end}} {{end}}") |
| 354 | local COUNT=0 |
| 355 | local PATTERNS=$* |
| 356 | for POD in $PODS; do |
| 357 | local NAME=$(echo $POD | cut -d/ -f 1) |
| 358 | local STATE=$(echo $POD | cut -d/ -f 2) |
| 359 | local CONTAINERS=$(echo $POD | cut -d/ -f 3 | sed -e 's/_/ /g') |
| 360 | if [ "$STATE" == "Running" ]; then |
| 361 | local TOTAL=$(echo $CONTAINERS | wc -w) |
| 362 | local FOUND=$(echo $CONTAINERS | grep -o true | wc -l) |
| 363 | if [ $TOTAL -eq $FOUND ]; then |
| 364 | for PATTERN in $PATTERNS; do |
| 365 | if [[ $NAME =~ $PATTERN ]]; then |
| 366 | COUNT=$(expr $COUNT + 1) |
| 367 | fi |
| 368 | done |
| 369 | fi |
| 370 | fi |
| 371 | done |
| 372 | echo $COUNT |
| 373 | } |
| 374 | |
| 375 | wait_for_pods() { |
| 376 | local INDENT= |
| 377 | if [ "$1" == "-" ]; then |
| 378 | INDENT=$1; shift |
| 379 | fi |
| 380 | local NAMESPACE=$1; shift |
| 381 | local EXPECT=$1; shift |
| 382 | local RETRY=$1; shift |
| 383 | local MESSAGE=$1; shift |
| 384 | local PATTERNS=$* |
| 385 | local HAVE=$(count_pods $NAMESPACE $PATTERNS) |
| 386 | COUNT=$(expr 300 / 15) |
| 387 | bspin $INDENT $MESSAGE |
| 388 | sspin $INDENT |
| 389 | if [ $HAVE -ne $EXPECT ]; then |
| 390 | while [ $HAVE -ne $EXPECT ]; do |
| 391 | sspin $INDENT |
| 392 | COUNT=$(expr $COUNT - 1) |
| 393 | if [ $COUNT -eq 0 ]; then |
| 394 | HAVE=$(count_pods $NAMESPACE $PATTERNS) |
| 395 | COUNT=$(expr 300 / 15) |
| 396 | fi |
| 397 | sleep .15 |
| 398 | done |
| 399 | fi |
| 400 | espin $INDENT $VERIFIED |
| 401 | if [ $HAVE -ne $EXPECT ]; then |
| 402 | return 1 |
| 403 | fi |
| 404 | return 0 |
| 405 | } |
| 406 | |
| 407 | helm_install() { |
| 408 | local INDENT= |
| 409 | if [ "$1" == "-" ]; then |
| 410 | INDENT=$1; shift |
| 411 | fi |
| 412 | local NAMESPACE=$1; shift |
| 413 | local NAME=$1; shift |
| 414 | local CHART=$1; shift |
| 415 | local MESSAGE=$* |
| 416 | |
| 417 | COUNT=$(expr 300 / 15) |
| 418 | bspin $INDENT $MESSAGE |
David Bainbridge | 1ceabc1 | 2019-07-25 17:21:05 +0000 | [diff] [blame] | 419 | (set -x; helm install -f $TYPE-values.yaml --set use_go=$USE_GO --set defaults.log_level=$VOLTHA_LOG_LEVEL --namespace $NAMESPACE --name $NAME $CHART >>$LOG 2>&1) >>$LOG 2>&1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 420 | SUCCESS=$? |
| 421 | while [ $SUCCESS -ne 0 ]; do |
| 422 | sspin $INDENT |
| 423 | COUNT=$(expr $COUNT - 1) |
| 424 | if [ $COUNT -eq 0 ]; then |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame] | 425 | (set -x; helm install -f $TYPE-values.yaml --set defaults.log_level=$VOLTHA_LOG_LEVEL --namespace $NAMESPACE --name $NAME $CHART >>$LOG 2>&1) >>$LOG 2>&1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 426 | COUNT=$(expr 300 / 15) |
| 427 | fi |
| 428 | sleep .15 |
| 429 | done |
| 430 | espin $INDENT $VERIFIED |
| 431 | } |
| 432 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 433 | echo "INSTALL TYPE: $TYPE" >> $LOG |
| 434 | |
| 435 | bspin "Verify GOPATH" |
| 436 | export GOPATH=$(pwd) |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 437 | mkdir -p $GOPATH/bin |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 438 | espin $VERIFIED |
| 439 | |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 440 | if [ "$INSTALL_KUBECTL" == "no" ]; then |
| 441 | bspin "Skip kubectl install" |
| 442 | espin $NO_ENTRY |
Test User | c13bdc9 | 2019-07-03 20:57:49 +0000 | [diff] [blame] | 443 | else |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 444 | bspin "Verify kubectl $HELM" |
| 445 | if [ -x $GOPATH/bin/kubectl ]; then |
| 446 | espin $VERIFIED |
| 447 | else |
| 448 | espin $NOT_VERIFIED |
| 449 | bspin - "Download and install Kubernetes/kubectl $DOWNLOAD" |
| 450 | (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 |
| 451 | (set -x; chmod 755 $GOPATH/bin/kubectl >>$LOG 2>&1) >>$LOG 2>&1 |
| 452 | espin - $VERIFIED |
| 453 | fi |
Test User | c13bdc9 | 2019-07-03 20:57:49 +0000 | [diff] [blame] | 454 | fi |
| 455 | |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 456 | if [ "$DEPLOY_K8S" == "no" ]; then |
| 457 | bspin "Skip Kubernetes/Kind Deployment" |
| 458 | espin $NO_ENTRY |
| 459 | else |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 460 | bspin "Verify Kubernetes/Kind $HELM" |
| 461 | if [ -x $GOPATH/bin/kind ]; then |
| 462 | espin $VERIFIED |
| 463 | else |
| 464 | espin $NOT_VERIFIED |
| 465 | bspin - "Download and install Kubernetes/kind $DOWNLOAD" |
David Bainbridge | 9e2a666 | 2019-07-11 17:07:57 +0000 | [diff] [blame] | 466 | (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] | 467 | (set -x; chmod 755 $GOPATH/bin/kind >>$LOG 2>&1) >>$LOG 2>&1 |
| 468 | espin - $VERIFIED |
| 469 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 470 | fi |
| 471 | |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 472 | if [ "$INSTALL_HELM" == "no" ]; then |
| 473 | bspin "Skip Helm Install" |
| 474 | espin $NO_ENTRY |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 475 | else |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 476 | bspin "Verify Helm $HELM" |
| 477 | if [ -x $GOPATH/bin/helm ]; then |
| 478 | espin $VERIFIED |
| 479 | else |
| 480 | espin $NOT_VERIFIED |
| 481 | bspin - "Download and install Helm $DOWNLOAD" |
| 482 | (set -x; curl -sSL https://git.io/get_helm.sh | USE_SUDO=false HELM_INSTALL_DIR=$GOPATH/bin bash >>$LOG 2>&1) >>$LOG 2>&1 |
| 483 | espin - $VERIFIED |
| 484 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 485 | fi |
| 486 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 487 | bspin "Verify voltctl $HIGH_VOLTAGE" |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 488 | if [ -x $GOPATH/bin/voltctl ]; then |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 489 | espin $VERIFIED |
| 490 | else |
| 491 | espin $NOT_VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 492 | bspin - "Download and build voltctl $DOWNLOAD" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 493 | (set -x; curl -o $GOPATH/bin/voltctl -sSL https://github.com/ciena/voltctl/releases/download/$VOLTCTL_VERSION/voltctl-$_VOLTCTL_VERSION-$HOSTOS-$HOSTARCH >>$LOG 2>&1) >>$LOG 2>&1 |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 494 | (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] | 495 | espin - $VERIFIED |
| 496 | fi |
| 497 | |
| 498 | bspin "Verify command PATH" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 499 | export PATH=$GOPATH/bin:$PATH |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 500 | espin $VERIFIED |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 501 | |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 502 | if [ "$DEPLOY_K8S" == "yes" ]; then |
| 503 | HAVE=$(kind get clusters | grep -c voltha-$TYPE) |
| 504 | bspin "Verify Kubernetes/Kind Cluster" |
| 505 | sspin |
| 506 | if [ $HAVE -eq 0 ]; then |
David Bainbridge | 491b1bd | 2019-07-11 17:53:11 +0000 | [diff] [blame] | 507 | espin $NOT_VERIFIED |
| 508 | bspin - "Verify cluster configuration" |
| 509 | if [ ! -r ./$TYPE-cluster.cfg ]; then |
| 510 | espin - $NOT_VERIFIED |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 511 | bspin - "Download cluster configuration: $TYPE-cluster.cfg $DOWNLOAD" |
David Bainbridge | 491b1bd | 2019-07-11 17:53:11 +0000 | [diff] [blame] | 512 | (set -x; curl -o ./$TYPE-cluster.cfg -sSL https://raw.githubusercontent.com/ciena/kind-voltha/master/$TYPE-cluster.cfg >>$LOG 2>&1) >>$LOG 2>&1 |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 513 | espin - $VERIFIED |
| 514 | else |
| 515 | espin - $VERIFIED |
| 516 | fi |
David Bainbridge | 491b1bd | 2019-07-11 17:53:11 +0000 | [diff] [blame] | 517 | kind create cluster --name voltha-$TYPE --config $TYPE-cluster.cfg |
| 518 | else |
| 519 | espin $VERIFIED |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 520 | fi |
| 521 | |
| 522 | export KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$TYPE")" |
| 523 | P="coredns-.* \ |
| 524 | etcd-voltha-$TYPE-control-plane \ |
| 525 | kindnet-.* \ |
| 526 | kube-apiserver-voltha-$TYPE-control-plane \ |
| 527 | kube-controller-manager-voltha-$TYPE-control-plane \ |
| 528 | kube-proxy-.* \ |
| 529 | kube-scheduler-voltha-$TYPE-control-plane" |
| 530 | |
| 531 | EXPECT=$(test "$TYPE" == "minimal" && echo "12" || echo "14") |
| 532 | wait_for_pods - "kube-system" $EXPECT -1 "Waiting for system PODs to start" $P |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 533 | fi |
| 534 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 535 | COUNT=$(count_pods "kube-system" "tiller-deploy-.*") |
| 536 | bspin "Verify Helm" |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 537 | if [ $COUNT -ne 1 ]; then |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 538 | espin $NOT_VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 539 | echo -e "Configuring Helm $GEAR" |
David K. Bainbridge | 0e89cb9 | 2019-07-17 11:30:10 -0700 | [diff] [blame] | 540 | if [ "$INSTALL_HELM" == "no" ]; then |
| 541 | bspin - "Skip Helm/Tiller Initialization" |
| 542 | espin - $NO_ENTRY |
| 543 | else |
| 544 | bspin - "Initialize Helm" |
| 545 | (set -x; helm init --upgrade >>$LOG 2>&1) >>$LOG 2>&1 |
| 546 | espin - $VERIFIED |
| 547 | wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start" "tiller-deploy-.*" |
| 548 | fi |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 549 | bspin - "Add Google Incubator repository to Helm" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 550 | (set -x; helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1 |
| 551 | espin - $VERIFIED |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 552 | |
| 553 | # HACK (sort-of) - the config for tiller is about to be patched, which will |
| 554 | # cause the tiller pod to be recreated. This can sometimes cause a timing |
| 555 | # issue with the "wait_for_pods" call on tiller as it may incorrectly |
| 556 | # identify the running/ready tiller pod that is soon to be terminated as |
| 557 | # what it is waiting for. To avoid this issue we do a clean scale down and |
| 558 | # scale up of the pod so the script controlls when it should be expecting |
| 559 | # things |
| 560 | (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] | 561 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 562 | bspin - "Add Google Stable repository to Helm" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 563 | (set -x; helm repo add stable https://kubernetes-charts.storage.googleapis.com >>$LOG 2>&1) >>$LOG 2>&1 |
| 564 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 565 | bspin - "Add ONF repository to Helm" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 566 | (set -x; helm repo add onf https://charts.opencord.org >>$LOG 2>&1) >>$LOG 2>&1 |
| 567 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 568 | bspin - "Update Helm repository cache" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 569 | (set -x; helm repo update >>$LOG 2>&1) >>$LOG 2>&1 |
| 570 | espin - $VERIFIED |
| 571 | |
| 572 | # Create and k8s service account so that Helm can create pods |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 573 | bspin - "Create Tiller ServiceAccount" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 574 | (set -x; kubectl create serviceaccount --namespace kube-system tiller >>$LOG 2>&1) >>$LOG 2>&1 |
| 575 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 576 | bspin - "Create Tiller ClusterRoleBinding" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 577 | (set -x; kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller >>$LOG 2>&1) >>$LOG 2>&1 |
| 578 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 579 | bspin - "Update Tiller Manifest" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 580 | (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] | 581 | |
| 582 | # HACK (sort-of) - part to, spin it back up |
| 583 | (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] | 584 | espin - $VERIFIED |
| 585 | else |
| 586 | espin $VERIFIED |
| 587 | fi |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 588 | wait_for_pods - "kube-system" 1 -1 "Waiting for Tiller POD to start" "tiller-deploy-.*" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 589 | |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 590 | bspin "Verify Helm values file: $TYPE-values.yaml" |
| 591 | if [ ! -r "./$TYPE-values.yaml" ]; then |
| 592 | espin $NOT_VERIFIED |
| 593 | bspin - "Download Helm values file: $TYPE-values.yaml $DOWNLOAD" |
| 594 | (set -x; curl -o ./$TYPE-values.yaml -sSL https://raw.githubusercontent.com/ciena/kind-voltha/master/$TYPE-values.yaml >>$LOG 2>&1) >>$LOG 2>&1 |
| 595 | espin - $VERIFIED |
| 596 | else |
| 597 | espin $VERIFIED |
| 598 | fi |
| 599 | |
| 600 | if [ "$JUST_K8S" == "yes" ]; then |
| 601 | echo "Environment deployed, not deploying VOLTHA artifacts as requested. Good bye." |
| 602 | echo "" |
| 603 | echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG |
| 604 | echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG |
| 605 | echo "tools required by VOLTHA in your command path. " | tee -a $LOG |
| 606 | echo "" | tee -a $LOG |
| 607 | echo -en $BOLD |
| 608 | if [ $DEPLOY_K8S == "yes" ]; then |
| 609 | echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$TYPE\")\"" | tee -a $LOG |
| 610 | fi |
| 611 | echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG |
| 612 | echo -en $NORMAL |
| 613 | echo "" | tee -a $LOG |
| 614 | echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG |
| 615 | exit 0 |
| 616 | fi |
| 617 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 618 | bspin "Verify ETCD Operator $OLD_KEY" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 619 | if [ $(helm list --deployed --short --namespace voltha "^etcd-operator\$" | wc -l) -ne 1 ]; then |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 620 | espin $NOT_VERIFIED |
| 621 | helm_install - voltha etcd-operator stable/etcd-operator "Install ETCD Operator" |
| 622 | else |
| 623 | espin $VERIFIED |
| 624 | fi |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 625 | EXPECT=$(test "$TYPE" == "minimal" && echo "1" || echo "3") |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 626 | wait_for_pods - "voltha" $EXPECT -1 "Waiting for ETCD Operator to start" "etcd-operator-.*" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 627 | |
David Bainbridge | b270c20 | 2019-07-26 01:44:42 +0000 | [diff] [blame] | 628 | if [ $WITH_ONOS == "yes" ]; then |
| 629 | bspin "Verify ONOS installed $BIRD" |
| 630 | if [ $(helm list --deployed --short --namespace default "^onos\$" | wc -l) -ne 1 ]; then |
| 631 | espin $NOT_VERIFIED |
| 632 | helm_install - default onos onf/onos "Install ONOS" |
| 633 | else |
| 634 | espin $VERIFIED |
| 635 | fi |
| 636 | wait_for_pods - "default" 1 -1 "Waiting for ONOS to start" "onos-.*" |
| 637 | |
| 638 | bspin - "Forward ONOS API port $FORWARD" |
David Bainbridge | 82bd121 | 2019-07-29 19:19:31 +0000 | [diff] [blame] | 639 | for i in $(screen -ls | grep onos-ui-$TYPE | awk '{print $1}'); do |
| 640 | (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1 |
| 641 | done |
| 642 | (set -x; screen -dmS onos-ui-$TYPE bash -c "while true; do kubectl port-forward service/onos-ui $ONOS_API_PORT:8181; done" >>$LOG 2>&1) >>$LOG 2>&1 |
David Bainbridge | b270c20 | 2019-07-26 01:44:42 +0000 | [diff] [blame] | 643 | espin - $VERIFIED |
| 644 | bspin - "Forward ONOS SSH port $FORWARD" |
David Bainbridge | 82bd121 | 2019-07-29 19:19:31 +0000 | [diff] [blame] | 645 | for i in $(screen -ls | grep onos-ssh-$TYPE | awk '{print $1}'); do |
| 646 | (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1 |
| 647 | done |
| 648 | (set -x; screen -dmS onos-ssh-$TYPE bash -c "while true; do kubectl port-forward service/onos-ssh $ONOS_SSH_PORT:8101; done" >>$LOG 2>&1) >>$LOG 2>&1 |
David Bainbridge | b270c20 | 2019-07-26 01:44:42 +0000 | [diff] [blame] | 649 | espin - $VERIFIED |
| 650 | if [ ! -x ./onos-files/install-onos-applications.sh ]; then |
| 651 | bspin - "Verify or download ONOS configuration support files $DOWNLOAD" |
| 652 | (set -x; mkdir -p ./onos-files >>$LOG 2>&1) >>$LOG 2>&1 |
| 653 | for i in dhcp-to-controller-flow.json install-onos-applications.sh olt-onos-enableExtraneousRules.json olt-onos-netcfg.json olt-onos-olt-settings.json radius-config.json; do |
| 654 | if [ ! -r ./onos-files/$i ]; then |
| 655 | (set -x; curl -o ./onos-files/$i -sSL https://raw.githubusercontent.com/ciena/kind-voltha/master/onos-files/$i >>$LOG 2>&1) >>$LOG 2>&1 |
| 656 | fi |
| 657 | done |
| 658 | (set -x; chmod 755 ./onos-files/install-onos-applications.sh >>$LOG 2>&1) >>$LOG 2>&1 |
| 659 | espin - $VERIFIED |
| 660 | fi |
| 661 | |
| 662 | bspin - "Install required ONOS applications $INSTALL" |
| 663 | (set -x; ./onos-files/install-onos-applications.sh >>$LOG 2>&1) >>$LOG 2>&1 |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 664 | espin - $VERIFIED |
| 665 | fi |
| 666 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 667 | bspin "Verify VOLTHA installed $HIGH_VOLTAGE" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 668 | 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] | 669 | espin $NOT_VERIFIED |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame] | 670 | helm_install - voltha voltha $VOLTHA_CHART "Install VOLTHA Core" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 671 | else |
| 672 | espin $VERIFIED |
| 673 | fi |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 674 | |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 675 | VOLTHA="ofagent-.* \ |
| 676 | ro-core.* \ |
| 677 | rw-core.* \ |
| 678 | voltha-api-server-.* \ |
| 679 | voltha-cli-server-.* \ |
| 680 | voltha-etcd-cluster-.* \ |
| 681 | voltha-kafka-.* \ |
| 682 | voltha-zookeeper-.*" |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 683 | EXPECT=$(test "$TYPE" == "minimal" && echo "9" || echo "11") |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 684 | wait_for_pods - "voltha" $EXPECT -1 "Waiting for VOLTHA Core to start" $VOLTHA |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 685 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 686 | echo -e "Verify Adapters $PLUG" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 687 | bspin - "Verify Simulated Adapters installed" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 688 | if [ $(helm list --deployed --short --namespace voltha "^sim\$" | wc -l) -ne 1 ]; then |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 689 | espin - $NOT_VERIFIED |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame] | 690 | helm_install - voltha sim $VOLTHA_ADAPTER_SIM_CHART "Install Simulated Adapters" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 691 | else |
| 692 | espin - $VERIFIED |
| 693 | fi |
| 694 | |
| 695 | bspin - "Verify OpenOLT Adapter installed" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 696 | if [ $(helm list --deployed --short --namespace voltha "^open-olt\$" | wc -l) -ne 1 ]; then |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 697 | espin - $NOT_VERIFIED |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame] | 698 | helm_install - voltha open-olt $VOLTHA_ADAPTER_OPEN_OLT_CHART "Install OpenOLT Adapter" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 699 | else |
| 700 | espin - $VERIFIED |
| 701 | fi |
| 702 | bspin - "Verify OpenONU Adapter installed" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 703 | if [ $(helm list --deployed --short --namespace voltha "^open-onu\$" | wc -l) -ne 1 ]; then |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 704 | espin - $NOT_VERIFIED |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame] | 705 | helm_install - voltha open-onu $VOLTHA_ADAPTER_OPEN_ONU_CHART "Install OpenONU Adapter" |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 706 | else |
| 707 | espin - $VERIFIED |
| 708 | fi |
| 709 | |
| 710 | ADAPTERS="adapter-.*" |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 711 | wait_for_pods - "voltha" 4 -1 "Waiting for adapters to start" $ADAPTERS |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 712 | |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 713 | if [ $WITH_BBSIM == "yes" ]; then |
| 714 | echo -e "Verify BBSIM $PLUG" |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 715 | bspin - "Verify BBSIM Installed" |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 716 | if [ $(helm list --deployed --short --namespace voltha "^bbsim\$" | wc -l) -ne 1 ]; then |
| 717 | espin - $NOT_VERIFIED |
| 718 | helm_install - voltha bbsim onf/bbsim "Install BBSIM" |
| 719 | else |
| 720 | espin - $VERIFIED |
| 721 | fi |
| 722 | wait_for_pods - "voltha" 1 -1 "Waiting for BBSIM to start" "bbsim-.*" |
| 723 | fi |
| 724 | |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 725 | if [ $WITH_RADIUS == "yes" ]; then |
| 726 | echo -e "Verify RADIUS $LOCK" |
| 727 | bspin - "Verify RADIUS Installed" |
| 728 | if [ $(helm list --deployed --short --namespace voltha "^radius\$" | wc -l) -ne 1 ]; then |
| 729 | espin - $NOT_VERIFIED |
| 730 | helm_install - voltha radius onf/freeradius "Install RADIUS" |
| 731 | else |
| 732 | espin - $VERIFIED |
| 733 | fi |
| 734 | wait_for_pods - "voltha" 1 -1 "Waiting for RADIUS to start" "radius-.*" |
| 735 | fi |
| 736 | |
David Bainbridge | e10f6d5 | 2019-07-25 00:28:13 +0000 | [diff] [blame] | 737 | if [ $SKIP_RESTART_API == "no" ]; then |
| 738 | echo -e "Restart VOLTHA API $RESTART" |
| 739 | API="voltha-api-server-.* ofagent-.*" |
| 740 | (set -x; kubectl scale --replicas=0 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1 |
| 741 | wait_for_pods - "voltha" 0 -1 "Wait for API to stop $STOP" $API |
| 742 | (set -x; kubectl scale --replicas=1 deployment -n voltha voltha-api-server ofagent >>$LOG 2>&1) >>$LOG 2>&1 |
| 743 | wait_for_pods - "voltha" 2 -1 "Wait for API to re-start $GO" $API |
| 744 | else |
| 745 | bspin "Skip VOLTHA API Restart" |
| 746 | espin $NO_ENTRY |
| 747 | fi |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 748 | |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 749 | bspin - "Forward VOLTHA API port $FORWARD" |
David Bainbridge | 82bd121 | 2019-07-29 19:19:31 +0000 | [diff] [blame] | 750 | for i in $(screen -ls | grep voltha-api-$TYPE | awk '{print $1}'); do |
| 751 | (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1 |
| 752 | done |
| 753 | (set -x; screen -dmS voltha-api-$TYPE bash -c "while true; do kubectl port-forward -n voltha service/voltha-api $VOLTHA_API_PORT:55555; done" >>$LOG 2>&1) >>$LOG 2>&1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 754 | espin - $VERIFIED |
Test User | b571237 | 2019-07-03 21:52:17 +0000 | [diff] [blame] | 755 | bspin - "Forward VOLTHA SSH port $FORWARD" |
David Bainbridge | 82bd121 | 2019-07-29 19:19:31 +0000 | [diff] [blame] | 756 | for i in $(screen -ls | grep voltha-ssh-$TYPE | awk '{print $1}'); do |
| 757 | (set -x; screen -X -S $i quit >>$LOG 2>&1) >>$LOG 2>&1 |
| 758 | done |
| 759 | (set -x; screen -dmS voltha-ssh-$TYPE bash -c "while true; do kubectl port-forward -n voltha service/voltha-cli $VOLTHA_SSH_PORT:5022; done" >>$LOG 2>&1) >>$LOG 2>&1 |
David K. Bainbridge | b728543 | 2019-07-02 22:05:24 -0700 | [diff] [blame] | 760 | espin - $VERIFIED |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 761 | |
David Bainbridge | b270c20 | 2019-07-26 01:44:42 +0000 | [diff] [blame] | 762 | if [ $WITH_ONOS == "yes" -a $WITH_RADIUS == "yes" ]; then |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 763 | bspin "Configure ONOS RADIUS Connection $GEAR" |
| 764 | (set -x; cat onos-files/radius-config.json | sed -e "s/:RADIUS_IP:/$(kubectl -n voltha get service/radius -o jsonpath={.spec.clusterIP})/g" | curl -XPOST -sSL http://karaf:karaf@localhost:8181/onos/v1/network/configuration -H Content-type:application/json -d@- >>$LOG 2>&1) >>$LOG 2>&1 |
| 765 | espin $VERIFIED |
| 766 | fi |
| 767 | |
| 768 | bspin "Create voltctl configuration file" |
Test User | 3d7ad8e | 2019-07-03 06:15:44 +0000 | [diff] [blame] | 769 | (set -x; mkdir -p $HOME/.volt >>$LOG 2>&1) >>$LOG 2>&1 |
Test User | 01ed064 | 2019-07-03 20:17:06 +0000 | [diff] [blame] | 770 | (set -x; voltctl -a v2 -s localhost:$VOLTHA_API_PORT config > $HOME/.volt/config-$TYPE 2>>$LOG) >>$LOG 2>&1 |
David Bainbridge | 5b7b96b | 2019-07-25 20:29:13 +0000 | [diff] [blame] | 771 | espin $VERIFIED |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 772 | |
David Bainbridge | b07fdf7 | 2019-07-29 22:51:40 +0000 | [diff] [blame] | 773 | if [ ! -f "$TYPE-env.sh" ]; then |
| 774 | touch $TYPE-env.sh |
| 775 | fi |
| 776 | |
David Bainbridge | 596f30d | 2019-07-30 17:07:59 +0000 | [diff] [blame] | 777 | for O in $ALL_OPTIONS; do |
| 778 | VAL=$(eval echo \$$O) |
| 779 | if [ $O == "USE_GO" ]; then |
| 780 | VAL="$(echo $VAL| test $(grep -c true) -eq 1 && echo yes || echo no)" |
| 781 | fi |
| 782 | if [ ! -z "$VAL" -a $(grep -c "^export $O=" $TYPE-env.sh) -eq 0 ]; then |
David Bainbridge | b07fdf7 | 2019-07-29 22:51:40 +0000 | [diff] [blame] | 783 | echo "export $O=\"$(eval echo \$$O)\"" >> $TYPE-env.sh |
| 784 | fi |
| 785 | done |
| 786 | |
| 787 | if [ $DEPLOY_K8S == "yes" -a $(grep -c "^export KUBECONFIG=" $TYPE-env.sh) -eq 0 ]; then |
| 788 | echo "export KUBECONFIG=\"$(./bin/kind get kubeconfig-path --name=voltha-$TYPE)\"" >> $TYPE-env.sh |
| 789 | fi |
| 790 | |
| 791 | if [ $(grep -c "^export VOLTCONFIG=" $TYPE-env.sh) -eq 0 ]; then |
| 792 | echo "export VOLTCONFIG=\"$HOME/.volt/config-$TYPE\"" >> $TYPE-env.sh |
| 793 | fi |
| 794 | |
| 795 | if [ $(grep -c "^export PATH=" $TYPE-env.sh) -eq 0 ]; then |
| 796 | echo "export PATH=\"$GOPATH/bin:\$PATH\"" >> $TYPE-env.sh |
| 797 | fi |
| 798 | |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 799 | echo "" |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 800 | echo "Please issue the following commands in your terminal to ensure that you" | tee -a $LOG |
| 801 | echo "are accessing the correct Kubernetes/Kind cluster as well as have the " | tee -a $LOG |
| 802 | echo "tools required by VOLTHA in your command path. " | tee -a $LOG |
| 803 | echo "" | tee -a $LOG |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 804 | echo -en $BOLD |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 805 | if [ $DEPLOY_K8S == "yes" ]; then |
| 806 | echo "export KUBECONFIG=\"\$(./bin/kind get kubeconfig-path --name=\"voltha-$TYPE\")\"" | tee -a $LOG |
| 807 | fi |
Test User | fa30f7f | 2019-07-03 20:35:19 +0000 | [diff] [blame] | 808 | echo "export VOLTCONFIG=\"$HOME/.volt/config-$TYPE\"" | tee -a $LOG |
Test User | ba1e7e7 | 2019-07-10 22:27:54 +0000 | [diff] [blame] | 809 | echo "export PATH=$GOPATH/bin:\$PATH" | tee -a $LOG |
Test User | 7d86612 | 2019-07-09 17:52:35 +0000 | [diff] [blame] | 810 | echo -en $NORMAL |
Test User | 08ebbd9 | 2019-07-03 17:15:39 +0000 | [diff] [blame] | 811 | echo "" | tee -a $LOG |
| 812 | echo "Thank you for choosing kind-voltha for you quick cluster needs." | tee -a $LOG |
| 813 | |