Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1 | # -*- mode: ruby -*- |
| 2 | # vi: set ft=ruby : |
| 3 | |
| 4 | Vagrant.configure(2) do |config| |
| 5 | |
Dave Wallace | ed0e49c | 2017-01-26 21:42:00 -0500 | [diff] [blame] | 6 | # Pick the right distro and bootstrap, default is ubuntu1604 |
| 7 | distro = ( ENV['VPP_VAGRANT_DISTRO'] || "ubuntu1604") |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 8 | if distro == 'centos7' |
Dave Wallace | d51020c | 2017-09-26 18:15:47 -0400 | [diff] [blame] | 9 | config.vm.box = "centos/7" |
| 10 | config.vm.box_version = "1708.01" |
Thomas F Herbert | 7b75d21 | 2016-08-01 18:33:48 -0400 | [diff] [blame] | 11 | config.ssh.insert_key = false |
Dave Wallace | ed0e49c | 2017-01-26 21:42:00 -0500 | [diff] [blame] | 12 | else |
| 13 | config.vm.box = "puppetlabs/ubuntu-16.04-64-nocm" |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 14 | end |
Thomas Monjalon | 9d6c0ab | 2016-06-01 10:02:04 +0200 | [diff] [blame] | 15 | config.vm.box_check_update = false |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 16 | |
Ed Warnicke | 30aff24 | 2016-05-06 12:58:31 -0500 | [diff] [blame] | 17 | config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"update.sh") |
Ray Kinsella | ee49bf8 | 2016-12-21 12:10:43 +0000 | [diff] [blame] | 18 | config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"build.sh"), :args => "/vpp vagrant" |
Dave Wallace | ed0e49c | 2017-01-26 21:42:00 -0500 | [diff] [blame] | 19 | |
Dave Wallace | 1948161 | 2017-09-15 18:47:44 -0400 | [diff] [blame] | 20 | # Create VCL client and server VM's |
| 21 | config.vm.define "vcl-server" do |server| |
| 22 | server.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"vcl_test.sh"), :args => "/vpp vagrant vcl-server" |
Dave Wallace | ed0e49c | 2017-01-26 21:42:00 -0500 | [diff] [blame] | 23 | end |
Dave Wallace | 1948161 | 2017-09-15 18:47:44 -0400 | [diff] [blame] | 24 | config.vm.define "vcl-client" do |client| |
| 25 | client.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"vcl_test.sh"), :args => "/vpp vagrant vcl-client" |
| 26 | end |
| 27 | |
Ed Warnicke | eeee9e2 | 2016-02-02 17:47:17 -0800 | [diff] [blame] | 28 | # Add .gnupg dir in so folks can sign patches |
| 29 | # Note, as gnupg puts socket files in that dir, we have |
| 30 | # to be cautious and make sure we are dealing with a plain file |
| 31 | homedir = File.expand_path("~/") |
| 32 | Dir["#{homedir}/.gnupg/**/*"].each do |fname| |
| 33 | if File.file?(fname) |
| 34 | destname = fname.sub(Regexp.escape("#{homedir}/"),'') |
| 35 | config.vm.provision "file", source: fname, destination: destname |
| 36 | end |
| 37 | end |
| 38 | |
| 39 | # Copy in the .gitconfig if it exists |
| 40 | if File.file?(File.expand_path("~/.gitconfig")) |
| 41 | config.vm.provision "file", source: "~/.gitconfig", destination: ".gitconfig" |
| 42 | end |
| 43 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 44 | # vagrant-cachier caches apt/yum etc to speed subsequent |
| 45 | # vagrant up |
| 46 | # to enable, run |
| 47 | # vagrant plugin install vagrant-cachier |
| 48 | # |
| 49 | if Vagrant.has_plugin?("vagrant-cachier") |
| 50 | config.cache.scope = :box |
| 51 | end |
| 52 | |
Vincent JARDIN | 1d3be19 | 2016-01-14 17:01:08 -0800 | [diff] [blame] | 53 | # Define some physical ports for your VMs to be used by DPDK |
Srivatsa Sangli | 010972a | 2016-06-21 12:58:19 -0700 | [diff] [blame] | 54 | nics = (ENV['VPP_VAGRANT_NICS'] || "2").to_i(10) |
Vincent JARDIN | 1d3be19 | 2016-01-14 17:01:08 -0800 | [diff] [blame] | 55 | for i in 1..nics |
| 56 | config.vm.network "private_network", type: "dhcp" |
| 57 | end |
| 58 | |
Ed Warnicke | b73f267 | 2015-12-14 16:08:45 -0700 | [diff] [blame] | 59 | # use http proxy if avaiable |
| 60 | if ENV['http_proxy'] && Vagrant.has_plugin?("vagrant-proxyconf") |
Jeff Shaw | ecec279 | 2016-04-05 10:23:17 -0700 | [diff] [blame] | 61 | config.proxy.http = ENV['http_proxy'] |
| 62 | config.proxy.https = ENV['https_proxy'] |
Ed Warnicke | b73f267 | 2015-12-14 16:08:45 -0700 | [diff] [blame] | 63 | config.proxy.no_proxy = "localhost,127.0.0.1" |
| 64 | end |
| 65 | |
Keith Burns (alagalah) | e0965d4 | 2016-06-19 07:58:51 -0700 | [diff] [blame] | 66 | vmcpu=(ENV['VPP_VAGRANT_VMCPU'] || 2) |
Keith Burns (alagalah) | f803564 | 2016-06-25 03:50:28 -0700 | [diff] [blame] | 67 | vmram=(ENV['VPP_VAGRANT_VMRAM'] || 4096) |
Ed Warnicke | 3ba4d36 | 2016-09-01 11:54:27 -0700 | [diff] [blame] | 68 | |
| 69 | config.ssh.forward_agent = true |
Dave Wallace | ed0e49c | 2017-01-26 21:42:00 -0500 | [diff] [blame] | 70 | config.ssh.forward_x11 = true |
Ed Warnicke | 3ba4d36 | 2016-09-01 11:54:27 -0700 | [diff] [blame] | 71 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 72 | config.vm.provider "virtualbox" do |vb| |
Keith Burns (alagalah) | 3d5916d | 2016-05-01 09:12:18 -0700 | [diff] [blame] | 73 | vb.customize ["modifyvm", :id, "--ioapic", "on"] |
Keith Burns (alagalah) | e0965d4 | 2016-06-19 07:58:51 -0700 | [diff] [blame] | 74 | vb.memory = "#{vmram}" |
| 75 | vb.cpus = "#{vmcpu}" |
Ray | 9387e51 | 2016-07-20 13:13:18 +0100 | [diff] [blame] | 76 | |
Padraig Connolly | 46f133d | 2017-01-17 14:13:03 +0000 | [diff] [blame] | 77 | # rsync the vpp directory if provision hasn't happened yet |
Dave Wallace | 1948161 | 2017-09-15 18:47:44 -0400 | [diff] [blame] | 78 | unless File.exist? (".vagrant/machines/client/virtualbox/action_provision") |
Padraig Connolly | 46f133d | 2017-01-17 14:13:03 +0000 | [diff] [blame] | 79 | config.vm.synced_folder "../../", "/vpp", type: "rsync", |
| 80 | rsync__auto: false, |
| 81 | rsync__exclude: [ |
| 82 | "build-root/build*/", |
| 83 | "build-root/install*/", |
| 84 | "build-root/images*/", |
| 85 | "build-root/*.deb", |
| 86 | "build-root/*.rpm", |
| 87 | "build-root/*.changes", |
| 88 | "build-root/python", |
| 89 | "build-root/deb/debian/*.dkms", |
| 90 | "build-root/deb/debian/*.install", |
| 91 | "build-root/deb/debian/changes", |
| 92 | "build-root/tools"] |
| 93 | end |
| 94 | |
Ray | 9387e51 | 2016-07-20 13:13:18 +0100 | [diff] [blame] | 95 | #support for the SSE4.x instruction is required in some versions of VB. |
| 96 | vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.1", "1"] |
| 97 | vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.2", "1"] |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 98 | end |
| 99 | config.vm.provider "vmware_fusion" do |fusion,override| |
Keith Burns (alagalah) | e0965d4 | 2016-06-19 07:58:51 -0700 | [diff] [blame] | 100 | fusion.vmx["memsize"] = "#{vmram}" |
| 101 | fusion.vmx["numvcpus"] = "#{vmcpu}" |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 102 | end |
Jeff Shaw | ecec279 | 2016-04-05 10:23:17 -0700 | [diff] [blame] | 103 | config.vm.provider "libvirt" do |lv| |
Keith Burns (alagalah) | e0965d4 | 2016-06-19 07:58:51 -0700 | [diff] [blame] | 104 | lv.memory = "#{vmram}" |
| 105 | lv.cpus = "#{vmcpu}" |
Jeff Shaw | ecec279 | 2016-04-05 10:23:17 -0700 | [diff] [blame] | 106 | end |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 107 | config.vm.provider "vmware_workstation" do |vws,override| |
Keith Burns (alagalah) | e0965d4 | 2016-06-19 07:58:51 -0700 | [diff] [blame] | 108 | vws.vmx["memsize"] = "#{vmram}" |
| 109 | vws.vmx["numvcpus"] = "#{vmcpu}" |
Dave Wallace | 1948161 | 2017-09-15 18:47:44 -0400 | [diff] [blame] | 110 | end |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 111 | end |