pacemaker  2.1.7-0f7f88312f
Scalable High-Availability cluster resource manager
pcmk_injections.c
Go to the documentation of this file.
1 /*
2  * Copyright 2009-2023 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 
32 #include "libpacemaker_private.h"
33 
35 
36 #define XPATH_NODE_CONFIG "//" XML_CIB_TAG_NODE "[@" XML_ATTR_UNAME "='%s']"
37 #define XPATH_NODE_STATE "//" XML_CIB_TAG_STATE "[@" XML_ATTR_UNAME "='%s']"
38 #define XPATH_NODE_STATE_BY_ID "//" XML_CIB_TAG_STATE "[@" XML_ATTR_ID "='%s']"
39 #define XPATH_RSC_HISTORY XPATH_NODE_STATE \
40  "//" XML_LRM_TAG_RESOURCE "[@" XML_ATTR_ID "='%s']"
41 
42 
52 static void
53 inject_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 = ID(cib_node);
59 
60  out->message(out, "inject-attr", name, value, cib_node);
61 
63  if (attrs == NULL) {
65  crm_xml_add(attrs, XML_ATTR_ID, node_uuid);
66  }
67 
68  instance_attrs = first_named_child(attrs, XML_TAG_ATTR_SETS);
69  if (instance_attrs == NULL) {
70  instance_attrs = create_xml_node(attrs, XML_TAG_ATTR_SETS);
71  crm_xml_add(instance_attrs, XML_ATTR_ID, node_uuid);
72  }
73 
74  crm_create_nvpair_xml(instance_attrs, NULL, name, value);
75 }
76 
89 void
90 pcmk__inject_failcount(pcmk__output_t *out, xmlNode *cib_node,
91  const char *resource, const char *task,
92  guint interval_ms, int rc)
93 {
94  if (rc == 0) {
95  return;
96 
97  } else if ((rc == 7) && (interval_ms == 0)) {
98  return;
99 
100  } else {
101  char *name = NULL;
102  char *now = pcmk__ttoa(time(NULL));
103 
104  name = pcmk__failcount_name(resource, task, interval_ms);
105  inject_transient_attr(out, cib_node, name, "value++");
106  free(name);
107 
108  name = pcmk__lastfailure_name(resource, task, interval_ms);
109  inject_transient_attr(out, cib_node, name, now);
110  free(name);
111 
112  free(now);
113  }
114 }
115 
123 static void
124 create_node_entry(cib_t *cib_conn, const char *node)
125 {
126  int rc = pcmk_ok;
127  char *xpath = crm_strdup_printf(XPATH_NODE_CONFIG, node);
128 
129  rc = cib_conn->cmds->query(cib_conn, xpath, NULL,
131 
132  if (rc == -ENXIO) { // Only add if not already existing
133  xmlNode *cib_object = create_xml_node(NULL, XML_CIB_TAG_NODE);
134 
135  crm_xml_add(cib_object, XML_ATTR_ID, node); // Use node name as ID
136  crm_xml_add(cib_object, XML_ATTR_UNAME, node);
137  cib_conn->cmds->create(cib_conn, XML_CIB_TAG_NODES, cib_object,
139  /* Not bothering with subsequent query to see if it exists,
140  we'll bomb out later in the call to query_node_uuid()... */
141 
142  free_xml(cib_object);
143  }
144 
145  free(xpath);
146 }
147 
161 static lrmd_event_data_t *
162 create_op(const xmlNode *cib_resource, const char *task, guint interval_ms,
163  int outcome)
164 {
165  lrmd_event_data_t *op = NULL;
166  xmlNode *xop = NULL;
167 
168  op = lrmd_new_event(ID(cib_resource), task, interval_ms);
169  lrmd__set_result(op, outcome, PCMK_EXEC_DONE, "Simulated action result");
170  op->params = NULL; // Not needed for simulation purposes
171  op->t_run = (unsigned int) time(NULL);
172  op->t_rcchange = op->t_run;
173 
174  // Use a call ID higher than any existing history entries
175  op->call_id = 0;
176  for (xop = pcmk__xe_first_child(cib_resource); xop != NULL;
177  xop = pcmk__xe_next(xop)) {
178 
179  int tmp = 0;
180 
182  if (tmp > op->call_id) {
183  op->call_id = tmp;
184  }
185  }
186  op->call_id++;
187 
188  return op;
189 }
190 
201 xmlNode *
203  int target_rc)
204 {
205  return pcmk__create_history_xml(cib_resource, op, CRM_FEATURE_SET,
206  target_rc, NULL, crm_system_name);
207 }
208 
222 xmlNode *
223 pcmk__inject_node(cib_t *cib_conn, const char *node, const char *uuid)
224 {
225  int rc = pcmk_ok;
226  xmlNode *cib_object = NULL;
227  char *xpath = crm_strdup_printf(XPATH_NODE_STATE, node);
228  bool duplicate = false;
229  char *found_uuid = NULL;
230 
232  create_node_entry(cib_conn, node);
233  }
234 
235  rc = cib_conn->cmds->query(cib_conn, xpath, &cib_object,
237 
238  if ((cib_object != NULL) && (ID(cib_object) == NULL)) {
239  crm_err("Detected multiple node_state entries for xpath=%s, bailing",
240  xpath);
241  duplicate = true;
242  goto done;
243  }
244 
245  if (rc == -ENXIO) {
246  if (uuid == NULL) {
247  query_node_uuid(cib_conn, node, &found_uuid, NULL);
248  } else {
249  found_uuid = strdup(uuid);
250  }
251 
252  if (found_uuid) {
253  char *xpath_by_uuid = crm_strdup_printf(XPATH_NODE_STATE_BY_ID,
254  found_uuid);
255 
256  // It's possible that a node_state entry doesn't have an uname yet.
257  rc = cib_conn->cmds->query(cib_conn, xpath_by_uuid, &cib_object,
259 
260  if ((cib_object != NULL) && (ID(cib_object) == NULL)) {
261  crm_err("Can't inject node state for %s because multiple "
262  "state entries found for ID %s", node, found_uuid);
263  duplicate = true;
264  free(xpath_by_uuid);
265  goto done;
266 
267  } else if (cib_object != NULL) {
268  crm_xml_add(cib_object, XML_ATTR_UNAME, node);
269 
270  rc = cib_conn->cmds->modify(cib_conn, XML_CIB_TAG_STATUS,
271  cib_object,
273  }
274 
275  free(xpath_by_uuid);
276  }
277  }
278 
279  if (rc == -ENXIO) {
280  cib_object = create_xml_node(NULL, XML_CIB_TAG_STATE);
281  crm_xml_add(cib_object, XML_ATTR_ID, found_uuid);
282  crm_xml_add(cib_object, XML_ATTR_UNAME, node);
283  cib_conn->cmds->create(cib_conn, XML_CIB_TAG_STATUS, cib_object,
285  free_xml(cib_object);
286 
287  rc = cib_conn->cmds->query(cib_conn, xpath, &cib_object,
289  crm_trace("Injecting node state for %s (rc=%d)", node, rc);
290  }
291 
292 done:
293  free(found_uuid);
294  free(xpath);
295 
296  if (duplicate) {
297  crm_log_xml_warn(cib_object, "Duplicates");
299  return NULL; // not reached, but makes static analysis happy
300  }
301 
302  CRM_ASSERT(rc == pcmk_ok);
303  return cib_object;
304 }
305 
316 xmlNode *
317 pcmk__inject_node_state_change(cib_t *cib_conn, const char *node, bool up)
318 {
319  xmlNode *cib_node = pcmk__inject_node(cib_conn, node, NULL);
320 
321  if (up) {
322  pcmk__xe_set_props(cib_node,
327  NULL);
328  } else {
329  pcmk__xe_set_props(cib_node,
334  NULL);
335  }
337  return cib_node;
338 }
339 
350 static xmlNode *
351 find_resource_xml(xmlNode *cib_node, const char *resource)
352 {
353  const char *node = crm_element_value(cib_node, XML_ATTR_UNAME);
354  char *xpath = crm_strdup_printf(XPATH_RSC_HISTORY, node, resource);
355  xmlNode *match = get_xpath_object(xpath, cib_node, LOG_TRACE);
356 
357  free(xpath);
358  return match;
359 }
360 
377 xmlNode *
379  const char *resource, const char *lrm_name,
380  const char *rclass, const char *rtype,
381  const char *rprovider)
382 {
383  xmlNode *lrm = NULL;
384  xmlNode *container = NULL;
385  xmlNode *cib_resource = NULL;
386 
387  cib_resource = find_resource_xml(cib_node, resource);
388  if (cib_resource != NULL) {
389  /* If an existing LRM history entry uses the resource name,
390  * continue using it, even if lrm_name is different.
391  */
392  return cib_resource;
393  }
394 
395  // Check for history entry under preferred name
396  if (strcmp(resource, lrm_name) != 0) {
397  cib_resource = find_resource_xml(cib_node, lrm_name);
398  if (cib_resource != NULL) {
399  return cib_resource;
400  }
401  }
402 
403  if ((rclass == NULL) || (rtype == NULL)) {
404  // @TODO query configuration for class, provider, type
405  out->err(out,
406  "Resource %s not found in the status section of %s "
407  "(supply class and type to continue)",
408  resource, ID(cib_node));
409  return NULL;
410 
411  } else if (!pcmk__strcase_any_of(rclass,
417  PCMK_RESOURCE_CLASS_LSB, NULL)) {
418  out->err(out, "Invalid class for %s: %s", resource, rclass);
419  return NULL;
420 
422  && (rprovider == NULL)) {
423  // @TODO query configuration for provider
424  out->err(out, "Please specify the provider for resource %s", resource);
425  return NULL;
426  }
427 
428  crm_info("Injecting new resource %s into node state '%s'",
429  lrm_name, ID(cib_node));
430 
431  lrm = first_named_child(cib_node, XML_CIB_TAG_LRM);
432  if (lrm == NULL) {
433  const char *node_uuid = ID(cib_node);
434 
435  lrm = create_xml_node(cib_node, XML_CIB_TAG_LRM);
436  crm_xml_add(lrm, XML_ATTR_ID, node_uuid);
437  }
438 
439  container = first_named_child(lrm, XML_LRM_TAG_RESOURCES);
440  if (container == NULL) {
441  container = create_xml_node(lrm, XML_LRM_TAG_RESOURCES);
442  }
443 
444  cib_resource = create_xml_node(container, XML_LRM_TAG_RESOURCE);
445 
446  // If we're creating a new entry, use the preferred name
447  crm_xml_add(cib_resource, XML_ATTR_ID, lrm_name);
448 
449  crm_xml_add(cib_resource, XML_AGENT_ATTR_CLASS, rclass);
450  crm_xml_add(cib_resource, XML_AGENT_ATTR_PROVIDER, rprovider);
451  crm_xml_add(cib_resource, XML_ATTR_TYPE, rtype);
452 
453  return cib_resource;
454 }
455 
456 static int
457 find_ticket_state(pcmk__output_t *out, cib_t *the_cib, const char *ticket_id,
458  xmlNode **ticket_state_xml)
459 {
460  int rc = pcmk_ok;
461  xmlNode *xml_search = NULL;
462 
463  GString *xpath = g_string_sized_new(256);
464 
465  CRM_ASSERT(ticket_state_xml != NULL);
466  *ticket_state_xml = NULL;
467 
468  g_string_append(xpath,
470  "/" XML_CIB_TAG_TICKETS);
471 
472  if (ticket_id) {
473  pcmk__g_strcat(xpath,
475  "[@" XML_ATTR_ID "=\"", ticket_id, "\"]", NULL);
476  }
477  rc = the_cib->cmds->query(the_cib, (const char *) xpath->str, &xml_search,
479  g_string_free(xpath, TRUE);
480 
481  if (rc != pcmk_ok) {
482  return rc;
483  }
484 
485  crm_log_xml_debug(xml_search, "Match");
486  if ((xml_search->children != NULL) && (ticket_id != NULL)) {
487  out->err(out, "Multiple ticket_states match ticket_id=%s", ticket_id);
488  }
489  *ticket_state_xml = xml_search;
490 
491  return rc;
492 }
493 
506 static int
507 set_ticket_state_attr(pcmk__output_t *out, const char *ticket_id,
508  const char *attr_name, bool attr_value, cib_t *cib)
509 {
510  int rc = pcmk_rc_ok;
511  xmlNode *xml_top = NULL;
512  xmlNode *ticket_state_xml = NULL;
513 
514  // Check for an existing ticket state entry
515  rc = find_ticket_state(out, cib, ticket_id, &ticket_state_xml);
516  rc = pcmk_legacy2rc(rc);
517 
518  if (rc == pcmk_rc_ok) { // Ticket state found, use it
519  crm_debug("Injecting attribute into existing ticket state %s",
520  ticket_id);
521  xml_top = ticket_state_xml;
522 
523  } else if (rc == ENXIO) { // No ticket state, create it
524  xmlNode *xml_obj = NULL;
525 
526  xml_top = create_xml_node(NULL, XML_CIB_TAG_STATUS);
527  xml_obj = create_xml_node(xml_top, XML_CIB_TAG_TICKETS);
528  ticket_state_xml = create_xml_node(xml_obj, XML_CIB_TAG_TICKET_STATE);
529  crm_xml_add(ticket_state_xml, XML_ATTR_ID, ticket_id);
530 
531  } else { // Error
532  return rc;
533  }
534 
535  // Add the attribute to the ticket state
536  pcmk__xe_set_bool_attr(ticket_state_xml, attr_name, attr_value);
537  crm_log_xml_debug(xml_top, "Update");
538 
539  // Commit the change to the CIB
540  rc = cib->cmds->modify(cib, XML_CIB_TAG_STATUS, xml_top,
542  rc = pcmk_legacy2rc(rc);
543 
544  free_xml(xml_top);
545  return rc;
546 }
547 
557 static void
558 inject_action(pcmk__output_t *out, const char *spec, cib_t *cib,
560 {
561  int rc;
562  int outcome = PCMK_OCF_OK;
563  guint interval_ms = 0;
564 
565  char *key = NULL;
566  char *node = NULL;
567  char *task = NULL;
568  char *resource = NULL;
569 
570  const char *rtype = NULL;
571  const char *rclass = NULL;
572  const char *rprovider = NULL;
573 
574  xmlNode *cib_op = NULL;
575  xmlNode *cib_node = NULL;
576  xmlNode *cib_resource = NULL;
577  const pcmk_resource_t *rsc = NULL;
578  lrmd_event_data_t *op = NULL;
579 
580  out->message(out, "inject-spec", spec);
581 
582  key = calloc(1, strlen(spec) + 1);
583  node = calloc(1, strlen(spec) + 1);
584  rc = sscanf(spec, "%[^@]@%[^=]=%d", key, node, &outcome);
585  if (rc != 3) {
586  out->err(out, "Invalid operation spec: %s. Only found %d fields",
587  spec, rc);
588  goto done;
589  }
590 
591  parse_op_key(key, &resource, &task, &interval_ms);
592 
593  rsc = pe_find_resource(scheduler->resources, resource);
594  if (rsc == NULL) {
595  out->err(out, "Invalid resource name: %s", resource);
596  goto done;
597  }
598 
600  rtype = crm_element_value(rsc->xml, XML_ATTR_TYPE);
601  rprovider = crm_element_value(rsc->xml, XML_AGENT_ATTR_PROVIDER);
602 
603  cib_node = pcmk__inject_node(cib, node, NULL);
604  CRM_ASSERT(cib_node != NULL);
605 
606  pcmk__inject_failcount(out, cib_node, resource, task, interval_ms, outcome);
607 
608  cib_resource = pcmk__inject_resource_history(out, cib_node,
609  resource, resource,
610  rclass, rtype, rprovider);
611  CRM_ASSERT(cib_resource != NULL);
612 
613  op = create_op(cib_resource, task, interval_ms, outcome);
614  CRM_ASSERT(op != NULL);
615 
616  cib_op = pcmk__inject_action_result(cib_resource, op, 0);
617  CRM_ASSERT(cib_op != NULL);
618  lrmd_free_event(op);
619 
620  rc = cib->cmds->modify(cib, XML_CIB_TAG_STATUS, cib_node,
622  CRM_ASSERT(rc == pcmk_ok);
623 
624 done:
625  free(task);
626  free(node);
627  free(key);
628 }
629 
638 void
640  const pcmk_injections_t *injections)
641 {
642  int rc = pcmk_ok;
643  const GList *iter = NULL;
644  xmlNode *cib_node = NULL;
645  pcmk__output_t *out = scheduler->priv;
646 
647  out->message(out, "inject-modify-config", injections->quorum,
648  injections->watchdog);
649  if (injections->quorum != NULL) {
650  xmlNode *top = create_xml_node(NULL, XML_TAG_CIB);
651 
652  /* crm_xml_add(top, XML_ATTR_DC_UUID, dc_uuid); */
653  crm_xml_add(top, XML_ATTR_HAVE_QUORUM, injections->quorum);
654 
655  rc = cib->cmds->modify(cib, NULL, top, cib_sync_call|cib_scope_local);
656  CRM_ASSERT(rc == pcmk_ok);
657  }
658 
659  if (injections->watchdog != NULL) {
661  XML_CIB_TAG_CRMCONFIG, NULL, NULL, NULL,
663  injections->watchdog, NULL, NULL);
664  CRM_ASSERT(rc == pcmk_rc_ok);
665  }
666 
667  for (iter = injections->node_up; iter != NULL; iter = iter->next) {
668  const char *node = (const char *) iter->data;
669 
670  out->message(out, "inject-modify-node", "Online", node);
671 
672  cib_node = pcmk__inject_node_state_change(cib, node, true);
673  CRM_ASSERT(cib_node != NULL);
674 
675  rc = cib->cmds->modify(cib, XML_CIB_TAG_STATUS, cib_node,
677  CRM_ASSERT(rc == pcmk_ok);
678  free_xml(cib_node);
679  }
680 
681  for (iter = injections->node_down; iter != NULL; iter = iter->next) {
682  const char *node = (const char *) iter->data;
683  char *xpath = NULL;
684 
685  out->message(out, "inject-modify-node", "Offline", node);
686 
687  cib_node = pcmk__inject_node_state_change(cib, node, false);
688  CRM_ASSERT(cib_node != NULL);
689 
690  rc = cib->cmds->modify(cib, XML_CIB_TAG_STATUS, cib_node,
692  CRM_ASSERT(rc == pcmk_ok);
693  free_xml(cib_node);
694 
695  xpath = crm_strdup_printf("//node_state[@uname='%s']/%s",
696  node, XML_CIB_TAG_LRM);
697  cib->cmds->remove(cib, xpath, NULL,
699  free(xpath);
700 
701  xpath = crm_strdup_printf("//node_state[@uname='%s']/%s",
703  cib->cmds->remove(cib, xpath, NULL,
705  free(xpath);
706  }
707 
708  for (iter = injections->node_fail; iter != NULL; iter = iter->next) {
709  const char *node = (const char *) iter->data;
710 
711  out->message(out, "inject-modify-node", "Failing", node);
712 
713  cib_node = pcmk__inject_node_state_change(cib, node, true);
715  CRM_ASSERT(cib_node != NULL);
716 
717  rc = cib->cmds->modify(cib, XML_CIB_TAG_STATUS, cib_node,
719  CRM_ASSERT(rc == pcmk_ok);
720  free_xml(cib_node);
721  }
722 
723  for (iter = injections->ticket_grant; iter != NULL; iter = iter->next) {
724  const char *ticket_id = (const char *) iter->data;
725 
726  out->message(out, "inject-modify-ticket", "Granting", ticket_id);
727 
728  rc = set_ticket_state_attr(out, ticket_id, "granted", true, cib);
729  CRM_ASSERT(rc == pcmk_rc_ok);
730  }
731 
732  for (iter = injections->ticket_revoke; iter != NULL; iter = iter->next) {
733  const char *ticket_id = (const char *) iter->data;
734 
735  out->message(out, "inject-modify-ticket", "Revoking", ticket_id);
736 
737  rc = set_ticket_state_attr(out, ticket_id, "granted", false, cib);
738  CRM_ASSERT(rc == pcmk_rc_ok);
739  }
740 
741  for (iter = injections->ticket_standby; iter != NULL; iter = iter->next) {
742  const char *ticket_id = (const char *) iter->data;
743 
744  out->message(out, "inject-modify-ticket", "Standby", ticket_id);
745 
746  rc = set_ticket_state_attr(out, ticket_id, "standby", true, cib);
747  CRM_ASSERT(rc == pcmk_rc_ok);
748  }
749 
750  for (iter = injections->ticket_activate; iter != NULL; iter = iter->next) {
751  const char *ticket_id = (const char *) iter->data;
752 
753  out->message(out, "inject-modify-ticket", "Activating", ticket_id);
754 
755  rc = set_ticket_state_attr(out, ticket_id, "standby", false, cib);
756  CRM_ASSERT(rc == pcmk_rc_ok);
757  }
758 
759  for (iter = injections->op_inject; iter != NULL; iter = iter->next) {
760  inject_action(out, (const char *) iter->data, cib, scheduler);
761  }
762 
763  if (!out->is_quiet(out)) {
764  out->end_list(out);
765  }
766 }
767 
768 void
770 {
771  if (injections == NULL) {
772  return;
773  }
774 
775  g_list_free_full(injections->node_up, g_free);
776  g_list_free_full(injections->node_down, g_free);
777  g_list_free_full(injections->node_fail, g_free);
778  g_list_free_full(injections->op_fail, g_free);
779  g_list_free_full(injections->op_inject, g_free);
780  g_list_free_full(injections->ticket_grant, g_free);
781  g_list_free_full(injections->ticket_revoke, g_free);
782  g_list_free_full(injections->ticket_standby, g_free);
783  g_list_free_full(injections->ticket_activate, g_free);
784  free(injections->quorum);
785  free(injections->watchdog);
786 
787  free(injections);
788 }
void(* end_list)(pcmk__output_t *out)
#define LOG_TRACE
Definition: logging.h:38
A dumping ground.
GList * op_inject
Definition: pacemaker.h:61
Internal software bug.
Definition: results.h:260
#define PCMK_RESOURCE_CLASS_SERVICE
Definition: agents.h:28
_Noreturn crm_exit_t crm_exit(crm_exit_t rc)
Definition: results.c:936
const char * name
Definition: cib.c:26
bool pcmk__strcase_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
Definition: strings.c:933
int(* message)(pcmk__output_t *out, const char *message_id,...)
#define XML_ATTR_TYPE
Definition: msg_xml.h:160
GList * ticket_activate
Definition: pacemaker.h:74
xmlNode * first_named_child(const xmlNode *parent, const char *name)
Definition: xml.c:2484
xmlNode * xml
Resource configuration (possibly expanded from template)
Definition: resources.h:404
bool(* is_quiet)(pcmk__output_t *out)
#define CRM_FEATURE_SET
Definition: crm.h:70
#define XML_TAG_TRANSIENT_NODEATTRS
Definition: msg_xml.h:420
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)
#define XML_LRM_TAG_RESOURCE
Definition: msg_xml.h:278
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:302
GList * node_up
Definition: pacemaker.h:52
unsigned int t_rcchange
Definition: lrmd_events.h:75
int query_node_uuid(cib_t *the_cib, const char *uname, char **uuid, int *is_remote_node)
Definition: cib_attrs.c:620
void pcmk__xe_set_bool_attr(xmlNodePtr node, const char *name, bool value)
Definition: nvpair.c:872
char * crm_system_name
Definition: utils.c:51
#define PCMK_RESOURCE_CLASS_OCF
Definition: agents.h:27
void pcmk__inject_scheduler_input(pcmk_scheduler_t *scheduler, cib_t *cib, const pcmk_injections_t *injections)
GList * ticket_grant
Definition: pacemaker.h:68
#define PCMK_RESOURCE_CLASS_SYSTEMD
Definition: agents.h:30
xmlNode * pcmk__inject_action_result(xmlNode *cib_resource, lrmd_event_data_t *op, int target_rc)
#define XPATH_NODE_CONFIG
#define XML_CIB_TAG_LRM
Definition: msg_xml.h:276
int crm_element_value_int(const xmlNode *data, const char *name, int *dest)
Retrieve the integer value of an XML attribute.
Definition: nvpair.c:483
#define XML_CIB_TAG_NODES
Definition: msg_xml.h:206
Implementation of pcmk_scheduler_t.
Definition: scheduler.h:172
xmlNode * get_xpath_object(const char *xpath, xmlNode *xml_obj, int error_level)
Definition: xpath.c:211
GList * resources
Resources in cluster.
Definition: scheduler.h:196
#define PCMK__XA_CRMD
Definition: crm_internal.h:84
#define XML_ATTR_ORIGIN
Definition: msg_xml.h:151
#define XML_TAG_ATTR_SETS
Definition: msg_xml.h:227
void pcmk_free_injections(pcmk_injections_t *injections)
Free a :pcmk_injections_t structure.
#define PCMK__XA_EXPECTED
Definition: crm_internal.h:85
#define CRMD_JOINSTATE_DOWN
Definition: crm.h:158
pcmk_resource_t * pe_find_resource(GList *rsc_list, const char *id_rh)
Definition: status.c:391
#define PCMK_RESOURCE_CLASS_UPSTART
Definition: agents.h:36
cib_api_operations_t * cmds
Definition: cib_types.h:345
Implementation of pcmk_resource_t.
Definition: resources.h:399
#define crm_debug(fmt, args...)
Definition: logging.h:386
#define XML_BOOLEAN_NO
Definition: msg_xml.h:170
Utility functions.
#define XML_ATTR_ID
Definition: msg_xml.h:156
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)
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
Definition: nvpair.c:447
#define XML_CIB_TAG_STATE
Definition: msg_xml.h:222
#define PCMK__XA_IN_CCM
Definition: crm_internal.h:88
GList * ticket_standby
Definition: pacemaker.h:72
#define crm_trace(fmt, args...)
Definition: logging.h:387
#define CRMD_JOINSTATE_MEMBER
Definition: crm.h:160
#define PCMK_RESOURCE_CLASS_STONITH
Definition: agents.h:31
void pcmk__g_strcat(GString *buffer,...) G_GNUC_NULL_TERMINATED
Definition: strings.c:1217
void * priv
For Pacemaker use only.
Definition: scheduler.h:229
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:99
int(* modify)(cib_t *cib, const char *section, xmlNode *data, int call_options)
Definition: cib_types.h:180
int(*) int(*) void(* err)(pcmk__output_t *out, const char *format,...) G_GNUC_PRINTF(2
#define crm_log_xml_debug(xml, text)
Definition: logging.h:394
int(* create)(cib_t *cib, const char *section, xmlNode *data, int call_options)
Definition: cib_types.h:178
#define XML_AGENT_ATTR_PROVIDER
Definition: msg_xml.h:281
#define XML_ATTR_HAVE_QUORUM
Definition: msg_xml.h:145
#define XML_ATTR_UNAME
Definition: msg_xml.h:178
#define XML_BOOLEAN_YES
Definition: msg_xml.h:169
ISO_8601 Date handling.
xmlNode * create_xml_node(xmlNode *parent, const char *name)
Definition: xml.c:638
#define crm_log_xml_warn(xml, text)
Definition: logging.h:391
Action completed, result is known.
Definition: results.h:318
int(* query)(cib_t *cib, const char *section, xmlNode **output_data, int call_options)
Definition: cib_types.h:156
void pcmk__inject_failcount(pcmk__output_t *out, xmlNode *cib_node, const char *resource, const char *task, guint interval_ms, int rc)
int pcmk_legacy2rc(int legacy_rc)
Definition: results.c:559
void free_xml(xmlNode *child)
Definition: xml.c:783
#define XML_CIB_TAG_NODE
Definition: msg_xml.h:223
bool pcmk__simulate_node_config
void pcmk__xe_set_props(xmlNodePtr node,...) G_GNUC_NULL_TERMINATED
Definition: xml.c:2654
unsigned int t_run
Definition: lrmd_events.h:72
#define XML_TAG_CIB
Definition: msg_xml.h:137
#define PCMK__XA_JOIN
Definition: crm_internal.h:89
Cluster status and scheduling.
GList * ticket_revoke
Definition: pacemaker.h:70
#define XML_LRM_TAG_RESOURCES
Definition: msg_xml.h:277
#define crm_err(fmt, args...)
Definition: logging.h:381
pcmk_scheduler_t * scheduler
#define XML_CIB_TAG_TICKET_STATE
Definition: msg_xml.h:447
#define CRM_ASSERT(expr)
Definition: results.h:42
Success.
Definition: results.h:170
Cluster Configuration.
void lrmd__set_result(lrmd_event_data_t *event, enum ocf_exitcode rc, int op_status, const char *exit_reason)
Definition: lrmd_client.c:2506
#define XML_CIB_TAG_CRMCONFIG
Definition: msg_xml.h:208
Synthetic cluster events that can be injected into the cluster for running simulations.
Definition: pacemaker.h:50
#define OFFLINESTATUS
Definition: util.h:38
#define PCMK_RESOURCE_CLASS_LSB
Definition: agents.h:29
#define XML_ATTR_HAVE_WATCHDOG
Definition: msg_xml.h:146
void lrmd_free_event(lrmd_event_data_t *event)
Free an executor event.
Definition: lrmd_client.c:243
GList * node_fail
Definition: pacemaker.h:56
This structure contains everything that makes up a single output formatter.
gboolean parse_op_key(const char *key, char **rsc_id, char **op_type, guint *interval_ms)
Definition: actions.c:96
#define XML_LRM_ATTR_CALLID
Definition: msg_xml.h:318
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:172
#define XPATH_RSC_HISTORY
xmlNode * pcmk__inject_node_state_change(cib_t *cib_conn, const char *node, bool up)
#define pcmk_ok
Definition: results.h:68
#define XPATH_NODE_STATE
GList * op_fail
Definition: pacemaker.h:66
#define XML_CIB_TAG_STATUS
Definition: msg_xml.h:204
uint32_t pcmk_get_ra_caps(const char *standard)
Get capabilities of a resource agent standard.
Definition: agents.c:31
int(* remove)(cib_t *cib, const char *section, xmlNode *data, int call_options)
Definition: cib_types.h:189
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:763
#define ID(x)
Definition: msg_xml.h:474
#define ONLINESTATUS
Definition: util.h:37
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.
Definition: lrmd_client.c:195
Resource agent executor events.
#define XPATH_NODE_STATE_BY_ID
#define XML_CIB_TAG_TICKETS
Definition: msg_xml.h:446
#define crm_info(fmt, args...)
Definition: logging.h:384
xmlNode * pcmk__inject_node(cib_t *cib_conn, const char *node, const char *uuid)
GList * node_down
Definition: pacemaker.h:54
#define XML_AGENT_ATTR_CLASS
Definition: msg_xml.h:280