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 = (
const char *) xml_obj->name;
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,
scheduler)) {
85 crm_info(
"Constraint %s %s is not active", tag,
id);
101 pe_err(
"Unsupported constraint type: %s", tag);
112 for (GList *iter = rsc_list; iter != NULL; iter = iter->next) {
149 NULL, (gpointer *) tag)) {
151 crm_warn(
"No resource is derived from template '%s'",
id);
159 NULL, (gpointer *) tag)) {
161 crm_warn(
"No resource is tagged with '%s'",
id);
167 crm_warn(
"No template or tag named '%s'",
id);
195 if ((tag != NULL) && find_constraint_tag(
scheduler,
id, tag)) {
219 xmlNode *new_xml = NULL;
220 bool any_refs =
false;
232 GList *tag_refs = NULL;
244 "because '%s' is not a valid resource or tag",
245 ID(xml_obj),
ID(xml_rsc));
254 xmlNode *last_ref = xml_rsc;
275 for (iter = tag->
refs; iter != NULL; iter = iter->next) {
276 const char *obj_ref = iter->data;
277 xmlNode *new_rsc_ref = NULL;
279 new_rsc_ref = xmlNewDocRawNode(set->doc, NULL,
284 xmlAddNextSibling(last_ref, new_rsc_ref);
286 last_ref = new_rsc_ref;
294 tag_refs = g_list_append(tag_refs, xml_rsc);
308 for (iter = tag_refs; iter != NULL; iter = iter->next) {
309 xmlNode *tag_ref = iter->data;
313 g_list_free(tag_refs);
338 const char *cons_id = NULL;
339 const char *
id = NULL;
346 CRM_CHECK((xml_obj != NULL) && (attr != NULL),
return false);
348 cons_id =
ID(xml_obj);
349 if (cons_id == NULL) {
362 "valid resource or tag", cons_id,
id);
373 for (GList *iter = tag->
refs; iter != NULL; iter = iter->next) {
374 const char *obj_ref = iter->data;
375 xmlNode *rsc_ref = NULL;
384 }
else if ((rsc != NULL) && convert_rsc) {
389 xmlNode *rsc_ref = NULL;
402 if (*rsc_set != NULL) {
418 crm_trace(
"Create internal constraints");
pcmk_assignment_methods_t * cmds
Resource assignment methods.
crm_time_t * crm_time_new_undefined(void)
Allocate memory for an uninitialized time object.
GHashTable * tags
Configuration tags (ID -> pcmk_tag_t *)
#define CRM_CHECK(expr, failure_action)
bool pcmk__tag_to_set(xmlNode *xml_obj, xmlNode **rsc_set, const char *attr, bool convert_rsc, const pcmk_scheduler_t *scheduler)
G_GNUC_INTERNAL void pcmk__unpack_location(xmlNode *xml_obj, pcmk_scheduler_t *scheduler)
bool crm_time_is_defined(const crm_time_t *t)
Check whether a time object has been initialized yet.
pcmk_resource_t * uber_parent(pcmk_resource_t *rsc)
struct crm_time_s crm_time_t
#define pcmk__config_warn(fmt...)
#define XML_CIB_TAG_CONSTRAINTS
xmlNode * first_named_child(const xmlNode *parent, const char *name)
#define pcmk__config_err(fmt...)
void pcmk__unpack_constraints(pcmk_scheduler_t *scheduler)
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
G_GNUC_INTERNAL void pcmk__unpack_rsc_ticket(xmlNode *xml_obj, pcmk_scheduler_t *scheduler)
#define XML_CONS_TAG_RSC_TICKET
Implementation of pcmk_scheduler_t.
#define XML_CONS_TAG_RSC_SET
GList * resources
Resources in cluster.
Also match clone instance ID from resource history.
xmlNode * copy_xml(xmlNode *src_node)
#define crm_warn(fmt, args...)
bool pcmk__valid_resource_or_tag(const pcmk_scheduler_t *scheduler, const char *id, pcmk_resource_t **rsc, pcmk_tag_t **tag)
Implementation of pcmk_resource_t.
#define crm_debug(fmt, args...)
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
G_GNUC_INTERNAL void pcmk__unpack_ordering(xmlNode *xml_obj, pcmk_scheduler_t *scheduler)
#define crm_trace(fmt, args...)
Wrappers for and extensions to libxml2.
xmlNode * create_xml_node(xmlNode *parent, const char *name)
#define XML_TAG_RESOURCE_REF
void free_xml(xmlNode *child)
long long crm_time_get_seconds_since_epoch(const crm_time_t *dt)
void pe__update_recheck_time(time_t recheck, pcmk_scheduler_t *scheduler, const char *reason)
G_GNUC_INTERNAL void pcmk__unpack_colocation(xmlNode *xml_obj, pcmk_scheduler_t *scheduler)
const xmlChar * pcmkXmlStr
GList * refs
XML IDs of objects that reference the tag.
Cluster status and scheduling.
pcmk__action_result_t result
void(* internal_constraints)(pcmk_resource_t *rsc)
pcmk_scheduler_t * scheduler
xmlNode * pcmk__expand_tags_in_sets(xmlNode *xml_obj, const pcmk_scheduler_t *scheduler)
pcmk_resource_t * pcmk__find_constraint_resource(GList *rsc_list, const char *id)
void xml_remove_prop(xmlNode *obj, const char *name)
Configuration tag object.
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
void pcmk__create_internal_constraints(pcmk_scheduler_t *scheduler)
crm_time_t * now
Current time for evaluation purposes.
#define crm_info(fmt, args...)
GHashTable * template_rsc_sets
Mappings of template ID to resource ID.
char * id
Resource ID in configuration.
xmlNode * crm_next_same_xml(const xmlNode *sibling)
Get next instance of same XML tag.
void crm_time_free(crm_time_t *dt)