summaryrefslogtreecommitdiffstats
path: root/ctdb/tools
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2013-09-06 13:20:26 +1000
committerAmitay Isaacs <amitay@gmail.com>2013-09-19 12:54:32 +1000
commit5f0d85d4db08b9de1eee35b161a4d1a05b43d77c (patch)
treeb4a3f052bc66b44592e56b0ef673a2b5074101f3 /ctdb/tools
parentc484361076d4fa9077e3e56811f791f073543c19 (diff)
downloadsamba-5f0d85d4db08b9de1eee35b161a4d1a05b43d77c.tar.gz
samba-5f0d85d4db08b9de1eee35b161a4d1a05b43d77c.tar.xz
samba-5f0d85d4db08b9de1eee35b161a4d1a05b43d77c.zip
tools/ctdb: Fix arguments/semantics of rebalance node
There's no reason why specifying a node should be compulsory. This is a cluster-wide operation because it is implemented by the recovery master so multiple nodes should not be specified using -n. However, the command should be able to specify multiple nodes so let it have its own nodestring argument. This change should be backward compatible with the old requirement of specifying a single node via -n. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 0846c00597adb66bba8c9dbf63443d0c2f91a7d1)
Diffstat (limited to 'ctdb/tools')
-rw-r--r--ctdb/tools/ctdb.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c
index a5553bdc406..a72f0eea373 100644
--- a/ctdb/tools/ctdb.c
+++ b/ctdb/tools/ctdb.c
@@ -1773,16 +1773,30 @@ static int rebalance_node(struct ctdb_context *ctdb, uint32_t pnn)
*/
static int control_rebalancenode(struct ctdb_context *ctdb, int argc, const char **argv)
{
- switch (options.pnn) {
- case CTDB_BROADCAST_ALL:
- case CTDB_CURRENT_NODE:
- DEBUG(DEBUG_ERR,("You must specify a node number with -n <pnn> for the node to rebalance\n"));
+ uint32_t *nodes;
+ uint32_t pnn_mode;
+ int i, ret;
+
+ assert_single_node_only();
+
+ if (argc > 1) {
+ usage();
+ }
+
+ /* Determine the nodes where IPs need to be reloaded */
+ if (!parse_nodestring(ctdb, argc == 1 ? argv[0] : NULL,
+ options.pnn, true, &nodes, &pnn_mode)) {
return -1;
}
- return rebalance_node(ctdb, options.pnn);
-}
+ for (i = 0; i < talloc_array_length(nodes); i++) {
+ if (!rebalance_node(ctdb, nodes[i])) {
+ ret = -1;
+ }
+ }
+ return ret;
+}
static int rebalance_ip(struct ctdb_context *ctdb, ctdb_sock_addr *addr)
{