From: huanwen ren Date: Tue, 18 Jul 2017 09:17:59 +0000 (+0800) Subject: mds: add to get version in the mds_commands X-Git-Tag: v12.1.2~169^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=378a2cc92bf35276982119f3128652b793c52e73;p=ceph.git mds: add to get version in the mds_commands 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 --- diff --git a/src/mds/MDSDaemon.cc b/src/mds/MDSDaemon.cc index 6f3d34206ac6..6ec8ab471b13 100644 --- a/src/mds/MDSDaemon.cc +++ b/src/mds/MDSDaemon.cc @@ -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 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 argsvec; cmd_getval(cct, cmdmap, "injected_args", argsvec);