25 void populate_hash(xmlNode * nvpair_list, GHashTable * hash,
const char **attrs,
int attrs_length);
123 dup_attr(gpointer key, gpointer value, gpointer user_data)
132 GHashTable *node_hash = NULL;
140 xmlAttrPtr xIter = NULL;
142 for (xIter = rsc->
xml->properties; xIter; xIter = xIter->next) {
143 const char *prop_name = (
const char *)xIter->name;
151 meta_hash, NULL, FALSE, data_set->
now);
158 meta_hash, NULL, FALSE, data_set->
now);
162 if (rsc->
parent != NULL) {
163 g_hash_table_foreach(rsc->
parent->
meta, dup_attr, meta_hash);
168 node_hash, meta_hash, NULL, FALSE, data_set->
now);
175 GHashTable *node_hash = NULL;
182 meta_hash, NULL, FALSE, data_set->
now);
185 if (rsc->
parent != NULL) {
191 node_hash, meta_hash, NULL, FALSE, data_set->
now);
195 #ifdef ENABLE_VERSIONED_ATTRS 197 pe_get_versioned_attributes(xmlNode * meta_hash,
resource_t * rsc,
200 GHashTable *node_hash = NULL;
207 meta_hash, data_set->
now);
210 if (rsc->
parent != NULL) {
211 pe_get_versioned_attributes(meta_hash, rsc->
parent, node, data_set);
216 node_hash, meta_hash, data_set->
now);
222 template_op_key(xmlNode * op)
238 unpack_template(xmlNode * xml_obj, xmlNode ** expanded_xml,
pe_working_set_t * data_set)
240 xmlNode *cib_resources = NULL;
241 xmlNode *
template = NULL;
242 xmlNode *new_xml = NULL;
243 xmlNode *child_xml = NULL;
244 xmlNode *rsc_ops = NULL;
245 xmlNode *template_ops = NULL;
246 const char *template_ref = NULL;
247 const char *clone = NULL;
248 const char *
id = NULL;
250 if (xml_obj == NULL) {
251 pe_err(
"No resource object for template unpacking");
256 if (template_ref == NULL) {
262 pe_err(
"'%s' object must have a id", crm_element_name(xml_obj));
267 pe_err(
"The resource object '%s' should not reference itself",
id);
272 if (cib_resources == NULL) {
273 pe_err(
"No resources configured");
278 if (
template == NULL) {
279 pe_err(
"No template named '%s'", template_ref);
284 xmlNodeSetName(new_xml, xml_obj->name);
294 for (child_xml = __xml_first_child(xml_obj); child_xml != NULL;
295 child_xml = __xml_next_element(child_xml)) {
296 xmlNode *new_child = NULL;
300 if (
crm_str_eq((
const char *)new_child->name,
"operations", TRUE)) {
305 if (template_ops && rsc_ops) {
307 GHashTable *rsc_ops_hash =
310 for (op = __xml_first_child(rsc_ops); op != NULL; op = __xml_next_element(op)) {
311 char *key = template_op_key(op);
313 g_hash_table_insert(rsc_ops_hash, key, op);
316 for (op = __xml_first_child(template_ops); op != NULL; 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)) {
420 if (pe_rsc_is_clone(top)) {
429 bool isdefault = FALSE;
430 xmlNode *expanded_xml = NULL;
433 const char *value = NULL;
434 const char *rclass = NULL;
436 int container_remote_node = 0;
437 int baremetal_remote_node = 0;
438 bool has_versioned_params = FALSE;
443 pe_err(
"Must specify id tag in <resource>");
446 }
else if (rsc == NULL) {
447 pe_err(
"Nowhere to unpack resource into");
452 if (unpack_template(xml_obj, &expanded_xml, data_set) == FALSE) {
457 (*rsc)->cluster = data_set;
461 (*rsc)->xml = expanded_xml;
462 (*rsc)->orig_xml = xml_obj;
465 (*rsc)->xml = xml_obj;
466 (*rsc)->orig_xml = NULL;
471 (*rsc)->parent = parent;
478 pe_err(
"Unknown resource type: %s", crm_element_name((*rsc)->xml));
486 #ifdef ENABLE_VERSIONED_ATTRS 487 (*rsc)->versioned_parameters =
create_xml_node(NULL, XML_TAG_VER_ATTRS);
493 (*rsc)->allowed_nodes =
504 (*rsc)->id = strdup(
id);
507 (*rsc)->fns = &resource_class_functions[(*rsc)->variant];
512 #ifdef ENABLE_VERSIONED_ATTRS 513 pe_get_versioned_attributes((*rsc)->versioned_parameters, *rsc, NULL, data_set);
524 (*rsc)->rsc_cons = NULL;
525 (*rsc)->rsc_tickets = NULL;
526 (*rsc)->actions = NULL;
532 (*rsc)->migration_threshold =
INFINITY;
533 (*rsc)->failure_timeout = 0;
537 (*rsc)->effective_priority = (*rsc)->priority;
545 (*rsc)->is_remote_node = TRUE;
547 container_remote_node = 1;
549 baremetal_remote_node = 1;
554 #ifdef ENABLE_VERSIONED_ATTRS 558 pe_rsc_trace((*rsc),
"Migration is disabled for resources with versioned parameters");
561 }
else if ((value == NULL) && baremetal_remote_node && !has_versioned_params) {
574 gboolean bool_value = TRUE;
577 if (bool_value == FALSE) {
586 gboolean bool_value = FALSE;
589 if (bool_value == TRUE) {
601 handle_rsc_isolation(*rsc);
605 if (
crm_is_true(value) || pe_rsc_is_clone(top) == FALSE) {
612 pe_rsc_trace((*rsc),
"\tDependency restart handling: restart");
616 pe_rsc_trace((*rsc),
"\tDependency restart handling: ignore");
622 pe_rsc_trace((*rsc),
"\tMultiple running resource recovery: stop only");
626 pe_rsc_trace((*rsc),
"\tMultiple running resource recovery: block");
630 pe_rsc_trace((*rsc),
"\tMultiple running resource recovery: stop/start");
640 (*rsc)->migration_threshold =
char2score(value);
642 }
else if (value == NULL) {
647 value = g_hash_table_lookup((*rsc)->meta,
"resource-failure-stickiness");
649 value = g_hash_table_lookup((*rsc)->meta,
"resource_failure_stickiness");
653 g_hash_table_lookup(data_set->
config_hash,
"default-resource-failure-stickiness");
657 g_hash_table_lookup(data_set->
config_hash,
"default_resource_failure_stickiness");
664 (*rsc)->migration_threshold = 1;
666 "Set a migration threshold of %d for %s based on a failure-stickiness of %s",
667 (*rsc)->migration_threshold, (*rsc)->id, value);
669 }
else if ((*rsc)->stickiness != 0 && fail_sticky != 0) {
670 (*rsc)->migration_threshold = (*rsc)->stickiness / fail_sticky;
671 if ((*rsc)->migration_threshold < 0) {
673 (*rsc)->migration_threshold = 0 - (*rsc)->migration_threshold;
675 (*rsc)->migration_threshold += 1;
677 "Calculated a migration threshold for %s of %d based on a stickiness of %d/%s",
678 (*rsc)->id, (*rsc)->migration_threshold, (*rsc)->stickiness, value);
690 handle_requires_pref:
698 crm_config_warn(
"%s is a fencing device but requires (un)fencing", (*rsc)->id);
701 goto handle_requires_pref;
704 crm_config_warn(
"%s requires (un)fencing but fencing is disabled", (*rsc)->id);
707 goto handle_requires_pref;
717 crm_config_warn(
"%s requires fencing but fencing is disabled", (*rsc)->id);
743 goto handle_requires_pref;
746 pe_rsc_trace((*rsc),
"\tRequired to start: %s%s", value, isdefault?
" (default)":
"");
753 if (baremetal_remote_node) {
758 (*rsc)->remote_reconnect_interval = (
crm_get_msec(value) / 1000);
761 (*rsc)->failure_timeout = (*rsc)->remote_reconnect_interval;
769 if ((*rsc)->fns->unpack(*rsc, data_set) == FALSE) {
775 }
else if (container_remote_node) {
783 is_set((*rsc)->flags,
pe_rsc_notify) ?
"required" :
"not required");
785 (*rsc)->utilization =
789 (*rsc)->utilization, NULL, FALSE, data_set->
now);
794 if (add_template_rsc(xml_obj, data_set) == FALSE) {
815 for (; gIter != NULL; gIter = gIter->next) {
828 if (parent == NULL || rsc == NULL) {
831 while (parent->
parent != NULL) {
832 if (parent->
parent == rsc) {
845 if (parent == NULL) {
871 #ifdef ENABLE_VERSIONED_ATTRS 872 if (rsc->versioned_parameters != NULL) {
873 free_xml(rsc->versioned_parameters);
876 if (rsc->
meta != NULL) {
877 g_hash_table_destroy(rsc->
meta);
899 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
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)
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
int crm_parse_int(const char *text, const char *default_text)
#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)
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
resource_object_functions_t resource_class_functions[]
resource_t * uber_parent(resource_t *rsc)
#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
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
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
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...)
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
#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)
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)
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
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_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)