script/vagrant: vagrantfile refactoring

- reorganize the code to cleanup main loop
- other small syntax improvements

Signed-off-by: Pawel Piatek <pawelx.piatek@intel.com>
Change-Id: I0a2b9ac9e78db2f96ed49d3e7e4d938425c76fa9
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3720
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
This commit is contained in:
Pawel Piatek 2020-08-10 16:18:55 +02:00 committed by Tomasz Zawadzki
parent 282b1945ef
commit dca3fdc482

View File

@ -275,8 +275,7 @@ def setup_libvirt(config, vmcpu, vmram, distro)
end end
end end
Vagrant.configure(2) do |config| #################################################################################################
# Pick the right distro and bootstrap, default is fedora30 # Pick the right distro and bootstrap, default is fedora30
distro = (ENV['SPDK_VAGRANT_DISTRO'] || "fedora30") distro = (ENV['SPDK_VAGRANT_DISTRO'] || "fedora30")
provider = (ENV['SPDK_VAGRANT_PROVIDER'] || "virtualbox") provider = (ENV['SPDK_VAGRANT_PROVIDER'] || "virtualbox")
@ -284,29 +283,26 @@ Vagrant.configure(2) do |config|
# Get all variables for creating vm # Get all variables for creating vm
vmcpu = (ENV['SPDK_VAGRANT_VMCPU'] || 2) vmcpu = (ENV['SPDK_VAGRANT_VMCPU'] || 2)
vmram = (ENV['SPDK_VAGRANT_VMRAM'] || 4096) vmram = (ENV['SPDK_VAGRANT_VMRAM'] || 4096)
spdk_dir=(ENV['SPDK_DIR'] || "none") nfs_sync_backend_distros = ['freebsd', 'clearlinux']
vmemulator=(ENV['SPDK_QEMU_EMULATOR'] || "")
emulated_nvme_types=(ENV['NVME_DISKS_TYPE'] || "nvme").split(',')
nvme_namespaces=(ENV['NVME_DISKS_NAMESPACES'] || "").split(',')
nvme_file=(ENV['NVME_FILE'] || "").split(',')
nvme_cmbs=(ENV['NVME_CMB'] || "").split(',')
vagrantfile_dir=(ENV['VAGRANTFILE_DIR'] || "none")
# generic/freebsd boxes do not work properly with vagrant-proxyconf and # generic/freebsd boxes do not work properly with vagrant-proxyconf and
# have issues installing rsync and sshfs for syncing files. NFS is # have issues installing rsync and sshfs for syncing files. NFS is
# pre-installed, so use it. # pre-installed, so use it.
# generic/fedora boxes on the other hand have problems running NFS # generic/fedora boxes on the other hand have problems running NFS
# service so use sshfs+rsync combo instead. # service so use sshfs+rsync combo instead.
plugins_sync_backend = {type: :sshfs} if (nfs_sync_backend_distros.any? { |d| distro.include?(d) })
files_sync_backend = {type: :nfs, nfs_udp: false, mount_options: ['ro']}
plugins_sync_backend = {type: :nfs, nfs_udp: false}
else
# Remove --copy-links from default rsync cmdline since we do want to sync # Remove --copy-links from default rsync cmdline since we do want to sync
# actual symlinks as well. Also, since copy is made between host and its # actual symlinks as well. Also, since copy is made between host and its
# local VM we don't need to worry about saturating the local link so skip # local VM we don't need to worry about saturating the local link so skip
# the compression to speed up the whole transfer. # the compression to speed up the whole transfer.
files_sync_backend = {type: "rsync", rsync__auto: false, rsync__args: ["--archive", "--verbose", "--delete"]} files_sync_backend = {type: "rsync", rsync__auto: false, rsync__args: ["--archive", "--verbose", "--delete"]}
if (distro.include? "freebsd") || (distro.include? "clearlinux") plugins_sync_backend = {type: :sshfs}
plugins_sync_backend = {type: :nfs, nfs_udp: false}
files_sync_backend = {type: :nfs, nfs_udp: false, mount_options: ['ro']}
end end
Vagrant.configure(2) do |config|
config.vm.box = get_box_type(distro) config.vm.box = get_box_type(distro)
config.vm.box_check_update = false config.vm.box_check_update = false
config.vm.synced_folder '.', '/vagrant', disabled: true config.vm.synced_folder '.', '/vagrant', disabled: true