pf-tools/pf-tools: enough for a one shot migration and better th...
parmelan-guest at users.alioth.debian.org
parmelan-guest at users.alioth.debian.org
Wed Apr 9 09:45:05 UTC 2014
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/ca2bd131e40a
changeset: 1257:ca2bd131e40a
user: shad
date: Wed Apr 09 11:33:55 2014 +0200
description:
enough for a one shot migration and better than playing with sed
diffstat:
tools/Translate_old_config | 22 ++++++++++++++++------
1 files changed, 16 insertions(+), 6 deletions(-)
diffs (82 lines):
diff -r 34a551dd424b -r ca2bd131e40a tools/Translate_old_config
--- a/tools/Translate_old_config Wed Apr 09 11:09:41 2014 +0200
+++ b/tools/Translate_old_config Wed Apr 09 11:33:55 2014 +0200
@@ -40,13 +40,15 @@
# Global vars
my @options_specs
- = ( 'help', 'type|t=s', 'include', 'input|i=s', 'output|o=s', );
+ = ( 'help', 'type|t=s', 'include', 'input|i=s', 'output|o=s', 'site|s=s',
+ );
my $options = {
'help' => 0,
'output' => q{-},
'type' => 'config',
'include' => 0,
+ 'site' => 'UNDEFINED',
};
my $program = basename $PROGRAM_NAME;
@@ -64,6 +66,7 @@
--include : parse include file if defined (default disabled)
-i --input : source for old configuration file
-o --output : destination for modified configuration file
+ -s --site : site for elements defined in the file
ENDHELP
return;
}
@@ -155,7 +158,7 @@
foreach my $key ( keys %{ $old_parsing->{$section} } ) {
# seems like old_parsing translate key ether.1 as a hash
- if ( $key =~ m{\A ether \z}xms ) {
+ if ( $key eq q{ether} ) {
$pftools++;
last;
}
@@ -258,10 +261,10 @@
{
my $cleanhostname = $hostdef;
$cleanhostname =~ s{%%}{}mxs;
+
+ # server definition hostfile
my $host_output_fh
- = IO::File->new( q{>}
- . $options->{'output'}
- . qq{.hostfile-$cleanhostname} )
+ = IO::File->new( q{>} . qq{hostfile-$cleanhostname} )
or croak
"Unable to open $options->{'output'}.hostfile-$cleanhostname} for translation";
@@ -296,6 +299,11 @@
}
}
else {
+ if ( $hostkey eq 'site' ) {
+ $trans->{$section}->{$hostdef}->{$hostsection}
+ ->{$hostkey} = $options->{'site'};
+ }
+
$host_output_fh->print(
"\t$hostkey\t= $trans->{$section}->{$hostdef}->{$hostsection}->{$hostkey}\n"
);
@@ -304,8 +312,9 @@
$host_output_fh->print("\n");
}
$host_output_fh->close();
- my $site = q{cbv4-pfds};
+ # server definition entry
+ my $site = $options->{'site'};
if ( $comments->{$hostdef}->{'general'} ) {
$output_fh->print(
join( qq{\n},
@@ -332,6 +341,7 @@
. qq{\n} );
}
$output_fh->print(qq{[$section]\n});
+ $trans->{$section}->{'site'} = $options->{'site'};
foreach my $key ( sort orderkeys keys %{ $trans->{$section} } ) {
if ( $comments->{$section}->{$key} ) {
$output_fh->print(
More information about the pf-tools-commits
mailing list