25 #include <sys/types.h> 66 populate_hash(xmlNode *nvpair_list, GHashTable *hash,
bool overwrite)
69 nvpair_list = nvpair_list->children;
77 const char *
name = NULL;
78 const char *value = NULL;
79 const char *old_value = NULL;
81 if (ref_nvpair == NULL) {
90 if ((
name == NULL) || (value == NULL)) {
94 old_value = g_hash_table_lookup(hash,
name);
99 "%s) to the explicit value '#default' is " 100 "deprecated and will be removed in a future " 102 if (old_value != NULL) {
103 crm_trace(
"Letting %s default (removing explicit value \"%s\")",
105 g_hash_table_remove(hash,
name);
108 }
else if (old_value == NULL) {
112 }
else if (overwrite) {
113 crm_trace(
"Setting %s=\"%s\" (overwriting old value \"%s\")",
114 name, value, old_value);
121 unpack_attr_set(gpointer
data, gpointer user_data)
123 xmlNode *pair =
data;
128 if ((rule_xml != NULL)
134 crm_trace(
"Adding name/value pairs from %s %s overwrite",
135 pcmk__xe_id(pair), (unpack_data->
overwrite?
"with" :
"without"));
149 make_pairs(
const xmlNode *xml_obj,
const char *set_name)
151 GList *unsorted = NULL;
153 if (xml_obj == NULL) {
157 attr_set != NULL; attr_set =
pcmk__xe_next(attr_set, NULL)) {
159 if ((set_name == NULL) || pcmk__xe_is(attr_set, set_name)) {
162 if (expanded_attr_set == NULL) {
165 unsorted = g_list_prepend(unsorted, expanded_attr_set);
187 const char *always_first, gboolean overwrite,
190 GList *pairs = make_pairs(xml_obj, set_name);
195 .first_id = always_first,
196 .overwrite = overwrite,
197 .next_change = next_change,
200 map_rule_input(&(
data.rule_input), rule_data);
203 g_list_foreach(pairs, unpack_attr_set, &
data);
224 GHashTable *node_hash, GHashTable *hash,
225 const char *always_first, gboolean overwrite,
237 always_first, overwrite, next_change);
void pe_unpack_nvpairs(xmlNode *top, const xmlNode *xml_obj, const char *set_name, GHashTable *node_hash, GHashTable *hash, const char *always_first, gboolean overwrite, crm_time_t *now, crm_time_t *next_change)
Extract nvpair blocks contained by an XML element into a hash table.
xmlNode * pcmk__xe_resolve_idref(xmlNode *xml, xmlNode *search)
xmlNode * pcmk__xe_first_child(const xmlNode *parent, const char *node_name, const char *attr_n, const char *attr_v)
int pcmk_evaluate_rule(xmlNode *rule, const pcmk_rule_input_t *rule_input, crm_time_t *next_change)
Evaluate a single rule, including all its conditions.
Deprecated Pacemaker rule API.
struct crm_time_s crm_time_t
#define pcmk__config_warn(fmt...)
#define PCMK__XE_ATTRIBUTES
CRM_TRACE_INIT_DATA(pe_rules)
gint pcmk__cmp_nvpair_blocks(gconstpointer a, gconstpointer b, gpointer user_data)
pe_match_data_t * match_data
pe_op_eval_data_t * op_data
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
#define crm_trace(fmt, args...)
gboolean test_rule(xmlNode *rule, GHashTable *node_hash, enum rsc_role_e role, crm_time_t *now)
Wrappers for and extensions to libxml2.
pe_rsc_eval_data_t * rsc_data
void populate_hash(xmlNode *nvpair_list, GHashTable *hash, const char **attrs, int attrs_length)
xmlNode * pcmk__xe_next(const xmlNode *node, const char *element_name)
pcmk_rule_input_t rule_input
void pe_eval_nvpairs(xmlNode *top, const xmlNode *xml_obj, const char *set_name, const pe_rule_eval_data_t *rule_data, GHashTable *hash, const char *always_first, gboolean overwrite, crm_time_t *next_change)
Extract nvpair blocks contained by an XML element into a hash table.
void pcmk__insert_dup(GHashTable *table, const char *name, const char *value)