Skip to content

Commit

Permalink
mogadm: add "device next" sub-command
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Eric Wong committed Oct 17, 2013
1 parent 71bfe84 commit e605198
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions mogadm
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ my $usage = {
"--weight=i" => "Positive numeric weight for device",
},
},
next => {
des => "Show the next available devid.",
},
},
},
domain => {
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -1474,6 +1492,8 @@ L</"HOST OPTIONS"> section.
=item B<device list>
=item B<device next>
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</"DEVICE OPTIONS"> section.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e605198

Please sign in to comment.