From 417cf43805572a6a965aca9de613339f0ffdceed Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Fri, 10 Dec 2021 09:32:13 -0500 Subject: [PATCH] cephfs-shell: add a --fs argument to allow mounting named filesystems Add a new --fs argument to cephfs-shell, so we can use it to mount named filesystems. Add a blurb to the manpage for it, and alphebetize the command-line flags. Fixes: https://tracker.ceph.com/issues/50235 Signed-off-by: Jeff Layton --- doc/man/8/cephfs-shell.rst | 8 ++++++-- src/tools/cephfs/cephfs-shell | 15 +++++++++------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/doc/man/8/cephfs-shell.rst b/doc/man/8/cephfs-shell.rst index b8a3699f90c..65b344fa912 100644 --- a/doc/man/8/cephfs-shell.rst +++ b/doc/man/8/cephfs-shell.rst @@ -32,13 +32,17 @@ Behaviour of CephFS Shell can be tweaked using ``cephfs-shell.conf``. Refer to Options ======= +.. option:: -b, --batch FILE + + Path to batch file. + .. option:: -c, --config FILE Path to cephfs-shell.conf -.. option:: -b, --batch FILE +.. option:: -f, --fs FS - Path to batch file. + Name of filesystem to mount. .. option:: -t, --test FILE diff --git a/src/tools/cephfs/cephfs-shell b/src/tools/cephfs/cephfs-shell index d1916a90618..923eefb6788 100755 --- a/src/tools/cephfs/cephfs-shell +++ b/src/tools/cephfs/cephfs-shell @@ -1498,14 +1498,14 @@ class CephFSShell(Cmd): # ##################################################### -def setup_cephfs(): +def setup_cephfs(args): """ Mounting a cephfs """ global cephfs try: cephfs = libcephfs.LibCephFS(conffile='') - cephfs.mount() + cephfs.mount(filesystem_name=args.fs) except libcephfs.ObjectNotFound as e: print('couldn\'t find ceph configuration not found') sys.exit(e.get_error_code()) @@ -1580,13 +1580,16 @@ def get_shell_conffile_path(arg_conf=''): def manage_args(): main_parser = argparse.ArgumentParser(description='') - main_parser.add_argument('-c', '--config', action='store', - help='Path to Ceph configuration file.', - type=str) main_parser.add_argument('-b', '--batch', action='store', help='Path to CephFS shell script/batch file' 'containing CephFS shell commands', type=str) + main_parser.add_argument('-c', '--config', action='store', + help='Path to Ceph configuration file.', + type=str) + main_parser.add_argument('-f', '--fs', action='store', + help='Name of filesystem to mount.', + type=str) main_parser.add_argument('-t', '--test', action='store', help='Test against transcript(s) in FILE', nargs='+') @@ -1620,7 +1623,7 @@ def manage_sys_argv(args): sys.argv.append(exe) sys.argv.extend([i.strip() for i in ' '.join(args.commands).split(',')]) - setup_cephfs() + setup_cephfs(args) def execute_cmd_args(args): -- 2.47.3