25 void populate_hash(xmlNode * nvpair_list, GHashTable * hash,
const char **attrs,
int attrs_length);
104 dup_attr(gpointer key, gpointer value, gpointer user_data)
113 GHashTable *node_hash = NULL;
121 xmlAttrPtr xIter = NULL;
123 for (xIter = rsc->
xml->properties; xIter; xIter = xIter->next) {
124 const char *prop_name = (
const char *)xIter->name;
132 meta_hash, NULL, FALSE, data_set->
now);
139 meta_hash, NULL, FALSE, data_set->
now);
143 if (rsc->
parent != NULL) {
144 g_hash_table_foreach(rsc->
parent->
meta, dup_attr, meta_hash);
149 node_hash, meta_hash, NULL, FALSE, data_set->
now);
156 GHashTable *node_hash = NULL;
163 meta_hash, NULL, FALSE, data_set->
now);
166 if (rsc->
parent != NULL) {
172 node_hash, meta_hash, NULL, FALSE, data_set->
now);
177 template_op_key(xmlNode * op)
193 unpack_template(xmlNode * xml_obj, xmlNode ** expanded_xml,
pe_working_set_t * data_set)
195 xmlNode *cib_resources = NULL;
196 xmlNode *
template = NULL;
197 xmlNode *new_xml = NULL;
198 xmlNode *child_xml = NULL;
199 xmlNode *rsc_ops = NULL;
200 xmlNode *template_ops = NULL;
201 const char *template_ref = NULL;
202 const char *clone = NULL;
203 const char *
id = NULL;
205 if (xml_obj == NULL) {
206 pe_err(
"No resource object for template unpacking");
211 if (template_ref == NULL) {
217 pe_err(
"'%s' object must have a id", crm_element_name(xml_obj));
222 pe_err(
"The resource object '%s' should not reference itself",
id);
227 if (cib_resources == NULL) {
228 pe_err(
"No resources configured");
233 if (
template == NULL) {
234 pe_err(
"No template named '%s'", template_ref);
239 xmlNodeSetName(new_xml, xml_obj->name);
249 for (child_xml = __xml_first_child(xml_obj); child_xml != NULL;
250 child_xml = __xml_next_element(child_xml)) {
251 xmlNode *new_child = NULL;
255 if (
crm_str_eq((
const char *)new_child->name,
"operations", TRUE)) {
260 if (template_ops && rsc_ops) {
262 GHashTable *rsc_ops_hash =
265 for (op = __xml_first_child(rsc_ops); op != NULL; op = __xml_next_element(op)) {
266 char *key = template_op_key(op);
268 g_hash_table_insert(rsc_ops_hash, key, op);
271 for (op = __xml_first_child(template_ops); op != NULL; op = __xml_next_element(op)) {
272 char *key = template_op_key(op);
274 if (g_hash_table_lookup(rsc_ops_hash, key) == NULL) {
282 g_hash_table_destroy(rsc_ops_hash);
289 *expanded_xml = new_xml;
305 const char *template_ref = NULL;
306 const char *
id = NULL;
308 if (xml_obj == NULL) {
309 pe_err(
"No resource object for processing resource list of template");
314 if (template_ref == NULL) {
320 pe_err(
"'%s' object must have a id", crm_element_name(xml_obj));
325 pe_err(
"The resource object '%s' should not reference itself",
id);
341 const char *wrapper = NULL;
349 if (g_hash_table_lookup(rsc->
parameters,
"pcmk_docker_image")) {
350 wrapper =
"docker-wrapper";
357 if (wrapper == NULL) {
384 bool isdefault = FALSE;
385 xmlNode *expanded_xml = NULL;
388 const char *value = NULL;
389 const char *rclass = NULL;
391 int container_remote_node = 0;
392 int baremetal_remote_node = 0;
397 pe_err(
"Must specify id tag in <resource>");
400 }
else if (rsc == NULL) {
401 pe_err(
"Nowhere to unpack resource into");
406 if (unpack_template(xml_obj, &expanded_xml, data_set) == FALSE) {
411 (*rsc)->cluster = data_set;
415 (*rsc)->xml = expanded_xml;
416 (*rsc)->orig_xml = xml_obj;
419 (*rsc)->xml = xml_obj;
420 (*rsc)->orig_xml = NULL;
425 (*rsc)->parent = parent;
432 pe_err(
"Unknown resource type: %s", crm_element_name((*rsc)->xml));
443 (*rsc)->allowed_nodes =
454 (*rsc)->id = strdup(
id);
457 (*rsc)->fns = &resource_class_functions[(*rsc)->variant];
471 (*rsc)->rsc_cons = NULL;
472 (*rsc)->rsc_tickets = NULL;
473 (*rsc)->actions = NULL;
479 (*rsc)->migration_threshold =
INFINITY;
480 (*rsc)->failure_timeout = 0;
484 (*rsc)->effective_priority = (*rsc)->priority;
493 container_remote_node = 1;
495 baremetal_remote_node = 1;
502 }
else if (value == NULL && baremetal_remote_node) {
514 gboolean bool_value = TRUE;
517 if (bool_value == FALSE) {
526 gboolean bool_value = FALSE;
529 if (bool_value == TRUE) {
541 handle_rsc_isolation(*rsc);
552 pe_rsc_trace((*rsc),
"\tDependency restart handling: restart");
556 pe_rsc_trace((*rsc),
"\tDependency restart handling: ignore");
562 pe_rsc_trace((*rsc),
"\tMultiple running resource recovery: stop only");
566 pe_rsc_trace((*rsc),
"\tMultiple running resource recovery: block");
570 pe_rsc_trace((*rsc),
"\tMultiple running resource recovery: stop/start");
580 (*rsc)->migration_threshold =
char2score(value);
582 }
else if (value == NULL) {
587 value = g_hash_table_lookup((*rsc)->meta,
"resource-failure-stickiness");
589 value = g_hash_table_lookup((*rsc)->meta,
"resource_failure_stickiness");
593 g_hash_table_lookup(data_set->
config_hash,
"default-resource-failure-stickiness");
597 g_hash_table_lookup(data_set->
config_hash,
"default_resource_failure_stickiness");
604 (*rsc)->migration_threshold = 1;
606 "Set a migration threshold of %d for %s based on a failure-stickiness of %s",
607 (*rsc)->migration_threshold, (*rsc)->id, value);
609 }
else if ((*rsc)->stickiness != 0 && fail_sticky != 0) {
610 (*rsc)->migration_threshold = (*rsc)->stickiness / fail_sticky;
611 if ((*rsc)->migration_threshold < 0) {
613 (*rsc)->migration_threshold = 0 - (*rsc)->migration_threshold;
615 (*rsc)->migration_threshold += 1;
617 "Calculated a migration threshold for %s of %d based on a stickiness of %d/%s",
618 (*rsc)->id, (*rsc)->migration_threshold, (*rsc)->stickiness, value);
630 handle_requires_pref:
638 crm_config_warn(
"%s is a fencing device but requires (un)fencing", (*rsc)->id);
641 goto handle_requires_pref;
644 crm_config_warn(
"%s requires (un)fencing but fencing is disabled", (*rsc)->id);
647 goto handle_requires_pref;
657 crm_config_warn(
"%s requires fencing but fencing is disabled", (*rsc)->id);
683 goto handle_requires_pref;
686 pe_rsc_trace((*rsc),
"\tRequired to start: %s%s", value, isdefault?
" (default)":
"");
693 if (baremetal_remote_node) {
698 (*rsc)->remote_reconnect_interval = (
crm_get_msec(value) / 1000);
701 (*rsc)->failure_timeout = (*rsc)->remote_reconnect_interval;
709 if ((*rsc)->fns->unpack(*rsc, data_set) == FALSE) {
715 }
else if (container_remote_node) {
723 is_set((*rsc)->flags,
pe_rsc_notify) ?
"required" :
"not required");
725 (*rsc)->utilization =
729 (*rsc)->utilization, NULL, FALSE, data_set->
now);
734 if (add_template_rsc(xml_obj, data_set) == FALSE) {
755 for (; gIter != NULL; gIter = gIter->next) {
768 if (parent == NULL || rsc == NULL) {
771 while (parent->
parent != NULL) {
772 if (parent->
parent == rsc) {
785 if (parent == NULL) {
788 while (parent->
parent != NULL) {
811 if (rsc->
meta != NULL) {
812 g_hash_table_destroy(rsc->
meta);
834 g_hash_table_destroy(rsc->
known_on);
xmlNode * find_xml_node(xmlNode *cib, const char *node_path, gboolean must_find)
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 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
void g_hash_destroy_str(gpointer data)
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
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
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 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)
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)
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 common_update_score(resource_t *rsc, const char *id, int score)
#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
gboolean common_unpack(xmlNode *xml_obj, resource_t **rsc, resource_t *parent, pe_working_set_t *data_set)
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
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)