27 void populate_hash(xmlNode * nvpair_list, GHashTable * hash,
const char **attrs,
int attrs_length);
125 dup_attr(gpointer key, gpointer value, gpointer user_data)
134 GHashTable *node_hash = NULL;
142 xmlAttrPtr xIter = NULL;
144 for (xIter = rsc->
xml->properties; xIter; xIter = xIter->next) {
145 const char *prop_name = (
const char *)xIter->name;
153 meta_hash, NULL, FALSE, data_set->
now);
160 meta_hash, NULL, FALSE, data_set->
now);
164 if (rsc->
parent != NULL) {
165 g_hash_table_foreach(rsc->
parent->
meta, dup_attr, meta_hash);
170 node_hash, meta_hash, NULL, FALSE, data_set->
now);
177 GHashTable *node_hash = NULL;
184 meta_hash, NULL, FALSE, data_set->
now);
187 if (rsc->
parent != NULL) {
193 node_hash, meta_hash, NULL, FALSE, data_set->
now);
197 #if ENABLE_VERSIONED_ATTRS
199 pe_get_versioned_attributes(xmlNode * meta_hash,
resource_t * rsc,
202 GHashTable *node_hash = NULL;
209 meta_hash, data_set->
now);
212 if (rsc->
parent != NULL) {
213 pe_get_versioned_attributes(meta_hash, rsc->
parent, node, data_set);
218 node_hash, meta_hash, data_set->
now);
224 template_op_key(xmlNode * op)
240 unpack_template(xmlNode * xml_obj, xmlNode ** expanded_xml,
pe_working_set_t * data_set)
242 xmlNode *cib_resources = NULL;
243 xmlNode *
template = NULL;
244 xmlNode *new_xml = NULL;
245 xmlNode *child_xml = NULL;
246 xmlNode *rsc_ops = NULL;
247 xmlNode *template_ops = NULL;
248 const char *template_ref = NULL;
249 const char *clone = NULL;
250 const char *
id = NULL;
252 if (xml_obj == NULL) {
253 pe_err(
"No resource object for template unpacking");
258 if (template_ref == NULL) {
264 pe_err(
"'%s' object must have a id", crm_element_name(xml_obj));
269 pe_err(
"The resource object '%s' should not reference itself",
id);
274 if (cib_resources == NULL) {
275 pe_err(
"No resources configured");
280 if (
template == NULL) {
281 pe_err(
"No template named '%s'", template_ref);
286 xmlNodeSetName(new_xml, xml_obj->name);
296 for (child_xml = __xml_first_child(xml_obj); child_xml != NULL;
297 child_xml = __xml_next_element(child_xml)) {
298 xmlNode *new_child = NULL;
302 if (
crm_str_eq((
const char *)new_child->name,
"operations", TRUE)) {
307 if (template_ops && rsc_ops) {
309 GHashTable *rsc_ops_hash =
312 for (op = __xml_first_child(rsc_ops); op != NULL; op = __xml_next_element(op)) {
313 char *key = template_op_key(op);
315 g_hash_table_insert(rsc_ops_hash, key, op);
318 for (op = __xml_first_child(template_ops); op != NULL; op = __xml_next_element(op)) {
319 char *key = template_op_key(op);
321 if (g_hash_table_lookup(rsc_ops_hash, key) == NULL) {
329 g_hash_table_destroy(rsc_ops_hash);
336 *expanded_xml = new_xml;
352 const char *template_ref = NULL;
353 const char *
id = NULL;
355 if (xml_obj == NULL) {
356 pe_err(
"No resource object for processing resource list of template");
361 if (template_ref == NULL) {
367 pe_err(
"'%s' object must have a id", crm_element_name(xml_obj));
372 pe_err(
"The resource object '%s' should not reference itself",
id);
388 const char *wrapper = NULL;
396 if (g_hash_table_lookup(rsc->
parameters,
"pcmk_docker_image")) {
397 wrapper =
"docker-wrapper";
404 if (wrapper == NULL) {
412 if (top == rsc->
parent && pe_rsc_is_clone(top)) {
421 " is deprecated and will be removed in a future release"
422 " (use bundle syntax instead)");
426 if (pe_rsc_is_clone(top)) {
437 g_hash_table_iter_init(&iter, rsc->
parameters);
438 while (g_hash_table_iter_next(&iter, (gpointer *) &key, NULL)) {
442 if (!strcmp(cmp,
"poweroff_action")) {
444 "Support for the 'pcmk_poweroff_action' stonith resource parameter"
445 " is deprecated and will be removed in a future version"
446 " (use 'pcmk_off_action' instead)");
448 }
else if (!strcmp(cmp,
"arg_map")) {
450 "Support for the 'pcmk_arg_map' stonith resource parameter"
451 " is deprecated and will be removed in a future version"
452 " (use 'pcmk_host_argument' instead)");
456 "Support for the 'pcmk_*_cmd' stonith resource parameters"
457 " is deprecated and will be removed in a future version"
458 " (use 'pcmk_*_action' instead)");
468 bool isdefault = FALSE;
469 xmlNode *expanded_xml = NULL;
472 const char *value = NULL;
473 const char *rclass = NULL;
475 int container_remote_node = 0;
476 int baremetal_remote_node = 0;
477 bool has_versioned_params = FALSE;
482 pe_err(
"Must specify id tag in <resource>");
485 }
else if (rsc == NULL) {
486 pe_err(
"Nowhere to unpack resource into");
491 if (unpack_template(xml_obj, &expanded_xml, data_set) == FALSE) {
496 (*rsc)->cluster = data_set;
500 (*rsc)->xml = expanded_xml;
501 (*rsc)->orig_xml = xml_obj;
504 (*rsc)->xml = xml_obj;
505 (*rsc)->orig_xml = NULL;
510 (*rsc)->parent = parent;
517 pe_err(
"Unknown resource type: %s", crm_element_name((*rsc)->xml));
522 (*rsc)->parameters = crm_str_table_new();
524 #if ENABLE_VERSIONED_ATTRS
528 (*rsc)->meta = crm_str_table_new();
530 (*rsc)->allowed_nodes =
541 (*rsc)->id = strdup(
id);
544 (*rsc)->fns = &resource_class_functions[(*rsc)->variant];
549 #if ENABLE_VERSIONED_ATTRS
550 pe_get_versioned_attributes((*rsc)->versioned_parameters, *rsc, NULL, data_set);
561 (*rsc)->rsc_cons = NULL;
562 (*rsc)->rsc_tickets = NULL;
563 (*rsc)->actions = NULL;
569 (*rsc)->migration_threshold =
INFINITY;
570 (*rsc)->failure_timeout = 0;
574 (*rsc)->effective_priority = (*rsc)->priority;
582 (*rsc)->is_remote_node = TRUE;
584 container_remote_node = 1;
586 baremetal_remote_node = 1;
591 #if ENABLE_VERSIONED_ATTRS
595 pe_rsc_trace((*rsc),
"Migration is disabled for resources with versioned parameters");
598 }
else if ((value == NULL) && baremetal_remote_node && !has_versioned_params) {
611 gboolean bool_value = TRUE;
614 if (bool_value == FALSE) {
623 gboolean bool_value = FALSE;
626 if (bool_value == TRUE) {
638 handle_rsc_isolation(*rsc);
642 if (
crm_is_true(value) || pe_rsc_is_clone(top) == FALSE) {
649 pe_rsc_trace((*rsc),
"\tDependency restart handling: restart");
653 pe_rsc_trace((*rsc),
"\tDependency restart handling: ignore");
659 pe_rsc_trace((*rsc),
"\tMultiple running resource recovery: stop only");
663 pe_rsc_trace((*rsc),
"\tMultiple running resource recovery: block");
667 pe_rsc_trace((*rsc),
"\tMultiple running resource recovery: stop/start");
677 (*rsc)->migration_threshold =
char2score(value);
679 }
else if (value == NULL) {
683 const char *legacy = NULL;
685 legacy = g_hash_table_lookup((*rsc)->meta,
686 "resource-failure-stickiness");
687 if (legacy == NULL) {
688 legacy = g_hash_table_lookup((*rsc)->meta,
689 "resource_failure_stickiness");
694 "Support for 'resource-failure-stickiness' resource meta-attribute"
695 " is deprecated and will be removed in a future release"
696 " (use 'migration-threshold' resource meta-attribute instead)");
699 legacy = g_hash_table_lookup(data_set->
config_hash,
700 "default-resource-failure-stickiness");
701 if (legacy == NULL) {
702 legacy = g_hash_table_lookup(data_set->
config_hash,
703 "default_resource_failure_stickiness");
710 "Support for 'default-resource-failure-stickiness' cluster option"
711 " is deprecated and will be removed in a future release"
712 " (use 'migration-threshold' in rsc_defaults instead)");
719 (*rsc)->migration_threshold = 1;
721 "Set a migration threshold of %d for %s based on a failure-stickiness of %s",
722 (*rsc)->migration_threshold, (*rsc)->id, value);
724 }
else if ((*rsc)->stickiness != 0 && fail_sticky != 0) {
725 (*rsc)->migration_threshold = (*rsc)->stickiness / fail_sticky;
726 if ((*rsc)->migration_threshold < 0) {
728 (*rsc)->migration_threshold = 0 - (*rsc)->migration_threshold;
730 (*rsc)->migration_threshold += 1;
732 "Calculated a migration threshold for %s of %d based on a stickiness of %d/%s",
733 (*rsc)->id, (*rsc)->migration_threshold, (*rsc)->stickiness, value);
741 check_deprecated_stonith(*rsc);
746 handle_requires_pref:
754 crm_config_warn(
"%s is a fencing device but requires (un)fencing", (*rsc)->id);
757 goto handle_requires_pref;
760 crm_config_warn(
"%s requires (un)fencing but fencing is disabled", (*rsc)->id);
763 goto handle_requires_pref;
773 crm_config_warn(
"%s requires fencing but fencing is disabled", (*rsc)->id);
799 goto handle_requires_pref;
802 pe_rsc_trace((*rsc),
"\tRequired to start: %s%s", value, isdefault?
" (default)":
"");
809 if (baremetal_remote_node) {
814 (*rsc)->remote_reconnect_interval = (
crm_get_msec(value) / 1000);
817 (*rsc)->failure_timeout = (*rsc)->remote_reconnect_interval;
825 if ((*rsc)->fns->unpack(*rsc, data_set) == FALSE) {
832 }
else if (container_remote_node) {
840 is_set((*rsc)->flags,
pe_rsc_notify) ?
"required" :
"not required");
842 (*rsc)->utilization = crm_str_table_new();
845 (*rsc)->utilization, NULL, FALSE, data_set->
now);
850 if (add_template_rsc(xml_obj, data_set) == FALSE) {
871 for (; gIter != NULL; gIter = gIter->next) {
884 if (parent == NULL || rsc == NULL) {
887 while (parent->
parent != NULL) {
888 if (parent->
parent == rsc) {
901 if (parent == NULL) {
927 #if ENABLE_VERSIONED_ATTRS
928 if (rsc->versioned_parameters != NULL) {
929 free_xml(rsc->versioned_parameters);
932 if (rsc->
meta != NULL) {
933 g_hash_table_destroy(rsc->
meta);
955 g_hash_table_destroy(rsc->
known_on);
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 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
gboolean is_parent(resource_t *child, resource_t *rsc)
#define RSC_ROLE_STARTED_S
#define crm_config_err(fmt...)
#define pe_rsc_needs_quorum
#define XML_RSC_ATTR_INCARNATION
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)
long long crm_get_msec(const char *input)
#define pe_rsc_provisional
xmlNode * find_entity(xmlNode *parent, const char *node_name, const char *id)
gboolean common_unpack(xmlNode *xml_obj, resource_t **rsc, resource_t *parent, pe_working_set_t *data_set)
enum pe_obj_types variant
void common_update_score(resource_t *rsc, const char *id, int score)
void common_free(resource_t *rsc)
int crm_parse_int(const char *text, const char *default_text)
void get_rsc_attributes(GHashTable *meta_hash, resource_t *rsc, node_t *node, pe_working_set_t *data_set)
#define XML_CIB_TAG_RSC_TEMPLATE
no_quorum_policy_t no_quorum_policy
#define XML_RSC_ATTR_STICKINESS
resource_t * uber_parent(resource_t *rsc)
#define clear_bit(word, bit)
const char * get_resource_typename(enum pe_obj_types type)
#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)
const char * crm_xml_replace(xmlNode *node, const char *name, const char *value)
#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
#define set_bit(word, bit)
#define XML_RSC_ATTR_REQUIRES
#define XML_RSC_ATTR_CONTAINER
#define XML_CIB_TAG_RESOURCE
#define XML_RSC_ATTR_ISOLATION
GHashTable * allowed_nodes
xmlNode * add_node_copy(xmlNode *new_parent, xmlNode *xml_node)
xmlNode * expand_idref(xmlNode *input, xmlNode *top)
#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)
const char * crm_element_value(xmlNode *data, 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)
node_t * native_location(resource_t *rsc, GListPtr *list, gboolean current)
gboolean xml_has_children(const xmlNode *root)
gboolean crm_str_eq(const char *a, const char *b, gboolean use_case)
#define XML_REMOTE_ATTR_RECONNECT_INTERVAL
#define XML_RSC_ATTR_NOTIFY
#define XML_RSC_ATTR_FAIL_STICKINESS
gboolean crm_ends_with(const char *s, const char *match)
resource_object_functions_t resource_class_functions[]
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)
#define XML_RSC_ATTR_UNIQUE
enum pe_obj_types get_resource_type(const char *name)
#define crm_config_warn(fmt...)
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
#define PCMK_RESOURCE_CLASS_STONITH
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)
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)
gboolean container_active(resource_t *rsc, gboolean all)
void get_meta_attributes(GHashTable *meta_hash, resource_t *rsc, node_t *node, pe_working_set_t *data_set)
#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)
#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
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)