From 264e0a0a2b122a7150e4cf9d6e0e67492f7aec01 Mon Sep 17 00:00:00 2001 From: Michal Berger Date: Fri, 5 Nov 2021 10:52:24 +0100 Subject: [PATCH] scripts/vagrant: Add option to force boot of given distro Signed-off-by: Michal Berger Change-Id: I1b437ee8f63e7cc15e60f611fe0c814542c73ece Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10131 Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Changpeng Liu Reviewed-by: Karol Latecki --- scripts/vagrant/Vagrantfile | 13 ++++++++----- scripts/vagrant/create_vbox.sh | 26 +++++++++++++++++--------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/scripts/vagrant/Vagrantfile b/scripts/vagrant/Vagrantfile index bc51425db..6c4424344 100644 --- a/scripts/vagrant/Vagrantfile +++ b/scripts/vagrant/Vagrantfile @@ -2,7 +2,7 @@ # vi: set ft=ruby : require 'open3' -def get_box_type(distro) +def get_box_type(distro, force_distro) spdk_distro = 'spdk/' + distro localboxes, stderr, status = Open3.capture3("vagrant box list") return spdk_distro if localboxes.include?(spdk_distro) @@ -19,9 +19,9 @@ def get_box_type(distro) 'arch' => 'generic/arch', 'freebsd12' => 'generic/freebsd12', } - abort("Invalid argument! #{distro}") unless distro_to_type.key?(distro) + abort("Invalid argument! #{distro}") unless distro_to_type.key?(distro) || force_distro - return distro_to_type[distro] + return distro_to_type[distro] ? distro_to_type[distro] : distro end def setup_proxy(config,distro) @@ -287,7 +287,10 @@ vmram = (ENV['SPDK_VAGRANT_VMRAM'] || 4096) # pre-installed, so use it. # generic/fedora boxes on the other hand have problems running NFS # service so use sshfs+rsync combo instead. -if (get_box_type(distro).include?("generic/freebsd")) +force_distro = ENV['FORCE_DISTRO'] == "true" ? true : false + +distro_to_use = get_box_type(distro, force_distro) +if (distro_to_use.include?("generic/freebsd")) files_sync_backend = {type: :nfs, nfs_udp: false, mount_options: ['ro']} plugins_sync_backend = {type: :nfs, nfs_udp: false} else @@ -300,7 +303,7 @@ else end Vagrant.configure(2) do |config| - config.vm.box = get_box_type(distro) + config.vm.box = distro_to_use config.vm.box_check_update = false config.vm.synced_folder '.', '/vagrant', disabled: true diff --git a/scripts/vagrant/create_vbox.sh b/scripts/vagrant/create_vbox.sh index 02a19af05..e7f478123 100755 --- a/scripts/vagrant/create_vbox.sh +++ b/scripts/vagrant/create_vbox.sh @@ -17,7 +17,7 @@ SPDK_DIR="$(cd "${DIR}/../../" && pwd)" # The command line help display_help() { echo - echo " Usage: ${0##*/} [-b nvme-backing-file] [-n ] [-s ] [-x ] [-hvrldcu] " + echo " Usage: ${0##*/} [-b nvme-backing-file] [-n ] [-s ] [-x ] [-hvrldcuf] " echo echo " distro = " @@ -48,7 +48,7 @@ display_help() { echo " -r dry-run" echo " -h help" echo " -v verbose" - echo + echo " -f Force use of given distro, regardless if it's supported by the script or not." echo " Examples:" echo echo " $0 -x http://user:password@host:port fedora33" @@ -86,8 +86,9 @@ VAGRANT_PASSWORD_AUTH=0 VAGRANT_PACKAGE_BOX=0 VAGRANT_HUGE_MEM=0 VAGRANTFILE=$DIR/Vagrantfile +FORCE_DISTRO=false -while getopts ":b:n:s:x:p:uvcraldoHh-:" opt; do +while getopts ":b:n:s:x:p:uvcraldoHhf-:" opt; do case "${opt}" in -) case "${OPTARG}" in @@ -146,6 +147,9 @@ while getopts ":b:n:s:x:p:uvcraldoHh-:" opt; do H) VAGRANT_HUGE_MEM=1 ;; + f) + FORCE_DISTRO=true + ;; *) echo " Invalid argument: -$OPTARG" >&2 echo " Try: \"$0 -h\"" >&2 @@ -163,15 +167,16 @@ case "${SPDK_VAGRANT_DISTRO}" in ubuntu1[68]04 | ubuntu2004) ;& fedora3[2-4]) ;& freebsd1[12]) ;& - arch | clearlinux) - export SPDK_VAGRANT_DISTRO - ;; + arch | clearlinux) ;; *) - echo " Invalid argument \"${SPDK_VAGRANT_DISTRO}\"" >&2 - echo " Try: \"$0 -h\"" >&2 - exit 1 + if [[ $FORCE_DISTRO == false ]]; then + echo " Invalid argument \"${SPDK_VAGRANT_DISTRO}\"" >&2 + echo " Try: \"$0 -h\"" >&2 + exit 1 + fi ;; esac +export SPDK_VAGRANT_DISTRO if [ -z "$NVME_FILE" ]; then TMP="/var/lib/libvirt/images/nvme_disk.img" @@ -225,6 +230,7 @@ if [ ${VERBOSE} = 1 ]; then echo SPDK_OPENSTACK_NETWORK=$SPDK_OPENSTACK_NETWORK echo VAGRANT_PACKAGE_BOX=$VAGRANT_PACKAGE_BOX echo VAGRANTFILE=$VAGRANTFILE + echo FORCE_DISTRO=$FORCE_DISTRO echo fi @@ -243,6 +249,7 @@ export NVME_DISKS_NAMESPACES export NVME_FILE export VAGRANT_PASSWORD_AUTH export VAGRANT_HUGE_MEM +export FORCE_DISTRO if [ -n "$SPDK_VAGRANT_PROVIDER" ]; then provider="--provider=${SPDK_VAGRANT_PROVIDER}" @@ -271,6 +278,7 @@ if [ ${DRY_RUN} = 1 ]; then printenv SPDK_DIR printenv VAGRANT_HUGE_MEM printenv VAGRANTFILE + printenv FORCE_DISTRO fi if [ -z "$VAGRANTFILE_DIR" ]; then VAGRANTFILE_DIR="${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}-${SPDK_VAGRANT_PROVIDER}"