From: Sage Weil Date: Fri, 5 Jan 2018 19:41:07 +0000 (-0600) Subject: mon/ConfigMonitor: 'config help' X-Git-Tag: v13.0.2~78^2~97 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a1ca906a63a8912fca58d6925005c3cdbf7a1a69;p=ceph.git mon/ConfigMonitor: 'config help' Signed-off-by: Sage Weil --- diff --git a/src/common/options.cc b/src/common/options.cc index 7aef43381660..dac76e12458b 100644 --- a/src/common/options.cc +++ b/src/common/options.cc @@ -232,6 +232,42 @@ ostream& operator<<(ostream& out, const Option::value_t& v) ceph_abort(); } +void Option::print(ostream *out) const +{ + *out << name << " - " << desc << "\n"; + *out << " (" << type_to_str(type) << ", " << level_to_str(level) << ")\n"; + if (!boost::get(&daemon_value)) { + *out << " Default (non-daemon): " << stringify(value) << "\n"; + *out << " Default (daemon): " << stringify(daemon_value) << "\n"; + } else { + *out << " Default: " << stringify(value) << "\n"; + } + if (!enum_allowed.empty()) { + *out << " Possible values: "; + for (auto& i : enum_allowed) { + *out << " " << stringify(i); + } + *out << "\n"; + } + if (!boost::get(&min)) { + *out << " Minimum: " << stringify(min) << "\n" + << " Maximum: " << stringify(max) << "\n"; + } + if (!services.empty()) { + *out << " Services: " << services << "\n"; + } + if (!tags.empty()) { + *out << " Tags: " << tags << "\n"; + } + if (!see_also.empty()) { + *out << " See also: " << see_also << "\n"; + } + + if (long_desc.size()) { + *out << "\n" << long_desc << "\n"; + } +} + constexpr unsigned long long operator"" _min (unsigned long long min) { return min * 60; } diff --git a/src/common/options.h b/src/common/options.h index 4138a6ec076d..ada6d03472e4 100644 --- a/src/common/options.h +++ b/src/common/options.h @@ -276,6 +276,7 @@ struct Option { } void dump(Formatter *f) const; + void print(ostream *out) const; bool has_flag(flag_t f) const { return flags & f; diff --git a/src/mon/ConfigMonitor.cc b/src/mon/ConfigMonitor.cc index f6c492002085..4f3b049d6c79 100644 --- a/src/mon/ConfigMonitor.cc +++ b/src/mon/ConfigMonitor.cc @@ -111,7 +111,24 @@ bool ConfigMonitor::preprocess_command(MonOpRequestRef op) cmd_getval(g_ceph_context, cmdmap, "prefix", prefix); bufferlist odata; - if (prefix == "config dump") { + if (prefix == "config help") { + string name; + cmd_getval(g_ceph_context, cmdmap, "key", name); + const Option *opt = g_conf->find_option(name); + if (!opt) { + ss << "configuration option '" << name << "' not recognized"; + err = -ENOENT; + goto reply; + } + if (f) { + f->dump_object("option", *opt); + f->flush(odata); + } else { + stringstream ss; + opt->print(&ss); + odata.append(ss.str()); + } + } else if (prefix == "config dump") { list> sections = { make_pair("global", &config_map.global) }; diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index a01ca14c2583..ad6048d5d742 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -1110,3 +1110,7 @@ COMMAND("config get " \ COMMAND("config dump", "Show all configuration option(s)", "mon", "r", "cli,rest") +COMMAND("config help " \ + "name=key,type=CephString", + "Describe a configuration option", + "config", "r", "cli,rest")