12 #include <sys/param.h> 13 #include <sys/types.h> 61 for (xmlNode *xml_obj = pcmk__xe_first_child(xml_constraints);
62 xml_obj != NULL; xml_obj = pcmk__xe_next(xml_obj)) {
64 xmlNode *lifetime = NULL;
66 const char *tag = crm_element_name(xml_obj);
74 crm_trace(
"Unpacking %s constraint '%s'", tag,
id);
77 if (lifetime != NULL) {
79 "deprecated (the rules it contains should " 80 "instead be direct descendents of the " 81 "constraint object)",
id);
84 if ((lifetime != NULL) && !evaluate_lifetime(lifetime,
data_set)) {
85 crm_info(
"Constraint %s %s is not active", tag,
id);
100 pe_err(
"Unsupported constraint type: %s", tag);
110 for (rIter = rsc_list;
id && rIter; rIter = rIter->next) {
146 NULL, (gpointer *) tag)) {
148 crm_warn(
"No resource is derived from template '%s'",
id);
156 NULL, (gpointer *) tag)) {
158 crm_warn(
"No resource is tagged with '%s'",
id);
164 crm_warn(
"No template or tag named '%s'",
id);
192 if ((tag != NULL) && find_constraint_tag(
data_set,
id, tag)) {
216 xmlNode *new_xml = NULL;
217 bool any_refs =
false;
229 GList *tag_refs = NULL;
241 "because '%s' is not a valid resource or tag",
242 ID(xml_obj),
ID(xml_rsc));
251 xmlNode *last_ref = xml_rsc;
275 for (gIter = tag->
refs; gIter != NULL; gIter = gIter->next) {
276 const char *obj_ref = (
const char *) gIter->data;
277 xmlNode *new_rsc_ref = NULL;
279 new_rsc_ref = xmlNewDocRawNode(
getDocPtr(
set), NULL,
282 xmlAddNextSibling(last_ref, new_rsc_ref);
284 last_ref = new_rsc_ref;
292 tag_refs = g_list_append(tag_refs, xml_rsc);
306 for (gIter = tag_refs; gIter != NULL; gIter = gIter->next) {
307 xmlNode *tag_ref = gIter->data;
311 g_list_free(tag_refs);
335 const char *cons_id = NULL;
336 const char *
id = NULL;
343 CRM_CHECK((xml_obj != NULL) && (attr != NULL),
return false);
345 cons_id =
ID(xml_obj);
346 if (cons_id == NULL) {
348 crm_element_name(xml_obj));
359 "valid resource or tag", cons_id,
id);
371 for (gIter = tag->
refs; gIter != NULL; gIter = gIter->next) {
372 const char *obj_ref = (
const char *) gIter->data;
373 xmlNode *rsc_ref = NULL;
382 }
else if ((rsc != NULL) && convert_rsc) {
385 xmlNode *rsc_ref = NULL;
398 if (*rsc_set != NULL) {
414 crm_trace(
"Create internal constraints");
crm_time_t * crm_time_new_undefined(void)
Allocate memory for an uninitialized time object.
#define CRM_CHECK(expr, failure_action)
bool crm_time_is_defined(const crm_time_t *t)
Check whether a time object has been initialized yet.
struct crm_time_s crm_time_t
void pe__update_recheck_time(time_t recheck, pe_working_set_t *data_set)
#define pcmk__config_warn(fmt...)
#define XML_CIB_TAG_CONSTRAINTS
resource_alloc_functions_t * cmds
xmlNode * first_named_child(const xmlNode *parent, const char *name)
#define pcmk__config_err(fmt...)
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
void pcmk__xe_set_bool_attr(xmlNodePtr node, const char *name, bool value)
#define XML_CONS_TAG_RSC_DEPEND
void(* internal_constraints)(pe_resource_t *, pe_working_set_t *)
#define XML_CONS_TAG_RSC_TICKET
#define XML_CONS_TAG_RSC_SET
void pcmk__create_internal_constraints(pe_working_set_t *data_set)
xmlDoc * getDocPtr(xmlNode *node)
xmlNode * copy_xml(xmlNode *src_node)
#define crm_warn(fmt, args...)
#define crm_debug(fmt, args...)
pe_resource_t * uber_parent(pe_resource_t *rsc)
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
xmlNode * pcmk_find_cib_element(xmlNode *cib, const char *element_name)
Find an element in the CIB.
#define XML_CONS_TAG_RSC_LOCATION
#define crm_trace(fmt, args...)
pe_working_set_t * data_set
Wrappers for and extensions to libxml2.
xmlNode * create_xml_node(xmlNode *parent, const char *name)
long long int crm_time_get_seconds_since_epoch(crm_time_t *dt)
#define XML_TAG_RESOURCE_REF
void pcmk__unpack_constraints(pe_working_set_t *data_set)
void free_xml(xmlNode *child)
bool pcmk__tag_to_set(xmlNode *xml_obj, xmlNode **rsc_set, const char *attr, bool convert_rsc, pe_working_set_t *data_set)
const xmlChar * pcmkXmlStr
xmlNode * pcmk__expand_tags_in_sets(xmlNode *xml_obj, pe_working_set_t *data_set)
match resource ID or LRM history ID
Cluster status and scheduling.
pcmk__action_result_t result
pe_resource_t * pcmk__find_constraint_resource(GList *rsc_list, const char *id)
G_GNUC_INTERNAL void pcmk__unpack_ordering(xmlNode *xml_obj, pe_working_set_t *data_set)
void xml_remove_prop(xmlNode *obj, const char *name)
gboolean pe_evaluate_rules(xmlNode *ruleset, GHashTable *node_hash, crm_time_t *now, crm_time_t *next_change)
Evaluate any rules contained by given XML element.
bool pcmk__valid_resource_or_tag(pe_working_set_t *data_set, const char *id, pe_resource_t **rsc, pe_tag_t **tag)
#define XML_CONS_TAG_RSC_ORDER
G_GNUC_INTERNAL void pcmk__unpack_colocation(xmlNode *xml_obj, pe_working_set_t *data_set)
G_GNUC_INTERNAL void pcmk__unpack_location(xmlNode *xml_obj, pe_working_set_t *data_set)
G_GNUC_INTERNAL void pcmk__unpack_rsc_ticket(xmlNode *xml_obj, pe_working_set_t *data_set)
#define crm_info(fmt, args...)
GHashTable * template_rsc_sets
xmlNode * crm_next_same_xml(const xmlNode *sibling)
Get next instance of same XML tag.
void crm_time_free(crm_time_t *dt)