46 ticket_role_matches(
const pe_resource_t *rsc,
const rsc_ticket_t *rsc_ticket)
49 || (rsc_ticket->role == rsc->
role)) {
52 pe_rsc_trace(rsc,
"Skipping constraint: \"%s\" state filter",
65 constraints_for_ticket(
pe_resource_t *rsc,
const rsc_ticket_t *rsc_ticket,
70 CRM_CHECK((rsc != NULL) && (rsc_ticket != NULL),
return);
72 if (rsc_ticket->ticket->granted && !rsc_ticket->ticket->standby) {
77 pe_rsc_trace(rsc,
"Processing ticket dependencies from %s", rsc->
id);
78 for (gIter = rsc->
children; gIter != NULL; gIter = gIter->next) {
79 constraints_for_ticket((
pe_resource_t *) gIter->data, rsc_ticket,
85 pe_rsc_trace(rsc,
"%s: Processing ticket dependency on %s (%s, %s)",
86 rsc->
id, rsc_ticket->ticket->id, rsc_ticket->id,
89 if (!rsc_ticket->ticket->granted && (rsc->
running_on != NULL)) {
91 switch (rsc_ticket->loss_policy) {
106 if (!ticket_role_matches(rsc, rsc_ticket)) {
114 gIter = gIter->next) {
116 "deadman ticket was lost", FALSE);
121 if (!ticket_role_matches(rsc, rsc_ticket)) {
131 }
else if (!rsc_ticket->ticket->granted) {
139 }
else if (rsc_ticket->ticket->standby) {
151 const char *state,
const char *loss_policy,
154 rsc_ticket_t *new_rsc_ticket = NULL;
158 "does not exist",
id);
162 new_rsc_ticket = calloc(1,
sizeof(rsc_ticket_t));
163 if (new_rsc_ticket == NULL) {
172 new_rsc_ticket->id =
id;
173 new_rsc_ticket->ticket = ticket;
174 new_rsc_ticket->rsc = rsc;
182 "' for ticket '%s' to 'stop' " 183 "because fencing is not configured", ticket->
id);
184 loss_policy =
"stop";
189 crm_debug(
"On loss of ticket '%s': Fence the nodes running %s (%s)",
190 new_rsc_ticket->ticket->id, new_rsc_ticket->rsc->id,
194 crm_debug(
"On loss of ticket '%s': Freeze %s (%s)",
195 new_rsc_ticket->ticket->id, new_rsc_ticket->rsc->id,
200 crm_debug(
"On loss of ticket '%s': Demote %s (%s)",
201 new_rsc_ticket->ticket->id, new_rsc_ticket->rsc->id,
206 crm_debug(
"On loss of ticket '%s': Stop %s (%s)",
207 new_rsc_ticket->ticket->id, new_rsc_ticket->rsc->id,
213 crm_debug(
"On loss of ticket '%s': Default to demote %s (%s)",
214 new_rsc_ticket->ticket->id, new_rsc_ticket->rsc->id,
219 crm_debug(
"On loss of ticket '%s': Default to stop %s (%s)",
220 new_rsc_ticket->ticket->id, new_rsc_ticket->rsc->id,
234 if (!(new_rsc_ticket->ticket->granted) || new_rsc_ticket->ticket->standby) {
235 constraints_for_ticket(rsc, new_rsc_ticket,
data_set);
241 unpack_rsc_ticket_set(xmlNode *
set,
pe_ticket_t *ticket,
244 const char *set_id = NULL;
245 const char *role = NULL;
248 CRM_CHECK(ticket != NULL,
return EINVAL);
251 if (set_id == NULL) {
266 if (resource == NULL) {
268 set_id,
ID(xml_rsc));
271 pe_rsc_trace(resource,
"Resource '%s' depends on ticket '%s'",
272 resource->
id, ticket->
id);
273 rsc_ticket_new(set_id, resource, ticket, role, loss_policy,
data_set);
282 const char *
id = NULL;
299 if (instance != NULL) {
302 "deprecated and will be removed in a future release.");
310 crm_element_name(xml_obj));
314 if (ticket_str == NULL) {
322 if (ticket == NULL) {
324 "does not exist",
id, ticket_str);
328 if (rsc_id == NULL) {
337 "does not exist",
id, rsc_id);
340 }
else if ((instance != NULL) && !pe_rsc_is_clone(rsc)) {
342 "is not a clone but instance '%s' was requested",
343 id, rsc_id, instance);
347 if (instance != NULL) {
351 "does not have an instance '%s'",
352 "'%s'",
id, rsc_id, instance);
357 rsc_ticket_new(
id, rsc, ticket, state, loss_policy,
data_set);
362 unpack_rsc_ticket_tags(xmlNode *xml_obj, xmlNode **expanded_xml,
365 const char *
id = NULL;
366 const char *rsc_id = NULL;
367 const char *state = NULL;
372 xmlNode *rsc_set = NULL;
374 *expanded_xml = NULL;
376 CRM_CHECK(xml_obj != NULL,
return EINVAL);
381 crm_element_name(xml_obj));
387 if (*expanded_xml != NULL) {
393 if (rsc_id == NULL) {
399 "valid resource or tag",
id, rsc_id);
402 }
else if (rsc != NULL) {
415 *expanded_xml = NULL;
419 if (rsc_set != NULL) {
428 *expanded_xml = NULL;
438 bool any_sets =
false;
440 const char *
id = NULL;
446 xmlNode *orig_xml = NULL;
447 xmlNode *expanded_xml = NULL;
454 crm_element_name(xml_obj));
462 if (ticket_str == NULL) {
469 if (ticket == NULL) {
471 if (ticket == NULL) {
476 if (unpack_rsc_ticket_tags(xml_obj, &expanded_xml,
480 if (expanded_xml != NULL) {
482 xml_obj = expanded_xml;
491 || (unpack_rsc_ticket_set(
set, ticket, loss_policy,
493 if (expanded_xml != NULL) {
506 unpack_simple_rsc_ticket(xml_obj,
data_set);
522 for (GList *item = rsc->
rsc_tickets; item != NULL; item = item->next) {
523 rsc_ticket_t *rsc_ticket = (rsc_ticket_t *) item->data;
526 && (!rsc_ticket->ticket->granted || rsc_ticket->ticket->standby)) {
528 "__stateful_without_ticket__", rsc->
cluster);
#define CRM_CHECK(expr, failure_action)
#define pcmk__config_warn(fmt...)
#define RSC_ROLE_STARTED_S
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.
G_GNUC_INTERNAL xmlNode * pcmk__expand_tags_in_sets(xmlNode *xml_obj, const pe_working_set_t *data_set)
void resource_location(pe_resource_t *rsc, const pe_node_t *node, int score, const char *tag, pe_working_set_t *data_set)
#define XML_CONS_TAG_RSC_SET
G_GNUC_INTERNAL 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 pe__set_resource_flags(resource, flags_to_set)
xmlNode * copy_xml(xmlNode *src_node)
const char * role2text(enum rsc_role_e role)
G_GNUC_INTERNAL bool pcmk__valid_resource_or_tag(const pe_working_set_t *data_set, const char *id, pe_resource_t **rsc, pe_tag_t **tag)
GList * ticket_constraints
#define crm_debug(fmt, args...)
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
void pcmk__unpack_rsc_ticket(xmlNode *xml_obj, pe_working_set_t *data_set)
#define pe_warn_once(pe_wo_bit, fmt...)
pe_ticket_t * ticket_new(const char *ticket_id, pe_working_set_t *data_set)
void pe_fence_node(pe_working_set_t *data_set, pe_node_t *node, const char *reason, bool priority_delay)
Schedule a fence action for a node.
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
xmlNode * expand_idref(xmlNode *input, xmlNode *top)
pe_working_set_t * data_set
#define pe_flag_stonith_enabled
#define XML_COLOC_ATTR_SOURCE_INSTANCE
#define XML_TAG_RESOURCE_REF
pe_resource_t * find_clone_instance(const pe_resource_t *rsc, const char *sub_id)
void free_xml(xmlNode *child)
enum rsc_role_e text2role(const char *role)
G_GNUC_INTERNAL pe_resource_t * pcmk__find_constraint_resource(GList *rsc_list, const char *id)
#define XML_COLOC_ATTR_SOURCE_ROLE
void pcmk__require_promotion_tickets(pe_resource_t *rsc)
Cluster status and scheduling.
GHashTable * pcmk__strkey_table(GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func)
void xml_remove_prop(xmlNode *obj, const char *name)
#define pe__clear_resource_flags(resource, flags_to_clear)
pe_working_set_t * cluster
void destroy_ticket(gpointer data)
#define RSC_ROLE_UNKNOWN_S
#define crm_log_xml_trace(xml, text)
#define XML_TICKET_ATTR_TICKET
#define pe_rsc_trace(rsc, fmt, args...)
#define XML_COLOC_ATTR_SOURCE
xmlNode * crm_next_same_xml(const xmlNode *sibling)
Get next instance of same XML tag.
#define XML_TICKET_ATTR_LOSS_POLICY