class ActivePyModule;
class ActivePyModules;
-/**
- * A Ceph CLI command description provided from a Python module
- */
-class ModuleCommand {
-public:
- std::string cmdstring;
- std::string helpstring;
- std::string perm;
- ActivePyModule *handler;
-};
-
class ActivePyModule : public PyModuleRunner
{
private:
health_check_map_t health_checks;
- std::vector<ModuleCommand> commands;
-
- int load_commands();
-
// Optional, URI exposed by plugins that implement serve()
std::string uri;
public:
- ActivePyModule(const std::string &module_name_,
- PyObject *pClass_,
- const SafeThreadState &my_ts_,
+ ActivePyModule(const PyModuleRef &py_module_,
LogChannelRef clog_)
- : PyModuleRunner(module_name_, pClass_, my_ts_, clog_)
+ : PyModuleRunner(py_module_, clog_)
{}
int load(ActivePyModules *py_modules);
void notify(const std::string ¬ify_type, const std::string ¬ify_id);
void notify_clog(const LogEntry &le);
- const std::vector<ModuleCommand> &get_commands() const
- {
- return commands;
- }
+ bool method_exists(const std::string &method) const;
+
+ PyObject *dispatch_remote(
+ const std::string &method,
+ PyObject *args,
+ PyObject *kwargs,
+ std::string *err);
int handle_command(
const cmdmap_t &cmdmap,
+ const bufferlist &inbuf,
std::stringstream *ds,
std::stringstream *ss);
- void set_health_checks(health_check_map_t&& c) {
+
+ bool set_health_checks(health_check_map_t&& c) {
+ // when health checks change a report is immediately sent to the monitors.
+ // currently modules have static health check details, but this equality
+ // test could be made smarter if too much noise shows up in the future.
+ bool changed = health_checks != c;
health_checks = std::move(c);
+ return changed;
}
void get_health_checks(health_check_map_t *checks);
+ void config_notify();
void set_uri(const std::string &str)
{