Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mgr: add a get_version to the python interface #13669

Merged
merged 1 commit into from Feb 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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