summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2011-12-06 20:10:34 +1100
committerMartin Schwenke <martin@meltin.net>2011-12-08 17:18:19 +1100
commitb646815567c43d38a8371e53e872a571ff499ffa (patch)
tree03da2947e6cf24bd20a3e023f7a996ab8624c3f7
parent8b74037633eea5f7d06732e60fd4d937b441eb5b (diff)
downloadsamba-b646815567c43d38a8371e53e872a571ff499ffa.tar.gz
samba-b646815567c43d38a8371e53e872a571ff499ffa.tar.xz
samba-b646815567c43d38a8371e53e872a571ff499ffa.zip
ctdb tool - factor out status printing functions
Create 2 new functions: control_status_1_machine() and control_status_1_human() that contain chunks of code from control_status(). We're about to find another purpose for these functions. This should be a no-op. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit fade71539482e8276f57ba3c003fe004d8666ce7)
-rw-r--r--ctdb/tools/ctdb.c44
1 files changed, 29 insertions, 15 deletions
diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c
index f42ecc5f94..8c093851de 100644
--- a/ctdb/tools/ctdb.c
+++ b/ctdb/tools/ctdb.c
@@ -778,6 +778,32 @@ static bool is_partially_online(struct ctdb_node_and_flags *node)
return ret;
}
+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,
+ ctdb_addr_to_str(&node->addr),
+ !!(node->flags&NODE_FLAGS_DISCONNECTED),
+ !!(node->flags&NODE_FLAGS_BANNED),
+ !!(node->flags&NODE_FLAGS_PERMANENTLY_DISABLED),
+ !!(node->flags&NODE_FLAGS_UNHEALTHY),
+ !!(node->flags&NODE_FLAGS_STOPPED),
+ !!(node->flags&NODE_FLAGS_INACTIVE),
+ is_partially_online(node) ? 1 : 0,
+ (node->pnn == mypnn)?'Y':'N');
+
+ return node->flags;
+}
+
+static int control_status_1_human(int mypnn, struct ctdb_node_and_flags *node)
+{
+ printf("pnn:%d %-16s %s%s\n", node->pnn,
+ ctdb_addr_to_str(&node->addr),
+ is_partially_online(node) ? "PARTIALLYONLINE" : pretty_print_flags(node->flags),
+ node->pnn == mypnn?" (THIS NODE)":"");
+
+ return node->flags;
+}
+
/*
display remote ctdb status
*/
@@ -807,16 +833,8 @@ static int control_status(struct ctdb_context *ctdb, int argc, const char **argv
if (nodemap->nodes[i].flags & NODE_FLAGS_DELETED) {
continue;
}
- printf(":%d:%s:%d:%d:%d:%d:%d:%d:%d:%c:\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),
- !!(nodemap->nodes[i].flags&NODE_FLAGS_INACTIVE),
- is_partially_online(&nodemap->nodes[i]) ? 1 : 0,
- (nodemap->nodes[i].pnn == mypnn)?'Y':'N');
+ (void) control_status_1_machine(mypnn,
+ &nodemap->nodes[i]);
}
return 0;
}
@@ -826,10 +844,7 @@ static int control_status(struct ctdb_context *ctdb, int argc, const char **argv
if (nodemap->nodes[i].flags & NODE_FLAGS_DELETED) {
continue;
}
- printf("pnn:%d %-16s %s%s\n", nodemap->nodes[i].pnn,
- ctdb_addr_to_str(&nodemap->nodes[i].addr),
- is_partially_online(&nodemap->nodes[i]) ? "PARTIALLYONLINE" : pretty_print_flags(nodemap->nodes[i].flags),
- nodemap->nodes[i].pnn == mypnn?" (THIS NODE)":"");
+ (void) control_status_1_human(mypnn, &nodemap->nodes[i]);
}
ret = ctdb_ctrl_getvnnmap(ctdb, TIMELIMIT(), options.pnn, ctdb, &vnnmap);
@@ -862,7 +877,6 @@ static int control_status(struct ctdb_context *ctdb, int argc, const char **argv
return 0;
}
-
struct natgw_node {
struct natgw_node *next;
const char *addr;