16 void populate_hash(xmlNode * nvpair_list, GHashTable * hash,
const char **attrs,
int attrs_length);
119 dup_attr(gpointer key, gpointer value, gpointer user_data)
128 GHashTable *node_hash = NULL;
136 xmlAttrPtr xIter = NULL;
138 for (xIter = rsc->
xml->properties; xIter; xIter = xIter->next) {
139 const char *prop_name = (
const char *)xIter->name;
147 meta_hash, NULL, FALSE, data_set->
now);
154 meta_hash, NULL, FALSE, data_set->
now);
158 if (rsc->
parent != NULL) {
159 g_hash_table_foreach(rsc->
parent->
meta, dup_attr, meta_hash);
164 node_hash, meta_hash, NULL, FALSE, data_set->
now);
171 GHashTable *node_hash = NULL;
178 meta_hash, NULL, FALSE, data_set->
now);
181 if (rsc->
parent != NULL) {
187 node_hash, meta_hash, NULL, FALSE, data_set->
now);
191 #if ENABLE_VERSIONED_ATTRS 193 pe_get_versioned_attributes(xmlNode * meta_hash,
resource_t * rsc,
196 GHashTable *node_hash = NULL;
203 meta_hash, data_set->
now);
206 if (rsc->
parent != NULL) {
207 pe_get_versioned_attributes(meta_hash, rsc->
parent, node, data_set);
212 node_hash, meta_hash, data_set->
now);
218 template_op_key(xmlNode * op)
234 unpack_template(xmlNode * xml_obj, xmlNode ** expanded_xml,
pe_working_set_t * data_set)
236 xmlNode *cib_resources = NULL;
237 xmlNode *
template = NULL;
238 xmlNode *new_xml = NULL;
239 xmlNode *child_xml = NULL;
240 xmlNode *rsc_ops = NULL;
241 xmlNode *template_ops = NULL;
242 const char *template_ref = NULL;
243 const char *clone = NULL;
244 const char *
id = NULL;
246 if (xml_obj == NULL) {
247 pe_err(
"No resource object for template unpacking");
252 if (template_ref == NULL) {
258 pe_err(
"'%s' object must have a id", crm_element_name(xml_obj));
263 pe_err(
"The resource object '%s' should not reference itself",
id);
268 if (cib_resources == NULL) {
269 pe_err(
"No resources configured");
274 if (
template == NULL) {
275 pe_err(
"No template named '%s'", template_ref);
280 xmlNodeSetName(new_xml, xml_obj->name);
290 for (child_xml = __xml_first_child_element(xml_obj); child_xml != NULL;
291 child_xml = __xml_next_element(child_xml)) {
292 xmlNode *new_child = NULL;
296 if (
crm_str_eq((
const char *)new_child->name,
"operations", TRUE)) {
301 if (template_ops && rsc_ops) {
303 GHashTable *rsc_ops_hash =
306 for (op = __xml_first_child_element(rsc_ops); op != NULL;
307 op = __xml_next_element(op)) {
309 char *key = template_op_key(op);
311 g_hash_table_insert(rsc_ops_hash, key, op);
314 for (op = __xml_first_child_element(template_ops); op != NULL;
315 op = __xml_next_element(op)) {
317 char *key = template_op_key(op);
319 if (g_hash_table_lookup(rsc_ops_hash, key) == NULL) {
327 g_hash_table_destroy(rsc_ops_hash);
334 *expanded_xml = new_xml;
350 const char *template_ref = NULL;
351 const char *
id = NULL;
353 if (xml_obj == NULL) {
354 pe_err(
"No resource object for processing resource list of template");
359 if (template_ref == NULL) {
365 pe_err(
"'%s' object must have a id", crm_element_name(xml_obj));
370 pe_err(
"The resource object '%s' should not reference itself",
id);
386 const char *wrapper = NULL;
394 if (g_hash_table_lookup(rsc->
parameters,
"pcmk_docker_image")) {
395 wrapper =
"docker-wrapper";
402 if (wrapper == NULL) {
410 if (top == rsc->
parent && pe_rsc_is_clone(top)) {
419 " is deprecated and will be removed in a future release" 420 " (use bundle syntax instead)");
424 if (pe_rsc_is_clone(top)) {
435 g_hash_table_iter_init(&iter, rsc->
parameters);
436 while (g_hash_table_iter_next(&iter, (gpointer *) &key, NULL)) {
440 if (!strcmp(cmp,
"poweroff_action")) {
442 "Support for the 'pcmk_poweroff_action' stonith resource parameter" 443 " is deprecated and will be removed in a future version" 444 " (use 'pcmk_off_action' instead)");
446 }
else if (!strcmp(cmp,
"arg_map")) {
448 "Support for the 'pcmk_arg_map' stonith resource parameter" 449 " is deprecated and will be removed in a future version" 450 " (use 'pcmk_host_argument' instead)");
454 "Support for the 'pcmk_*_cmd' stonith resource parameters" 455 " is deprecated and will be removed in a future version" 456 " (use 'pcmk_*_action' instead)");
466 bool isdefault = FALSE;
467 xmlNode *expanded_xml = NULL;
470 const char *value = NULL;
471 const char *rclass = NULL;
473 int container_remote_node = 0;
474 int baremetal_remote_node = 0;
475 bool has_versioned_params = FALSE;
480 pe_err(
"Must specify id tag in <resource>");
483 }
else if (rsc == NULL) {
484 pe_err(
"Nowhere to unpack resource into");
489 if (unpack_template(xml_obj, &expanded_xml, data_set) == FALSE) {
494 (*rsc)->cluster = data_set;
498 (*rsc)->xml = expanded_xml;
499 (*rsc)->orig_xml = xml_obj;
502 (*rsc)->xml = xml_obj;
503 (*rsc)->orig_xml = NULL;
508 (*rsc)->parent = parent;
515 pe_err(
"Unknown resource type: %s", crm_element_name((*rsc)->xml));
520 (*rsc)->parameters = crm_str_table_new();
522 #if ENABLE_VERSIONED_ATTRS 526 (*rsc)->meta = crm_str_table_new();
528 (*rsc)->allowed_nodes =
539 (*rsc)->id = strdup(
id);
542 (*rsc)->fns = &resource_class_functions[(*rsc)->variant];
547 #if ENABLE_VERSIONED_ATTRS 548 pe_get_versioned_attributes((*rsc)->versioned_parameters, *rsc, NULL, data_set);
559 (*rsc)->rsc_cons = NULL;
560 (*rsc)->rsc_tickets = NULL;
561 (*rsc)->actions = NULL;
567 (*rsc)->migration_threshold =
INFINITY;
568 (*rsc)->failure_timeout = 0;
572 (*rsc)->effective_priority = (*rsc)->priority;
580 (*rsc)->is_remote_node = TRUE;
582 container_remote_node = 1;
584 baremetal_remote_node = 1;
589 #if ENABLE_VERSIONED_ATTRS 593 pe_rsc_trace((*rsc),
"Migration is disabled for resources with versioned parameters");
596 }
else if ((value == NULL) && baremetal_remote_node && !has_versioned_params) {
609 gboolean bool_value = TRUE;
612 if (bool_value == FALSE) {
621 gboolean bool_value = FALSE;
624 if (bool_value == TRUE) {
637 handle_rsc_isolation(*rsc);
641 if (
crm_is_true(value) || pe_rsc_is_clone(top) == FALSE) {
648 pe_rsc_trace((*rsc),
"\tDependency restart handling: restart");
652 pe_rsc_trace((*rsc),
"\tDependency restart handling: ignore");
658 pe_rsc_trace((*rsc),
"\tMultiple running resource recovery: stop only");
662 pe_rsc_trace((*rsc),
"\tMultiple running resource recovery: block");
666 pe_rsc_trace((*rsc),
"\tMultiple running resource recovery: stop/start");
676 (*rsc)->migration_threshold =
char2score(value);
678 }
else if (value == NULL) {
682 const char *legacy = NULL;
684 legacy = g_hash_table_lookup((*rsc)->meta,
685 "resource-failure-stickiness");
686 if (legacy == NULL) {
687 legacy = g_hash_table_lookup((*rsc)->meta,
688 "resource_failure_stickiness");
693 "Support for 'resource-failure-stickiness' resource meta-attribute" 694 " is deprecated and will be removed in a future release" 695 " (use 'migration-threshold' resource meta-attribute instead)");
698 legacy = g_hash_table_lookup(data_set->
config_hash,
699 "default-resource-failure-stickiness");
700 if (legacy == NULL) {
701 legacy = g_hash_table_lookup(data_set->
config_hash,
702 "default_resource_failure_stickiness");
709 "Support for 'default-resource-failure-stickiness' cluster option" 710 " is deprecated and will be removed in a future release" 711 " (use 'migration-threshold' in rsc_defaults instead)");
718 (*rsc)->migration_threshold = 1;
720 "Set a migration threshold of %d for %s based on a failure-stickiness of %s",
721 (*rsc)->migration_threshold, (*rsc)->id, value);
723 }
else if ((*rsc)->stickiness != 0 && fail_sticky != 0) {
724 (*rsc)->migration_threshold = (*rsc)->stickiness / fail_sticky;
725 if ((*rsc)->migration_threshold < 0) {
727 (*rsc)->migration_threshold = 0 - (*rsc)->migration_threshold;
729 (*rsc)->migration_threshold += 1;
731 "Calculated a migration threshold for %s of %d based on a stickiness of %d/%s",
732 (*rsc)->id, (*rsc)->migration_threshold, (*rsc)->stickiness, value);
740 check_deprecated_stonith(*rsc);
745 handle_requires_pref:
753 crm_config_warn(
"%s is a fencing device but requires (un)fencing", (*rsc)->id);
756 goto handle_requires_pref;
759 crm_config_warn(
"%s requires (un)fencing but fencing is disabled", (*rsc)->id);
762 goto handle_requires_pref;
772 crm_config_warn(
"%s requires fencing but fencing is disabled", (*rsc)->id);
786 }
else if (((*rsc)->variant ==
pe_native)
806 goto handle_requires_pref;
809 pe_rsc_trace((*rsc),
"\tRequired to start: %s%s", value, isdefault?
" (default)":
"");
816 if (baremetal_remote_node) {
821 (*rsc)->remote_reconnect_interval = (
crm_get_msec(value) / 1000);
824 (*rsc)->failure_timeout = (*rsc)->remote_reconnect_interval;
832 if ((*rsc)->fns->unpack(*rsc, data_set) == FALSE) {
839 }
else if (container_remote_node) {
847 is_set((*rsc)->flags,
pe_rsc_notify) ?
"required" :
"not required");
849 (*rsc)->utilization = crm_str_table_new();
852 (*rsc)->utilization, NULL, FALSE, data_set->
now);
857 if (add_template_rsc(xml_obj, data_set) == FALSE) {
878 for (; gIter != NULL; gIter = gIter->next) {
891 if (parent == NULL || rsc == NULL) {
894 while (parent->
parent != NULL) {
895 if (parent->
parent == rsc) {
908 if (parent == NULL) {
934 #if ENABLE_VERSIONED_ATTRS 935 if (rsc->versioned_parameters != NULL) {
936 free_xml(rsc->versioned_parameters);
939 if (rsc->
meta != NULL) {
940 g_hash_table_destroy(rsc->
meta);
962 g_hash_table_destroy(rsc->
known_on);
1001 unsigned int *count_clean)
1005 bool keep_looking = FALSE;
1006 bool is_happy = FALSE;
1018 for (GList *node_iter = rsc->
running_on; node_iter != NULL;
1019 node_iter = node_iter->next) {
1021 node = node_iter->data;
1022 keep_looking = FALSE;
1029 if (count_clean && is_happy) {
1032 if (count_all || count_clean) {
1034 keep_looking = TRUE;
1042 keep_looking = TRUE;
1050 keep_looking = TRUE;
1053 if (active == NULL) {
1058 if (keep_looking == FALSE) {
1092 for (GList *item = rsc->
children; item != NULL; item = item->next) {
xmlNode * find_xml_node(xmlNode *cib, const char *node_path, gboolean must_find)
void container_free(resource_t *rsc)
void clone_print(resource_t *rsc, const char *pre_text, long options, void *print_data)
void pe__count_common(pe_resource_t *rsc)
void group_free(resource_t *rsc)
#define pe_flag_have_stonith_resource
gboolean safe_str_neq(const char *a, const char *b)
#define pe_rsc_needs_unfencing
gboolean get_target_role(resource_t *rsc, enum rsc_role_e *role)
#define XML_CIB_TAG_CONTAINER
#define pe_flag_enable_unfencing
int default_resource_stickiness
#define pe_rsc_maintenance
#define XML_TAG_UTILIZATION
enum pe_obj_types get_resource_type(const char *name)
#define RSC_ROLE_STARTED_S
#define crm_config_err(fmt...)
#define pe_rsc_needs_quorum
#define XML_RSC_ATTR_INCARNATION
void common_free(resource_t *rsc)
char * native_parameter(resource_t *rsc, node_t *node, gboolean create, const char *name, pe_working_set_t *data_set)
int char2score(const char *score)
pe_node_t * native_location(const pe_resource_t *rsc, GList **list, int current)
long long crm_get_msec(const char *input)
#define pe_rsc_provisional
xmlNode * find_entity(xmlNode *parent, const char *node_name, const char *id)
enum pe_obj_types variant
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
node_t * partial_migration_source
int crm_parse_int(const char *text, const char *default_text)
Parse an integer value from a string.
#define XML_CIB_TAG_RSC_TEMPLATE
no_quorum_policy_t no_quorum_policy
#define XML_RSC_ATTR_STICKINESS
#define clear_bit(word, bit)
#define pe_rsc_allow_migrate
void native_print(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)
bool crm_starts_with(const char *str, const char *prefix)
Check whether a string starts with a certain sequence.
void clone_free(resource_t *rsc)
enum rsc_role_e group_resource_state(const resource_t *rsc, gboolean current)
#define XML_CIB_ATTR_PRIORITY
const char * isolation_wrapper
xmlNode * copy_xml(xmlNode *src_node)
#define XML_TAG_ATTR_SETS
#define XML_CIB_TAG_RESOURCES
gboolean container_unpack(resource_t *rsc, pe_working_set_t *data_set)
const char * role2text(enum rsc_role_e role)
struct node_shared_s * details
pe_working_set_t * cluster
#define set_bit(word, bit)
#define XML_RSC_ATTR_REQUIRES
#define PCMK_RESOURCE_CLASS_OCF
resource_object_functions_t resource_class_functions[]
resource_t * uber_parent(resource_t *rsc)
#define XML_RSC_ATTR_CONTAINER
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
#define XML_CIB_TAG_RESOURCE
#define XML_RSC_ATTR_ISOLATION
const char * crm_xml_replace(xmlNode *node, const char *name, const char *value)
Replace an XML attribute with specified name and (possibly NULL) value.
GHashTable * allowed_nodes
xmlNode * add_node_copy(xmlNode *new_parent, xmlNode *xml_node)
xmlNode * expand_idref(xmlNode *input, xmlNode *top)
#define XML_AGENT_ATTR_PROVIDER
#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)
enum rsc_role_e native_resource_state(const resource_t *rsc, gboolean current)
#define pe_flag_maintenance_mode
void group_print(resource_t *rsc, const char *pre_text, long options, void *print_data)
gboolean native_active(resource_t *rsc, gboolean all)
GListPtr dangling_migrations
#define XML_TAG_RSC_VER_ATTRS
void free_xml(xmlNode *child)
gboolean xml_has_children(const xmlNode *root)
gboolean crm_str_eq(const char *a, const char *b, gboolean use_case)
pe_node_t * pe__find_active_on(const resource_t *rsc, unsigned int *count_all, unsigned int *count_clean)
#define XML_REMOTE_ATTR_RECONNECT_INTERVAL
#define XML_RSC_ATTR_NOTIFY
void get_rsc_attributes(GHashTable *meta_hash, resource_t *rsc, node_t *node, pe_working_set_t *data_set)
#define XML_RSC_ATTR_FAIL_STICKINESS
gboolean crm_ends_with(const char *s, const char *match)
enum rsc_role_e clone_resource_state(const resource_t *rsc, gboolean current)
void populate_hash(xmlNode *nvpair_list, GHashTable *hash, const char **attrs, int attrs_length)
gboolean is_parent(resource_t *child, resource_t *rsc)
#define XML_RSC_ATTR_UNIQUE
#define crm_config_warn(fmt...)
#define PCMK_RESOURCE_CLASS_STONITH
void get_meta_attributes(GHashTable *meta_hash, resource_t *rsc, node_t *node, pe_working_set_t *data_set)
int crm_str_to_boolean(const char *s, int *ret)
gboolean clone_active(resource_t *rsc, gboolean all)
gboolean xml_contains_remote_node(xmlNode *xml)
#define XML_CIB_TAG_INCARNATION
#define XML_RSC_ATTR_MAINTENANCE
#define XML_RSC_ATTR_FAIL_TIMEOUT
void add_hash_param(GHashTable *hash, const char *name, const char *value)
void resource_location(resource_t *rsc, node_t *node, int score, const char *tag, pe_working_set_t *data_set)
gboolean group_active(resource_t *rsc, gboolean all)
pe_node_t * pe__find_active_requires(const resource_t *rsc, unsigned int *count)
const char * get_resource_typename(enum pe_obj_types type)
enum rsc_role_e container_resource_state(const resource_t *rsc, gboolean current)
int compare_version(const char *version1, const char *version2)
int merge_weights(int w1, int w2)
#define XML_RSC_ATTR_MULTIPLE
#define XML_ATTR_CRM_VERSION
void container_print(resource_t *rsc, const char *pre_text, long options, void *print_data)
void common_update_score(resource_t *rsc, const char *id, int score)
gboolean container_active(resource_t *rsc, gboolean all)
#define XML_RSC_ATTR_RESTART
#define XML_CIB_TAG_MASTER
void native_free(resource_t *rsc)
gboolean native_unpack(resource_t *rsc, pe_working_set_t *data_set)
#define RSC_ROLE_UNKNOWN_S
void unpack_instance_attributes(xmlNode *top, xmlNode *xml_obj, const char *set_name, GHashTable *node_hash, GHashTable *hash, const char *always_first, gboolean overwrite, crm_time_t *now)
#define pe_flag_is_managed_default
#define crm_log_xml_trace(xml, text)
gboolean crm_is_true(const char *s)
#define XML_CIB_TAG_GROUP
#define pe_rsc_trace(rsc, fmt, args...)
#define pe_flag_symmetric_cluster
char * crm_concat(const char *prefix, const char *suffix, char join)
bool pe__resource_is_disabled(pe_resource_t *rsc)
gboolean common_unpack(xmlNode *xml_obj, resource_t **rsc, resource_t *parent, pe_working_set_t *data_set)
#define pe_rsc_needs_fencing
#define safe_str_eq(a, b)
gboolean group_unpack(resource_t *rsc, pe_working_set_t *data_set)
#define pe_rsc_fence_device
void g_hash_destroy_str(gpointer data)
GHashTable * template_rsc_sets
void pe__count_bundle(pe_resource_t *rsc)
resource_t * native_find_rsc(resource_t *rsc, const char *id, node_t *node, int flags)
#define XML_OP_ATTR_ALLOW_MIGRATE
#define pe_flag_stonith_enabled
enum crm_ais_msg_types type
#define pe_warn_once(pe_wo_bit, fmt...)
#define pe_rsc_info(rsc, fmt, args...)
gboolean clone_unpack(resource_t *rsc, pe_working_set_t *data_set)
#define XML_AGENT_ATTR_CLASS
gboolean master_unpack(resource_t *rsc, pe_working_set_t *data_set)