This source file includes following definitions.
- stonith_api_kick_helper
- stonith_api_time_helper
1
2
3
4
5
6
7
8
9
10 #ifndef STONITH_NG__H
11 # define STONITH_NG__H
12
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16
17
18
19
20
21
22
23 # include <dlfcn.h>
24 # include <errno.h>
25 # include <stdbool.h>
26 # include <stdint.h>
27 # include <time.h>
28
29 # define T_STONITH_NOTIFY_DISCONNECT "st_notify_disconnect"
30 # define T_STONITH_NOTIFY_FENCE "st_notify_fence"
31 # define T_STONITH_NOTIFY_HISTORY "st_notify_history"
32 # define T_STONITH_NOTIFY_HISTORY_SYNCED "st_notify_history_synced"
33
34
35 enum stonith_state {
36 stonith_connected_command,
37 stonith_connected_query,
38 stonith_disconnected,
39 };
40
41 enum stonith_call_options {
42 st_opt_none = 0x00000000,
43 st_opt_verbose = 0x00000001,
44 st_opt_allow_suicide = 0x00000002,
45
46 st_opt_manual_ack = 0x00000008,
47 st_opt_discard_reply = 0x00000010,
48
49 st_opt_topology = 0x00000040,
50 st_opt_scope_local = 0x00000100,
51 st_opt_cs_nodeid = 0x00000200,
52 st_opt_sync_call = 0x00001000,
53
54
55 st_opt_timeout_updates = 0x00002000,
56
57 st_opt_report_only_success = 0x00004000,
58
59 st_opt_cleanup = 0x000080000,
60
61 st_opt_broadcast = 0x000100000,
62 };
63
64
65 enum op_state
66 {
67 st_query,
68 st_exec,
69 st_done,
70 st_duplicate,
71 st_failed,
72 };
73
74
75 enum stonith_namespace {
76 st_namespace_invalid,
77 st_namespace_any,
78 st_namespace_internal,
79
80
81
82
83 st_namespace_rhcs,
84 st_namespace_lha,
85 };
86
87 enum stonith_namespace stonith_text2namespace(const char *namespace_s);
88 const char *stonith_namespace2text(enum stonith_namespace st_namespace);
89 enum stonith_namespace stonith_get_namespace(const char *agent,
90 const char *namespace_s);
91
92 typedef struct stonith_key_value_s {
93 char *key;
94 char *value;
95 struct stonith_key_value_s *next;
96 } stonith_key_value_t;
97
98 typedef struct stonith_history_s {
99 char *target;
100 char *action;
101 char *origin;
102 char *delegate;
103 char *client;
104 int state;
105 time_t completed;
106 struct stonith_history_s *next;
107 } stonith_history_t;
108
109 typedef struct stonith_s stonith_t;
110
111 typedef struct stonith_event_s
112 {
113 char *id;
114 char *type;
115 char *message;
116 char *operation;
117
118 int result;
119 char *origin;
120 char *target;
121 char *action;
122 char *executioner;
123
124 char *device;
125
126
127 char *client_origin;
128
129 } stonith_event_t;
130
131 typedef struct stonith_callback_data_s
132 {
133 int rc;
134 int call_id;
135 void *userdata;
136 } stonith_callback_data_t;
137
138 typedef struct stonith_api_operations_s
139 {
140
141
142
143 int (*free) (stonith_t *st);
144
145
146
147
148
149
150
151 int (*connect) (stonith_t *st, const char *name, int *stonith_fd);
152
153
154
155
156
157
158
159 int (*disconnect)(stonith_t *st);
160
161
162
163
164
165
166
167
168
169 int (*remove_device)(
170 stonith_t *st, int options, const char *name);
171
172
173
174
175
176
177
178
179
180 int (*register_device)(
181 stonith_t *st, int options, const char *id,
182 const char *provider, const char *agent, stonith_key_value_t *params);
183
184
185
186
187
188
189
190 int (*remove_level)(
191 stonith_t *st, int options, const char *node, int level);
192
193
194
195
196
197
198
199
200 int (*register_level)(
201 stonith_t *st, int options, const char *node, int level, stonith_key_value_t *device_list);
202
203
204
205
206
207
208
209
210
211 int (*metadata)(stonith_t *st, int options,
212 const char *device, const char *provider, char **output, int timeout);
213
214
215
216
217
218
219
220
221
222
223
224 int (*list_agents)(stonith_t *stonith, int call_options, const char *provider,
225 stonith_key_value_t **devices, int timeout);
226
227
228
229
230
231
232
233 int (*list)(stonith_t *st, int options, const char *id, char **list_output, int timeout);
234
235
236
237
238
239
240
241 int (*monitor)(stonith_t *st, int options, const char *id, int timeout);
242
243
244
245
246
247
248
249 int (*status)(stonith_t *st, int options, const char *id, const char *port, int timeout);
250
251
252
253
254
255
256
257
258
259
260 int (*query)(stonith_t *st, int options, const char *node,
261 stonith_key_value_t **devices, int timeout);
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278 int (*fence)(stonith_t *st, int options, const char *node, const char *action,
279 int timeout, int tolerance);
280
281
282
283
284
285
286
287 int (*confirm)(stonith_t *st, int options, const char *node);
288
289
290
291
292
293
294
295 int (*history)(stonith_t *st, int options, const char *node, stonith_history_t **output, int timeout);
296
297 int (*register_notification)(
298 stonith_t *st, const char *event,
299 void (*notify)(stonith_t *st, stonith_event_t *e));
300 int (*remove_notification)(stonith_t *st, const char *event);
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319 int (*register_callback)(stonith_t *st,
320 int call_id,
321 int timeout,
322 int options,
323 void *userdata,
324 const char *callback_name,
325 void (*callback)(stonith_t *st, stonith_callback_data_t *data));
326
327
328
329
330 int (*remove_callback)(stonith_t *st, int call_id, bool all_callbacks);
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347 int (*remove_level_full)(stonith_t *st, int options,
348 const char *node, const char *pattern,
349 const char *attr, const char *value, int level);
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367 int (*register_level_full)(stonith_t *st, int options,
368 const char *node, const char *pattern,
369 const char *attr, const char *value,
370 int level, stonith_key_value_t *device_list);
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390 int (*validate)(stonith_t *st, int call_options, const char *rsc_id,
391 const char *namespace_s, const char *agent,
392 stonith_key_value_t *params, int timeout, char **output,
393 char **error_output);
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412 int (*fence_with_delay)(stonith_t *st, int options, const char *node, const char *action,
413 int timeout, int tolerance, int delay);
414
415 } stonith_api_operations_t;
416
417 struct stonith_s
418 {
419 enum stonith_state state;
420
421 int call_id;
422 int call_timeout;
423 void *st_private;
424
425 stonith_api_operations_t *cmds;
426 };
427
428
429
430 stonith_t *stonith_api_new(void);
431 void stonith_api_delete(stonith_t * st);
432
433 void stonith_dump_pending_callbacks(stonith_t * st);
434
435 bool stonith_dispatch(stonith_t * st);
436
437 stonith_key_value_t *stonith_key_value_add(stonith_key_value_t * kvp, const char *key,
438 const char *value);
439 void stonith_key_value_freeall(stonith_key_value_t * kvp, int keys, int values);
440
441 void stonith_history_free(stonith_history_t *history);
442
443
444 int stonith_api_connect_retry(stonith_t *st, const char *name,
445 int max_attempts);
446 const char *stonith_op_state_str(enum op_state state);
447
448
449
450
451
452
453 int stonith_api_kick(uint32_t nodeid, const char *uname, int timeout, bool off);
454 time_t stonith_api_time(uint32_t nodeid, const char *uname, bool in_progress);
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496 # define STONITH_LIBRARY "libstonithd.so.26"
497
498 typedef int (*st_api_kick_fn) (int nodeid, const char *uname, int timeout, bool off);
499 typedef time_t (*st_api_time_fn) (int nodeid, const char *uname, bool in_progress);
500
501 static inline int
502 stonith_api_kick_helper(uint32_t nodeid, int timeout, bool off)
503 {
504 static void *st_library = NULL;
505 static st_api_kick_fn st_kick_fn;
506
507 if (st_library == NULL) {
508 st_library = dlopen(STONITH_LIBRARY, RTLD_LAZY);
509 }
510 if (st_library && st_kick_fn == NULL) {
511 st_kick_fn = (st_api_kick_fn) dlsym(st_library, "stonith_api_kick");
512 }
513 if (st_kick_fn == NULL) {
514 #ifdef ELIBACC
515 return -ELIBACC;
516 #else
517 return -ENOSYS;
518 #endif
519 }
520
521 return (*st_kick_fn) (nodeid, NULL, timeout, off);
522 }
523
524 static inline time_t
525 stonith_api_time_helper(uint32_t nodeid, bool in_progress)
526 {
527 static void *st_library = NULL;
528 static st_api_time_fn st_time_fn;
529
530 if (st_library == NULL) {
531 st_library = dlopen(STONITH_LIBRARY, RTLD_LAZY);
532 }
533 if (st_library && st_time_fn == NULL) {
534 st_time_fn = (st_api_time_fn) dlsym(st_library, "stonith_api_time");
535 }
536 if (st_time_fn == NULL) {
537 return 0;
538 }
539
540 return (*st_time_fn) (nodeid, NULL, in_progress);
541 }
542
543
544
545
546
547
548
549
550
551
552 bool stonith_agent_exists(const char *agent, int timeout);
553
554
555
556
557
558
559 const char *stonith_action_str(const char *action);
560
561 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
562 #include <crm/fencing/compat.h>
563 #endif
564
565 #ifdef __cplusplus
566 }
567 #endif
568
569 #endif