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