pacemaker 3.0.1-16e74fc4da
Scalable High-Availability cluster resource manager
Loading...
Searching...
No Matches
pcmk_fence.c
Go to the documentation of this file.
1/*
2 * Copyright 2009-2025 the Pacemaker project contributors
3 *
4 * The version control history for this file may have further details.
5 *
6 * This source code is licensed under the GNU General Public License version 2
7 * or later (GPLv2+) WITHOUT ANY WARRANTY.
8 */
9
10#include <crm_internal.h>
11#include <crm/common/mainloop.h>
12#include <crm/common/results.h>
13#include <crm/common/output.h>
15#include <crm/stonith-ng.h>
16#include <crm/fencing/internal.h> // stonith__*
17
18#include <glib.h>
19#include <libxml/tree.h>
20#include <pacemaker.h>
21#include <pacemaker-internal.h>
22
24
25static const int st_opts = st_opt_sync_call|st_opt_allow_self_fencing;
26
27static GMainLoop *mainloop = NULL;
28
29static struct {
31 const char *target;
32 const char *action;
33 char *name;
34 unsigned int timeout;
35 unsigned int tolerance;
36 int delay;
38} async_fence_data = { NULL, };
39
40static int
41handle_level(stonith_t *st, const char *target, int fence_level, GList *devices,
42 bool added)
43{
44 const char *node = NULL;
45 const char *pattern = NULL;
46 const char *name = NULL;
47 char *value = NULL;
48 int rc = pcmk_rc_ok;
49
50 if (target == NULL) {
51 // Not really possible, but makes static analysis happy
52 return EINVAL;
53 }
54
55 /* Determine if targeting by attribute, node name pattern or node name */
56 value = strchr(target, '=');
57 if (value != NULL) {
58 name = target;
59 *value++ = '\0';
60 } else if (*target == '@') {
61 pattern = target + 1;
62 } else {
63 node = target;
64 }
65
66 /* Register or unregister level as appropriate */
67 if (added) {
68 stonith_key_value_t *kvs = NULL;
69
70 for (GList *iter = devices; iter != NULL; iter = iter->next) {
71 kvs = stonith__key_value_add(kvs, NULL, iter->data);
72 }
73
74 rc = st->cmds->register_level_full(st, st_opts, node, pattern, name,
75 value, fence_level, kvs);
76 stonith__key_value_freeall(kvs, false, true);
77 } else {
78 rc = st->cmds->remove_level_full(st, st_opts, node, pattern,
79 name, value, fence_level);
80 }
81
82 return pcmk_legacy2rc(rc);
83}
84
85static stonith_history_t *
86reduce_fence_history(stonith_history_t *history)
87{
88 stonith_history_t *new, *hp, *np;
89
90 if (!history) {
91 return history;
92 }
93
94 new = history;
95 hp = new->next;
96 new->next = NULL;
97
98 while (hp) {
99 stonith_history_t *hp_next = hp->next;
100
101 hp->next = NULL;
102
103 for (np = new; ; np = np->next) {
104 if ((hp->state == st_done) || (hp->state == st_failed)) {
105 /* action not in progress */
106 if (pcmk__str_eq(hp->target, np->target, pcmk__str_casei)
107 && pcmk__str_eq(hp->action, np->action, pcmk__str_none)
108 && (hp->state == np->state)
109 && ((hp->state == st_done)
110 || pcmk__str_eq(hp->delegate, np->delegate,
111 pcmk__str_casei))) {
112 /* purge older hp */
114 break;
115 }
116 }
117
118 if (!np->next) {
119 np->next = hp;
120 break;
121 }
122 }
123 hp = hp_next;
124 }
125
126 return new;
127}
128
129static void
130notify_callback(stonith_t * st, stonith_event_t * e)
131{
132 if (pcmk__str_eq(async_fence_data.target, e->target, pcmk__str_casei)
133 && pcmk__str_eq(async_fence_data.action, e->action, pcmk__str_none)) {
134
135 pcmk__set_result(&async_fence_data.result,
139 g_main_loop_quit(mainloop);
140 }
141}
142
143static void
144fence_callback(stonith_t * stonith, stonith_callback_data_t * data)
145{
146 pcmk__set_result(&async_fence_data.result, stonith__exit_status(data),
149 g_main_loop_quit(mainloop);
150}
151
152static gboolean
153async_fence_helper(gpointer user_data)
154{
155 stonith_t *st = async_fence_data.st;
156 int call_id = 0;
157 int rc = stonith__api_connect_retry(st, async_fence_data.name, 10);
158 int timeout = 0;
159
160 if (rc != pcmk_rc_ok) {
161 g_main_loop_quit(mainloop);
162 pcmk__set_result(&async_fence_data.result, CRM_EX_ERROR,
164 return TRUE;
165 }
166
168 notify_callback);
169
170 call_id = st->cmds->fence_with_delay(st,
172 async_fence_data.target,
173 async_fence_data.action,
174 pcmk__timeout_ms2s(async_fence_data.timeout),
175 pcmk__timeout_ms2s(async_fence_data.tolerance),
176 async_fence_data.delay);
177
178 if (call_id < 0) {
179 g_main_loop_quit(mainloop);
180 pcmk__set_result(&async_fence_data.result, CRM_EX_ERROR,
182 return TRUE;
183 }
184
185 timeout = pcmk__timeout_ms2s(async_fence_data.timeout);
186 if (async_fence_data.delay > 0) {
187 timeout += async_fence_data.delay;
188 }
190 NULL, "callback", fence_callback);
191 return TRUE;
192}
193
194int
195pcmk__request_fencing(stonith_t *st, const char *target, const char *action,
196 const char *name, unsigned int timeout,
197 unsigned int tolerance, int delay, char **reason)
198{
199 crm_trigger_t *trig;
200 int rc = pcmk_rc_ok;
201
202 async_fence_data.st = st;
203 async_fence_data.name = strdup(name);
204 async_fence_data.target = target;
205 async_fence_data.action = action;
206 async_fence_data.timeout = timeout;
207 async_fence_data.tolerance = tolerance;
208 async_fence_data.delay = delay;
209 pcmk__set_result(&async_fence_data.result, CRM_EX_ERROR, PCMK_EXEC_UNKNOWN,
210 NULL);
211
212 trig = mainloop_add_trigger(G_PRIORITY_HIGH, async_fence_helper, NULL);
214
215 mainloop = g_main_loop_new(NULL, FALSE);
216 g_main_loop_run(mainloop);
217
218 free(async_fence_data.name);
219
220 if (reason != NULL) {
221 // Give the caller ownership of the exit reason
222 *reason = async_fence_data.result.exit_reason;
223 async_fence_data.result.exit_reason = NULL;
224 }
225 rc = stonith__result2rc(&async_fence_data.result);
226 pcmk__reset_result(&async_fence_data.result);
227 return rc;
228}
229
230int
231pcmk_request_fencing(xmlNodePtr *xml, const char *target, const char *action,
232 const char *name, unsigned int timeout,
233 unsigned int tolerance, int delay, char **reason)
234{
235 stonith_t *st = NULL;
236 pcmk__output_t *out = NULL;
237 int rc = pcmk_rc_ok;
238
239 rc = pcmk__setup_output_fencing(&out, &st, xml);
240 if (rc != pcmk_rc_ok) {
241 return rc;
242 }
243
245 delay, reason);
247
248 st->cmds->disconnect(st);
250 return rc;
251}
252
253int
255 unsigned int timeout, int verbose, bool broadcast,
256 bool cleanup)
257{
258 stonith_history_t *history = NULL;
259 stonith_history_t *latest = NULL;
260 int rc = pcmk_rc_ok;
261 int opts = 0;
262
263 if (cleanup) {
264 out->info(out, "cleaning up fencing-history%s%s",
265 target ? " for node " : "", target ? target : "");
266 }
267
268 if (broadcast) {
269 out->info(out, "gather fencing-history from all nodes");
270 }
271
272 stonith__set_call_options(opts, target, st_opts);
273
274 if (cleanup) {
276 }
277
278 if (broadcast) {
280 }
281
282 if (pcmk__str_eq(target, "*", pcmk__str_none)) {
283 target = NULL;
284 }
285
286 rc = st->cmds->history(st, opts, target, &history, pcmk__timeout_ms2s(timeout));
287
288 if (cleanup) {
289 // Cleanup doesn't return a history list
290 stonith__history_free(history);
291 return pcmk_legacy2rc(rc);
292 }
293
294 out->begin_list(out, "event", "events", "Fencing history");
295
296 history = stonith__sort_history(history);
297 for (stonith_history_t *hp = history; hp != NULL; hp = hp->next) {
298 if (hp->state == st_done) {
299 latest = hp;
300 }
301
302 if (out->is_quiet(out) || !verbose) {
303 continue;
304 }
305
306 out->message(out, "stonith-event", hp, true, false,
307 stonith__later_succeeded(hp, history),
308 (uint32_t) pcmk_show_failed_detail);
309 out->increment_list(out);
310 }
311
312 if (latest) {
313 if (out->is_quiet(out)) {
314 out->message(out, "stonith-event", latest, false, true, NULL,
315 (uint32_t) pcmk_show_failed_detail);
316 } else if (!verbose) { // already printed if verbose
317 out->message(out, "stonith-event", latest, false, false, NULL,
318 (uint32_t) pcmk_show_failed_detail);
319 out->increment_list(out);
320 }
321 }
322
323 out->end_list(out);
324
325 stonith__history_free(history);
326 return pcmk_legacy2rc(rc);
327}
328
329int
330pcmk_fence_history(xmlNodePtr *xml, const char *target, unsigned int timeout,
331 bool quiet, int verbose, bool broadcast, bool cleanup)
332{
333 stonith_t *st = NULL;
334 pcmk__output_t *out = NULL;
335 int rc = pcmk_rc_ok;
336
337 rc = pcmk__setup_output_fencing(&out, &st, xml);
338 if (rc != pcmk_rc_ok) {
339 return rc;
340 }
341
342 out->quiet = quiet;
343
344 rc = pcmk__fence_history(out, st, target, timeout, verbose, broadcast,
345 cleanup);
347
348 st->cmds->disconnect(st);
350 return rc;
351}
352
353int
355{
356 stonith_key_value_t *devices = NULL;
357 int rc = pcmk_rc_ok;
358
359 rc = st->cmds->list_agents(st, st_opt_sync_call, NULL, &devices, 0);
360 // rc is a negative error code or a positive number of agents
361 if (rc < 0) {
362 return pcmk_legacy2rc(rc);
363 }
364
365 out->begin_list(out, "fence device", "fence devices",
366 "Installed fence devices");
367 for (stonith_key_value_t *iter = devices; iter != NULL; iter = iter->next) {
368 out->list_item(out, "device", "%s", iter->value);
369 }
370 out->end_list(out);
371
372 stonith__key_value_freeall(devices, true, true);
373 return pcmk_rc_ok;
374}
375
376int
377pcmk_fence_installed(xmlNodePtr *xml, unsigned int timeout)
378{
379 stonith_t *st = NULL;
380 pcmk__output_t *out = NULL;
381 int rc = pcmk_rc_ok;
382
383 rc = pcmk__setup_output_fencing(&out, &st, xml);
384 if (rc != pcmk_rc_ok) {
385 return rc;
386 }
387
388 rc = pcmk__fence_installed(out, st);
390
391 st->cmds->disconnect(st);
393 return rc;
394}
395
396int
397pcmk__fence_last(pcmk__output_t *out, const char *target, bool as_nodeid)
398{
399 time_t when = 0;
400
401 if (target == NULL) {
402 return pcmk_rc_ok;
403 }
404
405 if (as_nodeid) {
406 when = stonith_api_time(atol(target), NULL, FALSE);
407 } else {
408 when = stonith_api_time(0, target, FALSE);
409 }
410
411 return out->message(out, "last-fenced", target, when);
412}
413
414int
415pcmk_fence_last(xmlNodePtr *xml, const char *target, bool as_nodeid)
416{
417 pcmk__output_t *out = NULL;
418 int rc = pcmk_rc_ok;
419
420 rc = pcmk__xml_output_new(&out, xml);
421 if (rc != pcmk_rc_ok) {
422 return rc;
423 }
424
426
427 rc = pcmk__fence_last(out, target, as_nodeid);
429 return rc;
430}
431
432int
434 const char *device_id, unsigned int timeout)
435{
436 GList *targets = NULL;
437 char *lists = NULL;
438 int rc = pcmk_rc_ok;
439
440 rc = st->cmds->list(st, st_opts, device_id, &lists, pcmk__timeout_ms2s(timeout));
441 if (rc != pcmk_rc_ok) {
442 return pcmk_legacy2rc(rc);
443 }
444
445 targets = stonith__parse_targets(lists);
446
447 out->begin_list(out, "fence target", "fence targets", "Fence Targets");
448 while (targets != NULL) {
449 out->list_item(out, NULL, "%s", (const char *) targets->data);
450 targets = targets->next;
451 }
452 out->end_list(out);
453
454 free(lists);
455 return rc;
456}
457
458int
459pcmk_fence_list_targets(xmlNodePtr *xml, const char *device_id, unsigned int timeout)
460{
461 stonith_t *st = NULL;
462 pcmk__output_t *out = NULL;
463 int rc = pcmk_rc_ok;
464
465 rc = pcmk__setup_output_fencing(&out, &st, xml);
466 if (rc != pcmk_rc_ok) {
467 return rc;
468 }
469
470 rc = pcmk__fence_list_targets(out, st, device_id, timeout);
472
473 st->cmds->disconnect(st);
475 return rc;
476}
477
478int
480 unsigned int timeout)
481{
482 char *buffer = NULL;
483 int rc = st->cmds->metadata(st, st_opt_sync_call, agent, NULL, &buffer,
485
486 if (rc != pcmk_rc_ok) {
487 return pcmk_legacy2rc(rc);
488 }
489
490 out->output_xml(out, PCMK_XE_METADATA, buffer);
491 free(buffer);
492 return rc;
493}
494
495int
496pcmk_fence_metadata(xmlNodePtr *xml, const char *agent, unsigned int timeout)
497{
498 stonith_t *st = NULL;
499 pcmk__output_t *out = NULL;
500 int rc = pcmk_rc_ok;
501
502 rc = pcmk__setup_output_fencing(&out, &st, xml);
503 if (rc != pcmk_rc_ok) {
504 return rc;
505 }
506
507 rc = pcmk__fence_metadata(out, st, agent, timeout);
509
510 st->cmds->disconnect(st);
512 return rc;
513}
514
515int
517 unsigned int timeout)
518{
519 stonith_key_value_t *devices = NULL;
520 int rc = pcmk_rc_ok;
521
522 rc = st->cmds->query(st, st_opts, target, &devices, pcmk__timeout_ms2s(timeout));
523 /* query returns a negative error code or a positive number of results. */
524 if (rc < 0) {
525 return pcmk_legacy2rc(rc);
526 }
527
528 out->begin_list(out, "fence device", "fence devices",
529 "Registered fence devices");
530 for (stonith_key_value_t *iter = devices; iter != NULL; iter = iter->next) {
531 out->list_item(out, "device", "%s", iter->value);
532 }
533 out->end_list(out);
534
535 stonith__key_value_freeall(devices, true, true);
536
537 /* Return pcmk_rc_ok here, not the number of results. Callers probably
538 * don't care.
539 */
540 return pcmk_rc_ok;
541}
542
543int
544pcmk_fence_registered(xmlNodePtr *xml, const char *target, unsigned int timeout)
545{
546 stonith_t *st = NULL;
547 pcmk__output_t *out = NULL;
548 int rc = pcmk_rc_ok;
549
550 rc = pcmk__setup_output_fencing(&out, &st, xml);
551 if (rc != pcmk_rc_ok) {
552 return rc;
553 }
554
557
558 st->cmds->disconnect(st);
560 return rc;
561}
562
563int
564pcmk__fence_register_level(stonith_t *st, const char *target, int fence_level,
565 GList *devices)
566{
567 return handle_level(st, target, fence_level, devices, true);
568}
569
570int
571pcmk_fence_register_level(xmlNodePtr *xml, const char *target, int fence_level,
572 GList *devices)
573{
574 stonith_t* st = NULL;
575 pcmk__output_t *out = NULL;
576 int rc = pcmk_rc_ok;
577
578 rc = pcmk__setup_output_fencing(&out, &st, xml);
579 if (rc != pcmk_rc_ok) {
580 return rc;
581 }
582
583 rc = pcmk__fence_register_level(st, target, fence_level, devices);
585
586 st->cmds->disconnect(st);
588 return rc;
589}
590
591int
592pcmk__fence_unregister_level(stonith_t *st, const char *target, int fence_level)
593{
594 return handle_level(st, target, fence_level, NULL, false);
595}
596
597int
598pcmk_fence_unregister_level(xmlNodePtr *xml, const char *target, int fence_level)
599{
600 stonith_t* st = NULL;
601 pcmk__output_t *out = NULL;
602 int rc = pcmk_rc_ok;
603
604 rc = pcmk__setup_output_fencing(&out, &st, xml);
605 if (rc != pcmk_rc_ok) {
606 return rc;
607 }
608
609 rc = pcmk__fence_unregister_level(st, target, fence_level);
611
612 st->cmds->disconnect(st);
614 return rc;
615}
616
617int
619 const char *id, GHashTable *params, unsigned int timeout)
620{
621 char *output = NULL;
622 char *error_output = NULL;
623 int rc;
624
625 rc = stonith__validate(st, st_opt_sync_call, id, agent, params,
626 pcmk__timeout_ms2s(timeout), &output, &error_output);
627 out->message(out, "validate", agent, id, output, error_output, rc);
628 return pcmk_legacy2rc(rc);
629}
630
631int
632pcmk_fence_validate(xmlNodePtr *xml, const char *agent, const char *id,
633 GHashTable *params, unsigned int timeout)
634{
635 stonith_t *st = NULL;
636 pcmk__output_t *out = NULL;
637 int rc = pcmk_rc_ok;
638
639 rc = pcmk__setup_output_fencing(&out, &st, xml);
640 if (rc != pcmk_rc_ok) {
641 return rc;
642 }
643
644 rc = pcmk__fence_validate(out, st, agent, id, params, timeout);
646
647 st->cmds->disconnect(st);
649 return rc;
650}
651
652int
654 enum pcmk__fence_history fence_history)
655{
656 int rc = pcmk_rc_ok;
657
658 if ((st == NULL) || (st->state == stonith_disconnected)) {
659 rc = ENOTCONN;
660 } else if (fence_history != pcmk__fence_history_none) {
661 rc = st->cmds->history(st, st_opt_sync_call, NULL, stonith_history,
662 120);
663
664 rc = pcmk_legacy2rc(rc);
665 if (rc != pcmk_rc_ok) {
666 return rc;
667 }
668
669 *stonith_history = stonith__sort_history(*stonith_history);
670 if (fence_history == pcmk__fence_history_reduced) {
671 *stonith_history = reduce_fence_history(*stonith_history);
672 }
673 }
674
675 return rc;
676}
guint pcmk__timeout_ms2s(guint timeout_ms)
Definition utils.c:429
char data[0]
Definition cpg.c:10
const char * stonith__exit_reason(const stonith_callback_data_t *data)
Definition st_client.c:2667
int stonith__api_connect_retry(stonith_t *stonith, const char *name, int max_attempts)
Definition st_client.c:1958
GList * stonith__parse_targets(const char *hosts)
Definition st_client.c:2300
void stonith__api_free(stonith_t *stonith_api)
Definition st_client.c:1939
int stonith__exit_status(const stonith_callback_data_t *data)
Definition st_client.c:2633
stonith_key_value_t * stonith__key_value_add(stonith_key_value_t *head, const char *key, const char *value)
Definition st_client.c:1995
stonith_history_t * stonith__sort_history(stonith_history_t *history)
Definition st_client.c:2387
#define stonith__set_call_options(st_call_opts, call_for, flags_to_set)
Definition internal.h:40
int stonith__validate(stonith_t *st, int call_options, const char *rsc_id, const char *agent, GHashTable *params, int timeout_sec, char **output, char **error_output)
Definition st_client.c:1742
int stonith__execution_status(const stonith_callback_data_t *data)
Definition st_client.c:2650
int stonith__result2rc(const pcmk__action_result_t *result)
Definition st_actions.c:316
void stonith__key_value_freeall(stonith_key_value_t *head, bool keys, bool values)
Definition st_client.c:2033
int stonith__event_exit_status(const stonith_event_t *event)
Definition st_client.c:2684
void stonith__history_free(stonith_history_t *head)
Definition st_client.c:776
int stonith__event_execution_status(const stonith_event_t *event)
Definition st_client.c:2704
const char * stonith__later_succeeded(const stonith_history_t *event, const stonith_history_t *top_history)
Definition st_client.c:2347
const char * stonith__event_exit_reason(const stonith_event_t *event)
Definition st_client.c:2724
void stonith__register_messages(pcmk__output_t *out)
Definition st_output.c:623
G_GNUC_INTERNAL int pcmk__setup_output_fencing(pcmk__output_t **out, stonith_t **st, xmlNode **xml)
Definition pcmk_setup.c:97
Wrappers for and extensions to glib mainloop.
void mainloop_set_trigger(crm_trigger_t *source)
Definition mainloop.c:195
crm_trigger_t * mainloop_add_trigger(int priority, int(*dispatch)(gpointer user_data), gpointer userdata)
Create a trigger to be used as a mainloop source.
Definition mainloop.c:183
struct trigger_s crm_trigger_t
Definition mainloop.h:39
#define PCMK__VALUE_ST_NOTIFY_FENCE
Control output from tools.
@ pcmk_show_failed_detail
Definition output.h:67
Formatted output for pacemaker tools.
void pcmk__xml_output_finish(pcmk__output_t *out, crm_exit_t exit_status, xmlNodePtr *xml)
Definition output.c:273
int pcmk__xml_output_new(pcmk__output_t **out, xmlNodePtr *xml)
Definition output.c:246
High Level API.
int pcmk_fence_list_targets(xmlNodePtr *xml, const char *device_id, unsigned int timeout)
List nodes that can be fenced.
Definition pcmk_fence.c:459
int pcmk__request_fencing(stonith_t *st, const char *target, const char *action, const char *name, unsigned int timeout, unsigned int tolerance, int delay, char **reason)
Ask the cluster to perform fencing.
Definition pcmk_fence.c:195
int pcmk__fence_metadata(pcmk__output_t *out, stonith_t *st, const char *agent, unsigned int timeout)
Get metadata for a fence agent.
Definition pcmk_fence.c:479
int pcmk__fence_registered(pcmk__output_t *out, stonith_t *st, const char *target, unsigned int timeout)
List registered fence devices.
Definition pcmk_fence.c:516
unsigned int timeout
Definition pcmk_fence.c:34
int pcmk__fence_register_level(stonith_t *st, const char *target, int fence_level, GList *devices)
Register a fencing level for a specific node, node regex, or attribute.
Definition pcmk_fence.c:564
int pcmk__get_fencing_history(stonith_t *st, stonith_history_t **stonith_history, enum pcmk__fence_history fence_history)
Fetch fencing history, optionally reducing it.
Definition pcmk_fence.c:653
int pcmk_fence_validate(xmlNodePtr *xml, const char *agent, const char *id, GHashTable *params, unsigned int timeout)
Validate a fence device configuration.
Definition pcmk_fence.c:632
int pcmk_fence_installed(xmlNodePtr *xml, unsigned int timeout)
List all installed fence agents.
Definition pcmk_fence.c:377
char * name
Definition pcmk_fence.c:33
int delay
Definition pcmk_fence.c:36
unsigned int tolerance
Definition pcmk_fence.c:35
int pcmk__fence_list_targets(pcmk__output_t *out, stonith_t *st, const char *device_id, unsigned int timeout)
List nodes that can be fenced.
Definition pcmk_fence.c:433
stonith_t * st
Definition pcmk_fence.c:30
int pcmk_request_fencing(xmlNodePtr *xml, const char *target, const char *action, const char *name, unsigned int timeout, unsigned int tolerance, int delay, char **reason)
Ask the cluster to perform fencing.
Definition pcmk_fence.c:231
int pcmk_fence_history(xmlNodePtr *xml, const char *target, unsigned int timeout, bool quiet, int verbose, bool broadcast, bool cleanup)
List the fencing operations that have occurred for a specific node.
Definition pcmk_fence.c:330
int pcmk_fence_unregister_level(xmlNodePtr *xml, const char *target, int fence_level)
Unregister a fencing topology level.
Definition pcmk_fence.c:598
const char * action
Definition pcmk_fence.c:32
int pcmk_fence_registered(xmlNodePtr *xml, const char *target, unsigned int timeout)
List registered fence devices.
Definition pcmk_fence.c:544
int pcmk_fence_metadata(xmlNodePtr *xml, const char *agent, unsigned int timeout)
Get metadata for a fence agent.
Definition pcmk_fence.c:496
int pcmk_fence_register_level(xmlNodePtr *xml, const char *target, int fence_level, GList *devices)
Register a fencing topology level.
Definition pcmk_fence.c:571
int pcmk__fence_last(pcmk__output_t *out, const char *target, bool as_nodeid)
When was a device last fenced?
Definition pcmk_fence.c:397
int pcmk_fence_last(xmlNodePtr *xml, const char *target, bool as_nodeid)
When was a device last fenced?
Definition pcmk_fence.c:415
pcmk__action_result_t result
Definition pcmk_fence.c:37
int pcmk__fence_unregister_level(stonith_t *st, const char *target, int fence_level)
Unregister a fencing level for specific node, node regex, or attribute.
Definition pcmk_fence.c:592
int pcmk__fence_installed(pcmk__output_t *out, stonith_t *st)
List all installed fence agents.
Definition pcmk_fence.c:354
int pcmk__fence_validate(pcmk__output_t *out, stonith_t *st, const char *agent, const char *id, GHashTable *params, unsigned int timeout)
Validate a fence device configuration.
Definition pcmk_fence.c:618
const char * target
Definition pcmk_fence.c:31
pcmk__fence_history
Control how much of the fencing history is output.
Definition pcmki_fence.h:22
@ pcmk__fence_history_reduced
Definition pcmki_fence.h:24
@ pcmk__fence_history_none
Definition pcmki_fence.h:23
Function and executable result codes.
const char * pcmk_strerror(int rc)
Definition results.c:257
const char * pcmk_rc_str(int rc)
Get a user-friendly description of a return code.
Definition results.c:617
@ CRM_EX_ERROR
Unspecified error.
Definition results.h:234
@ pcmk_rc_ok
Definition results.h:159
@ PCMK_EXEC_ERROR
Execution failed, may be retried.
Definition results.h:315
@ PCMK_EXEC_UNKNOWN
Used only to initialize variables.
Definition results.h:309
@ PCMK_EXEC_NOT_CONNECTED
No connection to executor.
Definition results.h:319
int pcmk_legacy2rc(int legacy_rc)
Definition results.c:675
crm_exit_t pcmk_rc2exitc(int rc)
Map a function return code to the most similar exit code.
Definition results.c:820
void pcmk__set_result(pcmk__action_result_t *result, int exit_status, enum pcmk_exec_status exec_status, const char *exit_reason)
Definition results.c:1088
void pcmk__reset_result(pcmk__action_result_t *result)
Definition results.c:1177
Fencing aka. STONITH.
time_t stonith_api_time(uint32_t nodeid, const char *uname, bool in_progress)
Definition st_client.c:2095
@ st_opt_cleanup
Definition stonith-ng.h:112
@ st_opt_timeout_updates
Definition stonith-ng.h:104
@ st_opt_broadcast
Definition stonith-ng.h:116
@ st_opt_allow_self_fencing
Definition stonith-ng.h:68
@ st_opt_sync_call
Definition stonith-ng.h:100
@ stonith_disconnected
Definition stonith-ng.h:47
@ st_failed
Definition stonith-ng.h:130
@ st_done
Definition stonith-ng.h:128
@ pcmk__str_none
@ pcmk__str_casei
This structure contains everything that makes up a single output formatter.
void(* end_list)(pcmk__output_t *out)
int(* message)(pcmk__output_t *out, const char *message_id,...)
bool(* is_quiet)(pcmk__output_t *out)
void void void(* increment_list)(pcmk__output_t *out)
int int void void(* output_xml)(pcmk__output_t *out, const char *name, const char *buf)
void(* begin_list)(pcmk__output_t *out, const char *singular_noun, const char *plural_noun, const char *format,...) G_GNUC_PRINTF(4
void void(* list_item)(pcmk__output_t *out, const char *name, const char *format,...) G_GNUC_PRINTF(3
bool quiet
Should this formatter supress most output?
int(* info)(pcmk__output_t *out, const char *format,...) G_GNUC_PRINTF(2
int(* fence_with_delay)(stonith_t *stonith, int call_options, const char *node, const char *action, int timeout, int tolerance, int delay)
Request delayed fencing of a target.
Definition stonith-ng.h:646
int(* register_callback)(stonith_t *stonith, int call_id, int timeout, int options, void *user_data, const char *callback_name, void(*callback)(stonith_t *st, stonith_callback_data_t *data))
Register a callback for an asynchronous fencing result.
Definition stonith-ng.h:528
int(* query)(stonith_t *stonith, int call_options, const char *target, stonith_key_value_t **devices, int timeout)
List registered fence devices.
Definition stonith-ng.h:432
int(* register_notification)(stonith_t *stonith, const char *event, void(*callback)(stonith_t *st, stonith_event_t *e))
Register a callback for fence notifications.
Definition stonith-ng.h:495
int(* disconnect)(stonith_t *st)
Disconnect from the local stonith daemon.
Definition stonith-ng.h:260
int(* list)(stonith_t *stonith, int call_options, const char *id, char **list_info, int timeout)
Get the output of a fence device's list action.
Definition stonith-ng.h:382
int(* remove_level_full)(stonith_t *st, int options, const char *node, const char *pattern, const char *attr, const char *value, int level)
Unregister fencing level for specified node, pattern or attribute.
Definition stonith-ng.h:570
int(* list_agents)(stonith_t *stonith, int call_options, const char *namespace_s, stonith_key_value_t **devices, int timeout)
Retrieve a list of installed fence agents.
Definition stonith-ng.h:365
int(* register_level_full)(stonith_t *st, int options, const char *node, const char *pattern, const char *attr, const char *value, int level, const stonith_key_value_t *device_list)
Register fencing level for specified node, pattern or attribute.
Definition stonith-ng.h:598
int(* history)(stonith_t *stonith, int call_options, const char *node, stonith_history_t **history, int timeout)
List fencing actions that have occurred for a target.
Definition stonith-ng.h:482
int(* metadata)(stonith_t *stonith, int call_options, const char *agent, const char *namespace_s, char **output, int timeout_sec)
Retrieve a fence agent's metadata.
Definition stonith-ng.h:344
Data for an asynchronous fencing request callback.
Definition stonith-ng.h:216
Fencing event.
Definition stonith-ng.h:194
Fencing history entry.
Definition stonith-ng.h:173
struct stonith_history_s * next
Definition stonith-ng.h:181
Key-value pair list node.
Definition stonith-ng.h:162
struct stonith_key_value_s * next
Definition stonith-ng.h:165
Fencer API connection object.
Definition stonith-ng.h:657
enum stonith_state state
Definition stonith-ng.h:658
stonith_api_operations_t * cmds
Definition stonith-ng.h:661
#define PCMK_XE_METADATA
Definition xml_names.h:131