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

Function native_rsc_location

pengine/native.c:1677–1735  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1675}
1676
1677void
1678native_rsc_location(resource_t * rsc, rsc_to_node_t * constraint)
1679{
1680 GListPtr gIter = NULL;
1681 GHashTableIter iter;
1682 node_t *node = NULL;
1683
1684 if (constraint == NULL) {
1685 pe_err("Constraint is NULL");
1686 return;
1687
1688 } else if (rsc == NULL) {
1689 pe_err("LHS of rsc_to_node (%s) is NULL", constraint->id);
1690 return;
1691 }
1692
1693 pe_rsc_trace(rsc, "Applying %s (%s) to %s", constraint->id,
1694 role2text(constraint->role_filter), rsc->id);
1695
1696 /* take "lifetime" into account */
1697 if (constraint->role_filter > 0 && constraint->role_filter != rsc->next_role) {
1698 pe_rsc_debug(rsc, "Constraint (%s) is not active (role : %s)",
1699 constraint->id, role2text(constraint->role_filter));
1700 return;
1701
1702 } else if (is_active(constraint) == FALSE) {
1703 pe_rsc_trace(rsc, "Constraint (%s) is not active", constraint->id);
1704 return;
1705 }
1706
1707 if (constraint->node_list_rh == NULL) {
1708 pe_rsc_trace(rsc, "RHS of constraint %s is NULL", constraint->id);
1709 return;
1710 }
1711
1712 for (gIter = constraint->node_list_rh; gIter != NULL; gIter = gIter->next) {
1713 node_t *node = (node_t *) gIter->data;
1714 node_t *other_node = NULL;
1715
1716 other_node = (node_t *) pe_hash_table_lookup(rsc->allowed_nodes, node->details->id);
1717
1718 if (other_node != NULL) {
1719 pe_rsc_trace(rsc, "%s + %s: %d + %d",
1720 node->details->uname,
1721 other_node->details->uname, node->weight, other_node->weight);
1722 other_node->weight = merge_weights(other_node->weight, node->weight);
1723
1724 } else {
1725 node_t *new_node = node_copy(node);
1726
1727 g_hash_table_insert(rsc->allowed_nodes, (gpointer) new_node->details->id, new_node);
1728 }
1729 }
1730
1731 g_hash_table_iter_init(&iter, rsc->allowed_nodes);
1732 while (g_hash_table_iter_next(&iter, NULL, (void **)&node)) {
1733 pe_rsc_trace(rsc, "%s + %s : %d", rsc->id, node->details->uname, node->weight);
1734 }

Callers 2

clone_rsc_locationFunction · 0.85
group_rsc_locationFunction · 0.85

Calls 7

role2textFunction · 0.85
is_activeFunction · 0.85
pe_hash_table_lookupFunction · 0.85
merge_weightsFunction · 0.85
node_copyFunction · 0.85
g_hash_table_iter_initFunction · 0.85
g_hash_table_iter_nextFunction · 0.85

Tested by

no test coverage detected