Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
Sapan Bhatia | 01ddea6 | 2017-02-10 11:28:48 -0800 | [diff] [blame] | 3 | set -e -x |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 4 | |
Zack Williams | 0620c93 | 2017-01-25 14:36:31 -0700 | [diff] [blame] | 5 | CORDDIR=~/cord |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 6 | VMDIR=/cord/build/ |
| 7 | CONFIG=config/cord_in_a_box.yml |
Andy Bavier | a69ee72 | 2016-11-17 07:26:01 -0800 | [diff] [blame] | 8 | SSHCONFIG=~/.ssh/config |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 9 | |
Andy Bavier | d116510 | 2017-01-13 16:38:57 -0500 | [diff] [blame] | 10 | # For CORD version |
| 11 | REPO_BRANCH="master" |
| 12 | VERSION_STRING="CiaB development version" |
| 13 | |
Sapan Bhatia | a94c2db | 2017-02-27 20:18:24 +0100 | [diff] [blame] | 14 | function finish { |
Sapan Bhatia | 9569209 | 2017-03-01 06:48:19 +0100 | [diff] [blame] | 15 | EXIT=$? |
Sapan Bhatia | eb7819c | 2017-03-01 15:26:17 +0100 | [diff] [blame^] | 16 | python $CORDDIR/build/elk-logger/mixpanel --event FINISH --corddir $CORDDIR --finish --status $EXIT |
Sapan Bhatia | a94c2db | 2017-02-27 20:18:24 +0100 | [diff] [blame] | 17 | } |
| 18 | |
Andy Bavier | 0f07bb3 | 2017-01-17 10:20:26 -0500 | [diff] [blame] | 19 | function add_box() { |
| 20 | vagrant box list | grep $1 | grep virtualbox || vagrant box add $1 |
| 21 | vagrant box list | grep $1 | grep libvirt || vagrant mutate $1 libvirt --input-provider virtualbox |
| 22 | } |
| 23 | |
Sapan Bhatia | 01ddea6 | 2017-02-10 11:28:48 -0800 | [diff] [blame] | 24 | function run_stage { |
Sapan Bhatia | a94c2db | 2017-02-27 20:18:24 +0100 | [diff] [blame] | 25 | cd $CORDDIR |
Sapan Bhatia | eb7819c | 2017-03-01 15:26:17 +0100 | [diff] [blame^] | 26 | python build/elk-logger/mixpanel --event $1-start --corddir $CORDDIR |
Sapan Bhatia | a94c2db | 2017-02-27 20:18:24 +0100 | [diff] [blame] | 27 | |
Sapan Bhatia | 01ddea6 | 2017-02-10 11:28:48 -0800 | [diff] [blame] | 28 | echo "==> "$1": Starting" |
| 29 | $1 |
| 30 | echo "==> "$1": Complete" |
Sapan Bhatia | a94c2db | 2017-02-27 20:18:24 +0100 | [diff] [blame] | 31 | |
| 32 | cd $CORDDIR |
Sapan Bhatia | eb7819c | 2017-03-01 15:26:17 +0100 | [diff] [blame^] | 33 | python build/elk-logger/mixpanel --event $1-end --corddir $CORDDIR |
Sapan Bhatia | 01ddea6 | 2017-02-10 11:28:48 -0800 | [diff] [blame] | 34 | } |
| 35 | |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 36 | function cleanup_from_previous_test() { |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 37 | echo "## Cleanup ##" |
| 38 | |
Andy Bavier | a4883ba | 2016-12-21 15:46:58 -0500 | [diff] [blame] | 39 | if [ -d $CORDDIR/build ] |
| 40 | then |
| 41 | echo "Destroying all Vagrant VMs" |
| 42 | cd $CORDDIR/build |
| 43 | sudo su $USER -c 'vagrant destroy' |
| 44 | fi |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 45 | |
Andy Bavier | 2505f59 | 2016-11-11 15:58:55 -0500 | [diff] [blame] | 46 | echo "Removing $CORDDIR" |
| 47 | cd ~ |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 48 | rm -rf $CORDDIR |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | function bootstrap() { |
Sapan Bhatia | 9569209 | 2017-03-01 06:48:19 +0100 | [diff] [blame] | 52 | echo "Generating build id" |
| 53 | dd bs=18 count=1 if=/dev/urandom | base64 | tr +/ _. > /tmp/cord-build |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 54 | cd ~ |
| 55 | sudo apt-get update |
| 56 | [ -e vagrant_1.8.5_x86_64.deb ] || wget https://releases.hashicorp.com/vagrant/1.8.5/vagrant_1.8.5_x86_64.deb |
Andy Bavier | ad3ea84 | 2016-12-21 16:19:07 -0500 | [diff] [blame] | 57 | dpkg -l vagrant || sudo dpkg -i vagrant_1.8.5_x86_64.deb |
Sapan Bhatia | 01ddea6 | 2017-02-10 11:28:48 -0800 | [diff] [blame] | 58 | sudo apt-get -y install qemu-kvm libvirt-bin libvirt-dev curl nfs-kernel-server git build-essential python-pip |
Sapan Bhatia | a94c2db | 2017-02-27 20:18:24 +0100 | [diff] [blame] | 59 | sudo pip install pyparsing python-logstash mixpanel |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 60 | |
| 61 | [ -e ~/.ssh/id_rsa ] || ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 62 | |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 63 | sudo adduser $USER libvirtd |
| 64 | |
| 65 | sudo curl -o /usr/local/bin/repo https://storage.googleapis.com/git-repo-downloads/repo |
| 66 | sudo chmod a+x /usr/local/bin/repo |
| 67 | |
| 68 | if [ ! -d "$CORDDIR" ] |
| 69 | then |
| 70 | mkdir $CORDDIR && cd $CORDDIR |
Sapan Bhatia | 868e001 | 2017-02-15 22:14:11 -0800 | [diff] [blame] | 71 | |
| 72 | |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 73 | git config --global user.name 'Test User' |
| 74 | git config --global user.email 'test@null.com' |
| 75 | git config --global color.ui false |
| 76 | |
Scott Baker | 0ab8682 | 2017-02-01 14:33:40 -0800 | [diff] [blame] | 77 | repo init -u https://gerrit.opencord.org/manifest -b $REPO_BRANCH -g build,onos,orchestration,voltha |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 78 | repo sync |
| 79 | |
Zack Williams | dae7ff6 | 2016-11-14 15:20:06 -0700 | [diff] [blame] | 80 | # check out gerrit branches using repo |
| 81 | for gerrit_branch in ${GERRIT_BRANCHES[@]}; do |
| 82 | echo "checking out opencord gerrit branch: $gerrit_branch" |
| 83 | repo download ${gerrit_branch/:/ } |
| 84 | done |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 85 | fi |
| 86 | |
Sapan Bhatia | 868e001 | 2017-02-15 22:14:11 -0800 | [diff] [blame] | 87 | exec > >(tee -i $CORDDIR/install.out) |
| 88 | exec 2>&1 |
| 89 | |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 90 | cd $CORDDIR/build |
Andy Bavier | ad3ea84 | 2016-12-21 16:19:07 -0500 | [diff] [blame] | 91 | vagrant plugin list | grep vagrant-libvirt || vagrant plugin install vagrant-libvirt --plugin-version 0.0.35 |
| 92 | vagrant plugin list | grep vagrant-mutate || vagrant plugin install vagrant-mutate |
Andy Bavier | 0f07bb3 | 2017-01-17 10:20:26 -0500 | [diff] [blame] | 93 | add_box ubuntu/trusty64 |
Sapan Bhatia | 9569209 | 2017-03-01 06:48:19 +0100 | [diff] [blame] | 94 | |
| 95 | # Start tracking failures from this point |
| 96 | trap finish EXIT |
| 97 | |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | function cloudlab_setup() { |
Andy Bavier | 8b4ed1f | 2017-02-13 17:06:58 -0800 | [diff] [blame] | 101 | |
| 102 | # The watchdog will sometimes reset groups, turn it off |
| 103 | if [ -e /usr/local/etc/emulab/watchdog ] |
| 104 | then |
| 105 | sudo /usr/bin/perl -w /usr/local/etc/emulab/watchdog stop |
| 106 | sudo mv /usr/local/etc/emulab/watchdog /usr/local/etc/emulab/watchdog-disabled |
| 107 | fi |
| 108 | |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 109 | if [ -e /usr/testbed/bin/mkextrafs ] |
| 110 | then |
Andy Bavier | 9c0835e | 2016-11-11 15:56:47 -0500 | [diff] [blame] | 111 | sudo mkdir -p /mnt/extra |
Scott Baker | 8b9182d | 2016-10-27 17:53:52 -0700 | [diff] [blame] | 112 | |
Andy Bavier | 8ce395f | 2016-10-14 12:51:30 -0400 | [diff] [blame] | 113 | # Sometimes this command fails on the first try |
Andy Bavier | 9c0835e | 2016-11-11 15:56:47 -0500 | [diff] [blame] | 114 | sudo /usr/testbed/bin/mkextrafs -r /dev/sdb -qf "/mnt/extra/" || sudo /usr/testbed/bin/mkextrafs -r /dev/sdb -qf "/mnt/extra/" |
| 115 | |
| 116 | # Check that the mount succeeded (sometimes mkextrafs succeeds but device not mounted) |
Andy Bavier | a69ee72 | 2016-11-17 07:26:01 -0800 | [diff] [blame] | 117 | mount | grep sdb || (echo "ERROR: mkextrafs failed, exiting!" && exit 1) |
Scott Baker | 8b9182d | 2016-10-27 17:53:52 -0700 | [diff] [blame] | 118 | |
| 119 | # we'll replace /var/lib/libvirt/images with a symlink below |
| 120 | [ -d /var/lib/libvirt/images/ ] && [ ! -h /var/lib/libvirt/images ] && sudo rmdir /var/lib/libvirt/images |
| 121 | |
Andy Bavier | 9c0835e | 2016-11-11 15:56:47 -0500 | [diff] [blame] | 122 | sudo mkdir -p /mnt/extra/libvirt_images |
Andy Bavier | 2505f59 | 2016-11-11 15:58:55 -0500 | [diff] [blame] | 123 | if [ ! -e /var/lib/libvirt/images ] |
| 124 | then |
| 125 | sudo ln -s /mnt/extra/libvirt_images /var/lib/libvirt/images |
| 126 | fi |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 127 | fi |
| 128 | } |
| 129 | |
Sapan Bhatia | 01ddea6 | 2017-02-10 11:28:48 -0800 | [diff] [blame] | 130 | function elk_up() { |
| 131 | cd $CORDDIR/build |
| 132 | |
| 133 | sudo su $USER -c 'vagrant up elastic --provider libvirt' |
| 134 | |
| 135 | # This is a workaround for a weird issue with ARP cache timeout breaking 'vagrant ssh' |
| 136 | # It allows SSH'ing to the machine via 'ssh corddev' |
| 137 | sudo su $USER -c "vagrant ssh-config elastic > $SSHCONFIG" |
| 138 | |
| 139 | cd $CORDDIR |
| 140 | if [ ! -f /tmp/elk-patch-applied ]; then |
| 141 | touch /tmp/elk-patch-applied |
| 142 | sh build/scripts/repo-apply.sh build/elk-logger/elk-ciab.diff |
| 143 | fi |
| 144 | |
| 145 | sudo chmod +x build/elk-logger/logstash_tail |
| 146 | build/elk-logger/logstash_tail --file install.out --hostport 10.100.198.222:5617 & |
| 147 | } |
| 148 | |
Andy Bavier | 2505f59 | 2016-11-11 15:58:55 -0500 | [diff] [blame] | 149 | function vagrant_vms_up() { |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 150 | cd $CORDDIR/build |
| 151 | |
Andy Bavier | 65c8e15 | 2016-12-22 16:01:27 -0500 | [diff] [blame] | 152 | sudo su $USER -c 'vagrant up corddev prod --provider libvirt' |
Andy Bavier | a69ee72 | 2016-11-17 07:26:01 -0800 | [diff] [blame] | 153 | |
| 154 | # This is a workaround for a weird issue with ARP cache timeout breaking 'vagrant ssh' |
| 155 | # It allows SSH'ing to the machine via 'ssh corddev' |
Andy Bavier | 2505f59 | 2016-11-11 15:58:55 -0500 | [diff] [blame] | 156 | sudo su $USER -c "vagrant ssh-config corddev prod > $SSHCONFIG" |
| 157 | |
| 158 | scp ~/.ssh/id_rsa* corddev:.ssh |
| 159 | ssh corddev "chmod go-r ~/.ssh/id_rsa" |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | function install_head_node() { |
| 163 | cd $CORDDIR/build |
| 164 | |
Andy Bavier | a69ee72 | 2016-11-17 07:26:01 -0800 | [diff] [blame] | 165 | # SSH config saved earlier allows us to connect to VM without running 'vagrant' |
Zack Williams | 0620c93 | 2017-01-25 14:36:31 -0700 | [diff] [blame] | 166 | ssh corddev "cd /cord/build; ./gradlew -PdeployConfig=$VMDIR/$CONFIG fetch" |
| 167 | ssh corddev "cd /cord/build; ./gradlew -PdeployConfig=$VMDIR/$CONFIG buildImages" |
Andy Bavier | 2505f59 | 2016-11-11 15:58:55 -0500 | [diff] [blame] | 168 | ssh corddev "cd /cord/build; ping -c 3 prod; ./gradlew -PdeployConfig=$VMDIR/$CONFIG -PtargetReg=10.100.198.201:5000 publish" |
Andy Bavier | a69ee72 | 2016-11-17 07:26:01 -0800 | [diff] [blame] | 169 | ssh corddev "cd /cord/build; ./gradlew -PdeployConfig=$VMDIR/$CONFIG deploy" |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | function set_up_maas_user() { |
Andy Bavier | 2505f59 | 2016-11-11 15:58:55 -0500 | [diff] [blame] | 173 | # Set up MAAS user on server to restart nodes via libvirt |
| 174 | grep maas /etc/passwd || sudo useradd -m maas |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 175 | sudo adduser maas libvirtd |
| 176 | |
Andy Bavier | 2505f59 | 2016-11-11 15:58:55 -0500 | [diff] [blame] | 177 | # Copy generated public key to maas user's authorized_keys |
| 178 | sudo su maas -c "mkdir -p ~/.ssh" |
| 179 | sudo cp $HOME/.ssh/id_rsa.pub ~maas/.ssh/authorized_keys |
| 180 | sudo chown maas:maas ~maas/.ssh/authorized_keys |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 181 | |
Andy Bavier | 2505f59 | 2016-11-11 15:58:55 -0500 | [diff] [blame] | 182 | # Copy generated private key to maas user's home dir in prod VM |
| 183 | scp $HOME/.ssh/id_rsa prod:/tmp |
| 184 | ssh prod "sudo mkdir -p ~maas/.ssh" |
| 185 | ssh prod "sudo cp /tmp/id_rsa ~maas/.ssh/id_rsa" |
| 186 | ssh prod "sudo chown -R maas:maas ~maas/.ssh" |
| 187 | } |
Srikanth Vavilapalli | b1c4da0 | 2016-11-17 15:24:28 -0600 | [diff] [blame] | 188 | |
Andy Bavier | 0f07bb3 | 2017-01-17 10:20:26 -0500 | [diff] [blame] | 189 | function turn_off_learning () { |
| 190 | NET=$1 |
| 191 | BRIDGE=`sudo virsh net-info $NET|grep "Bridge:"|awk '{print $2}'` |
| 192 | sudo brctl setageing $BRIDGE 0 |
| 193 | sudo brctl stp $BRIDGE off |
| 194 | } |
| 195 | |
| 196 | function leaf_spine_up() { |
| 197 | cd $CORDDIR/build |
| 198 | |
| 199 | if [[ $FABRIC -ne 0 ]] |
| 200 | then |
| 201 | sudo su $USER -c "FABRIC=$FABRIC vagrant up leaf-1 leaf-2 spine-1 spine-2 --provider libvirt" |
| 202 | else |
| 203 | # Linux bridging seems to be having issues with two spine switches |
| 204 | sudo su $USER -c "FABRIC=$FABRIC vagrant up leaf-1 leaf-2 spine-1 --provider libvirt" |
| 205 | fi |
| 206 | |
| 207 | # Turn off MAC learning on "links" -- i.e., bridges created by libvirt. |
| 208 | # Without this, sometimes packets are dropped because the bridges |
| 209 | # think they are not local -- this needs further investigation. |
| 210 | # A better solution might be to replace the bridges with UDP tunnels, but this |
| 211 | # is not supported with the version of libvirt available on Ubuntu 14.04. |
| 212 | turn_off_learning head-node-leaf-1 |
| 213 | turn_off_learning compute-node-1-leaf-1 |
| 214 | turn_off_learning compute-node-2-leaf-2 |
| 215 | turn_off_learning compute-node-3-leaf-2 |
| 216 | turn_off_learning leaf-1-spine-1 |
| 217 | turn_off_learning leaf-1-spine-2 |
| 218 | turn_off_learning leaf-2-spine-1 |
| 219 | turn_off_learning leaf-2-spine-2 |
| 220 | } |
| 221 | |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 222 | function add_compute_node() { |
Srikanth Vavilapalli | b1c4da0 | 2016-11-17 15:24:28 -0600 | [diff] [blame] | 223 | echo add_compute_node: $1 $2 |
Andy Bavier | 2505f59 | 2016-11-11 15:58:55 -0500 | [diff] [blame] | 224 | |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 225 | cd $CORDDIR/build |
Srikanth Vavilapalli | b1c4da0 | 2016-11-17 15:24:28 -0600 | [diff] [blame] | 226 | sudo su $USER -c "vagrant up $1 --provider libvirt" |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 227 | |
Andy Bavier | 2505f59 | 2016-11-11 15:58:55 -0500 | [diff] [blame] | 228 | # Set up power cycling for the compute node and wait for it to be provisioned |
| 229 | ssh prod "cd /cord/build/ansible; ansible-playbook maas-provision.yml --extra-vars \"maas_user=maas vagrant_name=$2\"" |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 230 | |
| 231 | echo "" |
Andy Bavier | 0f07bb3 | 2017-01-17 10:20:26 -0500 | [diff] [blame] | 232 | echo "$1 is fully provisioned!" |
| 233 | } |
| 234 | |
| 235 | function initialize_fabric() { |
| 236 | echo "Initializing fabric" |
| 237 | ssh prod "cd /cord/build/platform-install; ansible-playbook -i /etc/maas/ansible/pod-inventory cord-refresh-fabric.yml" |
| 238 | |
| 239 | echo "Fabric ping test" |
| 240 | ssh prod "cd /cord/build/platform-install; ansible-playbook -i /etc/maas/ansible/pod-inventory cord-fabric-pingtest.yml" |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | function run_e2e_test () { |
| 244 | cd $CORDDIR/build |
| 245 | |
Andy Bavier | 2505f59 | 2016-11-11 15:58:55 -0500 | [diff] [blame] | 246 | # User has been added to the lbvirtd group, but su $USER to be safe |
Andy Bavier | a69ee72 | 2016-11-17 07:26:01 -0800 | [diff] [blame] | 247 | ssh corddev "cd /cord/build; ./gradlew -PdeployConfig=$VMDIR/$CONFIG postDeployTests" |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 248 | } |
| 249 | |
| 250 | function run_diagnostics() { |
Zack Williams | 4fd3dcc | 2017-02-08 20:46:14 -0700 | [diff] [blame] | 251 | ssh corddev "cd /cord/build; ./gradlew -PdeployConfig=$VMDIR/$CONFIG PIrunDiag" |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | # Parse options |
Zack Williams | dae7ff6 | 2016-11-14 15:20:06 -0700 | [diff] [blame] | 255 | GERRIT_BRANCHES= |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 256 | RUN_TEST=0 |
Andy Bavier | 5c2e4fa | 2016-10-31 13:50:52 -0400 | [diff] [blame] | 257 | SETUP_ONLY=0 |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 258 | DIAGNOSTICS=0 |
| 259 | CLEANUP=0 |
Andy Bavier | 0f07bb3 | 2017-01-17 10:20:26 -0500 | [diff] [blame] | 260 | FABRIC=0 |
Srikanth Vavilapalli | b1c4da0 | 2016-11-17 15:24:28 -0600 | [diff] [blame] | 261 | #By default, cord-in-a-box creates 1 compute node. If more than one compute is |
| 262 | #needed, use -n option |
| 263 | NUM_COMPUTE_NODES=1 |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 264 | |
Andy Bavier | 0f07bb3 | 2017-01-17 10:20:26 -0500 | [diff] [blame] | 265 | while getopts "b:cdfhn:stv" opt; do |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 266 | case ${opt} in |
Zack Williams | dae7ff6 | 2016-11-14 15:20:06 -0700 | [diff] [blame] | 267 | b ) GERRIT_BRANCHES+=("$OPTARG") |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 268 | ;; |
| 269 | c ) CLEANUP=1 |
| 270 | ;; |
| 271 | d ) DIAGNOSTICS=1 |
| 272 | ;; |
Andy Bavier | 0f07bb3 | 2017-01-17 10:20:26 -0500 | [diff] [blame] | 273 | f ) FABRIC=1 |
| 274 | ;; |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 275 | h ) echo "Usage:" |
| 276 | echo " $0 install OpenStack and prep XOS and ONOS VMs [default]" |
Zack Williams | dae7ff6 | 2016-11-14 15:20:06 -0700 | [diff] [blame] | 277 | echo " $0 -b <project:changeset/revision> checkout a changesets from gerrit. Can" |
| 278 | echo " be used multiple times." |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 279 | echo " $0 -c cleanup from previous test" |
| 280 | echo " $0 -d run diagnostic collector" |
Andy Bavier | 0f07bb3 | 2017-01-17 10:20:26 -0500 | [diff] [blame] | 281 | echo " $0 -f use ONOS fabric (EXPERIMENTAL)" |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 282 | echo " $0 -h display this help message" |
Zack Williams | a9e76ec | 2017-01-20 16:17:35 -0700 | [diff] [blame] | 283 | echo " $0 -n # number of compute nodes to setup. Currently max 2 nodes can be supported" |
Andy Bavier | 5c2e4fa | 2016-10-31 13:50:52 -0400 | [diff] [blame] | 284 | echo " $0 -s run initial setup phase only (don't start building CORD)" |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 285 | echo " $0 -t do install, bring up cord-pod configuration, run E2E test" |
Andy Bavier | d116510 | 2017-01-13 16:38:57 -0500 | [diff] [blame] | 286 | echo " $0 -v print CiaB version and exit" |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 287 | exit 0 |
| 288 | ;; |
Srikanth Vavilapalli | b1c4da0 | 2016-11-17 15:24:28 -0600 | [diff] [blame] | 289 | n ) NUM_COMPUTE_NODES=$OPTARG |
| 290 | ;; |
Andy Bavier | 5c2e4fa | 2016-10-31 13:50:52 -0400 | [diff] [blame] | 291 | s ) SETUP_ONLY=1 |
| 292 | ;; |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 293 | t ) RUN_TEST=1 |
| 294 | ;; |
Andy Bavier | d116510 | 2017-01-13 16:38:57 -0500 | [diff] [blame] | 295 | v ) echo "$VERSION_STRING ($REPO_BRANCH branch)" |
| 296 | exit 0 |
| 297 | ;; |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 298 | \? ) echo "Invalid option: -$OPTARG" |
| 299 | exit 1 |
| 300 | ;; |
| 301 | esac |
| 302 | done |
| 303 | |
| 304 | # What to do |
| 305 | if [[ $CLEANUP -eq 1 ]] |
| 306 | then |
Sapan Bhatia | 3f454b3 | 2017-03-01 05:24:19 +0100 | [diff] [blame] | 307 | cleanup_from_previous_test |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 308 | fi |
| 309 | |
Andy Bavier | d116510 | 2017-01-13 16:38:57 -0500 | [diff] [blame] | 310 | echo "" |
| 311 | echo "Preparing to install $VERSION_STRING ($REPO_BRANCH branch)" |
| 312 | echo "" |
| 313 | |
Sapan Bhatia | a94c2db | 2017-02-27 20:18:24 +0100 | [diff] [blame] | 314 | bootstrap |
Sapan Bhatia | 01ddea6 | 2017-02-10 11:28:48 -0800 | [diff] [blame] | 315 | run_stage cloudlab_setup |
| 316 | run_stage elk_up |
| 317 | run_stage vagrant_vms_up |
Andy Bavier | 5c2e4fa | 2016-10-31 13:50:52 -0400 | [diff] [blame] | 318 | |
| 319 | if [[ $SETUP_ONLY -ne 0 ]] |
| 320 | then |
| 321 | echo "Finished build environment setup, exiting..." |
| 322 | exit 0 |
| 323 | fi |
| 324 | |
Sapan Bhatia | 01ddea6 | 2017-02-10 11:28:48 -0800 | [diff] [blame] | 325 | run_stage install_head_node |
| 326 | run_stage set_up_maas_user |
| 327 | run_stage leaf_spine_up |
Srikanth Vavilapalli | b1c4da0 | 2016-11-17 15:24:28 -0600 | [diff] [blame] | 328 | |
Andy Bavier | 0f07bb3 | 2017-01-17 10:20:26 -0500 | [diff] [blame] | 329 | if [[ $NUM_COMPUTE_NODES -gt 3 ]] |
Srikanth Vavilapalli | b1c4da0 | 2016-11-17 15:24:28 -0600 | [diff] [blame] | 330 | then |
Andy Bavier | 0f07bb3 | 2017-01-17 10:20:26 -0500 | [diff] [blame] | 331 | echo "currently max only three compute nodes can be supported..." |
| 332 | NUM_COMPUTE_NODES=3 |
Srikanth Vavilapalli | b1c4da0 | 2016-11-17 15:24:28 -0600 | [diff] [blame] | 333 | fi |
| 334 | |
Sapan Bhatia | 01ddea6 | 2017-02-10 11:28:48 -0800 | [diff] [blame] | 335 | echo "==> Adding compute nodes: Starting" |
Srikanth Vavilapalli | b1c4da0 | 2016-11-17 15:24:28 -0600 | [diff] [blame] | 336 | for i in `seq 1 $NUM_COMPUTE_NODES`; |
| 337 | do |
| 338 | echo adding the compute node: compute-node-$i |
Andy Bavier | 0f07bb3 | 2017-01-17 10:20:26 -0500 | [diff] [blame] | 339 | add_compute_node compute-node-$i build_compute-node-$i |
Srikanth Vavilapalli | b1c4da0 | 2016-11-17 15:24:28 -0600 | [diff] [blame] | 340 | done |
Sapan Bhatia | 01ddea6 | 2017-02-10 11:28:48 -0800 | [diff] [blame] | 341 | echo "==> Adding compute nodes: Complete" |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 342 | |
Zack Williams | 4fd3dcc | 2017-02-08 20:46:14 -0700 | [diff] [blame] | 343 | # run diagnostics both before/after the fabric/e2e tests |
| 344 | if [[ $DIAGNOSTICS -eq 1 ]] |
| 345 | then |
| 346 | run_diagnostics |
| 347 | fi |
| 348 | |
| 349 | |
Andy Bavier | 0f07bb3 | 2017-01-17 10:20:26 -0500 | [diff] [blame] | 350 | if [[ $FABRIC -ne 0 ]] |
| 351 | then |
Sapan Bhatia | 01ddea6 | 2017-02-10 11:28:48 -0800 | [diff] [blame] | 352 | run_stage initialize_fabric |
Andy Bavier | 0f07bb3 | 2017-01-17 10:20:26 -0500 | [diff] [blame] | 353 | fi |
| 354 | |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 355 | if [[ $RUN_TEST -eq 1 ]] |
| 356 | then |
Sapan Bhatia | 01ddea6 | 2017-02-10 11:28:48 -0800 | [diff] [blame] | 357 | run_stage run_e2e_test |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 358 | fi |
| 359 | |
| 360 | if [[ $DIAGNOSTICS -eq 1 ]] |
| 361 | then |
Sapan Bhatia | 01ddea6 | 2017-02-10 11:28:48 -0800 | [diff] [blame] | 362 | run_stage run_diagnostics |
Andy Bavier | 99c11d3 | 2016-09-14 17:21:20 -0400 | [diff] [blame] | 363 | fi |
| 364 | |
| 365 | exit 0 |