[Fai-commit] r6088 - trunk/lib/setup-storage
Julien Blache
jblache at alioth.debian.org
Fri Oct 1 10:25:22 UTC 2010
Author: jblache
Date: 2010-10-01 10:25:17 +0000 (Fri, 01 Oct 2010)
New Revision: 6088
Modified:
trunk/lib/setup-storage/Volumes.pm
Log:
Rework mdadm output parsing code to make it more tolerant to changes in the output format
Modified: trunk/lib/setup-storage/Volumes.pm
===================================================================
--- trunk/lib/setup-storage/Volumes.pm 2010-09-30 10:57:00 UTC (rev 6087)
+++ trunk/lib/setup-storage/Volumes.pm 2010-10-01 10:25:17 UTC (rev 6088)
@@ -437,20 +437,30 @@
# ARRAY /dev/md1 level=raid0 num-devices=3 metadata=00.90
# UUID=77a22e9f:83fd1276:135399f0:a895f15f
# devices=/dev/sde3,/dev/sdf3,/dev/sdd3
+# and another variant
+# ARRAY /dev/md1 level=raid0 metadata=1.2 num-devices=3
+# UUID=77a22e9f:83fd1276:135399f0:a895f15f
+# devices=/dev/sde3,/dev/sdf3,/dev/sdd3
-
# the id of the RAID
my $id;
# parse the output line by line
foreach my $line (@mdadm_print) {
- if ($line =~ /^ARRAY \/dev\/md[\/]?(\d+) level=(\S+) num-devices=\d+(\s+|$)/) {
+ if ($line =~ /^ARRAY \/dev\/md[\/]?(\d+)\s+/) {
$id = $1;
- $FAI::current_raid_config{$id}{mode} = $2;
+
+ foreach (split (" ", $line)) {
+ if ($_ =~ /^level=(\S+)/) {
+ $FAI::current_raid_config{$id}{mode} = $1;
+ }
+ }
} elsif ($line =~ /^\s*devices=(\S+)$/) {
defined($id) or &FAI::internal_error("mdadm ARRAY line not yet seen");
push @{ $FAI::current_raid_config{$id}{devices} }, abs_path($_)
foreach (split (",", $1));
+
+ undef($id);
}
}
}
More information about the Fai-commit
mailing list