| 420 | } |
| 421 | |
| 422 | static int |
| 423 | master_score(resource_t * rsc, node_t * node, int not_set_value) |
| 424 | { |
| 425 | char *attr_name; |
| 426 | char *name = rsc->id; |
| 427 | const char *attr_value = NULL; |
| 428 | int score = not_set_value, len = 0; |
| 429 | |
| 430 | if (rsc->children) { |
| 431 | GListPtr gIter = rsc->children; |
| 432 | |
| 433 | for (; gIter != NULL; gIter = gIter->next) { |
| 434 | resource_t *child = (resource_t *) gIter->data; |
| 435 | int c_score = master_score(child, node, not_set_value); |
| 436 | |
| 437 | if (score == not_set_value) { |
| 438 | score = c_score; |
| 439 | } else { |
| 440 | score += c_score; |
| 441 | } |
| 442 | } |
| 443 | return score; |
| 444 | } |
| 445 | |
| 446 | if (node == NULL) { |
| 447 | if(rsc->fns->state(rsc, TRUE) < RSC_ROLE_STARTED) { |
| 448 | pe_rsc_trace(rsc, "Ingoring master score for %s: unknown state", rsc->id); |
| 449 | return score; |
| 450 | } |
| 451 | |
| 452 | } else { |
| 453 | node_t *match = pe_find_node_id(rsc->running_on, node->details->id); |
| 454 | node_t *known = pe_hash_table_lookup(rsc->known_on, node->details->id); |
| 455 | |
| 456 | if(is_not_set(rsc->flags, pe_rsc_unique) && anonymous_known_on(rsc, node)) { |
| 457 | pe_rsc_trace(rsc, "Anonymous clone %s is known on %s", rsc->id, node->details->uname); |
| 458 | |
| 459 | } else if (match == NULL && known == NULL) { |
| 460 | pe_rsc_trace(rsc, "%s (aka. %s) is not known on %s - ignoring", rsc->id, rsc->clone_name, node->details->uname); |
| 461 | return score; |
| 462 | } |
| 463 | |
| 464 | match = pe_hash_table_lookup(rsc->allowed_nodes, node->details->id); |
| 465 | if (match == NULL) { |
| 466 | return score; |
| 467 | |
| 468 | } else if (match->weight < 0) { |
| 469 | pe_rsc_trace(rsc, "%s on %s has score: %d - ignoring", |
| 470 | rsc->id, match->details->uname, match->weight); |
| 471 | return score; |
| 472 | } |
| 473 | } |
| 474 | |
| 475 | if (rsc->clone_name) { |
| 476 | /* Use the name the lrm knows this resource as, |
| 477 | * since that's what crm_master would have used too |
| 478 | */ |
| 479 | name = rsc->clone_name; |
no test coverage detected