From 71c58f18b5b01e45e7ff1d0a0c086cd682d10307 Mon Sep 17 00:00:00 2001 From: Ricardo Marques Date: Mon, 27 Apr 2020 15:11:56 +0100 Subject: [PATCH] cephadm: Add '--mount' option to mount host file or directory Fixes: https://tracker.ceph.com/issues/45284 Signed-off-by: Ricardo Marques --- doc/cephadm/install.rst | 6 ++++-- src/cephadm/cephadm | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/doc/cephadm/install.rst b/doc/cephadm/install.rst index 81779ab64cf04..aa54738a6af73 100644 --- a/doc/cephadm/install.rst +++ b/doc/cephadm/install.rst @@ -110,7 +110,7 @@ Enable Ceph CLI =============== Cephadm does not require any Ceph packages to be installed on the -host. However, we recommend enabling easy access to the the ``ceph`` +host. However, we recommend enabling easy access to the ``ceph`` command. There are several ways to do this: * The ``cephadm shell`` command launches a bash shell in a container @@ -119,7 +119,9 @@ command. There are several ways to do this: host, they are passed into the container environment so that the shell is fully functional. Note that when executed on a MON host, ``cephadm shell`` will infer the ``config`` from the MON container - instead of using the default configuration:: + instead of using the default configuration. If ``--mount `` + is given, then the host ```` (file or directory) will appear + under ``/mnt`` inside the container:: # cephadm shell diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index 573aea2065f4b..e0593cda37545 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -2778,6 +2778,12 @@ def command_shell(): mounts[pathify(args.config)] = '/etc/ceph/ceph.conf:z' if args.keyring: mounts[pathify(args.keyring)] = '/etc/ceph/ceph.keyring:z' + if args.mount: + mount = pathify(args.mount) + filename = '' + if os.path.isfile(mount): + _, filename = os.path.split(mount) + mounts[mount] = '/mnt/{}:z'.format(filename) if args.command: command = args.command else: @@ -4301,6 +4307,9 @@ def _get_parser(): parser_shell.add_argument( '--keyring', '-k', help='ceph.keyring to pass through to the container') + parser_shell.add_argument( + '--mount', '-m', + help='file or directory path that will be mounted in container /mnt') parser_shell.add_argument( '--env', '-e', action='append', -- 2.39.5