From: Andrew Tridgell Date: Fri, 14 Sep 2007 05:23:23 +0000 (+1000) Subject: merge from ronnie X-Git-Tag: tevent-0.9.20~348^2~2403 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ed75f988d5e811531bc15becc04acecf917dfd6a;p=thirdparty%2Fsamba.git merge from ronnie (This used to be ctdb commit 913c33a7d2f67570548fecc568dba874e5f72dd2) --- ed75f988d5e811531bc15becc04acecf917dfd6a diff --cc ctdb/tools/ctdb.c index ca10aed0cce,e7d247f767d..b4f2ae575c3 --- a/ctdb/tools/ctdb.c +++ b/ctdb/tools/ctdb.c @@@ -541,53 -525,21 +525,27 @@@ static int tickle_tcp(struct ctdb_conte */ static int control_ip(struct ctdb_context *ctdb, int argc, const char **argv) { - int i, j, ret; + int i, ret; TALLOC_CTX *tmp_ctx = talloc_new(ctdb); - trbt_tree_t *tree; - struct ctdb_node_map *nodemap=NULL; struct ctdb_all_public_ips *ips; - struct ctdb_public_ip *ip; - - ret = ctdb_ctrl_getnodemap(ctdb, TIMELIMIT(), options.pnn, tmp_ctx, &nodemap); + /* read the public ip list from this node */ + ret = ctdb_ctrl_get_public_ips(ctdb, TIMELIMIT(), options.pnn, tmp_ctx, &ips); if (ret != 0) { - DEBUG(0, ("Unable to get nodemap from node %u\n", options.pnn)); - DEBUG(0, ("Unable to get public ips from node %u\n", i)); ++ DEBUG(0, ("Unable to get public ips from node %u\n", options.pnn)); talloc_free(tmp_ctx); return ret; } - /* create a tree to store the public addresses in indexed by s_addr */ - tree = trbt_create(tmp_ctx, 0); - CTDB_NO_MEMORY(ctdb, tree); - - for (i=0;inum;i++) { - /* dont read the public ip list from disconnected nodes */ - if (nodemap->nodes[i].flags & NODE_FLAGS_DISCONNECTED) { - continue; - } - - /* read the public ip list from this node */ - ret = ctdb_ctrl_get_public_ips(ctdb, TIMELIMIT(), i, tmp_ctx, &ips); - if (ret != 0) { - DEBUG(0, ("Unable to get public ips from node %u\n", i)); - talloc_free(tmp_ctx); - return ret; - } - - - /* store the public ip */ - for(j=0;jnum;j++){ - ip = talloc_memdup(tmp_ctx, &ips->ips[j], sizeof(struct ctdb_public_ip)); - /* ntohl() so that we sort by the first octet */ - trbt_insert32_callback(tree, ntohl(ips->ips[j].sin.sin_addr.s_addr), store_ip, ip); - } ++ if (options.machinereadable){ ++ printf(":Public IP:Node:\n"); ++ } else { ++ printf("Public IPs on node %u\n", options.pnn); + } + - /* traverse the tree and read back all the public ips one by one */ - if(options.machinereadable){ - printf(":Public IP:Node:\n"); + for (i=0;inum;i++) { + printf("%s %d\n", inet_ntoa(ips->ips[i].sin.sin_addr), ips->ips[i].pnn); } - trbt_traversearray32(tree, 1, print_ip, NULL); talloc_free(tmp_ctx); return 0;