16 void populate_hash(xmlNode * nvpair_list, GHashTable * hash,
const char **attrs,
int attrs_length);
62 get_resource_type(
const char *name)
85 dup_attr(gpointer key, gpointer value, gpointer user_data)
94 GHashTable *node_hash = NULL;
101 xmlAttrPtr xIter = NULL;
103 for (xIter = rsc->
xml->properties; xIter; xIter = xIter->next) {
104 const char *prop_name = (
const char *)xIter->name;
112 meta_hash, NULL, FALSE, data_set->
now);
115 if (rsc->
parent != NULL) {
116 g_hash_table_foreach(rsc->
parent->
meta, dup_attr, meta_hash);
121 node_hash, meta_hash, NULL, FALSE, data_set->
now);
128 GHashTable *node_hash = NULL;
135 meta_hash, NULL, FALSE, data_set->
now);
138 if (rsc->
parent != NULL) {
144 node_hash, meta_hash, NULL, FALSE, data_set->
now);
148 #if ENABLE_VERSIONED_ATTRS 150 pe_get_versioned_attributes(xmlNode * meta_hash,
resource_t * rsc,
153 GHashTable *node_hash = NULL;
160 meta_hash, data_set->
now);
163 if (rsc->
parent != NULL) {
164 pe_get_versioned_attributes(meta_hash, rsc->
parent, node, data_set);
169 node_hash, meta_hash, data_set->
now);
175 template_op_key(xmlNode * op)
186 key = crm_concat(name, role,
'-');
191 unpack_template(xmlNode * xml_obj, xmlNode ** expanded_xml,
pe_working_set_t * data_set)
193 xmlNode *cib_resources = NULL;
194 xmlNode *
template = NULL;
195 xmlNode *new_xml = NULL;
196 xmlNode *child_xml = NULL;
197 xmlNode *rsc_ops = NULL;
198 xmlNode *template_ops = NULL;
199 const char *template_ref = NULL;
200 const char *clone = NULL;
201 const char *
id = NULL;
203 if (xml_obj == NULL) {
204 pe_err(
"No resource object for template unpacking");
209 if (template_ref == NULL) {
215 pe_err(
"'%s' object must have a id", crm_element_name(xml_obj));
220 pe_err(
"The resource object '%s' should not reference itself",
id);
225 if (cib_resources == NULL) {
226 pe_err(
"No resources configured");
231 if (
template == NULL) {
232 pe_err(
"No template named '%s'", template_ref);
237 xmlNodeSetName(new_xml, xml_obj->name);
247 for (child_xml = __xml_first_child(xml_obj); child_xml != NULL;
248 child_xml = __xml_next_element(child_xml)) {
249 xmlNode *new_child = NULL;
253 if (
crm_str_eq((
const char *)new_child->name,
"operations", TRUE)) {
258 if (template_ops && rsc_ops) {
260 GHashTable *rsc_ops_hash = g_hash_table_new_full(
crm_str_hash,
264 for (op = __xml_first_child(rsc_ops); op != NULL; op = __xml_next_element(op)) {
265 char *key = template_op_key(op);
267 g_hash_table_insert(rsc_ops_hash, key, op);
270 for (op = __xml_first_child(template_ops); op != NULL; op = __xml_next_element(op)) {
271 char *key = template_op_key(op);
273 if (g_hash_table_lookup(rsc_ops_hash, key) == NULL) {
281 g_hash_table_destroy(rsc_ops_hash);
288 *expanded_xml = new_xml;
304 const char *template_ref = NULL;
305 const char *
id = NULL;
307 if (xml_obj == NULL) {
308 pe_err(
"No resource object for processing resource list of template");
313 if (template_ref == NULL) {
319 pe_err(
"'%s' object must have a id", crm_element_name(xml_obj));
324 pe_err(
"The resource object '%s' should not reference itself",
id);
338 const char *promotable = g_hash_table_lookup(rsc->
meta,
361 bool isdefault = FALSE;
362 xmlNode *expanded_xml = NULL;
364 const char *value = NULL;
365 const char *rclass = NULL;
367 int container_remote_node = 0;
368 int baremetal_remote_node = 0;
369 bool has_versioned_params = FALSE;
374 pe_err(
"Must specify id tag in <resource>");
377 }
else if (rsc == NULL) {
378 pe_err(
"Nowhere to unpack resource into");
383 if (unpack_template(xml_obj, &expanded_xml, data_set) == FALSE) {
388 (*rsc)->cluster = data_set;
392 (*rsc)->xml = expanded_xml;
393 (*rsc)->orig_xml = xml_obj;
396 (*rsc)->xml = xml_obj;
397 (*rsc)->orig_xml = NULL;
402 (*rsc)->parent = parent;
407 (*rsc)->variant = get_resource_type(crm_element_name((*rsc)->xml));
409 pe_err(
"Unknown resource type: %s", crm_element_name((*rsc)->xml));
414 (*rsc)->parameters = crm_str_table_new();
416 #if ENABLE_VERSIONED_ATTRS 420 (*rsc)->meta = crm_str_table_new();
422 (*rsc)->allowed_nodes =
423 g_hash_table_new_full(
crm_str_hash, g_str_equal, NULL, free);
425 (*rsc)->known_on = g_hash_table_new_full(
crm_str_hash, g_str_equal, NULL,
430 (*rsc)->id = crm_concat(
id, value,
':');
434 (*rsc)->id = strdup(
id);
437 (*rsc)->fns = &resource_class_functions[(*rsc)->variant];
442 #if ENABLE_VERSIONED_ATTRS 443 pe_get_versioned_attributes((*rsc)->versioned_parameters, *rsc, NULL, data_set);
454 (*rsc)->rsc_cons = NULL;
455 (*rsc)->rsc_tickets = NULL;
456 (*rsc)->actions = NULL;
461 (*rsc)->stickiness = 0;
462 (*rsc)->migration_threshold =
INFINITY;
463 (*rsc)->failure_timeout = 0;
474 (*rsc)->is_remote_node = TRUE;
476 container_remote_node = 1;
478 baremetal_remote_node = 1;
483 #if ENABLE_VERSIONED_ATTRS 487 pe_rsc_trace((*rsc),
"Migration is disabled for resources with versioned parameters");
490 }
else if ((value == NULL) && baremetal_remote_node && !has_versioned_params) {
503 gboolean bool_value = TRUE;
506 if (bool_value == FALSE) {
515 gboolean bool_value = FALSE;
518 if (bool_value == TRUE) {
533 if (detect_promotable(*rsc)) {
545 pe_rsc_trace((*rsc),
"\tDependency restart handling: restart");
547 "Support for restart-type is deprecated and will be removed in a future release");
551 pe_rsc_trace((*rsc),
"\tDependency restart handling: ignore");
557 pe_rsc_trace((*rsc),
"\tMultiple running resource recovery: stop only");
561 pe_rsc_trace((*rsc),
"\tMultiple running resource recovery: block");
565 pe_rsc_trace((*rsc),
"\tMultiple running resource recovery: stop/start");
575 (*rsc)->migration_threshold =
char2score(value);
585 handle_requires_pref:
593 crm_config_warn(
"%s is a fencing device but requires (un)fencing", (*rsc)->id);
596 goto handle_requires_pref;
599 crm_config_warn(
"%s requires (un)fencing but fencing is disabled", (*rsc)->id);
602 goto handle_requires_pref;
612 crm_config_warn(
"%s requires fencing but fencing is disabled", (*rsc)->id);
626 }
else if (((*rsc)->variant ==
pe_native)
646 goto handle_requires_pref;
649 pe_rsc_trace((*rsc),
"\tRequired to start: %s%s", value, isdefault?
" (default)":
"");
656 if (baremetal_remote_node) {
664 (*rsc)->failure_timeout = (*rsc)->remote_reconnect_ms / 1000;
672 if ((*rsc)->fns->unpack(*rsc, data_set) == FALSE) {
679 }
else if (container_remote_node) {
687 is_set((*rsc)->flags,
pe_rsc_notify) ?
"required" :
"not required");
689 (*rsc)->utilization = crm_str_table_new();
692 (*rsc)->utilization, NULL, FALSE, data_set->
now);
697 if (add_template_rsc(xml_obj, data_set) == FALSE) {
718 for (; gIter != NULL; gIter = gIter->next) {
731 if (parent == NULL || rsc == NULL) {
734 while (parent->
parent != NULL) {
735 if (parent->
parent == rsc) {
748 if (parent == NULL) {
774 #if ENABLE_VERSIONED_ATTRS 775 if (rsc->versioned_parameters != NULL) {
776 free_xml(rsc->versioned_parameters);
779 if (rsc->
meta != NULL) {
780 g_hash_table_destroy(rsc->
meta);
802 g_hash_table_destroy(rsc->
known_on);
841 unsigned int *count_clean)
845 bool keep_looking = FALSE;
846 bool is_happy = FALSE;
858 for (GList *node_iter = rsc->
running_on; node_iter != NULL;
859 node_iter = node_iter->next) {
861 node = node_iter->data;
862 keep_looking = FALSE;
869 if (count_clean && is_happy) {
872 if (count_all || count_clean) {
893 if (active == NULL) {
898 if (keep_looking == FALSE) {
xmlNode * find_xml_node(xmlNode *cib, const char *node_path, gboolean must_find)
void container_free(resource_t *rsc)
enum pe_quorum_policy no_quorum_policy
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)
GListPtr dangling_migrations
#define XML_CIB_TAG_CONTAINER
#define pe_flag_enable_unfencing
#define pe_rsc_maintenance
pe_node_t * partial_migration_source
#define XML_TAG_UTILIZATION
#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)
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
#define clear_bit(word, bit)
guint crm_parse_interval_spec(const char *input)
#define pe_rsc_allow_migrate
void native_print(resource_t *rsc, const char *pre_text, long options, void *print_data)
resource_t * native_find_rsc(resource_t *rsc, const char *id, const node_t *node, int flags)
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)
#define XML_CIB_ATTR_PRIORITY
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)
#define XML_RSC_ATTR_PROMOTABLE
const char * role2text(enum rsc_role_e role)
#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
const char * crm_xml_replace(xmlNode *node, const char *name, const char *value)
Replace an XML attribute with specified name and (possibly NULL) value.
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
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)
#define XML_TAG_RSC_VER_ATTRS
void free_xml(xmlNode *child)
enum pe_obj_types variant
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...)
#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)
enum rsc_role_e container_resource_state(const resource_t *rsc, gboolean current)
#define pe_rsc_promotable
int merge_weights(int w1, int w2)
#define XML_RSC_ATTR_MULTIPLE
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 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)
#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
pe_node_t * pe__find_active_requires(const pe_resource_t *rsc, unsigned int *count)
GHashTable * template_rsc_sets
#define XML_OP_ATTR_ALLOW_MIGRATE
#define pe_flag_stonith_enabled
#define pe_warn_once(pe_wo_bit, fmt...)
gboolean clone_unpack(resource_t *rsc, pe_working_set_t *data_set)
#define XML_AGENT_ATTR_CLASS
GHashTable * allowed_nodes