]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: add to get version in the mds_commands
authorhuanwen ren <ren.huanwen@zte.com.cn>
Tue, 18 Jul 2017 09:17:59 +0000 (17:17 +0800)
committerhuanwen ren <ren.huanwen@zte.com.cn>
Tue, 18 Jul 2017 11:48:43 +0000 (19:48 +0800)
Sometime we need to determine whether the mds/mon/osd RPM package
is correct, by use the command "ceph tell mds/mon/osd.* version"
is good way.but mds does not support, so I add it.

Signed-off-by: huanwen ren <ren.huanwen@zte.com.cn>
src/mds/MDSDaemon.cc

index 6f3d34206ac6b3b859a044550ace622fd1f50763..6ec8ab471b1369e6ceb9d49df61a377ff46e1363 100644 (file)
@@ -24,6 +24,7 @@
 #include "common/signal.h"
 #include "common/ceph_argparse.h"
 #include "common/errno.h"
+#include "common/version.h"
 
 #include "msg/Messenger.h"
 #include "mon/MonClient.h"
@@ -674,6 +675,7 @@ COMMAND("damage ls",
        "List detected metadata damage", "mds", "r", "cli,rest")
 COMMAND("damage rm name=damage_id,type=CephInt",
        "Remove a damage table entry", "mds", "rw", "cli,rest")
+COMMAND("version", "report version of MDS", "mds", "r", "cli,rest")
 COMMAND("heap " \
        "name=heapcmd,type=CephChoices,strings=dump|start_profiler|stop_profiler|release|stats", \
        "show heap usage info (available only if compiled with tcmalloc)", \
@@ -727,6 +729,8 @@ int MDSDaemon::_handle_command(
   std::stringstream ds;
   std::stringstream ss;
   std::string prefix;
+  std::string format;
+  boost::scoped_ptr<Formatter> f;
   cmd_getval(cct, cmdmap, "prefix", prefix);
 
   int r = 0;
@@ -748,6 +752,20 @@ int MDSDaemon::_handle_command(
 
     f->flush(ds);
     delete f;
+    goto out; 
+  }
+  
+  cmd_getval(cct, cmdmap, "format", format);
+  f.reset(Formatter::create(format));
+  if (prefix == "version") {
+    if (f) {
+      f->open_object_section("version");
+      f->dump_string("version", pretty_version_to_str());
+      f->close_section();
+      f->flush(ds);
+    } else {
+      ds << pretty_version_to_str();
+    }
   } else if (prefix == "injectargs") {
     vector<string> argsvec;
     cmd_getval(cct, cmdmap, "injected_args", argsvec);