]>
git.proxmox.com Git - ceph.git/blob - ceph/src/mgr/PyModules.h
431abec76f0e3cf4b814ed51239dc5d7feb99a46
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) 2014 John Spray <john.spray@inktank.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 #include "MgrPyModule.h"
19 #include "common/Finisher.h"
20 #include "common/Mutex.h"
21 #include "common/Thread.h"
23 #include "osdc/Objecter.h"
24 #include "client/Client.h"
25 #include "common/LogClient.h"
26 #include "mon/MgrMap.h"
27 #include "mon/MonCommand.h"
29 #include "DaemonState.h"
30 #include "ClusterState.h"
33 class health_check_map_t
;
37 std::map
<std::string
, std::unique_ptr
<MgrPyModule
>> modules
;
38 std::map
<std::string
, std::unique_ptr
<ServeThread
>> serve_threads
;
39 DaemonStateIndex
&daemon_state
;
40 ClusterState
&cluster_state
;
47 mutable Mutex lock
{"PyModules::lock"};
49 std::string
get_site_packages();
51 PyThreadState
*pMainThreadState
= nullptr;
54 static std::string config_prefix
;
56 PyModules(DaemonStateIndex
&ds
, ClusterState
&cs
, MonClient
&mc
,
57 LogChannelRef clog_
, Objecter
&objecter_
, Client
&client_
,
62 // FIXME: wrap for send_command?
63 MonClient
&get_monc() {return monc
;}
64 Objecter
&get_objecter() {return objecter
;}
65 Client
&get_client() {return client
;}
67 PyObject
*get_python(const std::string
&what
);
68 PyObject
*get_server_python(const std::string
&hostname
);
69 PyObject
*list_servers_python();
70 PyObject
*get_metadata_python(
71 std::string
const &handle
,
72 const std::string
&svc_name
, const std::string
&svc_id
);
73 PyObject
*get_daemon_status_python(
74 std::string
const &handle
,
75 const std::string
&svc_name
, const std::string
&svc_id
);
76 PyObject
*get_counter_python(
77 std::string
const &handle
,
78 const std::string
&svc_name
,
79 const std::string
&svc_id
,
80 const std::string
&path
);
81 PyObject
*get_perf_schema_python(
82 const std::string
&handle
,
83 const std::string svc_type
,
84 const std::string
&svc_id
);
85 PyObject
*get_context();
87 std::map
<std::string
, std::string
> config_cache
;
89 // Python command definitions, including callback
90 std::vector
<ModuleCommand
> get_py_commands() const;
92 // Monitor command definitions, suitable for CLI
93 std::vector
<MonCommand
> get_commands() const;
95 void insert_config(const std::map
<std::string
, std::string
> &new_config
);
97 // Public so that MonCommandCompletion can use it
98 // FIXME: for send_command completion notifications,
99 // send it to only the module that sent the command, not everyone
100 void notify_all(const std::string
¬ify_type
,
101 const std::string
¬ify_id
);
102 void notify_all(const LogEntry
&log_entry
);
108 void dump_server(const std::string
&hostname
,
109 const DaemonStateCollection
&dmc
,
112 bool get_config(const std::string
&handle
,
113 const std::string
&key
, std::string
*val
) const;
114 PyObject
*get_config_prefix(const std::string
&handle
,
115 const std::string
&prefix
) const;
116 void set_config(const std::string
&handle
,
117 const std::string
&key
, const std::string
&val
);
119 void set_health_checks(const std::string
& handle
,
120 health_check_map_t
&& checks
);
121 void get_health_checks(health_check_map_t
*checks
);
123 void log(const std::string
&handle
,
124 int level
, const std::string
&record
);
126 static void list_modules(std::set
<std::string
> *modules
);