diff options
author | Martin Schwenke <martin@meltin.net> | 2013-02-19 14:29:06 +1100 |
---|---|---|
committer | Amitay Isaacs <amitay@gmail.com> | 2013-02-20 14:44:38 +1100 |
commit | dab2f6817ddcb2e18f6f1b406b8485649b1857d8 (patch) | |
tree | 6bddb0390b2d3b95f43e86fa630ac40d54e6ab6d /ctdb/client | |
parent | a2abdc13531bdd874df3c6d410370d52e24307fd (diff) | |
download | samba-dab2f6817ddcb2e18f6f1b406b8485649b1857d8.tar.gz |
client: New generic node listing function list_of_nodes()
Signed-off-by: Martin Schwenke <martin@meltin.net>
Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>
(This used to be ctdb commit a73bb56991b8c07ed0e9517ffcf0dc264be30487)
Diffstat (limited to 'ctdb/client')
-rw-r--r-- | ctdb/client/ctdb_client.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/ctdb/client/ctdb_client.c b/ctdb/client/ctdb_client.c index d7c30316ec2..74bfb59a77c 100644 --- a/ctdb/client/ctdb_client.c +++ b/ctdb/client/ctdb_client.c @@ -3451,6 +3451,44 @@ uint32_t *list_of_vnnmap_nodes(struct ctdb_context *ctdb, return nodes; } +/* Get list of nodes not including those with flags specified by mask. + * If exclude_pnn is not -1 then exclude that pnn from the list. + */ +uint32_t *list_of_nodes(struct ctdb_context *ctdb, + struct ctdb_node_map *node_map, + TALLOC_CTX *mem_ctx, + uint32_t mask, + int exclude_pnn) +{ + int i, j, num_nodes; + uint32_t *nodes; + + for (i=num_nodes=0;i<node_map->num;i++) { + if (node_map->nodes[i].flags & mask) { + continue; + } + if (node_map->nodes[i].pnn == exclude_pnn) { + continue; + } + num_nodes++; + } + + nodes = talloc_array(mem_ctx, uint32_t, num_nodes); + CTDB_NO_MEMORY_FATAL(ctdb, nodes); + + for (i=j=0;i<node_map->num;i++) { + if (node_map->nodes[i].flags & mask) { + continue; + } + if (node_map->nodes[i].pnn == exclude_pnn) { + continue; + } + nodes[j++] = node_map->nodes[i].pnn; + } + + return nodes; +} + uint32_t *list_of_active_nodes(struct ctdb_context *ctdb, struct ctdb_node_map *node_map, TALLOC_CTX *mem_ctx, |