]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/ConfigMonitor: 'config help'
authorSage Weil <sage@redhat.com>
Fri, 5 Jan 2018 19:41:07 +0000 (13:41 -0600)
committerSage Weil <sage@redhat.com>
Tue, 6 Mar 2018 20:44:48 +0000 (14:44 -0600)
Signed-off-by: Sage Weil <sage@redhat.com>
src/common/options.cc
src/common/options.h
src/mon/ConfigMonitor.cc
src/mon/MonCommands.h

index 7aef433816608b283246f0a2a4d8da76ad8f356c..dac76e12458b9f79f331c73374b2a15e85a98aa6 100644 (file)
@@ -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<boost::blank>(&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<boost::blank>(&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;
 }
index 4138a6ec076d21faca153604df8af1e2861f5ae6..ada6d03472e4bd5df5c50db89c9e6eeccb3d1fae 100644 (file)
@@ -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;
index f6c492002085dc829a0385582fceedff14483b65..4f3b049d6c794091434c83245444c6df7af6b60f 100644 (file)
@@ -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<pair<string,Section*>> sections = {
       make_pair("global", &config_map.global)
     };
index a01ca14c2583f0c10eb0e6735fa9adf198f68e13..ad6048d5d74280cb4f7d3b60e022458f5db51958 100644 (file)
@@ -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")