pf-tools/pf-tools: 2 new changesets

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Mon Aug 18 16:11:43 UTC 2014


details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/743ce53a8426
changeset: 1315:743ce53a8426
user:      shad
date:      Mon Aug 18 17:22:51 2014 +0200
description:
translate properly mix of ipstart and ip

details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/069482f7049e
changeset: 1316:069482f7049e
user:      shad
date:      Mon Aug 18 17:23:24 2014 +0200
description:
more explicit error when ip attribution fail

diffstat:

 lib/PFTools/Compat/Translation.pm |  27 +++++++++++++++++----------
 lib/PFTools/Conf/Host.pm          |   1 +
 lib/PFTools/Update/Common.pm      |   3 ++-
 tools/Translate_old_config        |  11 +++++++----
 4 files changed, 27 insertions(+), 15 deletions(-)

diffs (135 lines):

diff -r e270822b7eed -r 069482f7049e lib/PFTools/Compat/Translation.pm
--- a/lib/PFTools/Compat/Translation.pm	Thu Aug 14 17:55:12 2014 +0200
+++ b/lib/PFTools/Compat/Translation.pm	Mon Aug 18 17:23:24 2014 +0200
@@ -35,20 +35,25 @@
 
 our @EXPORT_OK = qw();
 
-sub Translate_old2new_config ($) {
+sub Translate_old2new_config {
     my ($conf_parsed) = @_;
 
     my $new_conf = $conf_parsed;
     foreach my $section ( keys %{$new_conf} ) {
         if ( $section =~ /^@(.*)$/ ) {
-            $new_conf->{$1} = { 'action' => 'include' };
+            $new_conf->{qq{COMMON:/$1}} = { 'action' => 'include' };
             delete $new_conf->{$section};
             next;
-        } elsif ( $section =~ m{\A /distrib/tftpboot/pxelinux.cfg/(.*) \z}xms ) {
+        }
+        elsif ( $section =~ m{\A /distrib/tftpboot/pxelinux.cfg/(.*) \z}xms )
+        {
             my $new_section = qq{/usr/share/pf-tools/templates/$1};
             $new_conf->{$new_section} = delete $new_conf->{$section};
-            if ( $new_conf->{$new_section}->{depends} =~ m{\A /distrib/tftpboot/pxelinux.cfg/(.*) \z}xms ) {
-                $new_conf->{$new_section}->{depends} = qq{/usr/share/pf-tools/templates/$1};
+            if ( $new_conf->{$new_section}->{depends}
+                =~ m{\A /distrib/tftpboot/pxelinux.cfg/(.*) \z}xms )
+            {
+                $new_conf->{$new_section}->{depends}
+                    = qq{/usr/share/pf-tools/templates/$1};
             }
             $section = $new_section;
         }
@@ -381,8 +386,10 @@
             }
         }
     }
+
     # pf-tools 1 need a shortname, if none define, the first one is usually ok
-    if ( !$new_host->{'shortname'} && $host_parsed->{'interface'}->{'eth0'} ) {
+    if ( !$new_host->{'shortname'} && $host_parsed->{'interface'}->{'eth0'} )
+    {
         $new_host->{'shortname'} = $host_parsed->{'interface'}->{'eth0'};
     }
     return $new_host;
@@ -394,7 +401,7 @@
     if ( defined $host_parsed->{'ipstart'}->{$vlan} ) {
         $new_host->{ 'ipv4.' . $vlan } = $host_parsed->{'ipstart'}->{$vlan};
     }
-    elsif ( defined $host_parsed->{'ip'}->{$vlan} ) {
+    if ( defined $host_parsed->{'ip'}->{$vlan} ) {
         foreach my $subkey ( keys %{ $host_parsed->{'ip'}->{$vlan} } ) {
             if ( $subkey eq 'default'
                 && !defined $new_host->{ 'ipv4.' . $vlan } )
@@ -408,7 +415,7 @@
             }
         }
     }
-    else {
+    if ( !defined $new_host->{ 'ipv4.' . $vlan } ) {
         $new_host->{ 'ipv4.' . $vlan }
             = $host_parsed->{'ipstart'}->{'default'};
     }
@@ -423,7 +430,7 @@
         $new_host->{ 'link::' . $vlan }->{'ipv4'}
             = $host_parsed->{'ipstart'}->{$vlan};
     }
-    elsif ( defined $host_parsed->{'ip'}->{$vlan} ) {
+    if ( defined $host_parsed->{'ip'}->{$vlan} ) {
         foreach my $subkey ( keys %{ $host_parsed->{'ip'}->{$vlan} } ) {
             if ( $subkey eq 'default'
                 && !defined $new_host->{ 'link::' . $vlan }->{'ipv4'} )
@@ -437,7 +444,7 @@
             }
         }
     }
-    else {
+    if ( !defined $new_host->{ 'link::' . $vlan }->{'ipv4'} ) {
         $new_host->{ 'link::' . $vlan }->{'ipv4'}
             = $host_parsed->{'ipstart'}->{'default'};
     }
diff -r e270822b7eed -r 069482f7049e lib/PFTools/Conf/Host.pm
--- a/lib/PFTools/Conf/Host.pm	Thu Aug 14 17:55:12 2014 +0200
+++ b/lib/PFTools/Conf/Host.pm	Mon Aug 18 17:23:24 2014 +0200
@@ -867,6 +867,7 @@
             );
         };
         if ($EVAL_ERROR) {
+            print $EVAL_ERROR; # not beautiful but we get why ip attribution failed
             croak
                 qq{ERROR: No $ip_type defined for $hostname on $iface_name (vlan: $vlan_name)};
         }
diff -r e270822b7eed -r 069482f7049e lib/PFTools/Update/Common.pm
--- a/lib/PFTools/Update/Common.pm	Thu Aug 14 17:55:12 2014 +0200
+++ b/lib/PFTools/Update/Common.pm	Mon Aug 18 17:23:24 2014 +0200
@@ -208,7 +208,8 @@
     my ($cmd) = @_;
 
     if ( deferredlogsystem($cmd) ) {
-        carp qq{ERROR: Unable to execute [$cmd]};
+        carp colored( qq{ERROR: Unable to execute [$cmd]},
+            q{bold red on_white} );
         return;
     }
     return 1;
diff -r e270822b7eed -r 069482f7049e tools/Translate_old_config
--- a/tools/Translate_old_config	Thu Aug 14 17:55:12 2014 +0200
+++ b/tools/Translate_old_config	Mon Aug 18 17:23:24 2014 +0200
@@ -98,6 +98,7 @@
 my @included_list;
 open my $FILE, q{<}, $options->{'input'}
     or croak qq{Can't open '$options->{'input'}': $OS_ERROR};
+
 while (<$FILE>) {
     chomp;
 
@@ -423,11 +424,13 @@
 $output_fh->close();
 
 if ( $options->{'output'} ) {
-    foreach my $included_file ( @included_list ) {
+    foreach my $included_file (@included_list) {
         print qq{You may want to run :\n$PROGRAM_NAME -o $options->{'type'} };
-        print (($options->{'site'} ne q{UNDEFINED}) ? qq{-s $options->{'site'} -i } : q{-i });
-        print dirname ($options->{'input'}) .qq{/$included_file -o };
-        print dirname ($options->{'output'}) .qq{/$included_file\n};
+        print( ( $options->{'site'} ne q{UNDEFINED} )
+            ? qq{-s $options->{'site'} -i }
+            : q{-i } );
+        print dirname ( $options->{'input'} ) . qq{/$included_file -o };
+        print dirname ( $options->{'output'} ) . qq{/$included_file\n};
     }
 }
 



More information about the pf-tools-commits mailing list