19 void populate_hash(xmlNode * nvpair_list, GHashTable * hash,
const char **attrs,
int attrs_length);
73 get_resource_type(
const char *
name)
96 dup_attr(gpointer key, gpointer value, gpointer user_data)
116 rule_data, parent_orig_meta, NULL, FALSE,
data_set);
121 if (parent_orig_meta != NULL) {
126 g_hash_table_iter_init(&iter, parent_orig_meta);
127 while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &value)) {
130 dup_attr(key, value, meta_hash);
134 if (parent_orig_meta != NULL) {
135 g_hash_table_destroy(parent_orig_meta);
156 .rsc_data = &rsc_rule_data,
164 for (xmlAttrPtr a = pcmk__xe_first_attr(rsc->
xml); a != NULL; a = a->next) {
165 const char *prop_name = (
const char *) a->name;
176 if (rsc->
parent != NULL) {
177 expand_parents_fixed_nvpairs(rsc, &rule_data, meta_hash,
data_set);
182 &rule_data, meta_hash, NULL, FALSE,
data_set);
187 g_hash_table_foreach(rsc->
parent->
meta, dup_attr, meta_hash);
212 if (rsc->
parent != NULL) {
218 &rule_data, meta_hash, NULL, FALSE,
data_set);
223 template_op_key(xmlNode * op)
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");
281 if (
template == NULL) {
282 pe_err(
"No template named '%s'", template_ref);
287 xmlNodeSetName(new_xml, xml_obj->name);
297 for (child_xml = pcmk__xe_first_child(xml_obj); child_xml != NULL;
298 child_xml = pcmk__xe_next(child_xml)) {
299 xmlNode *new_child = NULL;
303 if (pcmk__str_eq((
const char *)new_child->name,
"operations",
pcmk__str_none)) {
308 if (template_ops && rsc_ops) {
312 for (op = pcmk__xe_first_child(rsc_ops); op != NULL;
313 op = pcmk__xe_next(op)) {
315 char *key = template_op_key(op);
317 g_hash_table_insert(rsc_ops_hash, key, op);
320 for (op = pcmk__xe_first_child(template_ops); op != NULL;
321 op = pcmk__xe_next(op)) {
323 char *key = template_op_key(op);
325 if (g_hash_table_lookup(rsc_ops_hash, key) == NULL) {
333 g_hash_table_destroy(rsc_ops_hash);
340 *expanded_xml = new_xml;
356 const char *template_ref = NULL;
357 const char *
id = NULL;
359 if (xml_obj == NULL) {
360 pe_err(
"No resource object for processing resource list of template");
365 if (template_ref == NULL) {
371 pe_err(
"'%s' object must have a id", crm_element_name(xml_obj));
376 pe_err(
"The resource object '%s' should not reference itself",
id);
390 const char *promotable = g_hash_table_lookup(rsc->
meta,
411 free_params_table(gpointer
data)
413 g_hash_table_destroy((GHashTable *)
data);
432 GHashTable *params_on_node = NULL;
438 const char *node_name =
"";
441 if ((rsc == NULL) || (
data_set == NULL)) {
456 if (params_on_node == NULL) {
462 return params_on_node;
474 unpack_requires(
pe_resource_t *rsc,
const char *value,
bool is_default)
492 "devices cannot require unfencing", rsc->
id);
499 "is disabled", rsc->
id);
509 const char *orig_value = value;
531 if (orig_value != NULL) {
533 "to '%s' because '%s' is not valid",
534 rsc->
id, value, orig_value);
536 unpack_requires(rsc, value,
true);
541 (is_default?
" (default)" :
""));
565 xmlNode *expanded_xml = NULL;
567 const char *value = NULL;
568 const char *
id = NULL;
569 bool guest_node =
false;
570 bool remote_node =
false;
593 crm_element_name(xml_obj));
597 if (unpack_template(xml_obj, &expanded_xml,
data_set) == FALSE) {
603 crm_crit(
"Unable to allocate memory for resource '%s'",
id);
610 (*rsc)->xml = expanded_xml;
611 (*rsc)->orig_xml = xml_obj;
614 (*rsc)->xml = xml_obj;
615 (*rsc)->orig_xml = NULL;
625 (*rsc)->variant = get_resource_type(crm_element_name((*rsc)->xml));
627 pe_err(
"Ignoring resource '%s' of unknown type '%s'",
628 id, crm_element_name((*rsc)->xml));
644 (*rsc)->id = strdup(
id);
659 (*rsc)->rsc_cons = NULL;
660 (*rsc)->rsc_tickets = NULL;
661 (*rsc)->actions = NULL;
666 (*rsc)->stickiness = 0;
667 (*rsc)->migration_threshold =
INFINITY;
668 (*rsc)->failure_timeout = 0;
684 (*rsc)->is_remote_node = TRUE;
695 }
else if ((value == NULL) && remote_node) {
707 if (value != NULL && !pcmk__str_eq(
"default", value,
pcmk__str_casei)) {
730 if (detect_promotable(*rsc)) {
740 pe_rsc_trace((*rsc),
"%s dependency restart handling: restart",
743 "Support for restart-type is deprecated and will be removed in a future release");
747 pe_rsc_trace((*rsc),
"%s dependency restart handling: ignore",
754 pe_rsc_trace((*rsc),
"%s multiple running resource recovery: stop only",
759 pe_rsc_trace((*rsc),
"%s multiple running resource recovery: block",
764 pe_rsc_trace((*rsc),
"%s multiple running resource recovery: " 765 "stop unexpected instances",
769 if (!pcmk__str_eq(value,
"stop_start",
772 ", using default of \"stop_start\"", value);
775 pe_rsc_trace((*rsc),
"%s multiple running resource recovery: " 776 "stop/start", (*rsc)->id);
780 if (value != NULL && !pcmk__str_eq(
"default", value,
pcmk__str_casei)) {
785 if (value != NULL && !pcmk__str_eq(
"default", value,
pcmk__str_casei)) {
786 (*rsc)->migration_threshold =
char2score(value);
787 if ((*rsc)->migration_threshold < 0) {
794 " must be non-negative, using 1 instead");
795 (*rsc)->migration_threshold = 1;
806 unpack_requires(*rsc, value,
false);
830 (*rsc)->failure_timeout = (*rsc)->remote_reconnect_ms / 1000;
835 pe_rsc_trace((*rsc),
"%s desired next state: %s", (*rsc)->id,
838 if ((*rsc)->fns->unpack(*rsc,
data_set) == FALSE) {
839 (*rsc)->fns->free(*rsc);
847 }
else if (guest_node) {
854 pe_rsc_trace((*rsc),
"%s action notification: %s", (*rsc)->id,
860 (*rsc)->utilization, NULL, FALSE,
data_set);
863 if (add_template_rsc(xml_obj,
data_set) == FALSE) {
864 (*rsc)->fns->free(*rsc);
886 for (; gIter != NULL; gIter = gIter->next) {
899 if (
parent == NULL || rsc == NULL) {
902 while (
parent->parent != NULL) {
903 if (
parent->parent == rsc) {
942 if (rsc->
meta != NULL) {
943 g_hash_table_destroy(rsc->
meta);
965 g_hash_table_destroy(rsc->
known_on);
1004 unsigned int *count_clean)
1008 bool keep_looking = FALSE;
1009 bool is_happy = FALSE;
1021 for (GList *node_iter = rsc->
running_on; node_iter != NULL;
1022 node_iter = node_iter->next) {
1024 node = node_iter->data;
1025 keep_looking = FALSE;
1032 if (count_clean && is_happy) {
1035 if (count_all || count_clean) {
1037 keep_looking = TRUE;
1045 keep_looking = TRUE;
1053 keep_looking = TRUE;
1056 if (active == NULL) {
1061 if (keep_looking == FALSE) {
1095 for (GList *item = rsc->
children; item != NULL; item = item->next) {
1124 pe_rsc_trace(rsc,
"Resetting next role for %s from %s to %s (%s)",
pe_resource_t * uber_parent(pe_resource_t *rsc)
#define CRM_CHECK(expr, failure_action)
#define RSC_ROLE_UNPROMOTED_S
enum pe_quorum_policy no_quorum_policy
void pe__count_common(pe_resource_t *rsc)
void group_free(pe_resource_t *rsc)
#define crm_crit(fmt, args...)
#define PCMK__VALUE_FENCING
void group_print(pe_resource_t *rsc, const char *pre_text, long options, void *print_data)
xmlNode * pcmk__xe_match(const xmlNode *parent, const char *node_name, const char *attr_n, const char *attr_v)
#define XML_EXPR_ATTR_TYPE
#define XML_CIB_TAG_CONTAINER
GHashTable * pe_rsc_params(pe_resource_t *rsc, const pe_node_t *node, pe_working_set_t *data_set)
Get a table of resource parameters.
bool pcmk__strcase_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
pe_node_t * partial_migration_source
#define XML_TAG_UTILIZATION
#define pcmk__config_warn(fmt...)
#define RSC_ROLE_STARTED_S
void pe__free_bundle(pe_resource_t *rsc)
#define pe_flag_symmetric_cluster
enum rsc_role_e pe__bundle_resource_state(const pe_resource_t *rsc, gboolean current)
#define XML_RSC_ATTR_INCARNATION
gboolean pe__group_is_filtered(pe_resource_t *rsc, GList *only_rsc, gboolean check_parent)
enum rsc_role_e next_role
#define pe_flag_maintenance_mode
gboolean group_active(pe_resource_t *rsc, gboolean all)
int char2score(const char *score)
Get the integer value of a score string.
#define pcmk__config_err(fmt...)
xmlNode * find_xml_node(const xmlNode *root, const char *search_path, gboolean must_find)
pe_node_t * native_location(const pe_resource_t *rsc, GList **list, int current)
#define PCMK__VALUE_QUORUM
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
#define PCMK__VALUE_UNFENCING
#define XML_CIB_TAG_RSC_TEMPLATE
#define XML_RSC_ATTR_STICKINESS
void resource_location(pe_resource_t *rsc, pe_node_t *node, int score, const char *tag, pe_working_set_t *data_set)
void pe__set_next_role(pe_resource_t *rsc, enum rsc_role_e role, const char *why)
void pe__print_bundle(pe_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)
gboolean pe__unpack_bundle(pe_resource_t *rsc, pe_working_set_t *data_set)
void native_free(pe_resource_t *rsc)
#define pe__set_resource_flags(resource, flags_to_set)
void clone_free(pe_resource_t *rsc)
#define XML_CIB_ATTR_PRIORITY
xmlNode * copy_xml(xmlNode *src_node)
enum rsc_role_e group_resource_state(const pe_resource_t *rsc, gboolean current)
#define pe_rsc_provisional
#define XML_TAG_ATTR_SETS
#define XML_CIB_TAG_RESOURCES
#define XML_RSC_ATTR_PROMOTABLE
const char * role2text(enum rsc_role_e role)
GList * dangling_migrations
enum rsc_role_e clone_resource_state(const pe_resource_t *rsc, gboolean current)
#define XML_RSC_ATTR_REQUIRES
gboolean pe__native_is_filtered(pe_resource_t *rsc, GList *only_rsc, gboolean check_parent)
#define pe_rsc_allow_migrate
#define XML_RSC_ATTR_CRITICAL
resource_object_functions_t resource_class_functions[]
#define XML_RSC_ATTR_CONTAINER
gboolean clone_active(pe_resource_t *rsc, gboolean all)
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.
#define pe_warn_once(pe_wo_bit, fmt...)
char * native_parameter(pe_resource_t *rsc, pe_node_t *node, gboolean create, const char *name, pe_working_set_t *data_set)
#define RSC_ROLE_UNPROMOTED_LEGACY_S
#define PCMK_RESOURCE_CLASS_STONITH
bool xml_contains_remote_node(xmlNode *xml)
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
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
gboolean get_target_role(pe_resource_t *rsc, enum rsc_role_e *role)
xmlNode * expand_idref(xmlNode *input, xmlNode *top)
#define XML_AGENT_ATTR_PROVIDER
#define pe_rsc_needs_fencing
#define pe_rsc_promotable
pe_working_set_t * data_set
#define XML_TAG_META_SETS
gboolean add_tag_ref(GHashTable *tags, const char *tag_name, const char *obj_ref)
#define XML_RSC_ATTR_MANAGED
#define pe_flag_stonith_enabled
enum rsc_role_e native_resource_state(const pe_resource_t *rsc, gboolean current)
void clone_print(pe_resource_t *rsc, const char *pre_text, long options, void *print_data)
void native_print(pe_resource_t *rsc, const char *pre_text, long options, void *print_data)
gboolean pe__bundle_is_filtered(pe_resource_t *rsc, GList *only_rsc, gboolean check_parent)
void get_rsc_attributes(GHashTable *meta_hash, const pe_resource_t *rsc, const pe_node_t *node, pe_working_set_t *data_set)
void free_xml(xmlNode *child)
enum pe_obj_types variant
#define XML_REMOTE_ATTR_RECONNECT_INTERVAL
#define XML_RSC_ATTR_NOTIFY
#define XML_RSC_ATTR_FAIL_STICKINESS
gboolean native_active(pe_resource_t *rsc, gboolean all)
void populate_hash(xmlNode *nvpair_list, GHashTable *hash, const char **attrs, int attrs_length)
#define pe_rsc_fence_device
#define XML_RSC_ATTR_UNIQUE
pe_resource_t * native_find_rsc(pe_resource_t *rsc, const char *id, const pe_node_t *node, int flags)
#define XML_CIB_TAG_INCARNATION
GHashTable * pcmk__strkey_table(GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func)
#define XML_RSC_ATTR_MAINTENANCE
#define XML_RSC_ATTR_FAIL_TIMEOUT
void get_meta_attributes(GHashTable *meta_hash, pe_resource_t *rsc, pe_node_t *node, pe_working_set_t *data_set)
void add_hash_param(GHashTable *hash, const char *name, const char *value)
gboolean clone_unpack(pe_resource_t *rsc, pe_working_set_t *data_set)
char guint crm_parse_interval_spec(const char *input)
Parse milliseconds from a Pacemaker interval specification.
gboolean is_parent(pe_resource_t *child, pe_resource_t *rsc)
#define PCMK_XE_PROMOTABLE_LEGACY
#define pe_rsc_needs_unfencing
#define XML_RSC_ATTR_MULTIPLE
#define pe__clear_resource_flags(resource, flags_to_clear)
#define pe__set_working_set_flags(working_set, flags_to_set)
rsc_role_e
Possible roles that a resource can be in.
#define pe_rsc_maintenance
#define XML_RSC_ATTR_RESTART
#define PCMK__VALUE_NOTHING
pe_working_set_t * cluster
int pcmk__add_scores(int score1, int score2)
#define RSC_ROLE_UNKNOWN_S
void common_free(pe_resource_t *rsc)
#define pe_rsc_needs_quorum
#define crm_log_xml_trace(xml, text)
GHashTable * parameter_cache
gboolean crm_is_true(const char *s)
#define pe_flag_have_stonith_resource
#define XML_CIB_TAG_GROUP
#define pe_flag_enable_unfencing
#define pe_rsc_trace(rsc, fmt, args...)
bool pe__resource_is_disabled(pe_resource_t *rsc)
void common_update_score(pe_resource_t *rsc, const char *id, int score)
gboolean native_unpack(pe_resource_t *rsc, pe_working_set_t *data_set)
gboolean pe__clone_is_filtered(pe_resource_t *rsc, GList *only_rsc, gboolean check_parent)
pe_node_t * pe__find_active_requires(const pe_resource_t *rsc, unsigned int *count)
GHashTable * template_rsc_sets
void pe__count_bundle(pe_resource_t *rsc)
#define XML_OP_ATTR_ALLOW_MIGRATE
int pe__unpack_resource(xmlNode *xml_obj, pe_resource_t **rsc, pe_resource_t *parent, pe_working_set_t *data_set)
gboolean pe__bundle_active(pe_resource_t *rsc, gboolean all)
GHashTable * pcmk__strikey_table(GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func)
#define XML_AGENT_ATTR_CLASS
GHashTable * allowed_nodes
gboolean group_unpack(pe_resource_t *rsc, pe_working_set_t *data_set)
void pe__unpack_dataset_nvpairs(const xmlNode *xml_obj, const char *set_name, pe_rule_eval_data_t *rule_data, GHashTable *hash, const char *always_first, gboolean overwrite, pe_working_set_t *data_set)