From: John Mulligan Date: Wed, 11 Oct 2023 18:05:17 +0000 (-0400) Subject: cephadm: add a --dry-run option to cephadm shell X-Git-Tag: v19.0.0~240^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=db1e785b2c1a55f4d232b1642573e5672a136190;p=ceph.git cephadm: add a --dry-run option to cephadm shell Instead of creating the shell, the --dry-run option prints the container command that would be used. This can be used as a starting point for creating custom container commands similar to what cephadm shell would generate but with tweaks. Signed-off-by: John Mulligan --- diff --git a/src/cephadm/cephadm.py b/src/cephadm/cephadm.py index a64b0b49404d..04104c846b85 100755 --- a/src/cephadm/cephadm.py +++ b/src/cephadm/cephadm.py @@ -5417,6 +5417,10 @@ def command_shell(ctx): privileged=True) command = c.shell_cmd(command) + if ctx.dry_run: + print(' '.join(shlex.quote(arg) for arg in command)) + return 0 + return call_timeout(ctx, command, ctx.timeout) ################################## @@ -7165,6 +7169,10 @@ def _get_parser(): '--no-hosts', action='store_true', help='dont pass /etc/hosts through to the container') + parser_shell.add_argument( + '--dry-run', + action='store_true', + help='print, but do not execute, the container command to start the shell') parser_enter = subparsers.add_parser( 'enter', help='run an interactive shell inside a running daemon container')