]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: add osd_perf_query methods to ActivePyModules
authorMykola Golub <mgolub@suse.com>
Thu, 20 Sep 2018 10:10:57 +0000 (13:10 +0300)
committerMykola Golub <mgolub@suse.com>
Wed, 3 Oct 2018 16:29:43 +0000 (19:29 +0300)
Signed-off-by: Mykola Golub <mgolub@suse.com>
src/mgr/ActivePyModules.cc
src/mgr/ActivePyModules.h
src/mgr/BaseMgrModule.cc
src/pybind/mgr/mgr_module.py

index 0ba80c792390438745772e5118022b66aa8c23e8..1c89dcc3188a24cf81536b1c275fb04ca680db83 100644 (file)
@@ -888,4 +888,17 @@ void ActivePyModules::set_uri(const std::string& module_name,
   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;
+  }
+}
index 91fc09697ec9742f7ee9ad877f3d0c3f39c679fc..35476c1bbc801f9b9a39fa9b2b01bdc8eef6fc23 100644 (file)
 
 #include "DaemonState.h"
 #include "ClusterState.h"
+#include "OSDPerfMetricQuery.h"
 
 class health_check_map_t;
 class DaemonServer;
+struct OSDPerfMetricQuery;
 
 class ActivePyModules
 {
@@ -91,6 +93,9 @@ public:
       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,
index 6cc3cda87a566a1602d64759459f5c9578978746..a6fe20d8f3ddbd13c5930228d55e61f1fdc079ed 100644 (file)
@@ -614,6 +614,34 @@ ceph_dispatch_remote(BaseMgrModule *self, PyObject *args)
   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,
@@ -683,6 +711,12 @@ PyMethodDef BaseMgrModule_methods[] = {
   {"_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}
 };
 
index b672b1f23a645a86df98356419e178f08ef7fd17..c920df1a1027fbc7e6221643659a12e4385298b4 100644 (file)
@@ -883,3 +883,20 @@ class MgrModule(ceph_module.BaseMgrModule):
         """
         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)