blob: 92d6832ac6e4819d416a6b21c2aa95cbd8024dce [file] [log] [blame]
Ed Warnickecb9cada2015-12-08 15:45:58 -07001# -*- mode: ruby -*-
2# vi: set ft=ruby :
3
4Vagrant.configure(2) do |config|
5
Dave Wallaceed0e49c2017-01-26 21:42:00 -05006 # Pick the right distro and bootstrap, default is ubuntu1604
7 distro = ( ENV['VPP_VAGRANT_DISTRO'] || "ubuntu1604")
Ed Warnickecb9cada2015-12-08 15:45:58 -07008 if distro == 'centos7'
Ed Warnickec841eac2016-03-22 16:10:07 -05009 config.vm.box = "puppetlabs/centos-7.2-64-nocm"
Thomas F Herbert7b75d212016-08-01 18:33:48 -040010 config.ssh.insert_key = false
Dave Wallaceed0e49c2017-01-26 21:42:00 -050011 else
12 config.vm.box = "puppetlabs/ubuntu-16.04-64-nocm"
Ed Warnickecb9cada2015-12-08 15:45:58 -070013 end
Thomas Monjalon9d6c0ab2016-06-01 10:02:04 +020014 config.vm.box_check_update = false
Ed Warnickecb9cada2015-12-08 15:45:58 -070015
Ed Warnicke30aff242016-05-06 12:58:31 -050016 config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"update.sh")
Ray Kinsellaee49bf82016-12-21 12:10:43 +000017 config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"build.sh"), :args => "/vpp vagrant"
Dave Wallaceed0e49c2017-01-26 21:42:00 -050018
Dave Wallace19481612017-09-15 18:47:44 -040019 # 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"
Dave Wallaceed0e49c2017-01-26 21:42:00 -050022 end
Dave Wallace19481612017-09-15 18:47:44 -040023 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
Ed Warnickeeeee9e22016-02-02 17:47:17 -080027 # 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
Ed Warnickecb9cada2015-12-08 15:45:58 -070043 # 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
Vincent JARDIN1d3be192016-01-14 17:01:08 -080052 # Define some physical ports for your VMs to be used by DPDK
Srivatsa Sangli010972a2016-06-21 12:58:19 -070053 nics = (ENV['VPP_VAGRANT_NICS'] || "2").to_i(10)
Vincent JARDIN1d3be192016-01-14 17:01:08 -080054 for i in 1..nics
55 config.vm.network "private_network", type: "dhcp"
56 end
57
Ed Warnickeb73f2672015-12-14 16:08:45 -070058 # use http proxy if avaiable
59 if ENV['http_proxy'] && Vagrant.has_plugin?("vagrant-proxyconf")
Jeff Shawecec2792016-04-05 10:23:17 -070060 config.proxy.http = ENV['http_proxy']
61 config.proxy.https = ENV['https_proxy']
Ed Warnickeb73f2672015-12-14 16:08:45 -070062 config.proxy.no_proxy = "localhost,127.0.0.1"
63 end
64
Keith Burns (alagalah)e0965d42016-06-19 07:58:51 -070065 vmcpu=(ENV['VPP_VAGRANT_VMCPU'] || 2)
Keith Burns (alagalah)f8035642016-06-25 03:50:28 -070066 vmram=(ENV['VPP_VAGRANT_VMRAM'] || 4096)
Ed Warnicke3ba4d362016-09-01 11:54:27 -070067
68 config.ssh.forward_agent = true
Dave Wallaceed0e49c2017-01-26 21:42:00 -050069 config.ssh.forward_x11 = true
Ed Warnicke3ba4d362016-09-01 11:54:27 -070070
Ed Warnickecb9cada2015-12-08 15:45:58 -070071 config.vm.provider "virtualbox" do |vb|
Keith Burns (alagalah)3d5916d2016-05-01 09:12:18 -070072 vb.customize ["modifyvm", :id, "--ioapic", "on"]
Keith Burns (alagalah)e0965d42016-06-19 07:58:51 -070073 vb.memory = "#{vmram}"
74 vb.cpus = "#{vmcpu}"
Ray9387e512016-07-20 13:13:18 +010075
Padraig Connolly46f133d2017-01-17 14:13:03 +000076 # rsync the vpp directory if provision hasn't happened yet
Dave Wallace19481612017-09-15 18:47:44 -040077 unless File.exist? (".vagrant/machines/client/virtualbox/action_provision")
Padraig Connolly46f133d2017-01-17 14:13:03 +000078 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
Ray9387e512016-07-20 13:13:18 +010094 #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"]
Ed Warnickecb9cada2015-12-08 15:45:58 -070097 end
98 config.vm.provider "vmware_fusion" do |fusion,override|
Keith Burns (alagalah)e0965d42016-06-19 07:58:51 -070099 fusion.vmx["memsize"] = "#{vmram}"
100 fusion.vmx["numvcpus"] = "#{vmcpu}"
Ed Warnickecb9cada2015-12-08 15:45:58 -0700101 end
Jeff Shawecec2792016-04-05 10:23:17 -0700102 config.vm.provider "libvirt" do |lv|
Keith Burns (alagalah)e0965d42016-06-19 07:58:51 -0700103 lv.memory = "#{vmram}"
104 lv.cpus = "#{vmcpu}"
Jeff Shawecec2792016-04-05 10:23:17 -0700105 end
Ed Warnickecb9cada2015-12-08 15:45:58 -0700106 config.vm.provider "vmware_workstation" do |vws,override|
Keith Burns (alagalah)e0965d42016-06-19 07:58:51 -0700107 vws.vmx["memsize"] = "#{vmram}"
108 vws.vmx["numvcpus"] = "#{vmcpu}"
Dave Wallace19481612017-09-15 18:47:44 -0400109 end
Ed Warnickecb9cada2015-12-08 15:45:58 -0700110end