summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2011-10-31 16:21:54 +0100
committerRonnie Sahlberg <ronniesahlberg@gmail.com>2011-11-30 09:02:26 +1100
commit6f657dadd33a27eea033221f30f7858d9b47a023 (patch)
treed118936c949ad61161d22c3ff8debaca7e564482
parent5a1da0ac558df99e6b8ee84e6affe810dc966db7 (diff)
downloadsamba-6f657dadd33a27eea033221f30f7858d9b47a023.tar.gz
samba-6f657dadd33a27eea033221f30f7858d9b47a023.tar.xz
samba-6f657dadd33a27eea033221f30f7858d9b47a023.zip
Add "ctdb check_srvid"
(This used to be ctdb commit 92a391a81d0697956b96e96e39bb1b9d13e18097)
-rw-r--r--ctdb/tools/ctdb.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c
index 9899b7dc54..8232446914 100644
--- a/ctdb/tools/ctdb.c
+++ b/ctdb/tools/ctdb.c
@@ -2066,6 +2066,51 @@ static int getsrvids(struct ctdb_context *ctdb, int argc, const char **argv)
}
/*
+ check if a server id exists
+ */
+static int check_srvids(struct ctdb_context *ctdb, int argc, const char **argv)
+{
+ int32_t status;
+ char *errmsg;
+ int ret;
+ uint32_t pnn;
+ uint64_t *ids;
+ int i;
+ TDB_DATA data, outdata;
+
+ if (argc < 2) {
+ usage();
+ }
+
+ pnn = strtoul(argv[0], NULL, 0);
+
+ ids = talloc_array(ctdb, uint64_t, argc-1);
+
+ for (i=0; i<argc-1; i++) {
+ ids[i] = strtoull(argv[i+1], NULL, 0);
+ }
+ data.dptr = (uint8_t *)ids;
+ data.dsize = talloc_get_size(ids);
+
+ ret = ctdb_control(ctdb, pnn, 0, CTDB_CONTROL_CHECK_SRVIDS,
+ 0, data, ctdb, &outdata, &status, NULL, &errmsg);
+ if (ret != 0) {
+ DEBUG(DEBUG_ERR, ("Unable to check server_id from node %u\n",
+ pnn));
+ return ret;
+ }
+ for (i=0; i<argc-1; i++) {
+ bool exists;
+
+ exists = ((outdata.dptr[i/8] & (1<<(i%8))) != 0);
+
+ printf("Server id %d:%llu %s\n", pnn, ids[i],
+ exists ? "exists" : "does not exist");
+ }
+ return 0;
+}
+
+/*
send a tcp tickle ack
*/
static int tickle_tcp(struct ctdb_context *ctdb, int argc, const char **argv)
@@ -5132,6 +5177,7 @@ static const struct {
{ "unregsrvid", unregsrvid, false, false, "unregister a server id", "<pnn> <type> <id>" },
{ "chksrvid", chksrvid, false, false, "check if a server id exists", "<pnn> <type> <id>" },
{ "getsrvids", getsrvids, false, false, "get a list of all server ids"},
+ { "check_srvids", check_srvids, false, false, "check if a srvid exists", "<pnn> <id>" },
{ "vacuum", ctdb_vacuum, false, false, "vacuum the databases of empty records", "[max_records]"},
{ "repack", ctdb_repack, false, false, "repack all databases", "[max_freelist]"},
{ "listnodes", control_listnodes, false, true, "list all nodes in the cluster"},