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 "common/Finisher.h"
24 #include "mon/health_check.h"
27 #include "PyModuleRunner.h"
35 class ActivePyModules
;
39 class ActivePyModule
: public PyModuleRunner
42 health_check_map_t health_checks
;
44 // Optional, URI exposed by plugins that implement serve()
47 std::string m_command_perms
;
48 const MgrSession
* m_session
= nullptr;
49 std::string fin_thread_name
;
51 Finisher finisher
; // per active module finisher to execute commands
54 ActivePyModule(const PyModuleRef
&py_module_
,
56 : PyModuleRunner(py_module_
, clog_
),
57 fin_thread_name(std::string("m-fin-" + py_module
->get_name()).substr(0,15)),
58 finisher(g_ceph_context
, thread_name
, fin_thread_name
)
63 int load(ActivePyModules
*py_modules
);
64 void notify(const std::string
¬ify_type
, const std::string
¬ify_id
);
65 void notify_clog(const LogEntry
&le
);
67 bool method_exists(const std::string
&method
) const;
69 PyObject
*dispatch_remote(
70 const std::string
&method
,
76 const ModuleCommand
& module_command
,
77 const MgrSession
& session
,
78 const cmdmap_t
&cmdmap
,
79 const bufferlist
&inbuf
,
80 std::stringstream
*ds
,
81 std::stringstream
*ss
);
84 bool set_health_checks(health_check_map_t
&& c
) {
85 // when health checks change a report is immediately sent to the monitors.
86 // currently modules have static health check details, but this equality
87 // test could be made smarter if too much noise shows up in the future.
88 bool changed
= health_checks
!= c
;
89 health_checks
= std::move(c
);
92 void get_health_checks(health_check_map_t
*checks
);
95 void set_uri(const std::string
&str
)
100 std::string
get_uri() const
105 std::string
get_fin_thread_name() const
107 return fin_thread_name
;
110 bool is_authorized(const std::map
<std::string
, std::string
>& arguments
) const;