From: Guillaume Abrioux Date: Wed, 9 Sep 2020 08:14:33 +0000 (+0200) Subject: cephadm: support multiple mounts when running shell X-Git-Tag: v16.1.0~1058^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3ed3cff0d0ea2744dff816270d49539fd73c1691;p=ceph-ci.git cephadm: support multiple mounts when running shell This commit adds the multiple mounts support when running the interactive shell. ie: ``` --mount /foo /bar:/bar:z ``` Keeping default destination `/mnt` when no destination is passed for backward compatibility. In the above example `/foo` will be mounted in `/mnt/foo` and `/bar` in `/bar` Signed-off-by: Guillaume Abrioux --- diff --git a/doc/man/8/cephadm.rst b/doc/man/8/cephadm.rst index 5a1da7a040e..76795a32387 100644 --- a/doc/man/8/cephadm.rst +++ b/doc/man/8/cephadm.rst @@ -38,7 +38,7 @@ Synopsis | **cephadm** **run** [-h] --name NAME --fsid FSID | **cephadm** **shell** [-h] [--fsid FSID] [--name NAME] [--config CONFIG] - [--keyring KEYRING] [--mount MOUNT] [--env ENV] + [--keyring KEYRING] --mount [MOUNT [MOUNT ...]] [--env ENV] [--] [command [command ...]] | **cephadm** **enter** [-h] [--fsid FSID] --name NAME [command [command ...]] diff --git a/qa/workunits/cephadm/test_cephadm.sh b/qa/workunits/cephadm/test_cephadm.sh index e0f038db178..8720bfa9aa5 100755 --- a/qa/workunits/cephadm/test_cephadm.sh +++ b/qa/workunits/cephadm/test_cephadm.sh @@ -82,6 +82,7 @@ fi # TMPDIR for test data [ -d "$TMPDIR" ] || TMPDIR=$(mktemp -d tmp.$SCRIPT_NAME.XXXXXX) +[ -d "$TMPDIR_TEST_MULTIPLE_MOUNTS" ] || TMPDIR_TEST_MULTIPLE_MOUNTS=$(mktemp -d tmp.$SCRIPT_NAME.XXXXXX) function cleanup() { @@ -388,7 +389,7 @@ $CEPHADM shell --fsid $FSID -- true $CEPHADM shell --fsid $FSID -- test -d /var/log/ceph expect_false $CEPHADM --timeout 10 shell --fsid $FSID -- sleep 60 $CEPHADM --timeout 60 shell --fsid $FSID -- sleep 10 -$CEPHADM shell --fsid $FSID --mount $TMPDIR -- stat /mnt/$(basename $TMPDIR) +$CEPHADM shell --fsid $FSID --mount $TMPDIR $TMPDIR_TEST_MULTIPLE_MOUNTS -- stat /mnt/$(basename $TMPDIR) ## enter expect_false $CEPHADM enter diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index f640037a548..51ffcb29535 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -3308,9 +3308,15 @@ def command_shell(): if args.keyring: mounts[pathify(args.keyring)] = '/etc/ceph/ceph.keyring:z' if args.mount: - mount = pathify(args.mount) - filename = os.path.basename(mount) - mounts[mount] = '/mnt/{}:z'.format(filename) + for _mount in args.mount: + split_src_dst = _mount.split(':') + mount = pathify(split_src_dst[0]) + filename = os.path.basename(split_src_dst[0]) + if len(split_src_dst) > 1: + dst = split_src_dst[1] + ':z' if len(split_src_dst) == 3 else split_src_dst[1] + mounts[mount] = dst + else: + mounts[mount] = '/mnt/{}:z'.format(filename) if args.command: command = args.command else: @@ -5454,7 +5460,11 @@ def _get_parser(): help='ceph.keyring to pass through to the container') parser_shell.add_argument( '--mount', '-m', - help='mount a file or directory under /mnt in the container') + help=("mount a file or directory in the container. " + "Support multiple mounts. " + "ie: `--mount /foo /bar:/bar`. " + "When no destination is passed, default is /mnt"), + nargs='+') parser_shell.add_argument( '--env', '-e', action='append',