]>
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"
26 #include "DaemonState.h"
27 #include "ClusterState.h"
33 std::map
<std::string
, std::unique_ptr
<MgrPyModule
>> modules
;
34 std::map
<std::string
, std::unique_ptr
<ServeThread
>> serve_threads
;
35 DaemonStateIndex
&daemon_state
;
36 ClusterState
&cluster_state
;
42 mutable Mutex lock
{"PyModules"};
44 std::string
get_site_packages();
47 static constexpr auto config_prefix
= "mgr.";
49 PyModules(DaemonStateIndex
&ds
, ClusterState
&cs
, MonClient
&mc
,
50 Objecter
&objecter_
, Client
&client_
,
55 // FIXME: wrap for send_command?
56 MonClient
&get_monc() {return monc
;}
57 Objecter
&get_objecter() {return objecter
;}
58 Client
&get_client() {return client
;}
60 PyObject
*get_python(const std::string
&what
);
61 PyObject
*get_server_python(const std::string
&hostname
);
62 PyObject
*list_servers_python();
63 PyObject
*get_metadata_python(std::string
const &handle
,
64 entity_type_t svc_type
, const std::string
&svc_id
);
65 PyObject
*get_counter_python(std::string
const &handle
,
66 entity_type_t svc_type
, const std::string
&svc_id
,
67 const std::string
&path
);
68 PyObject
*get_context();
70 std::map
<std::string
, std::string
> config_cache
;
72 std::vector
<ModuleCommand
> get_commands();
74 void insert_config(const std::map
<std::string
, std::string
> &new_config
);
76 // Public so that MonCommandCompletion can use it
77 // FIXME: for send_command completion notifications,
78 // send it to only the module that sent the command, not everyone
79 void notify_all(const std::string
¬ify_type
,
80 const std::string
¬ify_id
);
81 void notify_all(const LogEntry
&log_entry
);
87 void dump_server(const std::string
&hostname
,
88 const DaemonStateCollection
&dmc
,
91 bool get_config(const std::string
&handle
,
92 const std::string
&key
, std::string
*val
) const;
93 void set_config(const std::string
&handle
,
94 const std::string
&key
, const std::string
&val
);
96 void log(const std::string
&handle
,
97 int level
, const std::string
&record
);