return remoteResult;
}
-
+void ActivePyModule::config_notify()
+{
+ Gil gil(py_module->pMyThreadState, true);
+ dout(20) << "Calling " << py_module->get_name() << ".config_notify..."
+ << dendl;
+ auto remoteResult = PyObject_CallMethod(pClassInstance, "config_notify",
+ (char*)NULL);
+ if (remoteResult != nullptr) {
+ Py_DECREF(remoteResult);
+ }
+}
int ActivePyModule::handle_command(
const cmdmap_t &cmdmap,
return changed;
}
void get_health_checks(health_check_map_t *checks);
+ void config_notify();
void set_uri(const std::string &str)
{
}
}
+void ActivePyModules::config_notify()
+{
+ std::lock_guard l(lock);
+ for (auto& i : modules) {
+ auto module = i.second.get();
+ // Send all python calls down a Finisher to avoid blocking
+ // C++ code, and avoid any potential lock cycles.
+ finisher.queue(new FunctionContext([module](int r){
+ module->config_notify();
+ }));
+ }
+}
+
void ActivePyModules::set_uri(const std::string& module_name,
const std::string &uri)
{
health_check_map_t&& checks);
void get_health_checks(health_check_map_t *checks);
+ void config_notify();
+
void set_uri(const std::string& module_name, const std::string &uri);
int handle_command(
}
return false;
});
+ monc.register_config_notify_callback([this]() {
+ py_module_registry.handle_config_notify();
+ });
dout(4) << "Registered monc callback" << dendl;
int r = monc.init();
}
}
+void PyModuleRegistry::handle_config_notify()
+{
+ std::lock_guard l(lock);
+ if (active_modules) {
+ active_modules->config_notify();
+ }
+}
+
void PyModuleRegistry::upgrade_config(
MonClient *monc,
const std::map<std::string, std::string> &old_config)
public:
void handle_config(const std::string &k, const std::string &v);
+ void handle_config_notify();
/**
* Get references to all modules (whether they have loaded and/or
"""
pass
+ def config_notify(self):
+ """
+ Called by the ceph-mgr service to notify the Python plugin
+ that the configuration may have changed. Modules will want to
+ refresh any configuration values stored in config variables.
+ """
+ pass
+
def serve(self):
"""
Called by the ceph-mgr service to start any server that