pacemaker  2.1.8-3980678f03
Scalable High-Availability cluster resource manager
complex.c
Go to the documentation of this file.
1 /*
2  * Copyright 2004-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 Lesser General Public License
7  * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
8  */
9 
10 #include <crm_internal.h>
11 
12 #include <crm/pengine/rules.h>
13 #include <crm/pengine/internal.h>
14 #include <crm/common/xml.h>
17 
18 #include "pe_status_private.h"
19 
20 void populate_hash(xmlNode * nvpair_list, GHashTable * hash, const char **attrs, int attrs_length);
21 
22 static pcmk_node_t *active_node(const pcmk_resource_t *rsc,
23  unsigned int *count_all,
24  unsigned int *count_clean);
25 
27  {
38  active_node,
40  },
41  {
49  group_free,
52  active_node,
54  },
55  {
63  clone_free,
66  active_node,
68  },
69  {
82  }
83 };
84 
85 static enum pe_obj_types
86 get_resource_type(const char *name)
87 {
88  if (pcmk__str_eq(name, PCMK_XE_PRIMITIVE, pcmk__str_casei)) {
90 
91  } else if (pcmk__str_eq(name, PCMK_XE_GROUP, pcmk__str_casei)) {
93 
94  } else if (pcmk__str_eq(name, PCMK_XE_CLONE, pcmk__str_casei)) {
96 
97  } else if (pcmk__str_eq(name, PCMK__XE_PROMOTABLE_LEGACY,
98  pcmk__str_casei)) {
99  // @COMPAT deprecated since 2.0.0
100  return pcmk_rsc_variant_clone;
101 
102  } else if (pcmk__str_eq(name, PCMK_XE_BUNDLE, pcmk__str_casei)) {
104  }
105 
107 }
108 
120 static void
121 dup_attr(gpointer key, gpointer value, gpointer user_data)
122 {
123  GHashTable *table = user_data;
124 
125  CRM_CHECK((key != NULL) && (table != NULL), return);
126  if (pcmk__str_eq((const char *) value, "#default", pcmk__str_casei)) {
127  // @COMPAT Deprecated since 2.1.8
128  pcmk__config_warn("Support for setting meta-attributes (such as %s) to "
129  "the explicit value '#default' is deprecated and "
130  "will be removed in a future release",
131  (const char *) key);
132  } else if ((value != NULL) && (g_hash_table_lookup(table, key) == NULL)) {
133  pcmk__insert_dup(table, (const char *) key, (const char *) value);
134  }
135 }
136 
137 static void
138 expand_parents_fixed_nvpairs(pcmk_resource_t *rsc,
139  pe_rule_eval_data_t *rule_data,
140  GHashTable *meta_hash, pcmk_scheduler_t *scheduler)
141 {
142  GHashTable *parent_orig_meta = pcmk__strkey_table(free, free);
143  pcmk_resource_t *p = rsc->parent;
144 
145  if (p == NULL) {
146  return ;
147  }
148 
149  /* Search all parent resources, get the fixed value of
150  * PCMK_XE_META_ATTRIBUTES set only in the original xml, and stack it in the
151  * hash table. The fixed value of the lower parent resource takes precedence
152  * and is not overwritten.
153  */
154  while(p != NULL) {
155  /* A hash table for comparison is generated, including the id-ref. */
157  parent_orig_meta, NULL, FALSE, scheduler);
158  p = p->parent;
159  }
160 
161  if (parent_orig_meta != NULL) {
162  // This will not overwrite any values already existing for child
163  g_hash_table_foreach(parent_orig_meta, dup_attr, meta_hash);
164  }
165 
166  if (parent_orig_meta != NULL) {
167  g_hash_table_destroy(parent_orig_meta);
168  }
169 
170  return ;
171 
172 }
173 void
174 get_meta_attributes(GHashTable * meta_hash, pcmk_resource_t * rsc,
176 {
177  pe_rsc_eval_data_t rsc_rule_data = {
179  .provider = crm_element_value(rsc->xml, PCMK_XA_PROVIDER),
180  .agent = crm_element_value(rsc->xml, PCMK_XA_TYPE)
181  };
182 
183  pe_rule_eval_data_t rule_data = {
184  .node_hash = NULL,
185  .now = scheduler->now,
186  .match_data = NULL,
187  .rsc_data = &rsc_rule_data,
188  .op_data = NULL
189  };
190 
191  if (node) {
192  /* @COMPAT Support for node attribute expressions in rules for
193  * meta-attributes is deprecated. When we can break behavioral backward
194  * compatibility, drop this block.
195  */
196  rule_data.node_hash = node->details->attrs;
197  }
198 
199  for (xmlAttrPtr a = pcmk__xe_first_attr(rsc->xml); a != NULL; a = a->next) {
200  if (a->children != NULL) {
201  dup_attr((gpointer) a->name, (gpointer) a->children->content,
202  meta_hash);
203  }
204  }
205 
207  meta_hash, NULL, FALSE, scheduler);
208 
209  /* Set the PCMK_XE_META_ATTRIBUTES explicitly set in the parent resource to
210  * the hash table of the child resource. If it is already explicitly set as
211  * a child, it will not be overwritten.
212  */
213  if (rsc->parent != NULL) {
214  expand_parents_fixed_nvpairs(rsc, &rule_data, meta_hash, scheduler);
215  }
216 
217  /* check the defaults */
219  &rule_data, meta_hash, NULL, FALSE, scheduler);
220 
221  /* If there is PCMK_XE_META_ATTRIBUTES that the parent resource has not
222  * explicitly set, set a value that is not set from PCMK_XE_RSC_DEFAULTS
223  * either. The values already set up to this point will not be overwritten.
224  */
225  if (rsc->parent) {
226  g_hash_table_foreach(rsc->parent->meta, dup_attr, meta_hash);
227  }
228 }
229 
230 void
231 get_rsc_attributes(GHashTable *meta_hash, const pcmk_resource_t *rsc,
232  const pcmk_node_t *node, pcmk_scheduler_t *scheduler)
233 {
234  pe_rule_eval_data_t rule_data = {
235  .node_hash = NULL,
236  .now = scheduler->now,
237  .match_data = NULL,
238  .rsc_data = NULL,
239  .op_data = NULL
240  };
241 
242  if (node) {
243  rule_data.node_hash = node->details->attrs;
244  }
245 
247  &rule_data, meta_hash, NULL, FALSE, scheduler);
248 
249  /* set anything else based on the parent */
250  if (rsc->parent != NULL) {
251  get_rsc_attributes(meta_hash, rsc->parent, node, scheduler);
252 
253  } else {
256  NULL) != NULL) {
257  /* Not possible with schema validation enabled
258  *
259  * @COMPAT Drop support when we can break behavioral
260  * backward compatibility
261  */
263  "Support for " PCMK_XE_INSTANCE_ATTRIBUTES " in "
264  PCMK_XE_RSC_DEFAULTS " is deprecated and will be "
265  "removed in a future release");
266  }
267 
268  /* and finally check the defaults */
270  PCMK_XE_INSTANCE_ATTRIBUTES, &rule_data,
271  meta_hash, NULL, FALSE, scheduler);
272  }
273 }
274 
275 static char *
276 template_op_key(xmlNode * op)
277 {
278  const char *name = crm_element_value(op, PCMK_XA_NAME);
279  const char *role = crm_element_value(op, PCMK_XA_ROLE);
280  char *key = NULL;
281 
282  if ((role == NULL)
285  role = PCMK__ROLE_UNKNOWN;
286  }
287 
288  key = crm_strdup_printf("%s-%s", name, role);
289  return key;
290 }
291 
292 static gboolean
293 unpack_template(xmlNode *xml_obj, xmlNode **expanded_xml,
295 {
296  xmlNode *cib_resources = NULL;
297  xmlNode *template = NULL;
298  xmlNode *new_xml = NULL;
299  xmlNode *child_xml = NULL;
300  xmlNode *rsc_ops = NULL;
301  xmlNode *template_ops = NULL;
302  const char *template_ref = NULL;
303  const char *id = NULL;
304 
305  if (xml_obj == NULL) {
306  pcmk__config_err("No resource object for template unpacking");
307  return FALSE;
308  }
309 
310  template_ref = crm_element_value(xml_obj, PCMK_XA_TEMPLATE);
311  if (template_ref == NULL) {
312  return TRUE;
313  }
314 
315  id = pcmk__xe_id(xml_obj);
316  if (id == NULL) {
317  pcmk__config_err("'%s' object must have a id", xml_obj->name);
318  return FALSE;
319  }
320 
321  if (pcmk__str_eq(template_ref, id, pcmk__str_none)) {
322  pcmk__config_err("The resource object '%s' should not reference itself",
323  id);
324  return FALSE;
325  }
326 
327  cib_resources = get_xpath_object("//" PCMK_XE_RESOURCES, scheduler->input,
328  LOG_TRACE);
329  if (cib_resources == NULL) {
330  pcmk__config_err("No resources configured");
331  return FALSE;
332  }
333 
334  template = pcmk__xe_first_child(cib_resources, PCMK_XE_TEMPLATE,
335  PCMK_XA_ID, template_ref);
336  if (template == NULL) {
337  pcmk__config_err("No template named '%s'", template_ref);
338  return FALSE;
339  }
340 
341  new_xml = pcmk__xml_copy(NULL, template);
342  xmlNodeSetName(new_xml, xml_obj->name);
343  crm_xml_add(new_xml, PCMK_XA_ID, id);
344  crm_xml_add(new_xml, PCMK__META_CLONE,
346 
347  template_ops = pcmk__xe_first_child(new_xml, PCMK_XE_OPERATIONS, NULL,
348  NULL);
349 
350  for (child_xml = pcmk__xe_first_child(xml_obj, NULL, NULL, NULL);
351  child_xml != NULL; child_xml = pcmk__xe_next(child_xml)) {
352 
353  xmlNode *new_child = pcmk__xml_copy(new_xml, child_xml);
354 
355  if (pcmk__xe_is(new_child, PCMK_XE_OPERATIONS)) {
356  rsc_ops = new_child;
357  }
358  }
359 
360  if (template_ops && rsc_ops) {
361  xmlNode *op = NULL;
362  GHashTable *rsc_ops_hash = pcmk__strkey_table(free, NULL);
363 
364  for (op = pcmk__xe_first_child(rsc_ops, NULL, NULL, NULL); op != NULL;
365  op = pcmk__xe_next(op)) {
366 
367  char *key = template_op_key(op);
368 
369  g_hash_table_insert(rsc_ops_hash, key, op);
370  }
371 
372  for (op = pcmk__xe_first_child(template_ops, NULL, NULL, NULL);
373  op != NULL; op = pcmk__xe_next(op)) {
374 
375  char *key = template_op_key(op);
376 
377  if (g_hash_table_lookup(rsc_ops_hash, key) == NULL) {
378  pcmk__xml_copy(rsc_ops, op);
379  }
380 
381  free(key);
382  }
383 
384  if (rsc_ops_hash) {
385  g_hash_table_destroy(rsc_ops_hash);
386  }
387 
388  free_xml(template_ops);
389  }
390 
391  /*free_xml(*expanded_xml); */
392  *expanded_xml = new_xml;
393 
394 #if 0 /* Disable multi-level templates for now */
395  if (!unpack_template(new_xml, expanded_xml, scheduler)) {
396  free_xml(*expanded_xml);
397  *expanded_xml = NULL;
398  return FALSE;
399  }
400 #endif
401 
402  return TRUE;
403 }
404 
405 static gboolean
406 add_template_rsc(xmlNode *xml_obj, pcmk_scheduler_t *scheduler)
407 {
408  const char *template_ref = NULL;
409  const char *id = NULL;
410 
411  if (xml_obj == NULL) {
412  pcmk__config_err("No resource object for processing resource list "
413  "of template");
414  return FALSE;
415  }
416 
417  template_ref = crm_element_value(xml_obj, PCMK_XA_TEMPLATE);
418  if (template_ref == NULL) {
419  return TRUE;
420  }
421 
422  id = pcmk__xe_id(xml_obj);
423  if (id == NULL) {
424  pcmk__config_err("'%s' object must have a id", xml_obj->name);
425  return FALSE;
426  }
427 
428  if (pcmk__str_eq(template_ref, id, pcmk__str_none)) {
429  pcmk__config_err("The resource object '%s' should not reference itself",
430  id);
431  return FALSE;
432  }
433 
434  if (add_tag_ref(scheduler->template_rsc_sets, template_ref, id) == FALSE) {
435  return FALSE;
436  }
437 
438  return TRUE;
439 }
440 
441 static bool
442 detect_promotable(pcmk_resource_t *rsc)
443 {
444  const char *promotable = g_hash_table_lookup(rsc->meta,
446 
447  if (crm_is_true(promotable)) {
448  return TRUE;
449  }
450 
451  // @COMPAT deprecated since 2.0.0
452  if (pcmk__xe_is(rsc->xml, PCMK__XE_PROMOTABLE_LEGACY)) {
454  "Support for <" PCMK__XE_PROMOTABLE_LEGACY "> (such "
455  "as in %s) is deprecated and will be removed in a "
456  "future release. Use <" PCMK_XE_CLONE "> with a "
457  PCMK_META_PROMOTABLE " meta-attribute instead.",
458  rsc->id);
460  return TRUE;
461  }
462  return FALSE;
463 }
464 
465 static void
466 free_params_table(gpointer data)
467 {
468  g_hash_table_destroy((GHashTable *) data);
469 }
470 
483 GHashTable *
486 {
487  GHashTable *params_on_node = NULL;
488 
489  /* A NULL node is used to request the resource's default parameters
490  * (not evaluated for node), but we always want something non-NULL
491  * as a hash table key.
492  */
493  const char *node_name = "";
494 
495  // Sanity check
496  if ((rsc == NULL) || (scheduler == NULL)) {
497  return NULL;
498  }
499  if ((node != NULL) && (node->details->uname != NULL)) {
500  node_name = node->details->uname;
501  }
502 
503  // Find the parameter table for given node
504  if (rsc->parameter_cache == NULL) {
505  rsc->parameter_cache = pcmk__strikey_table(free, free_params_table);
506  } else {
507  params_on_node = g_hash_table_lookup(rsc->parameter_cache, node_name);
508  }
509 
510  // If none exists yet, create one with parameters evaluated for node
511  if (params_on_node == NULL) {
512  params_on_node = pcmk__strkey_table(free, free);
513  get_rsc_attributes(params_on_node, rsc, node, scheduler);
514  g_hash_table_insert(rsc->parameter_cache, strdup(node_name),
515  params_on_node);
516  }
517  return params_on_node;
518 }
519 
528 static void
529 unpack_requires(pcmk_resource_t *rsc, const char *value, bool is_default)
530 {
531  if (pcmk__str_eq(value, PCMK_VALUE_NOTHING, pcmk__str_casei)) {
532 
533  } else if (pcmk__str_eq(value, PCMK_VALUE_QUORUM, pcmk__str_casei)) {
535 
536  } else if (pcmk__str_eq(value, PCMK_VALUE_FENCING, pcmk__str_casei)) {
539  pcmk__config_warn("%s requires fencing but fencing is disabled",
540  rsc->id);
541  }
542 
543  } else if (pcmk__str_eq(value, PCMK_VALUE_UNFENCING, pcmk__str_casei)) {
545  pcmk__config_warn("Resetting \"" PCMK_META_REQUIRES "\" for %s "
546  "to \"" PCMK_VALUE_QUORUM "\" because fencing "
547  "devices cannot require unfencing", rsc->id);
548  unpack_requires(rsc, PCMK_VALUE_QUORUM, true);
549  return;
550 
551  } else if (!pcmk_is_set(rsc->cluster->flags,
553  pcmk__config_warn("Resetting \"" PCMK_META_REQUIRES "\" for %s "
554  "to \"" PCMK_VALUE_QUORUM "\" because fencing is "
555  "disabled", rsc->id);
556  unpack_requires(rsc, PCMK_VALUE_QUORUM, true);
557  return;
558 
559  } else {
562  }
563 
564  } else {
565  const char *orig_value = value;
566 
568  value = PCMK_VALUE_QUORUM;
569 
570  } else if (pcmk__is_primitive(rsc)
571  && xml_contains_remote_node(rsc->xml)) {
572  value = PCMK_VALUE_QUORUM;
573 
574  } else if (pcmk_is_set(rsc->cluster->flags,
576  value = PCMK_VALUE_UNFENCING;
577 
578  } else if (pcmk_is_set(rsc->cluster->flags,
580  value = PCMK_VALUE_FENCING;
581 
582  } else if (rsc->cluster->no_quorum_policy == pcmk_no_quorum_ignore) {
583  value = PCMK_VALUE_NOTHING;
584 
585  } else {
586  value = PCMK_VALUE_QUORUM;
587  }
588 
589  if (orig_value != NULL) {
590  pcmk__config_err("Resetting '" PCMK_META_REQUIRES "' for %s "
591  "to '%s' because '%s' is not valid",
592  rsc->id, value, orig_value);
593  }
594  unpack_requires(rsc, value, true);
595  return;
596  }
597 
598  pcmk__rsc_trace(rsc, "\tRequired to start: %s%s", value,
599  (is_default? " (default)" : ""));
600 }
601 
602 static void
603 warn_about_deprecated_classes(pcmk_resource_t *rsc)
604 {
605  const char *std = crm_element_value(rsc->xml, PCMK_XA_CLASS);
606 
607  if (pcmk__str_eq(std, PCMK_RESOURCE_CLASS_UPSTART, pcmk__str_none)) {
609  "Support for Upstart resources (such as %s) is "
610  "deprecated and will be removed in a future release",
611  rsc->id);
612 
613  } else if (pcmk__str_eq(std, PCMK_RESOURCE_CLASS_NAGIOS, pcmk__str_none)) {
615  "Support for Nagios resources (such as %s) is "
616  "deprecated and will be removed in a future release",
617  rsc->id);
618  }
619 }
620 
638 int
639 pe__unpack_resource(xmlNode *xml_obj, pcmk_resource_t **rsc,
641 {
642  xmlNode *expanded_xml = NULL;
643  xmlNode *ops = NULL;
644  const char *value = NULL;
645  const char *id = NULL;
646  bool guest_node = false;
647  bool remote_node = false;
648 
649  pe_rule_eval_data_t rule_data = {
650  .node_hash = NULL,
651  .now = NULL,
652  .match_data = NULL,
653  .rsc_data = NULL,
654  .op_data = NULL
655  };
656 
657  CRM_CHECK(rsc != NULL, return EINVAL);
658  CRM_CHECK((xml_obj != NULL) && (scheduler != NULL),
659  *rsc = NULL;
660  return EINVAL);
661 
662  rule_data.now = scheduler->now;
663 
664  crm_log_xml_trace(xml_obj, "[raw XML]");
665 
666  id = crm_element_value(xml_obj, PCMK_XA_ID);
667  if (id == NULL) {
668  pcmk__config_err("Ignoring <%s> configuration without " PCMK_XA_ID,
669  xml_obj->name);
670  return pcmk_rc_unpack_error;
671  }
672 
673  if (unpack_template(xml_obj, &expanded_xml, scheduler) == FALSE) {
674  return pcmk_rc_unpack_error;
675  }
676 
677  *rsc = calloc(1, sizeof(pcmk_resource_t));
678  if (*rsc == NULL) {
679  pcmk__sched_err("Unable to allocate memory for resource '%s'", id);
680  return ENOMEM;
681  }
682  (*rsc)->cluster = scheduler;
683 
684  if (expanded_xml) {
685  crm_log_xml_trace(expanded_xml, "[expanded XML]");
686  (*rsc)->xml = expanded_xml;
687  (*rsc)->orig_xml = xml_obj;
688 
689  } else {
690  (*rsc)->xml = xml_obj;
691  (*rsc)->orig_xml = NULL;
692  }
693 
694  /* Do not use xml_obj from here on, use (*rsc)->xml in case templates are involved */
695 
696  (*rsc)->parent = parent;
697 
698  ops = pcmk__xe_first_child((*rsc)->xml, PCMK_XE_OPERATIONS, NULL, NULL);
699  (*rsc)->ops_xml = expand_idref(ops, scheduler->input);
700 
701  (*rsc)->variant = get_resource_type((const char *) (*rsc)->xml->name);
702  if ((*rsc)->variant == pcmk_rsc_variant_unknown) {
703  pcmk__config_err("Ignoring resource '%s' of unknown type '%s'",
704  id, (*rsc)->xml->name);
705  common_free(*rsc);
706  *rsc = NULL;
707  return pcmk_rc_unpack_error;
708  }
709 
710  (*rsc)->meta = pcmk__strkey_table(free, free);
711  (*rsc)->allowed_nodes = pcmk__strkey_table(NULL, free);
712  (*rsc)->known_on = pcmk__strkey_table(NULL, free);
713 
714  value = crm_element_value((*rsc)->xml, PCMK__META_CLONE);
715  if (value) {
716  (*rsc)->id = crm_strdup_printf("%s:%s", id, value);
717  pcmk__insert_meta(*rsc, PCMK__META_CLONE, value);
718 
719  } else {
720  (*rsc)->id = strdup(id);
721  }
722 
723  warn_about_deprecated_classes(*rsc);
724 
725  (*rsc)->fns = &resource_class_functions[(*rsc)->variant];
726 
727  get_meta_attributes((*rsc)->meta, *rsc, NULL, scheduler);
728  (*rsc)->parameters = pe_rsc_params(*rsc, NULL, scheduler); // \deprecated
729 
730  (*rsc)->flags = 0;
732 
735  }
736 
737  (*rsc)->rsc_cons = NULL;
738  (*rsc)->rsc_tickets = NULL;
739  (*rsc)->actions = NULL;
740  (*rsc)->role = pcmk_role_stopped;
741  (*rsc)->next_role = pcmk_role_unknown;
742 
743  (*rsc)->recovery_type = pcmk_multiply_active_restart;
744  (*rsc)->stickiness = 0;
745  (*rsc)->migration_threshold = PCMK_SCORE_INFINITY;
746  (*rsc)->failure_timeout = 0;
747 
748  value = g_hash_table_lookup((*rsc)->meta, PCMK_META_PRIORITY);
749  (*rsc)->priority = char2score(value);
750 
751  value = g_hash_table_lookup((*rsc)->meta, PCMK_META_CRITICAL);
752  if ((value == NULL) || crm_is_true(value)) {
754  }
755 
756  value = g_hash_table_lookup((*rsc)->meta, PCMK_META_NOTIFY);
757  if (crm_is_true(value)) {
759  }
760 
761  if (xml_contains_remote_node((*rsc)->xml)) {
762  (*rsc)->is_remote_node = TRUE;
763  if (g_hash_table_lookup((*rsc)->meta, PCMK__META_CONTAINER)) {
764  guest_node = true;
765  } else {
766  remote_node = true;
767  }
768  }
769 
770  value = g_hash_table_lookup((*rsc)->meta, PCMK_META_ALLOW_MIGRATE);
771  if (crm_is_true(value)) {
773  } else if ((value == NULL) && remote_node) {
774  /* By default, we want remote nodes to be able
775  * to float around the cluster without having to stop all the
776  * resources within the remote-node before moving. Allowing
777  * migration support enables this feature. If this ever causes
778  * problems, migration support can be explicitly turned off with
779  * PCMK_META_ALLOW_MIGRATE=false.
780  */
782  }
783 
784  value = g_hash_table_lookup((*rsc)->meta, PCMK_META_IS_MANAGED);
785  if (value != NULL) {
786  if (pcmk__str_eq(PCMK_VALUE_DEFAULT, value, pcmk__str_casei)) {
787  // @COMPAT Deprecated since 2.1.8
788  pcmk__config_warn("Support for setting " PCMK_META_IS_MANAGED
789  " to the explicit value '" PCMK_VALUE_DEFAULT
790  "' is deprecated and will be removed in a "
791  "future release (just leave it unset)");
792  } else if (crm_is_true(value)) {
794  } else {
796  }
797  }
798 
799  value = g_hash_table_lookup((*rsc)->meta, PCMK_META_MAINTENANCE);
800  if (crm_is_true(value)) {
803  }
807  }
808 
809  if (pcmk__is_clone(pe__const_top_resource(*rsc, false))) {
810  value = g_hash_table_lookup((*rsc)->meta, PCMK_META_GLOBALLY_UNIQUE);
811  if (crm_is_true(value)) {
813  }
814  if (detect_promotable(*rsc)) {
816  }
817  } else {
819  }
820 
821  // @COMPAT Deprecated meta-attribute
822  value = g_hash_table_lookup((*rsc)->meta, PCMK__META_RESTART_TYPE);
823  if (pcmk__str_eq(value, PCMK_VALUE_RESTART, pcmk__str_casei)) {
824  (*rsc)->restart_type = pe_restart_restart;
825  pcmk__rsc_trace(*rsc, "%s dependency restart handling: restart",
826  (*rsc)->id);
828  "Support for " PCMK__META_RESTART_TYPE " is deprecated "
829  "and will be removed in a future release");
830 
831  } else {
832  (*rsc)->restart_type = pe_restart_ignore;
833  pcmk__rsc_trace(*rsc, "%s dependency restart handling: ignore",
834  (*rsc)->id);
835  }
836 
837  value = g_hash_table_lookup((*rsc)->meta, PCMK_META_MULTIPLE_ACTIVE);
838  if (pcmk__str_eq(value, PCMK_VALUE_STOP_ONLY, pcmk__str_casei)) {
839  (*rsc)->recovery_type = pcmk_multiply_active_stop;
840  pcmk__rsc_trace(*rsc, "%s multiple running resource recovery: stop only",
841  (*rsc)->id);
842 
843  } else if (pcmk__str_eq(value, PCMK_VALUE_BLOCK, pcmk__str_casei)) {
844  (*rsc)->recovery_type = pcmk_multiply_active_block;
845  pcmk__rsc_trace(*rsc, "%s multiple running resource recovery: block",
846  (*rsc)->id);
847 
848  } else if (pcmk__str_eq(value, PCMK_VALUE_STOP_UNEXPECTED,
849  pcmk__str_casei)) {
850  (*rsc)->recovery_type = pcmk_multiply_active_unexpected;
851  pcmk__rsc_trace(*rsc,
852  "%s multiple running resource recovery: "
853  "stop unexpected instances",
854  (*rsc)->id);
855 
856  } else { // PCMK_VALUE_STOP_START
857  if (!pcmk__str_eq(value, PCMK_VALUE_STOP_START,
859  pcmk__config_warn("%s is not a valid value for "
861  ", using default of "
862  "\"" PCMK_VALUE_STOP_START "\"",
863  value);
864  }
865  (*rsc)->recovery_type = pcmk_multiply_active_restart;
866  pcmk__rsc_trace(*rsc,
867  "%s multiple running resource recovery: stop/start",
868  (*rsc)->id);
869  }
870 
871  value = g_hash_table_lookup((*rsc)->meta, PCMK_META_RESOURCE_STICKINESS);
872  if (value != NULL) {
873  if (pcmk__str_eq(PCMK_VALUE_DEFAULT, value, pcmk__str_casei)) {
874  // @COMPAT Deprecated since 2.1.8
875  pcmk__config_warn("Support for setting "
877  " to the explicit value '" PCMK_VALUE_DEFAULT
878  "' is deprecated and will be removed in a "
879  "future release (just leave it unset)");
880  } else {
881  (*rsc)->stickiness = char2score(value);
882  }
883  }
884 
885  value = g_hash_table_lookup((*rsc)->meta, PCMK_META_MIGRATION_THRESHOLD);
886  if (value != NULL) {
887  if (pcmk__str_eq(PCMK_VALUE_DEFAULT, value, pcmk__str_casei)) {
888  // @COMPAT Deprecated since 2.1.8
889  pcmk__config_warn("Support for setting "
891  " to the explicit value '" PCMK_VALUE_DEFAULT
892  "' is deprecated and will be removed in a "
893  "future release (just leave it unset)");
894  } else {
895  (*rsc)->migration_threshold = char2score(value);
896  if ((*rsc)->migration_threshold < 0) {
897  /* @COMPAT We use 1 here to preserve previous behavior, but this
898  * should probably use the default (INFINITY) or 0 (to disable)
899  * instead.
900  */
903  " must be non-negative, using 1 instead");
904  (*rsc)->migration_threshold = 1;
905  }
906  }
907  }
908 
909  if (pcmk__str_eq(crm_element_value((*rsc)->xml, PCMK_XA_CLASS),
913  }
914 
915  value = g_hash_table_lookup((*rsc)->meta, PCMK_META_REQUIRES);
916  unpack_requires(*rsc, value, false);
917 
918  value = g_hash_table_lookup((*rsc)->meta, PCMK_META_FAILURE_TIMEOUT);
919  if (value != NULL) {
920  guint interval_ms = 0U;
921 
922  // Stored as seconds
923  pcmk_parse_interval_spec(value, &interval_ms);
924  (*rsc)->failure_timeout = (int) (interval_ms / 1000);
925  }
926 
927  if (remote_node) {
928  GHashTable *params = pe_rsc_params(*rsc, NULL, scheduler);
929 
930  /* Grabbing the value now means that any rules based on node attributes
931  * will evaluate to false, so such rules should not be used with
932  * PCMK_REMOTE_RA_RECONNECT_INTERVAL.
933  *
934  * @TODO Evaluate per node before using
935  */
936  value = g_hash_table_lookup(params, PCMK_REMOTE_RA_RECONNECT_INTERVAL);
937  if (value) {
938  /* reconnect delay works by setting failure_timeout and preventing the
939  * connection from starting until the failure is cleared. */
940  pcmk_parse_interval_spec(value, &((*rsc)->remote_reconnect_ms));
941 
942  /* We want to override any default failure_timeout in use when remote
943  * PCMK_REMOTE_RA_RECONNECT_INTERVAL is in use.
944  */
945  (*rsc)->failure_timeout = (*rsc)->remote_reconnect_ms / 1000;
946  }
947  }
948 
949  get_target_role(*rsc, &((*rsc)->next_role));
950  pcmk__rsc_trace(*rsc, "%s desired next state: %s", (*rsc)->id,
951  ((*rsc)->next_role == pcmk_role_unknown)?
952  "default" : pcmk_role_text((*rsc)->next_role));
953 
954  if ((*rsc)->fns->unpack(*rsc, scheduler) == FALSE) {
955  (*rsc)->fns->free(*rsc);
956  *rsc = NULL;
957  return pcmk_rc_unpack_error;
958  }
959 
961  // This tag must stay exactly the same because it is tested elsewhere
962  resource_location(*rsc, NULL, 0, "symmetric_default", scheduler);
963  } else if (guest_node) {
964  /* remote resources tied to a container resource must always be allowed
965  * to opt-in to the cluster. Whether the connection resource is actually
966  * allowed to be placed on a node is dependent on the container resource */
967  resource_location(*rsc, NULL, 0, "remote_connection_default",
968  scheduler);
969  }
970 
971  pcmk__rsc_trace(*rsc, "%s action notification: %s", (*rsc)->id,
972  pcmk_is_set((*rsc)->flags, pcmk_rsc_notify)? "required" : "not required");
973 
974  (*rsc)->utilization = pcmk__strkey_table(free, free);
975 
976  pe__unpack_dataset_nvpairs((*rsc)->xml, PCMK_XE_UTILIZATION, &rule_data,
977  (*rsc)->utilization, NULL, FALSE, scheduler);
978 
979  if (expanded_xml) {
980  if (add_template_rsc(xml_obj, scheduler) == FALSE) {
981  (*rsc)->fns->free(*rsc);
982  *rsc = NULL;
983  return pcmk_rc_unpack_error;
984  }
985  }
986  return pcmk_rc_ok;
987 }
988 
989 gboolean
991 {
992  pcmk_resource_t *parent = child;
993 
994  if (parent == NULL || rsc == NULL) {
995  return FALSE;
996  }
997  while (parent->parent != NULL) {
998  if (parent->parent == rsc) {
999  return TRUE;
1000  }
1001  parent = parent->parent;
1002  }
1003  return FALSE;
1004 }
1005 
1008 {
1009  pcmk_resource_t *parent = rsc;
1010 
1011  if (parent == NULL) {
1012  return NULL;
1013  }
1014  while ((parent->parent != NULL) && !pcmk__is_bundle(parent->parent)) {
1015  parent = parent->parent;
1016  }
1017  return parent;
1018 }
1019 
1031 const pcmk_resource_t *
1032 pe__const_top_resource(const pcmk_resource_t *rsc, bool include_bundle)
1033 {
1034  const pcmk_resource_t *parent = rsc;
1035 
1036  if (parent == NULL) {
1037  return NULL;
1038  }
1039  while (parent->parent != NULL) {
1040  if (!include_bundle && pcmk__is_bundle(parent->parent)) {
1041  break;
1042  }
1043  parent = parent->parent;
1044  }
1045  return parent;
1046 }
1047 
1048 void
1050 {
1051  if (rsc == NULL) {
1052  return;
1053  }
1054 
1055  pcmk__rsc_trace(rsc, "Freeing %s %d", rsc->id, rsc->variant);
1056 
1057  g_list_free(rsc->rsc_cons);
1058  g_list_free(rsc->rsc_cons_lhs);
1059  g_list_free(rsc->rsc_tickets);
1060  g_list_free(rsc->dangling_migrations);
1061 
1062  if (rsc->parameter_cache != NULL) {
1063  g_hash_table_destroy(rsc->parameter_cache);
1064  }
1065  if (rsc->meta != NULL) {
1066  g_hash_table_destroy(rsc->meta);
1067  }
1068  if (rsc->utilization != NULL) {
1069  g_hash_table_destroy(rsc->utilization);
1070  }
1071 
1072  if ((rsc->parent == NULL)
1073  && pcmk_is_set(rsc->flags, pcmk_rsc_removed)) {
1074 
1075  free_xml(rsc->xml);
1076  rsc->xml = NULL;
1077  free_xml(rsc->orig_xml);
1078  rsc->orig_xml = NULL;
1079 
1080  /* if rsc->orig_xml, then rsc->xml is an expanded xml from a template */
1081  } else if (rsc->orig_xml) {
1082  free_xml(rsc->xml);
1083  rsc->xml = NULL;
1084  }
1085  if (rsc->running_on) {
1086  g_list_free(rsc->running_on);
1087  rsc->running_on = NULL;
1088  }
1089  if (rsc->known_on) {
1090  g_hash_table_destroy(rsc->known_on);
1091  rsc->known_on = NULL;
1092  }
1093  if (rsc->actions) {
1094  g_list_free(rsc->actions);
1095  rsc->actions = NULL;
1096  }
1097  if (rsc->allowed_nodes) {
1098  g_hash_table_destroy(rsc->allowed_nodes);
1099  rsc->allowed_nodes = NULL;
1100  }
1101  g_list_free(rsc->fillers);
1102  g_list_free(rsc->rsc_location);
1103  pcmk__rsc_trace(rsc, "Resource freed");
1104  free(rsc->id);
1105  free(rsc->clone_name);
1106  free(rsc->allocated_to);
1107  free(rsc->variant_opaque);
1108  free(rsc->pending_task);
1109  free(rsc);
1110 }
1111 
1126 bool
1128  pcmk_node_t **active, unsigned int *count_all,
1129  unsigned int *count_clean)
1130 {
1131  bool keep_looking = false;
1132  bool is_happy = false;
1133 
1134  CRM_CHECK((rsc != NULL) && (node != NULL) && (active != NULL),
1135  return false);
1136 
1137  is_happy = node->details->online && !node->details->unclean;
1138 
1139  if (count_all != NULL) {
1140  ++*count_all;
1141  }
1142  if ((count_clean != NULL) && is_happy) {
1143  ++*count_clean;
1144  }
1145  if ((count_all != NULL) || (count_clean != NULL)) {
1146  keep_looking = true; // We're counting, so go through entire list
1147  }
1148 
1149  if (rsc->partial_migration_source != NULL) {
1150  if (pcmk__same_node(node, rsc->partial_migration_source)) {
1151  *active = node; // This is the migration source
1152  } else {
1153  keep_looking = true;
1154  }
1155  } else if (!pcmk_is_set(rsc->flags, pcmk_rsc_needs_fencing)) {
1156  if (is_happy && ((*active == NULL) || !(*active)->details->online
1157  || (*active)->details->unclean)) {
1158  *active = node; // This is the first clean node
1159  } else {
1160  keep_looking = true;
1161  }
1162  }
1163  if (*active == NULL) {
1164  *active = node; // This is the first node checked
1165  }
1166  return keep_looking;
1167 }
1168 
1169 // Shared implementation of pcmk_rsc_methods_t:active_node()
1170 static pcmk_node_t *
1171 active_node(const pcmk_resource_t *rsc, unsigned int *count_all,
1172  unsigned int *count_clean)
1173 {
1174  pcmk_node_t *active = NULL;
1175 
1176  if (count_all != NULL) {
1177  *count_all = 0;
1178  }
1179  if (count_clean != NULL) {
1180  *count_clean = 0;
1181  }
1182  if (rsc == NULL) {
1183  return NULL;
1184  }
1185  for (GList *iter = rsc->running_on; iter != NULL; iter = iter->next) {
1186  if (!pe__count_active_node(rsc, (pcmk_node_t *) iter->data, &active,
1187  count_all, count_clean)) {
1188  break; // Don't waste time iterating if we don't have to
1189  }
1190  }
1191  return active;
1192 }
1193 
1207 pcmk_node_t *
1208 pe__find_active_requires(const pcmk_resource_t *rsc, unsigned int *count)
1209 {
1210  if (rsc == NULL) {
1211  if (count != NULL) {
1212  *count = 0;
1213  }
1214  return NULL;
1215 
1216  } else if (pcmk_is_set(rsc->flags, pcmk_rsc_needs_fencing)) {
1217  return rsc->fns->active_node(rsc, count, NULL);
1218 
1219  } else {
1220  return rsc->fns->active_node(rsc, NULL, count);
1221  }
1222 }
1223 
1224 void
1226 {
1227  if (rsc->children != NULL) {
1228  for (GList *item = rsc->children; item != NULL; item = item->next) {
1229  ((pcmk_resource_t *) item->data)->fns->count(item->data);
1230  }
1231 
1232  } else if (!pcmk_is_set(rsc->flags, pcmk_rsc_removed)
1233  || (rsc->role > pcmk_role_stopped)) {
1234  rsc->cluster->ninstances++;
1235  if (pe__resource_is_disabled(rsc)) {
1236  rsc->cluster->disabled_resources++;
1237  }
1238  if (pcmk_is_set(rsc->flags, pcmk_rsc_blocked)) {
1239  rsc->cluster->blocked_resources++;
1240  }
1241  }
1242 }
1243 
1252 void
1253 pe__set_next_role(pcmk_resource_t *rsc, enum rsc_role_e role, const char *why)
1254 {
1255  CRM_ASSERT((rsc != NULL) && (why != NULL));
1256  if (rsc->next_role != role) {
1257  pcmk__rsc_trace(rsc, "Resetting next role for %s from %s to %s (%s)",
1258  rsc->id, pcmk_role_text(rsc->next_role),
1259  pcmk_role_text(role), why);
1260  rsc->next_role = role;
1261  }
1262 }
gboolean native_active(pcmk_resource_t *rsc, gboolean all)
Definition: native.c:345
#define LOG_TRACE
Definition: logging.h:38
void pe__count_bundle(pcmk_resource_t *rsc)
Definition: bundle.c:2100
#define CRM_CHECK(expr, failure_action)
Definition: logging.h:245
xmlNode * orig_xml
Definition: resources.h:403
xmlNode * pcmk__xml_copy(xmlNode *parent, xmlNode *src)
Definition: xml.c:883
enum pe_quorum_policy no_quorum_policy
Definition: scheduler.h:217
#define PCMK_VALUE_STOP_UNEXPECTED
Definition: options.h:212
GHashTable * known_on
Definition: resources.h:459
pcmk_scheduler_t * cluster
Definition: resources.h:408
GHashTable * attrs
Definition: nodes.h:142
#define PCMK_XA_NAME
Definition: xml_names.h:325
const char * pcmk_role_text(enum rsc_role_e role)
Get readable description of a resource role.
Definition: roles.c:23
unsigned int pe__clone_max_per_node(const pcmk_resource_t *rsc)
Definition: clone.c:1554
GList * rsc_tickets
Definition: resources.h:445
#define PCMK_META_PROMOTABLE
Definition: options.h:101
char data[0]
Definition: cpg.c:58
pcmk_resource_t * uber_parent(pcmk_resource_t *rsc)
Definition: complex.c:1007
GList * rsc_cons
Definition: resources.h:442
void pe__free_bundle(pcmk_resource_t *rsc)
Definition: bundle.c:2040
#define PCMK_META_MIGRATION_THRESHOLD
Definition: options.h:95
#define PCMK_META_REQUIRES
Definition: options.h:110
#define PCMK_REMOTE_RA_RECONNECT_INTERVAL
Definition: options.h:124
#define PCMK_XE_TEMPLATE
Definition: xml_names.h:206
Stopped.
Definition: roles.h:36
const char * name
Definition: cib.c:26
bool pcmk__strcase_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
Definition: strings.c:1026
#define PCMK_XE_PRIMITIVE
Definition: xml_names.h:160
enum rsc_role_e role
Definition: resources.h:464
#define pcmk__config_warn(fmt...)
GList * children
Definition: resources.h:471
#define pcmk__rsc_trace(rsc, fmt, args...)
xmlNode * xml
Definition: resources.h:400
#define PCMK_XE_RSC_DEFAULTS
Definition: xml_names.h:182
enum rsc_role_e next_role
Definition: resources.h:465
gboolean get_target_role(const pcmk_resource_t *rsc, enum rsc_role_e *role)
Definition: utils.c:410
#define pcmk__insert_meta(obj, name, value)
#define pcmk__config_err(fmt...)
#define PCMK_VALUE_STOP_START
Definition: options.h:211
pcmk_node_t * pe__find_active_requires(const pcmk_resource_t *rsc, unsigned int *count)
Definition: complex.c:1208
GHashTable * meta
Definition: resources.h:467
gboolean is_parent(pcmk_resource_t *child, pcmk_resource_t *rsc)
Definition: complex.c:990
#define PCMK_VALUE_RESTART
Definition: options.h:199
#define PCMK_VALUE_DEFAULT
Definition: options.h:142
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_META_MULTIPLE_ACTIVE
Definition: options.h:96
#define PCMK_XA_PROVIDER
Definition: xml_names.h:359
enum rsc_role_e native_resource_state(const pcmk_resource_t *rsc, gboolean current)
Definition: native.c:1111
#define PCMK_VALUE_BLOCK
Definition: options.h:135
GList * rsc_cons_lhs
Definition: resources.h:441
#define PCMK__META_CLONE
#define PCMK_XE_BUNDLE
Definition: xml_names.h:72
unsigned int pe__bundle_max_per_node(const pcmk_resource_t *rsc)
Definition: bundle.c:2267
bool pe__count_active_node(const pcmk_resource_t *rsc, pcmk_node_t *node, pcmk_node_t **active, unsigned int *count_all, unsigned int *count_clean)
Definition: complex.c:1127
#define PCMK_XA_TYPE
Definition: xml_names.h:425
char * pending_task
Definition: resources.h:424
int pe__unpack_resource(xmlNode *xml_obj, pcmk_resource_t **rsc, pcmk_resource_t *parent, pcmk_scheduler_t *scheduler)
Definition: complex.c:639
xmlNode * get_xpath_object(const char *xpath, xmlNode *xml_obj, int error_level)
Definition: xpath.c:189
unsigned int pe__group_max_per_node(const pcmk_resource_t *rsc)
Definition: group.c:537
#define PCMK_XA_TEMPLATE
Definition: xml_names.h:420
gboolean clone_unpack(pcmk_resource_t *rsc, pcmk_scheduler_t *scheduler)
Definition: clone.c:348
#define PCMK_META_IS_MANAGED
Definition: options.h:92
#define PCMK_VALUE_NOTHING
Definition: options.h:181
#define PCMK_VALUE_FENCING
Definition: options.h:154
char int pcmk_parse_interval_spec(const char *input, guint *result_ms)
Parse milliseconds from a Pacemaker interval specification.
Definition: strings.c:451
gboolean native_unpack(pcmk_resource_t *rsc, pcmk_scheduler_t *scheduler)
Definition: native.c:204
void pe__print_bundle(pcmk_resource_t *rsc, const char *pre_text, long options, void *print_data)
Definition: bundle.c:1938
gboolean group_unpack(pcmk_resource_t *rsc, pcmk_scheduler_t *scheduler)
Definition: group.c:180
#define PCMK_XE_CLONE
Definition: xml_names.h:80
#define PCMK_META_GLOBALLY_UNIQUE
Definition: options.h:89
pcmk_resource_t * parent
Definition: resources.h:409
GList * dangling_migrations
Definition: resources.h:474
#define PCMK_RESOURCE_CLASS_UPSTART
Definition: agents.h:36
gboolean clone_active(pcmk_resource_t *rsc, gboolean all)
Definition: clone.c:465
gboolean pe__bundle_is_filtered(const pcmk_resource_t *rsc, GList *only_rsc, gboolean check_parent)
Definition: bundle.c:2124
gboolean pe__clone_is_filtered(const pcmk_resource_t *rsc, GList *only_rsc, gboolean check_parent)
Definition: clone.c:1297
#define PCMK__ROLE_UNPROMOTED_LEGACY
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
Definition: nvpair.c:446
xmlNode * pcmk__xe_first_child(const xmlNode *parent, const char *node_name, const char *attr_n, const char *attr_v)
Definition: xml.c:440
void resource_location(pcmk_resource_t *rsc, const pcmk_node_t *node, int score, const char *tag, pcmk_scheduler_t *scheduler)
Definition: utils.c:359
#define pcmk__sched_err(fmt...)
#define PCMK_XE_UTILIZATION
Definition: xml_names.h:212
xmlNode * rsc_defaults
Definition: scheduler.h:242
int char2score(const char *score)
Get the integer value of a score string.
Definition: scores.c:36
unsigned int pe__primitive_max_per_node(const pcmk_resource_t *rsc)
Definition: native.c:1467
#define PCMK_RESOURCE_CLASS_STONITH
Definition: agents.h:31
bool xml_contains_remote_node(xmlNode *xml)
Definition: remote.c:47
GHashTable * pe_rsc_params(pcmk_resource_t *rsc, const pcmk_node_t *node, pcmk_scheduler_t *scheduler)
Get a table of resource parameters.
Definition: complex.c:484
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
enum rsc_role_e clone_resource_state(const pcmk_resource_t *rsc, gboolean current)
Definition: clone.c:1257
struct pe_node_shared_s * details
Definition: nodes.h:167
xmlNode * expand_idref(xmlNode *input, xmlNode *top)
Definition: xml.c:2152
#define PCMK_META_RESOURCE_STICKINESS
Definition: options.h:111
pe_obj_types
Definition: resources.h:34
unsigned long long flags
Definition: resources.h:428
const char * uname
Definition: nodes.h:73
Wrappers for and extensions to libxml2.
rsc_role_e
Definition: roles.h:34
char * clone_name
Definition: resources.h:397
gboolean add_tag_ref(GHashTable *tags, const char *tag_name, const char *obj_ref)
Definition: utils.c:627
void group_free(pcmk_resource_t *rsc)
Definition: group.c:458
void native_free(pcmk_resource_t *rsc)
Definition: native.c:1104
void pe__unpack_dataset_nvpairs(const xmlNode *xml_obj, const char *set_name, const pe_rule_eval_data_t *rule_data, GHashTable *hash, const char *always_first, gboolean overwrite, pcmk_scheduler_t *scheduler)
Definition: utils.c:719
GList * actions
Definition: resources.h:444
void get_meta_attributes(GHashTable *meta_hash, pcmk_resource_t *rsc, pcmk_node_t *node, pcmk_scheduler_t *scheduler)
Definition: complex.c:174
void common_free(pcmk_resource_t *rsc)
Definition: complex.c:1049
GHashTable * utilization
Definition: resources.h:469
enum rsc_role_e pe__bundle_resource_state(const pcmk_resource_t *rsc, gboolean current)
Definition: bundle.c:2074
#define PCMK_VALUE_TRUE
Definition: options.h:215
#define PCMK_XA_ID
Definition: xml_names.h:296
#define PCMK_XE_OPERATIONS
Definition: xml_names.h:148
void pe__count_common(pcmk_resource_t *rsc)
Definition: complex.c:1225
#define pcmk__set_rsc_flags(resource, flags_to_set)
void group_print(pcmk_resource_t *rsc, const char *pre_text, long options, void *print_data)
Definition: group.c:290
void free_xml(xmlNode *child)
Definition: xml.c:867
#define PCMK_VALUE_QUORUM
Definition: options.h:195
enum pe_obj_types variant
Definition: resources.h:410
xmlNode * input
Definition: scheduler.h:196
#define pcmk__warn_once(wo_flag, fmt...)
gboolean group_active(pcmk_resource_t *rsc, gboolean all)
Definition: group.c:236
#define PCMK_XE_META_ATTRIBUTES
Definition: xml_names.h:127
void populate_hash(xmlNode *nvpair_list, GHashTable *hash, const char **attrs, int attrs_length)
GList * fillers
Definition: resources.h:477
char * native_parameter(pcmk_resource_t *rsc, pcmk_node_t *node, gboolean create, const char *name, pcmk_scheduler_t *scheduler)
Definition: native.c:325
pcmk_resource_t * native_find_rsc(pcmk_resource_t *rsc, const char *id, const pcmk_node_t *node, int flags)
Definition: native.c:271
const pcmk_resource_t * pe__const_top_resource(const pcmk_resource_t *rsc, bool include_bundle)
Definition: complex.c:1032
#define PCMK_META_NOTIFY
Definition: options.h:97
gboolean pe__native_is_filtered(const pcmk_resource_t *rsc, GList *only_rsc, gboolean check_parent)
Definition: native.c:1443
#define PCMK_META_MAINTENANCE
Definition: options.h:94
void clone_print(pcmk_resource_t *rsc, const char *pre_text, long options, void *print_data)
Definition: clone.c:623
#define PCMK_XA_CLASS
Definition: xml_names.h:241
pcmk_rsc_methods_t resource_class_functions[]
Definition: complex.c:26
gboolean pe__unpack_bundle(pcmk_resource_t *rsc, pcmk_scheduler_t *scheduler)
Definition: bundle.c:984
const char * standard
Definition: common.h:35
GHashTable * pcmk__strkey_table(GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func)
Definition: strings.c:683
#define PCMK__ROLE_UNKNOWN
gboolean pe__bundle_active(pcmk_resource_t *rsc, gboolean all)
Definition: bundle.c:1354
crm_time_t * now
Definition: common.h:48
pcmk_rsc_methods_t * fns
Definition: resources.h:412
#define PCMK_ROLE_STARTED
Definition: roles.h:26
void * variant_opaque
Definition: resources.h:411
pcmk_scheduler_t * scheduler
#define CRM_ASSERT(expr)
Definition: results.h:42
GHashTable * node_hash
Definition: common.h:46
int disabled_resources
Definition: scheduler.h:255
#define PCMK_VALUE_STOP_ONLY
Definition: options.h:210
#define PCMK__META_RESTART_TYPE
#define PCMK_META_FAILURE_TIMEOUT
Definition: options.h:88
pcmk_node_t *(* active_node)(const pcmk_resource_t *rsc, unsigned int *count_all, unsigned int *count_clean)
Definition: resources.h:373
bool pe__resource_is_disabled(const pcmk_resource_t *rsc)
Definition: utils.c:737
pcmk_node_t * allocated_to
Definition: resources.h:447
GList * rsc_location
Definition: resources.h:443
#define PCMK_ROLE_UNPROMOTED
Definition: roles.h:27
#define PCMK_XE_GROUP
Definition: xml_names.h:116
GList * running_on
Definition: resources.h:456
#define PCMK_META_CRITICAL
Definition: options.h:86
#define PCMK_META_PRIORITY
Definition: options.h:100
void clone_free(pcmk_resource_t *rsc)
Definition: clone.c:1223
#define crm_log_xml_trace(xml, text)
Definition: logging.h:412
GHashTable * parameter_cache
Definition: resources.h:491
enum rsc_role_e group_resource_state(const pcmk_resource_t *rsc, gboolean current)
Definition: group.c:479
#define PCMK_VALUE_UNFENCING
Definition: options.h:216
gboolean crm_is_true(const char *s)
Definition: strings.c:488
#define PCMK__META_CONTAINER
void pe__set_next_role(pcmk_resource_t *rsc, enum rsc_role_e role, const char *why)
Definition: complex.c:1253
Resource role is unknown.
Definition: roles.h:35
pcmk_node_t * pe__bundle_active_node(const pcmk_resource_t *rsc, unsigned int *count_all, unsigned int *count_clean)
Definition: bundle.c:2184
#define PCMK_RESOURCE_CLASS_NAGIOS
Definition: agents.h:34
unsigned long long flags
Definition: scheduler.h:211
const char * parent
Definition: cib.c:27
pcmk_node_t * native_location(const pcmk_resource_t *rsc, GList **list, int current)
Definition: native.c:1134
gboolean pe__group_is_filtered(const pcmk_resource_t *rsc, GList *only_rsc, gboolean check_parent)
Definition: group.c:498
#define PCMK_XE_INSTANCE_ATTRIBUTES
Definition: xml_names.h:119
gboolean unclean
Definition: nodes.h:91
void get_rsc_attributes(GHashTable *meta_hash, const pcmk_resource_t *rsc, const pcmk_node_t *node, pcmk_scheduler_t *scheduler)
Definition: complex.c:231
#define PCMK_XA_ROLE
Definition: xml_names.h:382
#define PCMK__XE_PROMOTABLE_LEGACY
crm_time_t * now
Definition: scheduler.h:198
#define pcmk__clear_rsc_flags(resource, flags_to_clear)
#define PCMK_XE_RESOURCES
Definition: xml_names.h:175
void pcmk__insert_dup(GHashTable *table, const char *name, const char *value)
Definition: strings.c:701
#define pcmk__set_scheduler_flags(scheduler, flags_to_set)
GHashTable * template_rsc_sets
Definition: scheduler.h:248
gboolean online
Definition: nodes.h:80
void native_print(pcmk_resource_t *rsc, const char *pre_text, long options, void *print_data)
Definition: native.c:939
#define PCMK_META_ALLOW_MIGRATE
Definition: options.h:80
pcmk_node_t * partial_migration_source
Definition: resources.h:453
GHashTable * pcmk__strikey_table(GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func)
Definition: strings.c:739
#define PCMK_SCORE_INFINITY
Integer score to use to represent "infinity".
Definition: scores.h:24
GHashTable * allowed_nodes
Definition: resources.h:462