From: Ricardo Marques Date: Mon, 27 Apr 2020 14:11:56 +0000 (+0100) Subject: cephadm: Add '--mount' option to mount host file or directory X-Git-Tag: v15.2.4~73^2~79 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1838c61dd60f088a8ab4f9b767433b265372fa08;p=ceph.git cephadm: Add '--mount' option to mount host file or directory Fixes: https://tracker.ceph.com/issues/45284 Signed-off-by: Ricardo Marques (cherry picked from commit 71c58f18b5b01e45e7ff1d0a0c086cd682d10307) --- diff --git a/doc/cephadm/install.rst b/doc/cephadm/install.rst index 81779ab64cf0..aa54738a6af7 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 082a2dd3c4d5..934b1f6017d0 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -2785,6 +2785,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: @@ -4309,6 +4315,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',