From: Patrick Donnelly Date: Tue, 11 Oct 2016 17:53:16 +0000 (-0400) Subject: mon: omit deprecated commands in desc X-Git-Tag: v11.1.0~593^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=61d63433dfdcc08ecc21ba4f645794da5e01823c;p=ceph.git mon: omit deprecated commands in desc This is useful for filtering out deprecated commands in help output. For example, `ceph mds -h` no longer lists commands like `mds set_max_mds`. Signed-off-by: Patrick Donnelly --- diff --git a/src/ceph.in b/src/ceph.in index 5ea0876d7f0..a32d42c8e9c 100755 --- a/src/ceph.in +++ b/src/ceph.in @@ -33,6 +33,11 @@ except NameError: CEPH_GIT_VER="@CEPH_GIT_VER@" CEPH_GIT_NICE_VER="@CEPH_GIT_NICE_VER@" +# Flags from src/mon/Monitor.h +FLAG_NOFORWARD = (1 << 0) +FLAG_OBSOLETE = (1 << 1) +FLAG_DEPRECATED = (1 << 2) + # Make life easier on developers: # If in src/, and .libs and pybind exist here, assume we're running # from a Ceph source dir and tweak PYTHONPATH and LD_LIBRARY_PATH @@ -337,6 +342,8 @@ def format_help(cmddict, partial=None): if not cmd['help']: continue + if cmd['flags'] is not None and ((cmd['flags'] & (FLAG_OBSOLETE | FLAG_DEPRECATED)) != 0): + continue concise = concise_sig(cmd['sig']) if partial and not concise.startswith(partial): continue diff --git a/src/common/cmdparse.cc b/src/common/cmdparse.cc index ea8b8fe5ce6..51e67e38996 100644 --- a/src/common/cmdparse.cc +++ b/src/common/cmdparse.cc @@ -123,7 +123,8 @@ dump_cmddesc_to_json(Formatter *jf, const string& helptext, const string& module, const string& perm, - const string& avail) + const string& avail, + uint64_t flags) { jf->open_object_section(secname.c_str()); jf->open_array_section("sig"); @@ -133,10 +134,10 @@ dump_cmddesc_to_json(Formatter *jf, jf->dump_string("module", module.c_str()); jf->dump_string("perm", perm.c_str()); jf->dump_string("avail", avail.c_str()); + jf->dump_int("flags", flags); jf->close_section(); // cmd } - void cmdmap_dump(const cmdmap_t &cmdmap, Formatter *f) { assert(f != nullptr); diff --git a/src/common/cmdparse.h b/src/common/cmdparse.h index b13bfbde7b6..104848dc263 100644 --- a/src/common/cmdparse.h +++ b/src/common/cmdparse.h @@ -37,7 +37,8 @@ void dump_cmddesc_to_json(ceph::Formatter *jf, const std::string& helptext, const std::string& module, const std::string& perm, - const std::string& avail); + const std::string& avail, + uint64_t flags); bool cmdmap_from_json(std::vector cmd, cmdmap_t *mapp, std::stringstream &ss); void cmdmap_dump(const cmdmap_t &cmdmap, ceph::Formatter *f); diff --git a/src/mds/MDSDaemon.cc b/src/mds/MDSDaemon.cc index e539fc57eb9..07701ddf59b 100644 --- a/src/mds/MDSDaemon.cc +++ b/src/mds/MDSDaemon.cc @@ -760,7 +760,7 @@ int MDSDaemon::_handle_command( ostringstream secname; secname << "cmd" << setfill('0') << std::setw(3) << cmdnum; dump_cmddesc_to_json(f, secname.str(), cp->cmdstring, cp->helpstring, - cp->module, cp->perm, cp->availability); + cp->module, cp->perm, cp->availability, 0); cmdnum++; } f->close_section(); // command_descriptions diff --git a/src/mgr/DaemonServer.cc b/src/mgr/DaemonServer.cc index 31f0ce999d3..53740868dc5 100644 --- a/src/mgr/DaemonServer.cc +++ b/src/mgr/DaemonServer.cc @@ -263,7 +263,7 @@ bool DaemonServer::handle_command(MCommand *m) dout(20) << "Dumping " << pyc.cmdstring << " (" << pyc.helpstring << ")" << dendl; dump_cmddesc_to_json(&f, secname.str(), pyc.cmdstring, pyc.helpstring, - "mgr", pyc.perm, "cli"); + "mgr", pyc.perm, "cli", 0); cmdnum++; } #if 0 @@ -273,7 +273,7 @@ bool DaemonServer::handle_command(MCommand *m) ostringstream secname; secname << "cmd" << setfill('0') << std::setw(3) << cmdnum; dump_cmddesc_to_json(f, secname.str(), cp->cmdstring, cp->helpstring, - cp->module, cp->perm, cp->availability); + cp->module, cp->perm, cp->availability, 0); cmdnum++; } #endif diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 4a0c1ac3dfa..6a056c5104f 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -2559,7 +2559,7 @@ void Monitor::format_command_descriptions(const MonCommand *commands, secname << "cmd" << setfill('0') << std::setw(3) << cmdnum; dump_cmddesc_to_json(f, secname.str(), cp->cmdstring, cp->helpstring, cp->module, - cp->req_perms, cp->availability); + cp->req_perms, cp->availability, cp->flags); cmdnum++; } f->close_section(); // command_descriptions diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index bcdce403ac2..af3436e051f 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -5466,7 +5466,7 @@ void OSD::do_command(Connection *con, ceph_tid_t tid, vector& cmd, buffe ostringstream secname; secname << "cmd" << setfill('0') << std::setw(3) << cmdnum; dump_cmddesc_to_json(f, secname.str(), cp->cmdstring, cp->helpstring, - cp->module, cp->perm, cp->availability); + cp->module, cp->perm, cp->availability, 0); cmdnum++; } f->close_section(); // command_descriptions