From dca3fdc482425cdb41ec7ef2ae0c3f6cf4082da7 Mon Sep 17 00:00:00 2001 From: Pawel Piatek Date: Mon, 10 Aug 2020 16:18:55 +0200 Subject: [PATCH] script/vagrant: vagrantfile refactoring - reorganize the code to cleanup main loop - other small syntax improvements Signed-off-by: Pawel Piatek Change-Id: I0a2b9ac9e78db2f96ed49d3e7e4d938425c76fa9 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3720 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Tomasz Zawadzki Reviewed-by: Jim Harris Reviewed-by: Karol Latecki --- scripts/vagrant/Vagrantfile | 46 +++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/scripts/vagrant/Vagrantfile b/scripts/vagrant/Vagrantfile index 2404d8c95..6a0358b30 100644 --- a/scripts/vagrant/Vagrantfile +++ b/scripts/vagrant/Vagrantfile @@ -275,38 +275,34 @@ def setup_libvirt(config, vmcpu, vmram, distro) end end -Vagrant.configure(2) do |config| +################################################################################################# +# Pick the right distro and bootstrap, default is fedora30 +distro = (ENV['SPDK_VAGRANT_DISTRO'] || "fedora30") +provider = (ENV['SPDK_VAGRANT_PROVIDER'] || "virtualbox") - # Pick the right distro and bootstrap, default is fedora30 - distro = ( ENV['SPDK_VAGRANT_DISTRO'] || "fedora30") - provider = (ENV['SPDK_VAGRANT_PROVIDER'] || "virtualbox") +# Get all variables for creating vm +vmcpu = (ENV['SPDK_VAGRANT_VMCPU'] || 2) +vmram = (ENV['SPDK_VAGRANT_VMRAM'] || 4096) +nfs_sync_backend_distros = ['freebsd', 'clearlinux'] - # Get all variables for creating vm - vmcpu=(ENV['SPDK_VAGRANT_VMCPU'] || 2) - vmram=(ENV['SPDK_VAGRANT_VMRAM'] || 4096) - spdk_dir=(ENV['SPDK_DIR'] || "none") - 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 - # have issues installing rsync and sshfs for syncing files. NFS is - # pre-installed, so use it. - # generic/fedora boxes on the other hand have problems running NFS - # service so use sshfs+rsync combo instead. - plugins_sync_backend = {type: :sshfs} +# generic/freebsd boxes do not work properly with vagrant-proxyconf and +# have issues installing rsync and sshfs for syncing files. NFS is +# pre-installed, so use it. +# generic/fedora boxes on the other hand have problems running NFS +# service so use sshfs+rsync combo instead. +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 # 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 # the compression to speed up the whole transfer. files_sync_backend = {type: "rsync", rsync__auto: false, rsync__args: ["--archive", "--verbose", "--delete"]} - if (distro.include? "freebsd") || (distro.include? "clearlinux") - plugins_sync_backend = {type: :nfs, nfs_udp: false} - files_sync_backend = {type: :nfs, nfs_udp: false, mount_options: ['ro']} - end + plugins_sync_backend = {type: :sshfs} +end + +Vagrant.configure(2) do |config| config.vm.box = get_box_type(distro) config.vm.box_check_update = false config.vm.synced_folder '.', '/vagrant', disabled: true