pf-tools/pf-tools: 4 new changesets

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Thu Dec 18 14:53:26 UTC 2014


details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/1c813272af8e
changeset: 1403:1c813272af8e
user:      melkor <melkor at sitadelle.com>
date:      Thu Dec 18 15:38:37 2014 +0100
description:
remove check of redefined network section which die if a vlan has ipv6 and ipv4 definition

details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/b3cb6b622009
changeset: 1404:b3cb6b622009
user:      melkor <melkor at sitadelle.com>
date:      Thu Dec 18 15:43:03 2014 +0100
description:
use netmask6 key to define ipv6 network

details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/fbc3a779a261
changeset: 1405:fbc3a779a261
user:      melkor <melkor at sitadelle.com>
date:      Thu Dec 18 15:53:04 2014 +0100
description:
begins of ipv6

details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/80fbaa09a532
changeset: 1406:80fbaa09a532
user:      melkor <melkor at sitadelle.com>
date:      Thu Dec 18 15:53:23 2014 +0100
description:
begins of ipv6

diffstat:

 debian/control              |   2 +-
 lib/PFTools/Conf/Host.pm    |  61 ++++++++++++++++++++++++++++----------------
 lib/PFTools/Conf/Network.pm |  10 +------
 lib/PFTools/Net.pm          |   4 +-
 tools/Translate_old_config  |   2 +-
 5 files changed, 43 insertions(+), 36 deletions(-)

diffs (184 lines):

diff -r 74f016f64cda -r 80fbaa09a532 debian/control
--- a/debian/control	Thu Dec 18 09:28:40 2014 +0100
+++ b/debian/control	Thu Dec 18 15:53:23 2014 +0100
@@ -8,7 +8,7 @@
 
 Package: pf-tools
 Architecture: all
-Depends: perl, perl (>= 5.10.0) | libmd5-perl, libclone-perl, libconfig-inifiles-perl, liblist-moreutils-perl, libhash-merge-simple-perl, libmodule-runtime-perl, libnetaddr-ip-perl, libnet-dns-perl, libproc-reliable-perl, libreadonly-xs-perl, libreadonly-xs-perl, libregexp-common-perl, libtemplate-perl, libtemplate-tiny-perl, libtext-diff-perl, mercurial | subversion | cvs , ssh, iproute | iproute2, debconf, psmisc
+Depends: perl, perl (>= 5.10.0) | libmd5-perl, libclone-perl, libconfig-inifiles-perl, liblist-moreutils-perl, libhash-merge-simple-perl, libmodule-runtime-perl, libnetaddr-ip-perl, libnet-dns-perl, libproc-reliable-perl, libreadonly-perl, libreadonly-xs-perl, libregexp-common-perl, libtemplate-perl, libtemplate-tiny-perl, libtext-diff-perl, mercurial | subversion | cvs , ssh, iproute | iproute2, debconf, psmisc
 Description: Outils de gestion de la plateforme
  Mise a jour automatique et generation de conf.
  Deploiement de machines.
diff -r 74f016f64cda -r 80fbaa09a532 lib/PFTools/Conf/Host.pm
--- a/lib/PFTools/Conf/Host.pm	Thu Dec 18 09:28:40 2014 +0100
+++ b/lib/PFTools/Conf/Host.pm	Thu Dec 18 15:53:23 2014 +0100
@@ -181,7 +181,6 @@
                         hostname      => $hostname,
                         hostnum       => $hostnum,
                         hostnode      => $hostnode,
-                        host_ref      => $host_ref,
                         link_list_ref => \@link_list,
                         site_name     => $site,
                         site_ref      => $site_part_ref,
@@ -618,16 +617,30 @@
     my $prefix = $subnet_ref->prefix();
     $prefix =~ s{ \d+-[\d.]+ }{}xms;
     my $ip_address;
-    if ( $ipstart =~ /\A $RE{net}{IPv4} \Z/xms ) {
-        $ip_address = NetAddr::IP->new( $ipstart, $subnet_ref->mask() );
-    }
-    else {
-        $ip_address
-            = NetAddr::IP->new( $prefix . $ipstart, $subnet_ref->mask() );
-    }
-    if ( !$ip_address ) {
-        croak
-            qq{ERROR: Invalid IP with prefix='$prefix' and ipstart='$ipstart'};
+    if ($prefix) {
+        if ( $ipstart =~ /\A $RE{net}{IPv4} \Z/xms ) {
+            $ip_address = NetAddr::IP->new( $ipstart, $subnet_ref->mask() );
+        }
+        else {
+            $ip_address
+                = NetAddr::IP->new( $prefix . $ipstart, $subnet_ref->mask() );
+        }
+        if ( !$ip_address ) {
+            croak
+                qq{ERROR: Invalid IP with prefix='$prefix' and ipstart='$ipstart'};
+        }
+    } 
+    elsif ($subnet_ref->{isv6}) {
+        my @subnet_oct = split /:/, $subnet_ref->addr;
+        my @last_oct = split /:/, $ipstart;
+
+        my $index = -1;
+        while (my $oct = pop @last_oct) {
+            $subnet_oct[$index] = $oct;
+            $index --;
+        }
+        my $ip_v6 = join ':', @subnet_oct;
+        $ip_address = NetAddr::IP->new( $ip_v6, $subnet_ref->mask());
     }
 
     if ($hostnum) {
@@ -700,13 +713,10 @@
             next;
         }
 
-        # FIXME this obviously does not handle IPv6
         if ( $key_type =~ m{ \A ipv }xms ) {
             my $suffix = $hostnum ? qq{\.$hostnum} : q{};
-            $result->{qq{link::$spec}}->{qq{dev$suffix}}
-                = qq{eth$iface_index};
-            $result->{qq{link::$spec}}->{qq{ipv4$suffix}}
-                = $server_ref->{$key};
+            $result->{qq{link::$spec}}->{qq{dev$suffix}} = qq{eth$iface_index};
+            $result->{qq{link::$spec}}->{qq{${key_type}${suffix}}} = $server_ref->{$key};
             $iface_index++;
             next;
         }
@@ -759,11 +769,11 @@
 
     my @argument_names = qw(
         link_name   hostname   hostnum
-        hostnode    host_ref   link_list_ref
-        site_name   site_ref   pf_config
+        hostnode    host_ref   site_name
+        site_ref    pf_config
     );
     my ($link_name, $hostname, $hostnum,
-        $hostnode,  $host_ref, $link_list_ref,
+        $hostnode,  $host_ref, 
         $site_name, $site_ref, $pf_config
     ) = @{$arguments_ref}{@argument_names};
 
@@ -869,6 +879,7 @@
         }
     }
 
+    my $ip_found = 0;
     # Check address and route values
     foreach my $ip_type (qw( ipv4 ipv6 )) {
         next if not $pf_config->{'features'}->{$ip_type};
@@ -891,10 +902,10 @@
             );
         };
         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)};
+            #print $EVAL_ERROR; # not beautiful but we get why ip attribution failed
+            next
         }
+        $ip_found = 1;
 
         my $suffix    = get_suffix_from_ip_type($ip_type);
         my $route_key = '@route' . $suffix;
@@ -924,6 +935,10 @@
         }
     }
 
+    if (!$ip_found) {
+        croak qq{ERROR: No ip defined for $hostname on $iface_name (vlan: $vlan_name)};
+    }
+
     return $result;
 }
 
@@ -979,7 +994,7 @@
         = $link_section_ref->{$ip_type_dot_host_number} ? 0 : $nodes;
 
     if ( !defined $ipstart ) {
-        croak qq{ERROR: No $ip_type defined};
+        return;
     }
     my $params_ref = {
         ip_type    => $ip_type,
diff -r 74f016f64cda -r 80fbaa09a532 lib/PFTools/Conf/Network.pm
--- a/lib/PFTools/Conf/Network.pm	Thu Dec 18 09:28:40 2014 +0100
+++ b/lib/PFTools/Conf/Network.pm	Thu Dec 18 15:53:23 2014 +0100
@@ -293,15 +293,7 @@
 
         foreach my $site ( @{$site_list} ) {
             my $net_part = $site_part->{'BY_NAME'}->{$site}->{'NETWORK'};
-            if ( $net_part->{'BY_NAME'}->{$section_name} ) {
-
-                # FIXME is this not a fatal error?
-                carp
-                    qq{WARNING: file $start_file section $section_name: already defined};
-                next;
-            }
-
-            if ( $tag and $net_part->{'BY_TAG'}->{$tag} ) {
+            if ( $tag and $net_part->{'BY_TAG'}->{$tag} and $net_part->{'BY_TAG'}->{$tag} ne $section_name ) {
                 croak
                     qq{ERROR: File $start_file section $section_name: duplicate tag $tag};
             }
diff -r 74f016f64cda -r 80fbaa09a532 lib/PFTools/Net.pm
--- a/lib/PFTools/Net.pm	Thu Dec 18 09:28:40 2014 +0100
+++ b/lib/PFTools/Net.pm	Thu Dec 18 15:53:23 2014 +0100
@@ -83,9 +83,9 @@
         $subnet_ref = NetAddr::IP->new($net_def);
     }
     else {
-        my $netmask = $net_hash->{'netmask'};
+        my $netmask = $net_hash->{qq{netmask$suffix}};
         if ( !$netmask ) {
-            croak q{ERROR: Unable to retrieve netmask};
+            croak qq{ERROR: Unable to retrieve netmask$suffix};
         }
         $subnet_ref = NetAddr::IP->new( $net_def, $netmask );
     }
diff -r 74f016f64cda -r 80fbaa09a532 tools/Translate_old_config
--- a/tools/Translate_old_config	Thu Dec 18 09:28:40 2014 +0100
+++ b/tools/Translate_old_config	Thu Dec 18 15:53:23 2014 +0100
@@ -221,7 +221,7 @@
 
 # sort items by a more logical order
 my @orderby = qw( action depends source actiongroup filter owner group
-    arch mode distrib preseed
+    arch mode fstype options distrib preseed
     pxefilename pxetemplate initrd kernel cmdline
     option slaveon_config before_change on_noaction after_change
     type comment serial soa mail refresh retry expire negttl



More information about the pf-tools-commits mailing list