This source file includes following definitions.
- fenced_set_protocol_error
- 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 typedef struct stonith_device_s {
30 char *id;
31 char *agent;
32 char *namespace;
33
34
35 GString *on_target_actions;
36 GList *targets;
37 time_t targets_age;
38 gboolean has_attr_map;
39
40
41 gboolean include_nodeid;
42
43
44 gboolean automatic_unfencing;
45 guint priority;
46
47 uint32_t flags;
48
49 GHashTable *params;
50 GHashTable *aliases;
51 GList *pending_ops;
52 mainloop_timer_t *timer;
53 crm_trigger_t *work;
54 xmlNode *agent_metadata;
55
56
57
58 gboolean verified;
59
60 gboolean cib_registered;
61 gboolean api_registered;
62 gboolean dirty;
63 } stonith_device_t;
64
65
66
67
68
69
70 enum st_remap_phase {
71 st_phase_requested = 0,
72 st_phase_off = 1,
73 st_phase_on = 2,
74 st_phase_max = 3
75 };
76
77 typedef struct remote_fencing_op_s {
78
79 char *id;
80
81 char *target;
82
83 char *action;
84
85
86 time_t created;
87
88
89 gboolean notify_sent;
90
91 guint replies;
92
93 guint replies_expected;
94
95 gboolean owner;
96
97 guint op_timer_total;
98
99
100 guint op_timer_one;
101
102
103 guint query_timer;
104
105
106 gint base_timeout;
107
108
109
110 gint total_timeout;
111
112
113
114
115
116
117 int client_delay;
118
119
120
121
122
123 char *delegate;
124
125 time_t completed;
126
127 uint32_t call_options;
128
129
130
131 enum op_state state;
132
133 char *originator;
134
135 char *client_id;
136
137 int client_callid;
138
139 char *client_name;
140
141 GList *query_results;
142
143 xmlNode *request;
144
145
146 guint level;
147
148 enum st_remap_phase phase;
149
150
151 GList *automatic_list;
152
153 GList *devices_list;
154
155 GList *devices;
156
157
158
159 GList *duplicates;
160
161
162 long long completed_nsec;
163
164
165 pcmk__action_result_t result;
166 } remote_fencing_op_t;
167
168 void fenced_broadcast_op_result(const remote_fencing_op_t *op, bool op_merged);
169
170
171 enum st_client_flags {
172 st_callback_unknown = UINT64_C(0),
173 st_callback_notify_fence = (UINT64_C(1) << 0),
174 st_callback_device_add = (UINT64_C(1) << 2),
175 st_callback_device_del = (UINT64_C(1) << 4),
176 st_callback_notify_history = (UINT64_C(1) << 5),
177 st_callback_notify_history_synced = (UINT64_C(1) << 6)
178 };
179
180
181 enum fenced_target_by {
182 fenced_target_by_unknown = -1,
183 fenced_target_by_name,
184 fenced_target_by_pattern,
185 fenced_target_by_attribute,
186 };
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202 typedef struct stonith_topology_s {
203 enum fenced_target_by kind;
204
205
206 char *target;
207 char *target_value;
208 char *target_pattern;
209 char *target_attribute;
210
211
212 GList *levels[ST_LEVEL_MAX];
213
214 } stonith_topology_t;
215
216 void stonith_shutdown(int nsig);
217
218 void init_device_list(void);
219 void free_device_list(void);
220 void init_topology_list(void);
221 void free_topology_list(void);
222 void free_stonith_remote_op_list(void);
223 void init_stonith_remote_op_hash_table(GHashTable **table);
224 void free_metadata_cache(void);
225 void fenced_unregister_handlers(void);
226
227 uint64_t get_stonith_flag(const char *name);
228
229 void stonith_command(pcmk__client_t *client, uint32_t id, uint32_t flags,
230 xmlNode *op_request, const char *remote_peer);
231
232 int stonith_device_register(xmlNode *msg, gboolean from_cib);
233
234 void stonith_device_remove(const char *id, bool from_cib);
235
236 char *stonith_level_key(const xmlNode *msg, enum fenced_target_by);
237 void fenced_register_level(xmlNode *msg, char **desc,
238 pcmk__action_result_t *result);
239 void fenced_unregister_level(xmlNode *msg, char **desc,
240 pcmk__action_result_t *result);
241
242 stonith_topology_t *find_topology_for_host(const char *host);
243
244 void do_local_reply(const xmlNode *notify_src, pcmk__client_t *client,
245 int call_options);
246
247 xmlNode *fenced_construct_reply(const xmlNode *request, xmlNode *data,
248 const pcmk__action_result_t *result);
249
250 void
251 do_stonith_async_timeout_update(const char *client, const char *call_id, int timeout);
252
253 void fenced_send_notification(const char *type,
254 const pcmk__action_result_t *result,
255 xmlNode *data);
256 void fenced_send_device_notification(const char *op,
257 const pcmk__action_result_t *result,
258 const char *desc);
259 void fenced_send_level_notification(const char *op,
260 const pcmk__action_result_t *result,
261 const char *desc);
262
263 remote_fencing_op_t *initiate_remote_stonith_op(const pcmk__client_t *client,
264 xmlNode *request,
265 gboolean manual_ack);
266
267 void fenced_process_fencing_reply(xmlNode *msg);
268
269 int process_remote_stonith_query(xmlNode * msg);
270
271 void *create_remote_stonith_op(const char *client, xmlNode * request, gboolean peer);
272
273 void stonith_fence_history(xmlNode *msg, xmlNode **output,
274 const char *remote_peer, int options);
275
276 void stonith_fence_history_trim(void);
277
278 bool fencing_peer_active(crm_node_t *peer);
279
280 void set_fencing_completed(remote_fencing_op_t * op);
281
282 int fenced_handle_manual_confirmation(const pcmk__client_t *client,
283 xmlNode *msg);
284 void fencer_metadata(void);
285
286 const char *fenced_device_reboot_action(const char *device_id);
287 bool fenced_device_supports_on(const char *device_id);
288
289 gboolean node_has_attr(const char *node, const char *name, const char *value);
290
291 gboolean node_does_watchdog_fencing(const char *node);
292
293 void fencing_topology_init(void);
294 void setup_cib(void);
295 void fenced_cib_cleanup(void);
296
297 int fenced_scheduler_init(void);
298 void fenced_scheduler_cleanup(void);
299 void fenced_scheduler_run(xmlNode *cib);
300
301 static inline void
302 fenced_set_protocol_error(pcmk__action_result_t *result)
303 {
304 pcmk__set_result(result, CRM_EX_PROTOCOL, PCMK_EXEC_INVALID,
305 "Fencer API request missing required information (bug?)");
306 }
307
308
309
310
311
312
313
314
315
316
317 static inline uint32_t
318 fenced_support_flag(const char *action)
319 {
320 if (pcmk__str_eq(action, PCMK_ACTION_ON, pcmk__str_none)) {
321 return st_device_supports_on;
322 }
323 return st_device_supports_none;
324 }
325
326 extern char *stonith_our_uname;
327 extern gboolean stand_alone;
328 extern GHashTable *device_list;
329 extern GHashTable *topology;
330 extern long stonith_watchdog_timeout_ms;
331 extern GList *stonith_watchdog_targets;
332 extern GHashTable *stonith_remote_op_list;
333 extern crm_exit_t exit_code;
334 extern gboolean stonith_shutdown_flag;