You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by mitchell852 <gi...@git.apache.org> on 2017/05/31 15:45:29 UTC

[GitHub] incubator-trafficcontrol pull request #605: [TC-355] Add CDN match checks wh...

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

    https://github.com/apache/incubator-trafficcontrol/pull/605#discussion_r119394809
  
    --- Diff: traffic_ops/app/lib/API/Server.pm ---
    @@ -911,6 +911,21 @@ sub is_server_valid {
     		return ( 0, "Invalid server type" );
     	}
     
    +	my $cdn_mismatch;
    +	if ($id) {
    +		my $profile = $self->db->resultset('Profile')->search( { 'me.id' => $params->{profileId}}, { prefetch => ['cdn'] } )->single();
    +		if ( !defined($profile->cdn) ) {
    +			$cdn_mismatch = 1;
    +		} 
    +		elsif ( $params->{cdnId} != $profile->cdn->id ) {
    +			$cdn_mismatch = 1;
    +		}
    +	}
    +
    +	if ($cdn_mismatch) {
    +		return ( 0, "CDN of profile does not match Server CDN" );
    +	}
    --- End diff --
    
    you could simplify all this code to simply:
    
    if ($id) {
    		my $profile = $self->db->resultset('Profile')->search( { 'me.id' => $params->{profileId}}, { prefetch => ['cdn'] } )->single();
    		if ( !defined($profile->cdn) || $params->{cdnId} != $profile->cdn->id ) {
    			return ( 0, "CDN of profile does not match Server CDN" );
    		}
    	}


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---