numam-spdk/scripts/vagrant/Vagrantfile
John Meneghini e3a7138571 test: add support for multiple oses with vagrant
- Add vagrant create_vbox.sh script
   . This script replace env.sh
 - Refactor Vagrantfile
   . Add support for fedora28, Ubuntu18, and FreeBSD 11
   . Changes to provisioning rules
   . Removed build.sh
   . Changes to support vm_setup.sh on vagrant with Fedora 26
 - Add vagrant README.md
   . Instructions for provisioning different VMs
   . Post VM Initialization done with update.sh
 - Add vagrant run-autorun.sh script
   . Changes to run autotest.sh on vagrant with Fedora 26

Change-Id: I8a34273361dd4233241326b0cd31189cf511f503
Signed-off-by: John Meneghini <johnm@netapp.com>
Signed-off-by: Ed Rodriguez <ed.rodriguez@netapp.com>
Reviewed-on: https://review.gerrithub.io/414861
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Seth Howell <seth.howell5141@gmail.com>
2018-07-19 17:19:37 +00:00

131 lines
4.9 KiB
Ruby

# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
# Pick the right distro and bootstrap, default is ubuntu1604
distro = ( ENV['SPDK_VAGRANT_DISTRO'] || "fedora26")
case distro
when "centos7"
config.vm.box = "puppetlabs/centos-7.2-64-nocm"
config.ssh.insert_key = false
# Puppetlabs does not provide libvirt Box so we will use official one
config.vm.provider :libvirt do |libvirt|
config.vm.box = "centos/7"
end if Vagrant.has_plugin?('vagrant-libvirt')
when "ubuntu16"
# See: https://app.vagrantup.com/puppetlabs/boxes/ubuntu-16.04-64-nocm
config.vm.box = "puppetlabs/ubuntu-16.04-64-nocm"
config.vm.box_version = "1.0.0"
when "ubuntu18"
# See: https://app.vagrantup.com/bento/boxes/ubuntu-18.04
config.vm.box = "bento/ubuntu-18.04"
config.vm.box_version = "201803.24.0"
when "fedora26"
#See: https://app.vagrantup.com/generic/boxes/fedora2
config.vm.box = "generic/fedora26"
when "fedora27"
#See: https://app.vagrantup.com/generic/boxes/fedora27
config.vm.box = "generic/fedora27"
when "freebsd11"
#See: https://app.vagrantup.com/generic/boxes/freebsd11
config.vm.box = "generic/freebsd11"
else
"Invalid argument #{distro}"
abort("Invalid argument!")
end
config.vm.box_check_update = false
# Copy in the .gitconfig if it exists
if File.file?(File.expand_path("~/.gitconfig"))
config.vm.provision "file", source: "~/.gitconfig", destination: ".gitconfig"
end
# vagrant-cachier caches apt/yum etc to speed subsequent
# vagrant up
# to enable, run
# vagrant plugin install vagrant-cachier
#
if Vagrant.has_plugin?("vagrant-cachier")
config.cache.scope = :box
end
config.vm.network "private_network", type: "dhcp"
# use http proxy if avaiable
if ENV['http_proxy'] && Vagrant.has_plugin?("vagrant-proxyconf")
config.proxy.http = ENV['http_proxy']
config.proxy.https = ENV['https_proxy']
config.proxy.no_proxy = "localhost,127.0.0.1"
end
vmcpu=(ENV['SPDK_VAGRANT_VMCPU'] || 2)
vmram=(ENV['SPDK_VAGRANT_VMRAM'] || 4096)
spdk_dir=(ENV['SPDK_DIR'] || "none")
config.ssh.forward_agent = true
config.ssh.forward_x11 = true
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--ioapic", "on"]
vb.memory = "#{vmram}"
vb.cpus = "#{vmcpu}"
# rsync the spdk directory if provision hasn't happened yet
unless File.exist? (".vagrant/machines/default/virtualbox/action_provision")
if spdk_dir != "none"
config.vm.synced_folder "#{spdk_dir}", "/home/vagrant/spdk_repo/spdk", type: "rsync", rsync__auto: false
end
# Copy in the user's tools if they exists
if File.directory?(File.expand_path("~/vagrant_tools"))
config.vm.synced_folder "~/vagrant_tools", "/home/vagrant/tools", type: "rsync", rsync__auto: false
end
end
nvme_disk = 'nvme.vdi'
unless File.exist? (nvme_disk)
vb.customize ["createhd", "--filename", nvme_disk, "--variant", "Fixed", "--size", "1024"]
vb.customize ["storagectl", :id, "--name", "nvme", "--add", "pcie", "--controller", "NVMe", "--portcount", "1", "--bootable", "off"]
vb.customize ["storageattach", :id, "--storagectl", "nvme", "--type", "hdd", "--medium", nvme_disk, "--port", "0"]
end
#support for the SSE4.x instruction is required in some versions of VB.
vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.1", "1"]
vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.2", "1"]
end
# This setup was Tested on Fedora 27
# libvirt configuration need modern Qemu(tested on 2.10) & vagrant-libvirt in version 0.0.39+
# There are few limitation for SElinux - The file added outside libvirt must have proper SE ACL policy or setenforce 0
config.vm.provider "libvirt" do |libvirt, override|
# we put nvme_disk inside default pool to eliminate libvirt/SELinux Permissions Problems
# and to be able to run vagrant from user $HOME directory
nvme_disk = '/var/lib/libvirt/images/nvme_disk.img'
unless File.exist? (nvme_disk)
override.puts "If run with libvirt provider please execute create_nvme_img.sh"
end
libvirt.qemuargs :value => "-drive"
libvirt.qemuargs :value => "file=#{nvme_disk},if=none,id=D22"
libvirt.qemuargs :value => "-device"
libvirt.qemuargs :value => "nvme,drive=D22,serial=1234"
libvirt.driver = "kvm"
libvirt.graphics_type = "spice"
libvirt.memory = "#{vmram}"
libvirt.cpus = "#{vmcpu}"
libvirt.video_type = "qxl"
# Optional field if we want use other storage pools than default
# libvirt.storage_pool_name = "vm"
# rsync the spdk directory if provision hasn't happened yet
unless File.exist? (".vagrant/machines/default/virtualbox/action_provision")
if spdk_dir != "none"
config.vm.synced_folder "#{spdk_dir}", "/home/vagrant/spdk_repo/spdk", type: "rsync"
end
end
end
end