pf-tools/pf-tools: ordering real server section too and also kee...
parmelan-guest at users.alioth.debian.org
parmelan-guest at users.alioth.debian.org
Wed Apr 9 09:09:46 UTC 2014
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/34a551dd424b
changeset: 1256:34a551dd424b
user: shad
date: Wed Apr 09 11:09:41 2014 +0200
description:
ordering real server section too and also keep comment
diffstat:
tools/Translate_old_config | 49 +++++++++++++++++++++++----------------------
1 files changed, 25 insertions(+), 24 deletions(-)
diffs (104 lines):
diff -r f9281e042897 -r 34a551dd424b tools/Translate_old_config
--- a/tools/Translate_old_config Tue Apr 08 15:07:49 2014 +0200
+++ b/tools/Translate_old_config Wed Apr 09 11:09:41 2014 +0200
@@ -90,7 +90,7 @@
my $comments = {};
my @tempcomment;
my $current_section;
-my %sectionorder = ( __hostfile => 0 );
+my %sectionorder = ();
my $sectionnumber = 1;
open my $FILE, q{<}, $options->{'input'}
or croak qq{Can't open '$options->{'input'}': $OS_ERROR};
@@ -101,8 +101,9 @@
push @tempcomment, $_;
}
elsif ( $_ =~ m{\A \[ ([^\]]*) \] }msx ) {
- $current_section = $1;
- $sectionorder{$current_section} = $sectionnumber;
+ $current_section = $1;
+ $sectionorder{$current_section} = $sectionnumber;
+ $sectionorder{"__$current_section"} = $sectionnumber;
$sectionnumber++;
if (@tempcomment) {
@{ $comments->{$current_section}->{'general'} } = @tempcomment;
@@ -162,7 +163,7 @@
if ($pftools) {
# We need to translate into a hostfile configuration
- $trans->{'__hostfile'}->{$section}
+ $trans->{"__$section"}->{$section}
= Translate_old2new_host( $old_parsing->{$section},
$section );
}
@@ -219,6 +220,7 @@
return $orderby{$roota} <=> $orderby{$rootb};
}
}
+
if ( $options->{'type'} eq 'config' ) {
foreach my $section (
sort { $sectionorder{$a} <=> $sectionorder{$b} }
@@ -263,35 +265,25 @@
or croak
"Unable to open $options->{'output'}.hostfile-$cleanhostname} for translation";
+ foreach
+ my $section_comment ( keys %{ $comments->{$hostdef} } )
+ {
+ next if $section_comment eq q{general};
+ $host_output_fh->print(
+ join( qq{\n},
+ @{ $comments->{$hostdef}->{$section_comment} } )
+ . qq{\n}
+ );
+ }
foreach my $hostsection (
sort keys %{ $trans->{$section}->{$hostdef} } )
{
- if ( $comments->{$hostsection}->{'general'} ) {
- $output_fh->print(
- join(
- qq{\n},
- @{ $comments->{$hostsection}->{'general'}
- }
- )
- . qq{\n}
- );
- }
$host_output_fh->print(qq{[$hostsection]\n});
foreach my $hostkey (
sort orderkeys
keys
%{ $trans->{$section}->{$hostdef}->{$hostsection} } )
{
- if ( $comments->{$hostsection}->{$hostkey} ) {
- $output_fh->print(
- join(
- qq{\n},
- @{ $comments->{$hostsection}->{$hostkey}
- }
- )
- . qq{\n}
- );
- }
if ( $hostkey =~ m{\A @ }mxs ) {
foreach my $subhostkey (
@{ $trans->{$section}->{$hostdef}
@@ -313,7 +305,16 @@
}
$host_output_fh->close();
my $site = q{cbv4-pfds};
+
+ if ( $comments->{$hostdef}->{'general'} ) {
+ $output_fh->print(
+ join( qq{\n},
+ @{ $comments->{$hostdef}->{'general'} } )
+ . qq{\n}
+ );
+ }
$output_fh->print(qq{[$cleanhostname]\n});
+
$output_fh->print("\ttype\t= service\n");
$output_fh->print(
"\tcomment\t= $trans->{$section}->{$hostdef}->{hostgroup}->{comment}\n"
More information about the pf-tools-commits
mailing list