 |
pacemaker
2.0.3-4b1f869f0f
Scalable High-Availability cluster resource manager
|
Go to the documentation of this file.
18 void populate_hash(xmlNode * nvpair_list, GHashTable * hash,
const char **attrs,
int attrs_length);
68 get_resource_type(
const char *name)
91 dup_attr(gpointer key, gpointer value, gpointer user_data)
100 GHashTable *node_hash = NULL;
107 xmlAttrPtr xIter = NULL;
109 for (xIter = rsc->
xml->properties; xIter; xIter = xIter->next) {
110 const char *prop_name = (
const char *)xIter->name;
118 meta_hash, NULL, FALSE, data_set);
121 if (rsc->
parent != NULL) {
122 g_hash_table_foreach(rsc->
parent->
meta, dup_attr, meta_hash);
127 node_hash, meta_hash, NULL, FALSE, data_set);
134 GHashTable *node_hash = NULL;
141 meta_hash, NULL, FALSE, data_set);
144 if (rsc->
parent != NULL) {
150 node_hash, meta_hash, NULL, FALSE, data_set);
154 #if ENABLE_VERSIONED_ATTRS
156 pe_get_versioned_attributes(xmlNode * meta_hash,
resource_t * rsc,
159 GHashTable *node_hash = NULL;
166 meta_hash, data_set->
now, NULL);
169 if (rsc->
parent != NULL) {
170 pe_get_versioned_attributes(meta_hash, rsc->
parent, node, data_set);
175 node_hash, meta_hash, data_set->
now, NULL);
181 template_op_key(xmlNode * op)
192 key = crm_concat(name, role,
'-');
197 unpack_template(xmlNode * xml_obj, xmlNode ** expanded_xml,
pe_working_set_t * data_set)
199 xmlNode *cib_resources = NULL;
200 xmlNode *
template = NULL;
201 xmlNode *new_xml = NULL;
202 xmlNode *child_xml = NULL;
203 xmlNode *rsc_ops = NULL;
204 xmlNode *template_ops = NULL;
205 const char *template_ref = NULL;
206 const char *clone = NULL;
207 const char *
id = NULL;
209 if (xml_obj == NULL) {
210 pe_err(
"No resource object for template unpacking");
215 if (template_ref == NULL) {
221 pe_err(
"'%s' object must have a id", crm_element_name(xml_obj));
226 pe_err(
"The resource object '%s' should not reference itself",
id);
231 if (cib_resources == NULL) {
232 pe_err(
"No resources configured");
237 if (
template == NULL) {
238 pe_err(
"No template named '%s'", template_ref);
243 xmlNodeSetName(new_xml, xml_obj->name);
253 for (child_xml = __xml_first_child_element(xml_obj); child_xml != NULL;
254 child_xml = __xml_next_element(child_xml)) {
255 xmlNode *new_child = NULL;
259 if (
crm_str_eq((
const char *)new_child->name,
"operations", TRUE)) {
264 if (template_ops && rsc_ops) {
266 GHashTable *rsc_ops_hash = g_hash_table_new_full(
crm_str_hash,
270 for (op = __xml_first_child_element(rsc_ops); op != NULL;
271 op = __xml_next_element(op)) {
273 char *key = template_op_key(op);
275 g_hash_table_insert(rsc_ops_hash, key, op);
278 for (op = __xml_first_child_element(template_ops); op != NULL;
279 op = __xml_next_element(op)) {
281 char *key = template_op_key(op);
283 if (g_hash_table_lookup(rsc_ops_hash, key) == NULL) {
291 g_hash_table_destroy(rsc_ops_hash);
298 *expanded_xml = new_xml;
314 const char *template_ref = NULL;
315 const char *
id = NULL;
317 if (xml_obj == NULL) {
318 pe_err(
"No resource object for processing resource list of template");
323 if (template_ref == NULL) {
329 pe_err(
"'%s' object must have a id", crm_element_name(xml_obj));
334 pe_err(
"The resource object '%s' should not reference itself",
id);
348 const char *promotable = g_hash_table_lookup(rsc->
meta,
371 bool isdefault = FALSE;
372 xmlNode *expanded_xml = NULL;
374 const char *value = NULL;
375 const char *rclass = NULL;
377 bool guest_node = FALSE;
378 bool remote_node = FALSE;
379 bool has_versioned_params = FALSE;
384 pe_err(
"Must specify id tag in <resource>");
387 }
else if (rsc == NULL) {
388 pe_err(
"Nowhere to unpack resource into");
393 if (unpack_template(xml_obj, &expanded_xml, data_set) == FALSE) {
398 (*rsc)->cluster = data_set;
402 (*rsc)->xml = expanded_xml;
403 (*rsc)->orig_xml = xml_obj;
406 (*rsc)->xml = xml_obj;
407 (*rsc)->orig_xml = NULL;
412 (*rsc)->parent = parent;
417 (*rsc)->variant = get_resource_type(crm_element_name((*rsc)->xml));
419 pe_err(
"Unknown resource type: %s", crm_element_name((*rsc)->xml));
424 (*rsc)->parameters = crm_str_table_new();
426 #if ENABLE_VERSIONED_ATTRS
430 (*rsc)->meta = crm_str_table_new();
432 (*rsc)->allowed_nodes =
433 g_hash_table_new_full(
crm_str_hash, g_str_equal, NULL, free);
435 (*rsc)->known_on = g_hash_table_new_full(
crm_str_hash, g_str_equal, NULL,
440 (*rsc)->id = crm_concat(
id, value,
':');
444 (*rsc)->id = strdup(
id);
452 #if ENABLE_VERSIONED_ATTRS
453 pe_get_versioned_attributes((*rsc)->versioned_parameters, *rsc, NULL, data_set);
464 (*rsc)->rsc_cons = NULL;
465 (*rsc)->rsc_tickets = NULL;
466 (*rsc)->actions = NULL;
471 (*rsc)->stickiness = 0;
472 (*rsc)->migration_threshold =
INFINITY;
473 (*rsc)->failure_timeout = 0;
484 (*rsc)->is_remote_node = TRUE;
493 #if ENABLE_VERSIONED_ATTRS
497 pe_rsc_trace((*rsc),
"Migration is disabled for resources with versioned parameters");
500 }
else if ((value == NULL) && remote_node && !has_versioned_params) {
513 gboolean bool_value = TRUE;
516 if (bool_value == FALSE) {
525 gboolean bool_value = FALSE;
528 if (bool_value == TRUE) {
544 if (detect_promotable(*rsc)) {
556 pe_rsc_trace((*rsc),
"\tDependency restart handling: restart");
558 "Support for restart-type is deprecated and will be removed in a future release");
562 pe_rsc_trace((*rsc),
"\tDependency restart handling: ignore");
568 pe_rsc_trace((*rsc),
"\tMultiple running resource recovery: stop only");
572 pe_rsc_trace((*rsc),
"\tMultiple running resource recovery: block");
576 pe_rsc_trace((*rsc),
"\tMultiple running resource recovery: stop/start");
586 (*rsc)->migration_threshold =
char2score(value);
587 if ((*rsc)->migration_threshold < 0) {
594 " must be non-negative, using 1 instead");
595 (*rsc)->migration_threshold = 1;
606 handle_requires_pref:
614 crm_config_warn(
"%s is a fencing device but requires (un)fencing", (*rsc)->id);
617 goto handle_requires_pref;
620 crm_config_warn(
"%s requires (un)fencing but fencing is disabled", (*rsc)->id);
623 goto handle_requires_pref;
633 crm_config_warn(
"%s requires fencing but fencing is disabled", (*rsc)->id);
647 }
else if (((*rsc)->variant ==
pe_native)
667 goto handle_requires_pref;
670 pe_rsc_trace((*rsc),
"\tRequired to start: %s%s", value, isdefault?
" (default)":
"");
685 (*rsc)->failure_timeout = (*rsc)->remote_reconnect_ms / 1000;
693 if ((*rsc)->fns->unpack(*rsc, data_set) == FALSE) {
700 }
else if (guest_node) {
708 is_set((*rsc)->flags,
pe_rsc_notify) ?
"required" :
"not required");
710 (*rsc)->utilization = crm_str_table_new();
713 (*rsc)->utilization, NULL, FALSE, data_set);
718 if (add_template_rsc(xml_obj, data_set) == FALSE) {
739 for (; gIter != NULL; gIter = gIter->next) {
752 if (parent == NULL || rsc == NULL) {
755 while (parent->
parent != NULL) {
756 if (parent->
parent == rsc) {
769 if (parent == NULL) {
795 #if ENABLE_VERSIONED_ATTRS
796 if (rsc->versioned_parameters != NULL) {
797 free_xml(rsc->versioned_parameters);
800 if (rsc->
meta != NULL) {
801 g_hash_table_destroy(rsc->
meta);
823 g_hash_table_destroy(rsc->
known_on);
862 unsigned int *count_clean)
866 bool keep_looking = FALSE;
867 bool is_happy = FALSE;
879 for (GList *node_iter = rsc->
running_on; node_iter != NULL;
880 node_iter = node_iter->next) {
882 node = node_iter->data;
883 keep_looking = FALSE;
890 if (count_clean && is_happy) {
893 if (count_all || count_clean) {
914 if (active == NULL) {
919 if (keep_looking == FALSE) {
953 for (GList *item = rsc->
children; item != NULL; item = item->next) {
gboolean get_target_role(resource_t *rsc, enum rsc_role_e *role)
void pe__unpack_dataset_nvpairs(xmlNode *xml_obj, const char *set_name, GHashTable *node_hash, GHashTable *hash, const char *always_first, gboolean overwrite, pe_working_set_t *data_set)
#define RSC_ROLE_STARTED_S
enum rsc_role_e pe__bundle_resource_state(const pe_resource_t *rsc, gboolean current)
enum rsc_role_e native_resource_state(const resource_t *rsc, gboolean current)
gboolean crm_str_eq(const char *a, const char *b, gboolean use_case)
enum pe_obj_types variant
gboolean common_unpack(xmlNode *xml_obj, resource_t **rsc, resource_t *parent, pe_working_set_t *data_set)
GListPtr dangling_migrations
#define pe_rsc_allow_migrate
gboolean group_active(resource_t *rsc, gboolean all)
pe_node_t * pe__find_active_requires(const pe_resource_t *rsc, unsigned int *count)
void common_free(resource_t *rsc)
#define XML_OP_ATTR_ALLOW_MIGRATE
#define XML_REMOTE_ATTR_RECONNECT_INTERVAL
#define XML_RSC_ATTR_NOTIFY
int crm_str_to_boolean(const char *s, int *ret)
enum rsc_role_e clone_resource_state(const resource_t *rsc, gboolean current)
#define pe_rsc_provisional
#define PCMK_RESOURCE_CLASS_STONITH
xmlNode * create_xml_node(xmlNode *parent, const char *name)
gboolean native_unpack(resource_t *rsc, pe_working_set_t *data_set)
#define XML_CIB_TAG_INCARNATION
#define PCMK_RESOURCE_CLASS_OCF
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)
#define XML_RSC_ATTR_MAINTENANCE
xmlNode * copy_xml(xmlNode *src_node)
#define clear_bit(word, bit)
#define pe_rsc_fence_device
struct pe_node_shared_s * details
pe_node_t * native_location(const pe_resource_t *rsc, GList **list, int current)
#define safe_str_eq(a, b)
#define XML_CIB_TAG_RESOURCES
#define XML_TAG_ATTR_SETS
resource_object_functions_t resource_class_functions[]
resource_t * uber_parent(resource_t *rsc)
void pe__count_bundle(pe_resource_t *rsc)
void free_xml(xmlNode *child)
#define XML_CIB_ATTR_PRIORITY
const char * crm_xml_replace(xmlNode *node, const char *name, const char *value)
Replace an XML attribute with specified name and (possibly NULL) value.
gboolean crm_is_true(const char *s)
gboolean xml_contains_remote_node(xmlNode *xml)
gboolean xml_has_children(const xmlNode *root)
void native_free(resource_t *rsc)
#define XML_RSC_ATTR_MULTIPLE
void clone_print(resource_t *rsc, const char *pre_text, long options, void *print_data)
pe_node_t * pe__find_active_on(const pe_resource_t *rsc, unsigned int *count_all, unsigned int *count_clean)
#define set_bit(word, bit)
gboolean pe__unpack_bundle(pe_resource_t *rsc, pe_working_set_t *data_set)
#define XML_TAG_UTILIZATION
#define XML_CIB_TAG_RESOURCE
bool pe__resource_is_disabled(pe_resource_t *rsc)
void pe__print_bundle(pe_resource_t *rsc, const char *pre_text, long options, void *print_data)
xmlNode * find_entity(xmlNode *parent, const char *node_name, const char *id)
void clone_free(resource_t *rsc)
void group_print(resource_t *rsc, const char *pre_text, long options, void *print_data)
#define pe_rsc_needs_quorum
void pe__free_bundle(pe_resource_t *rsc)
#define XML_AGENT_ATTR_CLASS
#define XML_RSC_ATTR_PROMOTABLE
#define XML_RSC_ATTR_MANAGED
gboolean clone_unpack(resource_t *rsc, pe_working_set_t *data_set)
const char * role2text(enum rsc_role_e role)
void get_meta_attributes(GHashTable *meta_hash, resource_t *rsc, node_t *node, pe_working_set_t *data_set)
xmlNode * expand_idref(xmlNode *input, xmlNode *top)
#define XML_RSC_ATTR_UNIQUE
pe_node_t * partial_migration_source
#define pe_rsc_needs_unfencing
void get_rsc_attributes(GHashTable *meta_hash, resource_t *rsc, node_t *node, pe_working_set_t *data_set)
#define crm_log_xml_trace(xml, text)
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
#define pe_warn_once(pe_wo_bit, fmt...)
pe_working_set_t * cluster
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
#define XML_RSC_ATTR_FAIL_TIMEOUT
gboolean clone_active(resource_t *rsc, gboolean all)
#define XML_CIB_TAG_GROUP
#define XML_TAG_META_SETS
GHashTable * template_rsc_sets
void add_hash_param(GHashTable *hash, const char *name, const char *value)
gboolean add_tag_ref(GHashTable *tags, const char *tag_name, const char *obj_ref)
#define pe_rsc_needs_fencing
#define pe_flag_have_stonith_resource
int crm_parse_int(const char *text, const char *default_text)
Parse an integer value from a string.
void resource_location(resource_t *rsc, node_t *node, int score, const char *tag, pe_working_set_t *data_set)
void common_update_score(resource_t *rsc, const char *id, int score)
char * native_parameter(resource_t *rsc, node_t *node, gboolean create, const char *name, pe_working_set_t *data_set)
#define XML_RSC_ATTR_RESTART
#define XML_CIB_TAG_MASTER
#define XML_CIB_TAG_RSC_TEMPLATE
gboolean safe_str_neq(const char *a, const char *b)
#define crm_config_warn(fmt...)
guint crm_parse_interval_spec(const char *input)
int char2score(const char *score)
#define RSC_ROLE_UNKNOWN_S
void group_free(resource_t *rsc)
#define XML_TAG_RSC_VER_ATTRS
#define pe_flag_maintenance_mode
#define pe_flag_enable_unfencing
#define pe_rsc_trace(rsc, fmt, args...)
#define XML_AGENT_ATTR_PROVIDER
#define XML_RSC_ATTR_FAIL_STICKINESS
void populate_hash(xmlNode *nvpair_list, GHashTable *hash, const char **attrs, int attrs_length)
gboolean is_parent(resource_t *child, resource_t *rsc)
void native_print(resource_t *rsc, const char *pre_text, long options, void *print_data)
xmlNode * find_xml_node(xmlNode *cib, const char *node_path, gboolean must_find)
enum rsc_role_e group_resource_state(const resource_t *rsc, gboolean current)
gboolean group_unpack(resource_t *rsc, pe_working_set_t *data_set)
#define pe_rsc_promotable
#define XML_RSC_ATTR_REQUIRES
#define pe_flag_stonith_enabled
int merge_weights(int w1, int w2)
GHashTable * allowed_nodes
void pe__count_common(pe_resource_t *rsc)
gboolean native_active(resource_t *rsc, gboolean all)
enum pe_quorum_policy no_quorum_policy
#define pe_flag_symmetric_cluster
#define XML_RSC_ATTR_INCARNATION
gboolean pe__bundle_active(pe_resource_t *rsc, gboolean all)
#define XML_CIB_TAG_CONTAINER
xmlNode * add_node_copy(xmlNode *new_parent, xmlNode *xml_node)
#define XML_RSC_ATTR_STICKINESS
#define pe_rsc_maintenance
#define XML_RSC_ATTR_CONTAINER
#define crm_config_err(fmt...)