From 15f404adc3af25e656da5d7e39084836c30aad10 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 26 Jun 2018 07:03:29 -0500 Subject: [PATCH] mon/MonCommands: add HIDDEN flag Hide a command from the CLI and help. Signed-off-by: Sage Weil --- src/mon/MonCommand.h | 5 +++++ src/mon/MonCommands.h | 1 + src/mon/Monitor.cc | 4 +++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/mon/MonCommand.h b/src/mon/MonCommand.h index d4869c56201c3..50ccf2f26503f 100644 --- a/src/mon/MonCommand.h +++ b/src/mon/MonCommand.h @@ -31,6 +31,7 @@ struct MonCommand { static const uint64_t FLAG_DEPRECATED = 1 << 2; static const uint64_t FLAG_MGR = 1 << 3; static const uint64_t FLAG_POLL = 1 << 4; + static const uint64_t FLAG_HIDDEN = 1 << 5; bool has_flag(uint64_t flag) const { return (flags & flag) != 0; } void set_flag(uint64_t flag) { flags |= flag; } @@ -91,6 +92,10 @@ struct MonCommand { return has_flag(MonCommand::FLAG_MGR); } + bool is_hidden() const { + return has_flag(MonCommand::FLAG_HIDDEN); + } + static void encode_array(const MonCommand *cmds, int size, bufferlist &bl) { ENCODE_START(2, 1, bl); uint16_t s = size; diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index 56626085ec267..106d973695db2 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -114,6 +114,7 @@ * MGR - command goes to ceph-mgr (for luminous+) * POLL - command is intended to be called periodically by the * client (see iostat) + * HIDDEN - command is hidden (no reported by help etc) * * A command should always be first considered DEPRECATED before being * considered OBSOLETE, giving due consideration to users and conforming diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index dd9d11ee8f5d2..0d78814e63200 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -2977,7 +2977,9 @@ void Monitor::handle_command(MonOpRequestRef op) paxos_service[PAXOS_MGR].get())->get_command_descs(); for (auto& c : leader_mon_commands) { - commands.push_back(c); + if (!c.is_hidden()) { + commands.push_back(c); + } } format_command_descriptions(commands, f, &rdata); -- 2.39.5