Repository: incubator-trafficcontrol
Updated Branches:
  refs/heads/master 2429b0a10 -> 811c6ad2a


ports some functionality over from ui namespace. specifically creating location 
params (if don't exist) for header rewrites, regex_remap and cacheurl plus 
creates dsnseckey if cdn is dnssecenabled.


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

Branch: refs/heads/master
Commit: 55175a31ba87623d180c89d01dbc1d8da2776f26
Parents: 2169b45
Author: Jeremy Mitchell <mitchell...@gmail.com>
Authored: Tue Jan 10 14:55:45 2017 -0700
Committer: Jeremy Mitchell <mitchell...@gmail.com>
Committed: Tue Jan 10 14:55:45 2017 -0700

----------------------------------------------------------------------
 traffic_ops/app/lib/API/Deliveryservice.pm | 34 +++++++++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/55175a31/traffic_ops/app/lib/API/Deliveryservice.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/Deliveryservice.pm 
b/traffic_ops/app/lib/API/Deliveryservice.pm
index d202691..3aaa5cc 100644
--- a/traffic_ops/app/lib/API/Deliveryservice.pm
+++ b/traffic_ops/app/lib/API/Deliveryservice.pm
@@ -263,7 +263,7 @@ sub update {
                edge_header_rewrite         => $params->{edgeHeaderRewrite},
                geolimit_redirect_url       => $params->{geoLimitRedirectURL},
                geo_limit                   => $params->{geoLimit},
-               geo_limit_countries         => $params->{geoLimitCountries},
+               geo_limit_countries         => 
sanitize_geo_limit_countries($params->{geoLimitCountries}),
                geo_provider                => $params->{geoProvider},
                global_max_mbps             => $params->{globalMaxMbps},
                global_max_tps              => $params->{globalMaxTps},
@@ -300,6 +300,12 @@ sub update {
 
        my $rs = $ds->update($values);
        if ($rs) {
+               # create location parameters for header_rewrite*, regex_remap* 
and cacheurl* config files if necessary
+               &UI::DeliveryService::header_rewrite( $self, $rs->id, 
$params->{profileId}, $params->{xmlId}, $params->{edgeHeaderRewrite}, "edge" );
+               &UI::DeliveryService::header_rewrite( $self, $rs->id, 
$params->{profileId}, $params->{xmlId}, $params->{midHeaderRewrite},  "mid" );
+               &UI::DeliveryService::regex_remap( $self, $rs->id, 
$params->{profileId}, $params->{xmlId}, $params->{regexRemap} );
+               &UI::DeliveryService::cacheurl( $self, $rs->id, 
$params->{profileId}, $params->{xmlId}, $params->{cacheurl} );
+
                my @response;
                push(
                        @response, {
@@ -403,7 +409,7 @@ sub create {
                edge_header_rewrite         => $params->{edgeHeaderRewrite},
                geolimit_redirect_url       => $params->{geoLimitRedirectURL},
                geo_limit                   => $params->{geoLimit},
-               geo_limit_countries         => $params->{geoLimitCountries},
+               geo_limit_countries         => 
sanitize_geo_limit_countries($params->{geoLimitCountries}),
                geo_provider                => $params->{geoProvider},
                global_max_mbps             => $params->{globalMaxMbps},
                global_max_tps              => $params->{globalMaxTps},
@@ -441,6 +447,18 @@ sub create {
        my $insert = $self->db->resultset('Deliveryservice')->create($values);
        my $rs     = $insert->insert();
        if ($rs) {
+               # create location parameters for header_rewrite*, regex_remap* 
and cacheurl* config files if necessary
+               &UI::DeliveryService::header_rewrite( $self, $rs->id, 
$params->{profileId}, $params->{xmlId}, $params->{edgeHeaderRewrite}, "edge" );
+               &UI::DeliveryService::header_rewrite( $self, $rs->id, 
$params->{profileId}, $params->{xmlId}, $params->{midHeaderRewrite},  "mid" );
+               &UI::DeliveryService::regex_remap( $self, $rs->id, 
$params->{profileId}, $params->{xmlId}, $params->{regexRemap} );
+               &UI::DeliveryService::cacheurl( $self, $rs->id, 
$params->{profileId}, $params->{xmlId}, $params->{cacheurl} );
+
+               my $cdn = $self->db->resultset('Cdn')->search( { id => 
$params->{cdnId} } )->single();
+               my $dnssec_enabled = $cdn->dnssec_enabled;
+               if ( $dnssec_enabled ) {
+                       &UI::DeliveryService::create_dnssec_keys( $self, 
$cdn->name, $params->{xmlId}, $rs->id );
+               }
+
                my @response;
                push(
                        @response, {
@@ -1007,4 +1025,16 @@ sub is_valid_long {
        return undef;
 }
 
+sub sanitize_geo_limit_countries {
+       my $geo_limit_countries = shift;
+
+       if (!defined($geo_limit_countries)) {
+               return "";
+       }
+
+       $geo_limit_countries =~ s/\s+//g;
+       $geo_limit_countries = uc($geo_limit_countries);
+       return $geo_limit_countries;
+}
+
 1;

Reply via email to