modules[module_name]->set_uri(uri);
}
+OSDPerfMetricQueryID ActivePyModules::add_osd_perf_query(
+ const OSDPerfMetricQuery &query)
+{
+ return server.add_osd_perf_query(query);
+}
+void ActivePyModules::remove_osd_perf_query(OSDPerfMetricQueryID query_id)
+{
+ int r = server.remove_osd_perf_query(query_id);
+ if (r < 0) {
+ dout(0) << "remove_osd_perf_query for query_id=" << query_id << " failed: "
+ << cpp_strerror(r) << dendl;
+ }
+}
#include "DaemonState.h"
#include "ClusterState.h"
+#include "OSDPerfMetricQuery.h"
class health_check_map_t;
class DaemonServer;
+struct OSDPerfMetricQuery;
class ActivePyModules
{
const std::string &svc_id,
const std::string &path) const;
+ OSDPerfMetricQueryID add_osd_perf_query(const OSDPerfMetricQuery &query);
+ void remove_osd_perf_query(OSDPerfMetricQueryID query_id);
+
bool get_store(const std::string &module_name,
const std::string &key, std::string *val) const;
PyObject *get_store_prefix(const std::string &module_name,
return result;
}
+static PyObject*
+ceph_add_osd_perf_query(BaseMgrModule *self, PyObject *args)
+{
+ // TODO: parse args to build OSDPerfMetricQuery.
+ // For now it is ignored and can be anything.
+ PyObject *query_ = nullptr;
+ if (!PyArg_ParseTuple(args, "O:ceph_add_osd_perf_query", &query_)) {
+ derr << "Invalid args!" << dendl;
+ return nullptr;
+ }
+
+ OSDPerfMetricQuery query;
+ auto query_id = self->py_modules->add_osd_perf_query(query);
+ return PyLong_FromLong(query_id);
+}
+
+static PyObject*
+ceph_remove_osd_perf_query(BaseMgrModule *self, PyObject *args)
+{
+ OSDPerfMetricQueryID query_id;
+ if (!PyArg_ParseTuple(args, "i:ceph_remove_osd_perf_query", &query_id)) {
+ derr << "Invalid args!" << dendl;
+ return nullptr;
+ }
+
+ self->py_modules->remove_osd_perf_query(query_id);
+ Py_RETURN_NONE;
+}
PyMethodDef BaseMgrModule_methods[] = {
{"_ceph_get", (PyCFunction)ceph_state_get, METH_VARARGS,
{"_ceph_dispatch_remote", (PyCFunction)ceph_dispatch_remote,
METH_VARARGS, "Dispatch a call to another module"},
+ {"_ceph_add_osd_perf_query", (PyCFunction)ceph_add_osd_perf_query,
+ METH_VARARGS, "Add an osd perf query"},
+
+ {"_ceph_remove_osd_perf_query", (PyCFunction)ceph_remove_osd_perf_query,
+ METH_VARARGS, "Remove an osd perf query"},
+
{NULL, NULL, 0, NULL}
};
"""
return self._ceph_dispatch_remote(module_name, method_name,
args, kwargs)
+
+ def add_osd_perf_query(self, query):
+ """
+ Fetch the daemon metadata for a particular service.
+
+ :param object query: query
+ :rtype: int (query id)
+ """
+ return self._ceph_add_osd_perf_query(query)
+
+ def remove_osd_perf_query(self, query_id):
+ """
+ Fetch the daemon metadata for a particular service.
+
+ :param int query_id: query ID
+ """
+ return self._ceph_remove_osd_perf_query(query_id)