blob: 45c2f646f22964cd68bbd5d29ad23b16d2605f58 [file] [log] [blame]
Andy Bavier99c11d32016-09-14 17:21:20 -04001#!/usr/bin/env bash
Zack Williamsa1f55082017-02-28 22:41:36 -07002# cord-in-a-box.sh
Andy Bavier99c11d32016-09-14 17:21:20 -04003
Sapan Bhatia01ddea62017-02-10 11:28:48 -08004set -e -x
Andy Bavier99c11d32016-09-14 17:21:20 -04005
Zack Williamsa1f55082017-02-28 22:41:36 -07006# start time, used to name logfiles
7START_T=$(date -u "+%Y%m%d_%H%M%SZ")
8
9# Paths
Zack Williams0620c932017-01-25 14:36:31 -070010CORDDIR=~/cord
Andy Bavier99c11d32016-09-14 17:21:20 -040011VMDIR=/cord/build/
12CONFIG=config/cord_in_a_box.yml
Andy Baviera69ee722016-11-17 07:26:01 -080013SSHCONFIG=~/.ssh/config
Zack Williams1bffc162017-04-12 16:31:15 -070014VAGRANT_CWD=${CORDDIR}/build/
Zack Williams03a20ec2017-04-12 17:39:36 -070015VAGRANT_VM_PREFIX=build
Andy Bavier99c11d32016-09-14 17:21:20 -040016
Zack Williamsa1f55082017-02-28 22:41:36 -070017# CORD versioning
Andy Bavierd1165102017-01-13 16:38:57 -050018REPO_BRANCH="master"
Zack Williamsa1f55082017-02-28 22:41:36 -070019VERSION_STRING="CiaB Devel"
Andy Bavierd1165102017-01-13 16:38:57 -050020
Sapan Bhatiaa94c2db2017-02-27 20:18:24 +010021function finish {
Sapan Bhatia95692092017-03-01 06:48:19 +010022 EXIT=$?
Sapan Bhatiaeb7819c2017-03-01 15:26:17 +010023 python $CORDDIR/build/elk-logger/mixpanel --event FINISH --corddir $CORDDIR --finish --status $EXIT
Sapan Bhatiaa94c2db2017-02-27 20:18:24 +010024}
25
Andy Bavier0f07bb32017-01-17 10:20:26 -050026function add_box() {
27 vagrant box list | grep $1 | grep virtualbox || vagrant box add $1
28 vagrant box list | grep $1 | grep libvirt || vagrant mutate $1 libvirt --input-provider virtualbox
29}
30
Sapan Bhatia01ddea62017-02-10 11:28:48 -080031function run_stage {
Sapan Bhatiaa94c2db2017-02-27 20:18:24 +010032 cd $CORDDIR
Sapan Bhatiaeb7819c2017-03-01 15:26:17 +010033 python build/elk-logger/mixpanel --event $1-start --corddir $CORDDIR
Sapan Bhatiaa94c2db2017-02-27 20:18:24 +010034
Sapan Bhatia01ddea62017-02-10 11:28:48 -080035 echo "==> "$1": Starting"
36 $1
37 echo "==> "$1": Complete"
Sapan Bhatiaa94c2db2017-02-27 20:18:24 +010038
39 cd $CORDDIR
Sapan Bhatiaeb7819c2017-03-01 15:26:17 +010040 python build/elk-logger/mixpanel --event $1-end --corddir $CORDDIR
Sapan Bhatia01ddea62017-02-10 11:28:48 -080041}
42
Andy Bavier99c11d32016-09-14 17:21:20 -040043function cleanup_from_previous_test() {
Andy Bavier99c11d32016-09-14 17:21:20 -040044 echo "## Cleanup ##"
45
Andy Baviera4883ba2016-12-21 15:46:58 -050046 if [ -d $CORDDIR/build ]
47 then
48 echo "Destroying all Vagrant VMs"
49 cd $CORDDIR/build
Zack Williamsa1f55082017-02-28 22:41:36 -070050 for i in `seq 12`; do
Zack Williams9e7249a2017-03-28 13:07:41 -070051 sudo su $USER -c "VAGRANT_CWD=$VAGRANT_CWD vagrant destroy" && break
Zack Williamsa1f55082017-02-28 22:41:36 -070052 done
Andy Baviera4883ba2016-12-21 15:46:58 -050053 fi
Andy Bavier99c11d32016-09-14 17:21:20 -040054
Andy Bavier2505f592016-11-11 15:58:55 -050055 echo "Removing $CORDDIR"
56 cd ~
Andy Bavier99c11d32016-09-14 17:21:20 -040057 rm -rf $CORDDIR
Andy Bavier99c11d32016-09-14 17:21:20 -040058}
59
60function bootstrap() {
Zack Williamsa1f55082017-02-28 22:41:36 -070061
Sapan Bhatia95692092017-03-01 06:48:19 +010062 echo "Generating build id"
Sapan Bhatia77f26672017-03-13 18:30:25 +010063 rm -f /tmp/cord-build-version
Sapan Bhatia95692092017-03-01 06:48:19 +010064 dd bs=18 count=1 if=/dev/urandom | base64 | tr +/ _. > /tmp/cord-build
Andy Bavier99c11d32016-09-14 17:21:20 -040065
Zack Williamsa1f55082017-02-28 22:41:36 -070066 if [ ! -x "/usr/local/bin/repo" ]
67 then
68 echo "Installing repo..."
69 REPO_SHA256SUM="e147f0392686c40cfd7d5e6f332c6ee74c4eab4d24e2694b3b0a0c037bf51dc5" # not versioned...
70 curl -o /tmp/repo https://storage.googleapis.com/git-repo-downloads/repo
71 echo "$REPO_SHA256SUM /tmp/repo" | sha256sum -c -
72 sudo mv /tmp/repo /usr/local/bin/repo
73 sudo chmod a+x /usr/local/bin/repo
74 fi
75
76 if [ ! -x "/usr/bin/vagrant" ]
77 then
78 echo "Installing vagrant and associated tools..."
79 VAGRANT_SHA256SUM="faff6befacc7eed3978b4b71f0dbb9c135c01d8a4d13236bda2f9ed53482d2c4" # version 1.9.3
80 curl -o /tmp/vagrant.deb https://releases.hashicorp.com/vagrant/1.9.3/vagrant_1.9.3_x86_64.deb
81 echo "$VAGRANT_SHA256SUM /tmp/vagrant.deb" | sha256sum -c -
82 sudo apt-get update
83 sudo dpkg -i /tmp/vagrant.deb
Zack Williams2f130922017-04-28 15:02:09 -070084 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 -070085 sudo adduser $USER libvirtd
86 sudo pip install pyparsing python-logstash mixpanel
87 fi
88
89 echo "Installing vagrant plugins..."
Zack Williams2f130922017-04-28 15:02:09 -070090 # FIXME: fix for vagrant-libvirt dependency issue that arose on 2017-04-28 - zdw
91 # vagrant plugin list | grep vagrant-libvirt || vagrant plugin install vagrant-libvirt --plugin-version 0.0.35
92 if ! vagrant plugin list | grep vagrant-libvirt
93 then
94 git clone -b remove_xmlrpc_dep https://github.com/zdw/vagrant-libvirt.git ~/vagrant-libvirt
95 cd ~/vagrant-libvirt
96 gem2.0 build vagrant-libvirt.gemspec
97 vagrant plugin install vagrant-libvirt-0.0.35.gem
98 cd ~
99 fi
100
Zack Williamsa1f55082017-02-28 22:41:36 -0700101 vagrant plugin list | grep vagrant-mutate || vagrant plugin install vagrant-mutate
102
103 add_box ubuntu/trusty64
104
105 echo "Creating SSH key..."
Andy Bavier99c11d32016-09-14 17:21:20 -0400106 [ -e ~/.ssh/id_rsa ] || ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
Andy Bavier99c11d32016-09-14 17:21:20 -0400107
Andy Bavier99c11d32016-09-14 17:21:20 -0400108 if [ ! -d "$CORDDIR" ]
109 then
Zack Williamsa1f55082017-02-28 22:41:36 -0700110 echo "Downloading CORD/XOS..."
111
112 if [ ! -e "~/.gitconfig" ]
113 then
114 echo "No ~/.gitconfig, setting testing defaults"
115 git config --global user.name 'Test User'
116 git config --global user.email 'test@null.com'
117 git config --global color.ui false
118 fi
119
120 # make sure we can find gerrit.opencord.org as DNS failures will fail the build
121 dig +short gerrit.opencord.org || (echo "ERROR: gerrit.opencord.org can't be looked up in DNS" && exit 1)
122
Andy Bavier99c11d32016-09-14 17:21:20 -0400123 mkdir $CORDDIR && cd $CORDDIR
Matteo Scandolo4d7d1662017-05-30 11:20:57 -0700124 repo init -u https://gerrit.opencord.org/manifest -b $REPO_BRANCH
Andy Bavier99c11d32016-09-14 17:21:20 -0400125 repo sync
126
Zack Williamsdae7ff62016-11-14 15:20:06 -0700127 # check out gerrit branches using repo
128 for gerrit_branch in ${GERRIT_BRANCHES[@]}; do
Zack Williamsa1f55082017-02-28 22:41:36 -0700129 echo "Checking out opencord gerrit branch: $gerrit_branch"
Zack Williamsdae7ff62016-11-14 15:20:06 -0700130 repo download ${gerrit_branch/:/ }
131 done
Andy Bavier99c11d32016-09-14 17:21:20 -0400132 fi
133
Sapan Bhatia868e0012017-02-15 22:14:11 -0800134 exec > >(tee -i $CORDDIR/install.out)
135 exec 2>&1
136
Sapan Bhatia95692092017-03-01 06:48:19 +0100137 # Start tracking failures from this point
138 trap finish EXIT
139
Andy Bavier99c11d32016-09-14 17:21:20 -0400140}
141
142function cloudlab_setup() {
Andy Bavier8b4ed1f2017-02-13 17:06:58 -0800143
Andy Bavier46dfda62017-03-02 05:40:08 -0500144 # Don't do anything if not a CloudLab node
145 [ ! -d /usr/local/etc/emulab ] && return
146
Andy Bavier8b4ed1f2017-02-13 17:06:58 -0800147 # The watchdog will sometimes reset groups, turn it off
148 if [ -e /usr/local/etc/emulab/watchdog ]
149 then
150 sudo /usr/bin/perl -w /usr/local/etc/emulab/watchdog stop
151 sudo mv /usr/local/etc/emulab/watchdog /usr/local/etc/emulab/watchdog-disabled
152 fi
153
Zack Williamsf4e65222017-03-01 14:22:37 -0700154 # Mount extra space, if haven't already
155 if [ ! -d /mnt/extra ]
Andy Bavier99c11d32016-09-14 17:21:20 -0400156 then
Zack Williamsf4e65222017-03-01 14:22:37 -0700157 # for NVME SSD on Utah Cloudlab, not supported by mkextrafs
158 if $(df | grep -q nvme0n1p1) && [ -e /usr/testbed/bin/mkextrafs ]
Andy Bavier2505f592016-11-11 15:58:55 -0500159 then
Zack Williamsf4e65222017-03-01 14:22:37 -0700160 sudo mkdir -p /mnt/extra
161
162 # set partition type of 4th partition to Linux, ignore errors
163 echo -e "t\n4\n82\np\nw\nq" | sudo fdisk /dev/nvme0n1 || true
164
165 sudo mkfs.ext4 /dev/nvme0n1p4
166 echo "/dev/nvme0n1p4 /mnt/extra/ ext4 defaults 0 0" | sudo tee -a /etc/fstab
167 sudo mount /mnt/extra
168 mount | grep nvme0n1p4 || (echo "ERROR: NVME mkfs/mount failed, exiting!" && exit 1)
169
170 elif [ -e /usr/testbed/bin/mkextrafs ] # if on Clemson/Wisconsin Cloudlab
171 then
172 sudo mkdir -p /mnt/extra
173
174 # Sometimes this command fails on the first try
175 sudo /usr/testbed/bin/mkextrafs -r /dev/sdb -qf "/mnt/extra/" || sudo /usr/testbed/bin/mkextrafs -r /dev/sdb -qf "/mnt/extra/"
176
177 # Check that the mount succeeded (sometimes mkextrafs succeeds but device not mounted)
178 mount | grep sdb || (echo "ERROR: mkextrafs failed, exiting!" && exit 1)
Andy Bavier2505f592016-11-11 15:58:55 -0500179 fi
Andy Bavier99c11d32016-09-14 17:21:20 -0400180 fi
Zack Williamsf4e65222017-03-01 14:22:37 -0700181
182 # replace /var/lib/libvirt/images with a symlink
183 [ -d /var/lib/libvirt/images/ ] && [ ! -h /var/lib/libvirt/images ] && sudo rmdir /var/lib/libvirt/images
184 sudo mkdir -p /mnt/extra/libvirt_images
185
186 if [ ! -e /var/lib/libvirt/images ]
187 then
188 sudo ln -s /mnt/extra/libvirt_images /var/lib/libvirt/images
189 fi
Andy Bavier99c11d32016-09-14 17:21:20 -0400190}
191
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800192function elk_up() {
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800193
194 cd $CORDDIR
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800195 sudo chmod +x build/elk-logger/logstash_tail
Zack Williams49af5e62017-03-24 18:02:56 -0700196
197 build/elk-logger/logstash_tail --file install.out --hostport 10.100.198.201:5617 &
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800198}
199
Andy Bavier2505f592016-11-11 15:58:55 -0500200function vagrant_vms_up() {
Zack Williamsa1f55082017-02-28 22:41:36 -0700201
202 echo "Bringing up CORD-in-a-Box Vagrant VM's..."
Andy Bavier99c11d32016-09-14 17:21:20 -0400203 cd $CORDDIR/build
204
Zack Williams9e7249a2017-03-28 13:07:41 -0700205 sudo su $USER -c "VAGRANT_CWD=$VAGRANT_CWD vagrant up corddev prod --provider libvirt"
Andy Baviera69ee722016-11-17 07:26:01 -0800206
207 # This is a workaround for a weird issue with ARP cache timeout breaking 'vagrant ssh'
208 # It allows SSH'ing to the machine via 'ssh corddev'
Zack Williams9e7249a2017-03-28 13:07:41 -0700209 sudo su $USER -c "VAGRANT_CWD=$VAGRANT_CWD vagrant ssh-config corddev prod > $SSHCONFIG"
Andy Bavier2505f592016-11-11 15:58:55 -0500210
Zack Williams83a94ce2017-05-20 13:36:09 -0700211 # copy host SSH key to corddev, allow it access on prod (vagrant ssh key already has access)
Andy Bavier2505f592016-11-11 15:58:55 -0500212 scp ~/.ssh/id_rsa* corddev:.ssh
213 ssh corddev "chmod go-r ~/.ssh/id_rsa"
Zack Williams83a94ce2017-05-20 13:36:09 -0700214
215 scp ~/.ssh/id_rsa.pub prod:/tmp/install_id_rsa.pub
216 ssh prod "cat /tmp/install_id_rsa.pub >> ~/.ssh/authorized_keys"
Andy Bavier99c11d32016-09-14 17:21:20 -0400217}
218
219function install_head_node() {
220 cd $CORDDIR/build
221
Andy Baviera69ee722016-11-17 07:26:01 -0800222 # SSH config saved earlier allows us to connect to VM without running 'vagrant'
Zack Williams0620c932017-01-25 14:36:31 -0700223 ssh corddev "cd /cord/build; ./gradlew -PdeployConfig=$VMDIR/$CONFIG fetch"
224 ssh corddev "cd /cord/build; ./gradlew -PdeployConfig=$VMDIR/$CONFIG buildImages"
Andy Bavier2505f592016-11-11 15:58:55 -0500225 ssh corddev "cd /cord/build; ping -c 3 prod; ./gradlew -PdeployConfig=$VMDIR/$CONFIG -PtargetReg=10.100.198.201:5000 publish"
Andy Baviera69ee722016-11-17 07:26:01 -0800226 ssh corddev "cd /cord/build; ./gradlew -PdeployConfig=$VMDIR/$CONFIG deploy"
Andy Bavier99c11d32016-09-14 17:21:20 -0400227}
228
229function set_up_maas_user() {
Andy Bavier2505f592016-11-11 15:58:55 -0500230 # Set up MAAS user on server to restart nodes via libvirt
231 grep maas /etc/passwd || sudo useradd -m maas
Andy Bavier99c11d32016-09-14 17:21:20 -0400232 sudo adduser maas libvirtd
233
Andy Bavier2505f592016-11-11 15:58:55 -0500234 # Copy generated public key to maas user's authorized_keys
235 sudo su maas -c "mkdir -p ~/.ssh"
236 sudo cp $HOME/.ssh/id_rsa.pub ~maas/.ssh/authorized_keys
237 sudo chown maas:maas ~maas/.ssh/authorized_keys
Andy Bavier99c11d32016-09-14 17:21:20 -0400238
Andy Bavier2505f592016-11-11 15:58:55 -0500239 # Copy generated private key to maas user's home dir in prod VM
240 scp $HOME/.ssh/id_rsa prod:/tmp
241 ssh prod "sudo mkdir -p ~maas/.ssh"
242 ssh prod "sudo cp /tmp/id_rsa ~maas/.ssh/id_rsa"
243 ssh prod "sudo chown -R maas:maas ~maas/.ssh"
244}
Srikanth Vavilapallib1c4da02016-11-17 15:24:28 -0600245
Andy Bavier0f07bb32017-01-17 10:20:26 -0500246function turn_off_learning () {
247 NET=$1
248 BRIDGE=`sudo virsh net-info $NET|grep "Bridge:"|awk '{print $2}'`
249 sudo brctl setageing $BRIDGE 0
250 sudo brctl stp $BRIDGE off
251}
252
253function leaf_spine_up() {
254 cd $CORDDIR/build
255
256 if [[ $FABRIC -ne 0 ]]
257 then
Zack Williams9e7249a2017-03-28 13:07:41 -0700258 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 -0500259 else
260 # Linux bridging seems to be having issues with two spine switches
Zack Williams9e7249a2017-03-28 13:07:41 -0700261 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 -0500262 fi
263
264 # Turn off MAC learning on "links" -- i.e., bridges created by libvirt.
265 # Without this, sometimes packets are dropped because the bridges
266 # think they are not local -- this needs further investigation.
267 # A better solution might be to replace the bridges with UDP tunnels, but this
268 # is not supported with the version of libvirt available on Ubuntu 14.04.
269 turn_off_learning head-node-leaf-1
270 turn_off_learning compute-node-1-leaf-1
271 turn_off_learning compute-node-2-leaf-2
272 turn_off_learning compute-node-3-leaf-2
273 turn_off_learning leaf-1-spine-1
274 turn_off_learning leaf-1-spine-2
275 turn_off_learning leaf-2-spine-1
276 turn_off_learning leaf-2-spine-2
277}
278
Andy Bavier99c11d32016-09-14 17:21:20 -0400279function add_compute_node() {
Srikanth Vavilapallib1c4da02016-11-17 15:24:28 -0600280 echo add_compute_node: $1 $2
Andy Bavier2505f592016-11-11 15:58:55 -0500281
Andy Bavier99c11d32016-09-14 17:21:20 -0400282 cd $CORDDIR/build
Zack Williams9e7249a2017-03-28 13:07:41 -0700283 sudo su $USER -c "VAGRANT_CWD=$VAGRANT_CWD vagrant up $1 --provider libvirt"
Andy Bavier99c11d32016-09-14 17:21:20 -0400284
Andy Bavier2505f592016-11-11 15:58:55 -0500285 # Set up power cycling for the compute node and wait for it to be provisioned
286 ssh prod "cd /cord/build/ansible; ansible-playbook maas-provision.yml --extra-vars \"maas_user=maas vagrant_name=$2\""
Andy Bavier99c11d32016-09-14 17:21:20 -0400287
288 echo ""
Andy Bavier0f07bb32017-01-17 10:20:26 -0500289 echo "$1 is fully provisioned!"
290}
291
292function initialize_fabric() {
293 echo "Initializing fabric"
294 ssh prod "cd /cord/build/platform-install; ansible-playbook -i /etc/maas/ansible/pod-inventory cord-refresh-fabric.yml"
295
296 echo "Fabric ping test"
297 ssh prod "cd /cord/build/platform-install; ansible-playbook -i /etc/maas/ansible/pod-inventory cord-fabric-pingtest.yml"
Andy Bavier99c11d32016-09-14 17:21:20 -0400298}
299
300function run_e2e_test () {
301 cd $CORDDIR/build
302
Andy Bavier2505f592016-11-11 15:58:55 -0500303 # User has been added to the lbvirtd group, but su $USER to be safe
Andy Baviera69ee722016-11-17 07:26:01 -0800304 ssh corddev "cd /cord/build; ./gradlew -PdeployConfig=$VMDIR/$CONFIG postDeployTests"
Andy Bavier99c11d32016-09-14 17:21:20 -0400305}
306
307function run_diagnostics() {
Zack Williams4fd3dcc2017-02-08 20:46:14 -0700308 ssh corddev "cd /cord/build; ./gradlew -PdeployConfig=$VMDIR/$CONFIG PIrunDiag"
Andy Bavier99c11d32016-09-14 17:21:20 -0400309}
310
311# Parse options
Zack Williamsdae7ff62016-11-14 15:20:06 -0700312GERRIT_BRANCHES=
Andy Bavier99c11d32016-09-14 17:21:20 -0400313RUN_TEST=0
Andy Bavier5c2e4fa2016-10-31 13:50:52 -0400314SETUP_ONLY=0
Andy Bavier99c11d32016-09-14 17:21:20 -0400315DIAGNOSTICS=0
316CLEANUP=0
Andy Bavier0f07bb32017-01-17 10:20:26 -0500317FABRIC=0
Srikanth Vavilapallib1c4da02016-11-17 15:24:28 -0600318#By default, cord-in-a-box creates 1 compute node. If more than one compute is
319#needed, use -n option
320NUM_COMPUTE_NODES=1
Andy Bavier99c11d32016-09-14 17:21:20 -0400321
Andy Bavier0f07bb32017-01-17 10:20:26 -0500322while getopts "b:cdfhn:stv" opt; do
Andy Bavier99c11d32016-09-14 17:21:20 -0400323 case ${opt} in
Zack Williamsdae7ff62016-11-14 15:20:06 -0700324 b ) GERRIT_BRANCHES+=("$OPTARG")
Andy Bavier99c11d32016-09-14 17:21:20 -0400325 ;;
326 c ) CLEANUP=1
327 ;;
328 d ) DIAGNOSTICS=1
329 ;;
Andy Bavier0f07bb32017-01-17 10:20:26 -0500330 f ) FABRIC=1
331 ;;
Andy Bavier99c11d32016-09-14 17:21:20 -0400332 h ) echo "Usage:"
333 echo " $0 install OpenStack and prep XOS and ONOS VMs [default]"
Zack Williamsdae7ff62016-11-14 15:20:06 -0700334 echo " $0 -b <project:changeset/revision> checkout a changesets from gerrit. Can"
335 echo " be used multiple times."
Andy Bavier99c11d32016-09-14 17:21:20 -0400336 echo " $0 -c cleanup from previous test"
337 echo " $0 -d run diagnostic collector"
Andy Bavier0f07bb32017-01-17 10:20:26 -0500338 echo " $0 -f use ONOS fabric (EXPERIMENTAL)"
Andy Bavier99c11d32016-09-14 17:21:20 -0400339 echo " $0 -h display this help message"
Zack Williamsa9e76ec2017-01-20 16:17:35 -0700340 echo " $0 -n # number of compute nodes to setup. Currently max 2 nodes can be supported"
Andy Bavier5c2e4fa2016-10-31 13:50:52 -0400341 echo " $0 -s run initial setup phase only (don't start building CORD)"
Andy Bavier99c11d32016-09-14 17:21:20 -0400342 echo " $0 -t do install, bring up cord-pod configuration, run E2E test"
Andy Bavierd1165102017-01-13 16:38:57 -0500343 echo " $0 -v print CiaB version and exit"
Andy Bavier99c11d32016-09-14 17:21:20 -0400344 exit 0
345 ;;
Srikanth Vavilapallib1c4da02016-11-17 15:24:28 -0600346 n ) NUM_COMPUTE_NODES=$OPTARG
347 ;;
Andy Bavier5c2e4fa2016-10-31 13:50:52 -0400348 s ) SETUP_ONLY=1
349 ;;
Andy Bavier99c11d32016-09-14 17:21:20 -0400350 t ) RUN_TEST=1
351 ;;
Andy Bavierd1165102017-01-13 16:38:57 -0500352 v ) echo "$VERSION_STRING ($REPO_BRANCH branch)"
353 exit 0
354 ;;
Andy Bavier99c11d32016-09-14 17:21:20 -0400355 \? ) echo "Invalid option: -$OPTARG"
356 exit 1
357 ;;
358 esac
359done
360
361# What to do
362if [[ $CLEANUP -eq 1 ]]
363then
Sapan Bhatia3f454b32017-03-01 05:24:19 +0100364 cleanup_from_previous_test
Andy Bavier99c11d32016-09-14 17:21:20 -0400365fi
366
Andy Bavierd1165102017-01-13 16:38:57 -0500367echo ""
368echo "Preparing to install $VERSION_STRING ($REPO_BRANCH branch)"
369echo ""
370
Sapan Bhatiaa94c2db2017-02-27 20:18:24 +0100371bootstrap
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800372run_stage cloudlab_setup
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800373run_stage vagrant_vms_up
Zack Williams49af5e62017-03-24 18:02:56 -0700374run_stage elk_up
Andy Bavier5c2e4fa2016-10-31 13:50:52 -0400375
376if [[ $SETUP_ONLY -ne 0 ]]
377then
378 echo "Finished build environment setup, exiting..."
379 exit 0
380fi
381
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800382run_stage install_head_node
383run_stage set_up_maas_user
384run_stage leaf_spine_up
Srikanth Vavilapallib1c4da02016-11-17 15:24:28 -0600385
Andy Bavier0f07bb32017-01-17 10:20:26 -0500386if [[ $NUM_COMPUTE_NODES -gt 3 ]]
Srikanth Vavilapallib1c4da02016-11-17 15:24:28 -0600387then
Andy Bavier0f07bb32017-01-17 10:20:26 -0500388 echo "currently max only three compute nodes can be supported..."
389 NUM_COMPUTE_NODES=3
Srikanth Vavilapallib1c4da02016-11-17 15:24:28 -0600390fi
391
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800392echo "==> Adding compute nodes: Starting"
Srikanth Vavilapallib1c4da02016-11-17 15:24:28 -0600393for i in `seq 1 $NUM_COMPUTE_NODES`;
394do
395 echo adding the compute node: compute-node-$i
Zack Williams03a20ec2017-04-12 17:39:36 -0700396 add_compute_node compute-node-$i ${VAGRANT_VM_PREFIX}_compute-node-$i
Srikanth Vavilapallib1c4da02016-11-17 15:24:28 -0600397done
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800398echo "==> Adding compute nodes: Complete"
Andy Bavier99c11d32016-09-14 17:21:20 -0400399
Zack Williams4fd3dcc2017-02-08 20:46:14 -0700400# run diagnostics both before/after the fabric/e2e tests
401if [[ $DIAGNOSTICS -eq 1 ]]
402then
403 run_diagnostics
404fi
405
406
Andy Bavier0f07bb32017-01-17 10:20:26 -0500407if [[ $FABRIC -ne 0 ]]
408then
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800409 run_stage initialize_fabric
Andy Bavier0f07bb32017-01-17 10:20:26 -0500410fi
411
Andy Bavier99c11d32016-09-14 17:21:20 -0400412if [[ $RUN_TEST -eq 1 ]]
413then
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800414 run_stage run_e2e_test
Andy Bavier99c11d32016-09-14 17:21:20 -0400415fi
416
417if [[ $DIAGNOSTICS -eq 1 ]]
418then
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800419 run_stage run_diagnostics
Andy Bavier99c11d32016-09-14 17:21:20 -0400420fi
421
422exit 0