]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | /* | |
4 | * Ceph - scalable distributed file system | |
5 | * | |
6 | * Copyright (C) 2016 John Spray <john.spray@redhat.com> | |
7 | * | |
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. | |
12 | */ | |
13 | ||
14 | #ifndef DAEMON_SERVER_H_ | |
15 | #define DAEMON_SERVER_H_ | |
16 | ||
17 | #include "PyModules.h" | |
18 | ||
19 | #include <set> | |
20 | #include <string> | |
21 | ||
22 | #include "common/Mutex.h" | |
23 | #include "common/LogClient.h" | |
24 | ||
25 | #include <msg/Messenger.h> | |
26 | #include <mon/MonClient.h> | |
27 | ||
28 | #include "auth/AuthAuthorizeHandler.h" | |
29 | ||
30 | #include "MgrSession.h" | |
31 | #include "DaemonState.h" | |
32 | ||
33 | class MMgrReport; | |
34 | class MMgrOpen; | |
35 | class MCommand; | |
36 | struct MgrCommand; | |
37 | ||
38 | ||
39 | /** | |
40 | * Server used in ceph-mgr to communicate with Ceph daemons like | |
41 | * MDSs and OSDs. | |
42 | */ | |
43 | class DaemonServer : public Dispatcher | |
44 | { | |
45 | protected: | |
46 | boost::scoped_ptr<Throttle> client_byte_throttler; | |
47 | boost::scoped_ptr<Throttle> client_msg_throttler; | |
48 | boost::scoped_ptr<Throttle> osd_byte_throttler; | |
49 | boost::scoped_ptr<Throttle> osd_msg_throttler; | |
50 | boost::scoped_ptr<Throttle> mds_byte_throttler; | |
51 | boost::scoped_ptr<Throttle> mds_msg_throttler; | |
52 | boost::scoped_ptr<Throttle> mon_byte_throttler; | |
53 | boost::scoped_ptr<Throttle> mon_msg_throttler; | |
54 | ||
55 | Messenger *msgr; | |
56 | MonClient *monc; | |
57 | Finisher &finisher; | |
58 | DaemonStateIndex &daemon_state; | |
59 | ClusterState &cluster_state; | |
60 | PyModules &py_modules; | |
61 | LogChannelRef clog, audit_clog; | |
62 | ||
63 | AuthAuthorizeHandlerRegistry auth_registry; | |
64 | ||
65 | Mutex lock; | |
66 | ||
67 | static void _generate_command_map(map<string,cmd_vartype>& cmdmap, | |
68 | map<string,string> ¶m_str_map); | |
69 | static const MgrCommand *_get_mgrcommand(const string &cmd_prefix, | |
70 | MgrCommand *cmds, int cmds_size); | |
71 | bool _allowed_command( | |
72 | MgrSession *s, const string &module, const string &prefix, | |
73 | const map<string,cmd_vartype>& cmdmap, | |
74 | const map<string,string>& param_str_map, | |
75 | const MgrCommand *this_cmd); | |
76 | ||
77 | private: | |
78 | friend class ReplyOnFinish; | |
79 | bool _reply(MCommand* m, | |
80 | int ret, const std::string& s, const bufferlist& payload); | |
81 | ||
82 | public: | |
83 | int init(uint64_t gid, entity_addr_t client_addr); | |
84 | void shutdown(); | |
85 | ||
86 | entity_addr_t get_myaddr() const; | |
87 | ||
88 | DaemonServer(MonClient *monc_, | |
89 | Finisher &finisher_, | |
90 | DaemonStateIndex &daemon_state_, | |
91 | ClusterState &cluster_state_, | |
92 | PyModules &py_modules_, | |
93 | LogChannelRef cl, | |
94 | LogChannelRef auditcl); | |
95 | ~DaemonServer() override; | |
96 | ||
97 | bool ms_dispatch(Message *m) override; | |
98 | bool ms_handle_reset(Connection *con) override { return false; } | |
99 | void ms_handle_remote_reset(Connection *con) override {} | |
100 | bool ms_handle_refused(Connection *con) override; | |
101 | bool ms_get_authorizer(int dest_type, AuthAuthorizer **authorizer, | |
102 | bool force_new) override; | |
103 | bool ms_verify_authorizer(Connection *con, | |
104 | int peer_type, | |
105 | int protocol, | |
106 | ceph::bufferlist& authorizer, | |
107 | ceph::bufferlist& authorizer_reply, | |
108 | bool& isvalid, | |
109 | CryptoKey& session_key) override; | |
110 | ||
111 | bool handle_open(MMgrOpen *m); | |
112 | bool handle_report(MMgrReport *m); | |
113 | bool handle_command(MCommand *m); | |
114 | }; | |
115 | ||
116 | #endif | |
117 |