pf-tools commit: r559 [parmelan-guest] - in /trunk: README.doc sbin/mk_pxelinuxcfg
parmelan-guest at users.alioth.debian.org
parmelan-guest at users.alioth.debian.org
Fri Jan 18 12:49:32 UTC 2008
Author: parmelan-guest
Date: Fri Jan 18 12:49:31 2008
New Revision: 559
URL: http://svn.debian.org/wsvn/pf-tools/?sc=1&rev=559
Log:
* "forward port" my pxetemplate "documentation + simplification" from the stable branch.
* Revert two debug-related modifications that shouldn't have been committed :
- use Data::Dumper is not needed
- Get_Ramdisk_size_from_Initrd() must be used
Modified:
trunk/README.doc
trunk/sbin/mk_pxelinuxcfg
Modified: trunk/README.doc
URL: http://svn.debian.org/wsvn/pf-tools/trunk/README.doc?rev=559&op=diff
==============================================================================
--- trunk/README.doc (original)
+++ trunk/README.doc Fri Jan 18 12:49:31 2008
@@ -24,6 +24,25 @@
cmdline.default = noapic
cmdline.0 = noapic pci=noirq
+* 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: trunk/sbin/mk_pxelinuxcfg
URL: http://svn.debian.org/wsvn/pf-tools/trunk/sbin/mk_pxelinuxcfg?rev=559&op=diff
==============================================================================
--- trunk/sbin/mk_pxelinuxcfg (original)
+++ trunk/sbin/mk_pxelinuxcfg Fri Jan 18 12:49:31 2008
@@ -26,20 +26,18 @@
use PFTools::Net;
use PFTools::Update;
-use Data::Dumper ;
sub Mk_pxe_bootfile ($;$) {
- my ( $Z, $template ) = @_;
+ my ( $Z, $default_template ) = @_;
my $oldout;
my $s;
- my $hash_tpl = {} ;
+ my $templates = {};
- my $pxelinuxconfdir = dirname ( $template ) ;
- unless ( open ( TPL, $template ) ) {
- die "Unable to open file ".$template.": ".$!."\n" ;
- }
- @{$hash_tpl->{'default'}} = <TPL> ;
- close ( TPL ) ;
+ my $pxelinuxconfdir = dirname ( $default_template );
+ open TPL, $default_template)
+ or die "Unable to open $default_template: $!\n";
+ @{ $templates->{$default_template} } = <TPL>;
+ close TPL;
my $dhcpvlanregex
= '^([^.]+)\.('
@@ -88,27 +86,19 @@
. $hexaddr . ": "
. $!;
- my $temptemplatecontent ;
- if ( ! defined ( $M->{'pxetemplate'} ) ) {
- $temptemplatecontent = join ( "", @{$hash_tpl->{'default'}} ) ;
- } else {
- my $tpl_name ;
- $tpl_name = $M->{'pxetemplate'} ;
- $tpl_name =~ s%.*/%%;
- if ( ! defined ( $hash_tpl->{$tpl_name} ) ) {
- my $tpl ;
- ( $M->{'pxetemplate'} =~ /^\// ) ? $tpl = $M->{'pxetemplate'} : $tpl = $pxelinuxconfdir."/".$M->{'pxetemplate'};
- print "Need to open ".$tpl."\n" ;
- 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;
-# my $ramdisk_size = Get_Ramdisk_size_from_Initrd($M->{'initrd'} );
- my $ramdisk_size = 4096 ;
+ 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;
More information about the pf-tools-commits
mailing list