Last active
December 29, 2023 07:00
-
-
Save pchaigno/60af009537ecd6674b9bb05e1fbfcd72 to your computer and use it in GitHub Desktop.
OVS + Floodlight from sources in a VM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure(2) do |config| | |
config.vm.box = "ubuntu/trusty64" | |
config.vm.network :forwarded_port, guest: 8080, host: 8888 | |
config.vm.provider "virtualbox" do |vb| | |
vb.memory = 2048 | |
vb.cpus = 4 | |
vb.gui = true | |
end | |
config.vm.provision "dns", type: "shell", inline: <<-SHELL | |
echo "nameserver 172.30.1.3" > /etc/resolv.conf | |
echo "search rd.s34l.org" >> /etc/resolv.conf | |
SHELL | |
config.vm.provision "prepare", type: "shell", inline: <<-SHELL | |
add-apt-repository ppa:webupd8team/java -y | |
apt-get update | |
apt-get install -y git make gcc libssl-dev python autoconf automake libtool wget sparse default-jdk ant python-dev eclipse | |
# Optional, used for debugging. | |
apt-get install -y nmap htop sysstat | |
echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections | |
echo debconf shared/accepted-oracle-license-v1-1 seen true | debconf-set-selections | |
apt-get install -y oracle-java8-installer | |
SHELL | |
config.vm.provision "install", type: "shell", privileged: false, inline: <<-SHELL | |
# OVS must be cloned (and eventually modified) outside the VM first. | |
# git clone https://github.com/openvswitch/ovs | |
cd /vagrant/ovs | |
./boot.sh | |
./configure --enable-Werror --with-linux=/lib/modules/`uname -r`/build | |
C=1 make -j4 | |
# make check RECHECK=yes TESTSUITEFLAGS=-j4 | |
sudo make install | |
sudo make modules_install | |
sudo mkdir -p /usr/local/etc/openvswitch | |
if [ ! -f /usr/local/etc/openvswitch/conf.db ]; then | |
sudo ovsdb-tool create /usr/local/etc/openvswitch/conf.db vswitchd/vswitch.ovsschema | |
fi | |
SHELL | |
config.vm.provision "floodlight", type: "shell", privileged: false, inline: <<-SHELL | |
cd /home/vagrant | |
if [ ! -f floodlight ]; then | |
git clone git://github.com/floodlight/floodlight.git | |
fi | |
cd floodlight | |
ant | |
SHELL | |
config.vm.provision "fr", type: "shell", inline: <<-SHELL | |
loadkeys fr | |
locale-gen fr_FR.UTF-8 | |
dpkg-reconfigure locales | |
SHELL | |
config.vm.provision "start-floodlight", type: "shell", privileged: false, inline: <<-SHELL | |
cd /home/vagrant/floodlight | |
java -jar target/floodlight.jar &> /home/vagrant/floodlight.log & | |
SHELL | |
config.vm.provision "start", type: "shell", inline: <<-SHELL | |
modprobe openvswitch | |
ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/db.sock --remote=db:Open_vSwitch,Open_vSwitch,manager_options --private-key=db:Open_vSwitch,SSL,private_key --certificate=db:Open_vSwitch,SSL,certificate --bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert --log-file=/usr/local/var/log/openvswitch/ovs-vswitchd.log -vsyslog:dbg -vfile:dbg --pidfile --detach | |
ovs-vsctl --no-wait init | |
if [ -f /home/vagrant/started ]; then | |
ovs-vswitchd -v --pidfile --detach --log-file=/usr/local/var/log/openvswitch/ovs-vswitchd.log -vconsole:err -vsyslog:info -vfile:info && \ | |
ifconfig br-int 10.0.2.15 netmask 255.255.255.0 && \ | |
ifconfig eth0 0.0.0.0 && \ | |
route add default gw 10.0.2.3 br-int && \ | |
route del -net 10.0.2.0 netmask 255.255.255.0 eth0 && \ | |
ovs-vsctl set-controller br-int tcp:127.0.0.1:6653 | |
else | |
ovs-vswitchd -v --pidfile --detach --log-file=/usr/local/var/log/openvswitch/ovs-vswitchd.log -vconsole:err -vsyslog:info -vfile:info | |
ovs-vsctl add-br br-int | |
ovs-vsctl add-port br-int eth0 && \ | |
ifconfig br-int 10.0.2.15 netmask 255.255.255.0 && \ | |
ifconfig eth0 0.0.0.0 && \ | |
route add default gw 10.0.2.3 br-int | |
route del -net 10.0.2.0 netmask 255.255.255.0 eth0 | |
touch /home/vagrant/started | |
ovs-vsctl set-controller br-int tcp:127.0.0.1:6653 | |
fi | |
SHELL | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment