scripts/vagrant: Add option to force boot of given distro

Signed-off-by: Michal Berger <michalx.berger@intel.com>
Change-Id: I1b437ee8f63e7cc15e60f611fe0c814542c73ece
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10131
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
This commit is contained in:
Michal Berger 2021-11-05 10:52:24 +01:00 committed by Jim Harris
parent 1e2c5b1f3d
commit 264e0a0a2b
2 changed files with 25 additions and 14 deletions

View File

@ -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

View File

@ -17,7 +17,7 @@ SPDK_DIR="$(cd "${DIR}/../../" && pwd)"
# The command line help
display_help() {
echo
echo " Usage: ${0##*/} [-b nvme-backing-file] [-n <num-cpus>] [-s <ram-size>] [-x <http-proxy>] [-hvrldcu] <distro>"
echo " Usage: ${0##*/} [-b nvme-backing-file] [-n <num-cpus>] [-s <ram-size>] [-x <http-proxy>] [-hvrldcuf] <distro>"
echo
echo " distro = <centos7 | centos8| ubuntu1604 | ubuntu1804 | ubuntu2004 |"
echo " fedora32 | fedora33 | fedora34 | freebsd11 | freebsd12 | arch | clearlinux>"
@ -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}"