]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: add a get_version to the python interface 13669/head
authorJohn Spray <john.spray@redhat.com>
Mon, 14 Nov 2016 00:03:24 +0000 (00:03 +0000)
committerJohn Spray <john.spray@redhat.com>
Mon, 27 Feb 2017 11:29:43 +0000 (11:29 +0000)
We had the metadata for all the remote services,
but no quick way for the python module to
ask "what version is the process I'm running in?"

Signed-off-by: John Spray <john.spray@redhat.com>
src/mgr/PyState.cc
src/pybind/mgr/mgr_module.py

index 213563667c89e806eaf9395f3bcf821e32363c4b..5a6a2be56ffd759da861b2c5b8254ca479859fb9 100644 (file)
@@ -19,6 +19,7 @@
 #include "Mgr.h"
 
 #include "mon/MonClient.h"
+#include "common/version.h"
 
 #include "PyState.h"
 
@@ -223,6 +224,12 @@ ceph_log(PyObject *self, PyObject *args)
   Py_RETURN_NONE;
 }
 
+static PyObject *
+ceph_get_version(PyObject *self, PyObject *args)
+{
+  return PyString_FromString(pretty_version_to_str().c_str());
+}
+
 static PyObject*
 get_counter(PyObject *self, PyObject *args)
 {
@@ -262,6 +269,8 @@ PyMethodDef CephStateMethods[] = {
       "Get a performance counter"},
     {"log", ceph_log, METH_VARARGS,
      "Emit a (local) log message"},
+    {"get_version", ceph_get_version, METH_VARARGS,
+     "Get the ceph version of this process"},
     {NULL, NULL, 0, NULL}
 };
 
index 3aee169d994b3684dc067b17aed1544aa80f198b..20a893a9e6bb396647f210be8b11e7f36303ddab 100644 (file)
@@ -59,10 +59,16 @@ class MgrModule(object):
 
         self._logger.addHandler(CPlusPlusHandler())
 
+        self._version = ceph_state.get_version()
+
     @property
     def log(self):
         return self._logger
 
+    @property
+    def version(self):
+        return self._version
+
     def notify(self, notify_type, notify_id):
         """
         Called by the ceph-mgr service to notify the Python plugin