Skip to content

Commit

Permalink
mxraid_assemble: Add option to list arrays and devices
Browse files Browse the repository at this point in the history
Besides the obvious, calling with -lv might be useful to discover
errors in the database setup. Tool is almost complete (say 90%),
thus a new version.
  • Loading branch information
thomas committed Apr 27, 2018
1 parent 832fc9a commit 736b293
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions mxraid/mxraid_assemble
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import MxRaid::HostData;
import MxRaid::Utils;
import MxRaid::Color;

my $VERSION = '0.8';
my $VERSION = '0.9';

sub exec_usage {

Expand All @@ -32,16 +32,15 @@ sub exec_usage {
-c check database
-d file alternative database file
-h print this help and exit
-l list arrays on host, with -v will also show candidates
-q be quiet
-v be more verbose
-V print Version information and exit
__HELP

=things to come
-l list arrays on host
-n label print config records for new assemblies on host
-p paged list
-1 run script even if only 1 disk is present, well ...
=cut

Expand All @@ -63,7 +62,7 @@ sub exec_version {
my $ROOT=$<==0?1:0;

my %opts;
getopts('acd:hqvV', \%opts) or die "# ERROR: getopts failed, try -h.\n"; # Values in %opts
getopts('acd:hlqvV', \%opts) or die "# ERROR: getopts failed, try -h.\n"; # Values in %opts
exec_usage if $opts{h};
exec_version if $opts{V};

Expand Down Expand Up @@ -98,6 +97,23 @@ if ($opts{c}) {
printf "# Successor labels: %s\n", join(', ', @{$cd->next_db_labels});
print "\n";
}
} elsif ($opts{l}) {
my @labels = sort @{$hd->raid_labels()};
print "# NOTE: no active raids found.\n" unless @labels;
for my $label (@labels) {
print "$label:\n";
for my $rec (@{$hd->{configured_raids}{$label}}) { # todo write a proper accessor :xxx:
printf " %5s %-16s '%s'\n", @$rec;
}
print "\n";
}
if ($VERBOSE >= 2) {
print "Disks not part of a SW-RAID:\n";
for my $rec (@{$hd->non_raid_disks()}) {
printf " %5s %-16s '%s'\n", @$rec;
}
print "\n";
}
} else {
create_mdadm_configs();
}
Expand Down

1 comment on commit 736b293

@thomas
Copy link
Contributor Author

@thomas thomas commented on 736b293 Apr 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to my 'no installs on Friday' rule, i'll install it on Monday.

Please sign in to comment.