#include "BaseMgrStandbyModule.h"
#include "StandbyPyModules.h"
+#include "PyFormatter.h"
#define dout_context g_ceph_context
Py_RETURN_NONE;
}
+static PyObject*
+ceph_standby_state_get(BaseMgrStandbyModule *self, PyObject *args)
+{
+ char *whatc = NULL;
+ if (!PyArg_ParseTuple(args, "s:ceph_state_get", &whatc)) {
+ return NULL;
+ }
+ std::string what(whatc);
+
+ PyFormatter f;
+
+ // Drop the GIL, as most of the following blocks will block on
+ // a mutex -- they are all responsible for re-taking the GIL before
+ // touching the PyFormatter instance or returning from the function.
+ without_gil_t no_gil;
+
+ if (what == "mgr_ips") {
+ entity_addrvec_t myaddrs = self->this_module->get_myaddrs();
+ with_gil_t with_gil{no_gil};
+ f.open_array_section("ips");
+ std::set<std::string> did;
+ for (auto& i : myaddrs.v) {
+ std::string ip = i.ip_only_to_str();
+ if (auto [where, inserted] = did.insert(ip); inserted) {
+ f.dump_string("ip", ip);
+ }
+ }
+ f.close_section();
+ return f.get();
+ } else {
+ derr << "Python module requested unknown data '" << what << "'" << dendl;
+ with_gil_t with_gil{no_gil};
+ Py_RETURN_NONE;
+ }
+}
+
+
PyMethodDef BaseMgrStandbyModule_methods[] = {
+ {"_ceph_get", (PyCFunction)ceph_standby_state_get, METH_VARARGS,
+ "Get a cluster object (standby)"},
{"_ceph_get_mgr_id", (PyCFunction)ceph_get_mgr_id, METH_NOARGS,
"Get the name of the Mgr daemon where we are running"},
bool get_config(const std::string &key, std::string *value) const;
bool get_store(const std::string &key, std::string *value) const;
std::string get_active_uri() const;
+ entity_addrvec_t get_myaddrs() const {
+ return state.get_monc().get_myaddrs();
+ }
int load();
};
class BaseMgrStandbyModule(object):
def __init__(self, capsule): pass
+ def _ceph_get(self, data_name: str) -> Dict[str, Any]: ...
def _ceph_get_mgr_id(self):...
def _ceph_get_module_option(self, key, prefix=None):...
def _ceph_get_option(self, key):...
def get_active_uri(self) -> str:
return self._ceph_get_active_uri()
+ def get(self, data_name: str):
+ return self._ceph_get(data_name)
+
def get_mgr_ip(self) -> str:
# we don't have get() for standby modules; make do with the hostname
return socket.gethostname()