pf-tools commit: r558 [parmelan-guest] - in /branches/0.32-stable: README.doc debian/changelog lib-net pflaunch

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Fri Jan 18 12:21:48 UTC 2008


Author: parmelan-guest
Date: Fri Jan 18 12:21:48 2008
New Revision: 558

URL: http://svn.debian.org/wsvn/pf-tools/?sc=1&rev=558
Log:
pxetemplate: documentation + simplification.

Modified:
    branches/0.32-stable/README.doc
    branches/0.32-stable/debian/changelog
    branches/0.32-stable/lib-net
    branches/0.32-stable/pflaunch

Modified: branches/0.32-stable/README.doc
URL: http://svn.debian.org/wsvn/pf-tools/branches/0.32-stable/README.doc?rev=558&op=diff
==============================================================================
--- branches/0.32-stable/README.doc (original)
+++ branches/0.32-stable/README.doc Fri Jan 18 12:21:48 2008
@@ -46,6 +46,25 @@
 	...
 	console.1 = default
 
+* pxetemplate
+
+  [optional]
+
+  If defined, the value of this directive is used as the filename of the PXE
+  template file to use for this host, instead of the default value. If it is
+  not an absolute path, the directory component of the default value will be
+  used. (Note: The default value is the argument given to the mk_pxelinuxcfg
+  program).
+
+  Sample use :
+
+    To use "/path/to/my/pxe-template" instead of the default value for all
+    host%% servers :
+
+    [host%%]
+	...
+	pxetemplate.default = /path/to/my/pxe-template
+
 
 ========================================================================
 update-* :

Modified: branches/0.32-stable/debian/changelog
URL: http://svn.debian.org/wsvn/pf-tools/branches/0.32-stable/debian/changelog?rev=558&op=diff
==============================================================================
--- branches/0.32-stable/debian/changelog (original)
+++ branches/0.32-stable/debian/changelog Fri Jan 18 12:21:48 2008
@@ -1,8 +1,8 @@
 pf-tools (0.32.48-0.WIP) unstable; urgency=low
 
+  * WORK IN PROGRESS
+
   [ Thomas Parmelan ]
-  * WORK IN PROGRESS
-
   * pflaunch uses Sitalibs::Config instead of lib-net's Load_conf((), but
     Sitalibs::Config does not understand theses comments :
 
@@ -15,10 +15,9 @@
     things (such as trying to use "1.2.3.4 # FIXME" as an IP address).
 
   [ Christophe Caillet ]
-  * adding pxetemplate key. It permits to have different templates for PXE
-    configuration file.
-
- -- Christophe Caillet <tof at sitadelle.com>  Thu, 17 Jan 2008 14:19:30 +0100
+  * new (optional) "pxetemplate" directive (see README.doc for more information).
+
+ -- Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>  Fri, 18 Jan 2008 11:44:27 +0100
 
 pf-tools (0.32.47-1) unstable; urgency=low
 

Modified: branches/0.32-stable/lib-net
URL: http://svn.debian.org/wsvn/pf-tools/branches/0.32-stable/lib-net?rev=558&op=diff
==============================================================================
--- branches/0.32-stable/lib-net (original)
+++ branches/0.32-stable/lib-net Fri Jan 18 12:21:48 2008
@@ -899,12 +899,12 @@
                 $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->{pxetemplate}->{$mnamindexnum} ) ) {
+		$M->{pxetemplate} = $S->{pxetemplate}->{$mnamindexnum};
+	    }
+	    elsif ( defined( $S->{pxetemplate}->{default} ) ) {
+		$M->{pxetemplate} = $S->{pxetemplate}->{default};
+	    }
 
             if ( defined( $S->{dns}->{$mnamindexnum} ) ) {
                 $M->{dns} = $S->{dns}->{$mnamindexnum};
@@ -1553,17 +1553,17 @@
 }
 
 sub Mk_pxelinuxcfg {
-    my ( $template, $Z ) = @_;
+    my ($default_template, $Z) = @_;
     my $oldout;
     my $s;
-    my $pxelinuxconfdir = dirname($template);
+    my $pxelinuxconfdir = dirname($default_template);
     my @templatecontent;
-    my $hash_tpl = {} ;
-
-    open( PXETEMPLATE, "$template" )
-      || die "impossible d'ouvrir " . $template . ": " . $!;
-    @{$hash_tpl->{'default'}} = <PXETEMPLATE>;
-    close(PXETEMPLATE);
+    my $templates = {} ;
+
+    open PXETEMPLATE, "$default_template"
+	or die "Impossible d'ouvrir $default_template : $!\n";
+    @{ $templates->{$default_template} } = <PXETEMPLATE>;
+    close PXETEMPLATE;
 
     my $dhcpvlanregex =
       '^([^.]+)\.(' . join ( '|', @{ $Z->{SOA}->{dhcpvlan} } ) . ')(\.*)?$';
@@ -1608,22 +1608,15 @@
                               || die "impossible d'ecrire "
                               . $pxelinuxconfdir . "/" . $hexaddr . ": " . $!;
 
-                            my $temptemplatecontent ;
-                            if ( ! defined ( $M->{'pxetemplate'} ) ) {
-                                $temptemplatecontent = join ( "", @{$hash_tpl->{'default'}} ) ;
-                            } else {
-                                my $tpl_name ;
-                                $tpl_name = $M->{'pxetemplate'} ;
-                                $tpl_name =~ s%.*/%%; #cheap basename
-                                if ( ! defined ( $hash_tpl->{$tpl_name} ) ) {
-                                    my $tpl ;
-                                    ( $M->{'pxetemplate'} =~ /^\// ) ? $tpl = $M->{'pxetemplate'} : $tpl = $pxelinuxconfdir."/".$M->{'pxetemplate'};
-                                    open ( TPL, $tpl ) || die "impossible d'ouvrir " . $tpl . ": " . $!;
-                                    @{$hash_tpl->{$tpl_name}} = <TPL> ;
-                                    close ( TPL ) ;
-                                }
-                                $temptemplatecontent = join ( "", @{$hash_tpl->{$tpl_name}} ) ;
-                            }
+			    my $template_name = $M->{'pxetemplate'} ? $M->{'pxetemplate'} : $default_template;
+			    unless (defined $templates->{$template_name}) {
+				my $tpl = ( ($template_name =~ m/^\//) ? '' : "$pxelinuxconfdir/" ) . $template_name;
+				open PXETEMPLATE, $tpl or die "Impossible d'ouvrir $tpl : . $!\n";
+				@{ $templates->{$template_name} } = <PXETEMPLATE> ;
+				close PXETEMPLATE;
+			    }
+
+			    my $temptemplatecontent = join '', @{ $templates->{$template_name} };
 
 			    $temptemplatecontent =~ s/%KERNEL%/$M->{pxefilename}/gs;
 			    $temptemplatecontent =~ s/%INITRD%/$M->{initrd}/gs;

Modified: branches/0.32-stable/pflaunch
URL: http://svn.debian.org/wsvn/pf-tools/branches/0.32-stable/pflaunch?rev=558&op=diff
==============================================================================
--- branches/0.32-stable/pflaunch (original)
+++ branches/0.32-stable/pflaunch Fri Jan 18 12:21:48 2008
@@ -84,7 +84,7 @@
 }
 
 #
-#   update-config vire les commentaires, mais pas Sitalbis::Config ...
+#   update-config vire les commentaires, mais pas Sitalibs::Config ...
 #
 sub __suppress_comments_in_keys {
     my ($a) = @_;




More information about the pf-tools-commits mailing list