1
2
3
4
5
6
7
8 #include <stdint.h>
9 #include <crm/common/mainloop.h>
10
11
12
13
14
15
16
17
18
19
20
21 gboolean stonith_check_fence_tolerance(int tolerance, const char *target, const char *action);
22
23 typedef struct stonith_device_s {
24 char *id;
25 char *agent;
26 char *namespace;
27
28
29 char *on_target_actions;
30 GListPtr targets;
31 time_t targets_age;
32 gboolean has_attr_map;
33
34 gboolean include_nodeid;
35
36 gboolean automatic_unfencing;
37 guint priority;
38
39 uint32_t flags;
40
41 GHashTable *params;
42 GHashTable *aliases;
43 GList *pending_ops;
44 crm_trigger_t *work;
45 xmlNode *agent_metadata;
46
47
48
49 gboolean verified;
50
51 gboolean cib_registered;
52 gboolean api_registered;
53 } stonith_device_t;
54
55
56
57
58
59
60 enum st_remap_phase {
61 st_phase_requested = 0,
62 st_phase_off = 1,
63 st_phase_on = 2,
64 st_phase_max = 3
65 };
66
67
68
69
70 enum st_replay_option {
71 st_reply_opt_none = 0x00000000,
72 st_reply_opt_merged = 0x00000001,
73 };
74
75 typedef struct remote_fencing_op_s {
76
77 char *id;
78
79 char *target;
80
81 char *action;
82
83
84 time_t created;
85
86
87 gboolean notify_sent;
88
89 guint replies;
90
91 guint replies_expected;
92
93 gboolean owner;
94
95 guint op_timer_total;
96
97
98 guint op_timer_one;
99
100
101 guint query_timer;
102
103
104 gint base_timeout;
105
106
107
108 gint total_timeout;
109
110
111
112 int delay;
113
114
115
116
117
118 char *delegate;
119
120 time_t completed;
121
122 uint32_t call_options;
123
124
125
126 enum op_state state;
127
128 char *originator;
129
130 char *client_id;
131
132 int client_callid;
133
134 char *client_name;
135
136 GListPtr query_results;
137
138 xmlNode *request;
139
140
141 guint level;
142
143 enum st_remap_phase phase;
144
145
146 GListPtr automatic_list;
147
148 GListPtr devices_list;
149
150 GListPtr devices;
151
152
153
154 GListPtr duplicates;
155
156 } remote_fencing_op_t;
157
158
159
160
161
162
163
164 void stonith_bcast_result_to_peers(remote_fencing_op_t * op, int rc, gboolean op_merged);
165
166
167 enum st_client_flags {
168 st_callback_unknown = UINT64_C(0),
169 st_callback_notify_fence = (UINT64_C(1) << 0),
170 st_callback_device_add = (UINT64_C(1) << 2),
171 st_callback_device_del = (UINT64_C(1) << 4),
172 st_callback_notify_history = (UINT64_C(1) << 5),
173 st_callback_notify_history_synced = (UINT64_C(1) << 6)
174 };
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190 typedef struct stonith_topology_s {
191 int kind;
192
193
194 char *target;
195 char *target_value;
196 char *target_pattern;
197 char *target_attribute;
198
199
200 GListPtr levels[ST_LEVEL_MAX];
201
202 } stonith_topology_t;
203
204 void init_device_list(void);
205 void free_device_list(void);
206 void init_topology_list(void);
207 void free_topology_list(void);
208 void free_stonith_remote_op_list(void);
209 void init_stonith_remote_op_hash_table(GHashTable **table);
210 void free_metadata_cache(void);
211
212 uint64_t get_stonith_flag(const char *name);
213
214 void stonith_command(pcmk__client_t *client, uint32_t id, uint32_t flags,
215 xmlNode *op_request, const char *remote_peer);
216
217 int stonith_device_register(xmlNode * msg, const char **desc, gboolean from_cib);
218
219 int stonith_device_remove(const char *id, gboolean from_cib);
220
221 char *stonith_level_key(xmlNode * msg, int mode);
222 int stonith_level_kind(xmlNode * msg);
223 int stonith_level_register(xmlNode * msg, char **desc);
224
225 int stonith_level_remove(xmlNode * msg, char **desc);
226
227 stonith_topology_t *find_topology_for_host(const char *host);
228
229 void do_local_reply(xmlNode * notify_src, const char *client_id, gboolean sync_reply,
230 gboolean from_peer);
231
232 xmlNode *stonith_construct_reply(xmlNode * request, const char *output, xmlNode * data,
233 int rc);
234
235 void
236 do_stonith_async_timeout_update(const char *client, const char *call_id, int timeout);
237
238 void do_stonith_notify(int options, const char *type, int result, xmlNode * data);
239 void do_stonith_notify_device(int options, const char *op, int rc, const char *desc);
240 void do_stonith_notify_level(int options, const char *op, int rc, const char *desc);
241
242 remote_fencing_op_t *initiate_remote_stonith_op(pcmk__client_t *client,
243 xmlNode *request,
244 gboolean manual_ack);
245
246 int process_remote_stonith_exec(xmlNode * msg);
247
248 int process_remote_stonith_query(xmlNode * msg);
249
250 void *create_remote_stonith_op(const char *client, xmlNode * request, gboolean peer);
251
252 int stonith_fence_history(xmlNode *msg, xmlNode **output,
253 const char *remote_peer, int options);
254
255 void stonith_fence_history_trim(void);
256
257 bool fencing_peer_active(crm_node_t *peer);
258
259 int stonith_manual_ack(xmlNode * msg, remote_fencing_op_t * op);
260
261 gboolean string_in_list(GListPtr list, const char *item);
262
263 gboolean node_has_attr(const char *node, const char *name, const char *value);
264
265 extern char *stonith_our_uname;
266 extern gboolean stand_alone;
267 extern GHashTable *device_list;
268 extern GHashTable *topology;
269 extern long stonith_watchdog_timeout_ms;
270
271 extern GHashTable *stonith_remote_op_list;