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 descendants 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) {
147 NULL, (gpointer *) tag)) {
149 crm_warn(
"No resource is derived from template '%s'",
id);
157 NULL, (gpointer *) tag)) {
159 crm_warn(
"No resource is tagged with '%s'",
id);
165 crm_warn(
"No template or tag named '%s'",
id);
193 if ((tag != NULL) && find_constraint_tag(
data_set,
id, tag)) {
217 xmlNode *new_xml = NULL;
218 bool any_refs =
false;
230 GList *tag_refs = NULL;
242 "because '%s' is not a valid resource or tag",
243 ID(xml_obj),
ID(xml_rsc));
252 xmlNode *last_ref = xml_rsc;
276 for (gIter = tag->
refs; gIter != NULL; gIter = gIter->next) {
277 const char *obj_ref = (
const char *) gIter->data;
278 xmlNode *new_rsc_ref = NULL;
280 new_rsc_ref = xmlNewDocRawNode(
getDocPtr(
set), NULL,
283 xmlAddNextSibling(last_ref, new_rsc_ref);
285 last_ref = new_rsc_ref;
293 tag_refs = g_list_append(tag_refs, xml_rsc);
307 for (gIter = tag_refs; gIter != NULL; gIter = gIter->next) {
308 xmlNode *tag_ref = gIter->data;
312 g_list_free(tag_refs);
336 const char *cons_id = NULL;
337 const char *
id = NULL;
344 CRM_CHECK((xml_obj != NULL) && (attr != NULL),
return false);
346 cons_id =
ID(xml_obj);
347 if (cons_id == NULL) {
349 crm_element_name(xml_obj));
360 "valid resource or tag", cons_id,
id);
372 for (gIter = tag->
refs; gIter != NULL; gIter = gIter->next) {
373 const char *obj_ref = (
const char *) gIter->data;
374 xmlNode *rsc_ref = NULL;
383 }
else if ((rsc != NULL) && convert_rsc) {
386 xmlNode *rsc_ref = NULL;
399 if (*rsc_set != NULL) {
415 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.
void(* internal_constraints)(pe_resource_t *rsc)
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
#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.
bool pcmk__valid_resource_or_tag(const pe_working_set_t *data_set, const char *id, pe_resource_t **rsc, pe_tag_t **tag)
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)
#define XML_TAG_RESOURCE_REF
void pcmk__unpack_constraints(pe_working_set_t *data_set)
void free_xml(xmlNode *child)
long long crm_time_get_seconds_since_epoch(const crm_time_t *dt)
const xmlChar * pcmkXmlStr
match resource ID or LRM history ID
xmlNode * pcmk__expand_tags_in_sets(xmlNode *xml_obj, const pe_working_set_t *data_set)
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.
#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)
bool pcmk__tag_to_set(xmlNode *xml_obj, xmlNode **rsc_set, const char *attr, bool convert_rsc, const 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)