From e6051985b6e2dae415dcf298a3686af498cbb655 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 17 Oct 2013 01:05:23 +0000 Subject: [PATCH] mogadm: add "device next" sub-command This is a convenience command to ease the process of adding devices to a cluster. This may be useful when there are many devices to be added. This provides no synchronization and multiple administrative users will still have to coordinate device additions to avoid errors on duplicates. Adding synchronization would require extending the tracker protocol, and is probably not worth the complexity. --- mogadm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/mogadm b/mogadm index 61b47a2..8030e60 100755 --- a/mogadm +++ b/mogadm @@ -123,6 +123,9 @@ my $usage = { "--weight=i" => "Positive numeric weight for device", }, }, + next => { + des => "Show the next available devid.", + }, }, }, domain => { @@ -882,6 +885,21 @@ sub cmd_device_summary { } +sub cmd_device_next { + my $devs = mogadm()->get_devices; + fail_text('no_devices') unless @$devs; + my $maxid = 0; + foreach my $dev (@$devs) { + my $devid = $dev->{devid}; + if ($devid > $maxid) { + $maxid = $devid; + } + } + + print($maxid + 1, "\n"); + ok(); +} + sub cmd_slave_list { my $mogadm = mogadm(); @@ -1474,6 +1492,8 @@ L section. =item B +=item B + Functions for manipulating devices. For add and modify, device options are in the format of normal command line options and can include anything in the L section. @@ -1644,6 +1664,7 @@ Device manipulation: $ mogadm device list $ mogadm device summary $ mogadm device summary --status=dead,down + $ mogadm device next $ mogadm device add foo.local 16 $ mogadm device add foo.local 17 --status=alive $ mogadm device mark foo.local 17 down