Github user mitchell852 commented on a diff in the pull request:

    
https://github.com/apache/incubator-trafficcontrol/pull/141#discussion_r93525547
  
    --- Diff: traffic_ops/app/lib/API/Configs/ApacheTrafficServer.pm ---
    @@ -0,0 +1,1959 @@
    +package API::Configs::ApacheTrafficServer;
    +
    +#
    +#
    +# Licensed under the Apache License, Version 2.0 (the "License");
    +# you may not use this file except in compliance with the License.
    +# You may obtain a copy of the License at
    +#
    +#     http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +#
    +#
    +#
    +use UI::Utils;
    +use Mojo::Base 'Mojolicious::Controller';
    +use Date::Manip;
    +use NetAddr::IP;
    +use Data::Dumper;
    +use UI::DeliveryService;
    +use JSON;
    +use API::DeliveryService::KeysUrlSig qw(URL_SIG_KEYS_BUCKET);
    +use URI;
    +use File::Basename;
    +use File::Path;
    +
    +#Sub to generate ORT json
    +sub ort {
    +   my $self     = shift;
    +   my $id       = $self->param('id');
    +   my $filename = 'ort';
    +   my $scope    = 'server';
    +
    +   ##check user access
    +   if ( !&is_oper($self) ) {
    +           return $self->forbidden();
    +   }
    +
    +   ##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 $data_obj;
    +   my $host_name = $server_obj->host_name;
    +
    +   my %condition = ( 'me.host_name' => $host_name );
    +   my $rs_profile = $self->db->resultset('Server')->search( \%condition, { 
prefetch => [ 'cdn', 'profile' ] } );
    +
    +   my $row = $rs_profile->next;
    +   if ($row) {
    +           my $cdn_name = defined( $row->cdn_id ) ? $row->cdn->name : "";
    +
    +           $data_obj->{'profile'}->{'name'}   = $row->profile->name;
    +           $data_obj->{'profile'}->{'id'}     = $row->profile->id;
    +           $data_obj->{'other'}->{'CDN_name'} = $cdn_name;
    +
    +           %condition = (
    +                   'profile_parameters.profile' => 
$data_obj->{'profile'}->{'id'},
    +                   -or                          => [ 'name' => 'location', 
'name' => 'scope' ]
    +           );
    +           my $rs_config = $self->db->resultset('Parameter')->search( 
\%condition, { join => 'profile_parameters' } );
    +           while ( my $row = $rs_config->next ) {
    +                   if ( $row->name eq 'location' ) {
    +                           $data_obj->{'config_files'}->{ 
$row->config_file }->{'location'} = $row->value;
    +                   }
    +                   elsif ( $row->name eq 'scope' ) {
    +                           $data_obj->{'config_files'}->{ 
$row->config_file }->{'scope'} = $row->value;
    +                   }
    +           }
    +   }
    +
    +   foreach my $file ( keys %$data_obj->{'config_files'} ) {
    +           if ( !defined( $data_obj->{'config_files'}->{$file}->{'scope'} 
) ) {
    +                   $data_obj->{'config_files'}->{$file}->{'scope'} = 
$self->get_scope($file);
    +           }
    +   }
    +
    +   my $file_contents = encode_json($data_obj);
    +
    +   return $self->render( text => $file_contents, format => 'txt' );
    +}
    +
    +#entry point for server scope api route.
    +sub get_server_config {
    +   my $self     = shift;
    +   my $filename = $self->param("filename");
    +   my $id       = $self->param('id');
    +   my $scope    = $self->get_scope($filename);
    --- End diff --
    
    i thought scope was derived from the parameter table. it doesn't look like 
it is here which I actually like better. imo get rid of all the scope 
params/profile_params...unless i'm missing something...


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to