[Fai-commit] r6331 - in trunk: bin lib/setup-storage
Michael Tautschnig
mt at alioth.debian.org
Thu Apr 14 11:03:25 UTC 2011
Author: mt
Date: 2011-04-14 11:03:18 +0000 (Thu, 14 Apr 2011)
New Revision: 6331
Modified:
trunk/bin/setup-storage
trunk/lib/setup-storage/Parser.pm
Log:
setup-storage, setup-storage/Parser.pm: sanity checks.
Perform additional check for invalid configs (such as empty disk_config X
stanzas).
Modified: trunk/bin/setup-storage
===================================================================
--- trunk/bin/setup-storage 2011-04-14 10:59:17 UTC (rev 6330)
+++ trunk/bin/setup-storage 2011-04-14 11:03:18 UTC (rev 6331)
@@ -127,6 +127,9 @@
print "Using config file: $opt_f\n";
&FAI::run_parser($config_file);
+# make sure there are no empty disk_config stanzas
+&FAI::check_config;
+
# read the sizes and partition tables of all disks listed in $FAI::disks
&FAI::get_current_disks;
Modified: trunk/lib/setup-storage/Parser.pm
===================================================================
--- trunk/lib/setup-storage/Parser.pm 2011-04-14 10:59:17 UTC (rev 6330)
+++ trunk/lib/setup-storage/Parser.pm 2011-04-14 11:03:18 UTC (rev 6331)
@@ -982,5 +982,33 @@
defined $FAI::Parser->file($input) or die "Syntax error\n";
}
+################################################################################
+#
+# @brief Check for invalid configs (despite correct syntax)
+#
+################################################################################
+sub check_config {
+
+ # loop through all configs
+ foreach my $config (keys %FAI::configs) {
+ if ($config =~ /^PHY_(.+)$/) {
+ (scalar(keys %{ $FAI::configs{$config}{partitions} }) > 0) or
+ die "Empty disk_config stanza for device $1\n";
+ } elsif ($config =~ /^VG_(.+)$/) {
+ next if ($1 eq "--ANY--");
+ next;
+ } elsif ($config eq "RAID") {
+ (scalar(keys %{ $FAI::configs{$config}{volumes} }) > 0) or
+ die "Empty RAID configuration\n";
+ } elsif ($config eq "CRYPT") {
+ next;
+ } elsif ($config eq "TMPFS") {
+ next;
+ } else {
+ &FAI::internal_error("Unexpected key $config");
+ }
+ }
+}
+
1;
More information about the Fai-commit
mailing list