pacemaker 2.1.4-dc6eb4362e
Scalable High-Availability cluster resource manager
pcmk_injections.c
Go to the documentation of this file.
1/*
2 * Copyright 2009-2022 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/lrmd.h> // lrmd_event_data_t, lrmd_free_event()
23#include <crm/cib.h>
24#include <crm/cib/internal.h>
25#include <crm/common/util.h>
26#include <crm/common/iso8601.h>
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 "//" XML_CIB_TAG_NODE "[@uname='%s']"
37#define XPATH_NODE_STATE "//" XML_CIB_TAG_STATE "[@uname='%s']"
38#define XPATH_RSC_HISTORY XPATH_NODE_STATE "//" \
39 XML_LRM_TAG_RESOURCE "[@id='%s']"
40
41
51static void
52inject_transient_attr(pcmk__output_t *out, xmlNode *cib_node,
53 const char *name, const char *value)
54{
55 xmlNode *attrs = NULL;
56 xmlNode *instance_attrs = NULL;
57 const char *node_uuid = ID(cib_node);
58
59 out->message(out, "inject-attr", name, value, cib_node);
60
62 if (attrs == NULL) {
64 crm_xml_add(attrs, XML_ATTR_ID, node_uuid);
65 }
66
67 instance_attrs = first_named_child(attrs, XML_TAG_ATTR_SETS);
68 if (instance_attrs == NULL) {
69 instance_attrs = create_xml_node(attrs, XML_TAG_ATTR_SETS);
70 crm_xml_add(instance_attrs, XML_ATTR_ID, node_uuid);
71 }
72
73 crm_create_nvpair_xml(instance_attrs, NULL, name, value);
74}
75
88void
89pcmk__inject_failcount(pcmk__output_t *out, xmlNode *cib_node,
90 const char *resource, const char *task,
91 guint interval_ms, int rc)
92{
93 if (rc == 0) {
94 return;
95
96 } else if ((rc == 7) && (interval_ms == 0)) {
97 return;
98
99 } else {
100 char *name = NULL;
101 char *now = pcmk__ttoa(time(NULL));
102
103 name = pcmk__failcount_name(resource, task, interval_ms);
104 inject_transient_attr(out, cib_node, name, "value++");
105 free(name);
106
107 name = pcmk__lastfailure_name(resource, task, interval_ms);
108 inject_transient_attr(out, cib_node, name, now);
109 free(name);
110
111 free(now);
112 }
113}
114
122static void
123create_node_entry(cib_t *cib_conn, const char *node)
124{
125 int rc = pcmk_ok;
126 char *xpath = crm_strdup_printf(XPATH_NODE_CONFIG, node);
127
128 rc = cib_conn->cmds->query(cib_conn, xpath, NULL,
130
131 if (rc == -ENXIO) { // Only add if not already existing
132 xmlNode *cib_object = create_xml_node(NULL, XML_CIB_TAG_NODE);
133
134 crm_xml_add(cib_object, XML_ATTR_ID, node); // Use node name as ID
135 crm_xml_add(cib_object, XML_ATTR_UNAME, node);
136 cib_conn->cmds->create(cib_conn, XML_CIB_TAG_NODES, cib_object,
138 /* Not bothering with subsequent query to see if it exists,
139 we'll bomb out later in the call to query_node_uuid()... */
140
141 free_xml(cib_object);
142 }
143
144 free(xpath);
145}
146
160static lrmd_event_data_t *
161create_op(xmlNode *cib_resource, const char *task, guint interval_ms,
162 int outcome)
163{
164 lrmd_event_data_t *op = NULL;
165 xmlNode *xop = NULL;
166
167 op = lrmd_new_event(ID(cib_resource), task, interval_ms);
168 lrmd__set_result(op, outcome, PCMK_EXEC_DONE, "Simulated action result");
169 op->params = NULL; // Not needed for simulation purposes
170 op->t_run = (unsigned int) time(NULL);
171 op->t_rcchange = op->t_run;
172
173 // Use a call ID higher than any existing history entries
174 op->call_id = 0;
175 for (xop = pcmk__xe_first_child(cib_resource); xop != NULL;
176 xop = pcmk__xe_next(xop)) {
177
178 int tmp = 0;
179
181 if (tmp > op->call_id) {
182 op->call_id = tmp;
183 }
184 }
185 op->call_id++;
186
187 return op;
188}
189
200xmlNode *
202 int target_rc)
203{
204 return pcmk__create_history_xml(cib_resource, op, CRM_FEATURE_SET,
205 target_rc, NULL, crm_system_name);
206}
207
221xmlNode *
222pcmk__inject_node(cib_t *cib_conn, const char *node, const char *uuid)
223{
224 int rc = pcmk_ok;
225 xmlNode *cib_object = NULL;
226 char *xpath = crm_strdup_printf(XPATH_NODE_STATE, node);
227
229 create_node_entry(cib_conn, node);
230 }
231
232 rc = cib_conn->cmds->query(cib_conn, xpath, &cib_object,
234
235 if ((cib_object != NULL) && (ID(cib_object) == NULL)) {
236 crm_err("Detected multiple node_state entries for xpath=%s, bailing",
237 xpath);
238 crm_log_xml_warn(cib_object, "Duplicates");
239 free(xpath);
241 return NULL; // not reached, but makes static analysis happy
242 }
243
244 if (rc == -ENXIO) {
245 char *found_uuid = NULL;
246
247 if (uuid == NULL) {
248 query_node_uuid(cib_conn, node, &found_uuid, NULL);
249 } else {
250 found_uuid = strdup(uuid);
251 }
252
253 cib_object = create_xml_node(NULL, XML_CIB_TAG_STATE);
254 crm_xml_add(cib_object, XML_ATTR_UUID, found_uuid);
255 crm_xml_add(cib_object, XML_ATTR_UNAME, node);
256 cib_conn->cmds->create(cib_conn, XML_CIB_TAG_STATUS, cib_object,
258 free_xml(cib_object);
259 free(found_uuid);
260
261 rc = cib_conn->cmds->query(cib_conn, xpath, &cib_object,
263 crm_trace("Injecting node state for %s (rc=%d)", node, rc);
264 }
265
266 free(xpath);
267 CRM_ASSERT(rc == pcmk_ok);
268 return cib_object;
269}
270
281xmlNode *
282pcmk__inject_node_state_change(cib_t *cib_conn, const char *node, bool up)
283{
284 xmlNode *cib_node = pcmk__inject_node(cib_conn, node, NULL);
285
286 if (up) {
287 pcmk__xe_set_props(cib_node,
292 NULL);
293 } else {
294 pcmk__xe_set_props(cib_node,
299 NULL);
300 }
302 return cib_node;
303}
304
315static xmlNode *
316find_resource_xml(xmlNode *cib_node, const char *resource)
317{
318 const char *node = crm_element_value(cib_node, XML_ATTR_UNAME);
319 char *xpath = crm_strdup_printf(XPATH_RSC_HISTORY, node, resource);
320 xmlNode *match = get_xpath_object(xpath, cib_node, LOG_TRACE);
321
322 free(xpath);
323 return match;
324}
325
342xmlNode *
344 const char *resource, const char *lrm_name,
345 const char *rclass, const char *rtype,
346 const char *rprovider)
347{
348 xmlNode *lrm = NULL;
349 xmlNode *container = NULL;
350 xmlNode *cib_resource = NULL;
351
352 cib_resource = find_resource_xml(cib_node, resource);
353 if (cib_resource != NULL) {
354 /* If an existing LRM history entry uses the resource name,
355 * continue using it, even if lrm_name is different.
356 */
357 return cib_resource;
358 }
359
360 // Check for history entry under preferred name
361 if (strcmp(resource, lrm_name) != 0) {
362 cib_resource = find_resource_xml(cib_node, lrm_name);
363 if (cib_resource != NULL) {
364 return cib_resource;
365 }
366 }
367
368 if ((rclass == NULL) || (rtype == NULL)) {
369 // @TODO query configuration for class, provider, type
370 out->err(out, "Resource %s not found in the status section of %s."
371 " Please supply the class and type to continue", resource, ID(cib_node));
372 return NULL;
373
374 } else if (!pcmk__strcase_any_of(rclass,
381 out->err(out, "Invalid class for %s: %s", resource, rclass);
382 return NULL;
383
385 && (rprovider == NULL)) {
386 // @TODO query configuration for provider
387 out->err(out, "Please specify the provider for resource %s", resource);
388 return NULL;
389 }
390
391 crm_info("Injecting new resource %s into node state '%s'",
392 lrm_name, ID(cib_node));
393
394 lrm = first_named_child(cib_node, XML_CIB_TAG_LRM);
395 if (lrm == NULL) {
396 const char *node_uuid = ID(cib_node);
397
398 lrm = create_xml_node(cib_node, XML_CIB_TAG_LRM);
399 crm_xml_add(lrm, XML_ATTR_ID, node_uuid);
400 }
401
403 if (container == NULL) {
404 container = create_xml_node(lrm, XML_LRM_TAG_RESOURCES);
405 }
406
407 cib_resource = create_xml_node(container, XML_LRM_TAG_RESOURCE);
408
409 // If we're creating a new entry, use the preferred name
410 crm_xml_add(cib_resource, XML_ATTR_ID, lrm_name);
411
412 crm_xml_add(cib_resource, XML_AGENT_ATTR_CLASS, rclass);
413 crm_xml_add(cib_resource, XML_AGENT_ATTR_PROVIDER, rprovider);
414 crm_xml_add(cib_resource, XML_ATTR_TYPE, rtype);
415
416 return cib_resource;
417}
418
419#define XPATH_MAX 1024
420
421static int
422find_ticket_state(pcmk__output_t *out, cib_t *the_cib, const char *ticket_id,
423 xmlNode **ticket_state_xml)
424{
425 int offset = 0;
426 int rc = pcmk_ok;
427 xmlNode *xml_search = NULL;
428
429 char *xpath_string = NULL;
430
431 CRM_ASSERT(ticket_state_xml != NULL);
432 *ticket_state_xml = NULL;
433
434 xpath_string = calloc(1, XPATH_MAX);
435 offset += snprintf(xpath_string + offset, XPATH_MAX - offset, "%s", "/cib/status/tickets");
436
437 if (ticket_id) {
438 offset += snprintf(xpath_string + offset, XPATH_MAX - offset, "/%s[@id=\"%s\"]",
439 XML_CIB_TAG_TICKET_STATE, ticket_id);
440 }
441 CRM_LOG_ASSERT(offset > 0);
442 rc = the_cib->cmds->query(the_cib, xpath_string, &xml_search,
444
445 if (rc != pcmk_ok) {
446 goto bail;
447 }
448
449 crm_log_xml_debug(xml_search, "Match");
450 if (xml_has_children(xml_search)) {
451 if (ticket_id) {
452 out->err(out, "Multiple ticket_states match ticket_id=%s", ticket_id);
453 }
454 *ticket_state_xml = xml_search;
455 } else {
456 *ticket_state_xml = xml_search;
457 }
458
459 bail:
460 free(xpath_string);
461 return rc;
462}
463
476static int
477set_ticket_state_attr(pcmk__output_t *out, const char *ticket_id,
478 const char *attr_name, bool attr_value, cib_t *cib)
479{
480 int rc = pcmk_rc_ok;
481 xmlNode *xml_top = NULL;
482 xmlNode *ticket_state_xml = NULL;
483
484 // Check for an existing ticket state entry
485 rc = find_ticket_state(out, cib, ticket_id, &ticket_state_xml);
486 rc = pcmk_legacy2rc(rc);
487
488 if (rc == pcmk_rc_ok) { // Ticket state found, use it
489 crm_debug("Injecting attribute into existing ticket state %s",
490 ticket_id);
491 xml_top = ticket_state_xml;
492
493 } else if (rc == ENXIO) { // No ticket state, create it
494 xmlNode *xml_obj = NULL;
495
496 xml_top = create_xml_node(NULL, XML_CIB_TAG_STATUS);
497 xml_obj = create_xml_node(xml_top, XML_CIB_TAG_TICKETS);
498 ticket_state_xml = create_xml_node(xml_obj, XML_CIB_TAG_TICKET_STATE);
499 crm_xml_add(ticket_state_xml, XML_ATTR_ID, ticket_id);
500
501 } else { // Error
502 return rc;
503 }
504
505 // Add the attribute to the ticket state
506 pcmk__xe_set_bool_attr(ticket_state_xml, attr_name, attr_value);
507 crm_log_xml_debug(xml_top, "Update");
508
509 // Commit the change to the CIB
510 rc = cib->cmds->modify(cib, XML_CIB_TAG_STATUS, xml_top,
512 rc = pcmk_legacy2rc(rc);
513
514 free_xml(xml_top);
515 return rc;
516}
517
527static void
528inject_action(pcmk__output_t *out, const char *spec, cib_t *cib,
530{
531 int rc;
532 int outcome = PCMK_OCF_OK;
533 guint interval_ms = 0;
534
535 char *key = NULL;
536 char *node = NULL;
537 char *task = NULL;
538 char *resource = NULL;
539
540 const char *rtype = NULL;
541 const char *rclass = NULL;
542 const char *rprovider = NULL;
543
544 xmlNode *cib_op = NULL;
545 xmlNode *cib_node = NULL;
546 xmlNode *cib_resource = NULL;
547 pe_resource_t *rsc = NULL;
548 lrmd_event_data_t *op = NULL;
549
550 out->message(out, "inject-spec", spec);
551
552 key = calloc(1, strlen(spec) + 1);
553 node = calloc(1, strlen(spec) + 1);
554 rc = sscanf(spec, "%[^@]@%[^=]=%d", key, node, &outcome);
555 if (rc != 3) {
556 out->err(out, "Invalid operation spec: %s. Only found %d fields",
557 spec, rc);
558 goto done;
559 }
560
561 parse_op_key(key, &resource, &task, &interval_ms);
562
563 rsc = pe_find_resource(data_set->resources, resource);
564 if (rsc == NULL) {
565 out->err(out, "Invalid resource name: %s", resource);
566 goto done;
567 }
568
570 rtype = crm_element_value(rsc->xml, XML_ATTR_TYPE);
572
573 cib_node = pcmk__inject_node(cib, node, NULL);
574 CRM_ASSERT(cib_node != NULL);
575
576 pcmk__inject_failcount(out, cib_node, resource, task, interval_ms, outcome);
577
578 cib_resource = pcmk__inject_resource_history(out, cib_node,
579 resource, resource,
580 rclass, rtype, rprovider);
581 CRM_ASSERT(cib_resource != NULL);
582
583 op = create_op(cib_resource, task, interval_ms, outcome);
584 CRM_ASSERT(op != NULL);
585
586 cib_op = pcmk__inject_action_result(cib_resource, op, 0);
587 CRM_ASSERT(cib_op != NULL);
588 lrmd_free_event(op);
589
590 rc = cib->cmds->modify(cib, XML_CIB_TAG_STATUS, cib_node,
592 CRM_ASSERT(rc == pcmk_ok);
593
594done:
595 free(task);
596 free(node);
597 free(key);
598}
599
608void
610 pcmk_injections_t *injections)
611{
612 int rc = pcmk_ok;
613 GList *iter = NULL;
614 xmlNode *cib_node = NULL;
616
617 out->message(out, "inject-modify-config", injections->quorum,
618 injections->watchdog);
619 if (injections->quorum != NULL) {
620 xmlNode *top = create_xml_node(NULL, XML_TAG_CIB);
621
622 /* crm_xml_add(top, XML_ATTR_DC_UUID, dc_uuid); */
623 crm_xml_add(top, XML_ATTR_HAVE_QUORUM, injections->quorum);
624
625 rc = cib->cmds->modify(cib, NULL, top, cib_sync_call|cib_scope_local);
626 CRM_ASSERT(rc == pcmk_ok);
627 }
628
629 if (injections->watchdog != NULL) {
631 XML_CIB_TAG_CRMCONFIG, NULL, NULL, NULL, NULL,
632 XML_ATTR_HAVE_WATCHDOG, injections->watchdog,
633 NULL, NULL);
634 CRM_ASSERT(rc == pcmk_rc_ok);
635 }
636
637 for (iter = injections->node_up; iter != NULL; iter = iter->next) {
638 char *node = (char *) iter->data;
639
640 out->message(out, "inject-modify-node", "Online", node);
641
642 cib_node = pcmk__inject_node_state_change(cib, node, true);
643 CRM_ASSERT(cib_node != NULL);
644
645 rc = cib->cmds->modify(cib, XML_CIB_TAG_STATUS, cib_node,
647 CRM_ASSERT(rc == pcmk_ok);
648 free_xml(cib_node);
649 }
650
651 for (iter = injections->node_down; iter != NULL; iter = iter->next) {
652 char *node = (char *) iter->data;
653 char *xpath = NULL;
654
655 out->message(out, "inject-modify-node", "Offline", node);
656
657 cib_node = pcmk__inject_node_state_change(cib, node, false);
658 CRM_ASSERT(cib_node != NULL);
659
660 rc = cib->cmds->modify(cib, XML_CIB_TAG_STATUS, cib_node,
662 CRM_ASSERT(rc == pcmk_ok);
663 free_xml(cib_node);
664
665 xpath = crm_strdup_printf("//node_state[@uname='%s']/%s",
666 node, XML_CIB_TAG_LRM);
667 cib->cmds->remove(cib, xpath, NULL,
669 free(xpath);
670
671 xpath = crm_strdup_printf("//node_state[@uname='%s']/%s",
673 cib->cmds->remove(cib, xpath, NULL,
675 free(xpath);
676 }
677
678 for (iter = injections->node_fail; iter != NULL; iter = iter->next) {
679 char *node = (char *) iter->data;
680
681 out->message(out, "inject-modify-node", "Failing", node);
682
683 cib_node = pcmk__inject_node_state_change(cib, node, true);
685 CRM_ASSERT(cib_node != NULL);
686
687 rc = cib->cmds->modify(cib, XML_CIB_TAG_STATUS, cib_node,
689 CRM_ASSERT(rc == pcmk_ok);
690 free_xml(cib_node);
691 }
692
693 for (iter = injections->ticket_grant; iter != NULL; iter = iter->next) {
694 char *ticket_id = (char *) iter->data;
695
696 out->message(out, "inject-modify-ticket", "Granting", ticket_id);
697
698 rc = set_ticket_state_attr(out, ticket_id, "granted", true, cib);
699 CRM_ASSERT(rc == pcmk_rc_ok);
700 }
701
702 for (iter = injections->ticket_revoke; iter != NULL; iter = iter->next) {
703 char *ticket_id = (char *) iter->data;
704
705 out->message(out, "inject-modify-ticket", "Revoking", ticket_id);
706
707 rc = set_ticket_state_attr(out, ticket_id, "granted", false, cib);
708 CRM_ASSERT(rc == pcmk_rc_ok);
709 }
710
711 for (iter = injections->ticket_standby; iter != NULL; iter = iter->next) {
712 char *ticket_id = (char *) iter->data;
713
714 out->message(out, "inject-modify-ticket", "Standby", ticket_id);
715
716 rc = set_ticket_state_attr(out, ticket_id, "standby", true, cib);
717 CRM_ASSERT(rc == pcmk_rc_ok);
718 }
719
720 for (iter = injections->ticket_activate; iter != NULL; iter = iter->next) {
721 char *ticket_id = (char *) iter->data;
722
723 out->message(out, "inject-modify-ticket", "Activating", ticket_id);
724
725 rc = set_ticket_state_attr(out, ticket_id, "standby", false, cib);
726 CRM_ASSERT(rc == pcmk_rc_ok);
727 }
728
729 for (iter = injections->op_inject; iter != NULL; iter = iter->next) {
730 inject_action(out, (char *) iter->data, cib, data_set);
731 }
732
733 if (!out->is_quiet(out)) {
734 out->end_list(out);
735 }
736}
737
738void
740{
741 if (injections == NULL) {
742 return;
743 }
744
745 g_list_free_full(injections->node_up, g_free);
746 g_list_free_full(injections->node_down, g_free);
747 g_list_free_full(injections->node_fail, g_free);
748 g_list_free_full(injections->op_fail, g_free);
749 g_list_free_full(injections->op_inject, g_free);
750 g_list_free_full(injections->ticket_grant, g_free);
751 g_list_free_full(injections->ticket_revoke, g_free);
752 g_list_free_full(injections->ticket_standby, g_free);
753 g_list_free_full(injections->ticket_activate, g_free);
754 free(injections->quorum);
755 free(injections->watchdog);
756
757 free(injections);
758}
uint32_t pcmk_get_ra_caps(const char *standard)
Get capabilities of a resource agent standard.
Definition: agents.c:31
@ pcmk_ra_cap_provider
Definition: agents.h:47
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:188
int query_node_uuid(cib_t *the_cib, const char *uname, char **uuid, int *is_remote_node)
Definition: cib_attrs.c:597
const char * name
Definition: cib.c:24
Cluster Configuration.
@ cib_scope_local
Definition: cib_types.h:59
@ cib_xpath
Definition: cib_types.h:52
@ cib_sync_call
Definition: cib_types.h:61
void pcmk__xe_set_bool_attr(xmlNodePtr node, const char *name, bool value)
Definition: nvpair.c:954
Utility functions.
gboolean parse_op_key(const char *key, char **rsc_id, char **op_type, guint *interval_ms)
Definition: operations.c:185
#define ONLINESTATUS
Definition: util.h:39
#define OFFLINESTATUS
Definition: util.h:40
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:122
A dumping ground.
#define CRMD_JOINSTATE_DOWN
Definition: crm.h:163
#define CRM_FEATURE_SET
Definition: crm.h:69
char * crm_system_name
Definition: utils.c:54
#define CRMD_JOINSTATE_MEMBER
Definition: crm.h:165
ISO_8601 Date handling.
#define crm_info(fmt, args...)
Definition: logging.h:361
#define crm_log_xml_debug(xml, text)
Definition: logging.h:371
#define CRM_LOG_ASSERT(expr)
Definition: logging.h:210
#define crm_debug(fmt, args...)
Definition: logging.h:363
#define crm_err(fmt, args...)
Definition: logging.h:358
#define crm_log_xml_warn(xml, text)
Definition: logging.h:368
#define crm_trace(fmt, args...)
Definition: logging.h:364
#define LOG_TRACE
Definition: logging.h:37
Resource agent executor.
void lrmd_free_event(lrmd_event_data_t *event)
Free an executor event.
Definition: lrmd_client.c:243
lrmd_event_data_t * lrmd_new_event(const char *rsc_id, const char *task, guint interval_ms)
Definition: lrmd_client.c:195
void lrmd__set_result(lrmd_event_data_t *event, enum ocf_exitcode rc, int op_status, const char *exit_reason)
Definition: lrmd_client.c:2356
#define XML_TAG_CIB
Definition: msg_xml.h:115
#define XML_BOOLEAN_NO
Definition: msg_xml.h:149
#define ID(x)
Definition: msg_xml.h:460
#define XML_BOOLEAN_YES
Definition: msg_xml.h:148
#define XML_ATTR_HAVE_WATCHDOG
Definition: msg_xml.h:125
#define XML_ATTR_UNAME
Definition: msg_xml.h:157
#define XML_CIB_TAG_TICKET_STATE
Definition: msg_xml.h:433
#define XML_TAG_TRANSIENT_NODEATTRS
Definition: msg_xml.h:409
#define XML_ATTR_UUID
Definition: msg_xml.h:158
#define XML_NODE_IS_PEER
Definition: msg_xml.h:284
#define XML_LRM_TAG_RESOURCES
Definition: msg_xml.h:269
#define XML_CIB_TAG_STATE
Definition: msg_xml.h:204
#define XML_NODE_JOIN_STATE
Definition: msg_xml.h:281
#define XML_CIB_TAG_CRMCONFIG
Definition: msg_xml.h:190
#define XML_CIB_TAG_TICKETS
Definition: msg_xml.h:432
#define XML_TAG_ATTR_SETS
Definition: msg_xml.h:209
#define XML_ATTR_ID
Definition: msg_xml.h:135
#define XML_NODE_IN_CLUSTER
Definition: msg_xml.h:283
#define XML_ATTR_HAVE_QUORUM
Definition: msg_xml.h:124
#define XML_AGENT_ATTR_PROVIDER
Definition: msg_xml.h:273
#define XML_AGENT_ATTR_CLASS
Definition: msg_xml.h:272
#define XML_ATTR_ORIGIN
Definition: msg_xml.h:130
#define XML_NODE_EXPECTED
Definition: msg_xml.h:282
#define XML_ATTR_TYPE
Definition: msg_xml.h:138
#define XML_CIB_TAG_NODES
Definition: msg_xml.h:187
#define XML_CIB_TAG_STATUS
Definition: msg_xml.h:185
#define XML_LRM_ATTR_CALLID
Definition: msg_xml.h:315
#define XML_CIB_TAG_LRM
Definition: msg_xml.h:268
#define XML_CIB_TAG_NODE
Definition: msg_xml.h:205
#define XML_LRM_TAG_RESOURCE
Definition: msg_xml.h:270
pe_working_set_t * data_set
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
Definition: nvpair.c:529
int crm_element_value_int(const xmlNode *data, const char *name, int *dest)
Retrieve the integer value of an XML attribute.
Definition: nvpair.c:565
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:845
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:323
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
void pcmk__inject_failcount(pcmk__output_t *out, xmlNode *cib_node, const char *resource, const char *task, guint interval_ms, int rc)
void pcmk__inject_scheduler_input(pe_working_set_t *data_set, cib_t *cib, pcmk_injections_t *injections)
#define XPATH_NODE_STATE
#define XPATH_MAX
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)
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)
#define CRM_ASSERT(expr)
Definition: results.h:42
@ CRM_EX_SOFTWARE
Internal software bug.
Definition: results.h:257
_Noreturn crm_exit_t crm_exit(crm_exit_t rc)
Definition: results.c:775
@ PCMK_OCF_OK
Success.
Definition: results.h:162
@ pcmk_rc_ok
Definition: results.h:146
#define pcmk_ok
Definition: results.h:68
@ PCMK_EXEC_DONE
Action completed, result is known.
Definition: results.h:308
int pcmk_legacy2rc(int legacy_rc)
Definition: results.c:428
#define PCMK_RESOURCE_CLASS_SYSTEMD
Definition: services.h:42
#define PCMK_RESOURCE_CLASS_SERVICE
Definition: services.h:40
#define PCMK_RESOURCE_CLASS_STONITH
Definition: services.h:45
#define PCMK_RESOURCE_CLASS_OCF
Definition: services.h:39
#define PCMK_RESOURCE_CLASS_UPSTART
Definition: services.h:43
#define PCMK_RESOURCE_CLASS_LSB
Definition: services.h:41
Cluster status and scheduling.
pe_resource_t * pe_find_resource(GList *rsc_list, const char *id_rh)
Definition: status.c:391
bool pcmk__strcase_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
Definition: strings.c:931
int(* create)(cib_t *cib, const char *section, xmlNode *data, int call_options)
Definition: cib_types.h:105
int(* remove)(cib_t *cib, const char *section, xmlNode *data, int call_options)
Definition: cib_types.h:113
int(* query)(cib_t *cib, const char *section, xmlNode **output_data, int call_options)
Definition: cib_types.h:92
int(* modify)(cib_t *cib, const char *section, xmlNode *data, int call_options)
Definition: cib_types.h:107
cib_api_operations_t * cmds
Definition: cib_types.h:147
unsigned int t_run
Definition: lrmd.h:229
unsigned int t_rcchange
Definition: lrmd.h:231
void * params
Definition: lrmd.h:242
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(*) 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 * node_up
Definition: pacemaker.h:52
GList * op_inject
Definition: pacemaker.h:61
GList * op_fail
Definition: pacemaker.h:66
GList * ticket_standby
Definition: pacemaker.h:72
xmlNode * xml
Definition: pe_types.h:338
GList * resources
Definition: pe_types.h:165
gboolean xml_has_children(const xmlNode *root)
Definition: xml.c:2028
xmlNode * first_named_child(const xmlNode *parent, const char *name)
Definition: xml.c:2794
xmlNode * get_xpath_object(const char *xpath, xmlNode *xml_obj, int error_level)
Definition: xpath.c:214
void free_xml(xmlNode *child)
Definition: xml.c:824
xmlNode * create_xml_node(xmlNode *parent, const char *name)
Definition: xml.c:696
void pcmk__xe_set_props(xmlNodePtr node,...) G_GNUC_NULL_TERMINATED
Definition: xml.c:2974