[Fai-commit] r6438 - in branches/stable/3.4: bin lib/setup-storage

Michael Prokop mika at alioth.debian.org
Fri Apr 15 18:12:48 UTC 2011


Author: mika
Date: 2011-04-15 18:12:35 +0000 (Fri, 15 Apr 2011)
New Revision: 6438

Modified:
   branches/stable/3.4/bin/setup-storage
   branches/stable/3.4/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).

(cherry picked from commit a3f2c2d5472a45101bfecc1fb4f53ec2de516b71)

Modified: branches/stable/3.4/bin/setup-storage
===================================================================
--- branches/stable/3.4/bin/setup-storage	2011-04-15 18:12:04 UTC (rev 6437)
+++ branches/stable/3.4/bin/setup-storage	2011-04-15 18:12:35 UTC (rev 6438)
@@ -126,6 +126,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: branches/stable/3.4/lib/setup-storage/Parser.pm
===================================================================
--- branches/stable/3.4/lib/setup-storage/Parser.pm	2011-04-15 18:12:04 UTC (rev 6437)
+++ branches/stable/3.4/lib/setup-storage/Parser.pm	2011-04-15 18:12:35 UTC (rev 6438)
@@ -965,5 +965,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