From 44ef4ba9747f63ce783c8cf1f21e228fe4ef6e4d Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 27 Sep 2019 11:59:03 -0500 Subject: [PATCH] ceph-daemon: add 'shell' command Signed-off-by: Sage Weil --- src/ceph-daemon | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/ceph-daemon b/src/ceph-daemon index dc2ab7113eb..222a8c2176f 100755 --- a/src/ceph-daemon +++ b/src/ceph-daemon @@ -348,6 +348,24 @@ class CephContainer: self.image ] + self.args + def shell_cmd(self): + vols = sum( + [['-v', f'{host_dir}:{container_dir}'] + for host_dir, container_dir in self.volume_mounts.items()], []) + envs = [ + '-e', f'CONTAINER_IMAGE={self.image}', + '-e', f'NODE_NAME={get_hostname()}', + ] + return [ + find_program('podman'), + 'run', + '-it', + '--net=host', + ] + self.podman_args + envs + vols + [ + '--entrypoint', '/bin/bash', + self.image + ] + def run(self): logging.debug(self.run_cmd()) return subprocess.check_output(self.run_cmd()) @@ -510,6 +528,14 @@ def command_run(): ################################## +def command_shell(): + (daemon_type, daemon_id) = args.name.split('.') + (uid, gid) = extract_uid_gid() + c = get_container(args.fsid, daemon_type, daemon_id) + subprocess.call(c.shell_cmd()) + +################################## + def command_ls(): ls = [] @@ -666,6 +692,18 @@ parser_run.add_argument( required=True, help='cluster FSID') +parser_shell = subparsers.add_parser( + 'shell', help='run an interactive shel inside a daemon container') +parser_shell.set_defaults(func=command_shell) +parser_shell.add_argument( + '--fsid', + required=True, + help='cluster FSID') +parser_shell.add_argument( + '--name', '-n', + required=True, + help='daemon name (type.id)') + parser_bootstrap = subparsers.add_parser( 'bootstrap', help='bootstrap a cluster (mon + mgr daemons)') parser_bootstrap.set_defaults(func=command_bootstrap) -- 2.39.5