]>
git.proxmox.com Git - ceph.git/blob - ceph/src/mgr/PyModules.h
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"
28 #include "DaemonState.h"
29 #include "ClusterState.h"
35 std::map
<std::string
, std::unique_ptr
<MgrPyModule
>> modules
;
36 std::map
<std::string
, std::unique_ptr
<ServeThread
>> serve_threads
;
37 DaemonStateIndex
&daemon_state
;
38 ClusterState
&cluster_state
;
45 mutable Mutex lock
{"PyModules"};
47 std::string
get_site_packages();
49 PyThreadState
*pMainThreadState
= nullptr;
52 static std::string config_prefix
;
54 PyModules(DaemonStateIndex
&ds
, ClusterState
&cs
, MonClient
&mc
,
55 LogChannelRef clog_
, Objecter
&objecter_
, Client
&client_
,
60 // FIXME: wrap for send_command?
61 MonClient
&get_monc() {return monc
;}
62 Objecter
&get_objecter() {return objecter
;}
63 Client
&get_client() {return client
;}
65 PyObject
*get_python(const std::string
&what
);
66 PyObject
*get_server_python(const std::string
&hostname
);
67 PyObject
*list_servers_python();
68 PyObject
*get_metadata_python(
69 std::string
const &handle
,
70 const std::string
&svc_name
, const std::string
&svc_id
);
71 PyObject
*get_daemon_status_python(
72 std::string
const &handle
,
73 const std::string
&svc_name
, const std::string
&svc_id
);
74 PyObject
*get_counter_python(
75 std::string
const &handle
,
76 const std::string
&svc_name
,
77 const std::string
&svc_id
,
78 const std::string
&path
);
79 PyObject
*get_context();
81 std::map
<std::string
, std::string
> config_cache
;
83 std::vector
<ModuleCommand
> get_commands();
85 void insert_config(const std::map
<std::string
, std::string
> &new_config
);
87 // Public so that MonCommandCompletion can use it
88 // FIXME: for send_command completion notifications,
89 // send it to only the module that sent the command, not everyone
90 void notify_all(const std::string
¬ify_type
,
91 const std::string
¬ify_id
);
92 void notify_all(const LogEntry
&log_entry
);
98 void dump_server(const std::string
&hostname
,
99 const DaemonStateCollection
&dmc
,
102 bool get_config(const std::string
&handle
,
103 const std::string
&key
, std::string
*val
) const;
104 PyObject
*get_config_prefix(const std::string
&handle
,
105 const std::string
&prefix
) const;
106 void set_config(const std::string
&handle
,
107 const std::string
&key
, const std::string
&val
);
109 void log(const std::string
&handle
,
110 int level
, const std::string
&record
);
112 static void list_modules(std::set
<std::string
> *modules
);