[SCM] CTDB repository - branch master updated - ctdb-1.13-261-g7b75a3b

Amitay Isaacs amitay at samba.org
Tue Oct 2 00:44:22 MDT 2012


The branch, master has been updated
       via  7b75a3bb722dc86139b1a07a0100d08c34620b91 (commit)
       via  b29d5bbaa7048291c4b3a39bf12e04f0436f67da (commit)
       via  12a0a7a208d1c8fa8991894200d1dc133f3a2d1a (commit)
       via  2da7730dc06153173778ab14e228960e72ff8a86 (commit)
      from  93c97c3ba3ff714dfa0d056a91ff45010a6e2d66 (commit)

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


- Log -----------------------------------------------------------------
commit 7b75a3bb722dc86139b1a07a0100d08c34620b91
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jul 17 21:25:27 2012 +1000

    tools/ctdb: Remove redundant filtering loop in control_natgwlist()
    
    This used to catch trailing blank lines.  However, these are caught
    just as effectively by the whitespace filtering in the loop below.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit b29d5bbaa7048291c4b3a39bf12e04f0436f67da
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jul 17 21:15:57 2012 +1000

    tools/ctdb: natgwlist output is either human readable or machine readable
    
    The first line is currently human readable and the rest is machine
    readable.  This doesn't make sense.  Do one or the other...
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 12a0a7a208d1c8fa8991894200d1dc133f3a2d1a
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jul 17 21:09:46 2012 +1000

    tools/ctdb: Factor out printing of the machine readable status header
    
    It is already in 2 places and we might use it in another.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 2da7730dc06153173778ab14e228960e72ff8a86
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Jul 16 14:24:39 2012 +1000

    tools/ctdb: NAT gateway code should use CTDB_NATGW_NODES
    
    ... not NATGW_NODES.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

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

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


Changeset truncated at 500 lines:

diff --git a/tools/ctdb.c b/tools/ctdb.c
index 2b54ca3..badfb6f 100644
--- a/tools/ctdb.c
+++ b/tools/ctdb.c
@@ -836,6 +836,12 @@ static bool is_partially_online(struct ctdb_node_and_flags *node)
 	return ret;
 }
 
+static void control_status_header_machine(void)
+{
+	printf(":Node:IP:Disconnected:Banned:Disabled:Unhealthy:Stopped"
+	       ":Inactive:PartiallyOnline:ThisNode:\n");
+}
+
 static int control_status_1_machine(int mypnn, struct ctdb_node_and_flags *node)
 {
 	printf(":%d:%s:%d:%d:%d:%d:%d:%d:%d:%c:\n", node->pnn,
@@ -882,8 +888,7 @@ static int control_status(struct ctdb_context *ctdb, int argc, const char **argv
 	}
 
 	if (options.machinereadable) {
-		printf(":Node:IP:Disconnected:Banned:Disabled:Unhealthy:Stopped"
-		       ":Inactive:PartiallyOnline:ThisNode:\n");
+		control_status_header_machine();
 		for (i=0;i<nodemap->num;i++) {
 			if (nodemap->nodes[i].flags & NODE_FLAGS_DELETED) {
 				continue;
@@ -949,8 +954,7 @@ static int control_nodestatus(struct ctdb_context *ctdb, int argc, const char **
 	}
 
 	if (options.machinereadable) {
-		printf(":Node:IP:Disconnected:Banned:Disabled:Unhealthy:Stopped"
-		       ":Inactive:PartiallyOnline:ThisNode:\n");
+		control_status_header_machine();
 	} else if (pnn_mode == CTDB_BROADCAST_ALL) {
 		printf("Number of nodes:%d\n", (int) talloc_array_length(nodes));
 	}
@@ -997,10 +1001,12 @@ static int control_natgwlist(struct ctdb_context *ctdb, int argc, const char **a
 	struct natgw_node *natgw_nodes = NULL;
 	struct natgw_node *natgw_node;
 	struct ctdb_node_map *nodemap=NULL;
+	uint32_t mypnn;
+	const char *fmt;
 
 
 	/* read the natgw nodes file into a linked list */
-	natgw_list = getenv("NATGW_NODES");
+	natgw_list = getenv("CTDB_NATGW_NODES");
 	if (natgw_list == NULL) {
 		natgw_list = "/etc/ctdb/natgw_nodes";
 	}
@@ -1009,9 +1015,6 @@ static int control_natgwlist(struct ctdb_context *ctdb, int argc, const char **a
 		ctdb_set_error(ctdb, "Failed to load natgw node list '%s'\n", natgw_list);
 		return -1;
 	}
-	while (nlines > 0 && strcmp(lines[nlines-1], "") == 0) {
-		nlines--;
-	}
 	for (i=0;i<nlines;i++) {
 		char *node;
 
@@ -1062,7 +1065,14 @@ static int control_natgwlist(struct ctdb_context *ctdb, int argc, const char **a
 		}
 
 		i++;
-	}		
+	}
+
+	if (options.machinereadable) {
+		printf(":Node:IP:\n");
+		fmt = ":%d:%s:\n";
+	} else {
+		fmt = "%d %s\n";
+	}
 
 	/* pick a node to be natgwmaster
 	 * we dont allow STOPPED, DELETED, BANNED or UNHEALTHY nodes to become the natgwmaster
@@ -1077,7 +1087,7 @@ static int control_natgwlist(struct ctdb_context *ctdb, int argc, const char **a
 			if (!(capabilities&CTDB_CAP_NATGW)) {
 				continue;
 			}
-			printf("%d %s\n", nodemap->nodes[i].pnn,ctdb_addr_to_str(&nodemap->nodes[i].addr));
+			printf(fmt, nodemap->nodes[i].pnn,ctdb_addr_to_str(&nodemap->nodes[i].addr));
 			break;
 		}
 	}
@@ -1093,7 +1103,7 @@ static int control_natgwlist(struct ctdb_context *ctdb, int argc, const char **a
 				if (!(capabilities&CTDB_CAP_NATGW)) {
 					continue;
 				}
-				printf("%d %s\n", nodemap->nodes[i].pnn,ctdb_addr_to_str(&nodemap->nodes[i].addr));
+				printf(fmt, nodemap->nodes[i].pnn,ctdb_addr_to_str(&nodemap->nodes[i].addr));
 				break;
 			}
 		}
@@ -1110,29 +1120,36 @@ static int control_natgwlist(struct ctdb_context *ctdb, int argc, const char **a
 				if (!(capabilities&CTDB_CAP_NATGW)) {
 					continue;
 				}
-				printf("%d %s\n", nodemap->nodes[i].pnn, ctdb_addr_to_str(&nodemap->nodes[i].addr));
+				printf(fmt, nodemap->nodes[i].pnn, ctdb_addr_to_str(&nodemap->nodes[i].addr));
 				break;
 			}
 		}
 		/* or if we still can not find any */
 		if (i == nodemap->num) {
-			printf("-1 0.0.0.0\n");
+			printf(fmt, -1, "0.0.0.0");
 			ret = 2; /* matches ENOENT */
 		}
 	}
 
 	/* print the pruned list of nodes belonging to this natgw list */
+	if (!ctdb_getpnn(ctdb_connection, options.pnn, &mypnn)) {
+		DEBUG(DEBUG_ERR, ("Unable to get PNN from node %u\n", options.pnn));
+		return -1;
+	}
+	if (options.machinereadable) {
+		control_status_header_machine();
+	} else {
+		printf("Number of nodes:%d\n", nodemap->num);
+	}
 	for(i=0;i<nodemap->num;i++){
 		if (nodemap->nodes[i].flags & NODE_FLAGS_DELETED) {
 			continue;
 		}
-		printf(":%d:%s:%d:%d:%d:%d:%d\n", nodemap->nodes[i].pnn,
-			ctdb_addr_to_str(&nodemap->nodes[i].addr),
-		       !!(nodemap->nodes[i].flags&NODE_FLAGS_DISCONNECTED),
-		       !!(nodemap->nodes[i].flags&NODE_FLAGS_BANNED),
-		       !!(nodemap->nodes[i].flags&NODE_FLAGS_PERMANENTLY_DISABLED),
-		       !!(nodemap->nodes[i].flags&NODE_FLAGS_UNHEALTHY),
-		       !!(nodemap->nodes[i].flags&NODE_FLAGS_STOPPED));
+		if (options.machinereadable) {
+			control_status_1_machine(mypnn, &(nodemap->nodes[i]));
+		} else {
+			control_status_1_human(mypnn, &(nodemap->nodes[i]));
+		}
 	}
 
 	return ret;


-- 
CTDB repository


More information about the samba-cvs mailing list