pf-tools commit: r549 [ccaillet-guest] - in /branches/0.32-stable: debian/changelog lib-net

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Thu Jan 17 13:22:18 UTC 2008


Author: ccaillet-guest
Date: Thu Jan 17 13:22:17 2008
New Revision: 549

URL: http://svn.debian.org/wsvn/pf-tools/?sc=1&rev=549
Log:
* adding pxetemplate key. It permits to have different templates for PXE
  configuration file.

Modified:
    branches/0.32-stable/debian/changelog
    branches/0.32-stable/lib-net

Modified: branches/0.32-stable/debian/changelog
URL: http://svn.debian.org/wsvn/pf-tools/branches/0.32-stable/debian/changelog?rev=549&op=diff
==============================================================================
--- branches/0.32-stable/debian/changelog (original)
+++ branches/0.32-stable/debian/changelog Thu Jan 17 13:22:17 2008
@@ -1,5 +1,6 @@
 pf-tools (0.32.48-0.WIP) unstable; urgency=low
 
+  [ Thomas Parmelan ]
   * WORK IN PROGRESS
 
   * pflaunch uses Sitalibs::Config instead of lib-net's Load_conf((), but
@@ -13,7 +14,11 @@
     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
+  [ 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
 
 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=549&op=diff
==============================================================================
--- branches/0.32-stable/lib-net (original)
+++ branches/0.32-stable/lib-net Thu Jan 17 13:22:17 2008
@@ -899,6 +899,13 @@
                 $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} ) ) {
                 $M->{dns} = $S->{dns}->{$mnamindexnum};
             }
@@ -1551,10 +1558,11 @@
     my $s;
     my $pxelinuxconfdir = dirname($template);
     my @templatecontent;
+    my $hash_tpl = {} ;
 
     open( PXETEMPLATE, "$template" )
       || die "impossible d'ouvrir " . $template . ": " . $!;
-    @templatecontent = <PXETEMPLATE>;
+    @{$hash_tpl->{'default'}} = <PXETEMPLATE>;
     close(PXETEMPLATE);
 
     my $dhcpvlanregex =
@@ -1599,8 +1607,23 @@
                                 ">" . $pxelinuxconfdir . "/" . $hexaddr )
                               || die "impossible d'ecrire "
                               . $pxelinuxconfdir . "/" . $hexaddr . ": " . $!;
-                            my $temptemplatecontent =
-                              join ( "", @templatecontent );
+
+                            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}} ) ;
+                            }
 
 			    $temptemplatecontent =~ s/%KERNEL%/$M->{pxefilename}/gs;
 			    $temptemplatecontent =~ s/%INITRD%/$M->{initrd}/gs;




More information about the pf-tools-commits mailing list