Whamcloud - gitweb
LU-16631 llmount: improve usability 60/50260/3
authorTimothy Day <timday@amazon.com>
Fri, 10 Mar 2023 16:56:59 +0000 (16:56 +0000)
committerOleg Drokin <green@whamcloud.com>
Mon, 1 May 2023 04:09:15 +0000 (04:09 +0000)
Add some simple help messages to both llmount.sh and
llmountcleanup.sh, similar to what auster has. This
will help unfamilar people understand the use of these
scripts.

Add option to disable client setup for llmount.sh. Add
options for llmount.sh environment variables.

Fix a couple small shellcheck warnings.

Update the file headers to have the SPDX license and
use the standard format.

Test-Parameters: trivial
Signed-off-by: Timothy Day <timday@amazon.com>
Change-Id: I50dbb30bad8c8bc0479585293056d61a25aa001d
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50260
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Patrick Farrell <pfarrell@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/llmount.sh
lustre/tests/llmountcleanup.sh

index f87b189..453edb5 100755 (executable)
@@ -1,9 +1,80 @@
 #!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
 
-LUSTRE=${LUSTRE:-$(dirname $0)/..}
-. $LUSTRE/tests/test-framework.sh
+#
+# This file is part of Lustre, http://www.lustre.org/
+#
+# lustre/tests/llmount.sh
+#
+# Create a simple lustre filesystem and client for
+# testing
+#
+
+usage() {
+       less -F <<EOF
+Usage: ${0##*/} [options]
+Helper for creating, formatting, and mounting a simple lustre filesystem.
+       -S, --server-only   Do not setup up a client
+       -n, --no-format     Do not reformat the test filesystem
+       -s, --skip-setup    Do not setup the test filesystem
+       -l, --load-modules  Load the lustre modules
+       -h, --help          This help
+
+Environment variables
+See lustre/tests/cfg/local.sh to see more variables.
+       FSTYPE    ldiskfs,zfs  Type of backing filesystem
+       MDSCOUNT  number       Number of MDS
+       OSSCOUNT  number       Number of OSS
+       MOUNTOPT  string       Options passed to client mount command
+
+Example usage:
+Create a simple lustre filesystem.
+
+       ./llmount.sh --server-only
+
+Create a ZFS backed lustre filesystem with a client.
+
+       FSTYPE=zfs ./llmount.sh
+
+EOF
+       exit
+}
+
+setup_client=true
+
+# Replace long option with corresponding short option
+for arg in "$@"; do
+       shift
+       case "$arg" in
+               --server-only) set -- "$@" '-S';;
+               --no-format) set -- "$@" '-n';;
+               --skip-setup) set -- "$@" '-s';;
+               --load-modules) set -- "$@" '-l';;
+               --help) set -- "$@" '-h';;
+               *) set -- "$@" "$arg";;
+       esac
+done
+
+while getopts "Snslh" opt
+do
+       case "$opt" in
+               S) setup_client=false;;
+               n) NOFORMAT=true;;
+               s) NOSETUP=true;;
+               l) LOAD=true;;
+               h|\?) usage;;
+       esac
+done
+
+LUSTRE=${LUSTRE:-$(dirname "$0")/..}
+. "$LUSTRE/tests/test-framework.sh"
 init_test_env "$@"
 
 [ -n "$LOAD" ] && load_modules && exit 0
 [ -z "$NOFORMAT" ] && formatall
-[ -z "$NOSETUP" ] && setupall
+
+if $setup_client; then
+       [ -z "$NOSETUP" ] && setupall
+else
+       [ -z "$NOSETUP" ] && setupall server_only
+fi
index e37e711..848177c 100755 (executable)
@@ -1,7 +1,43 @@
 #!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
 
-LUSTRE=${LUSTRE:-$(dirname $0)/..}
-. $LUSTRE/tests/test-framework.sh
+#
+# This file is part of Lustre, http://www.lustre.org/
+#
+# lustre/tests/llmountcleanup.sh
+#
+# Destroy the lustre filesystem and client created by
+# llmount.sh
+#
+
+usage() {
+       less -F <<EOF
+Usage: ${0##*/}
+Destroy the lustre filesystem and client created by llmount.sh
+       -h, --help          This help
+
+EOF
+       exit
+}
+
+# Replace long option with corresponding short option
+for arg in "$@"; do
+       shift
+       case "$arg" in
+               --help) set -- "$@" '-h';;
+               *) set -- "$@" "$arg";;
+       esac
+done
+
+while getopts "h" opt
+do
+       case "$opt" in
+               h|\?) usage;;
+       esac
+done
+
+LUSTRE=${LUSTRE:-$(dirname "$0")/..}
+. "$LUSTRE/tests/test-framework.sh"
 init_test_env "$@"
 
 cleanupall -f