pf-tools commit: r599 [ccaillet-guest] - in /trunk: debian/changelog sbin/mk_dhcp sbin/mk_pxelinuxcfg
parmelan-guest at users.alioth.debian.org
parmelan-guest at users.alioth.debian.org
Tue Jun 3 15:07:56 UTC 2008
Author: ccaillet-guest
Date: Tue Jun 3 15:07:55 2008
New Revision: 599
URL: http://svn.debian.org/wsvn/pf-tools/?sc=1&rev=599
Log:
Patching mk_dhcp and mk_pxelinux according to changes on HASH structure
introduced by fixes on Mk_zone and Add_server
Modified:
trunk/debian/changelog
trunk/sbin/mk_dhcp
trunk/sbin/mk_pxelinuxcfg
Modified: trunk/debian/changelog
URL: http://svn.debian.org/wsvn/pf-tools/trunk/debian/changelog?rev=599&op=diff
==============================================================================
--- trunk/debian/changelog (original)
+++ trunk/debian/changelog Tue Jun 3 15:07:55 2008
@@ -11,8 +11,10 @@
* updating README.doc with new options
* Fix a bug on Mk_zone and Add_server to avoid a potential information loss
on certain configuration cases
-
- -- Christophe Caillet <quadchris at free.fr> Tue, 03 Jun 2008 16:19:02 +0200
+ * Patching mk_dhcp and mk_pxelinux according to changes on HASH structure
+ introduced by fixes on Mk_zone and Add_server
+
+ -- Christophe Caillet <quadchris at free.fr> Tue, 03 Jun 2008 17:06:39 +0200
pf-tools (0.33-0WIP1) unstable; urgency=low
Modified: trunk/sbin/mk_dhcp
URL: http://svn.debian.org/wsvn/pf-tools/trunk/sbin/mk_dhcp?rev=599&op=diff
==============================================================================
--- trunk/sbin/mk_dhcp (original)
+++ trunk/sbin/mk_dhcp Tue Jun 3 15:07:55 2008
@@ -65,116 +65,83 @@
print "\n";
foreach $s ( sort ( keys %{ $Z->{'SERVERS'}->{'BY_ADDR'} } ) ) {
- my $m;
- my $N = $Z->{'SERVERS'}->{'BY_ADDR'}->{$s};
+ foreach my $host ( @{$Z->{'SERVERS'}->{'BY_ADDR'}->{$s}} ) {
- print "# ", $N->{'comment'}, "\n";
- print "# number: ", $N->{'number'}, "\n";
- print "# nodes: ", $N->{'nodes'}, "\n"
- if ( defined( $N->{'nodes'} ) && $N->{'nodes'} > 1 );
- print "\n";
+ print "# ", $host->{'comment'}, "\n";
+ print "# number: ", $host->{'number'}, "\n";
+ print "# nodes: ", $host->{'nodes'}, "\n" if ( defined( $host->{'nodes'} ) && $host->{'nodes'} > 1 );
+ print "\n";
- foreach $m ( sort ( keys %{ $N->{'SRVLIST'} } ) ) {
- my $nam;
- my $M = $N->{'SRVLIST'}->{$m};
+ foreach my $m ( sort ( keys %{ $host->{'SRVLIST'} } ) ) {
+ my $nam;
+ my $M = $host->{'SRVLIST'}->{$m};
- foreach $nam ( sort ( keys %{ $M->{'zone'} } ) ) {
- if ( $nam =~ /$dhcpvlanregex/ ) {
- my $nam2 = $1;
+ foreach $nam ( sort ( keys %{ $M->{'zone'} } ) ) {
+ if ( $nam =~ /$dhcpvlanregex/ ) {
+ my $nam2 = $1;
- #my $vlan2 = $2;
+ my $hostnum = $nam2;
+ $hostnum =~ s/^.*?(\d*)[a-z]*$/$1/;
+ $hostnum =~ s/^0*//;
+ if ( $hostnum eq "" ) { $hostnum = 0; }
- my $hostnum = $nam2;
- $hostnum =~ s/^.*?(\d*)[a-z]*$/$1/;
- $hostnum =~ s/^0*//;
- if ( $hostnum eq "" ) {
- $hostnum = 0;
- }
+ if ( defined( $M->{'zone'}->{$nam}->{'ether'} ) ) {
+ printf( "host %s {\n", $nam2 );
+ printf( " hardware ethernet %s;\n", $M->{'zone'}->{$nam}->{'ether'} );
+ printf( " fixed-address %s.%s;\n", $nam, $Z->{'SOA'}->{'name'} );
- if ( defined( $M->{'zone'}->{$nam}->{'ether'} ) ) {
- printf( "host %s {\n", $nam2 );
- printf( " hardware ethernet %s;\n",
- $M->{'zone'}->{$nam}->{'ether'} );
- printf( " fixed-address %s.%s;\n",
- $nam, $Z->{'SOA'}->{'name'} );
+ if ( defined( $M->{'filename'} ) && $M->{'filename'} ne "" ) {
+ printf( " filename \"%s\";\n", $M->{'filename'} );
+ }
- if ( defined( $M->{'filename'} )
- && $M->{'filename'} ne "" )
- {
- printf( " filename \"%s\";\n",
- $M->{'filename'} );
+ if ( $M->{'initrd'} ) { printf qq{# initrd "%s";\n}, $M->{'initrd'}; }
+
+ if ( $M->{'cmdline'} ) { printf qq{# cmdline "%s";\n}, $M->{'cmdline'}; }
+
+ if ( $M->{'console'} ) { printf qq{# console "%s";\n}, $M->{'console'}; }
+
+ if ( defined( $M->{'pxefilename'} ) && $M->{'pxefilename'} ne "" ) {
+ printf( "# pxefilename \"%s\";\n", $M->{'pxefilename'} );
+ }
+
+ if ( defined( $M->{'pxelinuxconf'} ) && $M->{'pxelinuxconf'} ne "" ) {
+ printf( " option option-209 \"%s\";\n", $M->{'pxelinuxconf'} );
+ }
+
+ my @dns = Get_dns_from_zone( $Z, $M, $hostnum );
+
+ if ( $#dns >= 0 && defined $dns[0] ) {
+ printf( " option domain-name-servers %s;\n", join( ", ", @dns ) );
+ }
+
+ print "}\n\n";
}
+ if ( defined( $M->{'zone'}->{$nam}->{'vmether'} ) && ( $PFTOOLS_VARS->{'VMWARE'} || $PFTOOLS_VARS->{'UML'} ) ) {
+ printf( "host %s {\n", $nam2 );
+ printf( " hardware ethernet %s;\n", $M->{'zone'}->{$nam}->{'vmether'} );
+ printf( " fixed-address %s.%s;\n", $nam, $Z->{'SOA'}->{'name'} );
- if ( $M->{'initrd'} ) {
- printf qq{# initrd "%s";\n}, $M->{'initrd'};
+ if ( defined( $M->{'vmwfilename'} ) && $M->{'vmwfilename'} ne "" ) {
+ printf( " filename \"%s\";\n", $M->{'vmwfilename'} );
+ }
+
+ if ( defined( $M->{'pxelinuxconf'} ) && $M->{'pxelinuxconf'} ne "" ) {
+ printf( " option option-209 \"%s\";\n", $M->{'pxelinuxconf'} );
+ }
+
+ my @dns = Get_dns_from_zone( $Z, $M, $hostnum );
+
+ if ( $#dns >= 0 && defined $dns[0] ) {
+ printf( " option domain-name-servers %s;\n", join( ", ", @dns ) );
+ }
+
+ print "}\n\n";
}
-
- if ( $M->{'cmdline'} ) {
- printf qq{# cmdline "%s";\n}, $M->{'cmdline'};
- }
-
- if ( $M->{'console'} ) {
- printf qq{# console "%s";\n}, $M->{'console'};
- }
-
- if ( defined( $M->{'pxefilename'} )
- && $M->{'pxefilename'} ne "" )
- {
- printf( "# pxefilename \"%s\";\n",
- $M->{'pxefilename'} );
- }
-
- if ( defined( $M->{'pxelinuxconf'} )
- && $M->{'pxelinuxconf'} ne "" )
- {
- printf( " option option-209 \"%s\";\n",
- $M->{'pxelinuxconf'} );
- }
-
- my @dns = Get_dns_from_zone( $Z, $M, $hostnum );
-
- if ( $#dns >= 0 && defined $dns[0] ) {
- printf( " option domain-name-servers %s;\n",
- join( ", ", @dns ) );
- }
-
- print "}\n\n";
- }
- if ( defined( $M->{'zone'}->{$nam}->{'vmether'} )
- && ( $PFTOOLS_VARS->{'VMWARE'} || $PFTOOLS_VARS->{'UML'} ) )
- {
- printf( "host %s {\n", $nam2 );
- printf( " hardware ethernet %s;\n",
- $M->{'zone'}->{$nam}->{'vmether'} );
- printf( " fixed-address %s.%s;\n",
- $nam, $Z->{'SOA'}->{'name'} );
-
- if ( defined( $M->{'vmwfilename'} )
- && $M->{'vmwfilename'} ne "" )
- {
- printf( " filename \"%s\";\n",
- $M->{'vmwfilename'} );
- }
-
- if ( defined( $M->{'pxelinuxconf'} )
- && $M->{'pxelinuxconf'} ne "" )
- {
- printf( " option option-209 \"%s\";\n",
- $M->{'pxelinuxconf'} );
- }
-
- my @dns = Get_dns_from_zone( $Z, $M, $hostnum );
-
- if ( $#dns >= 0 && defined $dns[0] ) {
- printf( " option domain-name-servers %s;\n",
- join( ", ", @dns ) );
- }
-
- print "}\n\n";
}
}
}
}
+
print "\n";
}
Modified: trunk/sbin/mk_pxelinuxcfg
URL: http://svn.debian.org/wsvn/pf-tools/trunk/sbin/mk_pxelinuxcfg?rev=599&op=diff
==============================================================================
--- trunk/sbin/mk_pxelinuxcfg (original)
+++ trunk/sbin/mk_pxelinuxcfg Tue Jun 3 15:07:55 2008
@@ -59,89 +59,92 @@
. ')(\.*)?$';
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'} )
+ foreach my $host ( @{$Z->{'SERVERS'}->{'BY_ADDR'}->{$s}} ) {
+
+ foreach my $m ( sort ( keys %{ $host->{'SRVLIST'} } ) ) {
+ my $nam;
+ my $M = $host->{'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'} ) )
{
- my $hexaddr = sprintf( '%02X%02X%02X%02X',
- split( '\.', $addr ) );
-
- if ( -e $pxetftpdir . "/" . $hexaddr ) {
- unlink( $pxetftpdir . "/" . $hexaddr );
+ if ( $M->{'filename'} ne 'pxelinux.0' ) {
+ Warn( $ERR_SYNTAX,
+ "Mk_pxelinuxconf["
+ . $nam2
+ . "]: pxefilename exists but filename is not pxelinux.0!"
+ );
}
-
- open( PXELINUXCFG,
- ">" . $pxetftpdir . "/" . $hexaddr )
- || die "impossible d'ecrire "
- . $pxelinuxconfdir . "/"
- . $hexaddr . ": "
- . $!;
-
- 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 $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 $pxetftpdir . "/" . $hexaddr ) {
+ unlink( $pxetftpdir . "/" . $hexaddr );
+ }
+
+ open( PXELINUXCFG,
+ ">" . $pxetftpdir . "/" . $hexaddr )
+ || die "impossible d'ecrire "
+ . $pxelinuxconfdir . "/"
+ . $hexaddr . ": "
+ . $!;
+
+ 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;
+
+ if ( defined $M->{'preseedfilename'} ) {
+ $temptemplatecontent =~
+ s/%PRESEED_URL%/http:\/\/deploy.private\/$M->{preseedfilename}/gs;
+ my $preseed_md5 = Get_MD5SUM_from_preseedfilename ( $M->{'preseedfilename'} );
+ if ( ! defined $preseed_md5 ) {
+ die "Unable to get md5dum for preseed filename "
+ .$M->{'preseedfilename'}." for host ".$m."\n" ;
+ }
+ $temptemplatecontent =~ s/%PRESEED_MD5%/$preseed_md5/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;
+
+ my $cmdline = $M->{'cmdline'} || '';
+ $temptemplatecontent =~ s/%CMDLINE%/$cmdline/gs;
+
+ my $console = $M->{'console'} || '';
+ $console = "console=" . $console if $console;
+ $temptemplatecontent =~ s/%CONSOLE%/$console/gs;
+
+ my $serial_speed = $M->{'serialspeed'} || '115200' ;
+ $temptemplatecontent =~ s/%SERIAL_SPEED%/$serial_speed/gs;
+
+ $temptemplatecontent =~ s/ +/ /gs;
+
+ print PXELINUXCFG $temptemplatecontent;
+ close PXELINUXCFG;
}
-
- my $temptemplatecontent = join '', @{ $templates->{$template_name} };
-
- $temptemplatecontent =~ s/%KERNEL%/$M->{pxefilename}/gs;
- $temptemplatecontent =~ s/%INITRD%/$M->{initrd}/gs;
-
- if ( defined $M->{'preseedfilename'} ) {
- $temptemplatecontent =~ s/%PRESEED_URL%/http:\/\/deploy.private\/$M->{preseedfilename}/gs;
- my $preseed_md5 = Get_MD5SUM_from_preseedfilename ( $M->{'preseedfilename'} );
- if ( ! defined $preseed_md5 ) {
- die "Unable to get md5dum for preseed filename ".$M->{'preseedfilename'}." for host ".$m."\n" ;
- }
- $temptemplatecontent =~ s/%PRESEED_MD5%/$preseed_md5/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;
-
- my $cmdline = $M->{'cmdline'} || '';
- $temptemplatecontent =~ s/%CMDLINE%/$cmdline/gs;
-
- my $console = $M->{'console'} || '';
- $console = "console=" . $console if $console;
- $temptemplatecontent =~ s/%CONSOLE%/$console/gs;
-
- my $serial_speed = $M->{'serialspeed'} || '115200' ;
- $temptemplatecontent =~ s/%SERIAL_SPEED%/$serial_speed/gs;
-
- $temptemplatecontent =~ s/ +/ /gs;
-
- print PXELINUXCFG $temptemplatecontent;
- close PXELINUXCFG;
}
}
}
More information about the pf-tools-commits
mailing list