]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
admin_socket: streamline 'version' commands
authorSage Weil <sage@inktank.com>
Thu, 31 May 2012 03:20:12 +0000 (20:20 -0700)
committerSage Weil <sage@inktank.com>
Thu, 31 May 2012 03:38:38 +0000 (20:38 -0700)
 version     -- ceph version
 git_version -- git sha1
 0           -- proto version (for backward compat)

Signed-off-by: Sage Weil <sage@inktank.com>
src/common/admin_socket.cc

index 526f41eb94cfead838b292d803aa99bce303a2b0..750abaddc137b8961d367c35d289171ab5656822 100644 (file)
@@ -20,6 +20,7 @@
 #include "common/perf_counters.h"
 #include "common/pipe.h"
 #include "common/safe_io.h"
+#include "common/version.h"
 
 #include <errno.h>
 #include <fcntl.h>
@@ -391,7 +392,12 @@ int AdminSocket::unregister_command(std::string command)
 class VersionHook : public AdminSocketHook {
 public:
   virtual bool call(std::string command, bufferlist& out) {
-    out.append(CEPH_ADMIN_SOCK_VERSION);
+    if (command == "version")
+      out.append(ceph_version_to_str());
+    else if (command == "git_version")
+      out.append(git_version_to_str());
+    else if (command == "0")
+      out.append(CEPH_ADMIN_SOCK_VERSION);
     return true;
   }
 };
@@ -452,8 +458,9 @@ bool AdminSocket::init(const std::string &path)
   m_path = path;
 
   m_version_hook = new VersionHook;
-  register_command("version", m_version_hook, "get protocol version");
   register_command("0", m_version_hook, "");
+  register_command("version", m_version_hook, "get ceph version");
+  register_command("git_version", m_version_hook, "get git sha1");
   m_help_hook = new HelpHook(this);
   register_command("help", m_help_hook, "list available commands");
 
@@ -483,6 +490,7 @@ void AdminSocket::shutdown()
   }
 
   unregister_command("version");
+  unregister_command("git_version");
   unregister_command("0");
   delete m_version_hook;
   unregister_command("help");