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.
14 #ifndef DAEMON_SERVER_H_
15 #define DAEMON_SERVER_H_
17 #include "PyModules.h"
22 #include "common/Mutex.h"
23 #include "common/LogClient.h"
25 #include <msg/Messenger.h>
26 #include <mon/MonClient.h>
28 #include "auth/AuthAuthorizeHandler.h"
30 #include "MgrSession.h"
31 #include "DaemonState.h"
41 * Server used in ceph-mgr to communicate with Ceph daemons like
44 class DaemonServer
: public Dispatcher
47 boost::scoped_ptr
<Throttle
> client_byte_throttler
;
48 boost::scoped_ptr
<Throttle
> client_msg_throttler
;
49 boost::scoped_ptr
<Throttle
> osd_byte_throttler
;
50 boost::scoped_ptr
<Throttle
> osd_msg_throttler
;
51 boost::scoped_ptr
<Throttle
> mds_byte_throttler
;
52 boost::scoped_ptr
<Throttle
> mds_msg_throttler
;
53 boost::scoped_ptr
<Throttle
> mon_byte_throttler
;
54 boost::scoped_ptr
<Throttle
> mon_msg_throttler
;
59 DaemonStateIndex
&daemon_state
;
60 ClusterState
&cluster_state
;
61 PyModules
&py_modules
;
62 LogChannelRef clog
, audit_clog
;
64 AuthAuthorizeHandlerRegistry auth_registry
;
66 /// connections for osds
67 ceph::unordered_map
<int,set
<ConnectionRef
>> osd_cons
;
71 static void _generate_command_map(map
<string
,cmd_vartype
>& cmdmap
,
72 map
<string
,string
> ¶m_str_map
);
73 static const MgrCommand
*_get_mgrcommand(const string
&cmd_prefix
,
74 MgrCommand
*cmds
, int cmds_size
);
75 bool _allowed_command(
76 MgrSession
*s
, const string
&module
, const string
&prefix
,
77 const map
<string
,cmd_vartype
>& cmdmap
,
78 const map
<string
,string
>& param_str_map
,
79 const MgrCommand
*this_cmd
);
82 friend class ReplyOnFinish
;
83 bool _reply(MCommand
* m
,
84 int ret
, const std::string
& s
, const bufferlist
& payload
);
87 int init(uint64_t gid
, entity_addr_t client_addr
);
90 entity_addr_t
get_myaddr() const;
92 DaemonServer(MonClient
*monc_
,
94 DaemonStateIndex
&daemon_state_
,
95 ClusterState
&cluster_state_
,
96 PyModules
&py_modules_
,
98 LogChannelRef auditcl
);
99 ~DaemonServer() override
;
101 bool ms_dispatch(Message
*m
) override
;
102 bool ms_handle_reset(Connection
*con
) override
;
103 void ms_handle_remote_reset(Connection
*con
) override
{}
104 bool ms_handle_refused(Connection
*con
) override
;
105 bool ms_get_authorizer(int dest_type
, AuthAuthorizer
**authorizer
,
106 bool force_new
) override
;
107 bool ms_verify_authorizer(Connection
*con
,
110 ceph::bufferlist
& authorizer
,
111 ceph::bufferlist
& authorizer_reply
,
113 CryptoKey
& session_key
) override
;
115 bool handle_open(MMgrOpen
*m
);
116 bool handle_report(MMgrReport
*m
);
117 bool handle_command(MCommand
*m
);