]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
ceph: omit hidden commands from suggestions
authorPatrick Donnelly <pdonnell@redhat.com>
Mon, 21 Jan 2019 22:45:07 +0000 (14:45 -0800)
committerPatrick Donnelly <pdonnell@redhat.com>
Wed, 13 Feb 2019 15:58:54 +0000 (07:58 -0800)
Fixes: http://tracker.ceph.com/issues/37955
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
src/ceph.in
src/pybind/ceph_argparse.py

index eff2a59a945cd42a89a22ce12128da5b11b8864e..85e66289dd854688434ace7d4ccb832432deb511 100755 (executable)
@@ -38,13 +38,6 @@ CEPH_RELEASE = "@CEPH_RELEASE@"
 CEPH_RELEASE_NAME = "@CEPH_RELEASE_NAME@"
 CEPH_RELEASE_TYPE = "@CEPH_RELEASE_TYPE@"
 
-# Flags from src/mon/Monitor.h
-FLAG_NOFORWARD = (1 << 0)
-FLAG_OBSOLETE = (1 << 1)
-FLAG_DEPRECATED = (1 << 2)
-FLAG_POLL = (1 << 4)
-FLAG_HIDDEN = (1 << 5)
-
 # priorities from src/common/perf_counters.h
 PRIO_CRITICAL = 10
 PRIO_INTERESTING = 8
@@ -478,7 +471,7 @@ def format_help(cmddict, partial=None):
         if not cmd['help']:
             continue
         flags = cmd.get('flags', 0)
-        if flags & (FLAG_OBSOLETE | FLAG_DEPRECATED | FLAG_HIDDEN):
+        if flags & (argparse.FLAG_OBSOLETE | argparse.FLAG_DEPRECATED | argparse.FLAG_HIDDEN):
             continue
         concise = concise_sig(cmd['sig'])
         if partial and not concise.startswith(partial):
index f0da4ed8fad2b1e3f09eda14614c443d988560da..4f6e1d87f509f5b1841eb53147c8321fc1edd743 100644 (file)
@@ -23,10 +23,13 @@ import sys
 import threading
 import uuid
 
-
 # Flags are from MonCommand.h
-FLAG_MGR = 8   # command is intended for mgr
-FLAG_POLL = 16 # command is intended to be ran continuously by the client
+FLAG_NOFORWARD = (1 << 0)
+FLAG_OBSOLETE = (1 << 1)
+FLAG_DEPRECATED = (1 << 2)
+FLAG_MGR = (1<<3)
+FLAG_POLL = (1 << 4)
+FLAG_HIDDEN = (1 << 5)
 
 KWARG_EQUALS = "--([^=]+)=(.+)"
 KWARG_SPACE = "--([^=]+)"
@@ -1129,6 +1132,9 @@ def validate_command(sigdict, args, verbose=False):
     best_match_cnt = 0
     bestcmds = []
     for cmd in sigdict.values():
+        flags = cmd.get('flags', 0)
+        if flags & FLAG_OBSOLETE:
+            continue
         sig = cmd['sig']
         matched = matchnum(args, sig, partial=True)
         if (matched >= math.floor(best_match_cnt) and
@@ -1193,7 +1199,8 @@ def validate_command(sigdict, args, verbose=False):
             print("Invalid command:", ex, file=sys.stderr)
             print(concise_sig(sig), ': ', cmd['help'], file=sys.stderr)
     else:
-        bestcmds = bestcmds[:10]
+        bestcmds = [c for c in bestcmds if not c.get('flags', 0) & (FLAG_DEPRECATED | FLAG_HIDDEN)]
+        bestcmds = bestcmds[:10] # top 10
         print('no valid command found; {0} closest matches:'.format(len(bestcmds)), file=sys.stderr)
         for cmd in bestcmds:
             print(concise_sig(cmd['sig']), file=sys.stderr)