MCPcopy Create free account
hub / github.com/ClusterLabs/pacemaker / generate_location_rule

Function generate_location_rule

pengine/constraints.c:469–592  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

467}
468
469rsc_to_node_t *
470generate_location_rule(resource_t * rsc, xmlNode * rule_xml, pe_working_set_t * data_set)
471{
472 const char *rule_id = NULL;
473 const char *score = NULL;
474 const char *boolean = NULL;
475 const char *role = NULL;
476
477 GListPtr gIter = NULL;
478 GListPtr match_L = NULL;
479
480 int score_f = 0;
481 gboolean do_and = TRUE;
482 gboolean accept = TRUE;
483 gboolean raw_score = TRUE;
484
485 rsc_to_node_t *location_rule = NULL;
486
487 rule_xml = expand_idref(rule_xml, data_set->input);
488 rule_id = crm_element_value(rule_xml, XML_ATTR_ID);
489 boolean = crm_element_value(rule_xml, XML_RULE_ATTR_BOOLEAN_OP);
490 role = crm_element_value(rule_xml, XML_RULE_ATTR_ROLE);
491
492 crm_trace("Processing rule: %s", rule_id);
493
494 if (role != NULL && text2role(role) == RSC_ROLE_UNKNOWN) {
495 pe_err("Bad role specified for %s: %s", rule_id, role);
496 return NULL;
497 }
498
499 score = crm_element_value(rule_xml, XML_RULE_ATTR_SCORE);
500 if (score != NULL) {
501 score_f = char2score(score);
502
503 } else {
504 score = crm_element_value(rule_xml, XML_RULE_ATTR_SCORE_ATTRIBUTE);
505 if (score == NULL) {
506 score = crm_element_value(rule_xml, XML_RULE_ATTR_SCORE_MANGLED);
507 }
508 if (score != NULL) {
509 raw_score = FALSE;
510 }
511 }
512 if (safe_str_eq(boolean, "or")) {
513 do_and = FALSE;
514 }
515
516 location_rule = rsc2node_new(rule_id, rsc, 0, NULL, data_set);
517
518 if (location_rule == NULL) {
519 return NULL;
520 }
521 if (role != NULL) {
522 crm_trace("Setting role filter: %s", role);
523 location_rule->role_filter = text2role(role);
524 if (location_rule->role_filter == RSC_ROLE_SLAVE) {
525 /* Fold slave back into Started for simplicity
526 * At the point Slave location constraints are evaluated,

Callers 1

unpack_rsc_locationFunction · 0.85

Calls 11

expand_idrefFunction · 0.85
crm_element_valueFunction · 0.85
text2roleFunction · 0.85
char2scoreFunction · 0.85
rsc2node_newFunction · 0.85
node_list_dupFunction · 0.85
get_node_scoreFunction · 0.85
test_ruleFunction · 0.85
pe_find_node_idFunction · 0.85
node_copyFunction · 0.85
merge_weightsFunction · 0.85

Tested by

no test coverage detected