summaryrefslogtreecommitdiffstats
path: root/src/mgr
diff options
context:
space:
mode:
authorSage Weil <sage@redhat.com>2020-03-11 18:14:59 +0100
committerSage Weil <sage@redhat.com>2020-03-12 04:42:23 +0100
commit3eeaefddb98b76e319b47891d6cb41cff48cccff (patch)
treed6571b466c361becf8d5dca1da937c716f688cb2 /src/mgr
parentRevert "pybind/mgr/mgr_module: fix standby module logging options" (diff)
downloadceph-3eeaefddb98b76e319b47891d6cb41cff48cccff.tar.xz
ceph-3eeaefddb98b76e319b47891d6cb41cff48cccff.zip
mgr/PyModule: initialize options on standby class too
Create a separate callback (_register_options) and call that on both the regular MgrModule and MgrStandbyModule. Fixes: https://tracker.ceph.com/issues/44562 Signed-off-by: Sage Weil <sage@redhat.com>
Diffstat (limited to 'src/mgr')
-rw-r--r--src/mgr/PyModule.cc18
-rw-r--r--src/mgr/PyModule.h1
2 files changed, 19 insertions, 0 deletions
diff --git a/src/mgr/PyModule.cc b/src/mgr/PyModule.cc
index 004325a3c6f..016a6cf7df5 100644
--- a/src/mgr/PyModule.cc
+++ b/src/mgr/PyModule.cc
@@ -371,6 +371,7 @@ int PyModule::load(PyThreadState *pMainThreadState)
return r;
}
+ register_options(pClass);
r = load_options();
if (r != 0) {
derr << "Missing or invalid MODULE_OPTIONS attribute in module '"
@@ -388,6 +389,7 @@ int PyModule::load(PyThreadState *pMainThreadState)
if (!r) {
dout(4) << "Standby mode available in module '" << module_name
<< "'" << dendl;
+ register_options(pStandbyClass);
} else {
dout(4) << "Standby mode not provided by module '" << module_name
<< "'" << dendl;
@@ -473,6 +475,22 @@ int PyModule::walk_dict_list(
return r;
}
+int PyModule::register_options(PyObject *cls)
+{
+ PyObject *pRegCmd = PyObject_CallMethod(
+ cls,
+ const_cast<char*>("_register_options"), const_cast<char*>("(s)"),
+ module_name.c_str());
+ if (pRegCmd != nullptr) {
+ Py_DECREF(pRegCmd);
+ } else {
+ derr << "Exception calling _register_options on " << get_name()
+ << dendl;
+ derr << handle_pyerror() << dendl;
+ }
+ return 0;
+}
+
int PyModule::load_commands()
{
PyObject *pRegCmd = PyObject_CallMethod(pClass,
diff --git a/src/mgr/PyModule.h b/src/mgr/PyModule.h
index 2f980bdf509..6d555a81a2d 100644
--- a/src/mgr/PyModule.h
+++ b/src/mgr/PyModule.h
@@ -81,6 +81,7 @@ private:
int load_commands();
std::vector<ModuleCommand> commands;
+ int register_options(PyObject *cls);
int load_options();
std::map<std::string, MgrMap::ModuleOption> options;