1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2016 John Spray <john.spray@redhat.com>
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
17 // Python.h comes first because otherwise it clobbers ceph's assert
20 #include "common/cmdparse.h"
21 #include "common/LogEntry.h"
22 #include "common/Thread.h"
23 #include "mon/health_check.h"
26 #include "PyModuleRunner.h"
34 class ActivePyModules
;
38 class ActivePyModule
: public PyModuleRunner
41 health_check_map_t health_checks
;
43 // Optional, URI exposed by plugins that implement serve()
46 std::string m_command_perms
;
47 const MgrSession
* m_session
= nullptr;
50 ActivePyModule(const PyModuleRef
&py_module_
,
52 : PyModuleRunner(py_module_
, clog_
)
55 int load(ActivePyModules
*py_modules
);
56 void notify(const std::string
¬ify_type
, const std::string
¬ify_id
);
57 void notify_clog(const LogEntry
&le
);
59 bool method_exists(const std::string
&method
) const;
61 PyObject
*dispatch_remote(
62 const std::string
&method
,
68 const ModuleCommand
& module_command
,
69 const MgrSession
& session
,
70 const cmdmap_t
&cmdmap
,
71 const bufferlist
&inbuf
,
72 std::stringstream
*ds
,
73 std::stringstream
*ss
);
76 bool set_health_checks(health_check_map_t
&& c
) {
77 // when health checks change a report is immediately sent to the monitors.
78 // currently modules have static health check details, but this equality
79 // test could be made smarter if too much noise shows up in the future.
80 bool changed
= health_checks
!= c
;
81 health_checks
= std::move(c
);
84 void get_health_checks(health_check_map_t
*checks
);
87 void set_uri(const std::string
&str
)
92 std::string
get_uri() const
97 bool is_authorized(const std::map
<std::string
, std::string
>& arguments
) const;