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