]> git.proxmox.com Git - ceph.git/blame - ceph/src/mgr/ActivePyModules.h
update sources to 12.2.2
[ceph.git] / ceph / src / mgr / ActivePyModules.h
CommitLineData
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) 2014 John Spray <john.spray@inktank.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
3efd9988 14#pragma once
7c673cae 15
3efd9988 16#include "ActivePyModule.h"
7c673cae
FG
17
18#include "common/Finisher.h"
19#include "common/Mutex.h"
7c673cae
FG
20
21#include "osdc/Objecter.h"
22#include "client/Client.h"
224ce89b
WB
23#include "common/LogClient.h"
24#include "mon/MgrMap.h"
c07f9fc5 25#include "mon/MonCommand.h"
7c673cae
FG
26
27#include "DaemonState.h"
28#include "ClusterState.h"
29
c07f9fc5 30class health_check_map_t;
7c673cae 31
3efd9988
FG
32typedef std::map<std::string, std::string> PyModuleConfig;
33
34class ActivePyModules
7c673cae 35{
3efd9988
FG
36
37 std::map<std::string, std::unique_ptr<ActivePyModule>> modules;
38 PyModuleConfig config_cache;
7c673cae
FG
39 DaemonStateIndex &daemon_state;
40 ClusterState &cluster_state;
41 MonClient &monc;
224ce89b 42 LogChannelRef clog;
7c673cae
FG
43 Objecter &objecter;
44 Client &client;
45 Finisher &finisher;
46
7c673cae 47
3efd9988 48 mutable Mutex lock{"ActivePyModules::lock"};
31f18b77 49
7c673cae 50public:
3efd9988
FG
51 ActivePyModules(PyModuleConfig const &config_,
52 DaemonStateIndex &ds, ClusterState &cs, MonClient &mc,
224ce89b 53 LogChannelRef clog_, Objecter &objecter_, Client &client_,
7c673cae
FG
54 Finisher &f);
55
3efd9988 56 ~ActivePyModules();
7c673cae
FG
57
58 // FIXME: wrap for send_command?
59 MonClient &get_monc() {return monc;}
60 Objecter &get_objecter() {return objecter;}
61 Client &get_client() {return client;}
62
63 PyObject *get_python(const std::string &what);
64 PyObject *get_server_python(const std::string &hostname);
65 PyObject *list_servers_python();
224ce89b 66 PyObject *get_metadata_python(
3efd9988 67 const std::string &svc_type, const std::string &svc_id);
224ce89b 68 PyObject *get_daemon_status_python(
3efd9988 69 const std::string &svc_type, const std::string &svc_id);
224ce89b 70 PyObject *get_counter_python(
3efd9988 71 const std::string &svc_type,
224ce89b
WB
72 const std::string &svc_id,
73 const std::string &path);
c07f9fc5 74 PyObject *get_perf_schema_python(
c07f9fc5
FG
75 const std::string svc_type,
76 const std::string &svc_id);
7c673cae 77 PyObject *get_context();
3efd9988
FG
78 PyObject *get_osdmap();
79
80 bool get_config(const std::string &module_name,
81 const std::string &key, std::string *val) const;
82 PyObject *get_config_prefix(const std::string &module_name,
83 const std::string &prefix) const;
84 void set_config(const std::string &module_name,
85 const std::string &key, const boost::optional<std::string> &val);
86
87 void set_health_checks(const std::string& module_name,
88 health_check_map_t&& checks);
89 void get_health_checks(health_check_map_t *checks);
7c673cae 90
3efd9988 91 void set_uri(const std::string& module_name, const std::string &uri);
7c673cae 92
c07f9fc5
FG
93 // Python command definitions, including callback
94 std::vector<ModuleCommand> get_py_commands() const;
95
96 // Monitor command definitions, suitable for CLI
97 std::vector<MonCommand> get_commands() const;
7c673cae 98
3efd9988 99 std::map<std::string, std::string> get_services() const;
7c673cae
FG
100
101 // Public so that MonCommandCompletion can use it
102 // FIXME: for send_command completion notifications,
103 // send it to only the module that sent the command, not everyone
104 void notify_all(const std::string &notify_type,
105 const std::string &notify_id);
106 void notify_all(const LogEntry &log_entry);
107
108 int init();
7c673cae
FG
109 void shutdown();
110
3efd9988
FG
111 int start_one(std::string const &module_name,
112 PyObject *pClass,
113 const SafeThreadState &pMyThreadState);
114
7c673cae
FG
115 void dump_server(const std::string &hostname,
116 const DaemonStateCollection &dmc,
117 Formatter *f);
7c673cae
FG
118};
119