17 void populate_hash(xmlNode * nvpair_list, GHashTable * hash,
const char **attrs,
int attrs_length);
71 get_resource_type(
const char *
name)
94 dup_attr(gpointer key, gpointer value, gpointer user_data)
114 rule_data, parent_orig_meta, NULL, FALSE, data_set);
119 if (parent_orig_meta != NULL) {
124 g_hash_table_iter_init(&iter, parent_orig_meta);
125 while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &value)) {
128 dup_attr(key, value, meta_hash);
132 if (parent_orig_meta != NULL) {
133 g_hash_table_destroy(parent_orig_meta);
152 .now = data_set->
now,
154 .rsc_data = &rsc_rule_data,
162 for (xmlAttrPtr a = pcmk__xe_first_attr(rsc->
xml); a != NULL; a = a->next) {
163 const char *prop_name = (
const char *) a->name;
170 meta_hash, NULL, FALSE, data_set);
174 if (rsc->
parent != NULL) {
175 expand_parents_fixed_nvpairs(rsc, &rule_data, meta_hash, data_set);
180 &rule_data, meta_hash, NULL, FALSE, data_set);
185 g_hash_table_foreach(rsc->
parent->
meta, dup_attr, meta_hash);
196 .now = data_set->
now,
207 meta_hash, NULL, FALSE, data_set);
210 if (rsc->
parent != NULL) {
216 &rule_data, meta_hash, NULL, FALSE, data_set);
220 #if ENABLE_VERSIONED_ATTRS 222 pe_get_versioned_attributes(xmlNode * meta_hash,
pe_resource_t * rsc,
228 .now = data_set->
now,
235 &rule_data, meta_hash, NULL);
238 if (rsc->
parent != NULL) {
239 pe_get_versioned_attributes(meta_hash, rsc->
parent, node, data_set);
251 template_op_key(xmlNode * op)
268 unpack_template(xmlNode * xml_obj, xmlNode ** expanded_xml,
pe_working_set_t * data_set)
270 xmlNode *cib_resources = NULL;
271 xmlNode *
template = NULL;
272 xmlNode *new_xml = NULL;
273 xmlNode *child_xml = NULL;
274 xmlNode *rsc_ops = NULL;
275 xmlNode *template_ops = NULL;
276 const char *template_ref = NULL;
277 const char *clone = NULL;
278 const char *
id = NULL;
280 if (xml_obj == NULL) {
281 pe_err(
"No resource object for template unpacking");
286 if (template_ref == NULL) {
292 pe_err(
"'%s' object must have a id", crm_element_name(xml_obj));
297 pe_err(
"The resource object '%s' should not reference itself",
id);
302 if (cib_resources == NULL) {
303 pe_err(
"No resources configured");
309 if (
template == NULL) {
310 pe_err(
"No template named '%s'", template_ref);
315 xmlNodeSetName(new_xml, xml_obj->name);
325 for (child_xml = pcmk__xe_first_child(xml_obj); child_xml != NULL;
326 child_xml = pcmk__xe_next(child_xml)) {
327 xmlNode *new_child = NULL;
331 if (pcmk__str_eq((
const char *)new_child->name,
"operations",
pcmk__str_none)) {
336 if (template_ops && rsc_ops) {
340 for (op = pcmk__xe_first_child(rsc_ops); op != NULL;
341 op = pcmk__xe_next(op)) {
343 char *key = template_op_key(op);
345 g_hash_table_insert(rsc_ops_hash, key, op);
348 for (op = pcmk__xe_first_child(template_ops); op != NULL;
349 op = pcmk__xe_next(op)) {
351 char *key = template_op_key(op);
353 if (g_hash_table_lookup(rsc_ops_hash, key) == NULL) {
361 g_hash_table_destroy(rsc_ops_hash);
368 *expanded_xml = new_xml;
384 const char *template_ref = NULL;
385 const char *
id = NULL;
387 if (xml_obj == NULL) {
388 pe_err(
"No resource object for processing resource list of template");
393 if (template_ref == NULL) {
399 pe_err(
"'%s' object must have a id", crm_element_name(xml_obj));
404 pe_err(
"The resource object '%s' should not reference itself",
id);
418 const char *promotable = g_hash_table_lookup(rsc->
meta,
439 free_params_table(gpointer
data)
441 g_hash_table_destroy((GHashTable *)
data);
459 GHashTable *params_on_node = NULL;
465 const char *node_name =
"";
468 if ((rsc == NULL) || (data_set == NULL)) {
483 if (params_on_node == NULL) {
489 return params_on_node;
496 bool isdefault = FALSE;
497 xmlNode *expanded_xml = NULL;
499 const char *value = NULL;
500 const char *rclass = NULL;
502 bool guest_node = FALSE;
503 bool remote_node = FALSE;
504 bool has_versioned_params = FALSE;
509 .now = data_set->
now,
518 pe_err(
"Must specify id tag in <resource>");
521 }
else if (rsc == NULL) {
522 pe_err(
"Nowhere to unpack resource into");
527 if (unpack_template(xml_obj, &expanded_xml, data_set) == FALSE) {
532 (*rsc)->cluster = data_set;
536 (*rsc)->xml = expanded_xml;
537 (*rsc)->orig_xml = xml_obj;
540 (*rsc)->xml = xml_obj;
541 (*rsc)->orig_xml = NULL;
546 (*rsc)->parent = parent;
551 (*rsc)->variant = get_resource_type(crm_element_name((*rsc)->xml));
553 pe_err(
"Unknown resource type: %s", crm_element_name((*rsc)->xml));
558 #if ENABLE_VERSIONED_ATTRS 572 (*rsc)->id = strdup(
id);
580 #if ENABLE_VERSIONED_ATTRS 581 pe_get_versioned_attributes((*rsc)->versioned_parameters, *rsc, NULL, data_set);
591 (*rsc)->rsc_cons = NULL;
592 (*rsc)->rsc_tickets = NULL;
593 (*rsc)->actions = NULL;
598 (*rsc)->stickiness = 0;
599 (*rsc)->migration_threshold =
INFINITY;
600 (*rsc)->failure_timeout = 0;
616 (*rsc)->is_remote_node = TRUE;
625 #if ENABLE_VERSIONED_ATTRS 629 pe_rsc_trace((*rsc),
"Migration is disabled for resources with versioned parameters");
632 }
else if ((value == NULL) && remote_node && !has_versioned_params) {
644 if (value != NULL && !pcmk__str_eq(
"default", value,
pcmk__str_casei)) {
667 if (detect_promotable(*rsc)) {
679 pe_rsc_trace((*rsc),
"\tDependency restart handling: restart");
681 "Support for restart-type is deprecated and will be removed in a future release");
685 pe_rsc_trace((*rsc),
"\tDependency restart handling: ignore");
691 pe_rsc_trace((*rsc),
"\tMultiple running resource recovery: stop only");
695 pe_rsc_trace((*rsc),
"\tMultiple running resource recovery: block");
699 pe_rsc_trace((*rsc),
"\tMultiple running resource recovery: stop/start");
703 if (value != NULL && !pcmk__str_eq(
"default", value,
pcmk__str_casei)) {
708 if (value != NULL && !pcmk__str_eq(
"default", value,
pcmk__str_casei)) {
709 (*rsc)->migration_threshold =
char2score(value);
710 if ((*rsc)->migration_threshold < 0) {
717 " must be non-negative, using 1 instead");
718 (*rsc)->migration_threshold = 1;
729 handle_requires_pref:
738 "to 'quorum' because fencing devices cannot " 739 "require unfencing", (*rsc)->id);
742 goto handle_requires_pref;
746 "to 'quorum' because fencing is disabled",
750 goto handle_requires_pref;
765 const char *orig_value = value;
771 }
else if (((*rsc)->variant ==
pe_native)
791 if (orig_value != NULL) {
793 "to '%s' because '%s' is not valid",
794 (*rsc)->id, value, orig_value);
797 goto handle_requires_pref;
800 pe_rsc_trace((*rsc),
"\tRequired to start: %s%s", value, isdefault?
" (default)":
"");
823 (*rsc)->failure_timeout = (*rsc)->remote_reconnect_ms / 1000;
831 if ((*rsc)->fns->unpack(*rsc, data_set) == FALSE) {
838 }
else if (guest_node) {
851 (*rsc)->utilization, NULL, FALSE, data_set);
856 if (add_template_rsc(xml_obj, data_set) == FALSE) {
877 for (; gIter != NULL; gIter = gIter->next) {
890 if (parent == NULL || rsc == NULL) {
893 while (parent->
parent != NULL) {
894 if (parent->
parent == rsc) {
907 if (parent == NULL) {
933 #if ENABLE_VERSIONED_ATTRS 934 if (rsc->versioned_parameters != NULL) {
935 free_xml(rsc->versioned_parameters);
938 if (rsc->
meta != NULL) {
939 g_hash_table_destroy(rsc->
meta);
961 g_hash_table_destroy(rsc->
known_on);
1000 unsigned int *count_clean)
1004 bool keep_looking = FALSE;
1005 bool is_happy = FALSE;
1017 for (GList *node_iter = rsc->
running_on; node_iter != NULL;
1018 node_iter = node_iter->next) {
1020 node = node_iter->data;
1021 keep_looking = FALSE;
1028 if (count_clean && is_happy) {
1031 if (count_all || count_clean) {
1033 keep_looking = TRUE;
1041 keep_looking = TRUE;
1049 keep_looking = TRUE;
1052 if (active == NULL) {
1057 if (keep_looking == FALSE) {
1091 for (GList *item = rsc->
children; item != NULL; item = item->next) {
1120 pe_rsc_trace(rsc,
"Resetting next role for %s from %s to %s (%s)",
pe_resource_t * uber_parent(pe_resource_t *rsc)
xmlNode * find_xml_node(xmlNode *cib, const char *node_path, gboolean must_find)
#define RSC_ROLE_UNPROMOTED_S
enum pe_quorum_policy no_quorum_policy
void pe__count_common(pe_resource_t *rsc)
void group_free(pe_resource_t *rsc)
void group_print(pe_resource_t *rsc, const char *pre_text, long options, void *print_data)
#define XML_EXPR_ATTR_TYPE
#define XML_CIB_TAG_CONTAINER
bool pcmk__strcase_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
pe_node_t * partial_migration_source
#define XML_TAG_UTILIZATION
#define pcmk__config_warn(fmt...)
#define RSC_ROLE_STARTED_S
void pe__free_bundle(pe_resource_t *rsc)
#define pe_flag_symmetric_cluster
enum rsc_role_e pe__bundle_resource_state(const pe_resource_t *rsc, gboolean current)
#define XML_RSC_ATTR_INCARNATION
gboolean pe__group_is_filtered(pe_resource_t *rsc, GList *only_rsc, gboolean check_parent)
enum rsc_role_e next_role
#define pe_flag_maintenance_mode
gboolean group_active(pe_resource_t *rsc, gboolean all)
int char2score(const char *score)
#define pcmk__config_err(fmt...)
pe_node_t * native_location(const pe_resource_t *rsc, GList **list, int current)
xmlNode * pcmk__xe_match(xmlNode *parent, const char *node_name, const char *attr_n, const char *attr_v)
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
#define XML_CIB_TAG_RSC_TEMPLATE
#define XML_RSC_ATTR_STICKINESS
void resource_location(pe_resource_t *rsc, pe_node_t *node, int score, const char *tag, pe_working_set_t *data_set)
void pe__set_next_role(pe_resource_t *rsc, enum rsc_role_e role, const char *why)
void pe__print_bundle(pe_resource_t *rsc, const char *pre_text, long options, void *print_data)
xmlNode * get_xpath_object(const char *xpath, xmlNode *xml_obj, int error_level)
gboolean pe__unpack_bundle(pe_resource_t *rsc, pe_working_set_t *data_set)
void native_free(pe_resource_t *rsc)
#define pe__set_resource_flags(resource, flags_to_set)
void clone_free(pe_resource_t *rsc)
#define XML_CIB_ATTR_PRIORITY
void pe__unpack_dataset_nvpairs(xmlNode *xml_obj, const char *set_name, pe_rule_eval_data_t *rule_data, GHashTable *hash, const char *always_first, gboolean overwrite, pe_working_set_t *data_set)
xmlNode * copy_xml(xmlNode *src_node)
enum rsc_role_e group_resource_state(const pe_resource_t *rsc, gboolean current)
#define pe_rsc_provisional
#define XML_TAG_ATTR_SETS
#define XML_CIB_TAG_RESOURCES
#define XML_RSC_ATTR_PROMOTABLE
const char * role2text(enum rsc_role_e role)
GList * dangling_migrations
enum rsc_role_e clone_resource_state(const pe_resource_t *rsc, gboolean current)
#define XML_RSC_ATTR_REQUIRES
#define PCMK_RESOURCE_CLASS_OCF
void get_rsc_attributes(GHashTable *meta_hash, pe_resource_t *rsc, pe_node_t *node, pe_working_set_t *data_set)
gboolean pe__native_is_filtered(pe_resource_t *rsc, GList *only_rsc, gboolean check_parent)
#define pe_rsc_allow_migrate
#define XML_RSC_ATTR_CRITICAL
resource_object_functions_t resource_class_functions[]
#define XML_RSC_ATTR_CONTAINER
gboolean clone_active(pe_resource_t *rsc, gboolean all)
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
#define XML_CIB_TAG_RESOURCE
const char * crm_xml_replace(xmlNode *node, const char *name, const char *value)
Replace an XML attribute with specified name and (possibly NULL) value.
#define pe_warn_once(pe_wo_bit, fmt...)
char * native_parameter(pe_resource_t *rsc, pe_node_t *node, gboolean create, const char *name, pe_working_set_t *data_set)
#define RSC_ROLE_UNPROMOTED_LEGACY_S
bool xml_contains_remote_node(xmlNode *xml)
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.
xmlNode * add_node_copy(xmlNode *new_parent, xmlNode *xml_node)
pe_node_t * pe__find_active_on(const pe_resource_t *rsc, unsigned int *count_all, unsigned int *count_clean)
struct pe_node_shared_s * details
gboolean get_target_role(pe_resource_t *rsc, enum rsc_role_e *role)
xmlNode * expand_idref(xmlNode *input, xmlNode *top)
#define XML_AGENT_ATTR_PROVIDER
#define pe_rsc_needs_fencing
#define pe_rsc_promotable
#define XML_TAG_META_SETS
gboolean add_tag_ref(GHashTable *tags, const char *tag_name, const char *obj_ref)
#define XML_RSC_ATTR_MANAGED
xmlNode * create_xml_node(xmlNode *parent, const char *name)
#define pe_flag_stonith_enabled
enum rsc_role_e native_resource_state(const pe_resource_t *rsc, gboolean current)
void clone_print(pe_resource_t *rsc, const char *pre_text, long options, void *print_data)
GHashTable * pe_rsc_params(pe_resource_t *rsc, pe_node_t *node, pe_working_set_t *data_set)
Get a table of resource parameters.
void native_print(pe_resource_t *rsc, const char *pre_text, long options, void *print_data)
gboolean pe__bundle_is_filtered(pe_resource_t *rsc, GList *only_rsc, gboolean check_parent)
#define XML_TAG_RSC_VER_ATTRS
void free_xml(xmlNode *child)
enum pe_obj_types variant
gboolean xml_has_children(const xmlNode *root)
#define XML_REMOTE_ATTR_RECONNECT_INTERVAL
#define XML_RSC_ATTR_NOTIFY
#define XML_RSC_ATTR_FAIL_STICKINESS
gboolean native_active(pe_resource_t *rsc, gboolean all)
void populate_hash(xmlNode *nvpair_list, GHashTable *hash, const char **attrs, int attrs_length)
#define pe_rsc_fence_device
#define XML_RSC_ATTR_UNIQUE
#define PCMK_RESOURCE_CLASS_STONITH
pe_resource_t * native_find_rsc(pe_resource_t *rsc, const char *id, const pe_node_t *node, int flags)
#define XML_CIB_TAG_INCARNATION
GHashTable * pcmk__strkey_table(GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func)
#define XML_RSC_ATTR_MAINTENANCE
#define XML_RSC_ATTR_FAIL_TIMEOUT
void get_meta_attributes(GHashTable *meta_hash, pe_resource_t *rsc, pe_node_t *node, pe_working_set_t *data_set)
void add_hash_param(GHashTable *hash, const char *name, const char *value)
int pe__add_scores(int score1, int score2)
gboolean clone_unpack(pe_resource_t *rsc, pe_working_set_t *data_set)
char guint crm_parse_interval_spec(const char *input)
Parse milliseconds from a Pacemaker interval specification.
gboolean is_parent(pe_resource_t *child, pe_resource_t *rsc)
#define PCMK_XE_PROMOTABLE_LEGACY
#define pe_rsc_needs_unfencing
#define XML_RSC_ATTR_MULTIPLE
#define pe__clear_resource_flags(resource, flags_to_clear)
#define pe__set_working_set_flags(working_set, flags_to_set)
rsc_role_e
Possible roles that a resource can be in.
#define pe_rsc_maintenance
#define XML_RSC_ATTR_RESTART
pe_working_set_t * cluster
#define RSC_ROLE_UNKNOWN_S
void common_free(pe_resource_t *rsc)
#define pe_rsc_needs_quorum
#define crm_log_xml_trace(xml, text)
GHashTable * parameter_cache
gboolean crm_is_true(const char *s)
#define pe_flag_have_stonith_resource
#define XML_CIB_TAG_GROUP
#define pe_flag_enable_unfencing
#define pe_rsc_trace(rsc, fmt, args...)
bool pe__resource_is_disabled(pe_resource_t *rsc)
void common_update_score(pe_resource_t *rsc, const char *id, int score)
gboolean common_unpack(xmlNode *xml_obj, pe_resource_t **rsc, pe_resource_t *parent, pe_working_set_t *data_set)
gboolean native_unpack(pe_resource_t *rsc, pe_working_set_t *data_set)
gboolean pe__clone_is_filtered(pe_resource_t *rsc, GList *only_rsc, gboolean check_parent)
pe_node_t * pe__find_active_requires(const pe_resource_t *rsc, unsigned int *count)
GHashTable * template_rsc_sets
void pe__count_bundle(pe_resource_t *rsc)
#define XML_OP_ATTR_ALLOW_MIGRATE
gboolean pe__bundle_active(pe_resource_t *rsc, gboolean all)
GHashTable * pcmk__strikey_table(GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func)
#define XML_AGENT_ATTR_CLASS
GHashTable * allowed_nodes
gboolean group_unpack(pe_resource_t *rsc, pe_working_set_t *data_set)