blob: cb3a46878789bccd6feb5956d6ce9d99725bf599 [file] [log] [blame]
Matteo Scandolo60b640f2017-08-08 13:05:22 -07001
2# Copyright 2017-present Open Networking Foundation
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
Andy Bavier99c11d32016-09-14 17:21:20 -040017#!/usr/bin/env bash
Zack Williamsa1f55082017-02-28 22:41:36 -070018# cord-in-a-box.sh
Andy Bavier99c11d32016-09-14 17:21:20 -040019
Sapan Bhatia01ddea62017-02-10 11:28:48 -080020set -e -x
Andy Bavier99c11d32016-09-14 17:21:20 -040021
Zack Williamsa1f55082017-02-28 22:41:36 -070022# start time, used to name logfiles
23START_T=$(date -u "+%Y%m%d_%H%M%SZ")
24
25# Paths
Zack Williams0620c932017-01-25 14:36:31 -070026CORDDIR=~/cord
Andy Bavierf55e7f92017-06-22 10:16:44 -040027VMDIR=/opt/cord/build/
Andy Bavier99c11d32016-09-14 17:21:20 -040028CONFIG=config/cord_in_a_box.yml
Andy Baviera69ee722016-11-17 07:26:01 -080029SSHCONFIG=~/.ssh/config
Zack Williams1bffc162017-04-12 16:31:15 -070030VAGRANT_CWD=${CORDDIR}/build/
Zack Williams03a20ec2017-04-12 17:39:36 -070031VAGRANT_VM_PREFIX=build
Andy Bavier99c11d32016-09-14 17:21:20 -040032
Zack Williamsa1f55082017-02-28 22:41:36 -070033# CORD versioning
Andy Bavierd1165102017-01-13 16:38:57 -050034REPO_BRANCH="master"
Zack Williamsa1f55082017-02-28 22:41:36 -070035VERSION_STRING="CiaB Devel"
Andy Bavierd1165102017-01-13 16:38:57 -050036
Sapan Bhatiaa94c2db2017-02-27 20:18:24 +010037function finish {
Sapan Bhatia95692092017-03-01 06:48:19 +010038 EXIT=$?
Sapan Bhatiaeb7819c2017-03-01 15:26:17 +010039 python $CORDDIR/build/elk-logger/mixpanel --event FINISH --corddir $CORDDIR --finish --status $EXIT
Sapan Bhatiaa94c2db2017-02-27 20:18:24 +010040}
41
Andy Bavier0f07bb32017-01-17 10:20:26 -050042function add_box() {
43 vagrant box list | grep $1 | grep virtualbox || vagrant box add $1
44 vagrant box list | grep $1 | grep libvirt || vagrant mutate $1 libvirt --input-provider virtualbox
45}
46
Sapan Bhatia01ddea62017-02-10 11:28:48 -080047function run_stage {
Sapan Bhatiaa94c2db2017-02-27 20:18:24 +010048 cd $CORDDIR
Sapan Bhatiaeb7819c2017-03-01 15:26:17 +010049 python build/elk-logger/mixpanel --event $1-start --corddir $CORDDIR
Sapan Bhatiaa94c2db2017-02-27 20:18:24 +010050
Sapan Bhatia01ddea62017-02-10 11:28:48 -080051 echo "==> "$1": Starting"
52 $1
53 echo "==> "$1": Complete"
Sapan Bhatiaa94c2db2017-02-27 20:18:24 +010054
55 cd $CORDDIR
Sapan Bhatiaeb7819c2017-03-01 15:26:17 +010056 python build/elk-logger/mixpanel --event $1-end --corddir $CORDDIR
Sapan Bhatia01ddea62017-02-10 11:28:48 -080057}
58
Andy Bavier99c11d32016-09-14 17:21:20 -040059function cleanup_from_previous_test() {
Andy Bavier99c11d32016-09-14 17:21:20 -040060 echo "## Cleanup ##"
61
Andy Baviera4883ba2016-12-21 15:46:58 -050062 if [ -d $CORDDIR/build ]
63 then
64 echo "Destroying all Vagrant VMs"
65 cd $CORDDIR/build
Zack Williamsa1f55082017-02-28 22:41:36 -070066 for i in `seq 12`; do
Zack Williams9e7249a2017-03-28 13:07:41 -070067 sudo su $USER -c "VAGRANT_CWD=$VAGRANT_CWD vagrant destroy" && break
Zack Williamsa1f55082017-02-28 22:41:36 -070068 done
Andy Baviera4883ba2016-12-21 15:46:58 -050069 fi
Andy Bavier99c11d32016-09-14 17:21:20 -040070
Andy Bavier2505f592016-11-11 15:58:55 -050071 echo "Removing $CORDDIR"
72 cd ~
Andy Bavier99c11d32016-09-14 17:21:20 -040073 rm -rf $CORDDIR
Andy Bavier99c11d32016-09-14 17:21:20 -040074}
75
76function bootstrap() {
Zack Williamsa1f55082017-02-28 22:41:36 -070077
Sapan Bhatia95692092017-03-01 06:48:19 +010078 echo "Generating build id"
Sapan Bhatia77f26672017-03-13 18:30:25 +010079 rm -f /tmp/cord-build-version
Sapan Bhatia95692092017-03-01 06:48:19 +010080 dd bs=18 count=1 if=/dev/urandom | base64 | tr +/ _. > /tmp/cord-build
Andy Bavier99c11d32016-09-14 17:21:20 -040081
Zack Williamsa1f55082017-02-28 22:41:36 -070082 if [ ! -x "/usr/local/bin/repo" ]
83 then
84 echo "Installing repo..."
85 REPO_SHA256SUM="e147f0392686c40cfd7d5e6f332c6ee74c4eab4d24e2694b3b0a0c037bf51dc5" # not versioned...
86 curl -o /tmp/repo https://storage.googleapis.com/git-repo-downloads/repo
87 echo "$REPO_SHA256SUM /tmp/repo" | sha256sum -c -
88 sudo mv /tmp/repo /usr/local/bin/repo
89 sudo chmod a+x /usr/local/bin/repo
90 fi
91
92 if [ ! -x "/usr/bin/vagrant" ]
93 then
94 echo "Installing vagrant and associated tools..."
95 VAGRANT_SHA256SUM="faff6befacc7eed3978b4b71f0dbb9c135c01d8a4d13236bda2f9ed53482d2c4" # version 1.9.3
96 curl -o /tmp/vagrant.deb https://releases.hashicorp.com/vagrant/1.9.3/vagrant_1.9.3_x86_64.deb
97 echo "$VAGRANT_SHA256SUM /tmp/vagrant.deb" | sha256sum -c -
98 sudo apt-get update
99 sudo dpkg -i /tmp/vagrant.deb
Zack Williams2f130922017-04-28 15:02:09 -0700100 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 -0700101 sudo adduser $USER libvirtd
102 sudo pip install pyparsing python-logstash mixpanel
103 fi
104
105 echo "Installing vagrant plugins..."
Zack Williams2f130922017-04-28 15:02:09 -0700106 # FIXME: fix for vagrant-libvirt dependency issue that arose on 2017-04-28 - zdw
107 # vagrant plugin list | grep vagrant-libvirt || vagrant plugin install vagrant-libvirt --plugin-version 0.0.35
108 if ! vagrant plugin list | grep vagrant-libvirt
109 then
110 git clone -b remove_xmlrpc_dep https://github.com/zdw/vagrant-libvirt.git ~/vagrant-libvirt
111 cd ~/vagrant-libvirt
112 gem2.0 build vagrant-libvirt.gemspec
113 vagrant plugin install vagrant-libvirt-0.0.35.gem
114 cd ~
115 fi
116
Zack Williamsa1f55082017-02-28 22:41:36 -0700117 vagrant plugin list | grep vagrant-mutate || vagrant plugin install vagrant-mutate
118
119 add_box ubuntu/trusty64
120
121 echo "Creating SSH key..."
Andy Bavier99c11d32016-09-14 17:21:20 -0400122 [ -e ~/.ssh/id_rsa ] || ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
Andy Bavier99c11d32016-09-14 17:21:20 -0400123
Andy Bavier99c11d32016-09-14 17:21:20 -0400124 if [ ! -d "$CORDDIR" ]
125 then
Zack Williamsa1f55082017-02-28 22:41:36 -0700126 echo "Downloading CORD/XOS..."
127
128 if [ ! -e "~/.gitconfig" ]
129 then
130 echo "No ~/.gitconfig, setting testing defaults"
131 git config --global user.name 'Test User'
132 git config --global user.email 'test@null.com'
133 git config --global color.ui false
134 fi
135
136 # make sure we can find gerrit.opencord.org as DNS failures will fail the build
137 dig +short gerrit.opencord.org || (echo "ERROR: gerrit.opencord.org can't be looked up in DNS" && exit 1)
138
Andy Bavier99c11d32016-09-14 17:21:20 -0400139 mkdir $CORDDIR && cd $CORDDIR
Matteo Scandolo4d7d1662017-05-30 11:20:57 -0700140 repo init -u https://gerrit.opencord.org/manifest -b $REPO_BRANCH
Andy Bavier99c11d32016-09-14 17:21:20 -0400141 repo sync
142
Zack Williamsdae7ff62016-11-14 15:20:06 -0700143 # check out gerrit branches using repo
144 for gerrit_branch in ${GERRIT_BRANCHES[@]}; do
Zack Williamsa1f55082017-02-28 22:41:36 -0700145 echo "Checking out opencord gerrit branch: $gerrit_branch"
Zack Williamsdae7ff62016-11-14 15:20:06 -0700146 repo download ${gerrit_branch/:/ }
147 done
Andy Bavier99c11d32016-09-14 17:21:20 -0400148 fi
149
Sapan Bhatia868e0012017-02-15 22:14:11 -0800150 exec > >(tee -i $CORDDIR/install.out)
151 exec 2>&1
152
Sapan Bhatia95692092017-03-01 06:48:19 +0100153 # Start tracking failures from this point
154 trap finish EXIT
155
Andy Bavier99c11d32016-09-14 17:21:20 -0400156}
157
158function cloudlab_setup() {
Andy Bavier8b4ed1f2017-02-13 17:06:58 -0800159
Andy Bavier46dfda62017-03-02 05:40:08 -0500160 # Don't do anything if not a CloudLab node
161 [ ! -d /usr/local/etc/emulab ] && return
162
Andy Bavier8b4ed1f2017-02-13 17:06:58 -0800163 # The watchdog will sometimes reset groups, turn it off
164 if [ -e /usr/local/etc/emulab/watchdog ]
165 then
166 sudo /usr/bin/perl -w /usr/local/etc/emulab/watchdog stop
167 sudo mv /usr/local/etc/emulab/watchdog /usr/local/etc/emulab/watchdog-disabled
168 fi
169
Zack Williamsf4e65222017-03-01 14:22:37 -0700170 # Mount extra space, if haven't already
171 if [ ! -d /mnt/extra ]
Andy Bavier99c11d32016-09-14 17:21:20 -0400172 then
Zack Williamsf4e65222017-03-01 14:22:37 -0700173 # for NVME SSD on Utah Cloudlab, not supported by mkextrafs
174 if $(df | grep -q nvme0n1p1) && [ -e /usr/testbed/bin/mkextrafs ]
Andy Bavier2505f592016-11-11 15:58:55 -0500175 then
Zack Williamsf4e65222017-03-01 14:22:37 -0700176 sudo mkdir -p /mnt/extra
177
178 # set partition type of 4th partition to Linux, ignore errors
179 echo -e "t\n4\n82\np\nw\nq" | sudo fdisk /dev/nvme0n1 || true
180
181 sudo mkfs.ext4 /dev/nvme0n1p4
182 echo "/dev/nvme0n1p4 /mnt/extra/ ext4 defaults 0 0" | sudo tee -a /etc/fstab
183 sudo mount /mnt/extra
184 mount | grep nvme0n1p4 || (echo "ERROR: NVME mkfs/mount failed, exiting!" && exit 1)
185
186 elif [ -e /usr/testbed/bin/mkextrafs ] # if on Clemson/Wisconsin Cloudlab
187 then
188 sudo mkdir -p /mnt/extra
189
190 # Sometimes this command fails on the first try
191 sudo /usr/testbed/bin/mkextrafs -r /dev/sdb -qf "/mnt/extra/" || sudo /usr/testbed/bin/mkextrafs -r /dev/sdb -qf "/mnt/extra/"
192
193 # Check that the mount succeeded (sometimes mkextrafs succeeds but device not mounted)
194 mount | grep sdb || (echo "ERROR: mkextrafs failed, exiting!" && exit 1)
Andy Bavier2505f592016-11-11 15:58:55 -0500195 fi
Andy Bavier99c11d32016-09-14 17:21:20 -0400196 fi
Zack Williamsf4e65222017-03-01 14:22:37 -0700197
198 # replace /var/lib/libvirt/images with a symlink
199 [ -d /var/lib/libvirt/images/ ] && [ ! -h /var/lib/libvirt/images ] && sudo rmdir /var/lib/libvirt/images
200 sudo mkdir -p /mnt/extra/libvirt_images
201
202 if [ ! -e /var/lib/libvirt/images ]
203 then
204 sudo ln -s /mnt/extra/libvirt_images /var/lib/libvirt/images
205 fi
Andy Bavier99c11d32016-09-14 17:21:20 -0400206}
207
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800208function elk_up() {
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800209
210 cd $CORDDIR
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800211 sudo chmod +x build/elk-logger/logstash_tail
Zack Williams49af5e62017-03-24 18:02:56 -0700212
213 build/elk-logger/logstash_tail --file install.out --hostport 10.100.198.201:5617 &
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800214}
215
Andy Bavier2505f592016-11-11 15:58:55 -0500216function vagrant_vms_up() {
Zack Williamsa1f55082017-02-28 22:41:36 -0700217
218 echo "Bringing up CORD-in-a-Box Vagrant VM's..."
Andy Bavier99c11d32016-09-14 17:21:20 -0400219 cd $CORDDIR/build
220
Zack Williams9e7249a2017-03-28 13:07:41 -0700221 sudo su $USER -c "VAGRANT_CWD=$VAGRANT_CWD vagrant up corddev prod --provider libvirt"
Andy Baviera69ee722016-11-17 07:26:01 -0800222
223 # This is a workaround for a weird issue with ARP cache timeout breaking 'vagrant ssh'
224 # It allows SSH'ing to the machine via 'ssh corddev'
Zack Williams9e7249a2017-03-28 13:07:41 -0700225 sudo su $USER -c "VAGRANT_CWD=$VAGRANT_CWD vagrant ssh-config corddev prod > $SSHCONFIG"
Andy Bavier2505f592016-11-11 15:58:55 -0500226
Andy Baviera2acd2a2017-06-19 09:57:32 -0400227 # copy host SSH keypair to corddev
Andy Bavier2505f592016-11-11 15:58:55 -0500228 scp ~/.ssh/id_rsa* corddev:.ssh
229 ssh corddev "chmod go-r ~/.ssh/id_rsa"
Andy Bavier99c11d32016-09-14 17:21:20 -0400230}
231
232function install_head_node() {
233 cd $CORDDIR/build
234
Andy Baviera69ee722016-11-17 07:26:01 -0800235 # SSH config saved earlier allows us to connect to VM without running 'vagrant'
Andy Bavierf55e7f92017-06-22 10:16:44 -0400236 ssh corddev "cd $VMDIR; ./gradlew -PdeployConfig=$VMDIR/$CONFIG fetch"
237 ssh corddev "cd $VMDIR; ./gradlew -PdeployConfig=$VMDIR/$CONFIG buildImages"
238 ssh corddev "cd $VMDIR; ping -c 3 prod; ./gradlew -PdeployConfig=$VMDIR/$CONFIG -PtargetReg=10.100.198.201:5000 publish"
239 ssh corddev "cd $VMDIR; ./gradlew -PdeployConfig=$VMDIR/$CONFIG deploy"
Andy Bavier99c11d32016-09-14 17:21:20 -0400240}
241
242function set_up_maas_user() {
Andy Bavier2505f592016-11-11 15:58:55 -0500243 # Set up MAAS user on server to restart nodes via libvirt
244 grep maas /etc/passwd || sudo useradd -m maas
Andy Bavier99c11d32016-09-14 17:21:20 -0400245 sudo adduser maas libvirtd
246
Andy Bavier2505f592016-11-11 15:58:55 -0500247 # Copy generated public key to maas user's authorized_keys
248 sudo su maas -c "mkdir -p ~/.ssh"
249 sudo cp $HOME/.ssh/id_rsa.pub ~maas/.ssh/authorized_keys
250 sudo chown maas:maas ~maas/.ssh/authorized_keys
Andy Bavier99c11d32016-09-14 17:21:20 -0400251
Andy Bavier2505f592016-11-11 15:58:55 -0500252 # Copy generated private key to maas user's home dir in prod VM
253 scp $HOME/.ssh/id_rsa prod:/tmp
254 ssh prod "sudo mkdir -p ~maas/.ssh"
255 ssh prod "sudo cp /tmp/id_rsa ~maas/.ssh/id_rsa"
256 ssh prod "sudo chown -R maas:maas ~maas/.ssh"
257}
Srikanth Vavilapallib1c4da02016-11-17 15:24:28 -0600258
Andy Bavier0f07bb32017-01-17 10:20:26 -0500259function turn_off_learning () {
260 NET=$1
261 BRIDGE=`sudo virsh net-info $NET|grep "Bridge:"|awk '{print $2}'`
262 sudo brctl setageing $BRIDGE 0
263 sudo brctl stp $BRIDGE off
264}
265
266function leaf_spine_up() {
267 cd $CORDDIR/build
268
269 if [[ $FABRIC -ne 0 ]]
270 then
Zack Williams9e7249a2017-03-28 13:07:41 -0700271 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 -0500272 else
273 # Linux bridging seems to be having issues with two spine switches
Zack Williams9e7249a2017-03-28 13:07:41 -0700274 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 -0500275 fi
276
277 # Turn off MAC learning on "links" -- i.e., bridges created by libvirt.
278 # Without this, sometimes packets are dropped because the bridges
279 # think they are not local -- this needs further investigation.
280 # A better solution might be to replace the bridges with UDP tunnels, but this
281 # is not supported with the version of libvirt available on Ubuntu 14.04.
282 turn_off_learning head-node-leaf-1
283 turn_off_learning compute-node-1-leaf-1
284 turn_off_learning compute-node-2-leaf-2
285 turn_off_learning compute-node-3-leaf-2
286 turn_off_learning leaf-1-spine-1
287 turn_off_learning leaf-1-spine-2
288 turn_off_learning leaf-2-spine-1
289 turn_off_learning leaf-2-spine-2
290}
291
Andy Bavier99c11d32016-09-14 17:21:20 -0400292function add_compute_node() {
Srikanth Vavilapallib1c4da02016-11-17 15:24:28 -0600293 echo add_compute_node: $1 $2
Andy Bavier2505f592016-11-11 15:58:55 -0500294
Andy Bavier99c11d32016-09-14 17:21:20 -0400295 cd $CORDDIR/build
Zack Williams9e7249a2017-03-28 13:07:41 -0700296 sudo su $USER -c "VAGRANT_CWD=$VAGRANT_CWD vagrant up $1 --provider libvirt"
Andy Bavier99c11d32016-09-14 17:21:20 -0400297
Andy Bavier2505f592016-11-11 15:58:55 -0500298 # Set up power cycling for the compute node and wait for it to be provisioned
Andy Bavierf55e7f92017-06-22 10:16:44 -0400299 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 -0400300
301 echo ""
Andy Bavier0f07bb32017-01-17 10:20:26 -0500302 echo "$1 is fully provisioned!"
303}
304
305function initialize_fabric() {
306 echo "Initializing fabric"
Andy Bavierf55e7f92017-06-22 10:16:44 -0400307 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 -0500308
309 echo "Fabric ping test"
Andy Bavierf55e7f92017-06-22 10:16:44 -0400310 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 -0400311}
312
313function run_e2e_test () {
314 cd $CORDDIR/build
315
Andy Bavier2505f592016-11-11 15:58:55 -0500316 # User has been added to the lbvirtd group, but su $USER to be safe
Andy Bavierf55e7f92017-06-22 10:16:44 -0400317 ssh corddev "cd $VMDIR; ./gradlew -PdeployConfig=$VMDIR/$CONFIG postDeployTests"
Andy Bavier99c11d32016-09-14 17:21:20 -0400318}
319
320function run_diagnostics() {
Andy Bavierf55e7f92017-06-22 10:16:44 -0400321 ssh corddev "cd $VMDIR; ./gradlew -PdeployConfig=$VMDIR/$CONFIG PIrunDiag"
Andy Bavier99c11d32016-09-14 17:21:20 -0400322}
323
324# Parse options
Zack Williamsdae7ff62016-11-14 15:20:06 -0700325GERRIT_BRANCHES=
Andy Bavier99c11d32016-09-14 17:21:20 -0400326RUN_TEST=0
Andy Bavier5c2e4fa2016-10-31 13:50:52 -0400327SETUP_ONLY=0
Andy Bavier99c11d32016-09-14 17:21:20 -0400328DIAGNOSTICS=0
329CLEANUP=0
Andy Bavier0f07bb32017-01-17 10:20:26 -0500330FABRIC=0
Srikanth Vavilapallib1c4da02016-11-17 15:24:28 -0600331#By default, cord-in-a-box creates 1 compute node. If more than one compute is
332#needed, use -n option
333NUM_COMPUTE_NODES=1
Andy Bavier99c11d32016-09-14 17:21:20 -0400334
Andy Bavier0f07bb32017-01-17 10:20:26 -0500335while getopts "b:cdfhn:stv" opt; do
Andy Bavier99c11d32016-09-14 17:21:20 -0400336 case ${opt} in
Zack Williamsdae7ff62016-11-14 15:20:06 -0700337 b ) GERRIT_BRANCHES+=("$OPTARG")
Andy Bavier99c11d32016-09-14 17:21:20 -0400338 ;;
339 c ) CLEANUP=1
340 ;;
341 d ) DIAGNOSTICS=1
342 ;;
Andy Bavier0f07bb32017-01-17 10:20:26 -0500343 f ) FABRIC=1
344 ;;
Andy Bavier99c11d32016-09-14 17:21:20 -0400345 h ) echo "Usage:"
346 echo " $0 install OpenStack and prep XOS and ONOS VMs [default]"
Zack Williamsdae7ff62016-11-14 15:20:06 -0700347 echo " $0 -b <project:changeset/revision> checkout a changesets from gerrit. Can"
348 echo " be used multiple times."
Andy Bavier99c11d32016-09-14 17:21:20 -0400349 echo " $0 -c cleanup from previous test"
350 echo " $0 -d run diagnostic collector"
Andy Bavier0f07bb32017-01-17 10:20:26 -0500351 echo " $0 -f use ONOS fabric (EXPERIMENTAL)"
Andy Bavier99c11d32016-09-14 17:21:20 -0400352 echo " $0 -h display this help message"
Zack Williamsa9e76ec2017-01-20 16:17:35 -0700353 echo " $0 -n # number of compute nodes to setup. Currently max 2 nodes can be supported"
Andy Bavier5c2e4fa2016-10-31 13:50:52 -0400354 echo " $0 -s run initial setup phase only (don't start building CORD)"
Andy Bavier99c11d32016-09-14 17:21:20 -0400355 echo " $0 -t do install, bring up cord-pod configuration, run E2E test"
Andy Bavierd1165102017-01-13 16:38:57 -0500356 echo " $0 -v print CiaB version and exit"
Andy Bavier99c11d32016-09-14 17:21:20 -0400357 exit 0
358 ;;
Srikanth Vavilapallib1c4da02016-11-17 15:24:28 -0600359 n ) NUM_COMPUTE_NODES=$OPTARG
360 ;;
Andy Bavier5c2e4fa2016-10-31 13:50:52 -0400361 s ) SETUP_ONLY=1
362 ;;
Andy Bavier99c11d32016-09-14 17:21:20 -0400363 t ) RUN_TEST=1
364 ;;
Andy Bavierd1165102017-01-13 16:38:57 -0500365 v ) echo "$VERSION_STRING ($REPO_BRANCH branch)"
366 exit 0
367 ;;
Andy Bavier99c11d32016-09-14 17:21:20 -0400368 \? ) echo "Invalid option: -$OPTARG"
369 exit 1
370 ;;
371 esac
372done
373
374# What to do
375if [[ $CLEANUP -eq 1 ]]
376then
Sapan Bhatia3f454b32017-03-01 05:24:19 +0100377 cleanup_from_previous_test
Andy Bavier99c11d32016-09-14 17:21:20 -0400378fi
379
Andy Bavierd1165102017-01-13 16:38:57 -0500380echo ""
381echo "Preparing to install $VERSION_STRING ($REPO_BRANCH branch)"
382echo ""
383
Sapan Bhatiaa94c2db2017-02-27 20:18:24 +0100384bootstrap
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800385run_stage cloudlab_setup
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800386run_stage vagrant_vms_up
Zack Williams49af5e62017-03-24 18:02:56 -0700387run_stage elk_up
Andy Bavier5c2e4fa2016-10-31 13:50:52 -0400388
389if [[ $SETUP_ONLY -ne 0 ]]
390then
391 echo "Finished build environment setup, exiting..."
392 exit 0
393fi
394
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800395run_stage install_head_node
396run_stage set_up_maas_user
397run_stage leaf_spine_up
Srikanth Vavilapallib1c4da02016-11-17 15:24:28 -0600398
Andy Bavier0f07bb32017-01-17 10:20:26 -0500399if [[ $NUM_COMPUTE_NODES -gt 3 ]]
Srikanth Vavilapallib1c4da02016-11-17 15:24:28 -0600400then
Andy Bavier0f07bb32017-01-17 10:20:26 -0500401 echo "currently max only three compute nodes can be supported..."
402 NUM_COMPUTE_NODES=3
Srikanth Vavilapallib1c4da02016-11-17 15:24:28 -0600403fi
404
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800405echo "==> Adding compute nodes: Starting"
Srikanth Vavilapallib1c4da02016-11-17 15:24:28 -0600406for i in `seq 1 $NUM_COMPUTE_NODES`;
407do
408 echo adding the compute node: compute-node-$i
Zack Williams03a20ec2017-04-12 17:39:36 -0700409 add_compute_node compute-node-$i ${VAGRANT_VM_PREFIX}_compute-node-$i
Srikanth Vavilapallib1c4da02016-11-17 15:24:28 -0600410done
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800411echo "==> Adding compute nodes: Complete"
Andy Bavier99c11d32016-09-14 17:21:20 -0400412
Zack Williams4fd3dcc2017-02-08 20:46:14 -0700413# run diagnostics both before/after the fabric/e2e tests
414if [[ $DIAGNOSTICS -eq 1 ]]
415then
416 run_diagnostics
417fi
418
419
Andy Bavier0f07bb32017-01-17 10:20:26 -0500420if [[ $FABRIC -ne 0 ]]
421then
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800422 run_stage initialize_fabric
Andy Bavier0f07bb32017-01-17 10:20:26 -0500423fi
424
Andy Bavier99c11d32016-09-14 17:21:20 -0400425if [[ $RUN_TEST -eq 1 ]]
426then
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800427 run_stage run_e2e_test
Andy Bavier99c11d32016-09-14 17:21:20 -0400428fi
429
430if [[ $DIAGNOSTICS -eq 1 ]]
431then
Sapan Bhatia01ddea62017-02-10 11:28:48 -0800432 run_stage run_diagnostics
Andy Bavier99c11d32016-09-14 17:21:20 -0400433fi
434
435exit 0