From 736b293fe16c0b2dd0369da5533cd0c010a80a82 Mon Sep 17 00:00:00 2001 From: thomas Date: Fri, 27 Apr 2018 12:40:53 +0200 Subject: [PATCH] mxraid_assemble: Add option to list arrays and devices 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. --- mxraid/mxraid_assemble | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/mxraid/mxraid_assemble b/mxraid/mxraid_assemble index 336694c..bf23ab1 100755 --- a/mxraid/mxraid_assemble +++ b/mxraid/mxraid_assemble @@ -12,7 +12,7 @@ import MxRaid::HostData; import MxRaid::Utils; import MxRaid::Color; -my $VERSION = '0.8'; +my $VERSION = '0.9'; sub exec_usage { @@ -32,6 +32,7 @@ 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 @@ -39,9 +40,7 @@ sub exec_usage { __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 @@ -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}; @@ -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(); }