Extend ebuild to specify "configure" subdir, enable verify for sample-plugin
[vpp.git] / build-root / vagrant / Vagrantfile
1 # -*- mode: ruby -*-
2 # vi: set ft=ruby :
3
4 Vagrant.configure(2) do |config|
5
6   # Pick the right distro and bootstrap, default is ubuntu1604
7   distro = ( ENV['VPP_VAGRANT_DISTRO'] || "ubuntu1604")
8   if distro == 'centos7'
9     config.vm.box = "puppetlabs/centos-7.2-64-nocm"
10     config.ssh.insert_key = false
11   elsif distro == 'ubuntu1404'
12     config.vm.box = "puppetlabs/ubuntu-14.04-64-nocm"
13   else
14     config.vm.box = "puppetlabs/ubuntu-16.04-64-nocm"
15   end
16   config.vm.box_check_update = false
17
18   config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"update.sh")
19   config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"build.sh"), :args => "/vpp vagrant"
20
21   post_build = ( ENV['VPP_VAGRANT_POST_BUILD'] )
22   if post_build == "test"
23     config.vm.provision "shell", inline: "echo Testing VPP; cd /vpp; make test"
24   elsif post_build == "install"
25     config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"install.sh"), :args => "/vpp"
26     config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"clearinterfaces.sh")
27     config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"run.sh")
28   end
29
30   # Add .gnupg dir in so folks can sign patches
31   # Note, as gnupg puts socket files in that dir, we have
32   # to be cautious and make sure we are dealing with a plain file
33   homedir = File.expand_path("~/")
34   Dir["#{homedir}/.gnupg/**/*"].each do |fname|
35     if File.file?(fname)
36       destname = fname.sub(Regexp.escape("#{homedir}/"),'')
37       config.vm.provision "file", source: fname, destination: destname
38     end
39   end
40
41   # Copy in the .gitconfig if it exists
42   if File.file?(File.expand_path("~/.gitconfig"))
43     config.vm.provision  "file", source: "~/.gitconfig", destination: ".gitconfig"
44   end
45
46   # vagrant-cachier caches apt/yum etc to speed subsequent
47   # vagrant up
48   # to enable, run
49   # vagrant plugin install vagrant-cachier
50   #
51   if Vagrant.has_plugin?("vagrant-cachier")
52     config.cache.scope = :box
53   end
54
55   # Define some physical ports for your VMs to be used by DPDK
56   nics = (ENV['VPP_VAGRANT_NICS'] || "2").to_i(10)
57   for i in 1..nics
58     config.vm.network "private_network", type: "dhcp"
59   end
60
61   # use http proxy if avaiable
62   if ENV['http_proxy'] && Vagrant.has_plugin?("vagrant-proxyconf")
63    config.proxy.http     = ENV['http_proxy']
64    config.proxy.https    = ENV['https_proxy']
65    config.proxy.no_proxy = "localhost,127.0.0.1"
66   end
67
68   vmcpu=(ENV['VPP_VAGRANT_VMCPU'] || 2)
69   vmram=(ENV['VPP_VAGRANT_VMRAM'] || 4096)
70
71   config.ssh.forward_agent = true
72   config.ssh.forward_x11 = true
73
74   config.vm.provider "virtualbox" do |vb|
75       vb.customize ["modifyvm", :id, "--ioapic", "on"]
76       vb.memory = "#{vmram}"
77       vb.cpus = "#{vmcpu}"
78
79       # rsync the vpp directory if provision hasn't happened yet
80       unless File.exist? (".vagrant/machines/default/virtualbox/action_provision")
81         config.vm.synced_folder "../../", "/vpp", type: "rsync",
82          rsync__auto: false,
83          rsync__exclude: [
84           "build-root/build*/",
85           "build-root/install*/",
86           "build-root/images*/",
87           "build-root/*.deb",
88           "build-root/*.rpm",
89           "build-root/*.changes",
90           "build-root/python",
91           "build-root/deb/debian/*.dkms",
92           "build-root/deb/debian/*.install",
93           "build-root/deb/debian/changes",
94           "build-root/tools"]
95       end
96
97       #support for the SSE4.x instruction is required in some versions of VB.
98       vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.1", "1"]
99       vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.2", "1"]
100   end
101   config.vm.provider "vmware_fusion" do |fusion,override|
102     fusion.vmx["memsize"] = "#{vmram}"
103     fusion.vmx["numvcpus"] = "#{vmcpu}"
104   end
105   config.vm.provider "libvirt" do |lv|
106     lv.memory = "#{vmram}"
107     lv.cpus = "#{vmcpu}"
108   end
109   config.vm.provider "vmware_workstation" do |vws,override|
110     vws.vmx["memsize"] = "#{vmram}"
111     vws.vmx["numvcpus"] = "#{vmcpu}"
112   end
113 end