pf-tools/pf-tools: 7 new changesets
parmelan-guest at users.alioth.debian.org
parmelan-guest at users.alioth.debian.org
Wed Nov 24 13:19:20 UTC 2010
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/e2000bf3927d
changeset: 1066:e2000bf3927d
user: "Christophe Caillet <quadchris at free.fr>"
date: Wed Nov 24 08:06:58 2010 +0100
description:
Fix: better handling split of public and private part when adding into global structure
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/8e0ede5bb56c
changeset: 1067:8e0ede5bb56c
user: "Christophe Caillet <quadchris at free.fr>"
date: Wed Nov 24 08:08:51 2010 +0100
description:
Fix: now shortname are correctly handle when using resolve_from_global_config, carp instead of croak for better result with is_private_vlan
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/a77648b40fb1
changeset: 1068:a77648b40fb1
user: "Christophe Caillet <quadchris at free.fr>"
date: Wed Nov 24 08:09:38 2010 +0100
description:
Fix: test is now compliant with the structure's changes
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/925526824f3e
changeset: 1069:925526824f3e
user: "Christophe Caillet <quadchris at free.fr>"
date: Wed Nov 24 08:11:16 2010 +0100
description:
Fix: correctly build the zone with structure's changes
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/4fa68a3df02b
changeset: 1070:4fa68a3df02b
user: "Christophe Caillet <quadchris at free.fr>"
date: Wed Nov 24 08:12:12 2010 +0100
description:
Fix: now the result is compliant with __build_zone changes
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/dd629edaa1fa
changeset: 1071:dd629edaa1fa
user: "Christophe Caillet <quadchris at free.fr>"
date: Wed Nov 24 08:20:53 2010 +0100
description:
Add comments for using "ugly shortcuts" (melkor said)
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/3d7b67a62e16
changeset: 1072:3d7b67a62e16
user: "Christophe Caillet <quadchris at free.fr>"
date: Wed Nov 24 14:19:03 2010 +0100
description:
Fix: need to copy datas instead of working directly with references
diffstat:
6 files changed, 5 insertions(+), 9 deletions(-)
lib/PFTools/Conf/Host.pm | 2 +-
lib/PFTools/Conf/Syntax.pm | 2 +-
lib/PFTools/Structqueries.pm | 1 -
lib/PFTools/Utils.pm | 3 ---
t/13.conf.t | 3 +++
t/20.zone.t | 3 ---
diffs (328 lines):
diff -r 07e14d5ec87d -r 3d7b67a62e16 lib/PFTools/Conf/Host.pm
--- a/lib/PFTools/Conf/Host.pm Tue Nov 23 15:56:43 2010 +0100
+++ b/lib/PFTools/Conf/Host.pm Wed Nov 24 14:19:03 2010 +0100
@@ -1131,12 +1131,12 @@
? $zone_part_ref->{'BY_SITE'}->{$site}
: $zone_part_ref->{'ALL_SITES'};
my $added_hostclass = grep m{ \A $hostclass \z }xms,
- @{ $zone_part_ref->{'__hostclass_order'}->{$site} };
+ @{ $zone_entry->{'__hostclass_order'} };
if ( not defined $zone_entry->{$hostclass} and
not $added_hostclass
) {
- push @{ $zone_part_ref->{'__hostclass_order'}->{$site} },
+ push @{ $zone_entry->{'__hostclass_order'} },
$hostclass;
}
diff -r 07e14d5ec87d -r 3d7b67a62e16 lib/PFTools/Conf/Network.pm
--- a/lib/PFTools/Conf/Network.pm Tue Nov 23 15:56:43 2010 +0100
+++ b/lib/PFTools/Conf/Network.pm Wed Nov 24 14:19:03 2010 +0100
@@ -88,7 +88,7 @@
};
foreach my $ip_type (qw( ipv4 ipv6 )) {
- next unless $pf_config->{'features'}->{$ip_type};
+ next if not $pf_config->{'features'}->{$ip_type};
my $zone_key = $ip_type eq 'ipv6' ? 'ZONE6' : 'ZONE';
my $zone_part = $global_config->{$zone_key}->{'BY_NAME'};
@@ -101,8 +101,6 @@
'SOA' => $section_ref,
'BY_SITE' => {},
'ALL_SITES' => {},
- '__network_order' => {},
- '__hostclass_order' => {},
};
}
@@ -188,7 +186,7 @@
my $zone = $section_ref->{'zone'};
my $dhcpvlan = $section_ref->{'dhcpvlan'};
foreach my $ip_type (qw( ipv4 ipv6 )) {
- next unless $pf_config->{'features'}->{$ip_type};
+ next if not $pf_config->{'features'}->{$ip_type};
my $suffix = get_suffix_from_ip_type( $ip_type );
my $zone_part = $global_config->{"ZONE$suffix"};
@@ -272,7 +270,7 @@
# Check IP values
foreach my $ip_type (qw( ipv4 ipv6 )) {
- next unless $pf_config->{'features'}->{$ip_type};
+ next if not $pf_config->{'features'}->{$ip_type};
my $suffix = get_suffix_from_ip_type( $ip_type );
my $subnet_ref = get_subnet_from_vlan( $ip_type, $section_ref );
@@ -415,12 +413,15 @@
$zone_ref->{'gateway'} = qq{A\t} . $ref_net->{"gateway$suffix"};
}
- push @{ $zone_part->{'__network_order'}->{$site} }, $net_name;
if ( is_private_vlan ($net_name, $global_config, $site) ) {
+ push
+ @{ $zone_part->{'BY_SITE'}->{$site}->{'__network_order'} },
+ $net_name;
$zone_part->{'BY_SITE'}->{$site}->{$net_name} = $zone_ref;
}
else {
$zone_part->{'ALL_SITES'}->{$net_name} = $zone_ref;
+ push @{ $zone_part->{'ALL_SITES'}->{'__network_order'} }, $net_name;
}
return 1;
diff -r 07e14d5ec87d -r 3d7b67a62e16 lib/PFTools/Conf/Syntax.pm
--- a/lib/PFTools/Conf/Syntax.pm Tue Nov 23 15:56:43 2010 +0100
+++ b/lib/PFTools/Conf/Syntax.pm Wed Nov 24 14:19:03 2010 +0100
@@ -367,7 +367,9 @@
{
$+{iftype}
}xms;
- $parsed_keys_list->{'slaves'} = 1;
+ # FIXME : arbitrary set $parsed_keys_list->{'slaves'} to 1
+ # due to 'slaves' is a mandatory key on interface sections
+ $parsed_keys_list->{'slaves'} = 1 if ( $iface_type eq 'eth' );
}
if ( $context eq 'model' ) {
@@ -375,8 +377,9 @@
$check_mandatory = 0;
}
if ( $section_type eq 'interface' ) {
+ # FIXME : arbitrary set ipv4 and ipv6 to 1 when context is model
+ # due to ipv4 is mandatory in interface sections
$parsed_keys_list->{'ipv4'} = 1;
- $parsed_keys_list->{'ipv6'} = 1;
}
}
diff -r 07e14d5ec87d -r 3d7b67a62e16 lib/PFTools/Structqueries.pm
--- a/lib/PFTools/Structqueries.pm Tue Nov 23 15:56:43 2010 +0100
+++ b/lib/PFTools/Structqueries.pm Wed Nov 24 14:19:03 2010 +0100
@@ -327,7 +327,8 @@
my $site_part = $global_config->{'SITE'}->{'BY_NAME'}->{$site_name};
unless ($site_part->{'NETWORK'}->{'BY_NAME'}->{$vlan_name}) {
- croak qq{ERROR: unknown vlan $vlan_name on site $site_name};
+ carp qq{ERROR: unknown vlan $vlan_name on site $site_name};
+ return;
}
my $scope = $site_part->{'NETWORK'}->{'BY_NAME'}->{$vlan_name}->{'scope'};
@@ -473,27 +474,43 @@
my $zone_key = $ip_type eq 'ipv6' ? 'ZONE6' : 'ZONE';
my $zone_ref = $global_config->{$zone_key}->{'BY_NAME'}->{$zone_name};
- my $zone_part =
- ( is_private_vlan ($hostvlan, $global_config, $site_name) )
- ? $zone_ref->{'BY_SITE'}->{$site_name}
- : $zone_ref->{'ALL_SITES'};
-
- if ( $hostname =~ m{\A (network|netmask|broadcast|gateway) }xms ) {
- if ( $hostvlan and not $zone_part->{$hostvlan} ) {
- return;
- }
-
- my ( $type, $field ) = split qr{ \s+ }xms,
- $zone_part->{$hostvlan}->{$hostshort};
- return [$field];
+ my $zone_search;
+ if ( $hostvlan ) {
+ my $zone_part =
+ ( is_private_vlan ($hostvlan, $global_config, $site_name) )
+ ? $zone_ref->{'BY_SITE'}->{$site_name}
+ : $zone_ref->{'ALL_SITES'};
+ return if ( not defined $zone_part->{$hostvlan} );
+ $zone_search = [ $zone_part ];
+ }
+ else {
+ $zone_search = [
+ $zone_ref->{'BY_SITE'}->{$site_name}, $zone_ref->{'ALL_SITES'}
+ ];
}
my @fields;
- if ( ref $zone_part->{$hosttype}->{$hostname} eq 'ARRAY' ) {
- @fields = @{ $zone_part->{$hosttype}->{$hostname} };
- }
- else {
- @fields = ( $zone_part->{$hosttype}->{$hostname} );
+ foreach my $zone_part ( @{ $zone_search } ) {
+ if ( $hostname =~ m{\A (network|netmask|broadcast|gateway) }xms ) {
+ if ( $hostvlan and not $zone_part->{$hostvlan} ) {
+ return;
+ }
+ else {
+ use Data::Dumper;
+ print Dumper $zone_part->{$hostvlan};
+ }
+
+ my ( $type, $field ) = split qr{ \s+ }xms,
+ $zone_part->{$hostvlan}->{$hostshort};
+ return [$field];
+ }
+
+ if ( ref $zone_part->{$hosttype}->{$hostname} eq 'ARRAY' ) {
+ push @fields, @{ $zone_part->{$hosttype}->{$hostname} };
+ }
+ else {
+ push @fields, $zone_part->{$hosttype}->{$hostname};
+ }
}
my @result = ();
diff -r 07e14d5ec87d -r 3d7b67a62e16 lib/PFTools/Utils.pm
--- a/lib/PFTools/Utils.pm Tue Nov 23 15:56:43 2010 +0100
+++ b/lib/PFTools/Utils.pm Wed Nov 24 14:19:03 2010 +0100
@@ -1197,10 +1197,10 @@
q{;;============================================================================},
q{};
- my $network_order_ref
- = $global_config->{'ZONE'}->{'BY_NAME'}->{$zone_name}
- ->{'__network_order'}->{$site_name};
- foreach my $network ( @{$network_order_ref} ) {
+ my @network_order = @{ $zone_part->{'__network_order'} };
+ push @network_order,
+ @{ $zone_ref->{'ALL_SITES'}->{'__network_order'} };
+ foreach my $network ( @network_order ) {
my $head = qq{; $network};
if ( $merge->{$network}->{'comment'} ) {
$head .= ": $merge->{$network}->{'comment'}";
@@ -1230,10 +1230,16 @@
q{;;============================================================================},
q{};
- my $hostclass_order_ref
- = $global_config->{'ZONE'}->{'BY_NAME'}->{$zone_name}
- ->{'__hostclass_order'}->{$site_name};
- foreach my $server ( @{$hostclass_order_ref} ) {
+ my @hostclass_order =
+ @{ $zone_ref->{'BY_SITE'}->{$site_name}->{'__hostclass_order'} };
+ foreach my $hc ( @{ $zone_ref->{'ALL_SITES'}->{'__hostclass_roder'} } ) {
+ my $exist = grep m{ \A $hc \z }xms, @hostclass_order;
+ if ( not $exist ) {
+ push @hostclass_order, $hc;
+ }
+ }
+
+ foreach my $server ( @hostclass_order ) {
my $head = qq{; $server};
if ( $merge->{$server}->{'comment'} ) {
diff -r 07e14d5ec87d -r 3d7b67a62e16 t/13.conf.t
--- a/t/13.conf.t Tue Nov 23 15:56:43 2010 +0100
+++ b/t/13.conf.t Wed Nov 24 14:19:03 2010 +0100
@@ -1215,6 +1215,13 @@
'BY_NAME' => {
'private' => {
'ALL_SITES' => {
+ '__hostclass_order' => [
+ 'vip-spawn',
+ 'cbv4-spawn',
+ ],
+ '__network_order' => [
+ 'vlan-pfds-ext',
+ ],
'cbv4-spawn' => {
'cbv4-spawn01.vlan-pfds-ext' => 'A 192.168.1.98',
'cbv4-spawn00.vlan-pfds-ext' => 'A 192.168.1.97',
@@ -1231,6 +1238,17 @@
},
'BY_SITE' => {
'cbv4-pfds' => {
+ '__hostclass_order' => [
+ 'vip-spawn',
+ 'cbv4-pfds-filer',
+ 'cbv4-spawn',
+ ],
+ '__network_order' => [
+ 'vlan-systeme',
+ 'vlan-pfds-int',
+ 'vlan-admindsi',
+ 'vlan-middledsi'
+ ],
'vlan-admindsi' => {
'broadcast' => 'A 10.3.1.255',
'network' => 'A 10.3.1.0',
@@ -1289,6 +1307,12 @@
}
},
'cbv4' => {
+ '__hostclass_order' => [
+ 'cbv4-rdeploy',
+ ],
+ '__network_order' => [
+ 'vlan-systeme',
+ ],
'vlan-systeme' => {
'broadcast' => 'A 10.1.255.255',
'network' => 'A 10.1.0.0',
@@ -1318,16 +1342,6 @@
},
},
},
- '__hostclass_order' => {
- 'cbv4-pfds' => [
- 'vip-spawn',
- 'cbv4-pfds-filer',
- 'cbv4-spawn',
- ],
- 'cbv4' => [
- 'cbv4-rdeploy',
- ],
- },
'SOA' => {
'@ns' => [
'deploy00.vlan-systeme.private.',
@@ -1349,18 +1363,6 @@
'soa' => 'Deploy00.private.',
'expire' => '7D ; Expire (7 days)'
},
- '__network_order' => {
- 'cbv4-pfds' => [
- 'vlan-systeme',
- 'vlan-pfds-int',
- 'vlan-pfds-ext',
- 'vlan-admindsi',
- 'vlan-middledsi'
- ],
- 'cbv4' => [
- 'vlan-systeme'
- ]
- }
},
},
'BY_SITE' => {
diff -r 07e14d5ec87d -r 3d7b67a62e16 t/20.zone.t
--- a/t/20.zone.t Tue Nov 23 15:56:43 2010 +0100
+++ b/t/20.zone.t Wed Nov 24 14:19:03 2010 +0100
@@ -226,13 +226,6 @@
'netmask.vlan-pfds-int IN A 255.255.0.0',
'broadcast.vlan-pfds-int IN A 10.2.255.255',
'',
- '; vlan-pfds-ext',
- ';----------------------------------------------------------------------------',
- 'network.vlan-pfds-ext IN A 192.168.1.0',
- 'netmask.vlan-pfds-ext IN A 255.255.255.0',
- 'broadcast.vlan-pfds-ext IN A 192.168.1.255',
- 'gateway.vlan-pfds-ext IN A 192.168.1.254',
- '',
'; vlan-admindsi',
';----------------------------------------------------------------------------',
'network.vlan-admindsi IN A 10.3.1.0',
@@ -246,6 +239,13 @@
'netmask.vlan-middledsi IN A 255.255.255.0',
'broadcast.vlan-middledsi IN A 10.3.2.255',
'gateway.vlan-middledsi IN A 10.3.2.254',
+ '',
+ '; vlan-pfds-ext',
+ ';----------------------------------------------------------------------------',
+ 'network.vlan-pfds-ext IN A 192.168.1.0',
+ 'netmask.vlan-pfds-ext IN A 255.255.255.0',
+ 'broadcast.vlan-pfds-ext IN A 192.168.1.255',
+ 'gateway.vlan-pfds-ext IN A 192.168.1.254',
'',
'',
'',
More information about the pf-tools-commits
mailing list