]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
pybind/ceph_argparse: disambiguate mgr tell and CLI commands
authorSage Weil <sage@redhat.com>
Tue, 10 Sep 2019 18:53:54 +0000 (13:53 -0500)
committerSage Weil <sage@redhat.com>
Tue, 1 Oct 2019 21:30:53 +0000 (16:30 -0500)
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 <sage@redhat.com>
src/pybind/ceph_argparse.py

index f3e3a5b6176ed5db6bf91c7a7da0444e4280b5d0..107f4d88fa4826f204bb0948a5e5b9ee8814959e 100644 (file)
@@ -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 <pgid>