19 void populate_hash(xmlNode * nvpair_list, GHashTable * hash,
const char **attrs,
int attrs_length);
22 unsigned int *count_clean);
80 get_resource_type(
const char *
name)
103 dup_attr(gpointer key, gpointer value, gpointer user_data)
123 rule_data, parent_orig_meta, NULL, FALSE,
data_set);
128 if (parent_orig_meta != NULL) {
133 g_hash_table_iter_init(&iter, parent_orig_meta);
134 while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &value)) {
137 dup_attr(key, value, meta_hash);
141 if (parent_orig_meta != NULL) {
142 g_hash_table_destroy(parent_orig_meta);
163 .rsc_data = &rsc_rule_data,
171 for (xmlAttrPtr a = pcmk__xe_first_attr(rsc->
xml); a != NULL; a = a->next) {
172 const char *prop_name = (
const char *) a->name;
183 if (rsc->
parent != NULL) {
184 expand_parents_fixed_nvpairs(rsc, &rule_data, meta_hash,
data_set);
189 &rule_data, meta_hash, NULL, FALSE,
data_set);
194 g_hash_table_foreach(rsc->
parent->
meta, dup_attr, meta_hash);
219 if (rsc->
parent != NULL) {
225 &rule_data, meta_hash, NULL, FALSE,
data_set);
230 template_op_key(xmlNode * op)
249 xmlNode *cib_resources = NULL;
250 xmlNode *
template = NULL;
251 xmlNode *new_xml = NULL;
252 xmlNode *child_xml = NULL;
253 xmlNode *rsc_ops = NULL;
254 xmlNode *template_ops = NULL;
255 const char *template_ref = NULL;
256 const char *clone = NULL;
257 const char *
id = NULL;
259 if (xml_obj == NULL) {
260 pe_err(
"No resource object for template unpacking");
265 if (template_ref == NULL) {
271 pe_err(
"'%s' object must have a id", crm_element_name(xml_obj));
276 pe_err(
"The resource object '%s' should not reference itself",
id);
281 if (cib_resources == NULL) {
282 pe_err(
"No resources configured");
288 if (
template == NULL) {
289 pe_err(
"No template named '%s'", template_ref);
294 xmlNodeSetName(new_xml, xml_obj->name);
304 for (child_xml = pcmk__xe_first_child(xml_obj); child_xml != NULL;
305 child_xml = pcmk__xe_next(child_xml)) {
306 xmlNode *new_child = NULL;
310 if (pcmk__str_eq((
const char *)new_child->name,
"operations",
pcmk__str_none)) {
315 if (template_ops && rsc_ops) {
319 for (op = pcmk__xe_first_child(rsc_ops); op != NULL;
320 op = pcmk__xe_next(op)) {
322 char *key = template_op_key(op);
324 g_hash_table_insert(rsc_ops_hash, key, op);
327 for (op = pcmk__xe_first_child(template_ops); op != NULL;
328 op = pcmk__xe_next(op)) {
330 char *key = template_op_key(op);
332 if (g_hash_table_lookup(rsc_ops_hash, key) == NULL) {
340 g_hash_table_destroy(rsc_ops_hash);
347 *expanded_xml = new_xml;
363 const char *template_ref = NULL;
364 const char *
id = NULL;
366 if (xml_obj == NULL) {
367 pe_err(
"No resource object for processing resource list of template");
372 if (template_ref == NULL) {
378 pe_err(
"'%s' object must have a id", crm_element_name(xml_obj));
383 pe_err(
"The resource object '%s' should not reference itself",
id);
397 const char *promotable = g_hash_table_lookup(rsc->
meta,
418 free_params_table(gpointer
data)
420 g_hash_table_destroy((GHashTable *)
data);
439 GHashTable *params_on_node = NULL;
445 const char *node_name =
"";
448 if ((rsc == NULL) || (
data_set == NULL)) {
463 if (params_on_node == NULL) {
469 return params_on_node;
481 unpack_requires(
pe_resource_t *rsc,
const char *value,
bool is_default)
499 "devices cannot require unfencing", rsc->
id);
506 "is disabled", rsc->
id);
516 const char *orig_value = value;
538 if (orig_value != NULL) {
540 "to '%s' because '%s' is not valid",
541 rsc->
id, value, orig_value);
543 unpack_requires(rsc, value,
true);
548 (is_default?
" (default)" :
""));
551 #ifndef PCMK__COMPAT_2_0 559 "Support for Upstart resources (such as %s) is deprecated " 560 "and will be removed in a future release of Pacemaker",
565 "Support for Nagios resources (such as %s) is deprecated " 566 "and will be removed in a future release of Pacemaker",
593 xmlNode *expanded_xml = NULL;
595 const char *value = NULL;
596 const char *
id = NULL;
597 bool guest_node =
false;
598 bool remote_node =
false;
621 crm_element_name(xml_obj));
625 if (unpack_template(xml_obj, &expanded_xml,
data_set) == FALSE) {
631 crm_crit(
"Unable to allocate memory for resource '%s'",
id);
638 (*rsc)->xml = expanded_xml;
639 (*rsc)->orig_xml = xml_obj;
642 (*rsc)->xml = xml_obj;
643 (*rsc)->orig_xml = NULL;
653 (*rsc)->variant = get_resource_type(crm_element_name((*rsc)->xml));
655 pe_err(
"Ignoring resource '%s' of unknown type '%s'",
656 id, crm_element_name((*rsc)->xml));
662 #ifndef PCMK__COMPAT_2_0 663 warn_about_deprecated_classes(*rsc);
676 (*rsc)->id = strdup(
id);
691 (*rsc)->rsc_cons = NULL;
692 (*rsc)->rsc_tickets = NULL;
693 (*rsc)->actions = NULL;
698 (*rsc)->stickiness = 0;
699 (*rsc)->migration_threshold =
INFINITY;
700 (*rsc)->failure_timeout = 0;
716 (*rsc)->is_remote_node = TRUE;
727 }
else if ((value == NULL) && remote_node) {
739 if (value != NULL && !pcmk__str_eq(
"default", value,
pcmk__str_casei)) {
762 if (detect_promotable(*rsc)) {
772 pe_rsc_trace((*rsc),
"%s dependency restart handling: restart",
775 "Support for restart-type is deprecated and will be removed in a future release");
779 pe_rsc_trace((*rsc),
"%s dependency restart handling: ignore",
786 pe_rsc_trace((*rsc),
"%s multiple running resource recovery: stop only",
791 pe_rsc_trace((*rsc),
"%s multiple running resource recovery: block",
796 pe_rsc_trace((*rsc),
"%s multiple running resource recovery: " 797 "stop unexpected instances",
801 if (!pcmk__str_eq(value,
"stop_start",
804 ", using default of \"stop_start\"", value);
807 pe_rsc_trace((*rsc),
"%s multiple running resource recovery: " 808 "stop/start", (*rsc)->id);
812 if (value != NULL && !pcmk__str_eq(
"default", value,
pcmk__str_casei)) {
817 if (value != NULL && !pcmk__str_eq(
"default", value,
pcmk__str_casei)) {
818 (*rsc)->migration_threshold =
char2score(value);
819 if ((*rsc)->migration_threshold < 0) {
826 " must be non-negative, using 1 instead");
827 (*rsc)->migration_threshold = 1;
838 unpack_requires(*rsc, value,
false);
862 (*rsc)->failure_timeout = (*rsc)->remote_reconnect_ms / 1000;
867 pe_rsc_trace((*rsc),
"%s desired next state: %s", (*rsc)->id,
870 if ((*rsc)->fns->unpack(*rsc,
data_set) == FALSE) {
871 (*rsc)->fns->free(*rsc);
879 }
else if (guest_node) {
886 pe_rsc_trace((*rsc),
"%s action notification: %s", (*rsc)->id,
892 (*rsc)->utilization, NULL, FALSE,
data_set);
895 if (add_template_rsc(xml_obj,
data_set) == FALSE) {
896 (*rsc)->fns->free(*rsc);
909 if (
parent == NULL || rsc == NULL) {
912 while (
parent->parent != NULL) {
913 if (
parent->parent == rsc) {
954 while (
parent->parent != NULL) {
980 if (rsc->
meta != NULL) {
981 g_hash_table_destroy(rsc->
meta);
1003 g_hash_table_destroy(rsc->
known_on);
1041 pe_node_t **active,
unsigned int *count_all,
1042 unsigned int *count_clean)
1044 bool keep_looking =
false;
1045 bool is_happy =
false;
1047 CRM_CHECK((rsc != NULL) && (node != NULL) && (active != NULL),
1052 if (count_all != NULL) {
1055 if ((count_clean != NULL) && is_happy) {
1058 if ((count_all != NULL) || (count_clean != NULL)) {
1059 keep_looking =
true;
1066 keep_looking =
true;
1069 if (is_happy && ((*active == NULL) || !(*active)->details->online
1070 || (*active)->details->unclean)) {
1073 keep_looking =
true;
1076 if (*active == NULL) {
1079 return keep_looking;
1084 active_node(
const pe_resource_t *rsc,
unsigned int *count_all,
1085 unsigned int *count_clean)
1089 if (count_all != NULL) {
1092 if (count_clean != NULL) {
1098 for (GList *iter = rsc->
running_on; iter != NULL; iter = iter->next) {
1100 count_all, count_clean)) {
1124 if (count != NULL) {
1141 for (GList *item = rsc->
children; item != NULL; item = item->next) {
1170 pe_rsc_trace(rsc,
"Resetting next role for %s from %s to %s (%s)",
gboolean get_target_role(const pe_resource_t *rsc, enum rsc_role_e *role)
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...)
gboolean pe__bundle_is_filtered(const pe_resource_t *rsc, GList *only_rsc, gboolean check_parent)
#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
const pe_resource_t * pe__const_top_resource(const pe_resource_t *rsc, bool include_bundle)
#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
bool pe__count_active_node(const pe_resource_t *rsc, pe_node_t *node, pe_node_t **active, unsigned int *count_all, unsigned int *count_clean)
enum rsc_role_e pe__bundle_resource_state(const pe_resource_t *rsc, gboolean current)
#define XML_RSC_ATTR_INCARNATION
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
resource_object_functions_t * fns
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
bool pe__resource_is_disabled(const pe_resource_t *rsc)
gboolean pe__native_is_filtered(const pe_resource_t *rsc, GList *only_rsc, gboolean check_parent)
#define XML_CIB_TAG_RSC_TEMPLATE
#define XML_RSC_ATTR_STICKINESS
void resource_location(pe_resource_t *rsc, const 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)
pe_node_t *(* active_node)(const pe_resource_t *rsc, unsigned int *count_all, unsigned int *count_clean)
#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 PCMK_RESOURCE_CLASS_UPSTART
#define XML_RSC_ATTR_REQUIRES
#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)
struct pe_node_shared_s * details
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)
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
gboolean pe__clone_is_filtered(const pe_resource_t *rsc, GList *only_rsc, gboolean check_parent)
pe_node_t * pe__bundle_active_node(const pe_resource_t *rsc, unsigned int *count_all, unsigned int *count_clean)
#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)
gboolean pe__group_is_filtered(const pe_resource_t *rsc, GList *only_rsc, gboolean check_parent)
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
#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
void pe__unpack_dataset_nvpairs(const xmlNode *xml_obj, const char *set_name, const pe_rule_eval_data_t *rule_data, GHashTable *hash, const char *always_first, gboolean overwrite, pe_working_set_t *data_set)
#define XML_CIB_TAG_GROUP
#define pe_flag_enable_unfencing
#define pe_rsc_trace(rsc, fmt, args...)
#define PCMK_RESOURCE_CLASS_NAGIOS
gboolean native_unpack(pe_resource_t *rsc, pe_working_set_t *data_set)
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)