pf-tools/pf-tools: 5 new changesets

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Wed Apr 9 15:50:23 UTC 2014


details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/3c6ad775a985
changeset: 1258:3c6ad775a985
user:      shad
date:      Wed Apr 09 13:55:38 2014 +0200
description:
dev.default -> dev

details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/9f40d580f131
changeset: 1259:9f40d580f131
user:      shad
date:      Wed Apr 09 16:07:45 2014 +0200
description:
clean up old interface

details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/5d71c53c0f9b
changeset: 1260:5d71c53c0f9b
user:      shad
date:      Wed Apr 09 16:10:07 2014 +0200
description:
handle more correctly dev.[.%HOSTNUM%]

details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/d7d7a54f0447
changeset: 1261:d7d7a54f0447
user:      shad
date:      Wed Apr 09 17:47:38 2014 +0200
description:
preseed was missing

details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/7bd1f6f80db8
changeset: 1262:7bd1f6f80db8
user:      shad
date:      Wed Apr 09 17:50:18 2014 +0200
description:
trying to keep inline comment (only ether becoming eth at the moment)

diffstat:

 lib/PFTools/Compat/Translation.pm |   16 ++++-
 lib/PFTools/Conf/Host.pm          |  102 ++++++++++++++++++++++---------------
 lib/PFTools/Conf/Syntax.pm        |   25 ---------
 tools/Translate_old_config        |   25 ++++++++-
 4 files changed, 96 insertions(+), 72 deletions(-)

diffs (259 lines):

diff -r ca2bd131e40a -r 7bd1f6f80db8 lib/PFTools/Compat/Translation.pm
--- a/lib/PFTools/Compat/Translation.pm	Wed Apr 09 11:33:55 2014 +0200
+++ b/lib/PFTools/Compat/Translation.pm	Wed Apr 09 17:50:18 2014 +0200
@@ -228,8 +228,13 @@
                         keys %{ $host_parsed->{$key}->{$iface} } )
                     {
                         $vlan = $host_parsed->{$key}->{$iface}->{$hostnum};
-                        $new_host->{ 'link::' . $vlan }
-                            ->{ 'dev' . qq{.$hostnum} } = $iface;
+                        if ( $hostnum eq q{default} ) {
+                            $new_host->{ 'link::' . $vlan }->{'dev'} = $iface;
+                        }
+                        else {
+                            $new_host->{ 'link::' . $vlan }
+                                ->{ 'dev' . qq{.$hostnum} } = $iface;
+                        }
                         __addlinksection( $host_parsed, $new_host, $vlan,
                             $iface );
                         if ( !$ifacedone->{$iface} ) {
@@ -264,7 +269,9 @@
                 $new_host->{'dns'}->{'resolver'} = $host_parsed->{$key};
             }
         }
-        elsif ( $key =~ /^initrd|pxetemplate|console|(pxe|uml)?filename$/xms )
+        elsif ( $key
+            =~ /^initrd|preseedtpl|pxetemplate|console|(pxe|uml)?filename$/xms
+            )
         {
             my $new_key;
             if ( defined $1 ) {
@@ -273,6 +280,9 @@
             elsif ( $key eq 'filename' ) {
                 $new_key = 'pxefilename';
             }
+            elsif ( $key eq 'preseedtpl' ) {
+                $new_key = 'preseed';
+            }
             else {
                 $new_key = $key;
             }
diff -r ca2bd131e40a -r 7bd1f6f80db8 lib/PFTools/Conf/Host.pm
--- a/lib/PFTools/Conf/Host.pm	Wed Apr 09 11:33:55 2014 +0200
+++ b/lib/PFTools/Conf/Host.pm	Wed Apr 09 17:50:18 2014 +0200
@@ -161,6 +161,17 @@
             # Check interfaces
 
             foreach my $link (@link_list) {
+
+                my $iface;
+                $iface
+                    = $host_ref->{"link::$link"}
+                    ->{ 'dev.' . ( 0 + $hostnum ) } ||= $iface
+                    = $host_ref->{"link::$link"}->{'dev'};
+                if ( !$iface ) {
+                    carp
+                        qq{WARNING no 'dev' section for '$hostname', maybe not enough interface on the server};
+                    next;
+                }
                 my $new_iface_ref = __build_iface_entry(
                     {   link_name     => $link,
                         hostname      => $hostname,
@@ -174,7 +185,6 @@
                     }
                 );
 
-                my $iface      = $host_ref->{"link::$link"}->{'dev'};
                 my $iface_name = $iface;
 
                 if ($iface =~ m{
@@ -775,50 +785,60 @@
     }
 
     # Check optional 802.1Q tag
-    my $iface_name = $link_section_ref->{'dev'};
-    my ($iface_tag) = $iface_name =~ m{
-        \A
-        (?:
-            (?:
-                eth | bond
-            )
-            [\d]+
-        )
-        (?:
-            [.]
-            (               # $iface_tag
-                TAG[\d]+
-            )
-        )?
-        \z
-    }xms;
-    if (    $iface_tag
-        and $iface_tag =~ m{\A \d+ \z}xms
-        and $iface_tag ne $vlan_ref->{'tag'} )
-    {
+    my $iface_name = $link_section_ref->{ 'dev.' . ( 0 + $hostnum ) }
+        ||= $link_section_ref->{'dev'};
+    if ( !$iface_name ) {
         croak
-            qq{ERROR: $iface_tag for $link_section_name differs from $vlan_name def};
+            qq{ERROR: no iface name for '$hostname', maybe not enough interface on the server};
     }
-
-    # Bonding "master interface"?
-    if ( $iface_name =~ m{ \A bond }xms and not $iface_tag ) {
-
-        # Check if slaves are not in use
-        my $slave_ifaces_string = $link_section_ref->{"slaves.$host_number"}
-            || $link_section_ref->{'slaves'};
-
-        my @slave_ifaces = split m{ \s* [,] \s* }xms, $slave_ifaces_string;
-
-        foreach my $slave_iface (@slave_ifaces) {
-            if ( any { $_ eq $slave_iface } @iface_list_ref ) {
-                croak
-                    qq{ERROR: host $hostname: $slave_iface already in use, cannot be enslaved to $iface_name};
-            }
+    my $iface_tag;
+    if ($iface_name) {
+        ($iface_tag) = $iface_name =~ m{
+				\A
+				(?:
+					(?:
+						eth | bond
+					)
+					[\d]+
+				)
+				(?:
+					[.]
+					(               # $iface_tag
+						TAG[\d]+
+					)
+				)?
+				\z
+			}xms;
+        if (    $iface_tag
+            and $iface_tag =~ m{\A \d+ \z}xms
+            and $iface_tag ne $vlan_ref->{'tag'} )
+        {
+            croak
+                qq{ERROR: $iface_tag for $link_section_name differs from $vlan_name def};
         }
 
-        $result->{'slaves'} = join q{ }, @slave_ifaces;
-        $result->{'options'} = $link_section_ref->{"options.$host_number"}
-            || $link_section_ref->{'options'};
+        # Bonding "master interface"?
+        if ( $iface_name =~ m{ \A bond }xms and not $iface_tag ) {
+
+            # Check if slaves are not in use
+            my $slave_ifaces_string
+                = $link_section_ref->{"slaves.$host_number"}
+                || $link_section_ref->{'slaves'};
+
+            my @slave_ifaces = split m{ \s* [,] \s* }xms,
+                $slave_ifaces_string;
+
+            foreach my $slave_iface (@slave_ifaces) {
+                if ( any { $_ eq $slave_iface } @iface_list_ref ) {
+                    croak
+                        qq{ERROR: host $hostname: $slave_iface already in use, cannot be enslaved to $iface_name};
+                }
+            }
+
+            $result->{'slaves'} = join q{ }, @slave_ifaces;
+            $result->{'options'} = $link_section_ref->{"options.$host_number"}
+                || $link_section_ref->{'options'};
+        }
     }
 
     # Check address and route values
diff -r ca2bd131e40a -r 7bd1f6f80db8 lib/PFTools/Conf/Syntax.pm
--- a/lib/PFTools/Conf/Syntax.pm	Wed Apr 09 11:33:55 2014 +0200
+++ b/lib/PFTools/Conf/Syntax.pm	Wed Apr 09 17:50:18 2014 +0200
@@ -358,31 +358,6 @@
     my $parsed_keys_list     = {};
     my $check_mandatory_keys = 1;
 
-    if ( $section_type eq 'interface' ) {
-        ( my $iface_type = $section_name ) =~ s{
-                \A
-                    \Q$section_type\E
-                    (?:
-                        ::
-                        (?:                     # logical interface name
-                            (?<iftype>eth|bond) \d+  #   real interface name
-                            (?:                 #   optional 802.1Q tag
-                                [.]
-                                TAG \d+
-                            )?
-                        )
-                    )?
-                \z
-            }
-            {$LAST_PAREN_MATCH{'iftype'}}xms;
-
-        # FIXME arbitrary set $parsed_keys_list->{'slaves'} to 1
-        # due to 'slaves' is a mandatory key on interface sections
-        if ( $iface_type eq 'eth' ) {
-            $parsed_keys_list->{'slaves'} = 1;
-        }
-    }
-
     if ( $context eq 'model' ) {
         if ( $section_type eq 'hostgroup' ) {
             $check_mandatory_keys = 0;
diff -r ca2bd131e40a -r 7bd1f6f80db8 tools/Translate_old_config
--- a/tools/Translate_old_config	Wed Apr 09 11:33:55 2014 +0200
+++ b/tools/Translate_old_config	Wed Apr 09 17:50:18 2014 +0200
@@ -122,11 +122,17 @@
             undef @tempcomment;
         }
     }
-    elsif ( $_ =~ m{\A \s* ([^=\#\s]*) \s* = .*  }msx ) {
+    elsif ( $_ =~ m{\A \s* ([^=\#\s]*) \s* = [^\#]* (\#.*)?  }msx ) {
         if (@tempcomment) {
             @{ $comments->{$current_section}->{$1} } = @tempcomment;
             undef @tempcomment;
         }
+        if ($2) {
+            my ( $subsec, $subval ) = ( $1, $2 );
+            $subsec =~ s/ether/mac/;
+            $subsec =~ s/preseedtpl/preseed/;
+            $comments->{'inline'}->{$current_section}->{$subsec} = $subval;
+        }
     }
 }
 close $FILE
@@ -305,8 +311,16 @@
                             }
 
                             $host_output_fh->print(
-                                "\t$hostkey\t= $trans->{$section}->{$hostdef}->{$hostsection}->{$hostkey}\n"
+                                "\t$hostkey\t= $trans->{$section}->{$hostdef}->{$hostsection}->{$hostkey}"
                             );
+                            if ( $comments->{'inline'}->{$hostdef}
+                                ->{$hostkey} )
+                            {
+                                $host_output_fh->print(
+                                    " $comments->{'inline'}->{$hostdef}->{$hostkey}"
+                                );
+                            }
+                            $host_output_fh->print("\n");
                         }
                     }
                     $host_output_fh->print("\n");
@@ -348,7 +362,12 @@
                         join( qq{\n}, @{ $comments->{$section}->{$key} } )
                             . qq{\n} );
                 }
-                $output_fh->print("\t$key\t= $trans->{$section}->{$key}\n");
+                $output_fh->print("\t$key\t= $trans->{$section}->{$key}");
+                if ( $comments->{'inline'}->{$section}->{$key} ) {
+                    $output_fh->print(
+                        " $comments->{'inline'}->{$section}->{$key}");
+                }
+                $output_fh->print("\n");
             }
             $output_fh->print("\n");
         }



More information about the pf-tools-commits mailing list