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