This source file includes following definitions.
- fenced_support_flag
1
2
3
4
5
6
7
8 #include <stdint.h>
9 #include <libxml/tree.h>
10
11 #include <crm/common/mainloop.h>
12 #include <crm/cluster.h>
13 #include <crm/stonith-ng.h>
14 #include <crm/fencing/internal.h>
15
16
17
18
19
20
21
22
23
24
25
26
27 gboolean stonith_check_fence_tolerance(int tolerance, const char *target, const char *action);
28
29
30
31
32
33 enum fenced_device_flags {
34
35 fenced_df_none = UINT32_C(0),
36
37
38 fenced_df_supports_list = (UINT32_C(1) << 0),
39
40
41 fenced_df_supports_on = (UINT32_C(1) << 1),
42
43
44 fenced_df_supports_reboot = (UINT32_C(1) << 2),
45
46
47 fenced_df_supports_status = (UINT32_C(1) << 3),
48
49
50 fenced_df_auto_unfence = (UINT32_C(1) << 4),
51
52
53 fenced_df_verified = (UINT32_C(1) << 5),
54
55
56 fenced_df_api_registered = (UINT32_C(1) << 6),
57
58
59 fenced_df_cib_registered = (UINT32_C(1) << 7),
60
61
62 fenced_df_dirty = (UINT32_C(1) << 8),
63 };
64
65
66
67
68
69
70
71
72 #define fenced_device_set_flags(device, set_flags) do { \
73 pcmk__assert((device) != NULL); \
74 (device)->flags = pcmk__set_flags_as(__func__, __LINE__, LOG_TRACE, \
75 "Fence device", (device)->id, \
76 (device)->flags, set_flags, \
77 #set_flags); \
78 } while (0)
79
80
81
82
83
84
85
86
87
88 #define fenced_device_clear_flags(device, clear_flags) do { \
89 pcmk__assert((device) != NULL); \
90 (device)->flags = pcmk__clear_flags_as(__func__, __LINE__, \
91 LOG_TRACE, "Fence device", \
92 (device)->id, \
93 (device)->flags, \
94 clear_flags, #clear_flags); \
95 } while (0)
96
97
98
99
100
101 enum fenced_notify_flags {
102
103 fenced_nf_none = UINT32_C(0),
104
105
106 fenced_nf_fence_result = (UINT32_C(1) << 0),
107
108
109
110 fenced_nf_device_registered = (UINT32_C(1) << 1),
111
112
113
114 fenced_nf_device_removed = (UINT32_C(1) << 2),
115
116
117 fenced_nf_history_changed = (UINT32_C(1) << 3),
118
119
120
121
122
123
124
125 fenced_nf_history_synced = (UINT32_C(1) << 4),
126 };
127
128 enum fenced_notify_flags fenced_parse_notify_flag(const char *type);
129
130 typedef struct {
131 char *id;
132 char *agent;
133 char *namespace;
134
135
136 GString *on_target_actions;
137 GList *targets;
138 time_t targets_age;
139
140 uint32_t flags;
141
142 GHashTable *params;
143 GHashTable *aliases;
144 GList *pending_ops;
145 mainloop_timer_t *timer;
146 crm_trigger_t *work;
147 xmlNode *agent_metadata;
148 const char *default_host_arg;
149 } fenced_device_t;
150
151
152
153
154
155
156 enum st_remap_phase {
157 st_phase_requested = 0,
158 st_phase_off = 1,
159 st_phase_on = 2,
160 st_phase_max = 3
161 };
162
163 typedef struct remote_fencing_op_s {
164
165
166
167
168
169
170 char *id;
171
172 char *target;
173
174 char *action;
175
176
177 time_t created;
178
179
180 gboolean notify_sent;
181
182 guint replies;
183
184 guint replies_expected;
185
186 gboolean owner;
187
188 guint op_timer_total;
189
190
191 guint op_timer_one;
192
193
194 guint query_timer;
195
196
197 gint base_timeout;
198
199
200
201 gint total_timeout;
202
203
204
205
206
207
208 int client_delay;
209
210
211
212
213
214 char *delegate;
215
216 time_t completed;
217
218 uint32_t call_options;
219
220
221
222 enum op_state state;
223
224 char *originator;
225
226 char *client_id;
227
228 int client_callid;
229
230 char *client_name;
231
232 GList *query_results;
233
234 xmlNode *request;
235
236
237 guint level;
238
239 enum st_remap_phase phase;
240
241
242 GList *automatic_list;
243
244 GList *devices_list;
245
246 GList *devices;
247
248
249
250 GList *duplicates;
251
252
253 long long completed_nsec;
254
255
256 pcmk__action_result_t result;
257 } remote_fencing_op_t;
258
259 void fenced_broadcast_op_result(const remote_fencing_op_t *op, bool op_merged);
260
261
262 enum fenced_target_by {
263 fenced_target_by_unknown = -1,
264 fenced_target_by_name,
265 fenced_target_by_pattern,
266 fenced_target_by_attribute,
267 };
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283 typedef struct stonith_topology_s {
284 enum fenced_target_by kind;
285
286
287 char *target;
288 char *target_value;
289 char *target_pattern;
290 char *target_attribute;
291
292
293 GList *levels[ST__LEVEL_COUNT];
294
295 } stonith_topology_t;
296
297 void stonith_shutdown(int nsig);
298
299 void fenced_init_device_table(void);
300 void fenced_free_device_table(void);
301 bool fenced_has_watchdog_device(void);
302 void fenced_foreach_device(GHFunc fn, gpointer user_data);
303 void fenced_foreach_device_remove(GHRFunc fn);
304
305 void init_topology_list(void);
306 void free_topology_list(void);
307 void free_stonith_remote_op_list(void);
308 void init_stonith_remote_op_hash_table(GHashTable **table);
309 void free_metadata_cache(void);
310 void fenced_unregister_handlers(void);
311
312 void stonith_command(pcmk__client_t *client, uint32_t id, uint32_t flags,
313 xmlNode *op_request, const char *remote_peer);
314
315 int fenced_device_register(const xmlNode *dev, bool from_cib);
316
317 void stonith_device_remove(const char *id, bool from_cib);
318
319 char *stonith_level_key(const xmlNode *msg, enum fenced_target_by);
320 void fenced_register_level(xmlNode *msg, pcmk__action_result_t *result);
321 void fenced_unregister_level(xmlNode *msg, pcmk__action_result_t *result);
322
323 stonith_topology_t *find_topology_for_host(const char *host);
324
325 void do_local_reply(const xmlNode *notify_src, pcmk__client_t *client,
326 int call_options);
327
328 xmlNode *fenced_construct_reply(const xmlNode *request, xmlNode *data,
329 const pcmk__action_result_t *result);
330
331 void
332 do_stonith_async_timeout_update(const char *client, const char *call_id, int timeout);
333
334 void fenced_send_notification(const char *type,
335 const pcmk__action_result_t *result,
336 xmlNode *data);
337 void fenced_send_config_notification(const char *op,
338 const pcmk__action_result_t *result,
339 const char *desc);
340
341 remote_fencing_op_t *initiate_remote_stonith_op(const pcmk__client_t *client,
342 xmlNode *request,
343 gboolean manual_ack);
344
345 void fenced_process_fencing_reply(xmlNode *msg);
346
347 int process_remote_stonith_query(xmlNode * msg);
348
349 void *create_remote_stonith_op(const char *client, xmlNode * request, gboolean peer);
350
351 void stonith_fence_history(xmlNode *msg, xmlNode **output,
352 const char *remote_peer, int options);
353
354 void stonith_fence_history_trim(void);
355
356 bool fencing_peer_active(pcmk__node_status_t *peer);
357
358 void set_fencing_completed(remote_fencing_op_t * op);
359
360 int fenced_handle_manual_confirmation(const pcmk__client_t *client,
361 xmlNode *msg);
362
363 const char *fenced_device_reboot_action(const char *device_id);
364 bool fenced_device_supports_on(const char *device_id);
365
366 gboolean node_has_attr(const char *node, const char *name, const char *value);
367
368 gboolean node_does_watchdog_fencing(const char *node);
369
370 void fencing_topology_init(void);
371 void setup_cib(void);
372 void fenced_cib_cleanup(void);
373
374 int fenced_scheduler_init(void);
375 void fenced_set_local_node(const char *node_name);
376 const char *fenced_get_local_node(void);
377 void fenced_scheduler_cleanup(void);
378 void fenced_scheduler_run(xmlNode *cib);
379
380
381
382
383
384
385
386
387
388
389 static inline uint32_t
390 fenced_support_flag(const char *action)
391 {
392 if (pcmk__str_eq(action, PCMK_ACTION_ON, pcmk__str_none)) {
393 return fenced_df_supports_on;
394 }
395 return fenced_df_none;
396 }
397
398 extern GHashTable *topology;
399 extern long long stonith_watchdog_timeout_ms;
400 extern GList *stonith_watchdog_targets;
401 extern GHashTable *stonith_remote_op_list;
402 extern crm_exit_t exit_code;
403 extern gboolean stonith_shutdown_flag;