tools/ctdb: Factor out printing of the machine readable status header
authorMartin Schwenke <martin@meltin.net>
Tue, 17 Jul 2012 11:09:46 +0000 (21:09 +1000)
committerMartin Schwenke <martin@meltin.net>
Fri, 28 Sep 2012 07:05:34 +0000 (17:05 +1000)
It is already in 2 places and we might use it in another.

Signed-off-by: Martin Schwenke <martin@meltin.net>
tools/ctdb.c

index a9b7079f78d563268a6ba48e99673d687ee5ed6d..edf8d065d40c9dab84093e4cb728fc631cbac65b 100644 (file)
@@ -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));
        }