Fix TC-110 - parameterize ip_allow coalescing

Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/553e74f9
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/553e74f9
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/553e74f9

Branch: refs/heads/master
Commit: 553e74f9aa28b15e85f28042249f9304be47b469
Parents: 7591165
Author: Jan van Doorn <j...@apache.org>
Authored: Sat Jan 21 00:07:46 2017 +0000
Committer: Jeremy Mitchell <mitchell...@gmail.com>
Committed: Mon Jan 23 10:42:28 2017 -0700

----------------------------------------------------------------------
 docs/source/admin/traffic_ops_config.rst |  8 ++++++++
 traffic_ops/app/lib/UI/ConfigFiles.pm    | 26 +++++++++++++++++++++-----
 2 files changed, 29 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/553e74f9/docs/source/admin/traffic_ops_config.rst
----------------------------------------------------------------------
diff --git a/docs/source/admin/traffic_ops_config.rst 
b/docs/source/admin/traffic_ops_config.rst
index 90c0c1c..390788c 100644
--- a/docs/source/admin/traffic_ops_config.rst
+++ b/docs/source/admin/traffic_ops_config.rst
@@ -96,6 +96,14 @@ Below is a list of cache parameters that are likely to need 
changes from the def
 
+--------------------------+-------------------+-------------------------------------------------------------------------------------------------------------------------+
 | purge_allow_ip           | ip_allow.config   | The IP address range that is 
allowed to execute the PURGE method on the caches (not related to 
:ref:`rl-purge`)         |
 
+--------------------------+-------------------+-------------------------------------------------------------------------------------------------------------------------+
+| coalesce_masklen_v4     | ip_allow.config   | The masklen to use when 
coalescing v4 networks into one line using 
http://search.cpan.org/~miker/NetAddr-IP-4.078/IP.pm |
++--------------------------+-------------------+-------------------------------------------------------------------------------------------------------------------------+
+| coalesce_number_v4      | ip_allow.config   | The number to use when 
coalescing v4 networks into one line using 
http://search.cpan.org/~miker/NetAddr-IP-4.078/IP.pm  |
++--------------------------+-------------------+-------------------------------------------------------------------------------------------------------------------------+
+| coalesce_masklen_v6     | ip_allow.config   | The masklen to use when 
coalescing v6 networks into one line using 
http://search.cpan.org/~miker/NetAddr-IP-4.078/IP.pm |
++--------------------------+-------------------+-------------------------------------------------------------------------------------------------------------------------+
+| coalesce_masklen_v6     | ip_allow.config   | The masklen to use when 
coalescing v6 networks into one line using 
http://search.cpan.org/~miker/NetAddr-IP-4.078/IP.pm |
++--------------------------+-------------------+-------------------------------------------------------------------------------------------------------------------------+
 | health.threshold.loadavg | rascal.properties | The Unix load average at 
which Traffic Router will stop sending traffic to this cache                    
               |
 
+--------------------------+-------------------+-------------------------------------------------------------------------------------------------------------------------+
 | health.threshold.\\      | rascal.properties | The amount of bandwidth that 
Traffic Router will try to keep available on the cache.                         
           |

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/553e74f9/traffic_ops/app/lib/UI/ConfigFiles.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/UI/ConfigFiles.pm 
b/traffic_ops/app/lib/UI/ConfigFiles.pm
index e10cceb..156ff2c 100644
--- a/traffic_ops/app/lib/UI/ConfigFiles.pm
+++ b/traffic_ops/app/lib/UI/ConfigFiles.pm
@@ -475,9 +475,14 @@ sub ip_allow_data {
        $ipallow->[$i]->{action} = 'ip_allow';
        $ipallow->[$i]->{method} = "ALL";
        $i++;
+
+       # default for coalesce_ipv4 = 24, 5 and for ipv6 48, 5; override with 
the parameters in the server profile.
+       my $coalesce_masklen_v4 = 24;
+       my $coalesce_number_v4 = 5;
+       my $coalesce_masklen_v6 = 24;
+       my $coalesce_number_v6 = 5;
        my $rs_parameter =
-               $self->db->resultset('ProfileParameter')
-               ->search( { profile => $server->profile->id }, { prefetch => [ 
{ parameter => undef }, { profile => undef } ] } );
+               $self->db->resultset('ProfileParameter')->search( { profile => 
$server->profile->id }, { prefetch => [ "parameter", "profile" ] } );
 
        while ( my $row = $rs_parameter->next ) {
                if ( $row->parameter->name eq 'purge_allow_ip' && 
$row->parameter->config_file eq 'ip_allow.config' ) {
@@ -486,6 +491,18 @@ sub ip_allow_data {
                        $ipallow->[$i]->{method} = "ALL";
                        $i++;
                }
+               elsif ($row->parameter->name eq 'coalesce_masklen_v4' && 
$row->parameter->config_file eq 'ip_allow.config' ) {
+                       $coalesce_masklen_v4 = $row->parameter->value;
+               }
+               elsif ($row->parameter->name eq 'coalesce_number_v4' && 
$row->parameter->config_file eq 'ip_allow.config' ) {
+                       $coalesce_number_v4 = $row->parameter->value;
+               }
+               elsif ($row->parameter->name eq 'coalesce_masklen_v6' && 
$row->parameter->config_file eq 'ip_allow.config' ) {
+                       $coalesce_masklen_v6 = $row->parameter->value;
+               }
+               elsif ($row->parameter->name eq 'coalesce_number_v6' && 
$row->parameter->config_file eq 'ip_allow.config' ) {
+                       $coalesce_number_v6 = $row->parameter->value;
+               }
        }
 
        if ( $server->type->name =~ m/^MID/ ) {
@@ -533,9 +550,8 @@ sub ip_allow_data {
                }
 
                # compact, coalesce and compact combined list again
-               # if more than 5 servers are in a /24, list that /24 - TODO 
JvD: parameterize
                my @compacted_list = NetAddr::IP::Compact(@allowed_netaddrips);
-               my $coalesced_list = NetAddr::IP::Coalesce( 24, 5, 
@allowed_netaddrips );
+               my $coalesced_list = NetAddr::IP::Coalesce( 
$coalesce_masklen_v4 , $coalesce_masklen_v4, @allowed_netaddrips );
                my @combined_list  = NetAddr::IP::Compact( @allowed_netaddrips, 
@{$coalesced_list} );
                foreach my $net (@combined_list) {
                        my $range = $net->range();
@@ -548,7 +564,7 @@ sub ip_allow_data {
 
                # now add IPv6. TODO JvD: paremeterize support enabled on/ofd 
and /48 and number 5
                my @compacted__ipv6_list = 
NetAddr::IP::Compact(@allowed_ipv6_netaddrips);
-               my $coalesced_ipv6_list  = NetAddr::IP::Coalesce( 48, 5, 
@allowed_ipv6_netaddrips );
+               my $coalesced_ipv6_list  = NetAddr::IP::Coalesce( 
$coalesce_masklen_v6 , $coalesce_number_v6, @allowed_ipv6_netaddrips );
                my @combined_ipv6_list   = NetAddr::IP::Compact( 
@allowed_ipv6_netaddrips, @{$coalesced_ipv6_list} );
                foreach my $net (@combined_ipv6_list) {
                        my $range = $net->range();

Reply via email to