]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: add a --dry-run option to cephadm shell
authorJohn Mulligan <jmulligan@redhat.com>
Wed, 11 Oct 2023 18:05:17 +0000 (14:05 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Tue, 24 Oct 2023 17:58:59 +0000 (13:58 -0400)
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 <jmulligan@redhat.com>
src/cephadm/cephadm.py

index a64b0b49404dd8e9ebb453d946a0a8013c15ef56..04104c846b852fff1d62f65480d190dd09c747ec 100755 (executable)
@@ -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')