]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
add a ctdb command to print the default public ip of a host.
authorRonnie Sahlberg <sahlberg@ronnie>
Tue, 7 Aug 2007 02:10:05 +0000 (12:10 +1000)
committerRonnie Sahlberg <sahlberg@ronnie>
Tue, 7 Aug 2007 02:10:05 +0000 (12:10 +1000)
(This used to be ctdb commit 7de5489f6ebd0e5671e7afa5cb51471043ee46d1)

ctdb/tools/ctdb.c

index 7b44dc62cd2bbf297ecd220fd82f83e7f84ea165..6e889abe41afc00eae27150070dac4f2859939e1 100644 (file)
@@ -442,6 +442,28 @@ static int control_ip(struct ctdb_context *ctdb, int argc, const char **argv)
        return 0;
 }
 
+/*
+  display public ip address of this node
+ */
+static int control_publicip(struct ctdb_context *ctdb, int argc, const char **argv)
+{
+       int ret;
+       struct ctdb_all_public_ips *ips;
+       uint32_t myvnn;
+
+       myvnn = ctdb_ctrl_getvnn(ctdb, TIMELIMIT(), options.vnn);
+
+       ret = ctdb_ctrl_get_public_ips(ctdb, TIMELIMIT(), options.vnn, ctdb, &ips);
+       if (ret != 0) {
+               printf("Unable to get public ips from node %u\n", options.vnn);
+               return ret;
+       }
+
+       printf("%-16s\n", inet_ntoa(ips->ips[myvnn].sin.sin_addr));
+
+       return 0;
+}
+
 /*
   display pid of a ctdb daemon
  */
@@ -907,6 +929,7 @@ static const struct {
        { "statistics",      control_statistics,        false, "show statistics" },
        { "statisticsreset", control_statistics_reset,  true,  "reset statistics"},
        { "ip",              control_ip,                true,  "show which public ip's that ctdb manages" },
+       { "publicip",        control_publicip,          false, "show the default public ip address for this node" },
        { "process-exists",  control_process_exists,    true,  "check if a process exists on a node",  "<pid>"},
        { "getdbmap",        control_getdbmap,          true,  "show the database map" },
        { "catdb",           control_catdb,             true,  "dump a database" ,                     "<dbname>"},