예제 #1
0
int
ipa_topo_connection_exists(struct node_fanout *fanout, char* from, char *to)
{
    struct node_list *reachable = NULL;
    struct node_fanout *cursor = fanout;
    int connected = 0;
    /* init reachable nodes */
    while (cursor) {
        if (strcasecmp(cursor->node, from) == 0) {
            cursor->visited = 1;
            reachable = node_list_dup(cursor->targets);
        } else {
            cursor->visited = 0;
        }
        cursor = cursor->next;
    }
    /* check if target is in reachable nodes, if
     * not, expand reachables
     */
    if (reachable == NULL) return 0;
    while (reachable) {
        if (strcasecmp(reachable->node, to) == 0) {
            connected = 1;
            break;
        }
        ipa_topo_connection_append(fanout, reachable);
        reachable = reachable->next;
    }
    node_list_free(reachable);
    return connected;
}
예제 #2
0
파일: group.c 프로젝트: fghaas/pacemaker
void
group_rsc_location(resource_t * rsc, rsc_to_node_t * constraint)
{
    GListPtr gIter = rsc->children;
    GListPtr saved = constraint->node_list_rh;
    GListPtr zero = node_list_dup(constraint->node_list_rh, TRUE, FALSE);
    gboolean reset_scores = TRUE;
    group_variant_data_t *group_data = NULL;

    get_group_variant_data(group_data, rsc);

    crm_debug("Processing rsc_location %s for %s", constraint->id, rsc->id);

    native_rsc_location(rsc, constraint);

    for (; gIter != NULL; gIter = gIter->next) {
        resource_t *child_rsc = (resource_t *) gIter->data;

        child_rsc->cmds->rsc_location(child_rsc, constraint);
        if (group_data->colocated && reset_scores) {
            reset_scores = FALSE;
            constraint->node_list_rh = zero;
        }
    }

    constraint->node_list_rh = saved;
    slist_basic_destroy(zero);
}
예제 #3
0
void
ipa_topo_connection_append(struct node_fanout *fanout, struct node_list *reachable)
{
    struct node_fanout *cursor = fanout;

    while (cursor) {
        if (strcasecmp(reachable->node, cursor->node) == 0 &&
           cursor->visited == 0) {
            struct node_list *tail;
            struct node_list *extend;
            cursor->visited = 1;
            extend = node_list_dup(cursor->targets);
            tail = reachable;
            while (tail->next) {
                tail = tail->next;
            }
            tail->next = extend;
            break;
        }
        cursor = cursor->next;
    }
}