pf-tools/pf-tools: 5 new changesets
parmelan-guest at users.alioth.debian.org
parmelan-guest at users.alioth.debian.org
Thu Nov 25 09:52:29 UTC 2010
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/516c1fb7a6d1
changeset: 1078:516c1fb7a6d1
user: "Christophe Caillet <quadchris at free.fr>"
date: Wed Nov 24 18:35:14 2010 +0100
description:
Remove dead code
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/ce2ad7477158
changeset: 1079:ce2ad7477158
user: "Christophe Caillet <quadchris at free.fr>"
date: Wed Nov 24 18:37:20 2010 +0100
description:
Fix: perlcritic complains about postfix if
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/b893c96716b5
changeset: 1080:b893c96716b5
user: "Christophe Caillet <quadchris at free.fr>"
date: Wed Nov 24 18:59:44 2010 +0100
description:
Fix perlcritic about postfix statement (S2) and grep form (S4)
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/4c17b51b1092
changeset: 1081:4c17b51b1092
user: "Christophe Caillet <quadchris at free.fr>"
date: Wed Nov 24 19:25:45 2010 +0100
description:
Fix perlcritics
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/9e79004112bc
changeset: 1082:9e79004112bc
user: "Christophe Caillet <quadchris at free.fr>"
date: Wed Nov 24 19:39:32 2010 +0100
description:
Fix perlcritics : need to fix eval statement
diffstat:
1 file changed, 1 deletion(-)
lib/PFTools/Conf/Network.pm | 1 -
diffs (403 lines):
diff -r 6c3ae9927fb2 -r 9e79004112bc lib/PFTools/Conf/Config.pm
--- a/lib/PFTools/Conf/Config.pm Wed Nov 24 16:21:42 2010 +0100
+++ b/lib/PFTools/Conf/Config.pm Wed Nov 24 19:39:32 2010 +0100
@@ -27,6 +27,7 @@
use base qw( Exporter );
use Carp;
use English qw( -no_match_vars ); # Avoids regex performance penalty
+use Readonly;
use PFTools::Logger;
@@ -54,6 +55,8 @@
'DEPENDS' => {},
};
+Readonly::Scalar my $DEFAULT_AG_PRIO => 200;
+
##########################
# Vars
@@ -72,7 +75,7 @@
sub __Exists_deps {
my ( $dep, $parsed ) = @_;
- return unless $dep or $parsed;
+ return if not ( $dep or $parsed );
print "checking if dep exists\n";
return $parsed->{$dep};
@@ -81,22 +84,29 @@
sub __Same_actiongroup {
my ( $section1, $section2, $parsed ) = @_;
- return unless $section1 or $section2 or $parsed;
+ return if not ( $section1 or $section2 or $parsed );
my $actiongrp1 = $parsed->{$section1}->{'actiongroup'} || 'NONE';
my $actiongrp2 = $parsed->{$section2}->{'actiongroup'} || 'NONE';
my $same = 0;
- $same++ if ( $actiongrp1 eq $actiongrp2 );
- $same++ if (
- ( $parsed->{$section1}->{'action'} eq 'actiongroup'
- && $actiongrp2 eq 'NONE'
- )
- || ( $parsed->{$section2}->{'action'} eq 'actiongroup'
- && $parsed->{$section1}->{'action'} eq 'actiongroup'
- )
- || ( $parsed->{$section2}->{'action'} eq 'actiongroup'
- && $actiongrp1 eq 'NONE'
- )
- );
+ if ( $actiongrp1 eq $actiongrp2 ) {
+ $same++;
+ }
+ if (
+ (
+ $parsed->{$section1}->{'action'} eq 'actiongroup'
+ and $actiongrp2 eq 'NONE'
+ )
+ or
+ (
+ $parsed->{$section2}->{'action'} eq 'actiongroup'
+ and $parsed->{$section1}->{'action'} eq 'actiongroup'
+ )
+ or
+ (
+ $parsed->{$section2}->{'action'} eq 'actiongroup'
+ and $actiongrp1 eq 'NONE'
+ )
+ ) { $same++; }
# $same++ if ( $parsed->{$section}->{'actiongroup'})
return $same;
@@ -115,46 +125,47 @@
# Checking mandatory parameter
foreach my $par ('config','sect_name','ref_sect', 'parsed') {
- return unless $param->{$par};
+ return if not $param->{$par};
}
my $glob_cnf = $param->{'config'};
my $name = $param->{'sect_name'};
my $actiongrp = $param->{'ref_sect'}->{'actiongroup'} || 'NONE';
- $glob_cnf->{'ACTIONGROUP'}->{$actiongrp} = {}
- if ( ! defined $glob_cnf->{'ACTIONGROUP'}->{$actiongrp} );
+ if ( not defined $glob_cnf->{'ACTIONGROUP'}->{$actiongrp} ) {
+ $glob_cnf->{'ACTIONGROUP'}->{$actiongrp} = {};
+ }
my $action_entry = $glob_cnf->{'ACTIONGROUP'}->{$actiongrp};
if ( $param->{'ref_sect'}->{'depends'} ) {
- foreach my $dep ( split (/\s/, $param->{'ref_sect'}->{'depends'})) {
+ foreach my $dep (
+ split m{ \s }xms, $param->{'ref_sect'}->{'depends'}
+ ) {
croak qq{ERROR: Undefined $dep in section $name}
- if( ! __Exists_deps ($dep, $param->{'parsed'}) );
+ if not __Exists_deps ($dep, $param->{'parsed'}) ;
croak qq{ERROR: $dep and $name not on actiongroup $actiongrp}
- unless( __Same_actiongroup(
- $actiongrp, $dep, $param->{'parsed'})
+ if not __Same_actiongroup(
+ $actiongrp, $dep, $param->{'parsed'}
);
}
}
if ($param->{'ref_sect'}->{'action'} eq 'actiongroup') {
- if (
- ! grep(
- /^$name/,
- @{$glob_cnf->{'ACTIONGROUP'}->{'__actiongroups_order'}}
- )
- ) {
- push (
+ my $exist =
+ grep
+ { m{ \A $name }xms }
+ @{$glob_cnf->{'ACTIONGROUP'}->{'__actiongroups_order'}};
+ if ( not $exist ) {
+ push
@{$glob_cnf->{'ACTIONGROUP'}->{'__actiongroups_order'}},
- $name
- );
+ $name;
}
$glob_cnf->{'ACTIONGROUP'}->{$name}->{'priority'} =
- $param->{'ref_sect'}->{'priority'} || 200;
+ $param->{'ref_sect'}->{'priority'} || $DEFAULT_AG_PRIO;
$glob_cnf->{'ACTIONGROUP'}->{$name}->{'__config'} =
$param->{'ref_sect'};
}
else {
- push ( @{$action_entry->{'__order'}}, $name );
+ push @{$action_entry->{'__order'}}, $name;
$action_entry->{$name} = $param->{'ref_sect'};
$action_entry->{$name}->{'__subst'}->{'DESTINATION'} = $name;
}
@@ -162,7 +173,7 @@
return $glob_cnf;
}
-sub __Sort_depends_prio ($$) {
+sub __Sort_depends_prio {
my ( $action, $section ) = @_;
my $prio = 0;
@@ -184,7 +195,7 @@
$prio++;
# Third : Packaging infra and packages
- return $prio if ( $section =~ /^\/etc\/apt\// );
+ return $prio if ( $section =~ m{ \A /etc/apt/ }xms );
$prio++;
return $prio if ( $section eq "pf-tools" );
$prio++;
@@ -202,14 +213,14 @@
$prio++;
# Fifth : removing files and dirs
- return $prio if ( $action =~ /^remove/ );
+ return $prio if ( $action =~ m{ \A remove }xms );
$prio++;
# Last : other elements
return $prio;
}
-sub Sort_config_sections ($$$) {
+sub Sort_config_sections {
my ( $host_config, $a, $b ) = @_;
my $prioa = $host_config->{$a}->{'priority'} ||
diff -r 6c3ae9927fb2 -r 9e79004112bc lib/PFTools/Conf/Host.pm
--- a/lib/PFTools/Conf/Host.pm Wed Nov 24 16:21:42 2010 +0100
+++ b/lib/PFTools/Conf/Host.pm Wed Nov 24 19:39:32 2010 +0100
@@ -211,7 +211,7 @@
}
foreach my $ip_type ( 'ipv4', 'ipv6' ) {
- next unless $pf_config->{'features'}->{$ip_type};
+ next if not $pf_config->{'features'}->{$ip_type};
my $ip_type_suffix = get_suffix_from_ip_type($ip_type);
my $addr_key = qq{BY_ADDR$ip_type_suffix};
@@ -514,7 +514,7 @@
)
\z
}xms;
- next unless $iface;
+ next if not $iface;
push @if_list, $iface;
}
@@ -787,7 +787,7 @@
# Check address and route values
foreach my $ip_type (qw( ipv4 ipv6 )) {
- next unless $pf_config->{'features'}->{$ip_type};
+ next if not $pf_config->{'features'}->{$ip_type};
my $subnet_ref = get_subnet_from_vlan( $ip_type, $vlan_ref );
@@ -810,7 +810,7 @@
my @route_list;
foreach my $key ( keys %{$iface_section_ref} ) {
- next unless $key =~ m{ \A $route_key }xmso;
+ next if $key !~ m{ \A $route_key }xmso;
push @route_list, @{ $iface_section_ref->{$key} };
}
@@ -923,7 +923,7 @@
)?
\z
}xmso;
- return unless $destination;
+ return if not $destination;
my $new_route
= __build_route_destination( $destination, $net_site_ref, $hostname );
@@ -1130,7 +1130,7 @@
( is_private_vlan ($vlan, $global_config, $site) )
? $zone_part_ref->{'BY_SITE'}->{$site}
: $zone_part_ref->{'ALL_SITES'};
- my $added_hostclass = grep m{ \A $hostclass \z }xms,
+ my $added_hostclass = grep { m{ \A $hostclass \z }xms }
@{ $zone_entry->{'__hostclass_order'} };
if ( not defined $zone_entry->{$hostclass} and
@@ -1162,7 +1162,7 @@
}
foreach my $key ( keys %{$dns_def_ref} ) {
- next unless $key =~ m{ \A alias }xms;
+ next if $key !~ m{ \A alias }xms;
my ( $key_type, $alias, $host_num ) = split m{ [.] }xms, $key;
$host_part_ref->{$alias} = $shortname;
@@ -1211,7 +1211,7 @@
$value = $site_part_ref->{$key};
}
- next BOOT_KEY unless $value;
+ next BOOT_KEY if not $value;
# This check should be done only on the deploy hosts
if ($hostname =~ m{ \A $pf_config->{'regex'}->{'deploy_hosts'} \z }xms
@@ -1258,7 +1258,7 @@
foreach my $key ( keys %{$dep_def} ) {
my $value = $host_part_ref->{'deployment'}->{"$key\.$host_number"}
|| $host_part_ref->{'deployment'}->{$key};
- next unless $value;
+ next if not $value;
$result->{$key} = $value;
}
$result->{'dhcpvlan'} = $dhcpvlan;
diff -r 6c3ae9927fb2 -r 9e79004112bc lib/PFTools/Conf/Network.pm
--- a/lib/PFTools/Conf/Network.pm Wed Nov 24 16:21:42 2010 +0100
+++ b/lib/PFTools/Conf/Network.pm Wed Nov 24 19:39:32 2010 +0100
@@ -258,8 +258,8 @@
my $net2add = {
scope => $section_ref->{'scope'},
};
- $net2add->{'comment'} = $section_ref->{'comment'}
- if $section_ref->{'comment'};
+ if ( $section_ref->{'comment'} )
+ { $net2add->{'comment'} = $section_ref->{'comment'}; }
# Check TAG
my $tag = $section_ref->{'tag'};
diff -r 6c3ae9927fb2 -r 9e79004112bc lib/PFTools/Conf/Syntax.pm
--- a/lib/PFTools/Conf/Syntax.pm Wed Nov 24 16:21:42 2010 +0100
+++ b/lib/PFTools/Conf/Syntax.pm Wed Nov 24 19:39:32 2010 +0100
@@ -371,7 +371,7 @@
}xms;
# 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 ( $iface_type eq 'eth' ) { $parsed_keys_list->{'slaves'} = 1 };
}
if ( $context eq 'model' ) {
@@ -387,7 +387,6 @@
my $master_key = ( $context eq 'config' ) ? 'action' : 'type';
foreach my $key ( keys %{$section_hash} ) {
- my @split = split qr{ [.] }xmso, $key;
( my $new = $key ) =~ s{ \A ([^.]+) (?: [.] .*)? \z }{$1}xmso;
my $def_key =
( $int_context eq 'host'
diff -r 6c3ae9927fb2 -r 9e79004112bc lib/PFTools/Packages.pm
--- a/lib/PFTools/Packages.pm Wed Nov 24 16:21:42 2010 +0100
+++ b/lib/PFTools/Packages.pm Wed Nov 24 19:39:32 2010 +0100
@@ -42,7 +42,7 @@
sub Init_pkgtype_module {
my ( $pkg_type, $pf_config ) = @_;
- return unless $pkg_type;
+ return if not $pkg_type;
my $module_name = "PFTools::Packages::".uc( $pkg_type );
my $module;
@@ -57,80 +57,80 @@
sub Get_pkg_status {
my ( $pkg_type, $pkg_name ) = @_;
- return unless $pkg_type or $pkg_name;
+ return if not ( $pkg_type or $pkg_name );
my $result = {};
- if( ! Init_pkgtype_module ( $pkg_type ) ) {
+ if( not Init_pkgtype_module ( $pkg_type ) ) {
carp qq{ERROR: Unable to init package engine $pkg_type};
return;
}
return Pkg_status ( $pkg_name );
}
-sub Update_pkg_repository ($) {
+sub Update_pkg_repository {
my ($pkg_type) = @_;
- return unless $pkg_type;
+ return if not $pkg_type;
- if( ! Init_pkgtype_module ( $pkg_type ) ) {
+ if( not Init_pkgtype_module ( $pkg_type ) ) {
carp qq{ERROR: Unable to init package engine $pkg_type};
return;
}
return Pkg_update_repository ();
}
-sub Purge_pkg ($$) {
+sub Purge_pkg {
my ( $pkg_type, $pkg_name ) = @_;
- return unless $pkg_type or $pkg_name;
+ return if not ( $pkg_type or $pkg_name );
- if( ! Init_pkgtype_module ( $pkg_type ) ) {
+ if( not Init_pkgtype_module ( $pkg_type ) ) {
carp qq{ERROR: Unable to init package engine $pkg_type};
return;
}
return Pkg_purge ( $pkg_name );
}
-sub Get_pkg_depends ($$) {
+sub Get_pkg_depends {
my ( $pkg_type, $pkg_name ) = @_;
- return unless $pkg_type or $pkg_name;
+ return if not ( $pkg_type or $pkg_name );
- if( ! Init_pkgtype_module ( $pkg_type ) ) {
+ if( not Init_pkgtype_module ( $pkg_type ) ) {
carp qq{ERROR: Unable to init package engine $pkg_type};
return;
}
return Pkg_depends ( $pkg_name );
}
-sub Get_pkg_policy ($$$) {
+sub Get_pkg_policy {
my ( $pkg_type, $pkg_name, $version ) = @_;
- return unless $pkg_type or $pkg_name;
+ return if not ( $pkg_type or $pkg_name );
- if( ! Init_pkgtype_module ( $pkg_type ) ) {
+ if( not Init_pkgtype_module ( $pkg_type ) ) {
carp qq{ERROR: Unable to init package engine $pkg_type};
return;
}
return Pkg_policy ( $pkg_name, $version );
}
-sub Cmp_pkg_version ($$$$) {
+sub Cmp_pkg_version {
my ( $pkg_type, $pkg_name, $version1, $version2 ) = @_;
- return unless $pkg_type or $pkg_name or $version1 or $version2;
+ return if not ( $pkg_type or $pkg_name or $version1 or $version2 );
- if( ! Init_pkgtype_module ( $pkg_type ) ) {
+ if( not Init_pkgtype_module ( $pkg_type ) ) {
carp qq{ERROR: Unable to init package engine $pkg_type};
return;
}
return Pkg_compare_versions ( $pkg_name, $version1, $version2 );
}
-sub Install_pkg ($$;$) {
+sub Install_pkg {
my ( $pkg_type, $pkg_name, $version ) = @_;
- return unless $pkg_type or $pkg_name;
+ return if not ( $pkg_type or $pkg_name );
if( ! Init_pkgtype_module ( $pkg_type ) ) {
carp qq{ERROR: Unable to init package engine $pkg_type};
More information about the pf-tools-commits
mailing list