Repository: incubator-trafficcontrol Updated Branches: refs/heads/master 317b92237 -> 865c0efdd
completed scope split for remap Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/043466ff Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/043466ff Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/043466ff Branch: refs/heads/master Commit: 043466ff4c122c4e68adeff32f04fc68d742d18f Parents: 7f02e9d Author: Derek Gelinas <derek_geli...@cable.comcast.com> Authored: Mon Apr 24 09:50:06 2017 -0400 Committer: Jeremy Mitchell <mitchell...@gmail.com> Committed: Mon Apr 24 08:00:24 2017 -0600 ---------------------------------------------------------------------- .../app/lib/API/Configs/ApacheTrafficServer.pm | 26 ++++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/043466ff/traffic_ops/app/lib/API/Configs/ApacheTrafficServer.pm ---------------------------------------------------------------------- diff --git a/traffic_ops/app/lib/API/Configs/ApacheTrafficServer.pm b/traffic_ops/app/lib/API/Configs/ApacheTrafficServer.pm index 0967f3a..d8c8199 100644 --- a/traffic_ops/app/lib/API/Configs/ApacheTrafficServer.pm +++ b/traffic_ops/app/lib/API/Configs/ApacheTrafficServer.pm @@ -135,24 +135,25 @@ sub get_server_config { my $self = shift; my $filename = $self->param("filename"); my $id = $self->param('id'); - my $scope = $self->get_scope($filename); ##check user access if ( !&is_oper($self) ) { return $self->forbidden(); } - ##check the scope - is this the correct route? - if ( $scope ne 'servers' ) { - return $self->alert( "Error - incorrect file scope for route used. Please use the " . $scope . " route." ); - } - ##verify that a valid server ID has been used my $server_obj = $self->server_data($id); if ( !defined($server_obj) ) { return $self->not_found(); } + my $scope = $self->get_scope($filename, $server_obj); + + ##check the scope - is this the correct route? + if ( $scope ne 'servers' ) { + return $self->alert( "Error - incorrect file scope for route used. Please use the " . $scope . " route." ); + } + #generate the config file using the appropriate function my $file_contents; if ( $filename =~ /to_ext_.*\.config/ ) { $file_contents = $self->to_ext_dot_config( $server_obj, $filename ); } @@ -2129,11 +2130,11 @@ sub server_scope_remap_dot_config { foreach my $ds ( @{ $data->{dslist} } ) { foreach my $map_from ( keys %{ $ds->{remap_line} } ) { my $map_to = $ds->{remap_line}->{$map_from}; - $text = $self->build_remap_line( $server_obj, $pdata, $text, $data, $ds, $map_from, $map_to ); + $text = $self->build_remap_line( $server_obj->id, $pdata, $text, $data, $ds, $map_from, $map_to ); } foreach my $map_from ( keys %{ $ds->{remap_line2} } ) { my $map_to = $ds->{remap_line2}->{$map_from}; - $text = $self->build_remap_line( $server_obj, $pdata, $text, $data, $ds, $map_from, $map_to ); + $text = $self->build_remap_line( $server_obj->id, $pdata, $text, $data, $ds, $map_from, $map_to ); } } return $text; @@ -2184,11 +2185,11 @@ sub profile_scope_remap_dot_config { foreach my $ds ( @{ $data->{dslist} } ) { foreach my $map_from ( keys %{ $ds->{remap_line} } ) { my $map_to = $ds->{remap_line}->{$map_from}; - $text = $self->build_remap_line( $profile_obj, $pdata, $text, $data, $ds, $map_from, $map_to ); + $text = $self->build_remap_line( $profile_obj->id, $pdata, $text, $data, $ds, $map_from, $map_to ); } foreach my $map_from ( keys %{ $ds->{remap_line2} } ) { my $map_to = $ds->{remap_line2}->{$map_from}; - $text = $self->build_remap_line( $profile_obj, $pdata, $text, $data, $ds, $map_from, $map_to ); + $text = $self->build_remap_line( $profile_obj->id, $pdata, $text, $data, $ds, $map_from, $map_to ); } } return $text; @@ -2196,7 +2197,7 @@ sub profile_scope_remap_dot_config { sub build_remap_line { my $self = shift; - my $server_obj = shift; + my $id = shift; my $pdata = shift; my $text = shift; my $data = shift; @@ -2209,7 +2210,6 @@ sub build_remap_line { return $text; } - my $host_name = $data->{host_name}; my $dscp = $remap->{dscp}; $map_from =~ s/ccr/__HOSTNAME__/; @@ -2231,7 +2231,7 @@ sub build_remap_line { $text .= " \@plugin=regex_remap.so \@pparam=" . $dqs_file; } elsif ( $remap->{qstring_ignore} == 1 ) { - my $global_exists = $self->profile_param_value( $server_obj->id, 'cacheurl.config', 'location', undef ); + my $global_exists = $self->profile_param_value( $id, 'cacheurl.config', 'location', undef ); if ($global_exists) { $self->app->log->debug( "qstring_ignore == 1, but global cacheurl.config param exists, so skipping remap rename config_file=cacheurl.config parameter if you want to change"