summaryrefslogtreecommitdiffstats
path: root/vagrant
diff options
context:
space:
mode:
authorDave Wallace <dwallacelf@gmail.com>2016-02-03 02:09:58 -0500
committerDave Wallace <dwallacelf@gmail.com>2016-02-03 02:10:25 -0500
commitdd98ae7aa20dfa4d601c1c584f28ace9497bae46 (patch)
tree4aaa31545681afb394d5cb2b3b568b521e37ab36 /vagrant
parent2587eee429cb0ef07125f0f6d74d1f669878d553 (diff)
Initial Honeycomb vagrant support.
The following environment variables are used to customize the behavior of the vagrant VM: HONEYCOMB_VAGRANT_DISTRO - Set to "centos7" to run CentOS (currently inop). Unset or any other value runs ubuntu 14.04. HONEYCOMB_M2_REPOSITORY - Set to the pathname of a directory to contain the M2 repository outside of the VM. The specified directory will be mounted at /m2-repository and /home/vagrant/.m2/settings.xml will be modified to use /m2-repository instead of the default directory (/home/vagrant/.m2/repository). VPP_VAGRANT_NICS - Set to the number of addtional NICS desired for VPP to use. VPP_REPO - Set to the pathname of a VPP repository. The specified pathname will be mounted on /vpp and a working repo will be cloned into /home/vagrant/git/vpp. VPP will then be built, installed and started after the VM is created. Change-Id: I6b673c3c378c6b6b7c342d91dc33118ecc97bd05 Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
Diffstat (limited to 'vagrant')
-rw-r--r--vagrant/Vagrantfile64
-rw-r--r--vagrant/bootstrap.centos7.sh46
-rw-r--r--vagrant/bootstrap.ubuntu1404.sh128
-rw-r--r--vagrant/settings.xml108
4 files changed, 346 insertions, 0 deletions
diff --git a/vagrant/Vagrantfile b/vagrant/Vagrantfile
new file mode 100644
index 0000000..5a32039
--- /dev/null
+++ b/vagrant/Vagrantfile
@@ -0,0 +1,64 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+Vagrant.configure(2) do |config|
+
+ config.ssh.forward_x11 = true
+
+ # Pick the right distro and bootstrap, default is ubuntu1404
+ distro = ENV['HONEYCOMB_VAGRANT_DISTRO']
+ if distro == 'centos7'
+ config.vm.box = "puppetlabs/centos-7.0-64-nocm"
+ config.vm.provision 'shell', path: 'bootstrap.centos7.sh'
+ else
+ config.vm.box = "puppetlabs/ubuntu-14.04-64-nocm"
+ config.vm.provision 'shell', path: 'bootstrap.ubuntu1404.sh'
+ end
+
+ # vagrant-cachier caches apt/yum etc to speed subsequent
+ # vagrant up
+ # to enable, run
+ # vagrant plugin install vagrant-cachier
+ #
+ if Vagrant.has_plugin?("vagrant-cachier")
+ config.cache.scope = :box
+ end
+
+ # Define some physical ports for your VMs to be used by DPDK
+ nics = 0
+ if ENV.key?('VPP_VAGRANT_NICS')
+ nics = ENV['VPP_VAGRANT_NICS'].to_i(10)
+ end
+ for i in 1..nics
+ config.vm.network "private_network", type: "dhcp"
+ end
+
+ # use http proxy if avaiable
+ if ENV['http_proxy'] && Vagrant.has_plugin?("vagrant-proxyconf")
+ config.proxy.http = "$http_proxy"
+ config.proxy.https = "$https_proxy"
+ config.proxy.no_proxy = "localhost,127.0.0.1"
+ end
+
+ # Mount VPP repository if specified
+ if ENV.key?('VPP_REPO')
+ config.vm.synced_folder ENV['VPP_REPO'], "/vpp", disabled: false
+ end
+
+ # Mount Maven repository if specified
+ if ENV.key?('HONEYCOMB_M2_REPO')
+ config.vm.synced_folder ENV['HONEYCOMB_M2_REPO'], "/m2-repository", disabled: false
+ end
+
+ config.vm.synced_folder "../", "/honeycomb", disabled: false
+ config.vm.provider "virtualbox" do |vb|
+ vb.memory = "4096"
+ end
+ config.vm.provider "vmware_fusion" do |fusion,override|
+ fusion.vmx["memsize"] = "4096"
+ end
+ config.vm.provider "vmware_workstation" do |vws,override|
+ vws.vmx["memsize"] = "8192"
+ vws.vmx["numvcpus"] = "4"
+ end
+end
diff --git a/vagrant/bootstrap.centos7.sh b/vagrant/bootstrap.centos7.sh
new file mode 100644
index 0000000..f55e68a
--- /dev/null
+++ b/vagrant/bootstrap.centos7.sh
@@ -0,0 +1,46 @@
+
+# Standard update + upgrade dance
+yum check-update
+yum update -y
+
+# Install build tools
+yum groupinstall 'Development Tools' -y
+yum install openssl-devel -y
+yum install glibc-static -y
+
+# Install jdk and maven
+yum install -y java-1.8.0-openjdk-devel
+
+# Load the uio kernel module
+modprobe uio_pci_generic
+
+echo uio_pci_generic >> /etc/modules-load.d/uio_pci_generic.conf
+
+# Setup for hugepages using upstart so it persists across reboots
+sysctl -w vm.nr_hugepages=1024
+echo "vm.nr_hugepages=1024" >> /etc/sysctl.conf
+mkdir -p /mnt/huge
+echo "hugetlbfs /mnt/huge hugetlbfs defaults 0 0" >> /etc/fstab
+mount /mnt/huge
+
+# Setup the vpp code
+cd ~vagrant/
+sudo -u vagrant mkdir git
+cd git/
+
+# Check if git exists and remove it before attempting clone, else clone ineffective when "reload --provision"
+[ -d vpp ] && rm -rf vpp
+sudo -H -u vagrant git clone /vpp
+cd vpp
+
+# Initial vpp build
+if [ -d build-root ]; then
+ # Bootstrap vpp
+ cd build-root/
+ sudo -H -u vagrant ./bootstrap.sh
+
+ # Build vpp
+ sudo -H -u vagrant make PLATFORM=vpp TAG=vpp_debug install-packages
+ cd ~vagrant/
+ cat /vagrant/README
+fi
diff --git a/vagrant/bootstrap.ubuntu1404.sh b/vagrant/bootstrap.ubuntu1404.sh
new file mode 100644
index 0000000..da51e48
--- /dev/null
+++ b/vagrant/bootstrap.ubuntu1404.sh
@@ -0,0 +1,128 @@
+# set default route to be the GATEWAY
+declare -r GATEWAY=${1:-}
+# set default gateway for bridged interface, and make it happen at reboot
+if [[ -n "${GATEWAY}" ]]; then
+ echo "Setting default gateway through bridged interface"
+ ip route delete default 2>&1 >/dev/null || true
+ ip route add default via ${GATEWAY}
+ echo "GATEWAY=${GATEWAY}" >/etc/default/vagrant-bridge
+ [ -r /vagrant/vagrant-bridge.conf ] && cp /vagrant/vagrant-bridge.conf /etc/init/ # symlinks don't work
+ initctl reload-configuration
+fi
+
+# Fix grub-pc on Virtualbox with Ubuntu
+export DEBIAN_FRONTEND=noninteractive
+
+# Standard update + upgrade dance
+apt-get update
+apt-get upgrade -y
+
+# Fix the silly notion that /bin/sh should point to dash by pointing it to bash
+
+sudo update-alternatives --install /bin/sh sh /bin/bash 100
+
+# Install build tools
+apt-get install -y build-essential autoconf automake bison libssl-dev ccache libtool git dkms debhelper emacs libganglia1-dev libapr1-dev libconfuse-dev
+
+# Install other stuff
+# apt-get install -y qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils
+
+# Install uio
+apt-get install -y linux-image-extra-`uname -r`
+
+# Install jdk and maven
+apt-get install -y openjdk-7-jdk
+mkdir /usr/local/apache-maven
+cd /usr/local/apache-maven
+wget http://apache.go-parts.com/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
+tar -xzvf apache-maven-3.3.9-bin.tar.gz -C /usr/local/apache-maven/
+update-alternatives --install /usr/bin/mvn mvn /usr/local/apache-maven/apache-maven-3.3.9/bin/mvn 1
+update-alternatives --config mvn
+cd /home/vagrant
+sudo -H -u vagrant mkdir .m2
+sudo -H -u vagrant cp /honeycomb/vagrant/settings.xml .m2
+
+cat << EOF > .bash_aliases
+export M2_HOME=/usr/local/apache-maven/apache-maven-3.3.9
+export MAVEN_OPTS="-Xms256m -Xmx512m" # Very important to put the "m" on the end
+export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
+EOF
+chown vagrant:vagrant .bash_aliases
+
+# Use the external Maven M2 repository if it has been mounted on /m2-repository
+[ -d /m2-repository ] && sudo -u vagrant sed -i -e 's,/home/vagrant/.m2/repository,/m2-repository,g' /home/vagrant/.m2/settings.xml
+
+# Setup for hugepages using upstart so it persists across reboots
+echo "vm.nr_hugepages=1024" >> /etc/sysctl.d/20-hugepages.conf
+sysctl --system
+
+cat << EOF > /etc/init/hugepages.conf
+start on runlevel [2345]
+
+task
+
+script
+ mkdir -p /run/hugepages/kvm || true
+ rm -f /run/hugepages/kvm/* || true
+ rm -f /dev/shm/* || true
+ mount -t hugetlbfs nodev /run/hugepages/kvm
+end script
+EOF
+
+# Make sure we run that hugepages.conf right now
+start hugepages
+
+# Setup the vpp code
+cd ~vagrant/
+
+sudo -u vagrant mkdir git
+cd git/
+
+# Check if git exists and remove it before attempting clone, else clone ineffective when "reload --provision"
+[ -d honeycomb ] && rm -rf honeycomb
+sudo -H -u vagrant git clone /honeycomb
+cd honeycomb/
+
+# Initial honeycomb build
+sudo -H -u vagrant mvn clean install -DskipTests
+
+# Install honeycomb agent (v3po)
+mkdir -p /opt/honeycomb/v3po
+cp -a v3po/karaf /opt/honeycomb/v3po
+
+# Install ODL Virtual Bridge App
+mkdir -p /opt/odl/vbd
+cp -a vbd/karaf /opt/odl/vbd
+
+if [ -d /vpp ] ; then
+ cd ..
+
+ # Check if git exists and remove it before attempting clone, else clone ineffective when "reload --provision"
+ [ -d vpp ] && rm -rf vpp
+ sudo -H -u vagrant git clone /vpp
+ cd vpp/
+
+ # Initial vpp build
+ if [ -d build-root ]; then
+ # Bootstrap vpp
+ cd build-root/
+ sudo -H -u vagrant ./bootstrap.sh
+
+ # Build vpp
+ sudo -H -u vagrant make V=0 PLATFORM=vpp TAG=vpp_debug install-deb
+
+ # Install debian packages
+ dpkg -i *.deb
+
+ # Disable all ethernet interfaces other than the default route
+ # so VPP will use those interfaces.
+ for intf in $(ls /sys/class/net) ; do
+ if [ -d /sys/class/net/$intf/device ] && [ "$(route | grep default | grep $intf)" == "" ] ; then
+ ifconfig $intf down
+ fi
+ done
+
+ # Start vpp
+ start vpp
+ fi
+fi
diff --git a/vagrant/settings.xml b/vagrant/settings.xml
new file mode 100644
index 0000000..8312561
--- /dev/null
+++ b/vagrant/settings.xml
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=2 tabstop=2: -->
+<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
+
+ <!-- Include localRepository so it can be changed by vagrant bootstrap script -->
+ <localRepository>/home/vagrant/.m2/repository</localRepository>
+
+ <profiles>
+ <profile>
+ <id>fd.io-release</id>
+ <repositories>
+ <repository>
+ <id>fd.io-mirror</id>
+ <name>fd.io-mirror</name>
+ <url>https://nexus.fd.io/content/groups/public/</url>
+ <releases>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>fd.io-mirror</id>
+ <name>fd.io-mirror</name>
+ <url>https://nexus.fd.io/content/repositories/public/</url>
+ <releases>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+ </profile>
+
+ <profile>
+ <id>fd.io-snapshots</id>
+ <repositories>
+ <repository>
+ <id>fd.io-snapshot</id>
+ <name>fd.io-snapshot</name>
+ <url>https://nexus.fd.io/content/repositories/fd.io.snapshot/</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>fd.io-snapshot</id>
+ <name>fd.io-snapshot</name>
+ <url>https://nexus.fd.io/content/repositories/fd.io.snapshot/</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+ </profile>
+ <profile>
+ <id>opendaylight-snapshots</id>
+ <repositories>
+ <repository>
+ <id>opendaylight-snapshot</id>
+ <name>opendaylight-snapshot</name>
+ <url>https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>opendaylight-shapshot</id>
+ <name>opendaylight-snapshot</name>
+ <url>https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+ </profile>
+ </profiles>
+
+ <activeProfiles>
+ <activeProfile>fd.io-release</activeProfile>
+ <activeProfile>fd.io-snapshots</activeProfile>
+ <activeProfile>opendaylight-snapshots</activeProfile>
+ </activeProfiles>
+</settings>