pf-tools commit: r535 [parmelan-guest] - in /branches/0.32-stable: debian/changelog pflaunch

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Fri Jun 15 13:11:36 UTC 2007


Author: parmelan-guest
Date: Fri Jun 15 13:11:35 2007
New Revision: 535

URL: http://svn.debian.org/wsvn/pf-tools/?sc=1&rev=535
Log:
* WORK IN PROGRESS
* pflaunch uses Sitalibs::Config instead of lib-net's Load_conf((), but
  Sitalibs::Config does not understand theses comments :
      key = something # comment
  and therefore uses 'something # comment' instead of just 'something' as
  the key value.
  pflaunch now explicitly strips those comments to avoid doing evil, stupid
  things (such as trying to use "1.2.3.4 # FIXME" as an IP address).

Modified:
    branches/0.32-stable/debian/changelog
    branches/0.32-stable/pflaunch

Modified: branches/0.32-stable/debian/changelog
URL: http://svn.debian.org/wsvn/pf-tools/branches/0.32-stable/debian/changelog?rev=535&op=diff
==============================================================================
--- branches/0.32-stable/debian/changelog (original)
+++ branches/0.32-stable/debian/changelog Fri Jun 15 13:11:35 2007
@@ -1,3 +1,20 @@
+pf-tools (0.32.48-0.WIP) unstable; urgency=low
+
+  * WORK IN PROGRESS
+
+  * pflaunch uses Sitalibs::Config instead of lib-net's Load_conf((), but
+    Sitalibs::Config does not understand theses comments :
+
+        key = something # comment
+
+    and therefore uses 'something # comment' instead of just 'something' as
+    the key value.
+
+    pflaunch now explicitly strips those comments to avoid doing evil, stupid
+    things (such as trying to use "1.2.3.4 # FIXME" as an IP address).
+
+ -- Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>  Fri, 15 Jun 2007 14:54:58 +0200
+
 pf-tools (0.32.47-1) unstable; urgency=low
 
   * lib-net: new (optional) "console" directive (see README.doc for more

Modified: branches/0.32-stable/pflaunch
URL: http://svn.debian.org/wsvn/pf-tools/branches/0.32-stable/pflaunch?rev=535&op=diff
==============================================================================
--- branches/0.32-stable/pflaunch (original)
+++ branches/0.32-stable/pflaunch Fri Jun 15 13:11:35 2007
@@ -50,7 +50,7 @@
 my $umlaunch		= "/usr/local/sbin/umlaunch";
 my $cfgpath		= "/var/lib/cvsguest/$HOSTNAME/config/GLOBAL";
 my $configfile		= "$cfgpath/PF/$HOSTNAME.cfg";
-my $privatenetwork	= "$cfgpath/private-network";
+my $privatenetworkfile	= "$cfgpath/private-network";
 my $PF_STATUS_DIR	= "/var/lib/pftools";
 my $CVS_CHECKOUT	= "/var/lib/cvsguest";
 my $uml_switch_pipe	= "/var/run/uml-utilities/uml_switch.ctl";
@@ -68,13 +68,14 @@
 ####### GLOBAL
 my $cache;
 my $options;
-my $cvsupdated;
+my $cvsupdated = 0;
+my $private_network = undef; # hash correspondant à $privatenetworkfile
 
 # Compte les alias créés
 my %ifAliasCpt;
 
-Config_Need_Preproc ($privatenetwork);
-Config_Set_Var ($privatenetwork, ["UML"]);
+Config_Need_Preproc ($privatenetworkfile);
+Config_Set_Var ($privatenetworkfile, ["UML"]);
 
 if ( `which vconfig 2>/dev/null` eq ""
   || `which brctl 2>/dev/null` eq ""
@@ -82,6 +83,24 @@
   || `which screen 2>/dev/null` eq "" )
 {
   __Fault( "Sorry, I need vlan, bridge-utils, uml-utilities and screen");
+}
+
+
+#
+#   update-config vire les commentaires, mais pas Sitalbis::Config ...
+#
+sub __suppress_comments_in_keys {
+    my ($a) = @_;
+
+    return unless $a and ref $a eq 'HASH';
+
+    foreach my $section (keys %$a) {
+	foreach my $key (keys %{$a->{$section}}) {
+	    $a->{$section}->{$key} =~ s/\s+#\s+.*$//;
+	}
+    }
+
+    return $a;
 }
 
 
@@ -171,15 +190,12 @@
     $famille = $1;
     $num = $2;
     $section = $famille."%%";
-    unless (defined Config_Section($privatenetwork, $section))
-    {
-      if (defined Config_Section($privatenetwork, $vm))
-      {
+    unless (exists $private_network->{$section}) {
+      if (exists $private_network->{$vm}) {
         __Info ("La section $section n'existe pas, c'est $vm qui sera prise à la place");
 	$section = $vm;
       }
-      else
-      {
+      else {
         __Err ("La section $section n'existe pas, et pas de section $vm à la place. Problème a venir ...");
       }
     }
@@ -188,7 +204,7 @@
     $famille = $1;
     $num = 0;
     $section = $famille;
-    unless (Config_Key($privatenetwork, $section, "umlfilename.default")) {
+    unless ($private_network->{$section}->{'umlfilename.default'}) {
     __Info ("Attention, la machine `$vm' n'a pas de clef umlfilename.default, elle ne sera donc pas lancée");
     }
   } else {
@@ -209,7 +225,7 @@
   my ($famille, $num, $section) = __FamillyNumFromVM (shift);
 
    
-  my $s = Config_Section($privatenetwork, $section);
+  my $s = $private_network->{$section};
 
   __Fault("Familly '$famille' NOT found !") unless (defined ($s) and ($section)); 
   __Fault("VM $famille$num out of range.") if ($s->{number} <= $num);
@@ -240,7 +256,7 @@
 
   my ($famille, $num, $section) = __FamillyNumFromVM ($vm);
 
-  my $s = Config_Section($privatenetwork, $section);
+  my $s = $private_network->{$section};
   __Fault("Familly '$famille' NOT found !") unless (defined ($s) and ($s)); 
 
   # Recherche des ipstart
@@ -264,7 +280,7 @@
   foreach my $key (keys %$s) {
     if ($key =~ /^interface\.\S+/) {
       my $vlan = $s->{$key};
-      my $network = Config_Key ($privatenetwork, $vlan, "network");
+      my $network = $private_network->{$vlan}->{'network'};
       __Err("Can't get IP of vlan $vlan") unless defined $network;
       my $ip = Address(
         $network,
@@ -310,11 +326,11 @@
   {
     my ($famille, $num, $section) = __FamillyNumFromVM($vm); 
 
-    my $s = Config_Section($privatenetwork, $section);
+    my $s = $private_network->{$section};
 
     unless ($s)
     {
-      __Fault("(Je ne peux pas lire la section `$section` from $privatenetwork pour la vm `$vm'");
+      __Fault("(Je ne peux pas lire la section `$section` from $privatenetworkfile pour la vm `$vm'");
     }
 
     foreach my $lan (%{$s})
@@ -372,9 +388,9 @@
   my $vlan = shift;
 
 
-  my $section = Config_Section ($privatenetwork, $vlan);
-
-  __Err("Can't read section [$vlan] from `$privatenetwork'") unless (defined ($section) and ($section));
+  my $section = $private_network->{$vlan};
+
+  __Err("Can't read section [$vlan] from `$privatenetworkfile'") unless (defined ($section) and ($section));
   return $section;
 }
 
@@ -418,7 +434,7 @@
 
   my ($famille, $num, $section) = __FamillyNumFromVM ($vm);
 
-  my $s = Config_Section($privatenetwork, $section);
+  my $s = $private_network->{$section};
 
   my @ipstart;
   if ($s->{"ipstart.".$vlan}) {
@@ -436,7 +452,7 @@
   push @ipstart,"0" while (@ipstart<4);
   @ipstart = reverse @ipstart;
 
-  my $n = Config_Key($privatenetwork, $vlan, "network");
+  my $n = $private_network->{$vlan}->{'network'};
   __Fault("Je ne peux pas lire la s network du " 
     ."vlan `$vlan' dans le private-network") unless $n;
 
@@ -847,7 +863,7 @@
       next unless $host;
 
       my (undef,undef,$section) = __FamillyNumFromVM ($host);
-      unless (Config_Key($privatenetwork, $section, "umlfilename.default")) {
+      unless (exists $private_network->{$section}->{'umlfilename.default'}) {
         __Info ("Attention, la machine `$host' n'a pas de clef umlfilename.default,".
         "elle ne sera donc pas lancée");
        next;
@@ -1172,7 +1188,7 @@
   unless $vlan_if;
 
 
-  my $vlandata = Config_Section ($privatenetwork, $vlan);
+  my $vlandata = $private_network->{$vlan};
   unless ($vlandata)
   {
     __Debug("Erreur je n'arrive pas a lire dans private-network les infos du vlan `$vlan'");
@@ -1532,9 +1548,6 @@
   else
   {
 
-    my $pflaunchcfg;
-    my $privatenetworkcfg;
-    my $runningbranche;
     my $branchecvs = __GetBrancheCVS();
 
     __Info("Getting config from CVS");
@@ -1550,10 +1563,12 @@
     {
       __Fault("Je n'arrive pas a lire $configfile, vérifiez votre installation");
     }
-    unless (-r $privatenetwork) 
-    {
-      __Fault("Je n'arrive pas a lire $privatenetwork, vérifiez votre installation");
-    }
+    unless (-r $privatenetworkfile) 
+    {
+      __Fault("Je n'arrive pas a lire $privatenetworkfile, vérifiez votre installation");
+    }
+    $private_network = Load_Config($privatenetworkfile);
+    __suppress_comments_in_keys($private_network);
   }
 
 }




More information about the Pf-tools-commits mailing list