pf-tools commit: r603 [ccaillet-guest] - in /trunk: Makefile README.doc debian/changelog lib/PFTools/Net.pm sbin/mk_pxelinuxcfg templates/debian-installer

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Thu Jul 10 12:06:44 UTC 2008


Author: ccaillet-guest
Date: Thu Jul 10 12:06:44 2008
New Revision: 603

URL: http://svn.debian.org/wsvn/pf-tools/?sc=1&rev=603
Log:
* preparing release
* modifying Makefile for templates which are now installed on
  /usr/share/pf-tools/templates 
* adding the preseed template for debian-installer
* removing the useless directive preseedfilename on private-network
  configuration 
* adding automatic generation for preseed file when using debian-installer
  mechansim on mk_pxelinuxcfg tool
* No need of ramdisk size calculation if host deployment uses
  debian-installer 
* adding deploymode key for specifying the deployment mode : pf-tools or
  debian-installer. If not defined we keep the pf-tools mode as default 

Modified:
    trunk/Makefile
    trunk/README.doc
    trunk/debian/changelog
    trunk/lib/PFTools/Net.pm
    trunk/sbin/mk_pxelinuxcfg
    trunk/templates/debian-installer

Modified: trunk/Makefile
URL: http://svn.debian.org/wsvn/pf-tools/trunk/Makefile?rev=603&op=diff
==============================================================================
--- trunk/Makefile (original)
+++ trunk/Makefile Thu Jul 10 12:06:44 2008
@@ -4,7 +4,7 @@
 SBIN_DIR=$(DESTDIR)/usr/sbin
 FILTERS_DIR=$(DESTDIR)/usr/sbin
 CONF_DIR=$(DESTDIR)/etc
-TPL_DIR=$(DESTDIR)/usr/share/pf-tools/pxetemplates
+TPL_DIR=$(DESTDIR)/usr/share/pf-tools/templates
 INSTALLERS_DIR=$(DESTDIR)/usr/share/pf-tools
 
 SBIN=sbin/*

Modified: trunk/README.doc
URL: http://svn.debian.org/wsvn/pf-tools/trunk/README.doc?rev=603&op=diff
==============================================================================
--- trunk/README.doc (original)
+++ trunk/README.doc Thu Jul 10 12:06:44 2008
@@ -84,6 +84,30 @@
     [host%%]
 	...
 	console.1 = default
+
+* deploymode
+
+  [optional]
+
+  If defined, the value of this directive specifies the deployment mode used
+  to deploy the host. Allowed values are : pf-tools or debian-installer. If not
+  defined the default value is pf-tools.
+
+  Sample use :
+
+    To define debian-installer for default deployment mode for host%%
+
+    [host%%]
+	...
+	deploymode.default	= debian-installer
+
+    To define pf-tools mode for default deployment and debian-installer for
+    host00
+
+    [host%%]
+	...
+	deploymode.default	= pf-tools
+	deploymode.0		= debian-installer
 
 * <iface>.route%.HOSTNUM
 
@@ -181,21 +205,6 @@
         ipstart.vlan-system = 18.0
         ip.vlan-systeme.1   = 18.10
 
-* preseedfilename
-
-  [optional]
-
-  If defined, it uses this filename for getting on deploy.private the preseed file
-  for automated debian-installer process
-
-  Sample use :
-
-    To use a preseed file : debian-preseed.txt for host01
-
-    [host%%]
-	...
-	preseedfilename.1	= debian-preseed.txt
-
 * pxetemplate
 
   [optional]

Modified: trunk/debian/changelog
URL: http://svn.debian.org/wsvn/pf-tools/trunk/debian/changelog?rev=603&op=diff
==============================================================================
--- trunk/debian/changelog (original)
+++ trunk/debian/changelog Thu Jul 10 12:06:44 2008
@@ -1,3 +1,11 @@
+pf-tools (0.33-0+RC1) unstable; urgency=low
+
+  * preparing release
+  * modifying Makefile for templates which are now installed on
+    /usr/share/pf-tools/templates 
+
+ -- Christophe Caillet <quadchris at free.fr>  Thu, 10 Jul 2008 14:00:56 +0200
+
 pf-tools (0.33-0WIP2) unstable; urgency=low
 
   [ Christophe Caillet ]
@@ -15,8 +23,17 @@
     introduced by fixes on Mk_zone and Add_server
   * Adding the new syntax for avoiding duplication of values when we declare a
     tagged interface (see README.doc for more explanations) 
-
- -- Christophe Caillet <quadchris at free.fr>  Mon, 09 Jun 2008 11:42:30 +0200
+  * adding the preseed template for debian-installer
+  * removing the useless directive preseedfilename on private-network
+    configuration 
+  * adding automatic generation for preseed file when using debian-installer
+    mechansim on mk_pxelinuxcfg tool
+  * No need of ramdisk size calculation if host deployment uses
+    debian-installer 
+  * adding deploymode key for specifying the deployment mode : pf-tools or
+    debian-installer. If not defined we keep the pf-tools mode as default 
+
+ -- Christophe Caillet <quadchris at free.fr>  Thu, 10 Jul 2008 13:49:47 +0200
 
 pf-tools (0.33-0WIP1) unstable; urgency=low
 

Modified: trunk/lib/PFTools/Net.pm
URL: http://svn.debian.org/wsvn/pf-tools/trunk/lib/PFTools/Net.pm?rev=603&op=diff
==============================================================================
--- trunk/lib/PFTools/Net.pm (original)
+++ trunk/lib/PFTools/Net.pm Thu Jul 10 12:06:44 2008
@@ -73,6 +73,9 @@
 
 # Allowed architecture
 my $ALLOWED_ARCH = 'i386|amd64' ;
+# Allowed deploymode
+my $ALLOWED_DEPLOYMODE = 'pf-tools|debian-installer' ;
+
 
 #=======================================================#
 #							#
@@ -921,7 +924,7 @@
 		'vmwfilename',
 		'pxelinuxconf',
 		'pxetemplate',
-		'preseedfilename',
+		'deploymode',
 		'dns',
 		'arch',
 		'initrd',
@@ -932,16 +935,24 @@
 		if ( defined ( $S->{$key}->{$mnamindexnum} ) ) {
 		    if ( $key eq 'arch' && $S->{$key}->{$mnamindexnum} !~ /^$ALLOWED_ARCH$/ ) {
 			Abort( $ERR_SYNTAX, "Invalid architecture ".$S->{$key}->{$mnamindexnum} ) ;
+		    } elsif ( $key eq 'deploymode' ) {
+			Abort ( $ERR_SYNTAX, "Invalid deploymode key ".$S->{$key}->{$mnamindexnum} )
+				if ( $S->{$key}->{$mnamindexnum} !~ /^$ALLOWED_DEPLOYMODE$/ ) ;
+			Warn ( $ERR_SYNTAX, "No need to defined initrd" ) if ( defined $S->{'initrd'}->{$mnamindexnum} ) ;
 		    }
 		    $M->{$key} = $S->{$key}->{$mnamindexnum} ;
 		}
 		elsif ( defined ( $S->{$key}->{'default'} ) ) {
 		    if ( $key eq 'arch' && $S->{$key}->{'default'} !~ /^$ALLOWED_ARCH$/ ) {
 			Abort( $ERR_SYNTAX, "Invalid architecture ".$S->{$key}->{'default'} ) ;
+		    } elsif ( $key eq 'deploymode' ) {
+			Abort ( $ERR_SYNTAX, "Invalid deploymode key ".$S->{$key}->{'default'} )
+				if ( $S->{$key}->{'default'} !~ /^$ALLOWED_DEPLOYMODE$/ ) ;
+			Warn ( $ERR_SYNTAX, "No need to defined initrd" ) if ( defined $S->{'initrd'} ) ;
 		    }
 		    $M->{$key} = $S->{$key}->{'default'} ;
 		}
-		elsif ( $key eq 'initrd' ) {
+		elsif ( $key eq 'initrd' && $M->{'deploymode'} eq 'pf-tools' ) {
 		    $M->{'initrd'} = 'initrd' ;
 		}
 		elsif ( $key eq 'arch' ) {

Modified: trunk/sbin/mk_pxelinuxcfg
URL: http://svn.debian.org/wsvn/pf-tools/trunk/sbin/mk_pxelinuxcfg?rev=603&op=diff
==============================================================================
--- trunk/sbin/mk_pxelinuxcfg (original)
+++ trunk/sbin/mk_pxelinuxcfg Thu Jul 10 12:06:44 2008
@@ -27,15 +27,71 @@
 use Digest::MD5;
 use PFTools::Net;
 use PFTools::Update;
-
-my $DEPLOY_DOCROOT = "/var/www";
+use File::Compare ;
+use File::Copy ;
+
+my $DEPLOY_DOCROOT	= "/var/www";
+my $PRESEED_REPOS	= $DEPLOY_DOCROOT."/preseed" ;
+
+if ( ! -e $PRESEED_REPOS ) {
+	mkdir $PRESEED_REPOS ;
+	my ($login,$pass,$uid,$gid) = getpwnam ( 'www-data' ) ;
+	chown $uid, $gid, $PRESEED_REPOS ;
+	my $mode = '2750' ;
+	chmod $mode, $PRESEED_REPOS ;
+}
+
+my $TPL_PRESEED		= "/usr/share/pf-tools/templates/debian-preseed.tpl" ;
+my $DEFAULT_PRESEED	= $PRESEED_REPOS."/default_preseed.txt" ;
+
+sub Get_kpkg_from_pxefilename ($) {
+	my ( $pxefilename ) = @_ ;
+	
+	if ( $pxefilename =~ /pxe/ ) {
+		my ( $vm, $type, $pxe, $version, @append ) = split ( /-/, $pxefilename ) ;
+		return "linux-image-".$version."-".$type."-".join ( "-", @append ) ;
+	}
+	else {
+		my ( $vm, $version, $type, $append_version ) = split ( /-/, $pxefilename ) ;
+		return "linux-image-".$version."-".$type."-".$append_version ;
+	}
+}
+
+sub Build_preseed_filename ($$) {
+	my ( $srv_name, $ref_srv ) = @_ ;
+	
+	if ( ! open ( PRESEED_TPL, $TPL_PRESEED ) ) {
+		warn "Unable to get preseed template from file ".$TPL_PRESEED."\n" ;
+		return $DEFAULT_PRESEED ;
+	}
+	my $preseed_content = join '', <PRESEED_TPL> ;
+	close ( PRESEED_TPL ) ;
+	my $deb_kernel = Get_kpkg_from_pxefilename ( $ref_srv->{'pxefilename'} ) ;
+	$preseed_content =~ s/%KERNELPKG%/$deb_kernel/gs ;
+	if ( ! open ( DST_PRESEED, ">/tmp/tmp_preseed" ) ) {
+		warn "Unable to create preseed file /tmp_preseed\n" ;
+		return $DEFAULT_PRESEED ;
+	}
+	print DST_PRESEED $preseed_content ;
+	close ( DST_PRESEED ) ;
+	my $src = "/tmp/tmp_preseed" ;
+	my $dst = $PRESEED_REPOS."/preseed_".$srv_name ;
+	if ( compare ( $src, $dst ) ) {
+		move ($src, $dst) ;
+	} else {
+		if ( ! unlink ( $src ) ) {
+			warn "Unable to unlink source file ".$src."\n" ;
+		}
+	}
+	return "preseed_".$srv_name ;
+}
 
 sub Get_MD5SUM_from_preseedfilename ($) {
 	my ( $filename ) = @_;
 	my ( $md5, $hdl );
 	
 	$md5 = Digest::MD5->new;
-	open $hdl, $DEPLOY_DOCROOT."/".$filename || return undef;
+	open $hdl, $PRESEED_REPOS."/".$filename || return undef;
 	$md5->addfile ( $hdl );
 	return $md5->hexdigest;
 }
@@ -64,6 +120,8 @@
 			foreach my $m ( sort ( keys %{ $host->{'SRVLIST'} } ) ) {
 				my $nam;
 				my $M = $host->{'SRVLIST'}->{$m};
+				my $debian_installer ;
+				( defined $M->{'deploymode'} && $M->{'deploymode'} eq 'debian-installer' ) ? $debian_installer = 1 : $debian_installer = 0 ;
 	
 				foreach $nam ( sort ( keys %{ $M->{'zone'} } ) ) {
 					if ( $nam =~ /$dhcpvlanregex/ ) {
@@ -100,6 +158,7 @@
 										. $!;
 								
 								my $template_name = $M->{'pxetemplate'} ? $M->{'pxetemplate'} : $default_template;
+								$debian_installer = 1 if ( $template_name eq 'debian-installer' ) ;
 								unless (defined $templates->{$template_name}) {
 									my $tpl = ( ($template_name =~ m/^\//) ? '' : "$pxelinuxconfdir/" )
 										. $template_name;
@@ -110,23 +169,26 @@
 	
 								my $temptemplatecontent = join '', @{ $templates->{$template_name} };
 	
-								$temptemplatecontent =~ s/%KERNEL%/$M->{pxefilename}/gs;
-								$temptemplatecontent =~ s/%INITRD%/$M->{initrd}/gs;
+								$temptemplatecontent =~ s/%KERNEL%/$M->{'pxefilename'}/gs;
 								
-								if ( defined $M->{'preseedfilename'} ) {
+								if ( $debian_installer ) {
+									# Building preseed file
+									my $preseed_file = Build_preseed_filename ( $m, $M ) ;
+									# MD5sum on generated preseed file
 									$temptemplatecontent =~
-										s/%PRESEED_URL%/http:\/\/deploy.private\/$M->{preseedfilename}/gs;
-									my $preseed_md5 = Get_MD5SUM_from_preseedfilename ( $M->{'preseedfilename'} );
+										s/%PRESEED_URL%/http:\/\/deploy.private\/preseed\/$preseed_file/gs;
+									my $preseed_md5 = Get_MD5SUM_from_preseedfilename ( $preseed_file ) ;
 									if ( ! defined $preseed_md5 ) {
 										die "Unable to get md5dum for preseed filename "
-											.$M->{'preseedfilename'}." for host ".$m."\n" ;
+											.$preseed_file." for host ".$m."\n" ;
 									}
 									$temptemplatecontent =~ s/%PRESEED_MD5%/$preseed_md5/gs;
+								} else {
+									my $ramdisk_size = Get_Ramdisk_size_from_Initrd($M->{'initrd'} );
+									$temptemplatecontent =~ s/%RAMDISK_SIZE%/$ramdisk_size/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 $arch = $M->{'arch'} || 'i386' ;
 								$temptemplatecontent =~ s/%ARCH%/$arch/gs;
 	

Modified: trunk/templates/debian-installer
URL: http://svn.debian.org/wsvn/pf-tools/trunk/templates/debian-installer?rev=603&op=diff
==============================================================================
--- trunk/templates/debian-installer (original)
+++ trunk/templates/debian-installer Thu Jul 10 12:06:44 2008
@@ -5,7 +5,7 @@
 
 LABEL install
 	kernel debian-installer/%ARCH%/linux
-	append DEBCONF_PRIORITY=critical vga=normal auto=true initrd=%INITRD% interface=eth0 netcfg/no_default_route=true url=%PRESEED_URL% url/checksum=%PRESEED_MD5% -- %CONSOLE% %CMDLINE%
+	append DEBCONF_PRIORITY=critical vga=normal auto=true initrd=debian-installer/%ARCH%/initrd.gz interface=eth0 netcfg/no_default_route=true url=%PRESEED_URL% url/checksum=%PRESEED_MD5% -- %CONSOLE% %CMDLINE%
 
 LABEL linux
 	kernel %KERNEL%




More information about the pf-tools-commits mailing list