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 | |
parent | a2abdc13531bdd874df3c6d410370d52e24307fd (diff) | |
download | samba-dab2f6817ddcb2e18f6f1b406b8485649b1857d8.tar.gz samba-dab2f6817ddcb2e18f6f1b406b8485649b1857d8.tar.xz samba-dab2f6817ddcb2e18f6f1b406b8485649b1857d8.zip |
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)
-rw-r--r-- | ctdb/client/ctdb_client.c | 38 | ||||
-rw-r--r-- | ctdb/include/ctdb_client.h | 5 |
2 files changed, 43 insertions, 0 deletions
diff --git a/ctdb/client/ctdb_client.c b/ctdb/client/ctdb_client.c index d7c30316ec..74bfb59a77 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, diff --git a/ctdb/include/ctdb_client.h b/ctdb/include/ctdb_client.h index 9f0589f1e7..1b90ffb038 100644 --- a/ctdb/include/ctdb_client.h +++ b/ctdb/include/ctdb_client.h @@ -507,6 +507,11 @@ int ctdb_ctrl_setreclock(struct ctdb_context *ctdb, const char *reclock); +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); uint32_t *list_of_connected_nodes(struct ctdb_context *ctdb, struct ctdb_node_map *node_map, TALLOC_CTX *mem_ctx, |