summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonnie Sahlberg <ronniesahlberg@gmail.com>2008-11-28 09:52:26 +1100
committerRonnie Sahlberg <ronniesahlberg@gmail.com>2008-11-28 09:52:26 +1100
commit51cc8b4df86b21a48ad1e54f277428b282d8a41f (patch)
tree41b250d68ae0c1049f1ae86563c2383ea7ccc750
parenta782bdbacd3e407745e91951dcb4312eb1a4f3d1 (diff)
downloadsamba-51cc8b4df86b21a48ad1e54f277428b282d8a41f.tar.gz
make it possible to delete an ip from all nodes at once using
"ctdb delip x.x.x.x -n all" This is not as straightforward as one might think since during the delete process we don not want the ip to be bouncing from one node to another as node by node deletes it. Thus we first delete the ip from all connected nodes which are not currently hosting it. After this we delete the ip from the node which is hosting it. (This used to be ctdb commit bbd46f341e9aa32d8dbd49f7a9a07cb3f1f92ea3)
-rw-r--r--ctdb/tools/ctdb.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c
index 5c553e69a9f..c4932c24b7a 100644
--- a/ctdb/tools/ctdb.c
+++ b/ctdb/tools/ctdb.c
@@ -828,6 +828,76 @@ static int control_addip(struct ctdb_context *ctdb, int argc, const char **argv)
return 0;
}
+static int control_delip(struct ctdb_context *ctdb, int argc, const char **argv);
+
+static int control_delip_all(struct ctdb_context *ctdb, int argc, const char **argv, ctdb_sock_addr *addr)
+{
+ TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
+ struct ctdb_node_map *nodemap=NULL;
+ struct ctdb_all_public_ips *ips;
+ int ret, i, j;
+
+ ret = ctdb_ctrl_getnodemap(ctdb, TIMELIMIT(), CTDB_CURRENT_NODE, tmp_ctx, &nodemap);
+ if (ret != 0) {
+ DEBUG(DEBUG_ERR, ("Unable to get nodemap from current node\n"));
+ return ret;
+ }
+
+ /* remove it from the nodes that are not hosting the ip currently */
+ for(i=0;i<nodemap->num;i++){
+ if (nodemap->nodes[i].flags & NODE_FLAGS_DISCONNECTED) {
+ continue;
+ }
+ if (ctdb_ctrl_get_public_ips(ctdb, TIMELIMIT(), nodemap->nodes[i].pnn, tmp_ctx, &ips) != 0) {
+ DEBUG(DEBUG_ERR, ("Unable to get public ip list from node %d\n", nodemap->nodes[i].pnn));
+ continue;
+ }
+
+ for (j=0;j<ips->num;j++) {
+ if (ctdb_same_ip(addr, &ips->ips[j].addr)) {
+ break;
+ }
+ }
+ if (j==ips->num) {
+ continue;
+ }
+
+ if (ips->ips[j].pnn == nodemap->nodes[i].pnn) {
+ continue;
+ }
+
+ options.pnn = nodemap->nodes[i].pnn;
+ control_delip(ctdb, argc, argv);
+ }
+
+
+ /* remove it from every node (also the one hosting it) */
+ for(i=0;i<nodemap->num;i++){
+ if (nodemap->nodes[i].flags & NODE_FLAGS_DISCONNECTED) {
+ continue;
+ }
+ if (ctdb_ctrl_get_public_ips(ctdb, TIMELIMIT(), nodemap->nodes[i].pnn, tmp_ctx, &ips) != 0) {
+ DEBUG(DEBUG_ERR, ("Unable to get public ip list from node %d\n", nodemap->nodes[i].pnn));
+ continue;
+ }
+
+ for (j=0;j<ips->num;j++) {
+ if (ctdb_same_ip(addr, &ips->ips[j].addr)) {
+ break;
+ }
+ }
+ if (j==ips->num) {
+ continue;
+ }
+
+ options.pnn = nodemap->nodes[i].pnn;
+ control_delip(ctdb, argc, argv);
+ }
+
+ talloc_free(tmp_ctx);
+ return 0;
+}
+
/*
delete a public ip address from a node
*/
@@ -849,6 +919,10 @@ static int control_delip(struct ctdb_context *ctdb, int argc, const char **argv)
return -1;
}
+ if (options.pnn == CTDB_BROADCAST_ALL) {
+ return control_delip_all(ctdb, argc, argv, &addr);
+ }
+
pub.addr = addr;
pub.mask = 0;
pub.len = 0;