From 4000d500c0d2c017e7761a5592df1301d7f40538 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 10 Sep 2019 13:53:54 -0500 Subject: [PATCH] pybind/ceph_argparse: disambiguate mgr tell and CLI commands The mgr tell commands are somewhat special in that you can tell the mgr with an empty id ('ceph tell mgr' or target ('mgr', '')) to get the currently active mgr. This makes it hard to disabiguate between a tell command and a CLI command. Fix that by explicitly setting the target to 'mon-mgr' when a CLI command is flagged as a mgr command. Signed-off-by: Sage Weil --- src/pybind/ceph_argparse.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/pybind/ceph_argparse.py b/src/pybind/ceph_argparse.py index f3e3a5b6176..107f4d88fa4 100644 --- a/src/pybind/ceph_argparse.py +++ b/src/pybind/ceph_argparse.py @@ -1109,7 +1109,7 @@ def validate(args, signature, flags=0, partial=False): raise ArgumentError("unused arguments: " + str(myargs)) if flags & Flag.MGR: - d['target'] = ('mgr','') + d['target'] = ('mon-mgr','') if flags & Flag.POLL: d['poll'] = True @@ -1378,8 +1378,8 @@ def send_command(cluster, target=('mon', ''), cmd=None, inbuf=b'', timeout=0, cluster.osd_command, osdid, cmd, inbuf, timeout=timeout) elif target[0] == 'mgr': - name = '' - if len(target) > 1: + name = '' # non-None empty string means "current active mgr" + if len(target) > 1 and target[1] is not None: name = target[1] if verbose: print('submit {0} to {1} name {2}'.format(cmd, target[0], name), @@ -1387,6 +1387,13 @@ def send_command(cluster, target=('mon', ''), cmd=None, inbuf=b'', timeout=0, ret, outbuf, outs = run_in_thread( cluster.mgr_command, cmd, inbuf, timeout=timeout, target=name) + elif target[0] == 'mon-mgr': + if verbose: + print('submit {0} to {1}'.format(cmd, target[0]), + file=sys.stderr) + ret, outbuf, outs = run_in_thread( + cluster.mgr_command, cmd, inbuf, timeout=timeout) + elif target[0] == 'pg': pgid = target[1] # pgid will already be in the command for the pg -- 2.39.5