blob: 8a2454ae0afc35aed3fbc660410b90c7bfa70275 [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'
Dave Wallaced51020c2017-09-26 18:15:47 -04009 config.vm.box = "centos/7"
10 config.vm.box_version = "1708.01"
Thomas F Herbert7b75d212016-08-01 18:33:48 -040011 config.ssh.insert_key = false
Kyle Mesteryacc1fbc2018-08-10 16:32:13 -050012 elsif distro == 'ubuntu1804'
13 config.vm.box = "bento/ubuntu-18.04"
Dave Wallaceed0e49c2017-01-26 21:42:00 -050014 else
15 config.vm.box = "puppetlabs/ubuntu-16.04-64-nocm"
Ed Warnickecb9cada2015-12-08 15:45:58 -070016 end
Thomas Monjalon9d6c0ab2016-06-01 10:02:04 +020017 config.vm.box_check_update = false
Ed Warnickecb9cada2015-12-08 15:45:58 -070018
Ed Warnicke30aff242016-05-06 12:58:31 -050019 config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"update.sh")
Ray Kinsellaee49bf82016-12-21 12:10:43 +000020 config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"build.sh"), :args => "/vpp vagrant"
Dave Wallaceed0e49c2017-01-26 21:42:00 -050021
22 post_build = ( ENV['VPP_VAGRANT_POST_BUILD'] )
23 if post_build == "test"
24 config.vm.provision "shell", inline: "echo Testing VPP; cd /vpp; make test"
25 elsif post_build == "install"
26 config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"install.sh"), :args => "/vpp"
27 config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"clearinterfaces.sh")
28 config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"run.sh")
29 end
Ed Warnicked6a0fc52016-04-12 17:34:48 -050030
Ed Warnickeeeee9e22016-02-02 17:47:17 -080031 # Add .gnupg dir in so folks can sign patches
32 # Note, as gnupg puts socket files in that dir, we have
33 # to be cautious and make sure we are dealing with a plain file
34 homedir = File.expand_path("~/")
35 Dir["#{homedir}/.gnupg/**/*"].each do |fname|
36 if File.file?(fname)
37 destname = fname.sub(Regexp.escape("#{homedir}/"),'')
38 config.vm.provision "file", source: fname, destination: destname
39 end
40 end
41
42 # Copy in the .gitconfig if it exists
43 if File.file?(File.expand_path("~/.gitconfig"))
44 config.vm.provision "file", source: "~/.gitconfig", destination: ".gitconfig"
45 end
46
Ed Warnickecb9cada2015-12-08 15:45:58 -070047 # vagrant-cachier caches apt/yum etc to speed subsequent
48 # vagrant up
49 # to enable, run
50 # vagrant plugin install vagrant-cachier
51 #
52 if Vagrant.has_plugin?("vagrant-cachier")
53 config.cache.scope = :box
54 end
55
Vincent JARDIN1d3be192016-01-14 17:01:08 -080056 # Define some physical ports for your VMs to be used by DPDK
Srivatsa Sangli010972a2016-06-21 12:58:19 -070057 nics = (ENV['VPP_VAGRANT_NICS'] || "2").to_i(10)
Vincent JARDIN1d3be192016-01-14 17:01:08 -080058 for i in 1..nics
59 config.vm.network "private_network", type: "dhcp"
60 end
61
Ed Warnickeb73f2672015-12-14 16:08:45 -070062 # use http proxy if avaiable
63 if ENV['http_proxy'] && Vagrant.has_plugin?("vagrant-proxyconf")
Jeff Shawecec2792016-04-05 10:23:17 -070064 config.proxy.http = ENV['http_proxy']
65 config.proxy.https = ENV['https_proxy']
Ed Warnickeb73f2672015-12-14 16:08:45 -070066 config.proxy.no_proxy = "localhost,127.0.0.1"
67 end
68
Keith Burns (alagalah)e0965d42016-06-19 07:58:51 -070069 vmcpu=(ENV['VPP_VAGRANT_VMCPU'] || 2)
Keith Burns (alagalah)f8035642016-06-25 03:50:28 -070070 vmram=(ENV['VPP_VAGRANT_VMRAM'] || 4096)
Ed Warnicke3ba4d362016-09-01 11:54:27 -070071
72 config.ssh.forward_agent = true
Dave Wallaceed0e49c2017-01-26 21:42:00 -050073 config.ssh.forward_x11 = true
Ed Warnicke3ba4d362016-09-01 11:54:27 -070074
Ed Warnickecb9cada2015-12-08 15:45:58 -070075 config.vm.provider "virtualbox" do |vb|
Keith Burns (alagalah)3d5916d2016-05-01 09:12:18 -070076 vb.customize ["modifyvm", :id, "--ioapic", "on"]
Keith Burns (alagalah)e0965d42016-06-19 07:58:51 -070077 vb.memory = "#{vmram}"
78 vb.cpus = "#{vmcpu}"
Ray9387e512016-07-20 13:13:18 +010079
Padraig Connolly46f133d2017-01-17 14:13:03 +000080 # rsync the vpp directory if provision hasn't happened yet
81 unless File.exist? (".vagrant/machines/default/virtualbox/action_provision")
82 config.vm.synced_folder "../../", "/vpp", type: "rsync",
83 rsync__auto: false,
84 rsync__exclude: [
85 "build-root/build*/",
86 "build-root/install*/",
87 "build-root/images*/",
88 "build-root/*.deb",
89 "build-root/*.rpm",
90 "build-root/*.changes",
91 "build-root/python",
92 "build-root/deb/debian/*.dkms",
93 "build-root/deb/debian/*.install",
94 "build-root/deb/debian/changes",
95 "build-root/tools"]
96 end
97
Ray9387e512016-07-20 13:13:18 +010098 #support for the SSE4.x instruction is required in some versions of VB.
99 vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.1", "1"]
100 vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.2", "1"]
Ed Warnickecb9cada2015-12-08 15:45:58 -0700101 end
102 config.vm.provider "vmware_fusion" do |fusion,override|
Keith Burns (alagalah)e0965d42016-06-19 07:58:51 -0700103 fusion.vmx["memsize"] = "#{vmram}"
104 fusion.vmx["numvcpus"] = "#{vmcpu}"
Ed Warnickecb9cada2015-12-08 15:45:58 -0700105 end
Jeff Shawecec2792016-04-05 10:23:17 -0700106 config.vm.provider "libvirt" do |lv|
Keith Burns (alagalah)e0965d42016-06-19 07:58:51 -0700107 lv.memory = "#{vmram}"
108 lv.cpus = "#{vmcpu}"
Jeff Shawecec2792016-04-05 10:23:17 -0700109 end
Ed Warnickecb9cada2015-12-08 15:45:58 -0700110 config.vm.provider "vmware_workstation" do |vws,override|
Keith Burns (alagalah)e0965d42016-06-19 07:58:51 -0700111 vws.vmx["memsize"] = "#{vmram}"
112 vws.vmx["numvcpus"] = "#{vmcpu}"
Ed Warnickecb9cada2015-12-08 15:45:58 -0700113 end
114end