]>
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();
46 PyThreadState
*pMainThreadState
= nullptr;
49 static std::string config_prefix
;
51 PyModules(DaemonStateIndex
&ds
, ClusterState
&cs
, MonClient
&mc
,
52 Objecter
&objecter_
, Client
&client_
,
57 // FIXME: wrap for send_command?
58 MonClient
&get_monc() {return monc
;}
59 Objecter
&get_objecter() {return objecter
;}
60 Client
&get_client() {return client
;}
62 PyObject
*get_python(const std::string
&what
);
63 PyObject
*get_server_python(const std::string
&hostname
);
64 PyObject
*list_servers_python();
65 PyObject
*get_metadata_python(std::string
const &handle
,
66 entity_type_t svc_type
, const std::string
&svc_id
);
67 PyObject
*get_counter_python(std::string
const &handle
,
68 entity_type_t svc_type
, const std::string
&svc_id
,
69 const std::string
&path
);
70 PyObject
*get_context();
72 std::map
<std::string
, std::string
> config_cache
;
74 std::vector
<ModuleCommand
> get_commands();
76 void insert_config(const std::map
<std::string
, std::string
> &new_config
);
78 // Public so that MonCommandCompletion can use it
79 // FIXME: for send_command completion notifications,
80 // send it to only the module that sent the command, not everyone
81 void notify_all(const std::string
¬ify_type
,
82 const std::string
¬ify_id
);
83 void notify_all(const LogEntry
&log_entry
);
89 void dump_server(const std::string
&hostname
,
90 const DaemonStateCollection
&dmc
,
93 bool get_config(const std::string
&handle
,
94 const std::string
&key
, std::string
*val
) const;
95 PyObject
*get_config_prefix(const std::string
&handle
,
96 const std::string
&prefix
) const;
97 void set_config(const std::string
&handle
,
98 const std::string
&key
, const std::string
&val
);
100 void log(const std::string
&handle
,
101 int level
, const std::string
&record
);