]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/DaemonServer: 'config show <who>'
authorSage Weil <sage@redhat.com>
Mon, 4 Dec 2017 22:52:00 +0000 (16:52 -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/mgr/DaemonServer.cc
src/mgr/MgrCommands.h

index 165e4e86ad5660327d3492c4c07dfdd7fb686055..f57933deb04a968745e6ea52917254da5ddf826b 100644 (file)
@@ -1342,7 +1342,78 @@ bool DaemonServer::handle_command(MCommand *m)
     ss << std::endl;
     cmdctx->reply(r, ss);
     return true;
+  } else if (prefix == "config show") {
+    string who;
+    cmd_getval(g_ceph_context, cmdctx->cmdmap, "who", who);
+    int r = 0;
+    auto dot = who.find('.');
+    DaemonKey key;
+    key.first = who.substr(0, dot);
+    key.second = who.substr(dot + 1);
+    DaemonStatePtr daemon = daemon_state.get(key);
+    if (daemon) {
+      Mutex::Locker l(daemon->lock);
+      if (f) {
+       f->open_array_section("config");
+       for (auto& i : daemon->config) {
+         dout(20) << " " << i.first << " -> " << i.second << dendl;
+         if (i.second.empty()) {
+           continue;
+         }
+         f->open_object_section("value");
+         f->dump_string("name", i.first);
+         f->dump_string("value", i.second.rbegin()->second);
+         f->dump_string("source", ceph_conf_level_name(
+                          i.second.rbegin()->first));
+         if (i.second.size() > 1) {
+           f->open_array_section("overrides");
+           auto j = i.second.rend();
+           for (--j; j != i.second.rbegin(); --j) {
+             f->open_object_section("value");
+             f->dump_string("source", ceph_conf_level_name(j->first));
+             f->dump_string("value", j->second);
+             f->close_section();
+           }
+           f->close_section();
+         }
+         f->close_section();
+       }
+       f->close_section();
+       f->flush(cmdctx->odata);
+      } else {
+       TextTable tbl;
+       tbl.define_column("NAME", TextTable::LEFT, TextTable::LEFT);
+       tbl.define_column("VALUE", TextTable::LEFT, TextTable::LEFT);
+       tbl.define_column("SOURCE", TextTable::LEFT, TextTable::LEFT);
+       tbl.define_column("OVERRIDES", TextTable::LEFT, TextTable::LEFT);
+       for (auto& i : daemon->config) {
+         if (i.second.empty()) {
+           continue;
+         }
+         dout(20) << " " << i.first << " -> " << i.second << dendl;
+         tbl << i.first;
+         tbl << i.second.rbegin()->second;
+         tbl << ceph_conf_level_name(i.second.rbegin()->first);
+         if (i.second.size() > 1) {
+           list<string> ov;
+           auto j = i.second.rend();
+           for (--j; j != i.second.rbegin(); --j) {
+             ov.push_front(ceph_conf_level_name(j->first));
+           }
+           tbl << ov;
+         }
+         tbl << TextTable::endrow;
+       }
+       cmdctx->odata.append(stringify(tbl));
+      }
+    } else {
+      ss << "no state for daemon " << who;
+      r = -ENOENT;
+    }
+    cmdctx->reply(r, ss);
+    return true;
   } else {
+    // fall back to feeding command to PGMap
     r = cluster_state.with_pgmap([&](const PGMap& pg_map) {
        return cluster_state.with_osdmap([&](const OSDMap& osdmap) {
            return process_pg_map_command(prefix, cmdctx->cmdmap, pg_map, osdmap,
index 79766fafed93acdc1a36b6edb710ece131a3526a..29f0197b221177d5cce7f5ced2fba6f4dad41c3d 100644 (file)
@@ -136,3 +136,8 @@ COMMAND("config set " \
        "name=key,type=CephString name=value,type=CephString",
        "Set a configuration option at runtime (not persistent)",
        "mgr", "rw", "cli,rest")
+
+COMMAND("config show " \
+       "name=who,type=CephString",
+       "Show running configuration",
+       "mgr", "r", "cli,rest")