blob: 5697fba956dc2084962f41355a3dd6b097e96158 [file] [log] [blame]
Andy Bavierc4a40512017-08-10 07:06:25 -07001#!/usr/bin/env bash
2#
Matteo Scandolo60b640f2017-08-08 13:05:22 -07003# Copyright 2017-present Open Networking Foundation
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
Zack Williamsa1f55082017-02-28 22:41:36 -070017# cord-in-a-box.sh
Andy Bavier99c11d32016-09-14 17:21:20 -040018
Sapan Bhatia01ddea62017-02-10 11:28:48 -080019set -e -x
Andy Bavier99c11d32016-09-14 17:21:20 -040020
Zack Williamsa1f55082017-02-28 22:41:36 -070021# start time, used to name logfiles
22START_T=$(date -u "+%Y%m%d_%H%M%SZ")
23
24# Paths
Zack Williams0620c932017-01-25 14:36:31 -070025CORDDIR=~/cord
Andy Bavierf55e7f92017-06-22 10:16:44 -040026VMDIR=/opt/cord/build/
Andy Bavier99c11d32016-09-14 17:21:20 -040027CONFIG=config/cord_in_a_box.yml
Andy Baviera69ee722016-11-17 07:26:01 -080028SSHCONFIG=~/.ssh/config
Zack Williams1bffc162017-04-12 16:31:15 -070029VAGRANT_CWD=${CORDDIR}/build/
Zack Williams03a20ec2017-04-12 17:39:36 -070030VAGRANT_VM_PREFIX=build
Andy Bavier99c11d32016-09-14 17:21:20 -040031
Zack Williamsa1f55082017-02-28 22:41:36 -070032# CORD versioning
Andy Bavierd1165102017-01-13 16:38:57 -050033REPO_BRANCH="master"
Zack Williamsa1f55082017-02-28 22:41:36 -070034VERSION_STRING="CiaB Devel"
Andy Bavierd1165102017-01-13 16:38:57 -050035
Sapan Bhatiaa94c2db2017-02-27 20:18:24 +010036function finish {
Sapan Bhatia95692092017-03-01 06:48:19 +010037 EXIT=$?
Sapan Bhatiaeb7819c2017-03-01 15:26:17 +010038 python $CORDDIR/build/elk-logger/mixpanel --event FINISH --corddir $CORDDIR --finish --status $EXIT
Sapan Bhatiaa94c2db2017-02-27 20:18:24 +010039}
40
Andy Bavier0f07bb32017-01-17 10:20:26 -050041function add_box() {
42 vagrant box list | grep $1 | grep virtualbox || vagrant box add $1
43 vagrant box list | grep $1 | grep libvirt || vagrant mutate $1 libvirt --input-provider virtualbox
44}
45
Sapan Bhatia01ddea62017-02-10 11:28:48 -080046function run_stage {
Sapan Bhatiaa94c2db2017-02-27 20:18:24 +010047 cd $CORDDIR
Sapan Bhatiaeb7819c2017-03-01 15:26:17 +010048 python build/elk-logger/mixpanel --event $1-start --corddir $CORDDIR
Sapan Bhatiaa94c2db2017-02-27 20:18:24 +010049
Sapan Bhatia01ddea62017-02-10 11:28:48 -080050 echo "==> "$1": Starting"
51 $1
52 echo "==> "$1": Complete"
Sapan Bhatiaa94c2db2017-02-27 20:18:24 +010053
54 cd $CORDDIR
Sapan Bhatiaeb7819c2017-03-01 15:26:17 +010055 python build/elk-logger/mixpanel --event $1-end --corddir $CORDDIR
Sapan Bhatia01ddea62017-02-10 11:28:48 -080056}
57
Andy Bavier99c11d32016-09-14 17:21:20 -040058function cleanup_from_previous_test() {
Andy Bavier99c11d32016-09-14 17:21:20 -040059 echo "## Cleanup ##"
60
Andy Baviera4883ba2016-12-21 15:46:58 -050061 if [ -d $CORDDIR/build ]
62 then
63 echo "Destroying all Vagrant VMs"
64 cd $CORDDIR/build
Zack Williamsa1f55082017-02-28 22:41:36 -070065 for i in `seq 12`; do
Zack Williams9e7249a2017-03-28 13:07:41 -070066 sudo su $USER -c "VAGRANT_CWD=$VAGRANT_CWD vagrant destroy" && break
Zack Williamsa1f55082017-02-28 22:41:36 -070067 done
Andy Baviera4883ba2016-12-21 15:46:58 -050068 fi
Andy Bavier99c11d32016-09-14 17:21:20 -040069
Andy Bavier2505f592016-11-11 15:58:55 -050070 echo "Removing $CORDDIR"
71 cd ~
Andy Bavier99c11d32016-09-14 17:21:20 -040072 rm -rf $CORDDIR
Andy Bavier99c11d32016-09-14 17:21:20 -040073}
74
75function bootstrap() {
Zack Williamsa1f55082017-02-28 22:41:36 -070076
Sapan Bhatia95692092017-03-01 06:48:19 +010077 echo "Generating build id"
Sapan Bhatia77f26672017-03-13 18:30:25 +010078 rm -f /tmp/cord-build-version
Sapan Bhatia95692092017-03-01 06:48:19 +010079 dd bs=18 count=1 if=/dev/urandom | base64 | tr +/ _. > /tmp/cord-build
Andy Bavier99c11d32016-09-14 17:21:20 -040080
Zack Williamsa1f55082017-02-28 22:41:36 -070081 if [ ! -x "/usr/local/bin/repo" ]
82 then
83 echo "Installing repo..."
84 REPO_SHA256SUM="e147f0392686c40cfd7d5e6f332c6ee74c4eab4d24e2694b3b0a0c037bf51dc5" # not versioned...
85 curl -o /tmp/repo https://storage.googleapis.com/git-repo-downloads/repo
86 echo "$REPO_SHA256SUM /tmp/repo" | sha256sum -c -
87 sudo mv /tmp/repo /usr/local/bin/repo
88 sudo chmod a+x /usr/local/bin/repo
89 fi
90
91 if [ ! -x "/usr/bin/vagrant" ]
92 then
93 echo "Installing vagrant and associated tools..."
94 VAGRANT_SHA256SUM="faff6befacc7eed3978b4b71f0dbb9c135c01d8a4d13236bda2f9ed53482d2c4" # version 1.9.3
95 curl -o /tmp/vagrant.deb https://releases.hashicorp.com/vagrant/1.9.3/vagrant_1.9.3_x86_64.deb
96 echo "$VAGRANT_SHA256SUM /tmp/vagrant.deb" | sha256sum -c -
97 sudo apt-get update
98 sudo dpkg -i /tmp/vagrant.deb
Zack Williams2f130922017-04-28 15:02:09 -070099 sudo apt-get -y install qemu-kvm libvirt-bin libvirt-dev curl nfs-kernel-server git build-essential python-pip ruby2.0
Zack Williamsa1f55082017-02-28 22:41:36 -0700100 sudo adduser $USER libvirtd
101 sudo pip install pyparsing python-logstash mixpanel
102 fi
103
104 echo "Installing vagrant plugins..."
Zack Williams2f130922017-04-28 15:02:09 -0700105 # FIXME: fix for vagrant-libvirt dependency issue that arose on 2017-04-28 - zdw
106 # vagrant plugin list | grep vagrant-libvirt || vagrant plugin install vagrant-libvirt --plugin-version 0.0.35
107 if ! vagrant plugin list | grep vagrant-libvirt
108 then
109 git clone -b remove_xmlrpc_dep https://github.com/zdw/vagrant-libvirt.git ~/vagrant-libvirt
110 cd ~/vagrant-libvirt
111 gem2.0 build vagrant-libvirt.gemspec
112 vagrant plugin install vagrant-libvirt-0.0.35.gem
113 cd ~
114 fi
115
Zack Williamsa1f55082017-02-28 22:41:36 -0700116 vagrant plugin list | grep vagrant-mutate || vagrant plugin install vagrant-mutate
117
118 add_box ubuntu/trusty64
119
120 echo "Creating SSH key..."
Andy Bavier99c11d32016-09-14 17:21:20 -0400121 [ -e ~/.ssh/id_rsa ] || ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
Andy Bavier99c11d32016-09-14 17:21:20 -0400122
Andy Bavier99c11d32016-09-14 17:21:20 -0400123 if [ ! -d "$CORDDIR" ]
124 then
Zack Williamsa1f55082017-02-28 22:41:36 -0700125 echo "Downloading CORD/XOS..."
126
127 if [ ! -e "~/.gitconfig" ]
128 then
129 echo "No ~/.gitconfig, setting testing defaults"
130 git config --global user.name 'Test User'
131 git config --global user.email 'test@null.com'
132 git config --global color.ui false
133 fi
134
135 # make sure we can find gerrit.opencord.org as DNS failures will fail the build
136 dig +short gerrit.opencord.org || (echo "ERROR: gerrit.opencord.org can't be looked up in DNS" && exit 1)
137
Andy Bavier99c11d32016-09-14 17:21:20 -0400138 mkdir $CORDDIR && cd $CORDDIR
Matteo Scandolo4d7d1662017-05-30 11:20:57 -0700139 repo init -u https://gerrit.opencord.org/manifest -b $REPO_BRANCH
Andy Bavier99c11d32016-09-14 17:21:20 -0400140 repo sync
141
Zack Williamsdae7ff62016-11-14 15:20:06 -0700142 # check out gerrit branches using repo
143 for gerrit_branch in ${GERRIT_BRANCHES[@]}; do
Zack Williamsa1f55082017-02-28 22:41:36 -0700144 echo "Checking out opencord gerrit branch: $gerrit_branch"
Zack Williamsdae7ff62016-11-14 15:20:06 -0700145 repo download ${gerrit_branch/:/ }
146 done
Andy Bavier99c11d32016-09-14 17:21:20 -0400147 fi
148
Sapan Bhatia868e0012017-02-15 22:14:11 -0800149 exec > >(tee -i $CORDDIR/install.out)
150 exec 2>&1
151
Sapan Bhatia95692092017-03-01 06:48:19 +0100152 # Start tracking failures from this point
153 trap finish EXIT
154
Andy Bavier99c11d32016-09-14 17:21:20 -0400155}
156
157function cloudlab_setup() {
Andy Bavier8b4ed1f2017-02-13 17:06:58 -0800158
Andy Bavier46dfda62017-03-02 05:40:08 -0500159 # Don't do anything if not a CloudLab node
160 [ ! -d /usr/local/etc/emulab ] && return
161
Andy Bavier8b4ed1f2017-02-13 17:06:58 -0800162 # The watchdog will sometimes reset groups, turn it off
163 if [ -e /usr/local/etc/emulab/watchdog ]
164 then
165 sudo /usr/bin/perl -w /usr/local/etc/emulab/watchdog stop
166 sudo mv /usr/local/etc/emulab/watchdog /usr/local/etc/emulab/watchdog-disabled
167 fi
168
Zack Williamsf4e65222017-03-01 14:22:37 -0700169 # Mount extra space, if haven't already
170 if [ ! -d /mnt/extra ]
Andy Bavier99c11d32016-09-14 17:21:20 -0400171 then
Zack Williamsf4e65222017-03-01 14:22:37 -0700172 # for NVME SSD on Utah Cloudlab, not supported by mkextrafs
173 if $(df | grep -q nvme0n1p1) && [ -e /usr/testbed/bin/mkextrafs ]
Andy Bavier2505f592016-11-11 15:58:55 -0500174 then
Zack Williamsf4e65222017-03-01 14:22:37 -0700175 sudo mkdir -p /mnt/extra
176
177 # set partition type of 4th partition to Linux, ignore errors
178 echo -e "t\n4\n82\np\nw\nq" | sudo fdisk /dev/nvme0n1 || true
179
180 sudo mkfs.ext4 /dev/nvme0n1p4
181 echo "/dev/nvme0n1p4 /mnt/extra/ ext4 defaults 0 0" | sudo tee -a /etc/fstab
182 sudo mount /mnt/extra
183 mount | grep nvme0n1p4 || (echo "ERROR: NVME mkfs/mount failed, exiting!" && exit 1)
184
185 elif [ -e /usr/testbed/bin/mkextrafs ] # if on Clemson/Wisconsin Cloudlab
186 then
187 sudo mkdir -p /mnt/extra
188
189 # Sometimes this command fails on the first try
190 sudo /usr/testbed/bin/mkextrafs -r /dev/sdb -qf "/mnt/extra/" || sudo /usr/testbed/bin/mkextrafs -r /dev/sdb -qf "/mnt/extra/"
191
192 # Check that the mount succeeded (sometimes mkextrafs succeeds but device not mounted)
193 mount | grep sdb || (echo "ERROR: mkextrafs failed, exiting!" && exit 1)
Andy Bavier2505f592016-11-11 15:58:55 -0500194 fi
Andy Bavier99c11d32016-09-14 17:21:20 -0400195 fi
Zack Williamsf4e65222017-03-01 14:22:37 -0700196
197 # replace /var/lib/libvirt/images with a symlink
198 [ -d /var/lib/libvirt/images/ ] && [ ! -h /var/lib/libvirt/images ] && sudo rmdir /var/lib/libvirt/images
199 sudo mkdir -p /mnt/extra/libvirt_images
200
201 if [ ! -e /var/lib/libvirt/images ]
202 then
203 sudo ln -s /mnt/extra/libvirt_images /var/lib/libvirt/images
204 fi
Andy Bavier99c11d32016-09-14 17:21:20 -0400205}
206
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800207function elk_up() {
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800208
209 cd $CORDDIR
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800210 sudo chmod +x build/elk-logger/logstash_tail
Zack Williams49af5e62017-03-24 18:02:56 -0700211
212 build/elk-logger/logstash_tail --file install.out --hostport 10.100.198.201:5617 &
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800213}
214
Andy Bavier2505f592016-11-11 15:58:55 -0500215function vagrant_vms_up() {
Zack Williamsa1f55082017-02-28 22:41:36 -0700216
217 echo "Bringing up CORD-in-a-Box Vagrant VM's..."
Andy Bavier99c11d32016-09-14 17:21:20 -0400218 cd $CORDDIR/build
219
Zack Williams9e7249a2017-03-28 13:07:41 -0700220 sudo su $USER -c "VAGRANT_CWD=$VAGRANT_CWD vagrant up corddev prod --provider libvirt"
Andy Baviera69ee722016-11-17 07:26:01 -0800221
222 # This is a workaround for a weird issue with ARP cache timeout breaking 'vagrant ssh'
223 # It allows SSH'ing to the machine via 'ssh corddev'
Zack Williams9e7249a2017-03-28 13:07:41 -0700224 sudo su $USER -c "VAGRANT_CWD=$VAGRANT_CWD vagrant ssh-config corddev prod > $SSHCONFIG"
Andy Bavier2505f592016-11-11 15:58:55 -0500225
Andy Baviera2acd2a2017-06-19 09:57:32 -0400226 # copy host SSH keypair to corddev
Andy Bavier2505f592016-11-11 15:58:55 -0500227 scp ~/.ssh/id_rsa* corddev:.ssh
228 ssh corddev "chmod go-r ~/.ssh/id_rsa"
Andy Bavier99c11d32016-09-14 17:21:20 -0400229}
230
231function install_head_node() {
232 cd $CORDDIR/build
233
Andy Baviera69ee722016-11-17 07:26:01 -0800234 # SSH config saved earlier allows us to connect to VM without running 'vagrant'
Andy Bavierf55e7f92017-06-22 10:16:44 -0400235 ssh corddev "cd $VMDIR; ./gradlew -PdeployConfig=$VMDIR/$CONFIG fetch"
236 ssh corddev "cd $VMDIR; ./gradlew -PdeployConfig=$VMDIR/$CONFIG buildImages"
237 ssh corddev "cd $VMDIR; ping -c 3 prod; ./gradlew -PdeployConfig=$VMDIR/$CONFIG -PtargetReg=10.100.198.201:5000 publish"
238 ssh corddev "cd $VMDIR; ./gradlew -PdeployConfig=$VMDIR/$CONFIG deploy"
Andy Bavier99c11d32016-09-14 17:21:20 -0400239}
240
241function set_up_maas_user() {
Andy Bavier2505f592016-11-11 15:58:55 -0500242 # Set up MAAS user on server to restart nodes via libvirt
243 grep maas /etc/passwd || sudo useradd -m maas
Andy Bavier99c11d32016-09-14 17:21:20 -0400244 sudo adduser maas libvirtd
245
Andy Bavier2505f592016-11-11 15:58:55 -0500246 # Copy generated public key to maas user's authorized_keys
247 sudo su maas -c "mkdir -p ~/.ssh"
248 sudo cp $HOME/.ssh/id_rsa.pub ~maas/.ssh/authorized_keys
249 sudo chown maas:maas ~maas/.ssh/authorized_keys
Andy Bavier99c11d32016-09-14 17:21:20 -0400250
Andy Bavier2505f592016-11-11 15:58:55 -0500251 # Copy generated private key to maas user's home dir in prod VM
252 scp $HOME/.ssh/id_rsa prod:/tmp
253 ssh prod "sudo mkdir -p ~maas/.ssh"
254 ssh prod "sudo cp /tmp/id_rsa ~maas/.ssh/id_rsa"
255 ssh prod "sudo chown -R maas:maas ~maas/.ssh"
256}
Srikanth Vavilapallib1c4da02016-11-17 15:24:28 -0600257
Andy Bavier0f07bb32017-01-17 10:20:26 -0500258function turn_off_learning () {
259 NET=$1
260 BRIDGE=`sudo virsh net-info $NET|grep "Bridge:"|awk '{print $2}'`
261 sudo brctl setageing $BRIDGE 0
262 sudo brctl stp $BRIDGE off
263}
264
265function leaf_spine_up() {
266 cd $CORDDIR/build
267
268 if [[ $FABRIC -ne 0 ]]
269 then
Zack Williams9e7249a2017-03-28 13:07:41 -0700270 sudo su $USER -c "VAGRANT_CWD=$VAGRANT_CWD FABRIC=$FABRIC vagrant up leaf-1 leaf-2 spine-1 spine-2 --provider libvirt"
Andy Bavier0f07bb32017-01-17 10:20:26 -0500271 else
272 # Linux bridging seems to be having issues with two spine switches
Zack Williams9e7249a2017-03-28 13:07:41 -0700273 sudo su $USER -c "VAGRANT_CWD=$VAGRANT_CWD FABRIC=$FABRIC vagrant up leaf-1 leaf-2 spine-1 --provider libvirt"
Andy Bavier0f07bb32017-01-17 10:20:26 -0500274 fi
275
276 # Turn off MAC learning on "links" -- i.e., bridges created by libvirt.
277 # Without this, sometimes packets are dropped because the bridges
278 # think they are not local -- this needs further investigation.
279 # A better solution might be to replace the bridges with UDP tunnels, but this
280 # is not supported with the version of libvirt available on Ubuntu 14.04.
281 turn_off_learning head-node-leaf-1
282 turn_off_learning compute-node-1-leaf-1
283 turn_off_learning compute-node-2-leaf-2
284 turn_off_learning compute-node-3-leaf-2
285 turn_off_learning leaf-1-spine-1
286 turn_off_learning leaf-1-spine-2
287 turn_off_learning leaf-2-spine-1
288 turn_off_learning leaf-2-spine-2
289}
290
Andy Bavier99c11d32016-09-14 17:21:20 -0400291function add_compute_node() {
Srikanth Vavilapallib1c4da02016-11-17 15:24:28 -0600292 echo add_compute_node: $1 $2
Andy Bavier2505f592016-11-11 15:58:55 -0500293
Andy Bavier99c11d32016-09-14 17:21:20 -0400294 cd $CORDDIR/build
Zack Williams9e7249a2017-03-28 13:07:41 -0700295 sudo su $USER -c "VAGRANT_CWD=$VAGRANT_CWD vagrant up $1 --provider libvirt"
Andy Bavier99c11d32016-09-14 17:21:20 -0400296
Andy Bavier2505f592016-11-11 15:58:55 -0500297 # Set up power cycling for the compute node and wait for it to be provisioned
Andy Bavierf55e7f92017-06-22 10:16:44 -0400298 ssh prod "cd $VMDIR/ansible; ansible-playbook maas-provision.yml --extra-vars \"maas_user=maas vagrant_name=$2\""
Andy Bavier99c11d32016-09-14 17:21:20 -0400299
300 echo ""
Andy Bavier0f07bb32017-01-17 10:20:26 -0500301 echo "$1 is fully provisioned!"
302}
303
304function initialize_fabric() {
305 echo "Initializing fabric"
Andy Bavierf55e7f92017-06-22 10:16:44 -0400306 ssh prod "cd $VMDIR/platform-install; ansible-playbook -i /etc/maas/ansible/pod-inventory cord-refresh-fabric.yml"
Andy Bavier0f07bb32017-01-17 10:20:26 -0500307
308 echo "Fabric ping test"
Andy Bavierf55e7f92017-06-22 10:16:44 -0400309 ssh prod "cd $VMDIR/platform-install; ansible-playbook -i /etc/maas/ansible/pod-inventory cord-fabric-pingtest.yml"
Andy Bavier99c11d32016-09-14 17:21:20 -0400310}
311
312function run_e2e_test () {
313 cd $CORDDIR/build
314
Andy Bavier2505f592016-11-11 15:58:55 -0500315 # User has been added to the lbvirtd group, but su $USER to be safe
Andy Bavierf55e7f92017-06-22 10:16:44 -0400316 ssh corddev "cd $VMDIR; ./gradlew -PdeployConfig=$VMDIR/$CONFIG postDeployTests"
Andy Bavier99c11d32016-09-14 17:21:20 -0400317}
318
319function run_diagnostics() {
Andy Bavierf55e7f92017-06-22 10:16:44 -0400320 ssh corddev "cd $VMDIR; ./gradlew -PdeployConfig=$VMDIR/$CONFIG PIrunDiag"
Andy Bavier99c11d32016-09-14 17:21:20 -0400321}
322
323# Parse options
Zack Williamsdae7ff62016-11-14 15:20:06 -0700324GERRIT_BRANCHES=
Andy Bavier99c11d32016-09-14 17:21:20 -0400325RUN_TEST=0
Andy Bavier5c2e4fa2016-10-31 13:50:52 -0400326SETUP_ONLY=0
Andy Bavier99c11d32016-09-14 17:21:20 -0400327DIAGNOSTICS=0
328CLEANUP=0
Andy Bavier0f07bb32017-01-17 10:20:26 -0500329FABRIC=0
Srikanth Vavilapallib1c4da02016-11-17 15:24:28 -0600330#By default, cord-in-a-box creates 1 compute node. If more than one compute is
331#needed, use -n option
332NUM_COMPUTE_NODES=1
Andy Bavier99c11d32016-09-14 17:21:20 -0400333
Andy Bavier0f07bb32017-01-17 10:20:26 -0500334while getopts "b:cdfhn:stv" opt; do
Andy Bavier99c11d32016-09-14 17:21:20 -0400335 case ${opt} in
Zack Williamsdae7ff62016-11-14 15:20:06 -0700336 b ) GERRIT_BRANCHES+=("$OPTARG")
Andy Bavier99c11d32016-09-14 17:21:20 -0400337 ;;
338 c ) CLEANUP=1
339 ;;
340 d ) DIAGNOSTICS=1
341 ;;
Andy Bavier0f07bb32017-01-17 10:20:26 -0500342 f ) FABRIC=1
343 ;;
Andy Bavier99c11d32016-09-14 17:21:20 -0400344 h ) echo "Usage:"
345 echo " $0 install OpenStack and prep XOS and ONOS VMs [default]"
Zack Williamsdae7ff62016-11-14 15:20:06 -0700346 echo " $0 -b <project:changeset/revision> checkout a changesets from gerrit. Can"
347 echo " be used multiple times."
Andy Bavier99c11d32016-09-14 17:21:20 -0400348 echo " $0 -c cleanup from previous test"
349 echo " $0 -d run diagnostic collector"
Andy Bavier0f07bb32017-01-17 10:20:26 -0500350 echo " $0 -f use ONOS fabric (EXPERIMENTAL)"
Andy Bavier99c11d32016-09-14 17:21:20 -0400351 echo " $0 -h display this help message"
Zack Williamsa9e76ec2017-01-20 16:17:35 -0700352 echo " $0 -n # number of compute nodes to setup. Currently max 2 nodes can be supported"
Andy Bavier5c2e4fa2016-10-31 13:50:52 -0400353 echo " $0 -s run initial setup phase only (don't start building CORD)"
Andy Bavier99c11d32016-09-14 17:21:20 -0400354 echo " $0 -t do install, bring up cord-pod configuration, run E2E test"
Andy Bavierd1165102017-01-13 16:38:57 -0500355 echo " $0 -v print CiaB version and exit"
Andy Bavier99c11d32016-09-14 17:21:20 -0400356 exit 0
357 ;;
Srikanth Vavilapallib1c4da02016-11-17 15:24:28 -0600358 n ) NUM_COMPUTE_NODES=$OPTARG
359 ;;
Andy Bavier5c2e4fa2016-10-31 13:50:52 -0400360 s ) SETUP_ONLY=1
361 ;;
Andy Bavier99c11d32016-09-14 17:21:20 -0400362 t ) RUN_TEST=1
363 ;;
Andy Bavierd1165102017-01-13 16:38:57 -0500364 v ) echo "$VERSION_STRING ($REPO_BRANCH branch)"
365 exit 0
366 ;;
Andy Bavier99c11d32016-09-14 17:21:20 -0400367 \? ) echo "Invalid option: -$OPTARG"
368 exit 1
369 ;;
370 esac
371done
372
373# What to do
374if [[ $CLEANUP -eq 1 ]]
375then
Sapan Bhatia3f454b32017-03-01 05:24:19 +0100376 cleanup_from_previous_test
Andy Bavier99c11d32016-09-14 17:21:20 -0400377fi
378
Andy Bavierd1165102017-01-13 16:38:57 -0500379echo ""
380echo "Preparing to install $VERSION_STRING ($REPO_BRANCH branch)"
381echo ""
382
Sapan Bhatiaa94c2db2017-02-27 20:18:24 +0100383bootstrap
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800384run_stage cloudlab_setup
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800385run_stage vagrant_vms_up
Zack Williams49af5e62017-03-24 18:02:56 -0700386run_stage elk_up
Andy Bavier5c2e4fa2016-10-31 13:50:52 -0400387
388if [[ $SETUP_ONLY -ne 0 ]]
389then
390 echo "Finished build environment setup, exiting..."
391 exit 0
392fi
393
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800394run_stage install_head_node
395run_stage set_up_maas_user
396run_stage leaf_spine_up
Srikanth Vavilapallib1c4da02016-11-17 15:24:28 -0600397
Andy Bavier0f07bb32017-01-17 10:20:26 -0500398if [[ $NUM_COMPUTE_NODES -gt 3 ]]
Srikanth Vavilapallib1c4da02016-11-17 15:24:28 -0600399then
Andy Bavier0f07bb32017-01-17 10:20:26 -0500400 echo "currently max only three compute nodes can be supported..."
401 NUM_COMPUTE_NODES=3
Srikanth Vavilapallib1c4da02016-11-17 15:24:28 -0600402fi
403
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800404echo "==> Adding compute nodes: Starting"
Srikanth Vavilapallib1c4da02016-11-17 15:24:28 -0600405for i in `seq 1 $NUM_COMPUTE_NODES`;
406do
407 echo adding the compute node: compute-node-$i
Zack Williams03a20ec2017-04-12 17:39:36 -0700408 add_compute_node compute-node-$i ${VAGRANT_VM_PREFIX}_compute-node-$i
Srikanth Vavilapallib1c4da02016-11-17 15:24:28 -0600409done
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800410echo "==> Adding compute nodes: Complete"
Andy Bavier99c11d32016-09-14 17:21:20 -0400411
Zack Williams4fd3dcc2017-02-08 20:46:14 -0700412# run diagnostics both before/after the fabric/e2e tests
413if [[ $DIAGNOSTICS -eq 1 ]]
414then
415 run_diagnostics
416fi
417
418
Andy Bavier0f07bb32017-01-17 10:20:26 -0500419if [[ $FABRIC -ne 0 ]]
420then
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800421 run_stage initialize_fabric
Andy Bavier0f07bb32017-01-17 10:20:26 -0500422fi
423
Andy Bavier99c11d32016-09-14 17:21:20 -0400424if [[ $RUN_TEST -eq 1 ]]
425then
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800426 run_stage run_e2e_test
Andy Bavier99c11d32016-09-14 17:21:20 -0400427fi
428
429if [[ $DIAGNOSTICS -eq 1 ]]
430then
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800431 run_stage run_diagnostics
Andy Bavier99c11d32016-09-14 17:21:20 -0400432fi
433
434exit 0