pacemaker 2.1.8-2.1.8
Scalable High-Availability cluster resource manager
Loading...
Searching...
No Matches
pcmk_injections.c
Go to the documentation of this file.
1/*
2 * Copyright 2009-2024 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
12#include <stdio.h>
13#include <unistd.h>
14#include <stdlib.h>
15
16#include <sys/stat.h>
17#include <sys/param.h>
18#include <sys/types.h>
19#include <dirent.h>
20
21#include <crm/crm.h>
22#include <crm/cib.h>
23#include <crm/cib/internal.h>
24#include <crm/common/util.h>
25#include <crm/common/iso8601.h>
27#include <crm/lrmd_events.h> // lrmd_event_data_t, etc.
28#include <crm/lrmd_internal.h>
29#include <crm/pengine/status.h>
30#include <pacemaker-internal.h>
31
33
35
36#define XPATH_NODE_CONFIG "//" PCMK_XE_NODE "[@" PCMK_XA_UNAME "='%s']"
37#define XPATH_NODE_STATE "//" PCMK__XE_NODE_STATE "[@" PCMK_XA_UNAME "='%s']"
38#define XPATH_NODE_STATE_BY_ID "//" PCMK__XE_NODE_STATE "[@" PCMK_XA_ID "='%s']"
39#define XPATH_RSC_HISTORY XPATH_NODE_STATE \
40 "//" PCMK__XE_LRM_RESOURCE "[@" PCMK_XA_ID "='%s']"
41
42
52static void
53inject_transient_attr(pcmk__output_t *out, xmlNode *cib_node,
54 const char *name, const char *value)
55{
56 xmlNode *attrs = NULL;
57 xmlNode *instance_attrs = NULL;
58 const char *node_uuid = pcmk__xe_id(cib_node);
59
60 out->message(out, "inject-attr", name, value, cib_node);
61
63 NULL);
64 if (attrs == NULL) {
66 crm_xml_add(attrs, PCMK_XA_ID, node_uuid);
67 }
68
70 NULL, NULL);
71 if (instance_attrs == NULL) {
72 instance_attrs = pcmk__xe_create(attrs, PCMK_XE_INSTANCE_ATTRIBUTES);
73 crm_xml_add(instance_attrs, PCMK_XA_ID, node_uuid);
74 }
75
76 crm_create_nvpair_xml(instance_attrs, NULL, name, value);
77}
78
93void
94pcmk__inject_failcount(pcmk__output_t *out, cib_t *cib_conn, xmlNode *cib_node,
95 const char *resource, const char *task,
96 guint interval_ms, int exit_status)
97{
98 char *name = NULL;
99 char *value = NULL;
100
101 int failcount = 0;
102 xmlNode *output = NULL;
103
104 CRM_CHECK((out != NULL) && (cib_conn != NULL) && (cib_node != NULL)
105 && (resource != NULL) && (task != NULL), return);
106
107 if ((exit_status == PCMK_OCF_OK)
108 || ((exit_status == PCMK_OCF_NOT_RUNNING) && (interval_ms == 0))) {
109 return;
110 }
111
112 // Get current failcount and increment it
113 name = pcmk__failcount_name(resource, task, interval_ms);
114
115 if (cib__get_node_attrs(out, cib_conn, PCMK_XE_STATUS,
116 pcmk__xe_id(cib_node), NULL, NULL, NULL, name,
117 NULL, &output) == pcmk_rc_ok) {
118
119 if (crm_element_value_int(output, PCMK_XA_VALUE, &failcount) != 0) {
120 failcount = 0;
121 }
122 }
123 value = pcmk__itoa(failcount + 1);
124 inject_transient_attr(out, cib_node, name, value);
125
126 free(name);
127 free(value);
128 free_xml(output);
129
130 name = pcmk__lastfailure_name(resource, task, interval_ms);
131 value = pcmk__ttoa(time(NULL));
132 inject_transient_attr(out, cib_node, name, value);
133
134 free(name);
135 free(value);
136}
137
145static void
146create_node_entry(cib_t *cib_conn, const char *node)
147{
148 int rc = pcmk_ok;
149 char *xpath = crm_strdup_printf(XPATH_NODE_CONFIG, node);
150
151 rc = cib_conn->cmds->query(cib_conn, xpath, NULL,
153
154 if (rc == -ENXIO) { // Only add if not already existing
155 xmlNode *cib_object = pcmk__xe_create(NULL, PCMK_XE_NODE);
156
157 crm_xml_add(cib_object, PCMK_XA_ID, node); // Use node name as ID
158 crm_xml_add(cib_object, PCMK_XA_UNAME, node);
159 cib_conn->cmds->create(cib_conn, PCMK_XE_NODES, cib_object,
161 /* Not bothering with subsequent query to see if it exists,
162 we'll bomb out later in the call to query_node_uuid()... */
163
164 free_xml(cib_object);
165 }
166
167 free(xpath);
168}
169
183static lrmd_event_data_t *
184create_op(const xmlNode *cib_resource, const char *task, guint interval_ms,
185 int outcome)
186{
187 lrmd_event_data_t *op = NULL;
188 xmlNode *xop = NULL;
189
190 op = lrmd_new_event(pcmk__xe_id(cib_resource), task, interval_ms);
191 lrmd__set_result(op, outcome, PCMK_EXEC_DONE, "Simulated action result");
192 op->params = NULL; // Not needed for simulation purposes
193 op->t_run = (unsigned int) time(NULL);
194 op->t_rcchange = op->t_run;
195
196 // Use a call ID higher than any existing history entries
197 op->call_id = 0;
198 for (xop = pcmk__xe_first_child(cib_resource, NULL, NULL, NULL);
199 xop != NULL; xop = pcmk__xe_next(xop)) {
200
201 int tmp = 0;
202
204 if (tmp > op->call_id) {
205 op->call_id = tmp;
206 }
207 }
208 op->call_id++;
209
210 return op;
211}
212
223xmlNode *
225 int target_rc)
226{
227 return pcmk__create_history_xml(cib_resource, op, CRM_FEATURE_SET,
228 target_rc, NULL, crm_system_name);
229}
230
244xmlNode *
245pcmk__inject_node(cib_t *cib_conn, const char *node, const char *uuid)
246{
247 int rc = pcmk_ok;
248 xmlNode *cib_object = NULL;
249 char *xpath = crm_strdup_printf(XPATH_NODE_STATE, node);
250 bool duplicate = false;
251 char *found_uuid = NULL;
252
254 create_node_entry(cib_conn, node);
255 }
256
257 rc = cib_conn->cmds->query(cib_conn, xpath, &cib_object,
259
260 if ((cib_object != NULL) && (pcmk__xe_id(cib_object) == NULL)) {
261 crm_err("Detected multiple " PCMK__XE_NODE_STATE " entries for "
262 "xpath=%s, bailing",
263 xpath);
264 duplicate = true;
265 goto done;
266 }
267
268 if (rc == -ENXIO) {
269 if (uuid == NULL) {
270 query_node_uuid(cib_conn, node, &found_uuid, NULL);
271 } else {
272 found_uuid = strdup(uuid);
273 }
274
275 if (found_uuid) {
276 char *xpath_by_uuid = crm_strdup_printf(XPATH_NODE_STATE_BY_ID,
277 found_uuid);
278
279 /* It's possible that a PCMK__XE_NODE_STATE entry doesn't have a
280 * PCMK_XA_UNAME yet
281 */
282 rc = cib_conn->cmds->query(cib_conn, xpath_by_uuid, &cib_object,
284
285 if ((cib_object != NULL) && (pcmk__xe_id(cib_object) == NULL)) {
286 crm_err("Can't inject node state for %s because multiple "
287 "state entries found for ID %s", node, found_uuid);
288 duplicate = true;
289 free(xpath_by_uuid);
290 goto done;
291
292 } else if (cib_object != NULL) {
293 crm_xml_add(cib_object, PCMK_XA_UNAME, node);
294
295 rc = cib_conn->cmds->modify(cib_conn, PCMK_XE_STATUS,
296 cib_object,
298 }
299
300 free(xpath_by_uuid);
301 }
302 }
303
304 if (rc == -ENXIO) {
305 cib_object = pcmk__xe_create(NULL, PCMK__XE_NODE_STATE);
306 crm_xml_add(cib_object, PCMK_XA_ID, found_uuid);
307 crm_xml_add(cib_object, PCMK_XA_UNAME, node);
308 cib_conn->cmds->create(cib_conn, PCMK_XE_STATUS, cib_object,
310 free_xml(cib_object);
311
312 rc = cib_conn->cmds->query(cib_conn, xpath, &cib_object,
314 crm_trace("Injecting node state for %s (rc=%d)", node, rc);
315 }
316
317done:
318 free(found_uuid);
319 free(xpath);
320
321 if (duplicate) {
322 crm_log_xml_warn(cib_object, "Duplicates");
324 return NULL; // not reached, but makes static analysis happy
325 }
326
327 CRM_ASSERT(rc == pcmk_ok);
328 return cib_object;
329}
330
341xmlNode *
342pcmk__inject_node_state_change(cib_t *cib_conn, const char *node, bool up)
343{
344 xmlNode *cib_node = pcmk__inject_node(cib_conn, node, NULL);
345
346 if (up) {
347 pcmk__xe_set_props(cib_node,
352 NULL);
353 } else {
354 pcmk__xe_set_props(cib_node,
359 NULL);
360 }
362 return cib_node;
363}
364
375static xmlNode *
376find_resource_xml(xmlNode *cib_node, const char *resource)
377{
378 const char *node = crm_element_value(cib_node, PCMK_XA_UNAME);
379 char *xpath = crm_strdup_printf(XPATH_RSC_HISTORY, node, resource);
380 xmlNode *match = get_xpath_object(xpath, cib_node, LOG_TRACE);
381
382 free(xpath);
383 return match;
384}
385
402xmlNode *
404 const char *resource, const char *lrm_name,
405 const char *rclass, const char *rtype,
406 const char *rprovider)
407{
408 xmlNode *lrm = NULL;
409 xmlNode *container = NULL;
410 xmlNode *cib_resource = NULL;
411
412 cib_resource = find_resource_xml(cib_node, resource);
413 if (cib_resource != NULL) {
414 /* If an existing LRM history entry uses the resource name,
415 * continue using it, even if lrm_name is different.
416 */
417 return cib_resource;
418 }
419
420 // Check for history entry under preferred name
421 if (strcmp(resource, lrm_name) != 0) {
422 cib_resource = find_resource_xml(cib_node, lrm_name);
423 if (cib_resource != NULL) {
424 return cib_resource;
425 }
426 }
427
428 if ((rclass == NULL) || (rtype == NULL)) {
429 // @TODO query configuration for class, provider, type
430 out->err(out,
431 "Resource %s not found in the status section of %s "
432 "(supply class and type to continue)",
433 resource, pcmk__xe_id(cib_node));
434 return NULL;
435
436 } else if (!pcmk__strcase_any_of(rclass,
443 out->err(out, "Invalid class for %s: %s", resource, rclass);
444 return NULL;
445
447 && (rprovider == NULL)) {
448 // @TODO query configuration for provider
449 out->err(out, "Please specify the provider for resource %s", resource);
450 return NULL;
451 }
452
453 crm_info("Injecting new resource %s into node state '%s'",
454 lrm_name, pcmk__xe_id(cib_node));
455
456 lrm = pcmk__xe_first_child(cib_node, PCMK__XE_LRM, NULL, NULL);
457 if (lrm == NULL) {
458 const char *node_uuid = pcmk__xe_id(cib_node);
459
460 lrm = pcmk__xe_create(cib_node, PCMK__XE_LRM);
461 crm_xml_add(lrm, PCMK_XA_ID, node_uuid);
462 }
463
464 container = pcmk__xe_first_child(lrm, PCMK__XE_LRM_RESOURCES, NULL, NULL);
465 if (container == NULL) {
466 container = pcmk__xe_create(lrm, PCMK__XE_LRM_RESOURCES);
467 }
468
469 cib_resource = pcmk__xe_create(container, PCMK__XE_LRM_RESOURCE);
470
471 // If we're creating a new entry, use the preferred name
472 crm_xml_add(cib_resource, PCMK_XA_ID, lrm_name);
473
474 crm_xml_add(cib_resource, PCMK_XA_CLASS, rclass);
475 crm_xml_add(cib_resource, PCMK_XA_PROVIDER, rprovider);
476 crm_xml_add(cib_resource, PCMK_XA_TYPE, rtype);
477
478 return cib_resource;
479}
480
493static int
494set_ticket_state_attr(pcmk__output_t *out, const char *ticket_id,
495 const char *attr_name, bool attr_value, cib_t *cib)
496{
497 int rc = pcmk_rc_ok;
498 xmlNode *xml_top = NULL;
499 xmlNode *ticket_state_xml = NULL;
500
501 // Check for an existing ticket state entry
502 rc = pcmk__get_ticket_state(cib, ticket_id, &ticket_state_xml);
503
504 if (rc == pcmk_rc_duplicate_id) {
505 out->err(out, "Multiple " PCMK__XE_TICKET_STATE "s match ticket_id=%s",
506 ticket_id);
507 rc = pcmk_rc_ok;
508 }
509
510 if (rc == pcmk_rc_ok) { // Ticket state found, use it
511 crm_debug("Injecting attribute into existing ticket state %s",
512 ticket_id);
513 xml_top = ticket_state_xml;
514
515 } else if (rc == ENXIO) { // No ticket state, create it
516 xmlNode *xml_obj = NULL;
517
518 xml_top = pcmk__xe_create(NULL, PCMK_XE_STATUS);
519 xml_obj = pcmk__xe_create(xml_top, PCMK_XE_TICKETS);
520 ticket_state_xml = pcmk__xe_create(xml_obj, PCMK__XE_TICKET_STATE);
521 crm_xml_add(ticket_state_xml, PCMK_XA_ID, ticket_id);
522
523 } else { // Error
524 return rc;
525 }
526
527 // Add the attribute to the ticket state
528 pcmk__xe_set_bool_attr(ticket_state_xml, attr_name, attr_value);
529 crm_log_xml_debug(xml_top, "Update");
530
531 // Commit the change to the CIB
532 rc = cib->cmds->modify(cib, PCMK_XE_STATUS, xml_top,
534 rc = pcmk_legacy2rc(rc);
535
536 free_xml(xml_top);
537 return rc;
538}
539
549static void
550inject_action(pcmk__output_t *out, const char *spec, cib_t *cib,
552{
553 int rc;
554 int outcome = PCMK_OCF_OK;
555 guint interval_ms = 0;
556
557 char *key = NULL;
558 char *node = NULL;
559 char *task = NULL;
560 char *resource = NULL;
561
562 const char *rtype = NULL;
563 const char *rclass = NULL;
564 const char *rprovider = NULL;
565
566 xmlNode *cib_op = NULL;
567 xmlNode *cib_node = NULL;
568 xmlNode *cib_resource = NULL;
569 const pcmk_resource_t *rsc = NULL;
570 lrmd_event_data_t *op = NULL;
571
572 out->message(out, "inject-spec", spec);
573
574 key = pcmk__assert_alloc(1, strlen(spec) + 1);
575 node = pcmk__assert_alloc(1, strlen(spec) + 1);
576 rc = sscanf(spec, "%[^@]@%[^=]=%d", key, node, &outcome);
577 if (rc != 3) {
578 out->err(out, "Invalid operation spec: %s. Only found %d fields",
579 spec, rc);
580 goto done;
581 }
582
583 parse_op_key(key, &resource, &task, &interval_ms);
584
585 rsc = pe_find_resource(scheduler->resources, resource);
586 if (rsc == NULL) {
587 out->err(out, "Invalid resource name: %s", resource);
588 goto done;
589 }
590
591 rclass = crm_element_value(rsc->xml, PCMK_XA_CLASS);
592 rtype = crm_element_value(rsc->xml, PCMK_XA_TYPE);
593 rprovider = crm_element_value(rsc->xml, PCMK_XA_PROVIDER);
594
595 cib_node = pcmk__inject_node(cib, node, NULL);
596 CRM_ASSERT(cib_node != NULL);
597
598 pcmk__inject_failcount(out, cib, cib_node, resource, task, interval_ms,
599 outcome);
600
601 cib_resource = pcmk__inject_resource_history(out, cib_node,
602 resource, resource,
603 rclass, rtype, rprovider);
604 CRM_ASSERT(cib_resource != NULL);
605
606 op = create_op(cib_resource, task, interval_ms, outcome);
607 CRM_ASSERT(op != NULL);
608
609 cib_op = pcmk__inject_action_result(cib_resource, op, 0);
610 CRM_ASSERT(cib_op != NULL);
611 lrmd_free_event(op);
612
613 rc = cib->cmds->modify(cib, PCMK_XE_STATUS, cib_node,
615 CRM_ASSERT(rc == pcmk_ok);
616
617done:
618 free(task);
619 free(node);
620 free(key);
621}
622
631void
633 const pcmk_injections_t *injections)
634{
635 int rc = pcmk_ok;
636 const GList *iter = NULL;
637 xmlNode *cib_node = NULL;
639
640 out->message(out, "inject-modify-config", injections->quorum,
641 injections->watchdog);
642 if (injections->quorum != NULL) {
643 xmlNode *top = pcmk__xe_create(NULL, PCMK_XE_CIB);
644
645 /* crm_xml_add(top, PCMK_XA_DC_UUID, dc_uuid); */
646 crm_xml_add(top, PCMK_XA_HAVE_QUORUM, injections->quorum);
647
648 rc = cib->cmds->modify(cib, NULL, top, cib_sync_call|cib_scope_local);
649 CRM_ASSERT(rc == pcmk_ok);
650 }
651
652 if (injections->watchdog != NULL) {
654 PCMK_XE_CRM_CONFIG, NULL, NULL, NULL,
656 injections->watchdog, NULL, NULL);
657 CRM_ASSERT(rc == pcmk_rc_ok);
658 }
659
660 for (iter = injections->node_up; iter != NULL; iter = iter->next) {
661 const char *node = (const char *) iter->data;
662
663 out->message(out, "inject-modify-node", "Online", node);
664
665 cib_node = pcmk__inject_node_state_change(cib, node, true);
666 CRM_ASSERT(cib_node != NULL);
667
668 rc = cib->cmds->modify(cib, PCMK_XE_STATUS, cib_node,
670 CRM_ASSERT(rc == pcmk_ok);
671 free_xml(cib_node);
672 }
673
674 for (iter = injections->node_down; iter != NULL; iter = iter->next) {
675 const char *node = (const char *) iter->data;
676 char *xpath = NULL;
677
678 out->message(out, "inject-modify-node", "Offline", node);
679
680 cib_node = pcmk__inject_node_state_change(cib, node, false);
681 CRM_ASSERT(cib_node != NULL);
682
683 rc = cib->cmds->modify(cib, PCMK_XE_STATUS, cib_node,
685 CRM_ASSERT(rc == pcmk_ok);
686 free_xml(cib_node);
687
689 "[@" PCMK_XA_UNAME "='%s']"
690 "/" PCMK__XE_LRM,
691 node);
692 cib->cmds->remove(cib, xpath, NULL,
694 free(xpath);
695
697 "[@" PCMK_XA_UNAME "='%s']"
699 node);
700 cib->cmds->remove(cib, xpath, NULL,
702 free(xpath);
703 }
704
705 for (iter = injections->node_fail; iter != NULL; iter = iter->next) {
706 const char *node = (const char *) iter->data;
707
708 out->message(out, "inject-modify-node", "Failing", node);
709
710 cib_node = pcmk__inject_node_state_change(cib, node, true);
712 CRM_ASSERT(cib_node != NULL);
713
714 rc = cib->cmds->modify(cib, PCMK_XE_STATUS, cib_node,
716 CRM_ASSERT(rc == pcmk_ok);
717 free_xml(cib_node);
718 }
719
720 for (iter = injections->ticket_grant; iter != NULL; iter = iter->next) {
721 const char *ticket_id = (const char *) iter->data;
722
723 out->message(out, "inject-modify-ticket", "Granting", ticket_id);
724
725 rc = set_ticket_state_attr(out, ticket_id, PCMK__XA_GRANTED, true, cib);
726 CRM_ASSERT(rc == pcmk_rc_ok);
727 }
728
729 for (iter = injections->ticket_revoke; iter != NULL; iter = iter->next) {
730 const char *ticket_id = (const char *) iter->data;
731
732 out->message(out, "inject-modify-ticket", "Revoking", ticket_id);
733
734 rc = set_ticket_state_attr(out, ticket_id, PCMK__XA_GRANTED, false,
735 cib);
736 CRM_ASSERT(rc == pcmk_rc_ok);
737 }
738
739 for (iter = injections->ticket_standby; iter != NULL; iter = iter->next) {
740 const char *ticket_id = (const char *) iter->data;
741
742 out->message(out, "inject-modify-ticket", "Standby", ticket_id);
743
744 rc = set_ticket_state_attr(out, ticket_id, PCMK_XA_STANDBY, true, cib);
745 CRM_ASSERT(rc == pcmk_rc_ok);
746 }
747
748 for (iter = injections->ticket_activate; iter != NULL; iter = iter->next) {
749 const char *ticket_id = (const char *) iter->data;
750
751 out->message(out, "inject-modify-ticket", "Activating", ticket_id);
752
753 rc = set_ticket_state_attr(out, ticket_id, PCMK_XA_STANDBY, false, cib);
754 CRM_ASSERT(rc == pcmk_rc_ok);
755 }
756
757 for (iter = injections->op_inject; iter != NULL; iter = iter->next) {
758 inject_action(out, (const char *) iter->data, cib, scheduler);
759 }
760
761 if (!out->is_quiet(out)) {
762 out->end_list(out);
763 }
764}
765
766void
768{
769 if (injections == NULL) {
770 return;
771 }
772
773 g_list_free_full(injections->node_up, g_free);
774 g_list_free_full(injections->node_down, g_free);
775 g_list_free_full(injections->node_fail, g_free);
776 g_list_free_full(injections->op_fail, g_free);
777 g_list_free_full(injections->op_inject, g_free);
778 g_list_free_full(injections->ticket_grant, g_free);
779 g_list_free_full(injections->ticket_revoke, g_free);
780 g_list_free_full(injections->ticket_standby, g_free);
781 g_list_free_full(injections->ticket_activate, g_free);
782 free(injections->quorum);
783 free(injections->watchdog);
784
785 free(injections);
786}
gboolean parse_op_key(const char *key, char **rsc_id, char **op_type, guint *interval_ms)
Definition actions.c:250
#define PCMK_RESOURCE_CLASS_SYSTEMD
Definition agents.h:30
uint32_t pcmk_get_ra_caps(const char *standard)
Get capabilities of a resource agent standard.
Definition agents.c:31
#define PCMK_RESOURCE_CLASS_SERVICE
Definition agents.h:28
#define PCMK_RESOURCE_CLASS_STONITH
Definition agents.h:31
#define PCMK_RESOURCE_CLASS_OCF
Definition agents.h:27
@ pcmk_ra_cap_provider
Definition agents.h:59
#define PCMK_RESOURCE_CLASS_UPSTART
Definition agents.h:36
#define PCMK_RESOURCE_CLASS_LSB
Definition agents.h:29
int cib__get_node_attrs(pcmk__output_t *out, cib_t *cib, const char *section, const char *node_uuid, const char *set_type, const char *set_name, const char *attr_id, const char *attr_name, const char *user_name, xmlNode **result)
Definition cib_attrs.c:345
int cib__update_node_attr(pcmk__output_t *out, cib_t *cib, int call_options, const char *section, const char *node_uuid, const char *set_type, const char *set_name, const char *attr_id, const char *attr_name, const char *attr_value, const char *user_name, const char *node_type)
Definition cib_attrs.c:164
int query_node_uuid(cib_t *the_cib, const char *uname, char **uuid, int *is_remote_node)
Definition cib_attrs.c:628
const char * name
Definition cib.c:26
Cluster Configuration.
@ cib_scope_local
Definition cib_types.h:90
@ cib_xpath
Definition cib_types.h:63
@ cib_sync_call
Definition cib_types.h:133
void pcmk__xe_set_bool_attr(xmlNodePtr node, const char *name, bool value)
Definition nvpair.c:903
#define pcmk__assert_alloc(nmemb, size)
Definition internal.h:297
Utility functions.
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
Definition util.h:98
A dumping ground.
#define CRMD_JOINSTATE_DOWN
Definition crm.h:143
#define CRM_FEATURE_SET
Definition crm.h:72
char * crm_system_name
Definition utils.c:50
#define CRMD_JOINSTATE_MEMBER
Definition crm.h:145
ISO_8601 Date handling.
#define crm_info(fmt, args...)
Definition logging.h:397
#define crm_log_xml_debug(xml, text)
Definition logging.h:409
#define CRM_CHECK(expr, failure_action)
Definition logging.h:245
#define crm_debug(fmt, args...)
Definition logging.h:400
#define crm_err(fmt, args...)
Definition logging.h:389
#define crm_log_xml_warn(xml, text)
Definition logging.h:406
#define crm_trace(fmt, args...)
Definition logging.h:402
#define LOG_TRACE
Definition logging.h:38
Resource agent executor events.
void lrmd_free_event(lrmd_event_data_t *event)
Free an executor event.
lrmd_event_data_t * lrmd_new_event(const char *rsc_id, const char *task, guint interval_ms)
Create a new lrmd_event_data_t object.
void lrmd__set_result(lrmd_event_data_t *event, enum ocf_exitcode rc, int op_status, const char *exit_reason)
pcmk_scheduler_t * scheduler
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
Definition nvpair.c:446
int crm_element_value_int(const xmlNode *data, const char *name, int *dest)
Retrieve the integer value of an XML attribute.
Definition nvpair.c:482
xmlNode * crm_create_nvpair_xml(xmlNode *parent, const char *id, const char *name, const char *value)
Create an XML name/value pair.
Definition nvpair.c:799
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
Definition nvpair.c:301
#define PCMK_VALUE_OFFLINE
Definition options.h:183
#define PCMK_VALUE_TRUE
Definition options.h:215
#define PCMK_OPT_HAVE_WATCHDOG
Definition options.h:40
#define PCMK_VALUE_FALSE
Definition options.h:152
#define PCMK_VALUE_ONLINE
Definition options.h:184
xmlNode * pcmk__inject_action_result(xmlNode *cib_resource, lrmd_event_data_t *op, int target_rc)
#define XPATH_NODE_CONFIG
void pcmk_free_injections(pcmk_injections_t *injections)
Free a :pcmk_injections_t structure.
xmlNode * pcmk__inject_node(cib_t *cib_conn, const char *node, const char *uuid)
#define XPATH_RSC_HISTORY
bool pcmk__simulate_node_config
#define XPATH_NODE_STATE_BY_ID
#define XPATH_NODE_STATE
void pcmk__inject_scheduler_input(pcmk_scheduler_t *scheduler, cib_t *cib, const pcmk_injections_t *injections)
xmlNode * pcmk__inject_resource_history(pcmk__output_t *out, xmlNode *cib_node, const char *resource, const char *lrm_name, const char *rclass, const char *rtype, const char *rprovider)
xmlNode * pcmk__inject_node_state_change(cib_t *cib_conn, const char *node, bool up)
void pcmk__inject_failcount(pcmk__output_t *out, cib_t *cib_conn, xmlNode *cib_node, const char *resource, const char *task, guint interval_ms, int exit_status)
xmlNode * pcmk__create_history_xml(xmlNode *parent, lrmd_event_data_t *event, const char *caller_version, int target_rc, const char *node, const char *origin)
int pcmk__get_ticket_state(cib_t *cib, const char *ticket_id, xmlNode **state)
Definition pcmk_ticket.c:76
#define CRM_ASSERT(expr)
Definition results.h:42
@ CRM_EX_SOFTWARE
Internal software bug.
Definition results.h:275
_Noreturn crm_exit_t crm_exit(crm_exit_t rc)
Definition results.c:936
@ PCMK_OCF_NOT_RUNNING
Service safely stopped.
Definition results.h:190
@ PCMK_OCF_OK
Success.
Definition results.h:178
@ pcmk_rc_ok
Definition results.h:162
@ pcmk_rc_duplicate_id
Definition results.h:124
#define pcmk_ok
Definition results.h:69
@ PCMK_EXEC_DONE
Action completed, result is known.
Definition results.h:333
int pcmk_legacy2rc(int legacy_rc)
Definition results.c:559
Cluster status and scheduling.
pcmk_resource_t * pe_find_resource(GList *rsc_list, const char *id_rh)
Definition status.c:430
bool pcmk__strcase_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
Definition strings.c:1026
int(* create)(cib_t *cib, const char *section, xmlNode *data, int call_options)
Definition cib_types.h:226
int(* remove)(cib_t *cib, const char *section, xmlNode *data, int call_options)
Definition cib_types.h:237
int(* query)(cib_t *cib, const char *section, xmlNode **output_data, int call_options)
Definition cib_types.h:198
int(* modify)(cib_t *cib, const char *section, xmlNode *data, int call_options)
Definition cib_types.h:228
cib_api_operations_t * cmds
Definition cib_types.h:399
unsigned int t_run
Definition lrmd_events.h:72
unsigned int t_rcchange
Definition lrmd_events.h:75
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)
int(*) int(*) void(* err)(pcmk__output_t *out, const char *format,...) G_GNUC_PRINTF(2
Synthetic cluster events that can be injected into the cluster for running simulations.
Definition pacemaker.h:50
GList * node_down
Definition pacemaker.h:54
GList * ticket_activate
Definition pacemaker.h:74
GList * ticket_grant
Definition pacemaker.h:68
GList * ticket_revoke
Definition pacemaker.h:70
GList * node_fail
Definition pacemaker.h:56
GList * op_inject
Definition pacemaker.h:61
GList * ticket_standby
Definition pacemaker.h:72
xmlNode * xml
Definition resources.h:400
GList * resources
Definition scheduler.h:231
xmlNode * get_xpath_object(const char *xpath, xmlNode *xml_obj, int error_level)
Definition xpath.c:189
void free_xml(xmlNode *child)
Definition xml.c:867
xmlNode * pcmk__xe_first_child(const xmlNode *parent, const char *node_name, const char *attr_n, const char *attr_v)
Definition xml.c:440
xmlNode * pcmk__xe_create(xmlNode *parent, const char *name)
Definition xml.c:720
void pcmk__xe_set_props(xmlNodePtr node,...) G_GNUC_NULL_TERMINATED
Definition xml.c:2279
#define PCMK_XE_CIB
Definition xml_names.h:79
#define PCMK_XE_STATUS
Definition xml_names.h:199
#define PCMK_XA_CLASS
Definition xml_names.h:241
#define PCMK_XE_NODE
Definition xml_names.h:133
#define PCMK_XE_CRM_CONFIG
Definition xml_names.h:91
#define PCMK_XA_ID
Definition xml_names.h:296
#define PCMK_XA_CRMD
Definition xml_names.h:251
#define PCMK_XE_TICKETS
Definition xml_names.h:208
#define PCMK_XA_PROVIDER
Definition xml_names.h:359
#define PCMK_XE_INSTANCE_ATTRIBUTES
Definition xml_names.h:119
#define PCMK_XA_HAVE_QUORUM
Definition xml_names.h:290
#define PCMK_XA_VALUE
Definition xml_names.h:437
#define PCMK_XA_TYPE
Definition xml_names.h:425
#define PCMK_XA_CRM_DEBUG_ORIGIN
Definition xml_names.h:248
#define PCMK_XA_STANDBY
Definition xml_names.h:401
#define PCMK_XA_EXPECTED
Definition xml_names.h:273
#define PCMK_XE_NODES
Definition xml_names.h:139
#define PCMK_XA_UNAME
Definition xml_names.h:426
#define PCMK__XE_LRM_RESOURCE
#define PCMK__XE_TRANSIENT_ATTRIBUTES
#define PCMK__XE_LRM_RESOURCES
#define PCMK__XA_CALL_ID
#define PCMK__XA_JOIN
#define PCMK__XA_IN_CCM
#define PCMK__XA_GRANTED
#define PCMK__XE_NODE_STATE
#define PCMK__XE_LRM
#define PCMK__XE_TICKET_STATE