Skip to content

Commit

Permalink
Merge pull request #13669 from jcsp/wip-mgr-get-version
Browse files Browse the repository at this point in the history
mgr: add a get_version to the python interface

Reviewed-by: Kefu Chai <kchai@redhat.com>
  • Loading branch information
tchaikov committed Feb 28, 2017
2 parents ef6de18 + 5124e4d commit 15cbb98
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/mgr/PyState.cc
Expand Up @@ -19,6 +19,7 @@
#include "Mgr.h"

#include "mon/MonClient.h"
#include "common/version.h"

#include "PyState.h"

Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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}
};

6 changes: 6 additions & 0 deletions src/pybind/mgr/mgr_module.py
Expand Up @@ -59,10 +59,16 @@ def emit(self, record):

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
Expand Down

0 comments on commit 15cbb98

Please sign in to comment.