Add a vagrant file for mininet environment

- Modify the README
- Fixed the ubuntu image version
- Modify the apparmor profile for dhclient

Change-Id: Ia3b26e6ec85aab7739ac01157f5959c01e13f002
diff --git a/trellis/README.md b/trellis/README.md
index c8f53d6..e5406f3 100644
--- a/trellis/README.md
+++ b/trellis/README.md
@@ -9,7 +9,7 @@
 # Download
 `git clone https://gerrit.onosproject.org/routing`
 
-# Installation
+# Manual Installation
 
 ## Ubuntu 16.04 LTS
 Some dependencies need to be installed for a fresh Ubuntu.
@@ -75,11 +75,19 @@
 fpm connection ip 192.168.56.11 port 2620
 ```
 
-## Disable AppArmor
+## Disable/Modify AppArmor
 The apparmor will set dhcpd in enforce mode. We will need to disable the profile.
 ```
-ln -s /etc/apparmor.d/usr.sbin.dhcpd /etc/apparmor.d/disable/
-apparmor_parser -R /etc/apparmor.d/usr.sbin.dhcpd
+sudo ln -s /etc/apparmor.d/usr.sbin.dhcpd /etc/apparmor.d/disable/
+sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.dhcpd
+```
+
+The apparmor rules of dhclient will restrict the dhclient to write files to directory /var/lib/.
+We need to modify the rules of dhclient profile and restart the apparmor.
+```
+sudo /etc/init.d/apparmor stop
+sudo sed -i '30i  /var/lib/dhcp{,3}/dhcpclient* lrw,' /etc/apparmor.d/sbin.dhclient
+sudo /etc/init.d/apparmor start
 ```
 
 ## Start Mininet Emulation
@@ -93,6 +101,36 @@
 - `h1 ping 10.0.99.2` to check IPv4 connectivity
 - `h1v6 ping6 2000::9902` to check IPv6 connectivity
 
+# Vagrant
+We also provide a mininet VM image supported by Vagrant file.
+In that VM environment, you only need to modify the IP address of ONON controller for
+`trellis.py` and `zebradbgp*.conf`.
+
+In order to use the Vagrant, make sure you have already installed the Vagrant in your environment.
+
+## Start the VM
+```
+vagrant up
+```
+
+## Start the ONOS
+Start the ONON controller and set the config via `onos-netcfg` on the other host.
+
+## Operate the VM
+Type the following command to ssh into the VM environment.
+```
+vagrant ssh
+```
+
+Now. Follow above instructions to modify the IP address of `trellis.py` and `zebradbgp*.conf.
+and then start the mininet to test
+```
+cd routing/trellis
+vim trellis.py
+vim zebradbgp1.conf
+sudo ./trellis.py
+```
+
 # Troubleshooting
 - Services in the emulated hosts may still be alive if Mininet is not terminated properly.
 In that case, simply run the following command to clean up.
diff --git a/trellis/Vagrantfile b/trellis/Vagrantfile
new file mode 100644
index 0000000..c58907d
--- /dev/null
+++ b/trellis/Vagrantfile
@@ -0,0 +1,40 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+Vagrant.configure("2") do |config|
+  config.vm.box = "ubuntu/xenial64"
+  config.vm.box_version = "20171221.0.0"
+  config.vm.hostname = 'trellis-example'
+
+  config.vm.provision "shell", privileged: false, inline: <<-SHELL
+    set -e -x -u
+    sudo apt-get update
+    sudo apt-get install -y gawk texinfo python-pip build-essential iptables automake autoconf libtool mininet isc-dhcp-server
+    sudo pip install -U pip
+    sudo pip install ipaddress
+    git clone -b onos-1.11 https://gerrit.opencord.org/quagga
+    cd quagga
+    ./bootstrap.sh
+    ./configure --enable-fpm --sbindir=/usr/lib/quagga enable_user=root enable_group=root
+    make
+    sudo make install
+    cd ..
+
+    sudo /etc/init.d/apparmor stop
+    sudo ln -s /etc/apparmor.d/usr.sbin.dhcpd /etc/apparmor.d/disable/
+    sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.dhcpd
+    sudo sed -i '30i  /var/lib/dhcp{,3}/dhcpclient* lrw,' /etc/apparmor.d/sbin.dhclient
+    sudo /etc/init.d/apparmor start
+
+    git clone https://gerrit.onosproject.org/routing
+
+    sudo ldconfig
+    SHELL
+
+  config.vm.provider :virtualbox do |v|
+      v.customize ["modifyvm", :id, "--cpus", 2]
+      # enable this when you want to have more memory
+      # v.customize ["modifyvm", :id, "--memory", 4096]
+      v.customize ['modifyvm', :id, '--nicpromisc1', 'allow-all']
+  end
+end