20 void populate_hash(xmlNode * nvpair_list, GHashTable * hash,
const char **attrs,
int attrs_length);
23 unsigned int *count_all,
24 unsigned int *count_clean);
86 get_resource_type(
const char *
name)
121 dup_attr(gpointer key, gpointer value, gpointer user_data)
123 GHashTable *table = user_data;
125 CRM_CHECK((key != NULL) && (table != NULL),
return);
129 "the explicit value '#default' is deprecated and " 130 "will be removed in a future release",
132 }
else if ((value != NULL) && (g_hash_table_lookup(table, key) == NULL)) {
157 parent_orig_meta, NULL, FALSE,
scheduler);
161 if (parent_orig_meta != NULL) {
163 g_hash_table_foreach(parent_orig_meta, dup_attr, meta_hash);
166 if (parent_orig_meta != NULL) {
167 g_hash_table_destroy(parent_orig_meta);
187 .rsc_data = &rsc_rule_data,
199 for (xmlAttrPtr a = pcmk__xe_first_attr(rsc->
xml); a != NULL; a = a->next) {
200 if (a->children != NULL) {
201 dup_attr((gpointer) a->name, (gpointer) a->children->content,
213 if (rsc->
parent != NULL) {
214 expand_parents_fixed_nvpairs(rsc, &rule_data, meta_hash,
scheduler);
219 &rule_data, meta_hash, NULL, FALSE,
scheduler);
226 g_hash_table_foreach(rsc->
parent->
meta, dup_attr, meta_hash);
247 &rule_data, meta_hash, NULL, FALSE,
scheduler);
250 if (rsc->
parent != NULL) {
265 "removed in a future release");
276 template_op_key(xmlNode * op)
293 unpack_template(xmlNode *xml_obj, xmlNode **expanded_xml,
296 xmlNode *cib_resources = NULL;
297 xmlNode *
template = NULL;
298 xmlNode *new_xml = NULL;
299 xmlNode *child_xml = NULL;
300 xmlNode *rsc_ops = NULL;
301 xmlNode *template_ops = NULL;
302 const char *template_ref = NULL;
303 const char *
id = NULL;
305 if (xml_obj == NULL) {
311 if (template_ref == NULL) {
315 id = pcmk__xe_id(xml_obj);
329 if (cib_resources == NULL) {
336 if (
template == NULL) {
342 xmlNodeSetName(new_xml, xml_obj->name);
351 child_xml != NULL; child_xml = pcmk__xe_next(child_xml)) {
360 if (template_ops && rsc_ops) {
365 op = pcmk__xe_next(op)) {
367 char *key = template_op_key(op);
369 g_hash_table_insert(rsc_ops_hash, key, op);
373 op != NULL; op = pcmk__xe_next(op)) {
375 char *key = template_op_key(op);
377 if (g_hash_table_lookup(rsc_ops_hash, key) == NULL) {
385 g_hash_table_destroy(rsc_ops_hash);
392 *expanded_xml = new_xml;
395 if (!unpack_template(new_xml, expanded_xml,
scheduler)) {
397 *expanded_xml = NULL;
408 const char *template_ref = NULL;
409 const char *
id = NULL;
411 if (xml_obj == NULL) {
418 if (template_ref == NULL) {
422 id = pcmk__xe_id(xml_obj);
444 const char *promotable = g_hash_table_lookup(rsc->
meta,
455 "as in %s) is deprecated and will be removed in a " 466 free_params_table(gpointer
data)
468 g_hash_table_destroy((GHashTable *)
data);
487 GHashTable *params_on_node = NULL;
493 const char *node_name =
"";
496 if ((rsc == NULL) || (
scheduler == NULL)) {
511 if (params_on_node == NULL) {
517 return params_on_node;
529 unpack_requires(
pcmk_resource_t *rsc,
const char *value,
bool is_default)
547 "devices cannot require unfencing", rsc->
id);
555 "disabled", rsc->
id);
565 const char *orig_value = value;
570 }
else if (pcmk__is_primitive(rsc)
589 if (orig_value != NULL) {
591 "to '%s' because '%s' is not valid",
592 rsc->
id, value, orig_value);
594 unpack_requires(rsc, value,
true);
599 (is_default?
" (default)" :
""));
609 "Support for Upstart resources (such as %s) is " 610 "deprecated and will be removed in a future release",
615 "Support for Nagios resources (such as %s) is " 616 "deprecated and will be removed in a future release",
630 const char *value = g_hash_table_lookup(rsc->
meta,
637 " because '%s' is not a valid value: %s",
651 const char *value = g_hash_table_lookup(rsc->
meta,
659 "' is deprecated and will be removed in a " 660 "future release (just leave it unset)");
667 " because '%s' is not a valid value: %s",
694 xmlNode *expanded_xml = NULL;
696 const char *value = NULL;
697 const char *
id = NULL;
698 bool guest_node =
false;
699 bool remote_node =
false;
725 if (unpack_template(xml_obj, &expanded_xml,
scheduler) == FALSE) {
738 (*rsc)->xml = expanded_xml;
739 (*rsc)->orig_xml = xml_obj;
742 (*rsc)->xml = xml_obj;
743 (*rsc)->orig_xml = NULL;
753 (*rsc)->variant = get_resource_type((
const char *) (*rsc)->xml->name);
756 id, (*rsc)->xml->name);
772 (*rsc)->id = strdup(
id);
775 warn_about_deprecated_classes(*rsc);
789 (*rsc)->rsc_cons = NULL;
790 (*rsc)->rsc_tickets = NULL;
791 (*rsc)->actions = NULL;
796 (*rsc)->stickiness = 0;
798 (*rsc)->failure_timeout = 0;
800 unpack_priority(*rsc);
813 (*rsc)->is_remote_node = TRUE;
824 }
else if ((value == NULL) && remote_node) {
841 "' is deprecated and will be removed in a " 842 "future release (just leave it unset)");
865 if (detect_promotable(*rsc)) {
880 "and will be removed in a future release");
891 pcmk__rsc_trace(*rsc,
"%s multiple running resource recovery: stop only",
903 "%s multiple running resource recovery: " 904 "stop unexpected instances",
912 ", using default of " 918 "%s multiple running resource recovery: stop/start",
922 unpack_stickiness(*rsc);
931 "' is deprecated and will be removed in a " 932 "future release (just leave it unset)");
934 (*rsc)->migration_threshold =
char2score(value);
935 if ((*rsc)->migration_threshold < 0) {
942 " must be non-negative, using 1 instead");
943 (*rsc)->migration_threshold = 1;
955 unpack_requires(*rsc, value,
false);
959 guint interval_ms = 0U;
963 (*rsc)->failure_timeout = (int) (interval_ms / 1000);
984 (*rsc)->failure_timeout = (*rsc)->remote_reconnect_ms / 1000;
993 if ((*rsc)->fns->unpack(*rsc,
scheduler) == FALSE) {
994 (*rsc)->fns->free(*rsc);
1002 }
else if (guest_node) {
1016 (*rsc)->utilization, NULL, FALSE,
scheduler);
1019 if (add_template_rsc(xml_obj,
scheduler) == FALSE) {
1020 (*rsc)->fns->free(*rsc);
1033 if (
parent == NULL || rsc == NULL) {
1036 while (
parent->parent != NULL) {
1037 if (
parent->parent == rsc) {
1053 while ((
parent->parent != NULL) && !pcmk__is_bundle(
parent->parent)) {
1078 while (
parent->parent != NULL) {
1079 if (!include_bundle && pcmk__is_bundle(
parent->parent)) {
1104 if (rsc->
meta != NULL) {
1105 g_hash_table_destroy(rsc->
meta);
1111 if ((rsc->
parent == NULL)
1129 g_hash_table_destroy(rsc->
known_on);
1168 unsigned int *count_clean)
1170 bool keep_looking =
false;
1171 bool is_happy =
false;
1173 CRM_CHECK((rsc != NULL) && (node != NULL) && (active != NULL),
1178 if (count_all != NULL) {
1181 if ((count_clean != NULL) && is_happy) {
1184 if ((count_all != NULL) || (count_clean != NULL)) {
1185 keep_looking =
true;
1192 keep_looking =
true;
1195 if (is_happy && ((*active == NULL) || !(*active)->details->online
1196 || (*active)->details->unclean)) {
1199 keep_looking =
true;
1202 if (*active == NULL) {
1205 return keep_looking;
1211 unsigned int *count_clean)
1215 if (count_all != NULL) {
1218 if (count_clean != NULL) {
1224 for (GList *iter = rsc->
running_on; iter != NULL; iter = iter->next) {
1226 count_all, count_clean)) {
1250 if (count != NULL) {
1267 for (GList *item = rsc->
children; item != NULL; item = item->next) {
gboolean native_active(pcmk_resource_t *rsc, gboolean all)
void pe__count_bundle(pcmk_resource_t *rsc)
#define CRM_CHECK(expr, failure_action)
xmlNode * pcmk__xml_copy(xmlNode *parent, xmlNode *src)
enum pe_quorum_policy no_quorum_policy
#define PCMK_VALUE_STOP_UNEXPECTED
pcmk_scheduler_t * cluster
const char * pcmk_role_text(enum rsc_role_e role)
Get readable description of a resource role.
unsigned int pe__clone_max_per_node(const pcmk_resource_t *rsc)
#define PCMK_META_PROMOTABLE
pcmk_resource_t * uber_parent(pcmk_resource_t *rsc)
void pe__free_bundle(pcmk_resource_t *rsc)
#define PCMK_META_MIGRATION_THRESHOLD
#define PCMK_META_REQUIRES
#define PCMK_REMOTE_RA_RECONNECT_INTERVAL
bool pcmk__strcase_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
#define PCMK_XE_PRIMITIVE
#define pcmk__config_warn(fmt...)
#define pcmk__rsc_trace(rsc, fmt, args...)
#define PCMK_XE_RSC_DEFAULTS
enum rsc_role_e next_role
gboolean get_target_role(const pcmk_resource_t *rsc, enum rsc_role_e *role)
#define pcmk__insert_meta(obj, name, value)
#define pcmk__config_err(fmt...)
#define PCMK_VALUE_STOP_START
pcmk_node_t * pe__find_active_requires(const pcmk_resource_t *rsc, unsigned int *count)
gboolean is_parent(pcmk_resource_t *child, pcmk_resource_t *rsc)
#define PCMK_VALUE_RESTART
#define PCMK_VALUE_DEFAULT
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
#define PCMK_META_MULTIPLE_ACTIVE
enum rsc_role_e native_resource_state(const pcmk_resource_t *rsc, gboolean current)
unsigned int pe__bundle_max_per_node(const pcmk_resource_t *rsc)
const char * pcmk_rc_str(int rc)
Get a user-friendly description of a return code.
bool pe__count_active_node(const pcmk_resource_t *rsc, pcmk_node_t *node, pcmk_node_t **active, unsigned int *count_all, unsigned int *count_clean)
int pe__unpack_resource(xmlNode *xml_obj, pcmk_resource_t **rsc, pcmk_resource_t *parent, pcmk_scheduler_t *scheduler)
xmlNode * get_xpath_object(const char *xpath, xmlNode *xml_obj, int error_level)
unsigned int pe__group_max_per_node(const pcmk_resource_t *rsc)
gboolean clone_unpack(pcmk_resource_t *rsc, pcmk_scheduler_t *scheduler)
#define PCMK_META_IS_MANAGED
#define PCMK_VALUE_NOTHING
#define PCMK_VALUE_FENCING
char int pcmk_parse_interval_spec(const char *input, guint *result_ms)
Parse milliseconds from a Pacemaker interval specification.
gboolean native_unpack(pcmk_resource_t *rsc, pcmk_scheduler_t *scheduler)
void pe__print_bundle(pcmk_resource_t *rsc, const char *pre_text, long options, void *print_data)
gboolean group_unpack(pcmk_resource_t *rsc, pcmk_scheduler_t *scheduler)
#define PCMK_META_GLOBALLY_UNIQUE
GList * dangling_migrations
#define PCMK_RESOURCE_CLASS_UPSTART
gboolean clone_active(pcmk_resource_t *rsc, gboolean all)
gboolean pe__bundle_is_filtered(const pcmk_resource_t *rsc, GList *only_rsc, gboolean check_parent)
gboolean pe__clone_is_filtered(const pcmk_resource_t *rsc, GList *only_rsc, gboolean check_parent)
#define PCMK__ROLE_UNPROMOTED_LEGACY
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
xmlNode * pcmk__xe_first_child(const xmlNode *parent, const char *node_name, const char *attr_n, const char *attr_v)
void resource_location(pcmk_resource_t *rsc, const pcmk_node_t *node, int score, const char *tag, pcmk_scheduler_t *scheduler)
#define pcmk__sched_err(fmt...)
#define PCMK_XE_UTILIZATION
int char2score(const char *score)
Get the integer value of a score string.
unsigned int pe__primitive_max_per_node(const pcmk_resource_t *rsc)
#define PCMK_RESOURCE_CLASS_STONITH
bool xml_contains_remote_node(xmlNode *xml)
GHashTable * pe_rsc_params(pcmk_resource_t *rsc, const pcmk_node_t *node, pcmk_scheduler_t *scheduler)
Get a table of resource parameters.
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.
enum rsc_role_e clone_resource_state(const pcmk_resource_t *rsc, gboolean current)
struct pe_node_shared_s * details
xmlNode * expand_idref(xmlNode *input, xmlNode *top)
#define PCMK_META_RESOURCE_STICKINESS
Wrappers for and extensions to libxml2.
gboolean add_tag_ref(GHashTable *tags, const char *tag_name, const char *obj_ref)
void group_free(pcmk_resource_t *rsc)
void native_free(pcmk_resource_t *rsc)
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, pcmk_scheduler_t *scheduler)
void get_meta_attributes(GHashTable *meta_hash, pcmk_resource_t *rsc, pcmk_node_t *node, pcmk_scheduler_t *scheduler)
void common_free(pcmk_resource_t *rsc)
enum rsc_role_e pe__bundle_resource_state(const pcmk_resource_t *rsc, gboolean current)
#define PCMK_XE_OPERATIONS
void pe__count_common(pcmk_resource_t *rsc)
#define pcmk__set_rsc_flags(resource, flags_to_set)
void group_print(pcmk_resource_t *rsc, const char *pre_text, long options, void *print_data)
void free_xml(xmlNode *child)
#define PCMK_VALUE_QUORUM
enum pe_obj_types variant
#define pcmk__warn_once(wo_flag, fmt...)
gboolean group_active(pcmk_resource_t *rsc, gboolean all)
#define PCMK_XE_META_ATTRIBUTES
void populate_hash(xmlNode *nvpair_list, GHashTable *hash, const char **attrs, int attrs_length)
#define pcmk__assert(expr)
char * native_parameter(pcmk_resource_t *rsc, pcmk_node_t *node, gboolean create, const char *name, pcmk_scheduler_t *scheduler)
pcmk_resource_t * native_find_rsc(pcmk_resource_t *rsc, const char *id, const pcmk_node_t *node, int flags)
const pcmk_resource_t * pe__const_top_resource(const pcmk_resource_t *rsc, bool include_bundle)
gboolean pe__native_is_filtered(const pcmk_resource_t *rsc, GList *only_rsc, gboolean check_parent)
#define PCMK_META_MAINTENANCE
void clone_print(pcmk_resource_t *rsc, const char *pre_text, long options, void *print_data)
pcmk_rsc_methods_t resource_class_functions[]
gboolean pe__unpack_bundle(pcmk_resource_t *rsc, pcmk_scheduler_t *scheduler)
GHashTable * pcmk__strkey_table(GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func)
#define PCMK__ROLE_UNKNOWN
gboolean pe__bundle_active(pcmk_resource_t *rsc, gboolean all)
#define PCMK_ROLE_STARTED
pcmk_scheduler_t * scheduler
#define PCMK_VALUE_STOP_ONLY
#define PCMK__META_RESTART_TYPE
#define PCMK_META_FAILURE_TIMEOUT
pcmk_node_t *(* active_node)(const pcmk_resource_t *rsc, unsigned int *count_all, unsigned int *count_clean)
bool pe__resource_is_disabled(const pcmk_resource_t *rsc)
pcmk_node_t * allocated_to
#define PCMK_ROLE_UNPROMOTED
int pcmk_parse_score(const char *score_s, int *score, int default_score)
Parse an integer score from a string.
#define PCMK_META_CRITICAL
#define PCMK_META_PRIORITY
void clone_free(pcmk_resource_t *rsc)
#define crm_log_xml_trace(xml, text)
GHashTable * parameter_cache
enum rsc_role_e group_resource_state(const pcmk_resource_t *rsc, gboolean current)
#define PCMK_VALUE_UNFENCING
gboolean crm_is_true(const char *s)
#define PCMK__META_CONTAINER
void pe__set_next_role(pcmk_resource_t *rsc, enum rsc_role_e role, const char *why)
Resource role is unknown.
pcmk_node_t * pe__bundle_active_node(const pcmk_resource_t *rsc, unsigned int *count_all, unsigned int *count_clean)
#define PCMK_RESOURCE_CLASS_NAGIOS
pcmk_node_t * native_location(const pcmk_resource_t *rsc, GList **list, int current)
gboolean pe__group_is_filtered(const pcmk_resource_t *rsc, GList *only_rsc, gboolean check_parent)
#define PCMK_XE_INSTANCE_ATTRIBUTES
void get_rsc_attributes(GHashTable *meta_hash, const pcmk_resource_t *rsc, const pcmk_node_t *node, pcmk_scheduler_t *scheduler)
#define PCMK__XE_PROMOTABLE_LEGACY
#define pcmk__clear_rsc_flags(resource, flags_to_clear)
#define PCMK_XE_RESOURCES
void pcmk__insert_dup(GHashTable *table, const char *name, const char *value)
#define pcmk__set_scheduler_flags(scheduler, flags_to_set)
GHashTable * template_rsc_sets
void native_print(pcmk_resource_t *rsc, const char *pre_text, long options, void *print_data)
#define PCMK_META_ALLOW_MIGRATE
pcmk_node_t * partial_migration_source
GHashTable * pcmk__strikey_table(GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func)
#define PCMK_SCORE_INFINITY
Integer score to use to represent "infinity".
GHashTable * allowed_nodes