summaryrefslogtreecommitdiffstats
path: root/src/ceph-daemon
diff options
context:
space:
mode:
authorSage Weil <sage@redhat.com>2019-10-23 18:05:00 +0200
committerSage Weil <sage@redhat.com>2019-10-23 22:08:55 +0200
commit75c1ebe606e15eceb105bec70ca14fd49a38b9a5 (patch)
tree5dcc778dc6ddae0479f03fb4b219119adc800325 /src/ceph-daemon
parentqa/suites/rados/singleton-nomsgr/ceph-daemon: run test_ceph_daemon.sh (diff)
downloadceph-75c1ebe606e15eceb105bec70ca14fd49a38b9a5.tar.xz
ceph-75c1ebe606e15eceb105bec70ca14fd49a38b9a5.zip
ceph-daemon: allow shell to take optional command
This is different from 'exec' in that it creates a new container instead of entering an existing one. Signed-off-by: Sage Weil <sage@redhat.com>
Diffstat (limited to '')
-rwxr-xr-xsrc/ceph-daemon15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/ceph-daemon b/src/ceph-daemon
index c6b1ad183af..0f1a722a560 100755
--- a/src/ceph-daemon
+++ b/src/ceph-daemon
@@ -654,7 +654,7 @@ class CephContainer:
self.image
] + self.args
- def shell_cmd(self):
+ def shell_cmd(self, cmd):
vols = sum(
[['-v', f'{host_dir}:{container_dir}']
for host_dir, container_dir in self.volume_mounts.items()], [])
@@ -662,6 +662,9 @@ class CephContainer:
'-e', f'CONTAINER_IMAGE={self.image}',
'-e', f'NODE_NAME={get_hostname()}',
]
+ cmd_args = []
+ if cmd:
+ cmd_args = ['-c'] + cmd
return [
podman_path,
'run',
@@ -670,9 +673,9 @@ class CephContainer:
'--privileged',
'--env', 'LANG=C',
] + self.podman_args + envs + vols + [
- '--entrypoint', '/bin/bash',
+ '--entrypoint', cmd[0],
self.image
- ]
+ ] + cmd[1:]
def exec_cmd(self, cmd):
return [
@@ -1094,7 +1097,7 @@ def command_shell():
args=[],
podman_args=['--privileged'],
volume_mounts=mounts)
- subprocess.call(c.shell_cmd())
+ subprocess.call(c.shell_cmd(args.command))
##################################
@@ -1438,6 +1441,10 @@ parser_shell.add_argument(
parser_shell.add_argument(
'--keyring', '-k',
help='ceph.keyring to pass through to the container')
+parser_shell.add_argument(
+ 'command', nargs='*',
+ default=['bash'],
+ help='command (optional)')
parser_enter = subparsers.add_parser(
'enter', help='run an interactive shell inside a running daemon container')