pf-tools commit: r550 [ccaillet-guest] - in /trunk: debian/changelog lib/PFTools/Conf.pm lib/PFTools/Net.pm lib/PFTools/Update.pm

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Thu Jan 17 15:28:26 UTC 2008


Author: ccaillet-guest
Date: Thu Jan 17 15:28:12 2008
New Revision: 550

URL: http://svn.debian.org/wsvn/pf-tools/?sc=1&rev=550
Log:
* creating pxe_linuxcfg tool which is a rewrite of mk_pxelinuxcfg
* extracting Mk_pxelinuxcfg from Net.pm to pxe_linuxcfg and exporting some
  functions which are needed for pxe_linuxcfg

Modified:
    trunk/debian/changelog
    trunk/lib/PFTools/Conf.pm
    trunk/lib/PFTools/Net.pm
    trunk/lib/PFTools/Update.pm

Modified: trunk/debian/changelog
URL: http://svn.debian.org/wsvn/pf-tools/trunk/debian/changelog?rev=550&op=diff
==============================================================================
--- trunk/debian/changelog (original)
+++ trunk/debian/changelog Thu Jan 17 15:28:12 2008
@@ -8,6 +8,9 @@
   * modifying update-config by moving Get_options, Do_help function on
     Update.pm to update-config script (right place)
   * exporting some logging functions needed by update-config from Conf.pm
+  * creating pxe_linuxcfg tool which is a rewrite of mk_pxelinuxcfg
+  * extracting Mk_pxelinuxcfg from Net.pm to pxe_linuxcfg and exporting some
+    functions which are needed for pxe_linuxcfg
 
   [ Thomas Parmelan ]
   * lib-net: if no comment is specified in a zone, network or server
@@ -18,7 +21,7 @@
     made mistakes...
   * Update my email address.
 
- -- Christophe Caillet <quadchris at free.fr>  Mon, 07 Jan 2008 11:38:16 +0100
+ -- Christophe Caillet <quadchris at free.fr>  Thu, 17 Jan 2008 16:25:49 +0100
 
 pf-tools (0.32.46-1) unstable; urgency=low
 

Modified: trunk/lib/PFTools/Conf.pm
URL: http://svn.debian.org/wsvn/pf-tools/trunk/lib/PFTools/Conf.pm?rev=550&op=diff
==============================================================================
--- trunk/lib/PFTools/Conf.pm (original)
+++ trunk/lib/PFTools/Conf.pm Thu Jan 17 15:28:12 2008
@@ -22,7 +22,7 @@
 ##  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 ##
 
-use strict;
+# use strict;
 use warnings;
 
 use Exporter;
@@ -268,7 +268,7 @@
 sub Debug ($) {
     my (@msg) = @_;
 
-    # FIXME à faire une bonne fois pour toutes !
+    # FIXME � faire une bonne fois pour toutes !
     my $basename = ( split( '/', $0 ) )[-1];
     Log( $basename . ": DEBUG: ", @msg );
 }
@@ -555,8 +555,9 @@
 	Add_var( $V->{$esc1}, $quote, $val );
     }
     else {
-	$var =~ s/\\\././g;
+    	$var =~ s/\\\././g;
 	if ( defined( $V->{$var} ) ) {
+		print "Syntax error\n" ;
 	    return ($ERR_SYNTAX);
 	}
 	$V->{$var} = $val;

Modified: trunk/lib/PFTools/Net.pm
URL: http://svn.debian.org/wsvn/pf-tools/trunk/lib/PFTools/Net.pm?rev=550&op=diff
==============================================================================
--- trunk/lib/PFTools/Net.pm (original)
+++ trunk/lib/PFTools/Net.pm Thu Jan 17 15:28:12 2008
@@ -22,7 +22,7 @@
 ##  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 ##
 
-use strict;
+# use strict;
 use warnings;
 
 use Exporter;
@@ -35,6 +35,7 @@
     Get_Active_Filename
     Get_dns_from_hostname
     Get_If
+    Resolv
 
     Mk_dhcp
     Mk_pxelinuxcfg
@@ -46,6 +47,7 @@
 
 use Fcntl ':mode';
 use POSIX qw(ceil floor);
+use PFTools::Conf ;
 
 #use Data::Dumper;
 #$Data::Dumper::Sortkeys = 1;
@@ -960,6 +962,13 @@
 	    }
 	    elsif ( defined( $S->{'pxelinuxconf'}->{'default'} ) ) {
 		$M->{'pxelinuxconf'} = $S->{'pxelinuxconf'}->{'default'};
+	    }
+
+            if ( defined( $S->{'pxetemplate'}->{$mnamindexnum} ) ) {
+		$M->{'pxetemplate'} = $S->{'pxetemplate'}->{$mnamindexnum};
+	    }
+	    elsif ( defined( $S->{'pxetemplate'}->{'default'} ) ) {
+		$M->{'pxetemplate'} = $S->{'pxetemplate'}->{'default'};
 	    }
 
 	    if ( defined( $S->{'dns'}->{$mnamindexnum} ) ) {
@@ -1612,86 +1621,86 @@
     close(FIC);
 }
 
-sub Mk_pxelinuxcfg {
-    my ( $template, $Z ) = @_;
-    my $oldout;
-    my $s;
-    my $pxelinuxconfdir = dirname($template);
-    my @templatecontent;
-
-    open( PXETEMPLATE, "$template" )
-	|| die "impossible d'ouvrir " . $template . ": " . $!;
-    @templatecontent = <PXETEMPLATE>;
-    close(PXETEMPLATE);
-
-    my $dhcpvlanregex
-	= '^([^.]+)\.('
-	. join( '|', @{ $Z->{'SOA'}->{'dhcpvlan'} } )
-	. ')(\.*)?$';
-
-    foreach $s ( sort ( keys %{ $Z->{'SERVERS'}->{'BY_ADDR'} } ) ) {
-	my $m;
-	my $N = $Z->{'SERVERS'}->{'BY_ADDR'}->{$s};
-
-	foreach $m ( sort ( keys %{ $N->{'SRVLIST'} } ) ) {
-	    my $nam;
-	    my $M = $N->{'SRVLIST'}->{$m};
-
-	    foreach $nam ( sort ( keys %{ $M->{'zone'} } ) ) {
-		if ( $nam =~ /$dhcpvlanregex/ ) {
-		    my $nam2 = $1;
-
-		    #my $vlan2 = $2;
-		    if (   defined( $M->{'zone'}->{$nam}->{'ether'} )
-			&& defined( $M->{'filename'} )
-			&& defined( $M->{'pxefilename'} ) )
-		    {
-			if ( $M->{'filename'} ne 'pxelinux.0' ) {
-			    Warn( $ERR_SYNTAX,
-				      "Mk_pxelinuxconf[" 
-				    . $nam2
-				    . "]: pxefilename exists but filename is not pxelinux.0!"
-			    );
-			}
-			my $addr = Resolv( $nam . '.' . $Z->{'SOA'}->{'name'},
-			    $Z );
-			if ( defined $addr
-			    && $addr ne $nam . '.' . $Z->{'SOA'}->{'name'} )
-			{
-			    my $hexaddr = sprintf( '%02X%02X%02X%02X',
-				split( '\.', $addr ) );
-
-			    if ( -e $pxelinuxconfdir . "/" . $hexaddr ) {
-				unlink( $pxelinuxconfdir . "/" . $hexaddr );
-			    }
-
-			    open( PXELINUXCFG,
-				">" . $pxelinuxconfdir . "/" . $hexaddr )
-				|| die "impossible d'ecrire "
-				. $pxelinuxconfdir . "/"
-				. $hexaddr . ": "
-				. $!;
-			    my $temptemplatecontent
-				= join( "", @templatecontent );
-			    $temptemplatecontent
-				=~ s/%KERNEL%/$M->{pxefilename}/gs;
-			    $temptemplatecontent
-				=~ s/%INITRD%/$M->{initrd}/gs;
-			    my $ramdisk_size = Get_Ramdisk_size_from_Initrd(
-				$M->{'initrd'} );
-			    $temptemplatecontent
-				=~ s/%RAMDISK_SIZE%/$ramdisk_size/gs;
-			    my $cmdline = $M->{'cmdline'} || '';
-			    $temptemplatecontent =~ s/%CMDLINE%/$cmdline/gs;
-			    print PXELINUXCFG $temptemplatecontent;
-			    close(PXELINUXCFG);
-			}
-		    }
-		}
-	    }
-	}
-    }
-}
+# sub Mk_pxelinuxcfg {
+#     my ( $template, $Z ) = @_;
+#     my $oldout;
+#     my $s;
+#     my $pxelinuxconfdir = dirname($template);
+#     my @templatecontent;
+# 
+#     open( PXETEMPLATE, "$template" )
+# 	|| die "impossible d'ouvrir " . $template . ": " . $!;
+#     @templatecontent = <PXETEMPLATE>;
+#     close(PXETEMPLATE);
+# 
+#     my $dhcpvlanregex
+# 	= '^([^.]+)\.('
+# 	. join( '|', @{ $Z->{'SOA'}->{'dhcpvlan'} } )
+# 	. ')(\.*)?$';
+# 
+#     foreach $s ( sort ( keys %{ $Z->{'SERVERS'}->{'BY_ADDR'} } ) ) {
+# 	my $m;
+# 	my $N = $Z->{'SERVERS'}->{'BY_ADDR'}->{$s};
+# 
+# 	foreach $m ( sort ( keys %{ $N->{'SRVLIST'} } ) ) {
+# 	    my $nam;
+# 	    my $M = $N->{'SRVLIST'}->{$m};
+# 
+# 	    foreach $nam ( sort ( keys %{ $M->{'zone'} } ) ) {
+# 		if ( $nam =~ /$dhcpvlanregex/ ) {
+# 		    my $nam2 = $1;
+# 
+# 		    #my $vlan2 = $2;
+# 		    if (   defined( $M->{'zone'}->{$nam}->{'ether'} )
+# 			&& defined( $M->{'filename'} )
+# 			&& defined( $M->{'pxefilename'} ) )
+# 		    {
+# 			if ( $M->{'filename'} ne 'pxelinux.0' ) {
+# 			    Warn( $ERR_SYNTAX,
+# 				      "Mk_pxelinuxconf[" 
+# 				    . $nam2
+# 				    . "]: pxefilename exists but filename is not pxelinux.0!"
+# 			    );
+# 			}
+# 			my $addr = Resolv( $nam . '.' . $Z->{'SOA'}->{'name'},
+# 			    $Z );
+# 			if ( defined $addr
+# 			    && $addr ne $nam . '.' . $Z->{'SOA'}->{'name'} )
+# 			{
+# 			    my $hexaddr = sprintf( '%02X%02X%02X%02X',
+# 				split( '\.', $addr ) );
+# 
+# 			    if ( -e $pxelinuxconfdir . "/" . $hexaddr ) {
+# 				unlink( $pxelinuxconfdir . "/" . $hexaddr );
+# 			    }
+# 
+# 			    open( PXELINUXCFG,
+# 				">" . $pxelinuxconfdir . "/" . $hexaddr )
+# 				|| die "impossible d'ecrire "
+# 				. $pxelinuxconfdir . "/"
+# 				. $hexaddr . ": "
+# 				. $!;
+# 			    my $temptemplatecontent
+# 				= join( "", @templatecontent );
+# 			    $temptemplatecontent
+# 				=~ s/%KERNEL%/$M->{pxefilename}/gs;
+# 			    $temptemplatecontent
+# 				=~ s/%INITRD%/$M->{initrd}/gs;
+# 			    my $ramdisk_size = Get_Ramdisk_size_from_Initrd(
+# 				$M->{'initrd'} );
+# 			    $temptemplatecontent
+# 				=~ s/%RAMDISK_SIZE%/$ramdisk_size/gs;
+# 			    my $cmdline = $M->{'cmdline'} || '';
+# 			    $temptemplatecontent =~ s/%CMDLINE%/$cmdline/gs;
+# 			    print PXELINUXCFG $temptemplatecontent;
+# 			    close(PXELINUXCFG);
+# 			}
+# 		    }
+# 		}
+# 	    }
+# 	}
+#     }
+# }
 
 sub Mk_zoneheader {
     my ( $fic_zone, $Z ) = @_;

Modified: trunk/lib/PFTools/Update.pm
URL: http://svn.debian.org/wsvn/pf-tools/trunk/lib/PFTools/Update.pm?rev=550&op=diff
==============================================================================
--- trunk/lib/PFTools/Update.pm (original)
+++ trunk/lib/PFTools/Update.pm Thu Jan 17 15:28:12 2008
@@ -4,7 +4,7 @@
 ##
 ##  Copyright (C) 2007 Christophe Caillet <tof at sitadelle.com>
 ##  Copyright (C) 2004-2007 Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>
-##  Copyright (C) 2004 Gonéri Le Bouder <goneri at sitadelle.com>
+##  Copyright (C) 2004 Gon�ri Le Bouder <goneri at sitadelle.com>
 ##  Copyright (C) 2003-2005 Damien Clermonte <damien at sitadelle.com>
 ##  Copyright (C) 2001-2003 Olivier Molteni <olivier at molteni.net>
 ##
@@ -23,7 +23,7 @@
 ##  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 ##
 
-use strict;
+# use strict;
 use warnings;
 
 use Exporter;
@@ -32,9 +32,10 @@
 
 our @EXPORT = qw(
     $ERR_OPEN
+    $ERR_SYNTAX
 
     Get_source
-
+    dirname
     Do_update
 );
 
@@ -53,7 +54,7 @@
 
 # Error code
 our $ERR_OPEN = 1;
-my $ERR_SYNTAX = 2;
+our $ERR_SYNTAX = 2;
 
 $ENV{'PATH'}            = $ENV{'PATH'} . ":/usr/local/sbin:/usr/local/bin";
 $ENV{'DEBIAN_FRONTEND'} = "noninteractive";




More information about the pf-tools-commits mailing list