Commit dca3fdc4 authored by Pawel Piatek's avatar Pawel Piatek Committed by Tomasz Zawadzki
Browse files

script/vagrant: vagrantfile refactoring



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

Signed-off-by: default avatarPawel 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: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarKarol Latecki <karol.latecki@intel.com>
parent 282b1945
Loading
Loading
Loading
Loading
+23 −27
Original line number Diff line number Diff line
@@ -275,8 +275,7 @@ 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")
@@ -284,29 +283,26 @@ Vagrant.configure(2) do |config|
# 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")
nfs_sync_backend_distros = ['freebsd', 'clearlinux']

# 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}
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']}
  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