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)
112 .now = data_set->
now,
114 .rsc_data = &rsc_rule_data,
123 xmlAttrPtr xIter = NULL;
125 for (xIter = rsc->
xml->properties; xIter; xIter = xIter->next) {
126 const char *prop_name = (
const char *)xIter->name;
134 meta_hash, NULL, FALSE, data_set);
137 if (rsc->
parent != NULL) {
138 g_hash_table_foreach(rsc->
parent->
meta, dup_attr, meta_hash);
143 &rule_data, meta_hash, NULL, FALSE, data_set);
153 .now = data_set->
now,
164 meta_hash, NULL, FALSE, data_set);
167 if (rsc->
parent != NULL) {
173 &rule_data, meta_hash, NULL, FALSE, data_set);
177 #if ENABLE_VERSIONED_ATTRS 179 pe_get_versioned_attributes(xmlNode * meta_hash,
pe_resource_t * rsc,
185 .now = data_set->
now,
192 &rule_data, meta_hash, NULL);
195 if (rsc->
parent != NULL) {
196 pe_get_versioned_attributes(meta_hash, rsc->
parent, node, data_set);
208 template_op_key(xmlNode * op)
224 unpack_template(xmlNode * xml_obj, xmlNode ** expanded_xml,
pe_working_set_t * data_set)
226 xmlNode *cib_resources = NULL;
227 xmlNode *
template = NULL;
228 xmlNode *new_xml = NULL;
229 xmlNode *child_xml = NULL;
230 xmlNode *rsc_ops = NULL;
231 xmlNode *template_ops = NULL;
232 const char *template_ref = NULL;
233 const char *clone = NULL;
234 const char *
id = NULL;
236 if (xml_obj == NULL) {
237 pe_err(
"No resource object for template unpacking");
242 if (template_ref == NULL) {
248 pe_err(
"'%s' object must have a id", crm_element_name(xml_obj));
253 pe_err(
"The resource object '%s' should not reference itself",
id);
258 if (cib_resources == NULL) {
259 pe_err(
"No resources configured");
265 if (
template == NULL) {
266 pe_err(
"No template named '%s'", template_ref);
271 xmlNodeSetName(new_xml, xml_obj->name);
281 for (child_xml = pcmk__xe_first_child(xml_obj); child_xml != NULL;
282 child_xml = pcmk__xe_next(child_xml)) {
283 xmlNode *new_child = NULL;
287 if (pcmk__str_eq((
const char *)new_child->name,
"operations",
pcmk__str_none)) {
292 if (template_ops && rsc_ops) {
294 GHashTable *rsc_ops_hash = g_hash_table_new_full(
crm_str_hash,
298 for (op = pcmk__xe_first_child(rsc_ops); op != NULL;
299 op = pcmk__xe_next(op)) {
301 char *key = template_op_key(op);
303 g_hash_table_insert(rsc_ops_hash, key, op);
306 for (op = pcmk__xe_first_child(template_ops); op != NULL;
307 op = pcmk__xe_next(op)) {
309 char *key = template_op_key(op);
311 if (g_hash_table_lookup(rsc_ops_hash, key) == NULL) {
319 g_hash_table_destroy(rsc_ops_hash);
326 *expanded_xml = new_xml;
342 const char *template_ref = NULL;
343 const char *
id = NULL;
345 if (xml_obj == NULL) {
346 pe_err(
"No resource object for processing resource list of template");
351 if (template_ref == NULL) {
357 pe_err(
"'%s' object must have a id", crm_element_name(xml_obj));
362 pe_err(
"The resource object '%s' should not reference itself",
id);
376 const char *promotable = g_hash_table_lookup(rsc->
meta,
399 bool isdefault = FALSE;
400 xmlNode *expanded_xml = NULL;
402 const char *value = NULL;
403 const char *rclass = NULL;
405 bool guest_node = FALSE;
406 bool remote_node = FALSE;
407 bool has_versioned_params = FALSE;
412 .now = data_set->
now,
421 pe_err(
"Must specify id tag in <resource>");
424 }
else if (rsc == NULL) {
425 pe_err(
"Nowhere to unpack resource into");
430 if (unpack_template(xml_obj, &expanded_xml, data_set) == FALSE) {
435 (*rsc)->cluster = data_set;
439 (*rsc)->xml = expanded_xml;
440 (*rsc)->orig_xml = xml_obj;
443 (*rsc)->xml = xml_obj;
444 (*rsc)->orig_xml = NULL;
449 (*rsc)->parent = parent;
454 (*rsc)->variant = get_resource_type(crm_element_name((*rsc)->xml));
456 pe_err(
"Unknown resource type: %s", crm_element_name((*rsc)->xml));
461 (*rsc)->parameters = crm_str_table_new();
463 #if ENABLE_VERSIONED_ATTRS 467 (*rsc)->meta = crm_str_table_new();
469 (*rsc)->allowed_nodes =
470 g_hash_table_new_full(
crm_str_hash, g_str_equal, NULL, free);
472 (*rsc)->known_on = g_hash_table_new_full(
crm_str_hash, g_str_equal, NULL,
481 (*rsc)->id = strdup(
id);
489 #if ENABLE_VERSIONED_ATTRS 490 pe_get_versioned_attributes((*rsc)->versioned_parameters, *rsc, NULL, data_set);
500 (*rsc)->rsc_cons = NULL;
501 (*rsc)->rsc_tickets = NULL;
502 (*rsc)->actions = NULL;
507 (*rsc)->stickiness = 0;
508 (*rsc)->migration_threshold =
INFINITY;
509 (*rsc)->failure_timeout = 0;
520 (*rsc)->is_remote_node = TRUE;
529 #if ENABLE_VERSIONED_ATTRS 533 pe_rsc_trace((*rsc),
"Migration is disabled for resources with versioned parameters");
536 }
else if ((value == NULL) && remote_node && !has_versioned_params) {
548 if (value != NULL && !pcmk__str_eq(
"default", value,
pcmk__str_casei)) {
571 if (detect_promotable(*rsc)) {
583 pe_rsc_trace((*rsc),
"\tDependency restart handling: restart");
585 "Support for restart-type is deprecated and will be removed in a future release");
589 pe_rsc_trace((*rsc),
"\tDependency restart handling: ignore");
595 pe_rsc_trace((*rsc),
"\tMultiple running resource recovery: stop only");
599 pe_rsc_trace((*rsc),
"\tMultiple running resource recovery: block");
603 pe_rsc_trace((*rsc),
"\tMultiple running resource recovery: stop/start");
607 if (value != NULL && !pcmk__str_eq(
"default", value,
pcmk__str_casei)) {
612 if (value != NULL && !pcmk__str_eq(
"default", value,
pcmk__str_casei)) {
613 (*rsc)->migration_threshold =
char2score(value);
614 if ((*rsc)->migration_threshold < 0) {
621 " must be non-negative, using 1 instead");
622 (*rsc)->migration_threshold = 1;
633 handle_requires_pref:
642 "to 'quorum' because fencing devices cannot " 643 "require unfencing", (*rsc)->id);
646 goto handle_requires_pref;
650 "to 'quorum' because fencing is disabled",
654 goto handle_requires_pref;
669 const char *orig_value = value;
675 }
else if (((*rsc)->variant ==
pe_native)
695 if (orig_value != NULL) {
697 "to '%s' because '%s' is not valid",
698 (*rsc)->id, value, orig_value);
701 goto handle_requires_pref;
704 pe_rsc_trace((*rsc),
"\tRequired to start: %s%s", value, isdefault?
" (default)":
"");
719 (*rsc)->failure_timeout = (*rsc)->remote_reconnect_ms / 1000;
727 if ((*rsc)->fns->unpack(*rsc, data_set) == FALSE) {
734 }
else if (guest_node) {
744 (*rsc)->utilization = crm_str_table_new();
747 (*rsc)->utilization, NULL, FALSE, data_set);
752 if (add_template_rsc(xml_obj, data_set) == FALSE) {
773 for (; gIter != NULL; gIter = gIter->next) {
786 if (parent == NULL || rsc == NULL) {
789 while (parent->
parent != NULL) {
790 if (parent->
parent == rsc) {
803 if (parent == NULL) {
829 #if ENABLE_VERSIONED_ATTRS 830 if (rsc->versioned_parameters != NULL) {
831 free_xml(rsc->versioned_parameters);
834 if (rsc->
meta != NULL) {
835 g_hash_table_destroy(rsc->
meta);
857 g_hash_table_destroy(rsc->
known_on);
896 unsigned int *count_clean)
900 bool keep_looking = FALSE;
901 bool is_happy = FALSE;
913 for (GList *node_iter = rsc->
running_on; node_iter != NULL;
914 node_iter = node_iter->next) {
916 node = node_iter->data;
917 keep_looking = FALSE;
924 if (count_clean && is_happy) {
927 if (count_all || count_clean) {
948 if (active == NULL) {
953 if (keep_looking == FALSE) {
987 for (GList *item = rsc->
children; item != NULL; item = item->next) {
pe_resource_t * uber_parent(pe_resource_t *rsc)
xmlNode * find_xml_node(xmlNode *cib, const char *node_path, gboolean must_find)
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)
gboolean pe__group_is_filtered(pe_resource_t *rsc, GListPtr only_rsc, gboolean check_parent)
GListPtr dangling_migrations
#define XML_EXPR_ATTR_TYPE
#define XML_CIB_TAG_CONTAINER
pe_node_t * partial_migration_source
#define XML_TAG_UTILIZATION
#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 pcmk__config_err(fmt...)
#define XML_RSC_ATTR_INCARNATION
#define pe_flag_maintenance_mode
gboolean group_active(pe_resource_t *rsc, gboolean all)
int char2score(const char *score)
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.
int crm_parse_int(const char *text, const char *default_text)
Parse an integer value from a string.
#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)
guint crm_parse_interval_spec(const char *input)
Parse milliseconds from a Pacemaker interval specification.
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)
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)
#define pe_rsc_allow_migrate
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)
bool xml_contains_remote_node(xmlNode *xml)
#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)
void native_print(pe_resource_t *rsc, const char *pre_text, long options, void *print_data)
#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
gboolean pe__bundle_is_filtered(pe_resource_t *rsc, GListPtr only_rsc, gboolean check_parent)
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
#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)
gboolean is_parent(pe_resource_t *child, pe_resource_t *rsc)
gboolean pe__clone_is_filtered(pe_resource_t *rsc, GListPtr only_rsc, gboolean check_parent)
#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)
#define pe_rsc_maintenance
#define XML_RSC_ATTR_RESTART
#define XML_CIB_TAG_MASTER
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)
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)
char * crm_strdup_printf(char const *format,...) __attribute__((__format__(__printf__
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 pcmk__config_warn(fmt...)
#define XML_OP_ATTR_ALLOW_MIGRATE
gboolean pe__native_is_filtered(pe_resource_t *rsc, GListPtr only_rsc, gboolean check_parent)
gboolean pe__bundle_active(pe_resource_t *rsc, gboolean all)
#define XML_AGENT_ATTR_CLASS
GHashTable * allowed_nodes
gboolean group_unpack(pe_resource_t *rsc, pe_working_set_t *data_set)