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 <pdonnell@redhat.com>
This commit is contained in:
Patrick Donnelly 2016-10-11 13:53:16 -04:00
parent a39c3e8438
commit 61d63433df
No known key found for this signature in database
GPG Key ID: 3A2A7E25BEA8AADB
7 changed files with 17 additions and 8 deletions

View File

@ -33,6 +33,11 @@ except NameError:
CEPH_GIT_VER="@CEPH_GIT_VER@" CEPH_GIT_VER="@CEPH_GIT_VER@"
CEPH_GIT_NICE_VER="@CEPH_GIT_NICE_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: # Make life easier on developers:
# If in src/, and .libs and pybind exist here, assume we're running # 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 # 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']: if not cmd['help']:
continue continue
if cmd['flags'] is not None and ((cmd['flags'] & (FLAG_OBSOLETE | FLAG_DEPRECATED)) != 0):
continue
concise = concise_sig(cmd['sig']) concise = concise_sig(cmd['sig'])
if partial and not concise.startswith(partial): if partial and not concise.startswith(partial):
continue continue

View File

@ -123,7 +123,8 @@ dump_cmddesc_to_json(Formatter *jf,
const string& helptext, const string& helptext,
const string& module, const string& module,
const string& perm, const string& perm,
const string& avail) const string& avail,
uint64_t flags)
{ {
jf->open_object_section(secname.c_str()); jf->open_object_section(secname.c_str());
jf->open_array_section("sig"); 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("module", module.c_str());
jf->dump_string("perm", perm.c_str()); jf->dump_string("perm", perm.c_str());
jf->dump_string("avail", avail.c_str()); jf->dump_string("avail", avail.c_str());
jf->dump_int("flags", flags);
jf->close_section(); // cmd jf->close_section(); // cmd
} }
void cmdmap_dump(const cmdmap_t &cmdmap, Formatter *f) void cmdmap_dump(const cmdmap_t &cmdmap, Formatter *f)
{ {
assert(f != nullptr); assert(f != nullptr);

View File

@ -37,7 +37,8 @@ void dump_cmddesc_to_json(ceph::Formatter *jf,
const std::string& helptext, const std::string& helptext,
const std::string& module, const std::string& module,
const std::string& perm, const std::string& perm,
const std::string& avail); const std::string& avail,
uint64_t flags);
bool cmdmap_from_json(std::vector<std::string> cmd, cmdmap_t *mapp, bool cmdmap_from_json(std::vector<std::string> cmd, cmdmap_t *mapp,
std::stringstream &ss); std::stringstream &ss);
void cmdmap_dump(const cmdmap_t &cmdmap, ceph::Formatter *f); void cmdmap_dump(const cmdmap_t &cmdmap, ceph::Formatter *f);

View File

@ -760,7 +760,7 @@ int MDSDaemon::_handle_command(
ostringstream secname; ostringstream secname;
secname << "cmd" << setfill('0') << std::setw(3) << cmdnum; secname << "cmd" << setfill('0') << std::setw(3) << cmdnum;
dump_cmddesc_to_json(f, secname.str(), cp->cmdstring, cp->helpstring, 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++; cmdnum++;
} }
f->close_section(); // command_descriptions f->close_section(); // command_descriptions

View File

@ -263,7 +263,7 @@ bool DaemonServer::handle_command(MCommand *m)
dout(20) << "Dumping " << pyc.cmdstring << " (" << pyc.helpstring dout(20) << "Dumping " << pyc.cmdstring << " (" << pyc.helpstring
<< ")" << dendl; << ")" << dendl;
dump_cmddesc_to_json(&f, secname.str(), pyc.cmdstring, pyc.helpstring, dump_cmddesc_to_json(&f, secname.str(), pyc.cmdstring, pyc.helpstring,
"mgr", pyc.perm, "cli"); "mgr", pyc.perm, "cli", 0);
cmdnum++; cmdnum++;
} }
#if 0 #if 0
@ -273,7 +273,7 @@ bool DaemonServer::handle_command(MCommand *m)
ostringstream secname; ostringstream secname;
secname << "cmd" << setfill('0') << std::setw(3) << cmdnum; secname << "cmd" << setfill('0') << std::setw(3) << cmdnum;
dump_cmddesc_to_json(f, secname.str(), cp->cmdstring, cp->helpstring, 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++; cmdnum++;
} }
#endif #endif

View File

@ -2559,7 +2559,7 @@ void Monitor::format_command_descriptions(const MonCommand *commands,
secname << "cmd" << setfill('0') << std::setw(3) << cmdnum; secname << "cmd" << setfill('0') << std::setw(3) << cmdnum;
dump_cmddesc_to_json(f, secname.str(), dump_cmddesc_to_json(f, secname.str(),
cp->cmdstring, cp->helpstring, cp->module, cp->cmdstring, cp->helpstring, cp->module,
cp->req_perms, cp->availability); cp->req_perms, cp->availability, cp->flags);
cmdnum++; cmdnum++;
} }
f->close_section(); // command_descriptions f->close_section(); // command_descriptions

View File

@ -5466,7 +5466,7 @@ void OSD::do_command(Connection *con, ceph_tid_t tid, vector<string>& cmd, buffe
ostringstream secname; ostringstream secname;
secname << "cmd" << setfill('0') << std::setw(3) << cmdnum; secname << "cmd" << setfill('0') << std::setw(3) << cmdnum;
dump_cmddesc_to_json(f, secname.str(), cp->cmdstring, cp->helpstring, 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++; cmdnum++;
} }
f->close_section(); // command_descriptions f->close_section(); // command_descriptions