pf-tools commit: r862 [ccaillet-guest] - in /branches/next-gen: debian/changelog lib/PFTools/Compat/Parser.pm lib/PFTools/Compat/Translation.pm tools/Display_IP_config tools/Translate_old_config
parmelan-guest at users.alioth.debian.org
parmelan-guest at users.alioth.debian.org
Mon Aug 30 09:59:39 UTC 2010
Author: ccaillet-guest
Date: Mon Aug 30 09:59:38 2010
New Revision: 862
URL: http://svn.debian.org/wsvn/pf-tools/?sc=1&rev=862
Log:
* tools/Translate_old_config
- tools for translating old configuration (pf-tools 0.XX) into new syntax
Added:
branches/next-gen/tools/Translate_old_config (with props)
Modified:
branches/next-gen/debian/changelog
branches/next-gen/lib/PFTools/Compat/Parser.pm
branches/next-gen/lib/PFTools/Compat/Translation.pm
branches/next-gen/tools/Display_IP_config (contents, props changed)
Modified: branches/next-gen/debian/changelog
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/debian/changelog?rev=862&op=diff
==============================================================================
--- branches/next-gen/debian/changelog (original)
+++ branches/next-gen/debian/changelog Mon Aug 30 09:59:38 2010
@@ -72,8 +72,10 @@
- extracting from PFTools::Parser functions for parsing old syntax format
* lib/PFTools/Compat/Translation.pm
- library for translating old configuration (pf-tools 0.X) to new syntax
-
- -- Christophe Caillet <quadchris at free.fr> Mon, 30 Aug 2010 10:48:08 +0200
+ * tools/Translate_old_config
+ - tools for translating old configuration (pf-tools 0.XX) into new syntax
+
+ -- Christophe Caillet <quadchris at free.fr> Mon, 30 Aug 2010 11:34:57 +0200
pf-tools (0.99.98-1) unstable; urgency=low
Modified: branches/next-gen/lib/PFTools/Compat/Parser.pm
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/lib/PFTools/Compat/Parser.pm?rev=862&op=diff
==============================================================================
--- branches/next-gen/lib/PFTools/Compat/Parser.pm (original)
+++ branches/next-gen/lib/PFTools/Compat/Parser.pm Mon Aug 30 09:59:38 2010
@@ -87,8 +87,8 @@
my $PFTOOLS_VARS = {};
-sub Parser_pftools ($$) {
- my ( $fic_conf, $substdestvars ) = @_;
+sub Parser_pftools ($$;$) {
+ my ( $fic_conf, $substdestvars, $inc ) = @_;
my $CONF = {};
my $LOCATION = {} ;
@@ -190,7 +190,7 @@
next if ( $#cond >= 0 && !$cond[0] );
if (/^\@([^\s]+)\s+([^\s]+)$/) {
- if ( $1 eq "include" ) {
+ if ( $1 eq "include" && $inc ) {
my $fic_conf = $2;
my $oldficconf;
@@ -209,17 +209,17 @@
}
foreach $oldficconf (@ALL_CONF) {
- if ( $fic_conf eq $oldficconf ) {
- Warn( $CODE->{'OPEN'},
- $FIC_CONF[0] . ":"
- . $line[0] . ": "
- . $fic_conf
- . " deja inclus ligne "
- . $LOCATION->{'include'}->{$fic_conf}->{'line'}
- . " dans "
- . $LOCATION->{'include'}->{$fic_conf}->{'source'} );
- next LOADCONFLINE;
- }
+ if ( $fic_conf eq $oldficconf ) {
+ Warn( $CODE->{'OPEN'},
+ $FIC_CONF[0] . ":"
+ . $line[0] . ": "
+ . $fic_conf
+ . " deja inclus ligne "
+ . $LOCATION->{'include'}->{$fic_conf}->{'line'}
+ . " dans "
+ . $LOCATION->{'include'}->{$fic_conf}->{'source'} );
+ next LOADCONFLINE;
+ }
}
$LOCATION->{'include'}->{$fic_conf}->{'line'} = $line[0] ;
$LOCATION->{'include'}->{$fic_conf}->{'source'} = $FIC_CONF[0] ;
@@ -240,6 +240,10 @@
$fh = $newfh ;
print "Filehandles list after inclusion --> @FH\n" if ( $DEBUG );
}
+ elsif ( $1 eq "include" && ! $inc ) {
+ print "There is an include idrective which is deactivate\n" if ( $DEBUG );
+ $CONF->{"\@include-".$2} = 1;
+ }
elsif ( $1 eq "define" ) {
if ( defined( $PFTOOLS_VARS->{$2} ) ) {
Warn( $CODE->{'OPEN'},
Modified: branches/next-gen/lib/PFTools/Compat/Translation.pm
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/lib/PFTools/Compat/Translation.pm?rev=862&op=diff
==============================================================================
--- branches/next-gen/lib/PFTools/Compat/Translation.pm (original)
+++ branches/next-gen/lib/PFTools/Compat/Translation.pm Mon Aug 30 09:59:38 2010
@@ -42,6 +42,12 @@
my $new_conf = $conf_parsed;
foreach my $section ( keys %{$new_conf} ) {
+ if ( $section =~ /^@(.*)$/ ) {
+ $new_conf->{$1} = {
+ 'type' => 'include'
+ };
+ next;
+ }
foreach my $key ( keys %{$new_conf->{$section}} ) {
# Filter substitution
$new_conf->{$section}->{$key} =~ s/(filter_(\S+)) (\S+) (\S+) (\S+)/$1 -i $3 -h $4 -o $5/g;
Modified: branches/next-gen/tools/Display_IP_config
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/tools/Display_IP_config?rev=862&op=diff
==============================================================================
--- branches/next-gen/tools/Display_IP_config (original)
+++ branches/next-gen/tools/Display_IP_config Mon Aug 30 09:59:38 2010
@@ -1,6 +1,6 @@
#!/usr/bin/perl
##
-## $Id: dumpiplist.pl 582 2008-03-06 16:06:00Z ccaillet-guest $
+## $Id$
##
## Copyright (C) 2008-2010 Christophe Caillet <quadchris at free.fr>
## Copyright (C) 2004 Stephane Pontier <shad at sitadelle.com>
@@ -49,7 +49,7 @@
my $program = $0;
$program =~ s%.*/%%; # cheap basename
-my $version = sprintf( "svn-r%s", q$Revision: 795 $ =~ /([\d.]+)/ );
+my $version = sprintf( "svn-r%s", q$Revision$ =~ /([\d.]+)/ );
######################################################
# Functions
Propchange: branches/next-gen/tools/Display_IP_config
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Aug 30 09:59:38 2010
@@ -1,0 +1,2 @@
+Id
+Revision
Added: branches/next-gen/tools/Translate_old_config
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/tools/Translate_old_config?rev=862&op=file
==============================================================================
--- branches/next-gen/tools/Translate_old_config (added)
+++ branches/next-gen/tools/Translate_old_config Mon Aug 30 09:59:38 2010
@@ -1,0 +1,134 @@
+#!/usr/bin/perl
+##
+## $Id$
+##
+## Copyright (C) 2008-2010 Christophe Caillet <quadchris at free.fr>
+## Copyright (C) 2004 Stephane Pontier <shad at sitadelle.com>
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+##
+
+# liste toute les adresses ip depuis le fichier private-network
+# prend le fichier private-network en argument et un 1 en second
+# argument si on souhaite avoir les adresses pour les uml (implique alteon00 surtout)
+
+use strict;
+use warnings;
+
+use Data::Dumper;
+use PFTools::Logger;
+use PFTools::Compat::Parser;
+use PFTools::Compat::Translation;
+use Getopt::Long qw ( :config ignore_case_always bundling ) ;
+
+#################################
+# Global vars
+my $INPUT = "";
+my $OUTPUT = "";
+my $INCLUDE = 0;
+my $TYPE = "config";
+my $HELP = 0;
+
+my $program = $0;
+$program =~ s%.*/%%; # cheap basename
+
+my $version = sprintf( "svn-r%s", q$Revision$ =~ /([\d.]+)/ );
+
+#################################
+# Functions
+
+sub Do_help () {
+print STDERR << "# ENDHELP";
+ $program - version $version
+
+Usage: $0 [options]
+ --help : print help and exit
+ -t --type : type of configuration file, allowed types are : config, network
+ - config is for update-* file
+ - network is for file like old private-network
+ -i --input : source for old configuration file
+ -o --output : destination for modified configuration file
+# ENDHELP
+}
+
+#######################################################""
+### MAIN
+
+GetOptions (
+ 'help' => \$HELP,
+ 'include' => \$INCLUDE,
+ 't|type=s' => \$TYPE,
+ 'i|input=s' => \$INPUT,
+ 'o|output=s' => \$OUTPUT
+) or die "Didn't grok options (see --help).\n";
+
+if ( $HELP ) {
+ Do_help ();
+ exit 0;
+}
+
+if ( ! -e $INPUT ) {
+ Abort ( $CODE->{'UNDEF_KEY'}, "File ".$INPUT." doesn't exist : unable to translate old configuration" );
+}
+
+my $old_parsing = Parser_pftools ( $INPUT, {}, $INCLUDE );
+my $trans = {};
+if ( $TYPE eq 'config' ) {
+ $trans = Translate_old2new_config ( $old_parsing );
+}
+else {
+ foreach my $section ( keys %{$old_parsing} ) {
+ if ( $old_parsing->{$section}->{'type'} eq 'network' ) {
+ $trans->{$section} = Translate_old2new_network ( $old_parsing->{$section}, $section );
+ }
+ elsif ( $old_parsing->{$section}->{'type'} =~ /-server$/ ) {
+ my $pftools = 0;
+ # Need to see if it is a "virtual pf-tools" host or a "real pf-tools" host
+ foreach my $key ( keys %{$old_parsing->{$section}} ) {
+ if ( $key =~ /^ether\.\d+$/ ) {
+ $pftools++;
+ last;
+ }
+ }
+ if ( $pftools ) {
+ # We need to translate into a hostfile configuration
+ $trans->{'__hostfile'} = {
+ $section => Translate_old2new_host ( $old_parsing->{$section}, $section )
+ };
+ }
+ }
+ }
+}
+unless ( open OUTPUT, ">".$OUTPUT ) {
+ Abort ( $CODE->{'OPEN'}, "Unable to open ".$OUTPUT." for translation" );
+}
+if ( $TYPE eq 'config' ) {
+ foreach my $section ( keys %{$trans} ) {
+ next if ( $section =~ /^@/ );
+ print OUTPUT "[".$section."]\n";
+ foreach my $key ( keys %{$trans->{$section}} ) {
+ next if ( $key =~ /^__/ );
+ print OUTPUT "\t".$key."\t= ".$trans->{$section}->{$key}."\n";
+ }
+ print "\n";
+ }
+}
+else {
+ print "Need to implement the output for other type ".$TYPE;
+ print Dumper $trans;
+}
+close ( OUTPUT );
+
+exit 0;
Propchange: branches/next-gen/tools/Translate_old_config
------------------------------------------------------------------------------
svn:executable = *
Propchange: branches/next-gen/tools/Translate_old_config
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Mon Aug 30 09:59:38 2010
@@ -1,0 +1,2 @@
+Id
+Revision
More information about the pf-tools-commits
mailing list