[SCM] CTDB repository - branch master updated - ctdb-1.0.65-12-gbbd46f3

Ronnie Sahlberg sahlberg at samba.org
Thu Nov 27 22:54:44 GMT 2008


The branch, master has been updated
       via  bbd46f341e9aa32d8dbd49f7a9a07cb3f1f92ea3 (commit)
      from  499a01fece2a5f24f1b2943cf3dc6e9a3a8ca3b5 (commit)

http://gitweb.samba.org/?p=sahlberg/ctdb.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit bbd46f341e9aa32d8dbd49f7a9a07cb3f1f92ea3
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Fri Nov 28 09:52:26 2008 +1100

    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.

-----------------------------------------------------------------------

Summary of changes:
 tools/ctdb.c |   74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 74 insertions(+), 0 deletions(-)


Changeset truncated at 500 lines:

diff --git a/tools/ctdb.c b/tools/ctdb.c
index 5c553e6..c4932c2 100644
--- a/tools/ctdb.c
+++ b/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;


-- 
CTDB repository


More information about the samba-cvs mailing list