Vagrant provisioning and script to run integration tests
refs #2436
Change-Id: I43b2fc77a9f79df1512a180df0c0051a2797eac0
diff --git a/Vagrantfile b/Vagrantfile
new file mode 100644
index 0000000..3edc96b
--- /dev/null
+++ b/Vagrantfile
@@ -0,0 +1,102 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
+VAGRANTFILE_API_VERSION = "2"
+
+$setup = <<SCRIPT
+sudo apt-get update -qq
+sudo apt-get install -y python
+SCRIPT
+
+$setup_integ = <<SCRIPT
+cp -R /vagrant integration-tests
+cd integration-tests && ./install_apps.py install_all 2>&1 | tee install.log
+SCRIPT
+
+$setup_ssh = <<SCRIPT
+mkdir -p ~/.ssh
+cp /vagrant/temp/sshkey ~/.ssh/id_rsa
+cp /vagrant/temp/sshkey.pub ~/.ssh/id_rsa.pub
+cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
+chown -R vagrant:vagrant ~/.ssh
+chmod -R 700 ~/.ssh
+SCRIPT
+
+$setup_a = <<SCRIPT
+cat > ~/.ssh/config <<EOF
+Host 192.168.*.*
+ StrictHostKeyChecking no
+EOF
+
+sudo ip route add 192.168.3.0/24 via 192.168.2.3
+sudo ip -6 addr add fd01::3/64 dev eth1
+sudo ip -6 addr add fd02::2/64 dev eth2
+sudo ip -6 route add fd03::/64 via fd02::3
+SCRIPT
+
+$setup_d = <<SCRIPT
+ip route add 192.168.2.0/24 via 192.168.3.2
+ip -6 addr add fd03::3/64 dev eth1
+ip -6 route add fd02::/64 via fd03::2
+SCRIPT
+
+$setup_router = <<SCRIPT
+echo 1 > /proc/sys/net/ipv4/ip_forward
+echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
+ip -6 addr add fd02::3/64 dev eth1
+ip -6 addr add fd03::2/64 dev eth2
+SCRIPT
+
+Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
+ config.vm.box = "ubuntu/precise64"
+
+ config.vm.provider "virtualbox" do |vb|
+ vb.memory = "4096"
+ vb.cpus = "4"
+ vb.customize ["storagectl", :id, "--name", "SATAController", "--hostiocache", "off"]
+ end
+
+ config.vm.define "A" do |a|
+ a.vm.network "private_network", ip: "192.168.1.3", virtualbox__intnet: "ABC-switch"
+ a.vm.network "private_network", ip: "192.168.2.2", virtualbox__intnet: "AtoRouter"
+ a.vm.provision "shell", inline: $setup, privileged: false
+ a.vm.provision "shell", inline: $setup_a, privileged: false
+ a.vm.provision "shell", inline: $setup_ssh, privileged: false
+ a.vm.provision "shell", inline: $setup_integ, privileged: false
+ end
+
+ config.vm.define "B" do |b|
+ b.vm.network "private_network", ip: "192.168.1.2", virtualbox__intnet: "ABC-switch"
+ b.vm.provision "shell", inline: $setup, privileged: false
+ b.vm.provision "shell", inline: "ip -6 addr add fd01::2/64 dev eth1"
+ b.vm.provision "shell", inline: $setup_ssh, privileged: false
+ b.vm.provision "shell", inline: $setup_integ, privileged: false
+ end
+
+ config.vm.define "C" do |c|
+ c.vm.network "private_network", ip: "192.168.1.4", virtualbox__intnet: "ABC-switch"
+ c.vm.provision "shell", inline: $setup, privileged: false
+ c.vm.provision "shell", inline: "ip -6 addr add fd01::4/64 dev eth1"
+ c.vm.provision "shell", inline: $setup_ssh, privileged: false
+ c.vm.provision "shell", inline: $setup_integ, privileged: false
+ end
+
+ config.vm.define "D" do |d|
+ d.vm.network "private_network", ip: "192.168.3.3", virtualbox__intnet: "DtoRouter"
+ d.vm.provision "shell", inline: $setup, privileged: false
+ d.vm.provision "shell", inline: $setup_d
+ d.vm.provision "shell", inline: $setup_ssh, privileged: false
+ d.vm.provision "shell", inline: $setup_integ, privileged: false
+ end
+
+ config.vm.define "router" do |router|
+ router.vm.network "private_network", ip: "192.168.2.3", virtualbox__intnet: "AtoRouter"
+ router.vm.network "private_network", ip: "192.168.3.2", virtualbox__intnet: "DtoRouter"
+ router.vm.provision "shell", inline: $setup_router
+ router.vm.provider "virtualbox" do |vb|
+ vb.memory = "128"
+ vb.cpus = "1"
+ end
+ end
+end