Using env.sh file for Vagrantfile inputs, but assume some defaults 59/1659/3
authorKeith Burns (alagalah) <alagalah@gmail.com>
Sun, 19 Jun 2016 14:58:51 +0000 (07:58 -0700)
committerDave Barach <openvpp@barachs.net>
Mon, 20 Jun 2016 12:13:15 +0000 (12:13 +0000)
Change-Id: Ia4b45d88be5943d413d61435ff38796d1b6a32a2
Signed-off-by: Keith Burns (alagalah) <alagalah@gmail.com>
build-root/vagrant/README
build-root/vagrant/Vagrantfile
build-root/vagrant/WELCOME [new file with mode: 0644]
build-root/vagrant/env.sh [new file with mode: 0644]

index eb6aa2f..168b6b5 100644 (file)
@@ -1,61 +1,28 @@
-VPP has now been built, installed, and started.
+INTRO:
 
-To give it a spin, we can create a tap interface and try a simple ping
-(with trace).
+This is a vagrant environment for VPP.
 
-Make sure you have run:
+VPP currently works under Linux and has support for:
 
-$ vagrant ssh
+- Ubuntu 14.04, Ubuntu 16.04 and Centos7.2
 
-To get to the vagrant VM:
+The VM builds VPP from source which can be located at /vpp
 
-vagrant@localhost:~$
+VM PARTICULARS:
+This vagrant environment creates a VM based on environment variables found in ./env.sh
+To use, edit env.sh then
+  source ./env.sh
+  vagrant up
 
-Confirm that vpp is running with
+By default, the VM created is/has:
+- Ubuntu 14.04
+- 2 vCPUs
+- 2G of RAM
+- 2 NICs (1 x NAT - host access, 1 x VPP DPDK enabled)
 
-vagrant@localhost:~$ sudo status vpp
-vpp start/running, process 25202
+PROVIDERS:
 
-To create the tap:
+Supported vagrant providers are:
 
-vagrant@localhost:~$ sudo vppctl tap connect foobar
-Created tap-0 for Linux tap 'foobar'
-vagrant@localhost:~$ sudo vppctl show int
+- Virtualbox, VMware Fusion/Workstation, Libvirt
 
-To assign it an ip address (and 'up' the interface):
-
-vagrant@localhost:~$ sudo vppctl set int ip address tap-0 192.168.1.1/24
-vagrant@localhost:~$ sudo vppctl set int state tap-0 up
-
-To turn on packet tracing for the tap interface:
-vagrant@localhost:~$ sudo vppctl trace add tapcli-rx 10
-
-Now, to set up and try the other end:
-vagrant@localhost:~$ sudo ip addr add 192.168.1.2/24 dev foobar
-vagrant@localhost:~$ ping -c 3 192.168.1.1
-
-To look at the trace:
-vagrant@localhost:~$ sudo vppctl show trace
-
-And to stop tracing:
-
-vagrant@localhost:~$ sudo vppctl clear trace
-
-Other fun things to look at:
-
-The vlib packet processing graph:
-vagrant@localhost:~$ sudo vppctl show vlib graph
-
-which will produce output like:
-
-           Name                      Next                    Previous
-ip4-icmp-input                  error-punt [0]               ip4-local
-                                ip4-icmp-echo-request [1]
-                                vpe-icmp4-oam [2]
-
-To read this, the first column (Name) is the name of the node.
-The second column (Next) is the name of the children of that node.
-The third column (Previous) is the name of the parents of this node.
-
-To see this README again:
-cat /vagrant/README
index 7067bfc..9bb53b9 100644 (file)
@@ -4,7 +4,7 @@
 Vagrant.configure(2) do |config|
 
   # Pick the right distro and bootstrap, default is ubuntu1404
-  distro = ENV['VPP_VAGRANT_DISTRO']
+  distro = ( ENV['VPP_VAGRANT_DISTRO'] || "ubuntu1404")
   if distro == 'centos7'
     config.vm.box = "puppetlabs/centos-7.2-64-nocm"
   else
@@ -44,10 +44,7 @@ Vagrant.configure(2) do |config|
   end
 
   # Define some physical ports for your VMs to be used by DPDK
-  nics = 2
-  if ENV.key?('VPP_VAGRANT_NICS')
-    nics = ENV['VPP_VAGRANT_NICS'].to_i(10)
-  end
+  nics = (ENV['VPP_VAGRANT_NICS'] || 2).to_i(10)
   for i in 1..nics
     config.vm.network "private_network", type: "dhcp"
   end
@@ -59,21 +56,25 @@ Vagrant.configure(2) do |config|
    config.proxy.no_proxy = "localhost,127.0.0.1"
   end
 
+  vmcpu=(ENV['VPP_VAGRANT_VMCPU'] || 2)
+  vmram=(ENV['VPP_VAGRANT_VMRAM'] || 2048)
+  
   config.vm.synced_folder "../../", "/vpp", disabled: false
   config.vm.provider "virtualbox" do |vb|
       vb.customize ["modifyvm", :id, "--ioapic", "on"]
-      vb.memory = 4096
-      vb.cpus = 2
+      vb.memory = "#{vmram}"
+      vb.cpus = "#{vmcpu}"
   end
   config.vm.provider "vmware_fusion" do |fusion,override|
-    fusion.vmx["memsize"] = "4096"
+    fusion.vmx["memsize"] = "#{vmram}"
+    fusion.vmx["numvcpus"] = "#{vmcpu}"
   end
   config.vm.provider "libvirt" do |lv|
-    lv.memory = 4096
-    lv.cpus = 8
+    lv.memory = "#{vmram}"
+    lv.cpus = "#{vmcpu}"
   end
   config.vm.provider "vmware_workstation" do |vws,override|
-    vws.vmx["memsize"] = "8192"
-    vws.vmx["numvcpus"] = "4"
+    vws.vmx["memsize"] = "#{vmram}"
+    vws.vmx["numvcpus"] = "#{vmcpu}"
   end
 end
diff --git a/build-root/vagrant/WELCOME b/build-root/vagrant/WELCOME
new file mode 100644 (file)
index 0000000..eb6aa2f
--- /dev/null
@@ -0,0 +1,61 @@
+VPP has now been built, installed, and started.
+
+To give it a spin, we can create a tap interface and try a simple ping
+(with trace).
+
+Make sure you have run:
+
+$ vagrant ssh
+
+To get to the vagrant VM:
+
+vagrant@localhost:~$
+
+Confirm that vpp is running with
+
+vagrant@localhost:~$ sudo status vpp
+vpp start/running, process 25202
+
+To create the tap:
+
+vagrant@localhost:~$ sudo vppctl tap connect foobar
+Created tap-0 for Linux tap 'foobar'
+vagrant@localhost:~$ sudo vppctl show int
+
+To assign it an ip address (and 'up' the interface):
+
+vagrant@localhost:~$ sudo vppctl set int ip address tap-0 192.168.1.1/24
+vagrant@localhost:~$ sudo vppctl set int state tap-0 up
+
+To turn on packet tracing for the tap interface:
+vagrant@localhost:~$ sudo vppctl trace add tapcli-rx 10
+
+Now, to set up and try the other end:
+vagrant@localhost:~$ sudo ip addr add 192.168.1.2/24 dev foobar
+vagrant@localhost:~$ ping -c 3 192.168.1.1
+
+To look at the trace:
+vagrant@localhost:~$ sudo vppctl show trace
+
+And to stop tracing:
+
+vagrant@localhost:~$ sudo vppctl clear trace
+
+Other fun things to look at:
+
+The vlib packet processing graph:
+vagrant@localhost:~$ sudo vppctl show vlib graph
+
+which will produce output like:
+
+           Name                      Next                    Previous
+ip4-icmp-input                  error-punt [0]               ip4-local
+                                ip4-icmp-echo-request [1]
+                                vpe-icmp4-oam [2]
+
+To read this, the first column (Name) is the name of the node.
+The second column (Next) is the name of the children of that node.
+The third column (Previous) is the name of the parents of this node.
+
+To see this README again:
+cat /vagrant/README
diff --git a/build-root/vagrant/env.sh b/build-root/vagrant/env.sh
new file mode 100644 (file)
index 0000000..f0edfd8
--- /dev/null
@@ -0,0 +1,6 @@
+#!/usr/bin/env bash
+
+export VPP_VAGRANT_DISTRO="ubuntu1404"
+export VPP_VAGRANT_NICS=2
+export VPP_VAGRANT_VMCPU=4
+export VPP_VAGRANT_VMRAM=4096