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