You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by mi...@apache.org on 2017/03/09 19:09:09 UTC

[01/44] incubator-trafficcontrol git commit: cleanup remove debugs

Repository: incubator-trafficcontrol
Updated Branches:
  refs/heads/master f90fa69df -> b1842dc0a


cleanup remove debugs


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

Branch: refs/heads/master
Commit: a6b451b33b2054f2707dce06d38f3c438e818a32
Parents: 5bf0ae7
Author: Jan van Doorn <jv...@apache.org>
Authored: Sat Feb 11 23:22:21 2017 +0000
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:10 2017 +0000

----------------------------------------------------------------------
 .../app/lib/API/DeliveryService/SslKeys.pm      |  1 -
 traffic_ops/app/lib/API/Deliveryservice.pm      |  9 -----
 traffic_ops/app/lib/API/Profile.pm              |  1 -
 .../app/lib/Fixtures/Integration/Parameter.pm   |  2 +-
 .../app/lib/Fixtures/ProfileParameter.pm        | 42 --------------------
 .../Result/DeliveryServiceInfoForDomainList.pm  |  2 +-
 traffic_ops/app/lib/UI/DeliveryService.pm       | 10 ++---
 7 files changed, 7 insertions(+), 60 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/a6b451b3/traffic_ops/app/lib/API/DeliveryService/SslKeys.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/DeliveryService/SslKeys.pm b/traffic_ops/app/lib/API/DeliveryService/SslKeys.pm
index 985b171..c392006 100644
--- a/traffic_ops/app/lib/API/DeliveryService/SslKeys.pm
+++ b/traffic_ops/app/lib/API/DeliveryService/SslKeys.pm
@@ -158,7 +158,6 @@ sub view_by_hostname {
 		my @ds_ids_regex = $self->db->resultset('Deliveryservice')
 			->search( { 'regex.pattern' => "$host_regex" }, { join => { deliveryservice_regexes => { regex => undef } } } )->get_column('id')->all();
 
-		# TODO JvD - test this with online riak servers!
 		my $cdn_id = $self->db->resultset('Cdn')->search( { domain_name => $domain_name } )->get_column('id')->single();
 		my@domain_profiles = $self->db->resultset('Profile')->search( { cdn => $cdn_id } )->get_column('id')->all();
 

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/a6b451b3/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 b7eb1f9..fd91af2 100644
--- a/traffic_ops/app/lib/API/Deliveryservice.pm
+++ b/traffic_ops/app/lib/API/Deliveryservice.pm
@@ -93,7 +93,6 @@ sub index {
 				"missLat"                  => defined($row->miss_lat) ? 0.0 + $row->miss_lat : undef,
 				"missLat"                  => defined($row->miss_long) ? 0.0 + $row->miss_long : undef,
 				"multiSiteOrigin"          => \$row->multi_site_origin,
-				# "multiSiteOriginAlgorithm" => $row->multi_site_origin_algorithm,
 				"orgServerFqdn"            => $row->org_server_fqdn,
 				"originShield"             => $row->origin_shield,
 				"profileId"                => defined($row->profile) ? $row->profile->id : undef,
@@ -190,7 +189,6 @@ sub show {
 				"missLat"                  => defined($row->miss_lat) ? 0.0 + $row->miss_lat : undef,
 				"missLat"                  => defined($row->miss_long) ? 0.0 + $row->miss_long : undef,
 				"multiSiteOrigin"          => \$row->multi_site_origin,
-				# "multiSiteOriginAlgorithm" => $row->multi_site_origin_algorithm,
 				"orgServerFqdn"            => $row->org_server_fqdn,
 				"originShield"             => $row->origin_shield,
 				"profileId"                => $row->profile->id,
@@ -225,7 +223,6 @@ sub update {
 	}
 
 	my ( $is_valid, $result ) = $self->is_deliveryservice_valid($params);
-	print ">>>> " . $is_valid . " > < " . $result . "\n";
 	if ( !$is_valid ) {
 		return $self->alert($result);
 	}
@@ -275,7 +272,6 @@ sub update {
 		miss_lat                    => $params->{missLat},
 		miss_long                   => $params->{missLong},
 		multi_site_origin           => $params->{multiSiteOrigin},
-		# multi_site_origin_algorithm => $params->{multiSiteOriginAlgorithm},
 		org_server_fqdn             => $params->{orgServerFqdn},
 		origin_shield               => $params->{originShield},
 		profile                     => $params->{profileId},
@@ -338,7 +334,6 @@ sub update {
 				"missLat"                  => 0.0 + $rs->miss_lat,
 				"missLong"                 => 0.0 + $rs->miss_long,
 				"multiSiteOrigin"          => $rs->multi_site_origin,
-				# "multiSiteOriginAlgorithm" => $rs->multi_site_origin_algorithm,
 				"orgServerFqdn"            => $rs->org_server_fqdn,
 				"originShield"             => $rs->origin_shield,
 				"profileId"                => $rs->profile->id,
@@ -421,7 +416,6 @@ sub create {
 		miss_lat                    => $params->{missLat},
 		miss_long                   => $params->{missLong},
 		multi_site_origin           => $params->{multiSiteOrigin},
-		# multi_site_origin_algorithm => $params->{multiSiteOriginAlgorithm},
 		org_server_fqdn             => $params->{orgServerFqdn},
 		origin_shield               => $params->{originShield},
 		profile                     => $params->{profileId},
@@ -494,7 +488,6 @@ sub create {
 				"missLat"                  => $insert->miss_lat,
 				"missLong"                 => $insert->miss_long,
 				"multiSiteOrigin"          => $insert->multi_site_origin,
-				#"multiSiteOriginAlgorithm" => $insert->multi_site_origin_algorithm,
 				"orgServerFqdn"            => $insert->org_server_fqdn,
 				"originShield"             => $insert->origin_shield,
 				"profileId"                => $insert->profile->id,
@@ -607,7 +600,6 @@ sub get_deliveryservices_by_serverId {
 					"missLat"                  => $row->miss_lat,
 					"missLong"                 => $row->miss_long,
 					"multiSiteOrigin"          => \$row->multi_site_origin,
-					"multiSiteOriginAlgorithm" => $row->multi_site_origin_algorithm,
 					"orgServerFqdn"            => $row->org_server_fqdn,
 					"originShield"             => $row->origin_shield,
 					"profileId"                => $row->profile->id,
@@ -682,7 +674,6 @@ sub get_deliveryservices_by_userId {
 					"missLat"                  => $row->miss_lat,
 					"missLong"                 => $row->miss_long,
 					"multiSiteOrigin"          => \$row->multi_site_origin,
-					"multiSiteOriginAlgorithm" => $row->multi_site_origin_algorithm,
 					"orgServerFqdn"            => $row->org_server_fqdn,
 					"originShield"             => $row->origin_shield,
 					"profileId"                => $row->profile->id,

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/a6b451b3/traffic_ops/app/lib/API/Profile.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/Profile.pm b/traffic_ops/app/lib/API/Profile.pm
index 7e05f47..065cd59 100644
--- a/traffic_ops/app/lib/API/Profile.pm
+++ b/traffic_ops/app/lib/API/Profile.pm
@@ -124,7 +124,6 @@ sub show {
 
 sub create {
 	my $self   = shift;
-	print "KK:\n";
 	my $params = $self->req->json;
 	if ( !defined($params) ) {
 		return $self->alert("parameters must be in JSON format,  please check!");

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/a6b451b3/traffic_ops/app/lib/Fixtures/Integration/Parameter.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Fixtures/Integration/Parameter.pm b/traffic_ops/app/lib/Fixtures/Integration/Parameter.pm
index 9633bdb..66384a6 100644
--- a/traffic_ops/app/lib/Fixtures/Integration/Parameter.pm
+++ b/traffic_ops/app/lib/Fixtures/Integration/Parameter.pm
@@ -18,7 +18,7 @@ package Fixtures::Integration::Parameter;
 # under the License.
 
 
-# Note - removing the NODNAME parameter wreaks all kinds of havoc because of ordering / id problems, so I renamed
+# Note - removing the domain_name parameter wreaks all kinds of havoc because of ordering / id problems, so I renamed
 # it to NODNAME - JvD
 
 use Moose;

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/a6b451b3/traffic_ops/app/lib/Fixtures/ProfileParameter.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Fixtures/ProfileParameter.pm b/traffic_ops/app/lib/Fixtures/ProfileParameter.pm
index 20864b2..87cad71 100644
--- a/traffic_ops/app/lib/Fixtures/ProfileParameter.pm
+++ b/traffic_ops/app/lib/Fixtures/ProfileParameter.pm
@@ -19,48 +19,6 @@ use namespace::autoclean;
 use Digest::SHA1 qw(sha1_hex);
 
 my %definition_for = (
-    # domain_name => {
-    #     new   => 'ProfileParameter',
-    #     using => {
-    #         profile   => 100,
-    #         parameter => 3,
-    #     },
-    # },
-    # domain_name2 => {
-    #     new   => 'ProfileParameter',
-    #     using => {
-    #         profile   => 200,
-    #         parameter => 3,
-    #     },
-    # },
-    # domain_name3 => {
-    #     new   => 'ProfileParameter',
-    #     using => {
-    #         profile   => 300,
-    #         parameter => 3,
-    #     },
-    # },
-    # domain_name5 => {
-    #     new   => 'ProfileParameter',
-    #     using => {
-    #         profile   => 500,
-    #         parameter => 3,
-    #     },
-    # },
-    # domain_name6 => {
-    #     new   => 'ProfileParameter',
-    #     using => {
-    #         profile   => 600,
-    #         parameter => 3,
-    #     },
-    # },
-    # domain_name7 => {
-    #     new   => 'ProfileParameter',
-    #     using => {
-    #         profile   => 700,
-    #         parameter => 3,
-    #     },
-    # },
     rascal_properties1 => {
         new   => 'ProfileParameter',
         using => {

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/a6b451b3/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForDomainList.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForDomainList.pm b/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForDomainList.pm
index 310c914..20788c8 100644
--- a/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForDomainList.pm
+++ b/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForDomainList.pm
@@ -101,7 +101,7 @@ __PACKAGE__->add_columns(
 	"protocol",                    { data_type => "tinyint", is_nullable => 0, size => 4 },
 	"range_request_handling",      { data_type => "tinyint", is_nullable => 0, size => 4 },
 	"origin_shield",               { data_type => "varchar", is_nullable => 0, size => 1024 },
-    "profile",                     { data_type => "integer", is_nullable => 1},
+	"profile",                     { data_type => "integer", is_nullable => 1},
 );
 
 1;

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/a6b451b3/traffic_ops/app/lib/UI/DeliveryService.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/UI/DeliveryService.pm b/traffic_ops/app/lib/UI/DeliveryService.pm
index f319757..42604c1 100644
--- a/traffic_ops/app/lib/UI/DeliveryService.pm
+++ b/traffic_ops/app/lib/UI/DeliveryService.pm
@@ -734,9 +734,9 @@ sub update {
 		my $referer = $self->req->headers->header('referer');
 		return $self->redirect_to($referer);
 	}
-	foreach my $f ($self->param) {
-		print $f . " => " . $self->param($f) . "\n";
-	}
+#	foreach my $f ($self->param) {
+#		print $f . " => " . $self->param($f) . "\n";
+#	}
 
 	if ( $self->check_deliveryservice_input( $self->param('ds.cdn_id'), $id ) ) {
 
@@ -799,7 +799,7 @@ sub update {
 			$hash{http_bypass_fqdn} = $self->param('ds.http_bypass_fqdn');
 		}
 
-		print Dumper( \%hash );
+		#print Dumper( \%hash );
 		my $update = $self->db->resultset('Deliveryservice')->find( { id => $id } );
 		$update->update( \%hash );
 		$update->update();
@@ -958,7 +958,7 @@ sub create {
 	}
 
 	if ( $self->check_deliveryservice_input($cdn_id) ) {
-		print "CDN:$cdn_id\n";
+		#print "CDN:$cdn_id\n";
 		my $insert = $self->db->resultset('Deliveryservice')->create(
 			{
 				xml_id                      => $self->paramAsScalar('ds.xml_id'),


[24/44] incubator-trafficcontrol git commit: Add profile to query

Posted by mi...@apache.org.
Add profile to query


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

Branch: refs/heads/master
Commit: a24dd9de6a20ec2982bf4408a112f9b8363e024b
Parents: 71731cb
Author: Jan van Doorn <jv...@apache.org>
Authored: Sat Feb 11 20:40:19 2017 +0000
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:10 2017 +0000

----------------------------------------------------------------------
 .../app/lib/Schema/Result/DeliveryServiceInfoForServerList.pm    | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/a24dd9de/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForServerList.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForServerList.pm b/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForServerList.pm
index c7d6c02..13f5639 100644
--- a/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForServerList.pm
+++ b/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForServerList.pm
@@ -58,7 +58,8 @@ SELECT
     deliveryservice.cacheurl as cacheurl,
     deliveryservice.remap_text as remap_text,
     mid_header_rewrite as mid_header_rewrite,
-    deliveryservice.protocol as protocol
+    deliveryservice.protocol as protocol,
+    deliveryservice.profile as profile
 FROM
     deliveryservice
         JOIN deliveryservice_regex ON deliveryservice_regex.deliveryservice = deliveryservice.id
@@ -93,6 +94,7 @@ __PACKAGE__->add_columns(
 	"protocol",                    { data_type => "tinyint", is_nullable => 0, size => 4 },
 	"range_request_handling",      { data_type => "tinyint", is_nullable => 0, size => 4 },
 	"origin_shield",               { data_type => "varchar", is_nullable => 0, size => 1024 },
+	"profile",                     { data_type => "integer", is_nullable => 1},
 );
 
 1;


[33/44] incubator-trafficcontrol git commit: add qsh support, 5.x generation works now - no diff

Posted by mi...@apache.org.
add qsh support, 5.x generation works now - no diff


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

Branch: refs/heads/master
Commit: c1d25200be745b9fb2f3958e2d452284bfb44f54
Parents: 0449913
Author: Jan van Doorn <jv...@apache.org>
Authored: Sun Feb 12 17:45:14 2017 +0000
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:11 2017 +0000

----------------------------------------------------------------------
 traffic_ops/app/lib/UI/ConfigFiles.pm | 61 ++++++++++++------------------
 1 file changed, 25 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/c1d25200/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 0df9123..7154b56 100644
--- a/traffic_ops/app/lib/UI/ConfigFiles.pm
+++ b/traffic_ops/app/lib/UI/ConfigFiles.pm
@@ -396,7 +396,6 @@ sub parent_data {
 			my $rank             = $profile_cache{$pid}->{rank};
 			my $primary_parent   = $server->cachegroup->parent_cachegroup_id // -1;
 			my $secondary_parent = $server->cachegroup->secondary_parent_cachegroup_id // -1;
-			print "ds_domain:" . $ds_domain . " server_domain: " . $server_domain . "\n";
 
 			if ( defined($ds_domain) && defined($server_domain) && $ds_domain eq $server_domain ) {
 				my %p = (
@@ -1094,7 +1093,8 @@ sub parent_dot_config {
 
 	my $server      = $self->server_data($id);
 	my $server_type = $server->type->name;
-	my $parent_qstring;
+
+	#my $parent_qstring;
 	my $pinfo;
 	my $text = $self->header_comment( $server->host_name );
 	if ( !defined($data) ) {
@@ -1106,12 +1106,24 @@ sub parent_dot_config {
 	if ( $server_type =~ m/^MID/ ) {
 		my @unique_origin;
 		foreach my $ds ( @{ $data->{dslist} } ) {
-			my $xml_id = $ds->{ds_xml_id};
-			my $os     = $ds->{origin_shield};
-			$parent_qstring = "ignore";
-			my $multi_site_origin           = defined( $ds->{multi_site_origin} )           ? $ds->{multi_site_origin}           : 0;
-			my $multi_site_origin_algorithm = defined( $ds->{multi_site_origin_algorithm} ) ? $ds->{multi_site_origin_algorithm} : 0;
-
+			my $xml_id                           = $ds->{ds_xml_id};
+			my $os                               = $ds->{origin_shield};
+			my $multi_site_origin                = defined( $ds->{multi_site_origin} ) ? $ds->{multi_site_origin} : 0;
+			my $msoa                             = $ds->{'param'}->{'parent.config'}->{'mso.algorithm'};
+			my $mso_algorithm                    = defined($msoa) ? $msoa : 0;
+			my $dsre                             = $ds->{'param'}->{'parent.config'}->{'mso.dead_server_retry_enabled'};
+			my $dead_server_retry_enabled        = defined($dsre) ? $dsre : 0;
+			my $sre                              = $ds->{'param'}->{'parent.config'}->{'mso.simple_retry_enabled'};
+			my $simple_retry_enabled             = defined($sre) ? $sre : 0;
+			my $srsc                             = $ds->{'param'}->{'parent.config'}->{'mso.simple_retry_response_codes'};
+			my $simple_retry_response_codes      = defined($srsc) ? $srsc : "";
+			my $dsrrc                            = $ds->{'param'}->{'parent.config'}->{'mso.dead_server_retry_response_codes'};
+			my $dead_server_retry_response_codes = defined($dsrrc) ? $dsrrc : "";
+			my $qsh                              = $ds->{'param'}->{'parent.config'}->{'mso.qstring_handling'};
+			my $parent_qstring                   = "ignore"; # default is ignore, unless for alg consistent_hash
+			if ( !defined($qsh) && $mso_algorithm eq 'consistent_hash' && $ds->{qstring_ignore} == 0 ) {
+				$parent_qstring = 'consider';
+			}
 			my $org_uri = URI->new( $ds->{org} );
 
 			# Don't duplicate origin line if multiple seen
@@ -1168,28 +1180,7 @@ sub parent_dot_config {
 					@null_parent_info = grep { !$seen{$_}++ } @null_parent_info;
 				}
 				my $parents = 'parent="' . join( '', @parent_info ) . '' . join( '', @secondary_parent_info ) . '' . join( '', @null_parent_info ) . '"';
-				my $mso_algorithm = "";
-				if ( $multi_site_origin_algorithm == 0 ) {
-					$mso_algorithm = "consistent_hash";
-					if ( $ds->{qstring_ignore} == 0 ) {
-						$parent_qstring = "consider";
-					}
-				}
-				elsif ( $multi_site_origin_algorithm == 1 ) {
-					$mso_algorithm = "false";
-				}
-				elsif ( $multi_site_origin_algorithm == 2 ) {
-					$mso_algorithm = "strict";
-				}
-				elsif ( $multi_site_origin_algorithm == 3 ) {
-					$mso_algorithm = "true";
-				}
-				elsif ( $multi_site_origin_algorithm == 4 ) {
-					$mso_algorithm = "latched";
-				}
-				else {
-					$mso_algorithm = "consistent_hash";
-				}
+
 				$text .= "$parents round_robin=$mso_algorithm qstring=$parent_qstring go_direct=false parent_is_proxy=false\n";
 			}
 		}
@@ -1198,16 +1189,12 @@ sub parent_dot_config {
 		$self->app->log->debug( "MID PARENT.CONFIG:\n" . $text . "\n" );
 		return $text;
 	}
-	else {
-
-		#"True" Parent
+	else {    #"True" Parent - we are genning a EDGE config that points to a parent proxy.
 		$pinfo = $self->parent_data($server);
-
 		my %done = ();
 
 		foreach my $remap ( @{ $data->{dslist} } ) {
 			my $org = $remap->{org};
-			$parent_qstring = "ignore";
 			next if !defined $org || $org eq "";
 			next if $done{$org};
 			my $org_uri = URI->new($org);
@@ -1215,7 +1202,9 @@ sub parent_dot_config {
 				$text .= "dest_domain=" . $org_uri->host . " port=" . $org_uri->port . " go_direct=true\n";
 			}
 			else {
-				if ( $remap->{qstring_ignore} == 0 ) {
+				my $qsh = $remap->{'param'}->{'parent.config'}->{'psel.qstring_handling'};
+				my $parent_qstring = defined($qsh) ? $qsh : "ignore";
+				if ( $remap->{qstring_ignore} == 0 && !defined($qsh) ) {
 					$parent_qstring = "consider";
 				}
 


[35/44] incubator-trafficcontrol git commit: Add license to migration

Posted by mi...@apache.org.
Add license to migration


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

Branch: refs/heads/master
Commit: 86252a8732bc445406403ab98d2a418df0d0a22e
Parents: 8a43022
Author: Jan van Doorn <jv...@apache.org>
Authored: Mon Feb 13 01:18:34 2017 +0000
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:11 2017 +0000

----------------------------------------------------------------------
 .../20170205101432_cdn_table_domain_name.go          | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/86252a87/traffic_ops/app/db/migrations/20170205101432_cdn_table_domain_name.go
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/migrations/20170205101432_cdn_table_domain_name.go b/traffic_ops/app/db/migrations/20170205101432_cdn_table_domain_name.go
index 3b341c9..70cb01c 100644
--- a/traffic_ops/app/db/migrations/20170205101432_cdn_table_domain_name.go
+++ b/traffic_ops/app/db/migrations/20170205101432_cdn_table_domain_name.go
@@ -1,3 +1,18 @@
+// 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.
+
+// This file was initially generated by gen_to_start.go (add link), as a start
+// of the Traffic Ops golang data model
+
 package main
 
 import (


[10/44] incubator-trafficcontrol git commit: Add cdn column to profile table

Posted by mi...@apache.org.
Add cdn column to profile table


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

Branch: refs/heads/master
Commit: 36a4d0ea4f721de835b0001a2459680a5519514e
Parents: de60ccc
Author: Jan van Doorn <ja...@cable.comcast.com>
Authored: Mon Dec 26 14:47:16 2016 -0700
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:10 2017 +0000

----------------------------------------------------------------------
 .../20161226000000_cdn_domain_name.sql          | 26 +++++++++++++---
 traffic_ops/app/lib/Schema/Result/Cdn.pm        | 19 ++++++++++--
 traffic_ops/app/lib/Schema/Result/Profile.pm    | 32 ++++++++++++++++++--
 3 files changed, 69 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/36a4d0ea/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql b/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql
index 7b38d64..65a7b74 100644
--- a/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql
+++ b/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql
@@ -17,19 +17,37 @@
 -- SQL in section 'Up' is executed when this migration is applied
 
 ALTER TABLE public.cdn ADD COLUMN domain_name text;
-
 UPDATE cdn SET domain_name=domainlist.value
   FROM (SELECT distinct cdn_id,value FROM server,parameter WHERE type=(SELECT id FROM type WHERE name='EDGE') 
     AND parameter.id in (select parameter from profile_parameter WHERE profile_parameter.profile=server.profile) 
     AND parameter.name='domain_name' 
     AND config_file='CRConfig.json') AS domainlist
 WHERE id = domainlist.cdn_id;
-
 UPDATE public.cdn SET domain_name='-' WHERE name='ALL';
-
 ALTER TABLE public.cdn ALTER COLUMN domain_name SET NOT NULL;
 
+ALTER TABLE public.profile ADD COLUMN cdn bigint;
+ALTER TABLE public.profile
+  ADD CONSTRAINT fk_cdn1 FOREIGN KEY (cdn)
+      REFERENCES public.cdn (id) MATCH SIMPLE
+      ON UPDATE RESTRICT ON DELETE RESTRICT;
+CREATE INDEX idx_181818_fk_cdn1
+  ON public.profile
+  USING btree
+  (cdn);
+
+UPDATE profile set cdn=domainlist.cdn_id
+  FROM (SELECT distinct profile.id AS profile_id, value AS profile_domain_name, cdn.id cdn_id 
+    FROM profile, parameter, cdn, profile_parameter
+    WHERE parameter.name='domain_name'
+    AND parameter.config_file='CRConfig.json'
+    AND parameter.value = cdn.domain_name
+    AND parameter.id in (select parameter from profile_parameter where profile=profile.id)) as domainlist
+WHERE id = domainlist.profile_id;
+
 -- +goose Down
 -- SQL section 'Down' is executed when this migration is rolled back
 
-ALTER TABLE public.cdn DROP COLUMN domain_name;
\ No newline at end of file
+ALTER TABLE public.cdn DROP COLUMN domain_name;
+
+ALTER TABLE public.profile DROP COLUMN cdn;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/36a4d0ea/traffic_ops/app/lib/Schema/Result/Cdn.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Schema/Result/Cdn.pm b/traffic_ops/app/lib/Schema/Result/Cdn.pm
index 28b7f6b..bb0e520 100644
--- a/traffic_ops/app/lib/Schema/Result/Cdn.pm
+++ b/traffic_ops/app/lib/Schema/Result/Cdn.pm
@@ -121,6 +121,21 @@ __PACKAGE__->has_many(
   { cascade_copy => 0, cascade_delete => 0 },
 );
 
+=head2 profiles
+
+Type: has_many
+
+Related object: L<Schema::Result::Profile>
+
+=cut
+
+__PACKAGE__->has_many(
+  "profiles",
+  "Schema::Result::Profile",
+  { "foreign.cdn" => "self.id" },
+  { cascade_copy => 0, cascade_delete => 0 },
+);
+
 =head2 servers
 
 Type: has_many
@@ -152,8 +167,8 @@ __PACKAGE__->might_have(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.07046 @ 2016-12-26 10:44:56
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:AQZpzzOuEpgmacUrJGl+LQ
+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2016-12-26 14:46:31
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:QlfY6K6vVxW5C9vsHc4YqA
 
 
 # You can replace this text with custom code or comments, and it will be preserved on regeneration

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/36a4d0ea/traffic_ops/app/lib/Schema/Result/Profile.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Schema/Result/Profile.pm b/traffic_ops/app/lib/Schema/Result/Profile.pm
index 4ece9ed..2839364 100644
--- a/traffic_ops/app/lib/Schema/Result/Profile.pm
+++ b/traffic_ops/app/lib/Schema/Result/Profile.pm
@@ -47,6 +47,12 @@ __PACKAGE__->table("profile");
   is_nullable: 1
   original: {default_value => \"now()"}
 
+=head2 cdn
+
+  data_type: 'bigint'
+  is_foreign_key: 1
+  is_nullable: 1
+
 =cut
 
 __PACKAGE__->add_columns(
@@ -68,6 +74,8 @@ __PACKAGE__->add_columns(
     is_nullable   => 1,
     original      => { default_value => \"now()" },
   },
+  "cdn",
+  { data_type => "bigint", is_foreign_key => 1, is_nullable => 1 },
 );
 
 =head1 PRIMARY KEY
@@ -98,6 +106,26 @@ __PACKAGE__->add_unique_constraint("idx_18384_name_unique", ["name"]);
 
 =head1 RELATIONS
 
+=head2 cdn
+
+Type: belongs_to
+
+Related object: L<Schema::Result::Cdn>
+
+=cut
+
+__PACKAGE__->belongs_to(
+  "cdn",
+  "Schema::Result::Cdn",
+  { id => "cdn" },
+  {
+    is_deferrable => 0,
+    join_type     => "LEFT",
+    on_delete     => "RESTRICT",
+    on_update     => "RESTRICT",
+  },
+);
+
 =head2 deliveryservices
 
 Type: has_many
@@ -144,8 +172,8 @@ __PACKAGE__->has_many(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.07046 @ 2016-12-26 10:44:56
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:lLgKBTaWgSw4T1NXk7jh/g
+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2016-12-26 14:46:31
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:osx+OzuftRlkWwKwb1N+hg
 
 
 # You can replace this text with custom code or comments, and it will be preserved on regeneration


[32/44] incubator-trafficcontrol git commit: Add ATS 6.2 support. Finally!

Posted by mi...@apache.org.
Add ATS 6.2 support. Finally!


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

Branch: refs/heads/master
Commit: 8a430221c608f1dbc244481ed979b7b8bab33e02
Parents: f0b9d96
Author: Jan van Doorn <jv...@apache.org>
Authored: Mon Feb 13 00:34:26 2017 +0000
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:11 2017 +0000

----------------------------------------------------------------------
 traffic_ops/app/lib/UI/ConfigFiles.pm | 43 +++++++++++++++++-------------
 1 file changed, 25 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/8a430221/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 7154b56..12c64fb 100644
--- a/traffic_ops/app/lib/UI/ConfigFiles.pm
+++ b/traffic_ops/app/lib/UI/ConfigFiles.pm
@@ -1094,7 +1094,12 @@ sub parent_dot_config {
 	my $server      = $self->server_data($id);
 	my $server_type = $server->type->name;
 
-	#my $parent_qstring;
+	my $ats_ver =
+		$self->db->resultset('ProfileParameter')
+		->search( { 'parameter.name' => 'trafficserver', 'parameter.config_file' => 'package', 'profile.id' => $server->profile->id },
+		{ prefetch => [ 'profile', 'parameter' ] } )->get_column('parameter.value')->single();
+	my $ats_major_version = substr( $ats_ver, 0, 1 );
+
 	my $pinfo;
 	my $text = $self->header_comment( $server->host_name );
 	if ( !defined($data) ) {
@@ -1106,21 +1111,17 @@ sub parent_dot_config {
 	if ( $server_type =~ m/^MID/ ) {
 		my @unique_origin;
 		foreach my $ds ( @{ $data->{dslist} } ) {
-			my $xml_id                           = $ds->{ds_xml_id};
-			my $os                               = $ds->{origin_shield};
-			my $multi_site_origin                = defined( $ds->{multi_site_origin} ) ? $ds->{multi_site_origin} : 0;
-			my $msoa                             = $ds->{'param'}->{'parent.config'}->{'mso.algorithm'};
-			my $mso_algorithm                    = defined($msoa) ? $msoa : 0;
-			my $dsre                             = $ds->{'param'}->{'parent.config'}->{'mso.dead_server_retry_enabled'};
-			my $dead_server_retry_enabled        = defined($dsre) ? $dsre : 0;
-			my $sre                              = $ds->{'param'}->{'parent.config'}->{'mso.simple_retry_enabled'};
-			my $simple_retry_enabled             = defined($sre) ? $sre : 0;
-			my $srsc                             = $ds->{'param'}->{'parent.config'}->{'mso.simple_retry_response_codes'};
-			my $simple_retry_response_codes      = defined($srsc) ? $srsc : "";
-			my $dsrrc                            = $ds->{'param'}->{'parent.config'}->{'mso.dead_server_retry_response_codes'};
-			my $dead_server_retry_response_codes = defined($dsrrc) ? $dsrrc : "";
-			my $qsh                              = $ds->{'param'}->{'parent.config'}->{'mso.qstring_handling'};
-			my $parent_qstring                   = "ignore"; # default is ignore, unless for alg consistent_hash
+			my $xml_id                             = $ds->{ds_xml_id};
+			my $os                                 = $ds->{origin_shield};
+			my $multi_site_origin                  = $ds->{multi_site_origin} || 0;
+			my $mso_algorithm                      = $ds->{'param'}->{'parent.config'}->{'mso.algorithm'} || 0;
+			my $parent_retry                       = $ds->{'param'}->{'parent.config'}->{'mso.parent_retry'};
+			my $unavailable_server_retry_responses = $ds->{'param'}->{'parent.config'}->{'mso.unavailable_server_retry_responses'};
+			my $max_simple_retries                 = $ds->{'param'}->{'parent.config'}->{'mso.max_simple_retries'} || 1;
+			my $max_unavailable_server_retries     = $ds->{'param'}->{'parent.config'}->{'mso.max_unavailable_server_retries'} || 1;
+
+			my $qsh            = $ds->{'param'}->{'parent.config'}->{'mso.qstring_handling'};
+			my $parent_qstring = "ignore";                                                      # default is ignore, unless for alg consistent_hash
 			if ( !defined($qsh) && $mso_algorithm eq 'consistent_hash' && $ds->{qstring_ignore} == 0 ) {
 				$parent_qstring = 'consider';
 			}
@@ -1181,12 +1182,18 @@ sub parent_dot_config {
 				}
 				my $parents = 'parent="' . join( '', @parent_info ) . '' . join( '', @secondary_parent_info ) . '' . join( '', @null_parent_info ) . '"';
 
-				$text .= "$parents round_robin=$mso_algorithm qstring=$parent_qstring go_direct=false parent_is_proxy=false\n";
+				$text .= "$parents round_robin=$mso_algorithm qstring=$parent_qstring go_direct=false parent_is_proxy=false";
+
+				if ( $ats_major_version >= 6 && $parent_retry ne "" ) {
+					$text .= " parent_retry=$parent_retry unavailable_server_retry_responses=$unavailable_server_retry_responses";
+					$text .= " max_simple_retries=$max_simple_retries max_unavailable_server_retries=$max_unavailable_server_retries";
+				} 
+				$text .= "\n";
 			}
 		}
 
 		#$text .= "dest_domain=. go_direct=true\n"; # this is implicit.
-		$self->app->log->debug( "MID PARENT.CONFIG:\n" . $text . "\n" );
+		#$self->app->log->debug( "MID PARENT.CONFIG:\n" . $text . "\n" );
 		return $text;
 	}
 	else {    #"True" Parent - we are genning a EDGE config that points to a parent proxy.


[17/44] incubator-trafficcontrol git commit: Formatting, cleanup

Posted by mi...@apache.org.
Formatting, cleanup


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

Branch: refs/heads/master
Commit: 827da1003274ae798c083a7588e54dafdf08789f
Parents: 5110157
Author: Jan van Doorn <ja...@cable.comcast.com>
Authored: Wed Feb 8 07:42:00 2017 -0700
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:10 2017 +0000

----------------------------------------------------------------------
 .../20170205101432_cdn_table_domain_name.go     | 23 +++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/827da100/traffic_ops/app/db/migrations/20170205101432_cdn_table_domain_name.go
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/migrations/20170205101432_cdn_table_domain_name.go b/traffic_ops/app/db/migrations/20170205101432_cdn_table_domain_name.go
index af24643..72209ff 100644
--- a/traffic_ops/app/db/migrations/20170205101432_cdn_table_domain_name.go
+++ b/traffic_ops/app/db/migrations/20170205101432_cdn_table_domain_name.go
@@ -129,7 +129,16 @@ func Up_20170205101432(txn *sql.Tx) {
 		pDesc := "Deliveryservice profile for " + xml_id
 		pType := "DS_PROFILE"
 		mhrString := mid_header_rewrite.String
-		pmap[pName] = Profile{Id: -1, Name: pName, Desc: pDesc, Type: pType, Cdn: cdn_id, MidHeaderRewrite: mhrString, MultiSiteOriginAlg: multi_site_origin_algorithm.Int64, XMLId: xml_id}
+		pmap[pName] = Profile{
+			Id:                 -1,
+			Name:               pName,
+			Desc:               pDesc,
+			Type:               pType,
+			Cdn:                cdn_id,
+			MidHeaderRewrite:   mhrString,
+			MultiSiteOriginAlg: multi_site_origin_algorithm.Int64,
+			XMLId:              xml_id,
+		}
 	}
 	err = rows.Err()
 	checkErr(err, txn)
@@ -155,8 +164,10 @@ func Up_20170205101432(txn *sql.Tx) {
 					newId, ok = existingParam[string(match[1])+string(match[2])]
 					fmt.Printf("%s -> %v %v\n", string(match[1])+string(match[2]), newId, ok)
 					if !ok {
-						fmt.Println("INSERT INTO PARAMETER (name, config_file, value) VALUES ($1, $2, $3) RETURNING id", "mso."+string(match[1]), "parent.config", string(match[2]))
-						newRow := txn.QueryRow("INSERT INTO PARAMETER (name, config_file, value) VALUES ($1, $2, $3) RETURNING id", "mso."+string(match[1]), "parent.config", string(match[2]))
+						fmt.Println("INSERT INTO PARAMETER (name, config_file, value) VALUES ($1, $2, $3) RETURNING id", "mso."+
+							string(match[1]), "parent.config", string(match[2]))
+						newRow := txn.QueryRow("INSERT INTO PARAMETER (name, config_file, value) VALUES ($1, $2, $3) RETURNING id", "mso."+
+							string(match[1]), "parent.config", string(match[2]))
 						err := newRow.Scan(&newId)
 						checkErr(err, txn)
 						existingParam[string(match[1])+string(match[2])] = newId
@@ -182,8 +193,10 @@ func Up_20170205101432(txn *sql.Tx) {
 		var ok bool
 		newId, ok = existingParam["mso.algorithm"+"parent.config"+string(prof.MultiSiteOriginAlg)]
 		if !ok {
-			fmt.Println("INSERT INTO PARAMETER (name, config_file, value) VALUES ($1, $2, $3) RETURNING id", "mso.algorithm", "parent.config", prof.MultiSiteOriginAlg)
-			newRow = txn.QueryRow("INSERT INTO PARAMETER (name, config_file, value) VALUES ($1, $2, $3) RETURNING id", "mso.algorithm", "parent.config", prof.MultiSiteOriginAlg)
+			fmt.Println("INSERT INTO PARAMETER (name, config_file, value) VALUES ($1, $2, $3) RETURNING id",
+				"mso.algorithm", "parent.config", prof.MultiSiteOriginAlg)
+			newRow = txn.QueryRow("INSERT INTO PARAMETER (name, config_file, value) VALUES ($1, $2, $3) RETURNING id",
+				"mso.algorithm", "parent.config", prof.MultiSiteOriginAlg)
 			err = newRow.Scan(&newId)
 			checkErr(err, txn)
 			existingParam["mso.algorithm"+"parent.config"+string(prof.MultiSiteOriginAlg)] = newId


[22/44] incubator-trafficcontrol git commit: Move domain_name to cdn table - schema

Posted by mi...@apache.org.
Move domain_name to cdn table - schema


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

Branch: refs/heads/master
Commit: 1d5d9b5bc2a862fce61c9a00f5552a6f82bc405e
Parents: 065a311
Author: Jan van Doorn <ja...@cable.comcast.com>
Authored: Mon Dec 26 10:45:47 2016 -0700
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:10 2017 +0000

----------------------------------------------------------------------
 traffic_ops/app/db/ats_6_mso_migrate.pl  | 91 +++++++++++++++++----------
 traffic_ops/app/lib/Schema/Result/Cdn.pm | 15 +++--
 2 files changed, 70 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/1d5d9b5b/traffic_ops/app/db/ats_6_mso_migrate.pl
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/ats_6_mso_migrate.pl b/traffic_ops/app/db/ats_6_mso_migrate.pl
index 0604f03..fd63fd2 100755
--- a/traffic_ops/app/db/ats_6_mso_migrate.pl
+++ b/traffic_ops/app/db/ats_6_mso_migrate.pl
@@ -33,47 +33,74 @@ my $dsn = "DBI:$driver:dbname=$database;host=127.0.0.1;port=5432";
 my $dbh = DBI->connect( $dsn, $userid, $password, { RaiseError => 1 } )
 	or die $DBI::errstr;
 
-print "Opened database successfully\n";
-
-my $sql = 'select id,xml_id,mid_header_rewrite from deliveryservice where multi_site_origin=true;';
+# elsif ( $multi_site_origin_algorithm == 1 ) {
+# 					$mso_algorithm = "false";
+# 				}
+# 				elsif ( $multi_site_origin_algorithm == 2 ) {
+# 					$mso_algorithm = "strict";
+# 				}
+# 				elsif ( $multi_site_origin_algorithm == 3 ) {
+# 					$mso_algorithm = "true";
+# 				}
+# 				elsif ( $multi_site_origin_algorithm == 4 ) {
+# 					$mso_algorithm = "latched";
+# 				}
+# 				else {
+# 					$mso_algorithm = "consistent_hash";
+my @mso_algorithm_choices = ( "consistent_hash", "false", "strict", "true", "latched" );
+my $sql = 'select id,xml_id,mid_header_rewrite,multi_site_origin,multi_site_origin_algorithm from deliveryservice where multi_site_origin=true;';
 
 my $sth = $dbh->prepare_cached($sql);
 $sth->execute || die "Couldn't execute statement: " . $sth->errstr;
 while ( my @data = $sth->fetchrow_array() ) {
-	if ( !defined( $data[2] ) ) {
+	if ( defined( $data[3] ) && !$data[3] ) {
 		next;
 	}
-	my @lines = split( /__RETURN__/, $data[2] );
 	my %profile_ids;
-	foreach my $line (@lines) {
-		if ( !defined( $profile_ids{ $data[1] } ) ) {
-			my $insp = $dbh->prepare('INSERT INTO PROFILE ("name", "description") VALUES(?, ?);');
-			$insp->bind_param( 1, "MIDMSO_" . $data[1] );
-			$insp->bind_param( 2, "Profile for " . $data[1] . " MSO settings" );
-			$insp->execute();
-			my $profile_id = $dbh->last_insert_id( undef, undef, "profile", undef );
-			$profile_ids{ $data[1] } = $profile_id;
-		}
-		if ( $line =~ /set-config proxy.config.http.parent_origin/ ) {
-			my $setting = $line;
-			$setting =~ s/set-config //;
-			print $data[1] . " ->" . $setting . "\n";
-			$setting =~ s/^ *//;
-			my ( $name, $value ) = split( /\s+/, $setting );
-			print $name . " -> " . $value . "\n";
-			my $insh = $dbh->prepare('INSERT INTO PARAMETER ("name", "config_file", "value") VALUES (?, ?, ?);');
-			$insh->bind_param( 1, $name );
-			$insh->bind_param( 2, 'parent.config' );
-			$insh->bind_param( 3, $value );
-			$insh->execute();
-			my $param_id = $dbh->last_insert_id( undef, undef, "parameter", undef );
-			print "Last inserted: " . $param_id;
-			my $inspp = $dbh->prepare('INSERT INTO PROFILE_PARAMETER ("parameter", "profile") VALUES (?, ?);');
-			$inspp->bind_param( 1, $param_id );
-			$inspp->bind_param( 2, $profile_ids{ $data[1] } );
-			$inspp->execute();
+	if ( !defined( $profile_ids{ $data[1] } ) ) {
+		my $insp = $dbh->prepare('INSERT INTO PROFILE ("name", "description") VALUES(?, ?);');
+		$insp->bind_param( 1, "MSO_SELECT_" . $data[1] );
+		$insp->bind_param( 2, "Profile for " . $data[1] . " MSO settings" );
+		$insp->execute();
+		my $profile_id = $dbh->last_insert_id( undef, undef, "profile", undef );
+		$profile_ids{ $data[1] } = $profile_id;
+	}
+	if ( defined( $data[2] ) ) {
+		my @lines = split( /__RETURN__/, $data[2] );
+		foreach my $line (@lines) {
+			if ( $line =~ /set-config proxy.config.http.parent_origin/ ) {
+				my $setting = $line;
+				$setting =~ s/set-config\s+proxy.config.http.parent_origin.//;
+				print $data[1] . " ->" . $setting . "\n";
+				$setting =~ s/^ *//;
+				my ( $name, $value ) = split( /\s+/, $setting );
+				print $name . " -> " . $value . "\n";
+				my $insh = $dbh->prepare('INSERT INTO PARAMETER ("name", "config_file", "value") VALUES (?, ?, ?);');
+				$insh->bind_param( 1, $name );
+				$insh->bind_param( 2, 'parent.config' );
+				$insh->bind_param( 3, $value );
+				$insh->execute();
+				my $param_id = $dbh->last_insert_id( undef, undef, "parameter", undef );
+				print "Last inserted: " . $param_id;
+				my $inspp = $dbh->prepare('INSERT INTO PROFILE_PARAMETER ("parameter", "profile") VALUES (?, ?);');
+				$inspp->bind_param( 1, $param_id );
+				$inspp->bind_param( 2, $profile_ids{ $data[1] } );
+				$inspp->execute();
+			}
 		}
 	}
+	my $insh = $dbh->prepare('INSERT INTO PARAMETER ("name", "config_file", "value") VALUES (?, ?, ?);');
+	$insh->bind_param( 1, "algorithm" );
+	$insh->bind_param( 2, 'parent.config' );
+	my $mso_num = defined( $data[4] ) ? $data[4] : 0;
+	$insh->bind_param( 3, $mso_algorithm_choices[$mso_num] );
+	$insh->execute();
+	my $param_id = $dbh->last_insert_id( undef, undef, "parameter", undef );
+	print "Last inserted: " . $param_id;
+	my $inspp = $dbh->prepare('INSERT INTO PROFILE_PARAMETER ("parameter", "profile") VALUES (?, ?);');
+	$inspp->bind_param( 1, $param_id );
+	$inspp->bind_param( 2, $profile_ids{ $data[1] } );
+	$inspp->execute();
 }
 
 $dbh->disconnect();

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/1d5d9b5b/traffic_ops/app/lib/Schema/Result/Cdn.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Schema/Result/Cdn.pm b/traffic_ops/app/lib/Schema/Result/Cdn.pm
index 39669cb..28b7f6b 100644
--- a/traffic_ops/app/lib/Schema/Result/Cdn.pm
+++ b/traffic_ops/app/lib/Schema/Result/Cdn.pm
@@ -48,6 +48,11 @@ __PACKAGE__->table("cdn");
   default_value: false
   is_nullable: 0
 
+=head2 domain_name
+
+  data_type: 'text'
+  is_nullable: 0
+
 =cut
 
 __PACKAGE__->add_columns(
@@ -69,6 +74,8 @@ __PACKAGE__->add_columns(
   },
   "dnssec_enabled",
   { data_type => "boolean", default_value => \"false", is_nullable => 0 },
+  "domain_name",
+  { data_type => "text", is_nullable => 0 },
 );
 
 =head1 PRIMARY KEY
@@ -85,7 +92,7 @@ __PACKAGE__->set_primary_key("id");
 
 =head1 UNIQUE CONSTRAINTS
 
-=head2 C<idx_24701_cdn_cdn_unique>
+=head2 C<idx_18210_cdn_cdn_unique>
 
 =over 4
 
@@ -95,7 +102,7 @@ __PACKAGE__->set_primary_key("id");
 
 =cut
 
-__PACKAGE__->add_unique_constraint("idx_24701_cdn_cdn_unique", ["name"]);
+__PACKAGE__->add_unique_constraint("idx_18210_cdn_cdn_unique", ["name"]);
 
 =head1 RELATIONS
 
@@ -145,8 +152,8 @@ __PACKAGE__->might_have(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-12-09 09:10:09
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:yBLkvGMimI0emk0nO5/CAA
+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2016-12-26 10:44:56
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:AQZpzzOuEpgmacUrJGl+LQ
 
 
 # You can replace this text with custom code or comments, and it will be preserved on regeneration


[19/44] incubator-trafficcontrol git commit: move enum values stuff to view

Posted by mi...@apache.org.
move enum values stuff to view


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

Branch: refs/heads/master
Commit: 67ca5bfb7b753f4dab490da2c4eb1824379b3762
Parents: 16678b2
Author: Jan van Doorn <ja...@cable.comcast.com>
Authored: Fri Jan 6 16:44:42 2017 -0700
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:10 2017 +0000

----------------------------------------------------------------------
 .../20161226000000_cdn_domain_name.sql          |  3 +
 traffic_ops/app/lib/MojoPlugins/Enum.pm         | 12 ++--
 .../app/lib/Schema/Result/ProfileTypeValue.pm   | 69 ++++++++++++++++++++
 3 files changed, 77 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/67ca5bfb/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql b/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql
index b84cc35..45da0a8 100644
--- a/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql
+++ b/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql
@@ -18,6 +18,9 @@
 
 CREATE TYPE profile_type AS ENUM ('ATS_PROFILE', 'TR_PROFILE', 'TM_PROFILE', 'TS_PROFILE', 'TP_PROFILE', 'INFLUXDB_PROFILE', 
   'RIAK_PROFILE', 'SPLUNK_PROFILE', 'DS_PROFILE', 'ORG_PROFILE', 'KAFKA_PROFILE', 'LOGSTASH_PROFILE', 'ES_PROFILE', 'UNK_PROFILE');
+
+CREATE OR REPLACE VIEW "profile_type_values" AS SELECT unnest(enum_range(NULL::profile_type )) AS value ORDER BY value;
+  
 ALTER TABLE public.profile ADD COLUMN type profile_type;
 UPDATE public.profile SET type='UNK_PROFILE'; -- So we don't get any NULL, these should be checked.
 UPDATE public.profile SET type='TR_PROFILE' WHERE name like 'CCR_%' OR name like 'TR_%';

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/67ca5bfb/traffic_ops/app/lib/MojoPlugins/Enum.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/MojoPlugins/Enum.pm b/traffic_ops/app/lib/MojoPlugins/Enum.pm
index b132b61..4d7174d 100644
--- a/traffic_ops/app/lib/MojoPlugins/Enum.pm
+++ b/traffic_ops/app/lib/MojoPlugins/Enum.pm
@@ -29,13 +29,11 @@ sub register {
 			my $self = shift;
 			my $enum_name = shift;
 
-			my @possible;
-			my $dbh    = Schema->database_handle;
-			my $h = $dbh->prepare('SELECT unnest(enum_range(NULL:: ' . $enum_name . ' )) as value ORDER BY value');
-			$h->execute || print "ERR";
-			while ( my @data = $h->fetchrow_array() ) {
-				push(@possible, $data[0]);
-			}
+			print ">>> " . $enum_name . "\n";
+			my %views = (  # to add more enums, just add the key, val pair here.
+				'profile_type', 'ProfileTypeValue'
+			 ); 
+			my @possible = $self->db->resultset( $views{$enum_name })->search(undef)->get_column('value')->all();
 			return \@possible;
 		}
 	);

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/67ca5bfb/traffic_ops/app/lib/Schema/Result/ProfileTypeValue.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Schema/Result/ProfileTypeValue.pm b/traffic_ops/app/lib/Schema/Result/ProfileTypeValue.pm
new file mode 100644
index 0000000..0d1b50d
--- /dev/null
+++ b/traffic_ops/app/lib/Schema/Result/ProfileTypeValue.pm
@@ -0,0 +1,69 @@
+use utf8;
+package Schema::Result::ProfileTypeValue;
+
+# Created by DBIx::Class::Schema::Loader
+# DO NOT MODIFY THE FIRST PART OF THIS FILE
+
+=head1 NAME
+
+Schema::Result::ProfileTypeValue
+
+=cut
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class::Core';
+__PACKAGE__->table_class("DBIx::Class::ResultSource::View");
+
+=head1 TABLE: C<profile_type_values>
+
+=cut
+
+__PACKAGE__->table("profile_type_values");
+__PACKAGE__->result_source_instance->view_definition(" SELECT unnest(enum_range(NULL::profile_type)) AS value\n  ORDER BY (unnest(enum_range(NULL::profile_type)))");
+
+=head1 ACCESSORS
+
+=head2 value
+
+  data_type: 'enum'
+  extra: {custom_type_name => "profile_type",list => ["ATS_PROFILE","TR_PROFILE","TM_PROFILE","TS_PROFILE","TP_PROFILE","INFLUXDB_PROFILE","RIAK_PROFILE","SPLUNK_PROFILE","DS_PROFILE","ORG_PROFILE","KAFKA_PROFILE","LOGSTASH_PROFILE","ES_PROFILE","UNK_PROFILE"]}
+  is_nullable: 1
+
+=cut
+
+__PACKAGE__->add_columns(
+  "value",
+  {
+    data_type => "enum",
+    extra => {
+      custom_type_name => "profile_type",
+      list => [
+        "ATS_PROFILE",
+        "TR_PROFILE",
+        "TM_PROFILE",
+        "TS_PROFILE",
+        "TP_PROFILE",
+        "INFLUXDB_PROFILE",
+        "RIAK_PROFILE",
+        "SPLUNK_PROFILE",
+        "DS_PROFILE",
+        "ORG_PROFILE",
+        "KAFKA_PROFILE",
+        "LOGSTASH_PROFILE",
+        "ES_PROFILE",
+        "UNK_PROFILE",
+      ],
+    },
+    is_nullable => 1,
+  },
+);
+
+
+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2017-01-06 15:41:31
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:F1WD3vn6YZcU/YlHKVp8CA
+
+
+# You can replace this text with custom code or comments, and it will be preserved on regeneration
+1;


[28/44] incubator-trafficcontrol git commit: Add type ENUM and set the profile for DS in script

Posted by mi...@apache.org.
Add type ENUM and set the profile for DS in script


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

Branch: refs/heads/master
Commit: a6cc75638d04535a4a77f503b576fa7e28362abe
Parents: 9a602f5
Author: Jan van Doorn <ja...@cable.comcast.com>
Authored: Sat Dec 31 13:02:44 2016 -0700
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:10 2017 +0000

----------------------------------------------------------------------
 traffic_ops/app/db/ats_6_mso_migrate.pl         | 57 ++++++++++----------
 .../20161226000000_cdn_domain_name.sql          | 21 +++++++-
 2 files changed, 49 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/a6cc7563/traffic_ops/app/db/ats_6_mso_migrate.pl
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/ats_6_mso_migrate.pl b/traffic_ops/app/db/ats_6_mso_migrate.pl
index fd63fd2..e76810b 100755
--- a/traffic_ops/app/db/ats_6_mso_migrate.pl
+++ b/traffic_ops/app/db/ats_6_mso_migrate.pl
@@ -17,7 +17,7 @@
 # Script to create profiles / parameters from the header_rewrite settings to move to ATS 6.2
 # support.
 #
-# Please be careful using this script, it was created for a very specific usecase, and only
+# Please be careful using this script, it was created for a very specific use case, and only
 # tested our env - JvD
 
 use strict;
@@ -33,34 +33,22 @@ my $dsn = "DBI:$driver:dbname=$database;host=127.0.0.1;port=5432";
 my $dbh = DBI->connect( $dsn, $userid, $password, { RaiseError => 1 } )
 	or die $DBI::errstr;
 
-# elsif ( $multi_site_origin_algorithm == 1 ) {
-# 					$mso_algorithm = "false";
-# 				}
-# 				elsif ( $multi_site_origin_algorithm == 2 ) {
-# 					$mso_algorithm = "strict";
-# 				}
-# 				elsif ( $multi_site_origin_algorithm == 3 ) {
-# 					$mso_algorithm = "true";
-# 				}
-# 				elsif ( $multi_site_origin_algorithm == 4 ) {
-# 					$mso_algorithm = "latched";
-# 				}
-# 				else {
-# 					$mso_algorithm = "consistent_hash";
 my @mso_algorithm_choices = ( "consistent_hash", "false", "strict", "true", "latched" );
-my $sql = 'select id,xml_id,mid_header_rewrite,multi_site_origin,multi_site_origin_algorithm from deliveryservice where multi_site_origin=true;';
+my $sql = 'select id,xml_id,mid_header_rewrite,multi_site_origin,multi_site_origin_algorithm,cdn_id from deliveryservice where multi_site_origin=true;';
 
+my %profile_ids;
 my $sth = $dbh->prepare_cached($sql);
 $sth->execute || die "Couldn't execute statement: " . $sth->errstr;
 while ( my @data = $sth->fetchrow_array() ) {
 	if ( defined( $data[3] ) && !$data[3] ) {
 		next;
 	}
-	my %profile_ids;
 	if ( !defined( $profile_ids{ $data[1] } ) ) {
-		my $insp = $dbh->prepare('INSERT INTO PROFILE ("name", "description") VALUES(?, ?);');
-		$insp->bind_param( 1, "MSO_SELECT_" . $data[1] );
-		$insp->bind_param( 2, "Profile for " . $data[1] . " MSO settings" );
+		my $insp = $dbh->prepare('INSERT INTO PROFILE ("name", "description", "type", "cdn") VALUES(?, ?, ?, ?);');
+		$insp->bind_param( 1, "DS_" . $data[1] );
+		$insp->bind_param( 2, "Profile for delivery service " . $data[1] );
+		$insp->bind_param( 3, "DS_PROFILE");
+		$insp->bind_param( 4, $data[5]);
 		$insp->execute();
 		my $profile_id = $dbh->last_insert_id( undef, undef, "profile", undef );
 		$profile_ids{ $data[1] } = $profile_id;
@@ -70,22 +58,22 @@ while ( my @data = $sth->fetchrow_array() ) {
 		foreach my $line (@lines) {
 			if ( $line =~ /set-config proxy.config.http.parent_origin/ ) {
 				my $setting = $line;
-				$setting =~ s/set-config\s+proxy.config.http.parent_origin.//;
-				print $data[1] . " ->" . $setting . "\n";
+				$setting =~ s/set-config\s+proxy.config.http.//;
+				# print $data[1] . " ->" . $setting . "\n";
 				$setting =~ s/^ *//;
 				my ( $name, $value ) = split( /\s+/, $setting );
-				print $name . " -> " . $value . "\n";
+				# print $name . " -> " . $value . "\n";
 				my $insh = $dbh->prepare('INSERT INTO PARAMETER ("name", "config_file", "value") VALUES (?, ?, ?);');
 				$insh->bind_param( 1, $name );
 				$insh->bind_param( 2, 'parent.config' );
 				$insh->bind_param( 3, $value );
 				$insh->execute();
 				my $param_id = $dbh->last_insert_id( undef, undef, "parameter", undef );
-				print "Last inserted: " . $param_id;
+				# print "Last inserted: " . $param_id;
 				my $inspp = $dbh->prepare('INSERT INTO PROFILE_PARAMETER ("parameter", "profile") VALUES (?, ?);');
 				$inspp->bind_param( 1, $param_id );
 				$inspp->bind_param( 2, $profile_ids{ $data[1] } );
-				$inspp->execute();
+				$inspp->execute() || die "Couldn't execute statement: " . $inspp->errstr;
 			}
 		}
 	}
@@ -94,13 +82,26 @@ while ( my @data = $sth->fetchrow_array() ) {
 	$insh->bind_param( 2, 'parent.config' );
 	my $mso_num = defined( $data[4] ) ? $data[4] : 0;
 	$insh->bind_param( 3, $mso_algorithm_choices[$mso_num] );
-	$insh->execute();
+	$insh->execute() || die "Couldn't execute statement: " . $insh->errstr;
 	my $param_id = $dbh->last_insert_id( undef, undef, "parameter", undef );
-	print "Last inserted: " . $param_id;
+	# print "Last inserted: " . $param_id;
 	my $inspp = $dbh->prepare('INSERT INTO PROFILE_PARAMETER ("parameter", "profile") VALUES (?, ?);');
 	$inspp->bind_param( 1, $param_id );
 	$inspp->bind_param( 2, $profile_ids{ $data[1] } );
-	$inspp->execute();
+	$inspp->execute() || die "Couldn't execute statement: " . $inspp->errstr;
+}
+
+# drop all CCR profiles
+my $upd = $dbh->prepare('UPDATE deliveryservice SET profile=NULL;');
+$upd->execute() || die "Couldn't execute statement: " . $upd->errstr;
+
+# and update the ones that have a delivery service profile.
+foreach my $deliveryservice ( keys %profile_ids ) {
+	my $upd = $dbh->prepare('UPDATE deliveryservice SET profile=? WHERE xml_id=?;');
+	$upd->bind_param( 1, $profile_ids{$deliveryservice} );
+	$upd->bind_param( 2, $deliveryservice );
+	$upd->execute() || die "Couldn't execute statement: " . $upd->errstr;
 }
 
 $dbh->disconnect();
+

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/a6cc7563/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql b/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql
index 65a7b74..22e855a 100644
--- a/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql
+++ b/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql
@@ -16,6 +16,15 @@
 -- +goose Up
 -- SQL in section 'Up' is executed when this migration is applied
 
+-- INSERT INTO TYPE (name, description, use_in_table) VALUES ('SERVER_PROFILE', 'Profile to be assigned to server', 'profile');
+-- INSERT INTO TYPE (name, description, use_in_table) VALUES ('DS_PROFILE', 'Profile to be assigned to deliveryservice', 'profile');
+-- better to use ENUMs, I think
+
+CREATE TYPE profile_type AS ENUM ('SERVER_PROFILE', 'DS_PROFILE');
+ALTER TABLE public.profile ADD COLUMN type profile_type;
+UPDATE public.profile SET type='SERVER_PROFILE';
+ALTER TABLE public.profile ALTER type SET NOT NULL;
+
 ALTER TABLE public.cdn ADD COLUMN domain_name text;
 UPDATE cdn SET domain_name=domainlist.value
   FROM (SELECT distinct cdn_id,value FROM server,parameter WHERE type=(SELECT id FROM type WHERE name='EDGE') 
@@ -27,6 +36,7 @@ UPDATE public.cdn SET domain_name='-' WHERE name='ALL';
 ALTER TABLE public.cdn ALTER COLUMN domain_name SET NOT NULL;
 
 ALTER TABLE public.profile ADD COLUMN cdn bigint;
+
 ALTER TABLE public.profile
   ADD CONSTRAINT fk_cdn1 FOREIGN KEY (cdn)
       REFERENCES public.cdn (id) MATCH SIMPLE
@@ -45,9 +55,18 @@ UPDATE profile set cdn=domainlist.cdn_id
     AND parameter.id in (select parameter from profile_parameter where profile=profile.id)) as domainlist
 WHERE id = domainlist.profile_id;
 
+ALTER TABLE deliveryservice ALTER profile DROP NOT NULL;
+
+
 -- +goose Down
 -- SQL section 'Down' is executed when this migration is rolled back
 
 ALTER TABLE public.cdn DROP COLUMN domain_name;
 
-ALTER TABLE public.profile DROP COLUMN cdn;
\ No newline at end of file
+ALTER TABLE public.profile DROP COLUMN cdn;
+
+ALTER TABLE deliveryservice ALTER profile SET NOT NULL;
+
+ALTER TABLE public.profile DROP COLUMN type;
+
+DROP type profile_type;


[42/44] incubator-trafficcontrol git commit: Merge pull request #3 from mitchell852/jvd-splash

Posted by mi...@apache.org.
Merge pull request #3 from mitchell852/jvd-splash

fixes test

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

Branch: refs/heads/master
Commit: e3d202710b673837dba38984805c4643c5566b83
Parents: b630c9c 7a6e727
Author: Jan van Doorn <jv...@knutsel.com>
Authored: Thu Mar 9 12:00:17 2017 -0700
Committer: GitHub <no...@github.com>
Committed: Thu Mar 9 12:00:17 2017 -0700

----------------------------------------------------------------------
 traffic_ops/app/t/api/1.1/cachegroupparameter.t | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------



[36/44] incubator-trafficcontrol git commit: add back simple_retry_codes, it will be in upstream soon

Posted by mi...@apache.org.
add back simple_retry_codes, it will be in upstream soon


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

Branch: refs/heads/master
Commit: 658dcc053871776f060dd34b643d315d60e95fb9
Parents: 86252a8
Author: Jan van Doorn <jv...@apache.org>
Authored: Mon Feb 13 16:09:18 2017 +0000
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:11 2017 +0000

----------------------------------------------------------------------
 .../20170205101432_cdn_table_domain_name.go      | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/658dcc05/traffic_ops/app/db/migrations/20170205101432_cdn_table_domain_name.go
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/migrations/20170205101432_cdn_table_domain_name.go b/traffic_ops/app/db/migrations/20170205101432_cdn_table_domain_name.go
index 70cb01c..00bbee6 100644
--- a/traffic_ops/app/db/migrations/20170205101432_cdn_table_domain_name.go
+++ b/traffic_ops/app/db/migrations/20170205101432_cdn_table_domain_name.go
@@ -201,16 +201,15 @@ func Up_20170205101432(txn *sql.Tx) {
 							}
 						} else {
 							// unavailable_server_retry_responses is the only one that survives?
-							if string(match[1]) == "dead_server_retry_response_codes" {
-								pName := "mso.unavailable_server_retry_responses"
-								fmt.Println("INSERT INTO PARAMETER (name, config_file, value) VALUES ($1, $2, $3) RETURNING id",
-									pName, "parent.config", string(match[2]))
-								newRow := txn.QueryRow("INSERT INTO PARAMETER (name, config_file, value) VALUES ($1, $2, $3) RETURNING id",
-									pName, "parent.config", string(match[2]))
-								err := newRow.Scan(&newId)
-								checkErr(err, txn)
-								existingParam[string(match[1])+string(match[2])] = newId
-							}
+							//	if string(match[1]) == "dead_server_retry_response_codes" {
+							pName := strings.Replace("mso."+string(match[1]), "dead", "unavailable", 1) // "mso.unavailable_server_retry_responses"
+							fmt.Println("INSERT INTO PARAMETER (name, config_file, value) VALUES ($1, $2, $3) RETURNING id",
+								pName, "parent.config", string(match[2]))
+							newRow := txn.QueryRow("INSERT INTO PARAMETER (name, config_file, value) VALUES ($1, $2, $3) RETURNING id",
+								pName, "parent.config", string(match[2]))
+							err := newRow.Scan(&newId)
+							checkErr(err, txn)
+							existingParam[string(match[1])+string(match[2])] = newId
 						}
 					} else {
 						newId = existingParam[string(match[1])+string(match[2])]


[02/44] incubator-trafficcontrol git commit: Fix ServerCheck.pm -- thanks tests.

Posted by mi...@apache.org.
Fix ServerCheck.pm -- thanks tests.


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

Branch: refs/heads/master
Commit: 16678b2e2b2f3cfed95421e90e0fce027ece5308
Parents: ee593b1
Author: Jan van Doorn <ja...@cable.comcast.com>
Authored: Tue Jan 3 21:16:27 2017 -0700
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:10 2017 +0000

----------------------------------------------------------------------
 traffic_ops/app/lib/API/ServerCheck.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/16678b2e/traffic_ops/app/lib/API/ServerCheck.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/ServerCheck.pm b/traffic_ops/app/lib/API/ServerCheck.pm
index 34dd6a7..2a1394a 100644
--- a/traffic_ops/app/lib/API/ServerCheck.pm
+++ b/traffic_ops/app/lib/API/ServerCheck.pm
@@ -38,7 +38,7 @@ sub aadata {
 	my $rs_type = $self->db->resultset('Type')->search( \%condition );
 	my $rs =
 		$self->db->resultset('Server')
-		->search( { type => { -in => $rs_type->get_column('id')->as_query } }, { prefetch => [ 'servercheck', 'status', 'profile' ]} );
+		->search( { 'me.type' => { -in => $rs_type->get_column('id')->as_query } }, { prefetch => [ 'servercheck', 'status', 'profile' ]} );
 	while ( my $server = $rs->next ) {
 		if ( !defined $server || !defined $server->servercheck ) {
 			next;


[38/44] incubator-trafficcontrol git commit: Docs part 1

Posted by mi...@apache.org.
Docs part 1


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

Branch: refs/heads/master
Commit: e69522929da7f344fc22191fe9ad5456a8526923
Parents: 658dcc0
Author: Jan van Doorn <ja...@cable.comcast.com>
Authored: Sun Feb 19 13:16:11 2017 -0700
Committer: Jan van Doorn <ja...@cable.comcast.com>
Committed: Sun Feb 19 13:16:11 2017 -0700

----------------------------------------------------------------------
 docs/source/admin/quick_howto/index.rst         |  1 +
 .../admin/quick_howto/multi_site_ats5.rst       | 95 ++++++++++++++++++++
 docs/source/admin/traffic_ops_config.rst        |  6 +-
 docs/source/admin/traffic_ops_using.rst         | 68 +++++++-------
 docs/source/overview/traffic_router.rst         |  1 +
 docs/source/overview/traffic_server.rst         |  2 +-
 6 files changed, 139 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/e6952292/docs/source/admin/quick_howto/index.rst
----------------------------------------------------------------------
diff --git a/docs/source/admin/quick_howto/index.rst b/docs/source/admin/quick_howto/index.rst
index 96f098f..4eab27f 100644
--- a/docs/source/admin/quick_howto/index.rst
+++ b/docs/source/admin/quick_howto/index.rst
@@ -22,6 +22,7 @@ Traffic Control is a complicated system, and documenting it is not trivial. Some
   :maxdepth: 3
 
   multi_site.rst
+  multi_site_ats5.rst
   dnssec.rst
   federations.rst
   regionalgeo.rst

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/e6952292/docs/source/admin/quick_howto/multi_site_ats5.rst
----------------------------------------------------------------------
diff --git a/docs/source/admin/quick_howto/multi_site_ats5.rst b/docs/source/admin/quick_howto/multi_site_ats5.rst
new file mode 100644
index 0000000..9419de0
--- /dev/null
+++ b/docs/source/admin/quick_howto/multi_site_ats5.rst
@@ -0,0 +1,95 @@
+.. 
+.. 
+.. 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.
+.. 
+
+.. _rl-multi-site-origin-qht-ats5:
+
+*********************************
+Configure Multi Site Origin (5.x)
+*********************************
+
+1) Create "cachegroups" for the origin locations, and assign the appropriate parent-child relationship between the mid cg's and org cgs (click the image to see full size):
+
+.. image:: C5C4CD22-949A-48FD-8976-C673083E2177.png
+	:scale: 100%
+	:align: center
+
+2) Create a profile to assign to each of the origins:
+
+.. image:: 19BB6EC1-B6E8-4D22-BFA0-B7D6A9708B42.png
+	:scale: 100%
+	:align: center
+
+3) Create server entries for the origination vips:
+
+.. image:: D28614AA-9758-45ED-9EFD-3A284FC4218E.png
+	:scale: 100%
+	:align: center
+
+4) Check the multi-site check box in the delivery service screen and make sure that Content Routing Type is set to HTTP_LIVE_NATL:
+
+.. image:: mso-enable.png
+	:scale: 100%
+	:align: center
+
+5) Assign the org servers to the delivery service that will have the multi site feature:
+
+.. image:: 066CEF4F-C1A3-4A89-8B52-4F72B0531367.png
+	:scale: 100%
+	:align: center
+
+.. Note:: \u201cOrigin Server Base URL\u201d uniqueness: In order to enable MID caches to distinguish delivery services by different MSO algorithms while performing parent failover, it requires that \u201cOrigin Server Base URL\u201d (OFQDN) for each MSO enabled delivery service is unique unless the exceptions listed afterwards. This means that the OFQDN of a MSO enabled delivery service should be different with the OFQDNs of any other delivery service, regardless of whether they are MSO enabled or not. The exceptions are: 
+       1) If there are multiple CDNs created on the same Traffic Ops, delivery services across different CDNs may have the same OFQDN configured.
+       2) If several delivery services in the same CDN have the same MSO algorithm configured, they may share the same OFQDN.
+       3) If delivery services are assigned with different MID cache groups respectively, they can share the same OFQDN.
+
+6) Select an option from the "Multi Site Origin Algorithm" drop-down list. Four MSO algorithms are supported:
+
++------------------+--------------------------------------------------------------------------------------------------------------------+
+|     Option       |                                                            Description                                             |
++==================+====================================================================================================================+
+| Consistent hash  | Origin server selection is based on the consistent hash of requested URLs.                                         |
++------------------+--------------------------------------------------------------------------------------------------------------------+
+| Primary/back     | Round robin selection does not occur. The first origin server is selected unless it fails.                         |
+|                  | If the first fails, the second and other following origin servers will be tried by order.                          |
+|                  | Order is defined by 2 factors - if the origin server's cachegroup is configured as the                             |
+|                  | parent cachegroup for the mid, then this server will be used as the primary. The same rules                        |
+|                  | apply for secondary parents, in order.  Within the cachegroups, the rank parameter will sort                       |
+|                  | order further. If no parents are defined at the mid, then only rank is considered.                                 |  
++------------------+--------------------------------------------------------------------------------------------------------------------+
+| Strict           | MID caches serve requests strictly in turn. For example: origin server 1 serves the first request,                 |
+| round-robin      | origin server 2 serves the second request, and so on.                                                              |
++------------------+--------------------------------------------------------------------------------------------------------------------+
+| IP based         | MID cache goes through the origin server list in a round robin-based on the IP address of EDGE cache.              |
+| round-robin      |                                                                                                                    |
++------------------+--------------------------------------------------------------------------------------------------------------------+
+
+7) Optionally, there are two configuration options that can set the order of the origins used if "Primary/backup" is selected for "Multi Site Origin Algorithm". By creating location-based cachegroups and assigning the origin servers accordingly and defining these cachegroups as parents for specific mids, location-based primary/secondary selection can be made.   If primary/secondary selection should be the same for all mids, then a new parameter \u201crank\u201d should be configured for each origin server profile. Origin servers with lower values of rank have higher ranking in the origin server list on MID caches, e.g. OS with rank of "2" precedes OS with the rank of "5". For any OS, if rank value is not defined in its profile, its rank value will default to \u201c1\u201d.  In the event that both location based cachegroups are used alongside rank, sorting will be by cachegroup first and rank second.  In this way it is possible to have specific backup servers for use at specific locations.
+
+.. image:: mso-rank.png
+	:scale: 60%
+	:align: center
+
+8) Assign the parent.config location parameter to the MID profile:
+
+.. image:: D22DCAA3-18CC-48F4-965B-5312993F9820.png
+	:scale: 100%
+	:align: center
+
+
+9) Configure the mid hdr_rewrite on the delivery service, example: ::
+
+	cond %{REMAP_PSEUDO_HOOK} __RETURN__ set-config proxy.config.http.parent_origin.dead_server_retry_enabled 1 __RETURN__ set-config proxy.config.http.parent_origin.simple_retry_enabled 1 __RETURN__ set-config proxy.config.http.parent_origin.simple_retry_response_codes "400,404,412" __RETURN__ set-config proxy.config.http.parent_origin.dead_server_retry_response_codes "502,503" __RETURN__ set-config proxy.config.http.connect_attempts_timeout 2 __RETURN__ set-config proxy.config.http.connect_attempts_max_retries 2 __RETURN__ set-config proxy.config.http.connect_attempts_max_retries_dead_server 1 __RETURN__ set-config proxy.config.http.transaction_active_timeout_in 5 [L] __RETURN__
+
+10) Turn on parent_proxy_routing in the MID profile.

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/e6952292/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 390788c..89ff265 100644
--- a/docs/source/admin/traffic_ops_config.rst
+++ b/docs/source/admin/traffic_ops_config.rst
@@ -29,7 +29,7 @@ Content Delivery Networks
 
 Profile Parameters
 ======================
-Many of the settings for the different servers in a Traffic Control CDN are controlled by parameters in the parameter view of Traffic Ops. Parameters are grouped in profiles and profiles are assigned to a server. For a typical cache there are hundreds of configuration settings to apply. The Traffic Ops parameter view contains the defined settings. To make life easier, Traffic Ops allows for duplication, comparison, import and export of Profiles. Traffic Ops also has a "Global profile" - the parameters in this profile are going to be applied to all servers in the Traffic Ops instance, or apply to Traffic Ops themselves. These parameters are:
+Many of the settings for the different servers in a Traffic Control CDN are controlled by parameters in the parameter view of Traffic Ops. Parameters are grouped in profiles and profiles are assigned to a server or a deliveryservice. For a typical cache there are hundreds of configuration settings to apply. The Traffic Ops parameter view contains the defined settings. To make life easier, Traffic Ops allows for duplication, comparison, import and export of Profiles. Traffic Ops also has a "Global profile" - the parameters in this profile are going to be applied to all servers in the Traffic Ops instance, or apply to Traffic Ops themselves. These parameters are:
 
 
 .. index::
@@ -90,9 +90,9 @@ Below is a list of cache parameters that are likely to need changes from the def
 | allow_ip6                | astats.config     | This is a comma separated  list of IPv6 CIDR blocks that will have access to the astats statistics on the caches.       |
 |                          |                   | The Traffic Monitor IP addresses have to be included in this, if they are using IPv6 to monitor the caches.             |
 +--------------------------+-------------------+-------------------------------------------------------------------------------------------------------------------------+
-| Drive_Prefix             | storage.config    | JvD/Jeff to supply blurb                                                                                                |
+| Drive_Prefix             | storage.config    | The device path start of the disks. For example, if you have ``/dev/sda`` through ``/dev/sdf`` set this to ``/dev/sd``  |
 +--------------------------+-------------------+-------------------------------------------------------------------------------------------------------------------------+
-| Drive_Letters            | storage.config    | JvD/Jeff to supply blurb                                                                                                |
+| Drive_Letters            | storage.config    | The letter part of the disks, in the same example as above set this to ``a,b,c,d,e,f``                                  |
 +--------------------------+-------------------+-------------------------------------------------------------------------------------------------------------------------+
 | 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`)         |
 +--------------------------+-------------------+-------------------------------------------------------------------------------------------------------------------------+

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/e6952292/docs/source/admin/traffic_ops_using.rst
----------------------------------------------------------------------
diff --git a/docs/source/admin/traffic_ops_using.rst b/docs/source/admin/traffic_ops_using.rst
index eb3d0ee..76ad54c 100644
--- a/docs/source/admin/traffic_ops_using.rst
+++ b/docs/source/admin/traffic_ops_using.rst
@@ -122,6 +122,8 @@ The following tabs are available in the menu at the top of the Traffic Ops user
   +--------------------+-------------------------------------------------------------------------------------------+
   |       Option       |                                        Description                                        |
   +====================+===========================================================================================+
+  | CDNs               | Create/Read/Update/Delete CDNs                                                            |
+  +--------------------+-------------------------------------------------------------------------------------------+
   | Cache Groups       | Create/Read/Update/Delete cache groups                                                    |
   +--------------------+-------------------------------------------------------------------------------------------+
   | Users              | Create/Read/Update/Delete users                                                           |
@@ -255,7 +257,7 @@ These are the types of servers that can be managed in Traffic Ops:
 +---------------+---------------------------------------------+
 | ORG           | Origin                                      |
 +---------------+---------------------------------------------+
-| CCR           | Comcast Content Router                      |
+| CCR           | Traffic Router                              |
 +---------------+---------------------------------------------+
 | RASCAL        | Rascal health polling & reporting           |
 +---------------+---------------------------------------------+
@@ -278,7 +280,7 @@ These are the types of servers that can be managed in Traffic Ops:
 
 Bulk Upload Server
 ++++++++++++++++++
-
+TBD
 
 
 Delivery Service
@@ -339,12 +341,7 @@ The fields in the Delivery Service view are:
 +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
 | Use Multi Site Origin Feature                    | Enable the Multi Site Origin feature for this delivery service. See :ref:`rl-multi-site-origin`                                                                                                                     |
 +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-| Multi Site Origin Algorithm                      | - 1 Consistent Hash spreads requests across multiple parents simultaneously based on hash of content URL.                                                                                                           |
-|                                                  | - 2 Strict Round Robin spreads requests across multiple parents simultaneously based on order of requests.                                                                                                          |
-|                                                  | - 3 IP Based Round Robin spreads requests across multiple parents simultaneously based on order of requests, but ensures that requests from the same IP always go to the same parent if available.                  |
-|                                                  | - 4 Latched uses only a single parent at any given time and switches to a new parent only if the current parent fails.                                                                                              |
-+--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-| CCR profile                                      | The Traffic Router  profile for this delivery service. See :ref:`rl-ccr-profile`.                                                                                                                                   |
+| Profile                                          | The profile for this delivery service.                                                                                                                                                                              |
 +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
 | Maximum Bits per Second allowed globally         | The maximum bits per second this delivery service can serve across all EDGE caches before traffic will be diverted to the bypass destination. For a DNS delivery service, the Bypass Ipv4 or Ipv6  will be used     |
 |                                                  | (depending on whether this was a A or AAAA request), and for HTTP delivery services the Bypass FQDN will be used.                                                                                                   |
@@ -594,14 +591,14 @@ Parameters in the Mid (parent) profile that influence this feature:
 
 Multi Site Origin
 +++++++++++++++++
-.. Note:: The Multi Site Origin feature is based upon a feature n ATS that has yet to be submitted to Traffic Server upstream, until it is, set this to 0, or use the ATS rpm supplied on the trafficcontrol.apache.org website.
 
-Normally, the mid servers are not aware of any redundancy at the origin layer. With Multi Site Origin enabled this changes - Traffic Server (and Traffic Ops) are now made aware of the fact there are multiple origins, and can be configured to do more advanced failover and loadbalancing actions.
+.. Note:: The configuration of this feature changed significantly between ATS version 5 and >= 6. Some configuration in Traffic Control is different as well. This documentation assumes ATS 6 or higher. See :ref:`rl-multi-site-origin-qht-ats5` for the ATS version 5.x configuration details.
 
-With This feature enabled, origin servers (or origin server VIP names for a site) are going to be entered as servers in to the Traiffic Ops UI. Server type is ""
+Normally, the mid servers are not aware of any redundancy at the origin layer. With Multi Site Origin enabled this changes - Traffic Server (and Traffic Ops) are now made aware of the fact there are multiple origins, and can be configured to do more advanced failover and loadbalancing actions. A prerequisite for MSO to work is that the multiple origin sites serve identical content with identical paths, and both are configured to serve the same origin hostname as is configured in the deliveryservice `Origin Server Base URL` field. See the `Apache Traffic Server docs <https://docs.trafficserver.apache.org/en/latest/admin-guide/files/parent.config.en.html>`_ for more information on that cache's implementation.
 
+With This feature enabled, origin servers (or origin server VIP names for a site) are going to be entered as servers in to the Traiffic Ops UI. Server type is "ORG".
 
-Parameters in the Origin profile that influence this feature:
+Parameters in the mid profile that influence this feature:
 
 +--------------------------------------------------------------------------+----------------+------------+----------------------------------------------------------------------------------------------------+
 |                                   Name                                   |    Filename    |  Default   |                                            Description                                             |
@@ -610,27 +607,40 @@ Parameters in the Origin profile that influence this feature:
 +--------------------------------------------------------------------------+----------------+------------+----------------------------------------------------------------------------------------------------+
 | CONFIG proxy.config. url_remap.remap_required                            | records.config | INT 1      | required for parent selection.                                                                     |
 +--------------------------------------------------------------------------+----------------+------------+----------------------------------------------------------------------------------------------------+
-| CONFIG proxy.config. http.parent_proxy.per_parent_connect_attempts       | records.config | INT 5      | maximum of 5 connection attempts per parent (parent.config list) within a transaction.             |
-+--------------------------------------------------------------------------+----------------+------------+----------------------------------------------------------------------------------------------------+
-| CONFIG proxy.config. http.parent_proxy.total_connect_attempts            | records.config | INT 10     | maximum of 10 total connection attempts within a transaction.                                      |
-+--------------------------------------------------------------------------+----------------+------------+----------------------------------------------------------------------------------------------------+
-| CONFIG proxy.config. http.parent_origin.simple_retry_enabled             | records.config | INT 1      | enables simple retry.                                                                              |
-+--------------------------------------------------------------------------+----------------+------------+----------------------------------------------------------------------------------------------------+
-| CONFIG proxy.config. http.parent_origin.simple_retry_response_codes      | records.config | STRING 404 | the response code that invokes simple retry.  May be a comman separated list of response codes.    |
-+--------------------------------------------------------------------------+----------------+------------+----------------------------------------------------------------------------------------------------+
-| CONFIG proxy.config. http.parent_origin.dead_server_retry_response_codes | records.config | STRING 503 | the response code that invokes dead server retry.  May be a comma separated list of response codes |
-+--------------------------------------------------------------------------+----------------+------------+----------------------------------------------------------------------------------------------------+
-| CONFIG proxy.config. http.parent_origin.dead_server_retry_enabled        | records.config | INT 1      | enables dead server retry.                                                                         |
-+--------------------------------------------------------------------------+----------------+------------+----------------------------------------------------------------------------------------------------+
-| CONFIG proxy.config. diags.debug.enabled                                 | records.config | INT 1      | enable debugging for testing only                                                                  |
-+--------------------------------------------------------------------------+----------------+------------+----------------------------------------------------------------------------------------------------+
+
+
+Parameters in the deliveryservice profile that influence this feature:
+
++---------------------------------------------+----------------+-----------------+---------------------------------------------------------------------------------------------------------------------------------+
+|                                   Name      |    Filename    |  Default        |                                                                         Description                                             |
++=============================================+================+=================+=================================================================================================================================+
+| mso.parent_retry                            | parent.config  | \-              | Either ``simple_retry``, ``dead_server_retry`` or ``both``.                                                                     |
++---------------------------------------------+----------------+-----------------+---------------------------------------------------------------------------------------------------------------------------------+
+| mso.algorithm                               | parent.config  | consistent_hash | The algorithm to use. ``consisten_hash``, ``strict``, ``true``, ``false``, or ``latched``.                                      |
+|                                             |                |                 |                                                                                                                                 |
+|                                             |                |                 | - ``consisten_hash`` - spreads requests across multiple parents simultaneously based on hash of content URL.                    |
+|                                             |                |                 | - ``strict`` - strict Round Robin spreads requests across multiple parents simultaneously based on order of requests.           |
+|                                             |                |                 | - ``true`` - same as strict, but ensures that requests from the same IP always go to the same parent if available.              |
+|                                             |                |                 | - ``false`` - uses only a single parent at any given time and switches to a new parent only if the current parent fails.        |
+|                                             |                |                 | - ``latched`` - same as false, but now, a failed parent will not be retried.                                                    |
++---------------------------------------------+----------------+-----------------+---------------------------------------------------------------------------------------------------------------------------------+
+| mso.unavailable_server_retry_response_codes | parent.config  | "503"           | Quoted, comma separated list of HTTP status codes that count as a unavailable_server_retry_response_code.                       |
++---------------------------------------------+----------------+-----------------+---------------------------------------------------------------------------------------------------------------------------------+
+| mso.max_unavailable_server_retries          | parent.config  | 1               | How many times an unavailable server will be retried.                                                                           |
++---------------------------------------------+----------------+-----------------+---------------------------------------------------------------------------------------------------------------------------------+
+| mso.simple_retry_response_codes             | parent.config  | "404"           | Quoted, comma separated list of HTTP status codes that count as a simple retry response code.                                   |
++---------------------------------------------+----------------+-----------------+---------------------------------------------------------------------------------------------------------------------------------+
+| mso.max_simple_retries                      | parent.config  | 1               | How many times a simple retry will be done.                                                                                     |
++---------------------------------------------+----------------+-----------------+---------------------------------------------------------------------------------------------------------------------------------+
+
+
 
 see :ref:`rl-multi-site-origin-qht` for a *quick how to* on this feature.
 
 .. _rl-ccr-profile:
 
-CCR Profile or Traffic Router Profile
-+++++++++++++++++++++++++++++++++++++
+Traffic Router Profile
+++++++++++++++++++++++
 
 +-----------------------------------------+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
 |                   Name                  |      Config_file       |                                                                                                Description                                                                                                |
@@ -655,8 +665,6 @@ CCR Profile or Traffic Router Profile
 +-----------------------------------------+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
 | coveragezone.polling.url                | CRConfig.json          | The location (URL) to retrieve the coverage zone map file in XML format from.                                                                                                                             |
 +-----------------------------------------+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-| domain_name                             | CRConfig.json          | The top level domain of this Traffic Router instance.                                                                                                                                                     |
-+-----------------------------------------+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
 | tld.soa.expire                          | CRConfig.json          | The value for the expire field the Traffic Router DNS Server will respond with on Start of Authority (SOA) records.                                                                                       |
 +-----------------------------------------+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
 | tld.soa.minimum                         | CRConfig.json          | The value for the minimum field the Traffic Router DNS Server will respond with on SOA records.                                                                                                           |

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/e6952292/docs/source/overview/traffic_router.rst
----------------------------------------------------------------------
diff --git a/docs/source/overview/traffic_router.rst b/docs/source/overview/traffic_router.rst
index f9ed1bc..dd021ac 100644
--- a/docs/source/overview/traffic_router.rst
+++ b/docs/source/overview/traffic_router.rst
@@ -48,6 +48,7 @@ Traffic routing options are often configured at the Delivery Service level.
   * Token based authentication settings. 
   * Header rewrite rules.
 
+  Since Traffic Control version 2.1 deliveryservices can optionally be linked to a :ref:`rl-profile`, and have parameters associated with them. The first feature that uses deliveryservice parameters is the :ref:`rl-multi-site-origin` configuration.
   Delivery Services are also for use in allowing multi-tenants to coexist in the Traffic Control CDN without interfering with each other, and to keep information about their content separated. 
 
 |

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/e6952292/docs/source/overview/traffic_server.rst
----------------------------------------------------------------------
diff --git a/docs/source/overview/traffic_server.rst b/docs/source/overview/traffic_server.rst
index 4928e4e..520c8be 100644
--- a/docs/source/overview/traffic_server.rst
+++ b/docs/source/overview/traffic_server.rst
@@ -45,5 +45,5 @@ All caches (and other servers) are assigned a Profile in Traffic Ops.
 
 |arrow| Profile
 ---------------
-  A Profile is a set of configuration settings and parameters, applied to a server. For a typical cache there are hundreds of configuration settings to apply. The Traffic Ops parameter view contains the defined settings, and bundled into groups using Profiles. Traffic Ops allows for duplication, comparison, import and export of Profiles. 
+  A Profile is a set of configuration settings and parameters, applied to a server or deliveryservice. For a typical cache there are hundreds of configuration settings to apply. The Traffic Ops parameter view contains the defined settings, and bundled into groups using Profiles. Traffic Ops allows for duplication, comparison, import and export of Profiles. 
 


[08/44] incubator-trafficcontrol git commit: clean up old file

Posted by mi...@apache.org.
clean up old file


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

Branch: refs/heads/master
Commit: 76cf848c0f30cecd9f305f0f9772868f8fd81900
Parents: 1d5d9b5
Author: Jan van Doorn <ja...@cable.comcast.com>
Authored: Mon Dec 26 10:46:26 2016 -0700
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:10 2017 +0000

----------------------------------------------------------------------
 .../20161222000000_add_mso_profile.sql          | 29 --------------------
 1 file changed, 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/76cf848c/traffic_ops/app/db/migrations/20161222000000_add_mso_profile.sql
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/migrations/20161222000000_add_mso_profile.sql b/traffic_ops/app/db/migrations/20161222000000_add_mso_profile.sql
deleted file mode 100644
index 69b8592..0000000
--- a/traffic_ops/app/db/migrations/20161222000000_add_mso_profile.sql
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
-
-    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.
-*/
-
--- +goose Up
--- SQL in section 'Up' is executed when this migration is applied
-ALTER TABLE public.deliveryservice ADD COLUMN mso_profile bigint;
-ALTER TABLE public.deliveryservice
-  ADD CONSTRAINT fk_deliveryservice_profile2 FOREIGN KEY (mso_profile)
-      REFERENCES public.profile (id) MATCH SIMPLE
-      ON UPDATE NO ACTION ON DELETE NO ACTION;
-CREATE INDEX idx_18221_fk_deliveryservice_mso_profile1
-  ON public.deliveryservice
-  USING btree
-  (mso_profile);
--- +goose Down
--- SQL section 'Down' is executed when this migration is rolled back
-ALTER TABLE public.deliveryservice DROP COLUMN mso_profile;
\ No newline at end of file


[18/44] incubator-trafficcontrol git commit: Change CDN ids in tests

Posted by mi...@apache.org.
Change CDN ids in tests


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

Branch: refs/heads/master
Commit: 4a1af4692ccc6a9eb8974258c716138fdc326f28
Parents: 67ca5bf
Author: Jan van Doorn <ja...@cable.comcast.com>
Authored: Fri Jan 13 14:00:25 2017 -0700
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:10 2017 +0000

----------------------------------------------------------------------
 traffic_ops/app/lib/Fixtures/Profile.pm | 15 ++++++++-------
 traffic_ops/app/t/api/1.1/profile.t     |  3 ++-
 traffic_ops/app/t/api/1.2/profile.t     |  4 ++--
 traffic_ops/app/t/profile.t             |  4 ++--
 4 files changed, 14 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/4a1af469/traffic_ops/app/lib/Fixtures/Profile.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Fixtures/Profile.pm b/traffic_ops/app/lib/Fixtures/Profile.pm
index bb2a33a..4b021d2 100644
--- a/traffic_ops/app/lib/Fixtures/Profile.pm
+++ b/traffic_ops/app/lib/Fixtures/Profile.pm
@@ -24,7 +24,7 @@ my %definition_for = (
 			id          => 100,
 			name        => 'EDGE1',
 			description => 'edge description',
-			cdn         => 1,
+			cdn         => 100,
 			type        => 'ATS_PROFILE',
 		},
 	},
@@ -34,7 +34,7 @@ my %definition_for = (
 			id          => 200,
 			name        => 'MID1',
 			description => 'mid description',
-			cdn         => 1,
+			cdn         => 100,
 			type        => 'ATS_PROFILE',
 		},
 	},
@@ -44,7 +44,7 @@ my %definition_for = (
 			id          => 300,
 			name        => 'CCR1',
 			description => 'ccr description',
-			cdn         => 1,
+			cdn         => 100,
 			type        => 'TR_PROFILE',
 		},
 	},
@@ -54,7 +54,7 @@ my %definition_for = (
 			id          => 301,
 			name        => 'CCR2',
 			description => 'ccr description',
-			cdn         => 2,
+			cdn         => 200,
 			type        => 'TR_PROFILE',
 		},
 	},
@@ -64,7 +64,7 @@ my %definition_for = (
 			id          => 500,
 			name        => 'RIAK1',
 			description => 'riak description',
-			cdn         => 1,
+			cdn         => 100,
 			type        => 'RIAK_PROFILE',
 		},
 	},
@@ -74,7 +74,7 @@ my %definition_for = (
 			id          => 600,
 			name        => 'RASCAL1',
 			description => 'rascal description',
-			cdn         => 1,
+			cdn         => 100,
 			type        => 'TM_PROFILE',
 		},
 	},
@@ -84,7 +84,7 @@ my %definition_for = (
 			id          => 700,
 			name        => 'RASCAL2',
 			description => 'rascal2 description',
-			cdn         => 2,
+			cdn         => 200,
 			type        => 'TM_PROFILE',
 		},
 	},
@@ -94,6 +94,7 @@ my %definition_for = (
 			id          => 8,
 			name        => 'MISC',
 			description => 'misc profile description',
+			type        => 'UNK_PROFILE',
 		},
 	},
 );

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/4a1af469/traffic_ops/app/t/api/1.1/profile.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/api/1.1/profile.t b/traffic_ops/app/t/api/1.1/profile.t
index 192f011..ce9cab0 100644
--- a/traffic_ops/app/t/api/1.1/profile.t
+++ b/traffic_ops/app/t/api/1.1/profile.t
@@ -44,7 +44,8 @@ $t->get_ok("/api/1.1/profiles.json")->status_is(200)->or( sub { diag $t->tx->res
 	->json_is( "/response/1/name", "CCR2" )->json_is( "/response/1/description", "ccr description" )
 	->json_is( "/response/2/name", "EDGE1" )->json_is( "/response/2/description", "edge description" )
 	->json_is( "/response/3/name", "MID1" )->json_is( "/response/3/description", "mid description" )
-	->json_is( "/response/4/name", "RASCAL1" )->json_is( "/response/4/description", "rascal description" );
+	->json_is( "/response/4/name", "MISC" )->json_is( "/response/4/description", "misc profile description" )
+	->json_is( "/response/5/name", "RASCAL1" )->json_is( "/response/5/description", "rascal description" );
 
 $t->get_ok("/api/1.1/profiles/trimmed.json")->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } );
 

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/4a1af469/traffic_ops/app/t/api/1.2/profile.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/api/1.2/profile.t b/traffic_ops/app/t/api/1.2/profile.t
index dc0a58e..eb5c801 100644
--- a/traffic_ops/app/t/api/1.2/profile.t
+++ b/traffic_ops/app/t/api/1.2/profile.t
@@ -39,7 +39,7 @@ ok $t->post_ok( '/login', => form => { u => Test::TestHelper::ADMIN_USER, p => T
 	->or( sub { diag $t->tx->res->content->asset->{content}; } ), 'Should login?';
 
 ok $t->post_ok('/api/1.2/profiles' => {Accept => 'application/json'} => json => {
-	"name" => "CCR_CREATE", "description" => "CCR_CREATE description", "cdn" => 1, "type" => 'TR_PROFILE' })->status_is(200)
+	"name" => "CCR_CREATE", "description" => "CCR_CREATE description", "cdn" => 100, "type" => 'TR_PROFILE' })->status_is(200)
 	->or( sub { diag $t->tx->res->content->asset->{content}; } )
 	->json_is( "/response/name" => "CCR_CREATE" )
 	->json_is( "/response/description" => "CCR_CREATE description" )
@@ -73,7 +73,7 @@ my $profile_id = &get_profile_id('CCR_CREATE');
 ok $t->put_ok('/api/1.2/profiles/' . $profile_id  => {Accept => 'application/json'} => json => {
         "name" => "CCR_UPDATE",
         "description" => "CCR_UPDATE description",
-        "cdn" => 1,
+        "cdn" => 100,
         "type" => "TR_PROFILE"
         })
     ->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } )

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/4a1af469/traffic_ops/app/t/profile.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/profile.t b/traffic_ops/app/t/profile.t
index a4947b4..23e3b96 100644
--- a/traffic_ops/app/t/profile.t
+++ b/traffic_ops/app/t/profile.t
@@ -53,7 +53,7 @@ $t->post_ok(
 	'/profile/create' => form => {
 		'profile.name'        => 'JLP_Test',
 		'profile.description' => 'JLP Test Host',
-		'profile.cdn'         => 1,
+		'profile.cdn'         => 100,
 		'profile.type'        => 'ATS_PROFILE'
 	}
 )->status_is(302)->or( sub { diag $t->tx->res->content->asset->{content}; } );
@@ -74,7 +74,7 @@ sub upd_and_del() {
 			"/profile/$id/update" => form => {
 				'profile.name'        => 'JLP_Test',
 				'profile.description' => 'JLP Test Host Updated',
-				'profile.cdn'         => 1,
+				'profile.cdn'         => 100,
 				'profile.type'        => 'ATS_PROFILE'
 			}
 		)->status_is(302)->or( sub { diag $t->tx->res->content->asset->{content}; } );


[03/44] incubator-trafficcontrol git commit: Better names for variables

Posted by mi...@apache.org.
Better names for variables


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

Branch: refs/heads/master
Commit: f84a4e2372d9e33cc5517e826a02b96e7e0792e9
Parents: 613e4ba
Author: Jan van Doorn <ja...@cable.comcast.com>
Authored: Mon Jan 2 14:03:33 2017 -0700
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:10 2017 +0000

----------------------------------------------------------------------
 traffic_ops/app/lib/UI/Profile.pm               | 10 ++++++----
 traffic_ops/app/templates/profile/_form.html.ep |  2 +-
 2 files changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/f84a4e23/traffic_ops/app/lib/UI/Profile.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/UI/Profile.pm b/traffic_ops/app/lib/UI/Profile.pm
index e386341..996555b 100644
--- a/traffic_ops/app/lib/UI/Profile.pm
+++ b/traffic_ops/app/lib/UI/Profile.pm
@@ -31,6 +31,7 @@ sub index {
 	$self->stash( profile => {} );
 }
 
+# stash the cdn array for a form select.. optional second arg is the one that is selected.
 sub stash_cdn_selector {
 	my $self = shift;
 	my $selected = shift || -1;
@@ -47,20 +48,21 @@ sub stash_cdn_selector {
 	$self->stash( cdns => \@cdns );
 }
 
+# stash the profile_type array for a form select. optional second arg is the one that is selected.
 sub stash_profile_type_selector {
 	my $self = shift;
 	my $selected = shift || -1;
 
 	my $enum_possible = $self->enum_values("profile_type");
-	my @possible;
+	my @types;
     foreach my $val ( @{$enum_possible} ) {
     	if ($val eq $selected) {
-			push(@possible, [ $val => $val , selected => 'true' ] );
+			push(@types, [ $val => $val , selected => 'true' ] );
     	} else {
-			push(@possible, [ $val => $val ] );
+			push(@types, [ $val => $val ] );
     	}
 	}
-	$self->stash( profile_type_possible  => \@possible );
+	$self->stash( profile_types  => \@types );
 }
 
 # for the fancybox view

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/f84a4e23/traffic_ops/app/templates/profile/_form.html.ep
----------------------------------------------------------------------
diff --git a/traffic_ops/app/templates/profile/_form.html.ep b/traffic_ops/app/templates/profile/_form.html.ep
index 3301d37..9bc22f6 100644
--- a/traffic_ops/app/templates/profile/_form.html.ep
+++ b/traffic_ops/app/templates/profile/_form.html.ep
@@ -40,5 +40,5 @@
         <span class="field-with-error"><%= field('profile.type')->error %></span>
     <% } %>
     %= label_for 'profile.type' => '* Profile Type', class => 'label'
-    %= field('profile.type')->select( \@{$profile_type_possible} )
+    %= field('profile.type')->select( \@{$profile_types} )
 </div>
\ No newline at end of file


[27/44] incubator-trafficcontrol git commit: Merge 2 - profile test

Posted by mi...@apache.org.
Merge 2 - profile test


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

Branch: refs/heads/master
Commit: d095923ee94a1e33e8dbb0cced14f6f267523bdd
Parents: 742d475
Author: Jan van Doorn <ja...@cable.comcast.com>
Authored: Thu Dec 29 11:00:53 2016 -0700
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:10 2017 +0000

----------------------------------------------------------------------
 traffic_ops/app/lib/API/Cdn.pm                  | 21 +++++++++++++++++---
 .../app/lib/API/DeliveryService/SslKeys.pm      |  2 +-
 .../app/t/api/1.1/deliveryservice/ssl_keys.t    |  2 +-
 traffic_ops/app/t/api/1.1/profile.t             |  9 ++++++---
 traffic_ops/app/t/api/1.2/cdn.t                 |  2 +-
 5 files changed, 27 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d095923e/traffic_ops/app/lib/API/Cdn.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/Cdn.pm b/traffic_ops/app/lib/API/Cdn.pm
index 269dec9..cec6a24 100644
--- a/traffic_ops/app/lib/API/Cdn.pm
+++ b/traffic_ops/app/lib/API/Cdn.pm
@@ -39,7 +39,8 @@ sub index {
 				"id"            => $row->id,
 				"dnssecEnabled" => \$row->dnssec_enabled,
 				"lastUpdated" 	=> $row->last_updated,
-				"name"          => $row->name
+				"name"          => $row->name,
+				"domainName"    => $row->domain_name
 			}
 		);
 	}
@@ -58,7 +59,8 @@ sub show {
 				"id"            => $row->id,
 				"dnssecEnabled" => \$row->dnssec_enabled,
 				"lastUpdated" 	=> $row->last_updated,
-				"name"          => $row->name
+				"name"          => $row->name,
+				"domainName"    => $row->domain_name
 			}
 		);
 	}
@@ -77,7 +79,8 @@ sub name {
 				"id"            => $row->id,
 				"dnssecEnabled" => \$row->dnssec_enabled,
 				"lastUpdated"   => $row->last_updated,
-				"name"          => $row->name
+				"name"          => $row->name,
+				"domainName"    => $row->domain_name
 			}
 		);
 	}
@@ -104,15 +107,26 @@ sub create {
 		return $self->alert("dnssecEnabled is required.");
 	}
 
+	if ( !defined( $params->{domainName} ) ) {
+		return $self->alert("Domain Name is required.");
+	}
+
 	my $existing = $self->db->resultset('Cdn')->search( { name => $params->{name} } )->single();
 	if ($existing) {
 		$self->app->log->error( "a cdn with name '" . $params->{name} . "' already exists." );
 		return $self->alert( "a cdn with name " . $params->{name} . " already exists." );
 	}
 
+	my $existing = $self->db->resultset('Cdn')->search( { domain_name => $params->{domainName} } )->single();
+	if ($existing) {
+		$self->app->log->error( "a cdn with domain name '" . $params->{domainName} . "' already exists." );
+		return $self->alert( "a cdn with domain " . $params->{domainName} . " already exists." );
+	}
+
 	my $values = {
 		name => $params->{name},
 		dnssec_enabled => $params->{dnssecEnabled},
+		domain_name => $params->{domainName},
 	};
 
 	my $insert = $self->db->resultset('Cdn')->create($values);
@@ -123,6 +137,7 @@ sub create {
 		my $response;
 		$response->{id}            = $rs->id;
 		$response->{name}          = $rs->name;
+		$response->{domainName}    = $rs->domain_name;
 		$response->{dnssecEnabled} = \$rs->dnssec_enabled;
 		&log( $self, "Created CDN with id: " . $rs->id . " and name: " . $rs->name, "APICHANGE" );
 		return $self->success( $response, "cdn was created." );

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d095923e/traffic_ops/app/lib/API/DeliveryService/SslKeys.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/DeliveryService/SslKeys.pm b/traffic_ops/app/lib/API/DeliveryService/SslKeys.pm
index 49d19fc..985b171 100644
--- a/traffic_ops/app/lib/API/DeliveryService/SslKeys.pm
+++ b/traffic_ops/app/lib/API/DeliveryService/SslKeys.pm
@@ -159,7 +159,7 @@ sub view_by_hostname {
 			->search( { 'regex.pattern' => "$host_regex" }, { join => { deliveryservice_regexes => { regex => undef } } } )->get_column('id')->all();
 
 		# TODO JvD - test this with online riak servers!
-		my $cdn_id = $self->db->resultset('Cdn')->search( { domain_name => $domain_name } )->get_column('id');
+		my $cdn_id = $self->db->resultset('Cdn')->search( { domain_name => $domain_name } )->get_column('id')->single();
 		my@domain_profiles = $self->db->resultset('Profile')->search( { cdn => $cdn_id } )->get_column('id')->all();
 
 		my $rs_ds = $self->db->resultset('Deliveryservice')->search( { 'profile' => { -in => \@domain_profiles } }, {} );

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d095923e/traffic_ops/app/t/api/1.1/deliveryservice/ssl_keys.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/api/1.1/deliveryservice/ssl_keys.t b/traffic_ops/app/t/api/1.1/deliveryservice/ssl_keys.t
index 2108cd1..e76f7a0 100644
--- a/traffic_ops/app/t/api/1.1/deliveryservice/ssl_keys.t
+++ b/traffic_ops/app/t/api/1.1/deliveryservice/ssl_keys.t
@@ -146,7 +146,7 @@ ok $t->get_ok("/api/1.1/deliveryservices/xmlId/foo.bar/sslkeys.json")->json_has(
 	->or( sub { diag $t->tx->res->content->asset->{content}; } );
 
 #get key by hostname
-my $gen_hostname = "edge.foo.top.kabletown.net";
+my $gen_hostname = "edge.foo.cdn1.kabletown.net";
 ok $t->get_ok("/api/1.1/deliveryservices/hostname/$gen_hostname/sslkeys.json")->json_has("/response")->json_has("/response/certificate/csr")
 	->json_has("/response/certificate/key")->json_has("/response/certificate/crt")->json_is( "/response/organization" => $org )
 	->json_is( "/response/state" => $state )->json_is( "/response/city" => $city )->json_is( "/response/businessUnit" => $unit )

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d095923e/traffic_ops/app/t/api/1.1/profile.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/api/1.1/profile.t b/traffic_ops/app/t/api/1.1/profile.t
index d68581d..192f011 100644
--- a/traffic_ops/app/t/api/1.1/profile.t
+++ b/traffic_ops/app/t/api/1.1/profile.t
@@ -39,9 +39,12 @@ Test::TestHelper->load_core_data($schema);
 ok $t->post_ok( '/login', => form => { u => Test::TestHelper::PORTAL_USER, p => Test::TestHelper::PORTAL_USER_PASSWORD } )->status_is(302)
 	->or( sub { diag $t->tx->res->content->asset->{content}; } );
 
-$t->get_ok("/api/1.1/profiles.json")->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } )->json_is( "/response/0/name", "CCR1" )
-	->json_is( "/response/0/description", "ccr description" )->json_is( "/response/1/name", "EDGE1" )
-	->json_is( "/response/1/description", "edge description" )->json_is( "/response/2/name", "MID1" );
+$t->get_ok("/api/1.1/profiles.json")->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } )
+	->json_is( "/response/0/name", "CCR1" )->json_is( "/response/0/description", "ccr description" )
+	->json_is( "/response/1/name", "CCR2" )->json_is( "/response/1/description", "ccr description" )
+	->json_is( "/response/2/name", "EDGE1" )->json_is( "/response/2/description", "edge description" )
+	->json_is( "/response/3/name", "MID1" )->json_is( "/response/3/description", "mid description" )
+	->json_is( "/response/4/name", "RASCAL1" )->json_is( "/response/4/description", "rascal description" );
 
 $t->get_ok("/api/1.1/profiles/trimmed.json")->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } );
 

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d095923e/traffic_ops/app/t/api/1.2/cdn.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/api/1.2/cdn.t b/traffic_ops/app/t/api/1.2/cdn.t
index f962719..b833312 100644
--- a/traffic_ops/app/t/api/1.2/cdn.t
+++ b/traffic_ops/app/t/api/1.2/cdn.t
@@ -69,7 +69,7 @@ $t->get_ok("/api/1.2/servers?cdnId=100")->status_is(200)
     ->or( sub { diag $t->tx->res->content->asset->{content}; } );
 
 ok $t->post_ok('/api/1.2/cdns' => {Accept => 'application/json'} => json => {
-        "name" => "cdn_test", "dnssecEnabled" => "true" })
+        "name" => "cdn_test", "dnssecEnabled" => "true", "domainName" => "testcdn.kabletown.net" })
     ->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } )
     ->json_is( "/response/name" => "cdn_test" )
     ->json_is( "/alerts/0/level" => "success" )


[09/44] incubator-trafficcontrol git commit: cdn domain_name migration

Posted by mi...@apache.org.
cdn domain_name migration


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

Branch: refs/heads/master
Commit: de60ccc7a1e18584d3122f73087253eb4b7b6d24
Parents: 898611b
Author: Jan van Doorn <ja...@cable.comcast.com>
Authored: Mon Dec 26 10:48:53 2016 -0700
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:10 2017 +0000

----------------------------------------------------------------------
 .../20161226000000_cdn_domain_name.sql          | 35 ++++++++++++++++++++
 1 file changed, 35 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/de60ccc7/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql b/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql
new file mode 100644
index 0000000..7b38d64
--- /dev/null
+++ b/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql
@@ -0,0 +1,35 @@
+/*
+
+    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.
+*/
+
+-- +goose Up
+-- SQL in section 'Up' is executed when this migration is applied
+
+ALTER TABLE public.cdn ADD COLUMN domain_name text;
+
+UPDATE cdn SET domain_name=domainlist.value
+  FROM (SELECT distinct cdn_id,value FROM server,parameter WHERE type=(SELECT id FROM type WHERE name='EDGE') 
+    AND parameter.id in (select parameter from profile_parameter WHERE profile_parameter.profile=server.profile) 
+    AND parameter.name='domain_name' 
+    AND config_file='CRConfig.json') AS domainlist
+WHERE id = domainlist.cdn_id;
+
+UPDATE public.cdn SET domain_name='-' WHERE name='ALL';
+
+ALTER TABLE public.cdn ALTER COLUMN domain_name SET NOT NULL;
+
+-- +goose Down
+-- SQL section 'Down' is executed when this migration is rolled back
+
+ALTER TABLE public.cdn DROP COLUMN domain_name;
\ No newline at end of file


[40/44] incubator-trafficcontrol git commit: Merge pull request #2 from mitchell852/jvd-splash

Posted by mi...@apache.org.
Merge pull request #2 from mitchell852/jvd-splash

minor changes (removes commented out code and print statements) and f\u2026

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

Branch: refs/heads/master
Commit: b630c9c619a1c1055eb78e2b45c048f34abf168f
Parents: e695229 3b1df01
Author: Jan van Doorn <jv...@knutsel.com>
Authored: Thu Mar 9 11:39:58 2017 -0700
Committer: GitHub <no...@github.com>
Committed: Thu Mar 9 11:39:58 2017 -0700

----------------------------------------------------------------------
 .../development/traffic_ops_api/v12/cdn.rst     |  54 +++++--
 .../traffic_ops_api/v12/deliveryservice.rst     |   6 -
 .../development/traffic_ops_api/v12/profile.rst | 151 +++++++++++--------
 traffic_ops/app/lib/API/Cdn.pm                  |  32 ++--
 traffic_ops/app/lib/API/Deliveryservice.pm      |   6 +-
 traffic_ops/app/lib/API/Profile.pm              |  31 ++--
 .../lib/Fixtures/Integration/Deliveryservice.pm |   8 -
 traffic_ops/app/lib/Fixtures/Parameter.pm       |   9 --
 traffic_ops/app/lib/UI/Cdn.pm                   |   4 -
 traffic_ops/app/t/api/1.1/cachegroupparameter.t |   2 +-
 10 files changed, 175 insertions(+), 128 deletions(-)
----------------------------------------------------------------------



[26/44] incubator-trafficcontrol git commit: Remove removal of header_rewrite stuff, and add string algorithm

Posted by mi...@apache.org.
Remove removal of header_rewrite stuff, and add string algorithm


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

Branch: refs/heads/master
Commit: 4599a5b86da31b822e57f96d2769a28a340f282b
Parents: 827da10
Author: Jan van Doorn <ja...@cable.comcast.com>
Authored: Wed Feb 8 15:35:12 2017 -0700
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:10 2017 +0000

----------------------------------------------------------------------
 .../20170205101432_cdn_table_domain_name.go     | 46 +++++++++++++++++---
 1 file changed, 41 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/4599a5b8/traffic_ops/app/db/migrations/20170205101432_cdn_table_domain_name.go
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/migrations/20170205101432_cdn_table_domain_name.go b/traffic_ops/app/db/migrations/20170205101432_cdn_table_domain_name.go
index 72209ff..072e225 100644
--- a/traffic_ops/app/db/migrations/20170205101432_cdn_table_domain_name.go
+++ b/traffic_ops/app/db/migrations/20170205101432_cdn_table_domain_name.go
@@ -28,8 +28,40 @@ func doExec(stmt string, txn *sql.Tx) {
 	}
 }
 
+/*
+ if ( $multi_site_origin_algorithm == 0 ) {
+1174                     $mso_algorithm = "consistent_hash";
+1175                     if ( $ds->{qstring_ignore} == 0 ) {
+1176                         $parent_qstring = "consider";
+1177                     }
+1178                 }
+1179                 elsif ( $multi_site_origin_algorithm == 1 ) {
+1180                     $mso_algorithm = "false";
+1181                 }
+1182                 elsif ( $multi_site_origin_algorithm == 2 ) {
+1183                     $mso_algorithm = "strict";
+1184                 }
+1185                 elsif ( $multi_site_origin_algorithm == 3 ) {
+1186                     $mso_algorithm = "true";
+1187                 }
+1188                 elsif ( $multi_site_origin_algorithm == 4 ) {
+1189                     $mso_algorithm = "latched";
+1190                 }
+1191                 else {
+1192                     $mso_algorithm = "consistent_hash";
+1193                 }
+*/
 // Up is executed when this migration is applied
 func Up_20170205101432(txn *sql.Tx) {
+
+	algorithmStr := map[int64]string{
+		0: "consistent_hash",
+		1: "false",
+		2: "strict",
+		3: "true",
+		4: "latched",
+	}
+
 	fmt.Println("  Starting migration 20130106222315...")
 	doExec("CREATE TYPE profile_type AS ENUM ("+
 		"'ATS_PROFILE', 'TR_PROFILE', 'TM_PROFILE', 'TS_PROFILE', 'TP_PROFILE', 'INFLUXDB_PROFILE',"+
@@ -184,24 +216,28 @@ func Up_20170205101432(txn *sql.Tx) {
 				}
 			}
 		}
+		/* -- Not doing the remove at this time, so we can support both 5.x and 6.x - 6.x will have a warning if these are not removed from the DS, but
+		      should run just fine.
+
 		fmt.Printf("MHRW was: %s, \nMHRW now: %s\n", prof.MidHeaderRewrite, remainingString)
 
 		_, err = txn.Exec("UPDATE deliveryservice set mid_header_rewrite=$1 where xml_id=$2", remainingString, prof.XMLId)
 		checkErr(err, txn)
+		*/
 
 		var newId int64
 		var ok bool
-		newId, ok = existingParam["mso.algorithm"+"parent.config"+string(prof.MultiSiteOriginAlg)]
+		newId, ok = existingParam["mso.algorithm"+"parent.config"+algorithmStr[prof.MultiSiteOriginAlg]]
 		if !ok {
 			fmt.Println("INSERT INTO PARAMETER (name, config_file, value) VALUES ($1, $2, $3) RETURNING id",
-				"mso.algorithm", "parent.config", prof.MultiSiteOriginAlg)
+				"mso.algorithm", "parent.config", algorithmStr[prof.MultiSiteOriginAlg])
 			newRow = txn.QueryRow("INSERT INTO PARAMETER (name, config_file, value) VALUES ($1, $2, $3) RETURNING id",
-				"mso.algorithm", "parent.config", prof.MultiSiteOriginAlg)
+				"mso.algorithm", "parent.config", algorithmStr[prof.MultiSiteOriginAlg])
 			err = newRow.Scan(&newId)
 			checkErr(err, txn)
-			existingParam["mso.algorithm"+"parent.config"+string(prof.MultiSiteOriginAlg)] = newId
+			existingParam["mso.algorithm"+"parent.config"+algorithmStr[prof.MultiSiteOriginAlg]] = newId
 		} else {
-			newId = existingParam["mso.algorithm"+"parent.config"+string(prof.MultiSiteOriginAlg)]
+			newId = existingParam["mso.algorithm"+"parent.config"+algorithmStr[prof.MultiSiteOriginAlg]]
 		}
 
 		fmt.Println("INSERT INTO PROFILE_PARAMETER (parameter, profile) VALUES ($1, $2)", newId, newProfileId)


[25/44] incubator-trafficcontrol git commit: Add params in ps_data formatting (sorry) and protocol in query

Posted by mi...@apache.org.
Add params in ps_data formatting (sorry) and protocol in query


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

Branch: refs/heads/master
Commit: 71731cbe3725c82e9c2730db77bbffae533d20f8
Parents: 4599a5b
Author: Jan van Doorn <ja...@cable.comcast.com>
Authored: Sat Feb 11 08:21:58 2017 -0700
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:10 2017 +0000

----------------------------------------------------------------------
 .../Result/DeliveryServiceInfoForDomainList.pm  |   4 +-
 traffic_ops/app/lib/UI/ConfigFiles.pm           | 123 +++++++++++--------
 2 files changed, 72 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/71731cbe/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForDomainList.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForDomainList.pm b/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForDomainList.pm
index 8969815..310c914 100644
--- a/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForDomainList.pm
+++ b/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForDomainList.pm
@@ -58,7 +58,8 @@ SELECT
     deliveryservice.regex_remap,
     deliveryservice.cacheurl,
     deliveryservice.remap_text,
-    deliveryservice.protocol
+    deliveryservice.protocol,
+    deliveryservice.profile
 FROM
     deliveryservice
     JOIN deliveryservice_regex ON deliveryservice_regex.deliveryservice = deliveryservice.id
@@ -100,6 +101,7 @@ __PACKAGE__->add_columns(
 	"protocol",                    { data_type => "tinyint", is_nullable => 0, size => 4 },
 	"range_request_handling",      { data_type => "tinyint", is_nullable => 0, size => 4 },
 	"origin_shield",               { data_type => "varchar", is_nullable => 0, size => 1024 },
+    "profile",                     { data_type => "integer", is_nullable => 1},
 );
 
 1;

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/71731cbe/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 d64ae2e..0df9123 100644
--- a/traffic_ops/app/lib/UI/ConfigFiles.pm
+++ b/traffic_ops/app/lib/UI/ConfigFiles.pm
@@ -212,7 +212,7 @@ sub ds_data {
 		my $cacheurl                    = $row->cacheurl;
 		my $remap_text                  = $row->remap_text;
 		my $multi_site_origin           = $row->multi_site_origin;
-		my $multi_site_origin_algorithm = 0; #TODO JvD -- may not need this here, the other params are needed somewhere else as well
+		my $multi_site_origin_algorithm = 0;
 
 		if ( $re_type eq 'HOST_REGEXP' ) {
 			my $host_re = $row->pattern;
@@ -249,7 +249,7 @@ sub ds_data {
 				if ( $protocol == 0 ) {
 					$dsinfo->{dslist}->[$j]->{"remap_line"}->{$map_from} = $map_to;
 				}
-				elsif ( $protocol == 1 || $protocol == 3) {
+				elsif ( $protocol == 1 || $protocol == 3 ) {
 					$map_from = "https://" . $host_re . "/";
 					$dsinfo->{dslist}->[$j]->{"remap_line"}->{$map_from} = $map_to;
 				}
@@ -257,6 +257,7 @@ sub ds_data {
 
 					#add the first with http
 					$dsinfo->{dslist}->[$j]->{"remap_line"}->{$map_from} = $map_to;
+
 					#add the second with https
 					my $map_from2 = "https://" . $host_re . "/";
 					$dsinfo->{dslist}->[$j]->{"remap_line2"}->{$map_from2} = $map_to;
@@ -293,6 +294,13 @@ sub ds_data {
 			$dsinfo->{dslist}->[$j]->{"cacheurl_file"} = $fname;
 		}
 
+		if ( defined( $row->profile ) ) {
+			my $dsparamrs = $self->db->resultset('ProfileParameter')->search( { profile => $row->profile }, { prefetch => [ 'profile', 'parameter' ] } );
+			while ( my $prow = $dsparamrs->next ) {
+				$dsinfo->{dslist}->[$j]->{'param'}->{ $prow->parameter->config_file }->{ $prow->parameter->name } = $prow->parameter->value;
+			}
+		}
+
 		$j++;
 	}
 
@@ -370,7 +378,7 @@ sub parent_data {
 	}
 
 	# get the server's cdn domain
-	my $server_domain = $self->get_cdn_domain_by_profile_id( $server->profile->id ); 
+	my $server_domain = $self->get_cdn_domain_by_profile_id( $server->profile->id );
 
 	my %profile_cache;
 	my %deliveryservices;
@@ -380,26 +388,27 @@ sub parent_data {
 	$self->cachegroup_profiles( \@secondary_parent_cachegroup_ids, \%profile_cache, \%deliveryservices );
 	foreach my $prefix ( keys %deliveryservices ) {
 		foreach my $row ( @{ $deliveryservices{$prefix} } ) {
-			my $pid            = $row->profile->id;
-			my $ds_domain      = $profile_cache{$pid}->{domain_name};
-			my $weight         = $profile_cache{$pid}->{weight};
-			my $port           = $profile_cache{$pid}->{port};
-			my $use_ip_address = $profile_cache{$pid}->{use_ip_address};
-			my $rank           = $profile_cache{$pid}->{rank};
-			my $primary_parent         = $server->cachegroup->parent_cachegroup_id // -1;
-			my $secondary_parent      = $server->cachegroup->secondary_parent_cachegroup_id // -1;
-			print "ds_domain:" . $ds_domain . " server_domain: ". $server_domain . "\n";
+			my $pid              = $row->profile->id;
+			my $ds_domain        = $profile_cache{$pid}->{domain_name};
+			my $weight           = $profile_cache{$pid}->{weight};
+			my $port             = $profile_cache{$pid}->{port};
+			my $use_ip_address   = $profile_cache{$pid}->{use_ip_address};
+			my $rank             = $profile_cache{$pid}->{rank};
+			my $primary_parent   = $server->cachegroup->parent_cachegroup_id // -1;
+			my $secondary_parent = $server->cachegroup->secondary_parent_cachegroup_id // -1;
+			print "ds_domain:" . $ds_domain . " server_domain: " . $server_domain . "\n";
+
 			if ( defined($ds_domain) && defined($server_domain) && $ds_domain eq $server_domain ) {
 				my %p = (
-					host_name      => $row->host_name,
-					port           => defined($port) ? $port : $row->tcp_port,
-					domain_name    => $row->domain_name,
-					weight         => $weight,
-					use_ip_address => $use_ip_address,
-					rank           => $rank,
-					ip_address     => $row->ip_address,
-					primary_parent         => ( $primary_parent == $row->cachegroup->id ) ? 1 : 0,
-					secondary_parent      => ( $secondary_parent == $row->cachegroup->id ) ? 1 : 0,
+					host_name        => $row->host_name,
+					port             => defined($port) ? $port : $row->tcp_port,
+					domain_name      => $row->domain_name,
+					weight           => $weight,
+					use_ip_address   => $use_ip_address,
+					rank             => $rank,
+					ip_address       => $row->ip_address,
+					primary_parent   => ( $primary_parent == $row->cachegroup->id ) ? 1 : 0,
+					secondary_parent => ( $secondary_parent == $row->cachegroup->id ) ? 1 : 0,
 				);
 				push @{ $parent_info{$prefix} }, \%p;
 			}
@@ -449,10 +458,10 @@ sub cachegroup_profiles {
 			# assign $ds_domain, $weight and $port, and cache the results %profile_cache
 			$profile_cache->{$pid} = {
 				domain_name    => $row->cdn->domain_name,
-				weight         => $self->profile_param_value( $pid, 'parent.config', 'weight',         '0.999' ),
-				port           => $self->profile_param_value( $pid, 'parent.config', 'port',           undef ),
+				weight         => $self->profile_param_value( $pid, 'parent.config', 'weight', '0.999' ),
+				port           => $self->profile_param_value( $pid, 'parent.config', 'port', undef ),
 				use_ip_address => $self->profile_param_value( $pid, 'parent.config', 'use_ip_address', 0 ),
-				rank           => $self->profile_param_value( $pid, 'parent.config', 'rank',           1 ),
+				rank           => $self->profile_param_value( $pid, 'parent.config', 'rank', 1 ),
 			};
 		}
 	}
@@ -479,9 +488,9 @@ sub ip_allow_data {
 
 	# 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_number_v4  = 5;
 	my $coalesce_masklen_v6 = 48;
-	my $coalesce_number_v6 = 5;
+	my $coalesce_number_v6  = 5;
 	my $rs_parameter =
 		$self->db->resultset('ProfileParameter')->search( { profile => $server->profile->id }, { prefetch => [ "parameter", "profile" ] } );
 
@@ -492,16 +501,16 @@ 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' ) {
+		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' ) {
+		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' ) {
+		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' ) {
+		elsif ( $row->parameter->name eq 'coalesce_number_v6' && $row->parameter->config_file eq 'ip_allow.config' ) {
 			$coalesce_number_v6 = $row->parameter->value;
 		}
 	}
@@ -552,7 +561,7 @@ sub ip_allow_data {
 
 		# compact, coalesce and compact combined list again
 		my @compacted_list = NetAddr::IP::Compact(@allowed_netaddrips);
-		my $coalesced_list = NetAddr::IP::Coalesce( $coalesce_masklen_v4 , $coalesce_number_v4, @allowed_netaddrips );
+		my $coalesced_list = NetAddr::IP::Coalesce( $coalesce_masklen_v4, $coalesce_number_v4, @allowed_netaddrips );
 		my @combined_list  = NetAddr::IP::Compact( @allowed_netaddrips, @{$coalesced_list} );
 		foreach my $net (@combined_list) {
 			my $range = $net->range();
@@ -565,7 +574,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( $coalesce_masklen_v6 , $coalesce_number_v6, @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();
@@ -810,9 +819,9 @@ sub hosting_dot_config {
 	my $file = shift;
 	my $data = shift;
 
-	my $server = $self->server_data($id);
-	my $storage_data   = $self->param_data( $server, "storage.config" );
-	my $text   = $self->header_comment( $server->host_name );
+	my $server       = $self->server_data($id);
+	my $storage_data = $self->param_data( $server, "storage.config" );
+	my $text         = $self->header_comment( $server->host_name );
 	if ( !defined($data) ) {
 		$data = $self->ds_data($server);
 	}
@@ -840,7 +849,7 @@ sub hosting_dot_config {
 			}
 		}
 	}
-	my $disk_volume = 1; # note this will actually be the RAM (RAM_Drive_Prefix) volume if there is no Drive_Prefix parameter.
+	my $disk_volume = 1;    # note this will actually be the RAM (RAM_Drive_Prefix) volume if there is no Drive_Prefix parameter.
 	$text .= "hostname=*   volume=" . $disk_volume . "\n";
 
 	return $text;
@@ -956,7 +965,7 @@ sub remap_dot_config {
 			if ( $remap->{type} =~ /LIVE/ && $remap->{type} !~ /NATNL/ ) {
 				next;    # Live local delivery services skip mids
 			}
-			if ( defined( $remap->{org} ) && defined( $mid_remap{$remap->{org} } ) ) {
+			if ( defined( $remap->{org} ) && defined( $mid_remap{ $remap->{org} } ) ) {
 				next;    # skip remap rules from extra HOST_REGEXP entries
 			}
 
@@ -1087,7 +1096,7 @@ sub parent_dot_config {
 	my $server_type = $server->type->name;
 	my $parent_qstring;
 	my $pinfo;
-	my $text        = $self->header_comment( $server->host_name );
+	my $text = $self->header_comment( $server->host_name );
 	if ( !defined($data) ) {
 		$data = $self->ds_data($server);
 	}
@@ -1097,16 +1106,16 @@ sub parent_dot_config {
 	if ( $server_type =~ m/^MID/ ) {
 		my @unique_origin;
 		foreach my $ds ( @{ $data->{dslist} } ) {
-			my $xml_id                      = $ds->{ds_xml_id};
-			my $os                          = $ds->{origin_shield};
-			$parent_qstring 		= "ignore";
-			my $multi_site_origin           = defined( $ds->{multi_site_origin} ) ? $ds->{multi_site_origin} : 0;
+			my $xml_id = $ds->{ds_xml_id};
+			my $os     = $ds->{origin_shield};
+			$parent_qstring = "ignore";
+			my $multi_site_origin           = defined( $ds->{multi_site_origin} )           ? $ds->{multi_site_origin}           : 0;
 			my $multi_site_origin_algorithm = defined( $ds->{multi_site_origin_algorithm} ) ? $ds->{multi_site_origin_algorithm} : 0;
 
-			my $org_uri = URI->new($ds->{org});
+			my $org_uri = URI->new( $ds->{org} );
 
 			# Don't duplicate origin line if multiple seen
-			next if ( grep( /^$org_uri$/, @unique_origin));
+			next if ( grep( /^$org_uri$/, @unique_origin ) );
 			push @unique_origin, $org_uri;
 
 			if ( defined($os) ) {
@@ -1125,16 +1134,14 @@ sub parent_dot_config {
 					$pinfo = $self->parent_data($server);
 				}
 
-
 				my @ranked_parents = ();
-				if ( exists( $pinfo->{$org_uri->host} ) ) {
-					@ranked_parents = sort by_parent_rank @{ $pinfo->{$org_uri->host} };
+				if ( exists( $pinfo->{ $org_uri->host } ) ) {
+					@ranked_parents = sort by_parent_rank @{ $pinfo->{ $org_uri->host } };
 				}
 				else {
 					$self->app->log->debug( "BUG: Did not match an origin: " . $org_uri );
 				}
 
-
 				my @parent_info;
 				my @secondary_parent_info;
 				my @null_parent_info;
@@ -1142,7 +1149,7 @@ sub parent_dot_config {
 					if ( $parent->{primary_parent} ) {
 						push @parent_info, format_parent_info($parent);
 					}
-					elsif ($parent ->{secondary_parent} ) {
+					elsif ( $parent->{secondary_parent} ) {
 						push @secondary_parent_info, format_parent_info($parent);
 					}
 					else {
@@ -1160,7 +1167,7 @@ sub parent_dot_config {
 					my %seen;
 					@null_parent_info = grep { !$seen{$_}++ } @null_parent_info;
 				}
-                                my $parents = 'parent="' . join( '', @parent_info ) . '' . join ( '', @secondary_parent_info ) . '' . join( '', @null_parent_info ) . '"';
+				my $parents = 'parent="' . join( '', @parent_info ) . '' . join( '', @secondary_parent_info ) . '' . join( '', @null_parent_info ) . '"';
 				my $mso_algorithm = "";
 				if ( $multi_site_origin_algorithm == 0 ) {
 					$mso_algorithm = "consistent_hash";
@@ -1234,7 +1241,12 @@ sub parent_dot_config {
 				}
 				my $round_robin = 'round_robin=consistent_hash';
 				my $go_direct   = 'go_direct=false';
-				$text .= "dest_domain=" . $org_uri->host . " port=" . $org_uri->port . " $parents $secparents $round_robin $go_direct qstring=$parent_qstring\n";
+				$text
+					.= "dest_domain="
+					. $org_uri->host
+					. " port="
+					. $org_uri->port
+					. " $parents $secparents $round_robin $go_direct qstring=$parent_qstring\n";
 			}
 			$done{$org} = 1;
 		}
@@ -1310,7 +1322,8 @@ sub regex_revalidate_dot_config {
 
 	my %regex_time;
 	$max_days =
-		$self->db->resultset('Parameter')->search( { name => "maxRevalDurationDays" }, { config_file => "regex_revalidate.config" } )->get_column('value')->first;
+		$self->db->resultset('Parameter')->search( { name => "maxRevalDurationDays" }, { config_file => "regex_revalidate.config" } )->get_column('value')
+		->first;
 	my $max_hours = $max_days * 24;
 	my $min_hours = 1;
 
@@ -1505,8 +1518,10 @@ sub ssl_multicert_dot_config {
 
 	# get a list of delivery services for the server
 	my $protocol_search = '> 0';
-	my @ds_list = $self->db->resultset('Deliveryservice')->search( { -and => [ 'server.id' => $server->id, 'me.protocol' => \$protocol_search ] },
-		{ prefetch => ['cdn'], join => { deliveryservice_servers => { server => undef } }, } );
+	my @ds_list         = $self->db->resultset('Deliveryservice')->search(
+		{ -and => [ 'server.id' => $server->id, 'me.protocol' => \$protocol_search ] },
+		{ prefetch => ['cdn'], join => { deliveryservice_servers => { server => undef } }, }
+	);
 	foreach my $ds (@ds_list) {
 		my $ds_id        = $ds->id;
 		my $xml_id       = $ds->xml_id;


[12/44] incubator-trafficcontrol git commit: Fix Integration tests, Fixtures

Posted by mi...@apache.org.
Fix Integration tests, Fixtures


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

Branch: refs/heads/master
Commit: ee593b12729f715085c3970aa4347622ba2d18c4
Parents: 5ef37ce
Author: Jan van Doorn <ja...@cable.comcast.com>
Authored: Tue Jan 3 17:34:26 2017 -0700
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:10 2017 +0000

----------------------------------------------------------------------
 .../lib/Fixtures/Integration/Deliveryservice.pm | 16 +++---
 .../app/lib/Fixtures/Integration/Profile.pm     | 22 +++++++++
 .../Fixtures/Integration/ProfileParameter.pm    | 51 ++++++++++++++++++++
 traffic_ops/app/lib/UI/Profile.pm               |  2 +-
 4 files changed, 82 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/ee593b12/traffic_ops/app/lib/Fixtures/Integration/Deliveryservice.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Fixtures/Integration/Deliveryservice.pm b/traffic_ops/app/lib/Fixtures/Integration/Deliveryservice.pm
index 65c9615..146a5da 100644
--- a/traffic_ops/app/lib/Fixtures/Integration/Deliveryservice.pm
+++ b/traffic_ops/app/lib/Fixtures/Integration/Deliveryservice.pm
@@ -72,7 +72,7 @@ my %definition_for = (
 			dns_bypass_ip               => '',
 			edge_header_rewrite         => 'add-header X-Powered-By: KBLTN [L]',
 			multi_site_origin           => undef,
-			multi_site_origin_algorithm => undef,
+			# multi_site_origin_algorithm => undef,
 			tr_request_headers          => undef,
 		},
 	},
@@ -83,7 +83,7 @@ my %definition_for = (
 			xml_id                      => 'games-c1',
 			regional_geo_blocking       => 0,
 			multi_site_origin           => undef,
-			multi_site_origin_algorithm => undef,
+			# multi_site_origin_algorithm => undef,
 			protocol                    => '0',
 			dns_bypass_ttl              => undef,
 			edge_header_rewrite         => 'cond %{SEND_RESPONSE_HDR_HOOK} __RETURN__ add-header X-CDN-Info "KableTown___CACHE_IPV4__" [L]',
@@ -138,7 +138,7 @@ my %definition_for = (
 			type                        => '10',
 			dns_bypass_cname            => undef,
 			multi_site_origin           => undef,
-			multi_site_origin_algorithm => undef,
+			# multi_site_origin_algorithm => undef,
 			qstring_ignore              => '0',
 			ccr_dns_ttl                 => '3600',
 			dscp                        => '40',
@@ -208,7 +208,7 @@ my %definition_for = (
 			long_desc_1                 => 'test-ds1 long_desc_1',
 			max_dns_answers             => '0',
 			multi_site_origin           => '1',
-			multi_site_origin_algorithm => '0',
+			# multi_site_origin_algorithm => '0',
 			active                      => '1',
 			edge_header_rewrite         => 'cond %{REMAP_PSEUDO_HOOK} __RETURN__ set-config proxy.config.http.transaction_active_timeout_out 5 [L]',
 			global_max_mbps             => '0',
@@ -252,7 +252,7 @@ my %definition_for = (
 			ipv6_routing_enabled        => undef,
 			mid_header_rewrite          => undef,
 			multi_site_origin           => undef,
-			multi_site_origin_algorithm => undef,
+			# multi_site_origin_algorithm => undef,
 			qstring_ignore              => '0',
 			active                      => '1',
 			cacheurl                    => undef,
@@ -305,7 +305,7 @@ my %definition_for = (
 			miss_long                   => '-87.627778',
 			org_server_fqdn             => 'https://games.origin.kabletown.net',
 			multi_site_origin           => undef,
-			multi_site_origin_algorithm => undef,
+			# multi_site_origin_algorithm => undef,
 			cacheurl                    => undef,
 			dns_bypass_ip               => '',
 			dns_bypass_ip6              => undef,
@@ -352,7 +352,7 @@ my %definition_for = (
 			global_max_tps              => '0',
 			initial_dispersion          => '1',
 			multi_site_origin           => undef,
-			multi_site_origin_algorithm => undef,
+			# multi_site_origin_algorithm => undef,
 			org_server_fqdn             => 'http://national-tv.origin.kabletown.net',
 			signed                      => '0',
 			display_name                => 'tv-nat-c2',
@@ -392,7 +392,7 @@ my %definition_for = (
 			long_desc                   => 'test- long_desc',
 			long_desc_2                 => 'test- long_desc_2',
 			multi_site_origin           => undef,
-			multi_site_origin_algorithm => undef,
+			# multi_site_origin_algorithm => undef,
 			origin_shield               => undef,
 			protocol                    => '0',
 			ipv6_routing_enabled        => undef,

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/ee593b12/traffic_ops/app/lib/Fixtures/Integration/Profile.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Fixtures/Integration/Profile.pm b/traffic_ops/app/lib/Fixtures/Integration/Profile.pm
index eea64cf..89ef8af 100644
--- a/traffic_ops/app/lib/Fixtures/Integration/Profile.pm
+++ b/traffic_ops/app/lib/Fixtures/Integration/Profile.pm
@@ -33,6 +33,7 @@ use namespace::autoclean;
 			name => 'CCR_CDN1',
 			description => 'Comcast Content Router for cdn1.cdn.net',
 			cdn => 1,
+			type => 'TR_PROFILE',
 			last_updated => '2015-12-10 15:43:48',
 		},
 	},
@@ -43,6 +44,7 @@ use namespace::autoclean;
 			name => 'CCR_CDN2',
 			description => 'Comcast Content Router for cdn2.comcast.net',
 			cdn => 2,
+			type => 'TR_PROFILE',
 			last_updated => '2015-12-10 15:43:48',
 		},
 	},
@@ -53,6 +55,7 @@ use namespace::autoclean;
 			name => 'EDGE1_CDN1_402',
 			description => 'Dell R720xd, Edge, CDN1 CDN, ATS v4.0.2',
 			cdn => 1,
+			type => 'ATS_PROFILE',
 			last_updated => '2015-12-10 15:43:48',
 		},
 	},
@@ -63,6 +66,7 @@ use namespace::autoclean;
 			name => 'EDGE1_CDN1_421',
 			description => 'Dell R720xd, Edge, CDN1 CDN, ATS v4.2.1, Consistent Parent',
 			cdn => 1,
+			type => 'ATS_PROFILE',
 			last_updated => '2015-12-10 15:43:48',
 		},
 	},
@@ -73,6 +77,7 @@ use namespace::autoclean;
 			name => 'EDGE1_CDN1_421_SSL',
 			description => 'Dell r720xd, Edge, CDN1 CDN, ATS v4.2.1, SSL enabled',
 			cdn => 1,
+			type => 'ATS_PROFILE',
 			last_updated => '2015-12-10 15:43:48',
 		},
 	},
@@ -83,6 +88,7 @@ use namespace::autoclean;
 			name => 'EDGE1_CDN2_402',
 			last_updated => '2015-12-10 15:43:48',
 			cdn => 2,
+			type => 'ATS_PROFILE',
 			description => 'Dell R720xd, Edge, CDN2 CDN, ATS v4.0.2',
 		},
 	},
@@ -91,6 +97,7 @@ use namespace::autoclean;
 		new => 'Profile',
 		using => {
 			name => 'EDGE1_CDN2_421',
+			type => 'ATS_PROFILE',
 			description => 'Dell R720xd, Edge, CDN2 CDN, ATS v4.2.1, Consistent Parent',
 			cdn => 2,
 			last_updated => '2015-12-10 15:43:48',
@@ -103,6 +110,7 @@ use namespace::autoclean;
 			name => 'EDGE2_CDN1',
 			description => 'HP DL380 Edge',
 			cdn => 1,
+			type => 'ATS_PROFILE',
 			last_updated => '2015-12-10 15:43:48',
 		},
 	},
@@ -113,6 +121,7 @@ use namespace::autoclean;
 			name => 'EDGE2_CDN1_402',
 			description => 'HP DL380, Edge, CDN1 CDN, ATS v4.0.x',
 			cdn => 1,
+			type => 'ATS_PROFILE',
 			last_updated => '2015-12-10 15:43:48',
 		},
 	},
@@ -123,6 +132,7 @@ use namespace::autoclean;
 			name => 'EDGE2_CDN2_402',
 			description => 'HP DL380, Edge, CDN2 CDN, ATS v4.0.x',
 			cdn => 2,
+			type => 'ATS_PROFILE',
 			last_updated => '2015-12-10 15:43:48',
 		},
 	},
@@ -133,6 +143,7 @@ use namespace::autoclean;
 			name => 'EDGE2_CDN2_421',
 			description => 'HP DL380, Edge, CDN2 CDN, ATS v4.2.1, Consistent Parent',
 			cdn => 2,
+			type => 'ATS_PROFILE',
 			last_updated => '2015-12-10 15:43:48',
 		},
 	},
@@ -142,6 +153,7 @@ use namespace::autoclean;
 		using => {
 			name => 'GLOBAL',
 			description => 'GLOBAL Traffic Ops Profile -- DO NOT DELETE',
+			type => 'UNK_PROFILE',
 			last_updated => '2015-12-10 15:43:48',
 		},
 	},
@@ -152,6 +164,7 @@ use namespace::autoclean;
 			name => 'MID1_CDN1_421',
 			description => 'Dell R720xd, Mid, CDN1 CDN, ATS v4.2.1',
 			cdn => 1,
+			type => 'ATS_PROFILE',
 			last_updated => '2015-12-10 15:43:48',
 		},
 	},
@@ -162,6 +175,7 @@ use namespace::autoclean;
 			name => 'MID1_CDN2_402',
 			description => 'Dell R720xd, Mid, CDN2 CDN, new vol config, ATS v4.0.x',
 			cdn => 2,
+			type => 'ATS_PROFILE',
 			last_updated => '2015-12-10 15:43:48',
 		},
 	},
@@ -172,6 +186,7 @@ use namespace::autoclean;
 			name => 'MID1_CDN2_421',
 			description => 'Dell R720xd, Mid, CDN2 CDN, ATS v4.2.1',
 			cdn => 2,
+			type => 'ATS_PROFILE',
 			last_updated => '2015-12-10 15:43:48',
 		},
 	},
@@ -182,6 +197,7 @@ use namespace::autoclean;
 			name => 'MID2_CDN1',
 			description => 'HP DL380 Mid',
 			cdn => 1,
+			type => 'ATS_PROFILE',
 			last_updated => '2015-12-10 15:43:48',
 		},
 	},
@@ -192,6 +208,7 @@ use namespace::autoclean;
 			name => 'ORG1_CDN1',
 			last_updated => '2015-12-10 15:43:48',
 			cdn => 1,
+			type => 'ORG_PROFILE',
 			description => 'Multi site origin profile 1',
 		},
 	},
@@ -202,6 +219,7 @@ use namespace::autoclean;
 			name => 'ORG2_CDN1',
 			description => 'Multi site origin profile 2',
 			cdn => 1,
+			type => 'ORG_PROFILE',
 			last_updated => '2015-12-10 15:43:48',
 		},
 	},
@@ -212,6 +230,7 @@ use namespace::autoclean;
 			name => 'RASCAL_CDN1',
 			description => 'TrafficMonitor for CDN1',
 			cdn => 1,
+			type => 'TM_PROFILE',
 			last_updated => '2015-12-10 15:43:48',
 		},
 	},
@@ -221,6 +240,7 @@ use namespace::autoclean;
 		using => {
 			name => 'RASCAL_CDN2',
 			cdn => 2,
+			type => 'TM_PROFILE',
 			last_updated => '2015-12-10 15:43:48',
 			description => 'TrafficMonitor for CDN2 ',
 		},
@@ -231,6 +251,7 @@ use namespace::autoclean;
 		using => {
 			name => 'RIAK_ALL',
 			description => 'Riak profile for all CDNs',
+			type => 'RIAK_PROFILE',
 			last_updated => '2015-12-10 15:43:48',
 		},
 	},
@@ -241,6 +262,7 @@ use namespace::autoclean;
 			name => 'TRAFFIC_STATS',
 			last_updated => '2015-12-10 15:43:48',
 			description => 'Traffic Stats profile for all CDNs',
+			type => 'TS_PROFILE',
 		},
 	},
 );

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/ee593b12/traffic_ops/app/lib/Fixtures/Integration/ProfileParameter.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Fixtures/Integration/ProfileParameter.pm b/traffic_ops/app/lib/Fixtures/Integration/ProfileParameter.pm
index be45640..54f110f 100644
--- a/traffic_ops/app/lib/Fixtures/Integration/ProfileParameter.pm
+++ b/traffic_ops/app/lib/Fixtures/Integration/ProfileParameter.pm
@@ -24058,6 +24058,23 @@ my %definition_for = (
 			parameter => '37',
  		},
 	},
+	'3013-1' => { # JvD - added by hand, not sure how LogFormat.Format could be missing from an ATS profile
+ 		new => 'ProfileParameter',
+ 		using => {
+			last_updated => '2015-12-10 15:44:35',
+			parameter => '379',
+			profile => '15',
+ 		},
+	},
+	'3013-2' => { # JvD - added by hand, not sure how Drive_Prefix could be missing from an ATS profile
+ 		new => 'ProfileParameter',
+ 		using => {
+			last_updated => '2015-12-10 15:44:35',
+			parameter => '295',
+			profile => '15',
+ 		},
+	},
+########
 	'3014' => {
  		new => 'ProfileParameter',
  		using => {
@@ -26386,6 +26403,23 @@ my %definition_for = (
 			profile => '13',
  		},
 	},
+	'3305-1' => { # JvD - added by hand, not sure how LogFormat.Format could be missing from an ATS profile
+ 		new => 'ProfileParameter',
+ 		using => {
+			last_updated => '2015-12-10 15:44:35',
+			parameter => '379',
+			profile => '13',
+ 		},
+	},
+	'3305-2' => { # JvD - added by hand, not sure how Drive_Prefix could be missing from an ATS profile
+ 		new => 'ProfileParameter',
+ 		using => {
+			last_updated => '2015-12-10 15:44:35',
+			parameter => '295',
+			profile => '13',
+ 		},
+	},
+########
 	'3306' => {
  		new => 'ProfileParameter',
  		using => {
@@ -31474,6 +31508,23 @@ my %definition_for = (
 			profile => '5',
  		},
 	},
+	'3943-1' => { # JvD - added by hand, not sure how LogFormat.Format could be missing from an ATS profile
+ 		new => 'ProfileParameter',
+ 		using => {
+			last_updated => '2015-12-10 15:44:35',
+			parameter => '379',
+			profile => '5',
+ 		},
+	},
+ 	'3943-2' => { # JvD - added by hand, not sure how Drive_Prefix could be missing from an ATS profile
+ 		new => 'ProfileParameter',
+ 		using => {
+			last_updated => '2015-12-10 15:44:35',
+			parameter => '295',
+			profile => '5',
+ 		},
+	},
+########
 	'3944' => {
  		new => 'ProfileParameter',
  		using => {

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/ee593b12/traffic_ops/app/lib/UI/Profile.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/UI/Profile.pm b/traffic_ops/app/lib/UI/Profile.pm
index 188bd84..e035255 100644
--- a/traffic_ops/app/lib/UI/Profile.pm
+++ b/traffic_ops/app/lib/UI/Profile.pm
@@ -95,7 +95,7 @@ sub readprofile {
 				"id"           => $row->id,
 				"name"         => $row->name,
 				"type"         => $row->type,
-				"cdn"          => $row->cdn->name,
+				"cdn"          => defined($row->cdn) ? $row->cdn->name : undef,
 				"description"  => $row->description,
 				"last_updated" => $row->last_updated,
 			}


[05/44] incubator-trafficcontrol git commit: Reverese schema update

Posted by mi...@apache.org.
Reverese schema update


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

Branch: refs/heads/master
Commit: 05798ae1a2c46e1a0355888b0fa1fcf55b49d7cf
Parents: a6cc756
Author: Jan van Doorn <ja...@cable.comcast.com>
Authored: Sat Dec 31 13:58:55 2016 -0700
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:10 2017 +0000

----------------------------------------------------------------------
 traffic_ops/app/db/ats_6_mso_migrate.pl         |  2 +-
 .../app/lib/Schema/Result/Deliveryservice.pm    | 23 ++++++++++++--------
 traffic_ops/app/lib/Schema/Result/Profile.pm    | 23 ++++++++++++++++----
 3 files changed, 34 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/05798ae1/traffic_ops/app/db/ats_6_mso_migrate.pl
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/ats_6_mso_migrate.pl b/traffic_ops/app/db/ats_6_mso_migrate.pl
index e76810b..6315b8c 100755
--- a/traffic_ops/app/db/ats_6_mso_migrate.pl
+++ b/traffic_ops/app/db/ats_6_mso_migrate.pl
@@ -64,7 +64,7 @@ while ( my @data = $sth->fetchrow_array() ) {
 				my ( $name, $value ) = split( /\s+/, $setting );
 				# print $name . " -> " . $value . "\n";
 				my $insh = $dbh->prepare('INSERT INTO PARAMETER ("name", "config_file", "value") VALUES (?, ?, ?);');
-				$insh->bind_param( 1, $name );
+				$insh->bind_param( 1, 'mso.'.$name );
 				$insh->bind_param( 2, 'parent.config' );
 				$insh->bind_param( 3, $value );
 				$insh->execute();

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/05798ae1/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm b/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm
index 27d48a0..8f81857 100644
--- a/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm
+++ b/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm
@@ -98,7 +98,7 @@ __PACKAGE__->table("deliveryservice");
 
   data_type: 'bigint'
   is_foreign_key: 1
-  is_nullable: 0
+  is_nullable: 1
 
 =head2 cdn_id
 
@@ -323,7 +323,7 @@ __PACKAGE__->add_columns(
   "type",
   { data_type => "bigint", is_foreign_key => 1, is_nullable => 0 },
   "profile",
-  { data_type => "bigint", is_foreign_key => 1, is_nullable => 0 },
+  { data_type => "bigint", is_foreign_key => 1, is_nullable => 1 },
   "cdn_id",
   { data_type => "bigint", is_foreign_key => 1, is_nullable => 0 },
   "ccr_dns_ttl",
@@ -417,7 +417,7 @@ __PACKAGE__->set_primary_key("id", "type");
 
 =head1 UNIQUE CONSTRAINTS
 
-=head2 C<idx_18221_ds_id_unique>
+=head2 C<idx_90606_ds_id_unique>
 
 =over 4
 
@@ -427,9 +427,9 @@ __PACKAGE__->set_primary_key("id", "type");
 
 =cut
 
-__PACKAGE__->add_unique_constraint("idx_18221_ds_id_unique", ["id"]);
+__PACKAGE__->add_unique_constraint("idx_90606_ds_id_unique", ["id"]);
 
-=head2 C<idx_18221_ds_name_unique>
+=head2 C<idx_90606_ds_name_unique>
 
 =over 4
 
@@ -439,7 +439,7 @@ __PACKAGE__->add_unique_constraint("idx_18221_ds_id_unique", ["id"]);
 
 =cut
 
-__PACKAGE__->add_unique_constraint("idx_18221_ds_name_unique", ["xml_id"]);
+__PACKAGE__->add_unique_constraint("idx_90606_ds_name_unique", ["xml_id"]);
 
 =head1 RELATIONS
 
@@ -545,7 +545,12 @@ __PACKAGE__->belongs_to(
   "profile",
   "Schema::Result::Profile",
   { id => "profile" },
-  { is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" },
+  {
+    is_deferrable => 0,
+    join_type     => "LEFT",
+    on_delete     => "NO ACTION",
+    on_update     => "NO ACTION",
+  },
 );
 
 =head2 staticdnsentries
@@ -609,8 +614,8 @@ __PACKAGE__->belongs_to(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.07046 @ 2016-12-26 10:44:56
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:+HFlbMehDLwkF/hmfifkjw
+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2016-12-31 13:55:06
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:+2cW0kP4B6YbySGBBtDp0Q
 
 # You can replace this text with custom code or comments, and it will be preserved on regeneration
 #

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/05798ae1/traffic_ops/app/lib/Schema/Result/Profile.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Schema/Result/Profile.pm b/traffic_ops/app/lib/Schema/Result/Profile.pm
index 2839364..f7ccd98 100644
--- a/traffic_ops/app/lib/Schema/Result/Profile.pm
+++ b/traffic_ops/app/lib/Schema/Result/Profile.pm
@@ -47,6 +47,12 @@ __PACKAGE__->table("profile");
   is_nullable: 1
   original: {default_value => \"now()"}
 
+=head2 type
+
+  data_type: 'enum'
+  extra: {custom_type_name => "profile_type",list => ["SERVER_PROFILE","DS_PROFILE"]}
+  is_nullable: 0
+
 =head2 cdn
 
   data_type: 'bigint'
@@ -74,6 +80,15 @@ __PACKAGE__->add_columns(
     is_nullable   => 1,
     original      => { default_value => \"now()" },
   },
+  "type",
+  {
+    data_type => "enum",
+    extra => {
+      custom_type_name => "profile_type",
+      list => ["SERVER_PROFILE", "DS_PROFILE"],
+    },
+    is_nullable => 0,
+  },
   "cdn",
   { data_type => "bigint", is_foreign_key => 1, is_nullable => 1 },
 );
@@ -92,7 +107,7 @@ __PACKAGE__->set_primary_key("id");
 
 =head1 UNIQUE CONSTRAINTS
 
-=head2 C<idx_18384_name_unique>
+=head2 C<idx_90769_name_unique>
 
 =over 4
 
@@ -102,7 +117,7 @@ __PACKAGE__->set_primary_key("id");
 
 =cut
 
-__PACKAGE__->add_unique_constraint("idx_18384_name_unique", ["name"]);
+__PACKAGE__->add_unique_constraint("idx_90769_name_unique", ["name"]);
 
 =head1 RELATIONS
 
@@ -172,8 +187,8 @@ __PACKAGE__->has_many(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.07046 @ 2016-12-26 14:46:31
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:osx+OzuftRlkWwKwb1N+hg
+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2016-12-31 13:55:06
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:NyNmb9qs7HXNZ13aV1VvuQ
 
 
 # You can replace this text with custom code or comments, and it will be preserved on regeneration


[34/44] incubator-trafficcontrol git commit: rm db/ats_6_mso_migrate.pl - is all in the go migration now

Posted by mi...@apache.org.
rm db/ats_6_mso_migrate.pl - is all in the go migration now


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

Branch: refs/heads/master
Commit: 02ece633e67e62a702dbc2f1a0c109f12f8a6c70
Parents: a6b451b
Author: Jan van Doorn <jv...@apache.org>
Authored: Sat Feb 11 23:36:08 2017 +0000
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:11 2017 +0000

----------------------------------------------------------------------
 traffic_ops/app/db/ats_6_mso_migrate.pl | 107 ---------------------------
 1 file changed, 107 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/02ece633/traffic_ops/app/db/ats_6_mso_migrate.pl
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/ats_6_mso_migrate.pl b/traffic_ops/app/db/ats_6_mso_migrate.pl
deleted file mode 100755
index 6315b8c..0000000
--- a/traffic_ops/app/db/ats_6_mso_migrate.pl
+++ /dev/null
@@ -1,107 +0,0 @@
-#!/usr/bin/perl
-#
-#
-# 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.
-#
-
-# Script to create profiles / parameters from the header_rewrite settings to move to ATS 6.2
-# support.
-#
-# Please be careful using this script, it was created for a very specific use case, and only
-# tested our env - JvD
-
-use strict;
-use warnings;
-use DBI;
-
-my $driver   = "Pg";
-my $database = $ARGV[0];
-my $userid   = $ARGV[1];
-my $password = $ARGV[2];
-
-my $dsn = "DBI:$driver:dbname=$database;host=127.0.0.1;port=5432";
-my $dbh = DBI->connect( $dsn, $userid, $password, { RaiseError => 1 } )
-	or die $DBI::errstr;
-
-my @mso_algorithm_choices = ( "consistent_hash", "false", "strict", "true", "latched" );
-my $sql = 'select id,xml_id,mid_header_rewrite,multi_site_origin,multi_site_origin_algorithm,cdn_id from deliveryservice where multi_site_origin=true;';
-
-my %profile_ids;
-my $sth = $dbh->prepare_cached($sql);
-$sth->execute || die "Couldn't execute statement: " . $sth->errstr;
-while ( my @data = $sth->fetchrow_array() ) {
-	if ( defined( $data[3] ) && !$data[3] ) {
-		next;
-	}
-	if ( !defined( $profile_ids{ $data[1] } ) ) {
-		my $insp = $dbh->prepare('INSERT INTO PROFILE ("name", "description", "type", "cdn") VALUES(?, ?, ?, ?);');
-		$insp->bind_param( 1, "DS_" . $data[1] );
-		$insp->bind_param( 2, "Profile for delivery service " . $data[1] );
-		$insp->bind_param( 3, "DS_PROFILE");
-		$insp->bind_param( 4, $data[5]);
-		$insp->execute();
-		my $profile_id = $dbh->last_insert_id( undef, undef, "profile", undef );
-		$profile_ids{ $data[1] } = $profile_id;
-	}
-	if ( defined( $data[2] ) ) {
-		my @lines = split( /__RETURN__/, $data[2] );
-		foreach my $line (@lines) {
-			if ( $line =~ /set-config proxy.config.http.parent_origin/ ) {
-				my $setting = $line;
-				$setting =~ s/set-config\s+proxy.config.http.//;
-				# print $data[1] . " ->" . $setting . "\n";
-				$setting =~ s/^ *//;
-				my ( $name, $value ) = split( /\s+/, $setting );
-				# print $name . " -> " . $value . "\n";
-				my $insh = $dbh->prepare('INSERT INTO PARAMETER ("name", "config_file", "value") VALUES (?, ?, ?);');
-				$insh->bind_param( 1, 'mso.'.$name );
-				$insh->bind_param( 2, 'parent.config' );
-				$insh->bind_param( 3, $value );
-				$insh->execute();
-				my $param_id = $dbh->last_insert_id( undef, undef, "parameter", undef );
-				# print "Last inserted: " . $param_id;
-				my $inspp = $dbh->prepare('INSERT INTO PROFILE_PARAMETER ("parameter", "profile") VALUES (?, ?);');
-				$inspp->bind_param( 1, $param_id );
-				$inspp->bind_param( 2, $profile_ids{ $data[1] } );
-				$inspp->execute() || die "Couldn't execute statement: " . $inspp->errstr;
-			}
-		}
-	}
-	my $insh = $dbh->prepare('INSERT INTO PARAMETER ("name", "config_file", "value") VALUES (?, ?, ?);');
-	$insh->bind_param( 1, "algorithm" );
-	$insh->bind_param( 2, 'parent.config' );
-	my $mso_num = defined( $data[4] ) ? $data[4] : 0;
-	$insh->bind_param( 3, $mso_algorithm_choices[$mso_num] );
-	$insh->execute() || die "Couldn't execute statement: " . $insh->errstr;
-	my $param_id = $dbh->last_insert_id( undef, undef, "parameter", undef );
-	# print "Last inserted: " . $param_id;
-	my $inspp = $dbh->prepare('INSERT INTO PROFILE_PARAMETER ("parameter", "profile") VALUES (?, ?);');
-	$inspp->bind_param( 1, $param_id );
-	$inspp->bind_param( 2, $profile_ids{ $data[1] } );
-	$inspp->execute() || die "Couldn't execute statement: " . $inspp->errstr;
-}
-
-# drop all CCR profiles
-my $upd = $dbh->prepare('UPDATE deliveryservice SET profile=NULL;');
-$upd->execute() || die "Couldn't execute statement: " . $upd->errstr;
-
-# and update the ones that have a delivery service profile.
-foreach my $deliveryservice ( keys %profile_ids ) {
-	my $upd = $dbh->prepare('UPDATE deliveryservice SET profile=? WHERE xml_id=?;');
-	$upd->bind_param( 1, $profile_ids{$deliveryservice} );
-	$upd->bind_param( 2, $deliveryservice );
-	$upd->execute() || die "Couldn't execute statement: " . $upd->errstr;
-}
-
-$dbh->disconnect();
-


[13/44] incubator-trafficcontrol git commit: Checkpoint - t tests work now w Profile cdn / type

Posted by mi...@apache.org.
Checkpoint - t tests work now w Profile cdn / type


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

Branch: refs/heads/master
Commit: 5ef37cee40f4e4fe18b8c0901c16b9d9147799c3
Parents: 9ede7b6
Author: Jan van Doorn <ja...@cable.comcast.com>
Authored: Tue Jan 3 14:04:26 2017 -0700
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:10 2017 +0000

----------------------------------------------------------------------
 traffic_ops/app/lib/API/Deliveryservice.pm       | 18 +++++++++---------
 traffic_ops/app/lib/API/Deliveryservice2.pm      |  2 +-
 traffic_ops/app/lib/API/Profile.pm               | 19 ++++++++++++++++++-
 traffic_ops/app/lib/Fixtures/Profile.pm          | 14 +++++++-------
 .../Result/DeliveryServiceInfoForDomainList.pm   |  2 --
 .../Result/DeliveryServiceInfoForServerList.pm   |  2 --
 traffic_ops/app/lib/UI/ConfigFiles.pm            |  2 +-
 traffic_ops/app/lib/UI/DeliveryService.pm        |  8 +++++---
 traffic_ops/app/lib/UI/DeliveryServiceServer.pm  |  3 ++-
 traffic_ops/app/lib/UI/Profile.pm                |  1 +
 traffic_ops/app/t/api/1.2/profile.t              |  6 ++++--
 traffic_ops/app/t/deliveryservice.t              |  4 ++--
 traffic_ops/app/t/profile.t                      |  8 ++++++--
 13 files changed, 56 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/5ef37cee/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 156f8c9..b7eb1f9 100644
--- a/traffic_ops/app/lib/API/Deliveryservice.pm
+++ b/traffic_ops/app/lib/API/Deliveryservice.pm
@@ -93,12 +93,12 @@ sub index {
 				"missLat"                  => defined($row->miss_lat) ? 0.0 + $row->miss_lat : undef,
 				"missLat"                  => defined($row->miss_long) ? 0.0 + $row->miss_long : undef,
 				"multiSiteOrigin"          => \$row->multi_site_origin,
-				"multiSiteOriginAlgorithm" => $row->multi_site_origin_algorithm,
+				# "multiSiteOriginAlgorithm" => $row->multi_site_origin_algorithm,
 				"orgServerFqdn"            => $row->org_server_fqdn,
 				"originShield"             => $row->origin_shield,
-				"profileId"                => $row->profile->id,
-				"profileName"              => $row->profile->name,
-				"profileDescription"       => $row->profile->description,
+				"profileId"                => defined($row->profile) ? $row->profile->id : undef,
+				"profileName"              => defined($row->profile) ? $row->profile->name : undef,
+				"profileDescription"       => defined($row->profile) ? $row->profile->description : undef,
 				"protocol"                 => $row->protocol,
 				"qstringIgnore"            => $row->qstring_ignore,
 				"rangeRequestHandling"     => $row->range_request_handling,
@@ -190,7 +190,7 @@ sub show {
 				"missLat"                  => defined($row->miss_lat) ? 0.0 + $row->miss_lat : undef,
 				"missLat"                  => defined($row->miss_long) ? 0.0 + $row->miss_long : undef,
 				"multiSiteOrigin"          => \$row->multi_site_origin,
-				"multiSiteOriginAlgorithm" => $row->multi_site_origin_algorithm,
+				# "multiSiteOriginAlgorithm" => $row->multi_site_origin_algorithm,
 				"orgServerFqdn"            => $row->org_server_fqdn,
 				"originShield"             => $row->origin_shield,
 				"profileId"                => $row->profile->id,
@@ -275,7 +275,7 @@ sub update {
 		miss_lat                    => $params->{missLat},
 		miss_long                   => $params->{missLong},
 		multi_site_origin           => $params->{multiSiteOrigin},
-		multi_site_origin_algorithm => $params->{multiSiteOriginAlgorithm},
+		# multi_site_origin_algorithm => $params->{multiSiteOriginAlgorithm},
 		org_server_fqdn             => $params->{orgServerFqdn},
 		origin_shield               => $params->{originShield},
 		profile                     => $params->{profileId},
@@ -338,7 +338,7 @@ sub update {
 				"missLat"                  => 0.0 + $rs->miss_lat,
 				"missLong"                 => 0.0 + $rs->miss_long,
 				"multiSiteOrigin"          => $rs->multi_site_origin,
-				"multiSiteOriginAlgorithm" => $rs->multi_site_origin_algorithm,
+				# "multiSiteOriginAlgorithm" => $rs->multi_site_origin_algorithm,
 				"orgServerFqdn"            => $rs->org_server_fqdn,
 				"originShield"             => $rs->origin_shield,
 				"profileId"                => $rs->profile->id,
@@ -421,7 +421,7 @@ sub create {
 		miss_lat                    => $params->{missLat},
 		miss_long                   => $params->{missLong},
 		multi_site_origin           => $params->{multiSiteOrigin},
-		multi_site_origin_algorithm => $params->{multiSiteOriginAlgorithm},
+		# multi_site_origin_algorithm => $params->{multiSiteOriginAlgorithm},
 		org_server_fqdn             => $params->{orgServerFqdn},
 		origin_shield               => $params->{originShield},
 		profile                     => $params->{profileId},
@@ -494,7 +494,7 @@ sub create {
 				"missLat"                  => $insert->miss_lat,
 				"missLong"                 => $insert->miss_long,
 				"multiSiteOrigin"          => $insert->multi_site_origin,
-				"multiSiteOriginAlgorithm" => $insert->multi_site_origin_algorithm,
+				#"multiSiteOriginAlgorithm" => $insert->multi_site_origin_algorithm,
 				"orgServerFqdn"            => $insert->org_server_fqdn,
 				"originShield"             => $insert->origin_shield,
 				"profileId"                => $insert->profile->id,

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/5ef37cee/traffic_ops/app/lib/API/Deliveryservice2.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/Deliveryservice2.pm b/traffic_ops/app/lib/API/Deliveryservice2.pm
index 8243701..81b340c 100644
--- a/traffic_ops/app/lib/API/Deliveryservice2.pm
+++ b/traffic_ops/app/lib/API/Deliveryservice2.pm
@@ -116,7 +116,7 @@ sub delivery_services {
 					"missLat"                  => $row->miss_lat,
 					"missLong"                 => $row->miss_long,
 					"multiSiteOrigin"          => \$row->multi_site_origin,
-					"multiSiteOriginAlgorithm" => $row->multi_site_origin_algorithm,
+					# "multiSiteOriginAlgorithm" => $row->multi_site_origin_algorithm,
 					"orgServerFqdn"            => $row->org_server_fqdn,
 					"originShield"             => $row->origin_shield,
 					"profileId"                => $row->profile->id,

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/5ef37cee/traffic_ops/app/lib/API/Profile.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/Profile.pm b/traffic_ops/app/lib/API/Profile.pm
index 1de9c8c..7e05f47 100644
--- a/traffic_ops/app/lib/API/Profile.pm
+++ b/traffic_ops/app/lib/API/Profile.pm
@@ -124,6 +124,7 @@ sub show {
 
 sub create {
 	my $self   = shift;
+	print "KK:\n";
 	my $params = $self->req->json;
 	if ( !defined($params) ) {
 		return $self->alert("parameters must be in JSON format,  please check!");
@@ -153,10 +154,14 @@ sub create {
 		return $self->alert("a profile with the exact same description already exists.");
 	}
 
+	my $cdn = $params->{cdn};
+	my $type = $params->{type};
 	my $insert = $self->db->resultset('Profile')->create(
 		{
 			name        => $name,
 			description => $description,
+			cdn         => $cdn,
+			type        => $type,
 		}
 	);
 	$insert->insert();
@@ -168,6 +173,8 @@ sub create {
 	$response->{id}          = $new_id;
 	$response->{name}        = $name;
 	$response->{description} = $description;
+	$response->{cdn}         = $cdn;
+	$response->{type}        = $type;
 	return $self->success($response);
 }
 
@@ -200,10 +207,14 @@ sub copy {
 	my $profile_copy_from_id = $row1->id;
 	my $description          = $row1->description;
 
+	my $cdn = $row1->cdn;
+	my $type = $row1->type;
 	my $insert = $self->db->resultset('Profile')->create(
 		{
 			name        => $name,
 			description => $description,
+			cdn         => $cdn,
+			type        => $type,
 		}
 	);
 	$insert->insert();
@@ -275,9 +286,13 @@ sub update {
 		}
 	}
 
+	my $cdn = $params->{cdn};
+	my $type = $params->{type};
 	my $values = {
 		name        => $name,
-		description => $description
+		description => $description,
+		cdn         => $cdn,
+		type        => $type,
 	};
 
 	my $rs = $profile->update($values);
@@ -286,6 +301,8 @@ sub update {
 		$response->{id}          = $id;
 		$response->{name}        = $name;
 		$response->{description} = $description;
+		$response->{cdn}         = $cdn;
+		$response->{type}        = $type;
 		&log( $self, "Update profile with id: " . $id . " and name: " . $name, "APICHANGE" );
 		return $self->success( $response, "Profile was updated: " . $id );
 	}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/5ef37cee/traffic_ops/app/lib/Fixtures/Profile.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Fixtures/Profile.pm b/traffic_ops/app/lib/Fixtures/Profile.pm
index f4370fd..bb2a33a 100644
--- a/traffic_ops/app/lib/Fixtures/Profile.pm
+++ b/traffic_ops/app/lib/Fixtures/Profile.pm
@@ -25,7 +25,7 @@ my %definition_for = (
 			name        => 'EDGE1',
 			description => 'edge description',
 			cdn         => 1,
-			type        => 'SERVER_PROFILE',
+			type        => 'ATS_PROFILE',
 		},
 	},
 	MID1 => {
@@ -35,7 +35,7 @@ my %definition_for = (
 			name        => 'MID1',
 			description => 'mid description',
 			cdn         => 1,
-			type        => 'SERVER_PROFILE',
+			type        => 'ATS_PROFILE',
 		},
 	},
 	CCR1 => {
@@ -45,7 +45,7 @@ my %definition_for = (
 			name        => 'CCR1',
 			description => 'ccr description',
 			cdn         => 1,
-			type        => 'SERVER_PROFILE',
+			type        => 'TR_PROFILE',
 		},
 	},
 	CCR2 => {
@@ -55,7 +55,7 @@ my %definition_for = (
 			name        => 'CCR2',
 			description => 'ccr description',
 			cdn         => 2,
-			type        => 'SERVER_PROFILE',
+			type        => 'TR_PROFILE',
 		},
 	},
 	RIAK1 => {
@@ -65,7 +65,7 @@ my %definition_for = (
 			name        => 'RIAK1',
 			description => 'riak description',
 			cdn         => 1,
-			type        => 'SERVER_PROFILE',
+			type        => 'RIAK_PROFILE',
 		},
 	},
 	RASCAL1 => {
@@ -75,7 +75,7 @@ my %definition_for = (
 			name        => 'RASCAL1',
 			description => 'rascal description',
 			cdn         => 1,
-			type        => 'SERVER_PROFILE',
+			type        => 'TM_PROFILE',
 		},
 	},
 	RASCAL2 => {
@@ -85,7 +85,7 @@ my %definition_for = (
 			name        => 'RASCAL2',
 			description => 'rascal2 description',
 			cdn         => 2,
-			type        => 'SERVER_PROFILE',
+			type        => 'TM_PROFILE',
 		},
 	},
 	MISC => {

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/5ef37cee/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForDomainList.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForDomainList.pm b/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForDomainList.pm
index d64c681..8969815 100644
--- a/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForDomainList.pm
+++ b/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForDomainList.pm
@@ -46,7 +46,6 @@ SELECT
     deliveryservice.qstring_ignore,
     deliveryservice.org_server_fqdn,
     deliveryservice.multi_site_origin,
-    deliveryservice.multi_site_origin_algorithm,
     deliveryservice.range_request_handling,
     deliveryservice.origin_shield,
     regex.pattern,
@@ -84,7 +83,6 @@ __PACKAGE__->add_columns(
 	"xml_id",          { data_type => "varchar", is_nullable => 0, size => 45 },
 	"org_server_fqdn", { data_type => "varchar", is_nullable => 0, size => 45 },
 	"multi_site_origin",           { data_type => "integer", is_nullable => 0 },
-	"multi_site_origin_algorithm", { data_type => "tinyint", is_nullable => 1 },
 	"ds_id",                       { data_type => "integer", is_nullable => 0 },
 	"dscp",                        { data_type => "integer", is_nullable => 0 },
 	"signed",                      { data_type => "integer", is_nullable => 0 },

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/5ef37cee/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForServerList.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForServerList.pm b/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForServerList.pm
index 6fc45af..c7d6c02 100644
--- a/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForServerList.pm
+++ b/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForServerList.pm
@@ -46,7 +46,6 @@ SELECT
     deliveryservice.qstring_ignore AS qstring_ignore,
     deliveryservice.org_server_fqdn as org_server_fqdn,
     deliveryservice.multi_site_origin as multi_site_origin,
-    deliveryservice.multi_site_origin_algorithm as multi_site_origin_algorithm,
     deliveryservice.range_request_handling as range_request_handling,
     deliveryservice.origin_shield as origin_shield,
     regex.pattern AS pattern,
@@ -77,7 +76,6 @@ __PACKAGE__->add_columns(
 	"xml_id",          { data_type => "varchar", is_nullable => 0, size => 45 },
 	"org_server_fqdn", { data_type => "varchar", is_nullable => 0, size => 45 },
 	"multi_site_origin",           { data_type => "integer", is_nullable => 0 },
-	"multi_site_origin_algorithm", { data_type => "tinyint", is_nullable => 1 },
 	"ds_id",                       { data_type => "integer", is_nullable => 0 },
 	"dscp",                        { data_type => "integer", is_nullable => 0 },
 	"signed",                      { data_type => "integer", is_nullable => 0 },

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/5ef37cee/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 68af823..d64ae2e 100644
--- a/traffic_ops/app/lib/UI/ConfigFiles.pm
+++ b/traffic_ops/app/lib/UI/ConfigFiles.pm
@@ -212,7 +212,7 @@ sub ds_data {
 		my $cacheurl                    = $row->cacheurl;
 		my $remap_text                  = $row->remap_text;
 		my $multi_site_origin           = $row->multi_site_origin;
-		my $multi_site_origin_algorithm = $row->multi_site_origin_algorithm;
+		my $multi_site_origin_algorithm = 0; #TODO JvD -- may not need this here, the other params are needed somewhere else as well
 
 		if ( $re_type eq 'HOST_REGEXP' ) {
 			my $host_re = $row->pattern;

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/5ef37cee/traffic_ops/app/lib/UI/DeliveryService.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/UI/DeliveryService.pm b/traffic_ops/app/lib/UI/DeliveryService.pm
index 834b08d..f319757 100644
--- a/traffic_ops/app/lib/UI/DeliveryService.pm
+++ b/traffic_ops/app/lib/UI/DeliveryService.pm
@@ -958,6 +958,7 @@ sub create {
 	}
 
 	if ( $self->check_deliveryservice_input($cdn_id) ) {
+		print "CDN:$cdn_id\n";
 		my $insert = $self->db->resultset('Deliveryservice')->create(
 			{
 				xml_id                      => $self->paramAsScalar('ds.xml_id'),
@@ -1059,7 +1060,6 @@ sub create {
 			);
 			$insert->insert();
 			my $new_re_id = $insert->id;
-
 			my $de_re_insert = $self->db->resultset('DeliveryserviceRegex')->create(
 				{
 					regex           => $new_re_id,
@@ -1080,6 +1080,7 @@ sub create {
 		my $cdn_rs = $self->db->resultset('Cdn')->search( { id => $cdn_id } )->single();
 		my $dnssec_enabled = $cdn_rs->dnssec_enabled;
 
+
 		if ( $dnssec_enabled == 1 ) {
 			$self->app->log->debug("dnssec is enabled, creating dnssec keys");
 			$self->create_dnssec_keys( $cdn_rs->name, $self->param('ds.xml_id'), $new_id );
@@ -1090,7 +1091,7 @@ sub create {
 	else {
 		my $selected_type    = $self->param('ds.type');
 		my $selected_profile = $self->param('ds.profile');
-		my $selected_cdn     = $self->param('ds.cdn');
+		my $selected_cdn     = $self->param('ds.cdn_id');
 		&stash_role($self);
 		$self->stash(
 			ds               => {},
@@ -1188,7 +1189,8 @@ sub get_key_ttl {
 sub add {
 	my $self = shift;
 
-	$self->stash_profile_selector();
+	$self->stash_profile_selector('DS_PROFILE');
+	$self->stash_cdn_selector();
 	&stash_role($self);
 	$self->stash(
 		fbox_layout      => 1,

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/5ef37cee/traffic_ops/app/lib/UI/DeliveryServiceServer.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/UI/DeliveryServiceServer.pm b/traffic_ops/app/lib/UI/DeliveryServiceServer.pm
index 758025e..1007c8e 100644
--- a/traffic_ops/app/lib/UI/DeliveryServiceServer.pm
+++ b/traffic_ops/app/lib/UI/DeliveryServiceServer.pm
@@ -31,7 +31,8 @@ sub cpdss_iframe {
 		my $server = $self->db->resultset('Server')->search( { 'me.id' => $srvr_id }, { prefetch => [ 'cachegroup' ] } )->single();
 
 		my @etypeids = &type_ids( $self, 'EDGE%', 'server' );
-		my $rs = $self->db->resultset('Server')->search( { type => { -in => \@etypeids }, cdn_id => $server->cdn_id }, { prefetch => 'profile', order_by => 'host_name' } );
+		my $rs = $self->db->resultset('Server')->search( { 'me.type' => { -in => \@etypeids }, cdn_id => $server->cdn_id }, 
+			{ prefetch => 'profile', order_by => 'host_name' } );
 		my @from_server_list;
 		while ( my $row = $rs->next ) {
 			if ( $row->id == $srvr_id ) {

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/5ef37cee/traffic_ops/app/lib/UI/Profile.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/UI/Profile.pm b/traffic_ops/app/lib/UI/Profile.pm
index 550f18b..188bd84 100644
--- a/traffic_ops/app/lib/UI/Profile.pm
+++ b/traffic_ops/app/lib/UI/Profile.pm
@@ -236,6 +236,7 @@ sub create {
 	my $p_cdn         = $self->param('profile.cdn');
 	my $p_type        = $self->param('profile.type');
 
+	print ">>> cdn: $p_cdn t: $p_type \n";
 	if ( !&is_admin($self) ) {
 		my $err = "You must be an ADMIN to perform this operation!" . "__NEWLINE__";
 		return $self->flash( message => $err );

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/5ef37cee/traffic_ops/app/t/api/1.2/profile.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/api/1.2/profile.t b/traffic_ops/app/t/api/1.2/profile.t
index 427466c..dc0a58e 100644
--- a/traffic_ops/app/t/api/1.2/profile.t
+++ b/traffic_ops/app/t/api/1.2/profile.t
@@ -39,7 +39,7 @@ ok $t->post_ok( '/login', => form => { u => Test::TestHelper::ADMIN_USER, p => T
 	->or( sub { diag $t->tx->res->content->asset->{content}; } ), 'Should login?';
 
 ok $t->post_ok('/api/1.2/profiles' => {Accept => 'application/json'} => json => {
-	"name" => "CCR_CREATE", "description" => "CCR_CREATE description" })->status_is(200)
+	"name" => "CCR_CREATE", "description" => "CCR_CREATE description", "cdn" => 1, "type" => 'TR_PROFILE' })->status_is(200)
 	->or( sub { diag $t->tx->res->content->asset->{content}; } )
 	->json_is( "/response/name" => "CCR_CREATE" )
 	->json_is( "/response/description" => "CCR_CREATE description" )
@@ -72,7 +72,9 @@ my $profile_id = &get_profile_id('CCR_CREATE');
 
 ok $t->put_ok('/api/1.2/profiles/' . $profile_id  => {Accept => 'application/json'} => json => {
         "name" => "CCR_UPDATE",
-        "description" => "CCR_UPDATE description"
+        "description" => "CCR_UPDATE description",
+        "cdn" => 1,
+        "type" => "TR_PROFILE"
         })
     ->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } )
     ->json_is( "/response/id" => "$profile_id")

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/5ef37cee/traffic_ops/app/t/deliveryservice.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/deliveryservice.t b/traffic_ops/app/t/deliveryservice.t
index 99866b1..189791c 100644
--- a/traffic_ops/app/t/deliveryservice.t
+++ b/traffic_ops/app/t/deliveryservice.t
@@ -183,7 +183,7 @@ ok $t->post_ok(
 		'ds.qstring_ignore'              => '1',
 		'ds.signed'                      => '1',
 		'ds.type'                        => '9',
-		'ds.xml_id'                      => 'tst_xml_id_2',
+		'ds.xml_id'                      => 'tst_xml_id_3',
 		'ds.protocol'                    => '0',
 		'ds.edge_header_rewrite'         => '',
 		'ds.mid_header_rewrite'          => '',
@@ -201,7 +201,7 @@ ok $t->post_ok(
 		'ds.regional_geo_blocking'       => '0',
 		'ds.geolimit_redirect_url'       => 'http://knutsel3.com',
 	}
-)->status_is(200), "create HTTP_NO_CACHE deliveryservice";
+)->status_is(302), "create HTTP_NO_CACHE deliveryservice";
 
 #add - validate 200 response (data is actually added to DB when create is called)
 ok $t->get_ok('/ds/add')->status_is(200), "validate add screen";

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/5ef37cee/traffic_ops/app/t/profile.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/profile.t b/traffic_ops/app/t/profile.t
index 6293ed0..a4947b4 100644
--- a/traffic_ops/app/t/profile.t
+++ b/traffic_ops/app/t/profile.t
@@ -52,7 +52,9 @@ $t->get_ok('/dataprofile')->status_is(200)->json_has('/0/name')->json_has('/0/de
 $t->post_ok(
 	'/profile/create' => form => {
 		'profile.name'        => 'JLP_Test',
-		'profile.description' => 'JLP Test Host'
+		'profile.description' => 'JLP Test Host',
+		'profile.cdn'         => 1,
+		'profile.type'        => 'ATS_PROFILE'
 	}
 )->status_is(302)->or( sub { diag $t->tx->res->content->asset->{content}; } );
 
@@ -71,7 +73,9 @@ sub upd_and_del() {
 		$t->post_ok(
 			"/profile/$id/update" => form => {
 				'profile.name'        => 'JLP_Test',
-				'profile.description' => 'JLP Test Host Updated'
+				'profile.description' => 'JLP Test Host Updated',
+				'profile.cdn'         => 1,
+				'profile.type'        => 'ATS_PROFILE'
 			}
 		)->status_is(302)->or( sub { diag $t->tx->res->content->asset->{content}; } );
 		$t->get_ok("/profile/$id/delete")->status_is(302);


[11/44] incubator-trafficcontrol git commit: Merge 1 - Tests

Posted by mi...@apache.org.
Merge 1 - Tests


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

Branch: refs/heads/master
Commit: 742d475ce7a877b07557ae739f34b33fbac4cc2e
Parents: 36a4d0e
Author: Jan van Doorn <ja...@cable.comcast.com>
Authored: Tue Dec 27 20:44:23 2016 -0700
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:10 2017 +0000

----------------------------------------------------------------------
 traffic_ops/app/lib/API/Cdn.pm                  | 29 +++++++-------------
 .../app/lib/API/DeliveryService/SslKeys.pm      | 12 ++------
 .../app/lib/API/DeliveryServiceServer.pm        | 20 ++++++--------
 traffic_ops/app/lib/API/Deliveryservice.pm      |  2 +-
 traffic_ops/app/lib/API/Deliveryservice2.pm     | 19 +++++--------
 traffic_ops/app/lib/Fixtures/Cdn.pm             |  2 ++
 traffic_ops/app/lib/Fixtures/Profile.pm         | 15 ++++++++++
 .../app/lib/MojoPlugins/DeliveryService.pm      | 21 ++++----------
 .../Result/DeliveryServiceInfoForDomainList.pm  |  8 ++----
 .../Result/DeliveryServiceInfoForServerList.pm  |  7 ++---
 traffic_ops/app/lib/Test/TestHelper.pm          |  2 +-
 traffic_ops/app/lib/UI/ConfigFiles.pm           | 13 +++++----
 traffic_ops/app/lib/UI/DataAll.pm               | 19 ++++++-------
 traffic_ops/app/lib/UI/DeliveryService.pm       | 11 ++------
 traffic_ops/app/lib/UI/DnssecKeys.pm            | 15 +++-------
 traffic_ops/app/lib/UI/Server.pm                |  6 ++++
 traffic_ops/app/lib/UI/Topology.pm              |  5 ++--
 .../app/t/api/1.1/deliveryservice/ssl_keys.t    |  2 +-
 traffic_ops/app/t/api/1.2/deliveryservice.t     |  8 +++---
 19 files changed, 93 insertions(+), 123 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/742d475c/traffic_ops/app/lib/API/Cdn.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/Cdn.pm b/traffic_ops/app/lib/API/Cdn.pm
index c432ec7..269dec9 100644
--- a/traffic_ops/app/lib/API/Cdn.pm
+++ b/traffic_ops/app/lib/API/Cdn.pm
@@ -627,11 +627,9 @@ sub gen_traffic_router_config {
 		'profile_parameters.profile' => $ccr_profile_id,
 		'config_file'                => 'CRConfig.json'
 	);
+	$ccr_domain_name = $self->db->resultset('Cdn')->search({ 'name' => $cdn_name})->get_column('domain_name')->single();
 	my $rs_config = $self->db->resultset('Parameter')->search( \%condition, { join => 'profile_parameters' } );
 	while ( my $row = $rs_config->next ) {
-		if ( $row->name eq 'domain_name' ) {
-			$ccr_domain_name = $row->value;
-		}
 		if ( $row->name eq 'tld.soa.admin' ) {
 			$cdn_soa_admin = $row->value;
 		}
@@ -1039,23 +1037,15 @@ sub domains {
 	my $self = shift;
 	my @data;
 
-	my @ccrprofs = $self->db->resultset('Profile')->search( { name => { -like => 'CCR%' } } )->get_column('id')->all();
-	my $rs_pp = $self->db->resultset('ProfileParameter')->search(
-		{
-			profile                 => { -in => \@ccrprofs },
-			'parameter.name'        => 'domain_name',
-			'parameter.config_file' => 'CRConfig.json'
-		},
-		{ prefetch => [ 'parameter', 'profile' ] }
-	);
-	while ( my $row = $rs_pp->next ) {
+	my $rs = $self->db->resultset('Profile')->search( { 'me.name' => { -like => 'CCR%' } }, { prefetch => ['cdn'] } );
+	while ( my $row = $rs->next ) {
 		push(
 			@data, {
-				"domainName"         => $row->parameter->value,
-				"parameterId"        => $row->parameter->id,
-				"profileId"          => $row->profile->id,
-				"profileName"        => $row->profile->name,
-				"profileDescription" => $row->profile->description,
+				"domainName"         => $row->cdn->domain_name,
+				"parameterId"        => -1,  # it's not a parameter anymore
+				"profileId"          => $row->id,
+				"profileName"        => $row->name,
+				"profileDescription" => $row->description,
 			}
 		);
 
@@ -1112,6 +1102,7 @@ sub refresh_keys {
 	while ( my $row = $rs_data->next ) {
 		if ( $row->dnssec_enabled == 1 ) {
 			my $cdn_name = $row->name;
+			my $cdn_domain_name = $row->domain_name;
 			my $keys;
 			my $response_container = $self->riak_get( "dnssec", $cdn_name );
 			my $get_keys = $response_container->{'response'};
@@ -1211,7 +1202,7 @@ sub refresh_keys {
 					my $ds_id = $ds->id;
 
 					#create the ds domain name for dnssec keys
-					my $domain_name = UI::DeliveryService::get_cdn_domain( $self, $ds_id );
+					my $domain_name = $cdn_domain_name;
 					my $deliveryservice_regexes = UI::DeliveryService::get_regexp_set( $self, $ds_id );
 					my $rs_ds = $self->db->resultset('Deliveryservice')
 						->search( { 'me.xml_id' => $xml_id }, { prefetch => [ { 'type' => undef }, { 'profile' => undef } ] } );

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/742d475c/traffic_ops/app/lib/API/DeliveryService/SslKeys.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/DeliveryService/SslKeys.pm b/traffic_ops/app/lib/API/DeliveryService/SslKeys.pm
index e7cf456..49d19fc 100644
--- a/traffic_ops/app/lib/API/DeliveryService/SslKeys.pm
+++ b/traffic_ops/app/lib/API/DeliveryService/SslKeys.pm
@@ -158,15 +158,9 @@ sub view_by_hostname {
 		my @ds_ids_regex = $self->db->resultset('Deliveryservice')
 			->search( { 'regex.pattern' => "$host_regex" }, { join => { deliveryservice_regexes => { regex => undef } } } )->get_column('id')->all();
 
-		my @domain_profiles = $self->db->resultset('Profile')->search(
-			{
-				'parameter.value'       => "$domain_name",
-				'parameter.config_file' => 'CRConfig.json',
-				'parameter.name'        => 'domain_name'
-			}, {
-				join => { 'profile_parameters' => { parameter => undef } }
-			}
-		)->get_column('id')->all();
+		# TODO JvD - test this with online riak servers!
+		my $cdn_id = $self->db->resultset('Cdn')->search( { domain_name => $domain_name } )->get_column('id');
+		my@domain_profiles = $self->db->resultset('Profile')->search( { cdn => $cdn_id } )->get_column('id')->all();
 
 		my $rs_ds = $self->db->resultset('Deliveryservice')->search( { 'profile' => { -in => \@domain_profiles } }, {} );
 

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/742d475c/traffic_ops/app/lib/API/DeliveryServiceServer.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/DeliveryServiceServer.pm b/traffic_ops/app/lib/API/DeliveryServiceServer.pm
index 441a20a..3cfee04 100644
--- a/traffic_ops/app/lib/API/DeliveryServiceServer.pm
+++ b/traffic_ops/app/lib/API/DeliveryServiceServer.pm
@@ -46,23 +46,21 @@ sub index {
 	$self->success( \@data, undef, $orderby, $limit, $page );
 }
 
+
+# why is this here and in API/Cdn.pm?
 sub domains {
 	my $self = shift;
 	my @data;
 
-	my @ccrprofs = $self->db->resultset('Profile')->search( { name => { -like => 'CCR%' } } )->get_column('id')->all();
-	my $rs_pp =
-		$self->db->resultset('ProfileParameter')
-		->search( { profile => { -in => \@ccrprofs }, 'parameter.name' => 'domain_name', 'parameter.config_file' => 'CRConfig.json' },
-		{ prefetch => [ 'parameter', 'profile' ] } );
-	while ( my $row = $rs_pp->next ) {
+	my $rs = $self->db->resultset('Profile')->search( { 'me.name' => { -like => 'CCR%' } }, { prefetch => ['cdn'] } );
+	while ( my $row = $rs->next ) {
 		push(
 			@data, {
-				"domainName"         => $row->parameter->value,
-				"parameterId"        => $row->parameter->id,
-				"profileId"          => $row->profile->id,
-				"profileName"        => $row->profile->name,
-				"profileDescription" => $row->profile->description,
+				"domainName"         => $row->cdn->domain_name,
+				"parameterId"        => -1,  # it's not a parameter anymore
+				"profileId"          => $row->id,
+				"profileName"        => $row->name,
+				"profileDescription" => $row->description,
 			}
 		);
 

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/742d475c/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 d14b1a4..156f8c9 100644
--- a/traffic_ops/app/lib/API/Deliveryservice.pm
+++ b/traffic_ops/app/lib/API/Deliveryservice.pm
@@ -225,7 +225,7 @@ sub update {
 	}
 
 	my ( $is_valid, $result ) = $self->is_deliveryservice_valid($params);
-
+	print ">>>> " . $is_valid . " > < " . $result . "\n";
 	if ( !$is_valid ) {
 		return $self->alert($result);
 	}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/742d475c/traffic_ops/app/lib/API/Deliveryservice2.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/Deliveryservice2.pm b/traffic_ops/app/lib/API/Deliveryservice2.pm
index 946b415..8243701 100644
--- a/traffic_ops/app/lib/API/Deliveryservice2.pm
+++ b/traffic_ops/app/lib/API/Deliveryservice2.pm
@@ -419,26 +419,21 @@ sub _check_params {
 		return (undef, "protocol must be 0|1|2|3." );
 	}
 
+
 	if ( defined($params->{profileName}) ) {
-		my $ccr_profiles;
-		my @ccrprofs = $self->db->resultset('Profile')->search( { name => { -like => 'CCR%' } } )->get_column('id')->all();
-		my $rs = $self->db->resultset('ProfileParameter')->search(
-				{ profile => { -in => \@ccrprofs }, 'parameter.name' => 'domain_name', 'parameter.config_file' => 'CRConfig.json' },
-				{ prefetch => [ 'parameter', 'profile' ] }
-		);
-		while ( my $row = $rs->next ) {
-			$ccr_profiles->{ $row->profile->name } = $row->profile->id;
-		}
-		if ( !exists $ccr_profiles->{ $params->{profileName} } ) {
-			return (undef, "profileName (" . $params->{profileName} . ") must be CCR profiles." );
+		my $pname = $params->{profileName};
+		my $profile =  $self->db->resultset('Profile')->search( { 'me.name' => $pname }, { prefetch => ['cdn'] } )->single();
+		if ( !defined($profile) || $profile->cdn->name ne  $params->{cdnName} ) {
+			return (undef, "profileName (" . $params->{profileName} . ") does not exist, or is not on the same CDN as " . $params->{cdnName} );
 		}
 		else {
-			$transformed_params->{ profile_id } = $ccr_profiles->{ $params->{profileName} };
+			$transformed_params->{ profile_id } = $profile->id;
 		}
 	} else {
 		return (undef, "parameter profileName is must." );
 	}
 
+
 	my $cdn_id = undef;
 	if ( defined($params->{cdnName}) ) {
 		$cdn_id = $self->db->resultset('Cdn')->search( { name => $params->{cdnName} } )->get_column('id')->single();

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/742d475c/traffic_ops/app/lib/Fixtures/Cdn.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Fixtures/Cdn.pm b/traffic_ops/app/lib/Fixtures/Cdn.pm
index 4ca30b4..c62640a 100644
--- a/traffic_ops/app/lib/Fixtures/Cdn.pm
+++ b/traffic_ops/app/lib/Fixtures/Cdn.pm
@@ -25,6 +25,7 @@ my %definition_for = (
 		using => {
 			id          => 100,
 			name        => 'cdn1',
+			domain_name => 'cdn1.kabletown.net',
 		},
 	},
 	## id => 2
@@ -33,6 +34,7 @@ my %definition_for = (
 		using => {
 			id          => 200,
 			name        => 'cdn2',
+			domain_name => 'cdn2.kabletown.net',
 		},
 	},
 );

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/742d475c/traffic_ops/app/lib/Fixtures/Profile.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Fixtures/Profile.pm b/traffic_ops/app/lib/Fixtures/Profile.pm
index f14f629..be05f9c 100644
--- a/traffic_ops/app/lib/Fixtures/Profile.pm
+++ b/traffic_ops/app/lib/Fixtures/Profile.pm
@@ -24,6 +24,7 @@ my %definition_for = (
 			id          => 100,
 			name        => 'EDGE1',
 			description => 'edge description',
+			cdn         => 1,
 		},
 	},
 	MID1 => {
@@ -32,6 +33,7 @@ my %definition_for = (
 			id          => 200,
 			name        => 'MID1',
 			description => 'mid description',
+			cdn         => 1,
 		},
 	},
 	CCR1 => {
@@ -40,6 +42,16 @@ my %definition_for = (
 			id          => 300,
 			name        => 'CCR1',
 			description => 'ccr description',
+			cdn         => 1,
+		},
+	},
+	CCR2 => {
+		new   => 'Profile',
+		using => {
+			id          => 301,
+			name        => 'CCR2',
+			description => 'ccr description',
+			cdn         => 2,
 		},
 	},
 	RIAK1 => {
@@ -48,6 +60,7 @@ my %definition_for = (
 			id          => 500,
 			name        => 'RIAK1',
 			description => 'riak description',
+			cdn         => 1,
 		},
 	},
 	RASCAL1 => {
@@ -56,6 +69,7 @@ my %definition_for = (
 			id          => 600,
 			name        => 'RASCAL1',
 			description => 'rascal description',
+			cdn         => 1,
 		},
 	},
 	RASCAL2 => {
@@ -64,6 +78,7 @@ my %definition_for = (
 			id          => 700,
 			name        => 'RASCAL2',
 			description => 'rascal2 description',
+			cdn         => 2,
 		},
 	},
 	MISC => {

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/742d475c/traffic_ops/app/lib/MojoPlugins/DeliveryService.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/MojoPlugins/DeliveryService.pm b/traffic_ops/app/lib/MojoPlugins/DeliveryService.pm
index e14e0fb..ccaa43f 100755
--- a/traffic_ops/app/lib/MojoPlugins/DeliveryService.pm
+++ b/traffic_ops/app/lib/MojoPlugins/DeliveryService.pm
@@ -214,14 +214,8 @@ sub register {
 			my $self = shift || confess($no_instance_message);
 			my $ds_id = shift || confess("Please supply a delivery service id!");
 
-			my $cdn_domain = $self->db->resultset('Parameter')->search(
-				{ -and => [ 'me.name' => 'domain_name', 'deliveryservices.id' => $ds_id ] },
-				{
-					join     => { profile_parameters => { profile => { deliveryservices => undef } } },
-					distinct => 1
-				}
-			)->get_column('value')->single();
-
+			my $cdn_id = $self->db->resultset('Deliveryservice')->search( { id => $ds_id } )->get_column('cdn_id')->single();
+			my $cdn_domain = $self->db->resultset('Cdn')->search( { id =>  $cdn_id } )->get_column('domain_name')->single();
 			return $cdn_domain;
 		}
 	);
@@ -231,14 +225,9 @@ sub register {
 			my $self = shift || confess($no_instance_message);
 			my $profile_id = shift || confess("Please Supply a profile id");
 
-			return $self->db->resultset('Parameter')->search(
-				{
-					'Name'                       => 'domain_name',
-					'Config_file'                => 'CRConfig.json',
-					'profile_parameters.profile' => $profile_id,
-				},
-				{ join => 'profile_parameters', }
-			)->get_column('value')->single();
+			my $cdn_id = $self->db->resultset('Profile')->search( { id => $profile_id } )->get_column('cdn')->single();
+			my $cdn_domain = $self->db->resultset('Cdn')->search( { id =>  $cdn_id } )->get_column('domain_name')->single();
+			return $cdn_domain;
 		}
 	);
 

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/742d475c/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForDomainList.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForDomainList.pm b/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForDomainList.pm
index 7476054..d64c681 100644
--- a/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForDomainList.pm
+++ b/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForDomainList.pm
@@ -52,7 +52,7 @@ SELECT
     regex.pattern,
     retype.name AS re_type,
     dstype.name AS ds_type,
-    parameter.value AS domain_name,
+    cdn.name AS domain_name,
     deliveryservice_regex.set_number,
     deliveryservice.edge_header_rewrite,
     deliveryservice.mid_header_rewrite,
@@ -66,11 +66,9 @@ FROM
     JOIN regex ON deliveryservice_regex.regex = regex.id
     JOIN type as retype ON regex.type = retype.id
     JOIN type as dstype ON deliveryservice.type = dstype.id
-    JOIN profile_parameter ON deliveryservice.profile = profile_parameter.profile
-    JOIN parameter ON parameter.id = profile_parameter.parameter
+    JOIN cdn ON cdn.id = deliveryservice.cdn_id
 WHERE
-    parameter.name = 'domain_name'
-    AND parameter.value = ?
+    cdn.domain_name = ?
     AND deliveryservice.id in (
         SELECT
             deliveryservice_server.deliveryservice

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/742d475c/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForServerList.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForServerList.pm b/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForServerList.pm
index 2c36f82..6fc45af 100644
--- a/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForServerList.pm
+++ b/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForServerList.pm
@@ -52,7 +52,7 @@ SELECT
     regex.pattern AS pattern,
     retype.name AS re_type,
     dstype.name AS ds_type,
-    parameter.value AS domain_name,
+    cdn.domain_name AS domain_name,
     deliveryservice_regex.set_number AS set_number,
     deliveryservice.edge_header_rewrite as edge_header_rewrite,
     deliveryservice.regex_remap as regex_remap,
@@ -66,10 +66,9 @@ FROM
         JOIN regex ON deliveryservice_regex.regex = regex.id
         JOIN type as retype ON regex.type = retype.id
         JOIN type as dstype ON deliveryservice.type = dstype.id
-        JOIN profile_parameter ON deliveryservice.profile = profile_parameter.profile
-        JOIN parameter ON parameter.id = profile_parameter.parameter
+        JOIN cdn ON cdn.id = deliveryservice.cdn_id
         JOIN deliveryservice_server ON deliveryservice_server.deliveryservice = deliveryservice.id
-WHERE parameter.name = 'domain_name' AND deliveryservice_server.server = ?
+WHERE deliveryservice_server.server = ?
 ORDER BY ds_id, re_type , deliveryservice_regex.set_number
 "
 );

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/742d475c/traffic_ops/app/lib/Test/TestHelper.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Test/TestHelper.pm b/traffic_ops/app/lib/Test/TestHelper.pm
index 2b53dcd..acb9399 100644
--- a/traffic_ops/app/lib/Test/TestHelper.pm
+++ b/traffic_ops/app/lib/Test/TestHelper.pm
@@ -151,7 +151,7 @@ sub unload_core_data {
 	$self->teardown($schema, 'ProfileParameter');
 	$self->teardown($schema, 'Type');
 	$self->teardown($schema, 'Status');
-	$self->teardown( $schema, 'Snapshot' );
+	$self->teardown($schema, 'Snapshot');
 	$self->teardown($schema, 'Cdn');
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/742d475c/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 a609963..68af823 100644
--- a/traffic_ops/app/lib/UI/ConfigFiles.pm
+++ b/traffic_ops/app/lib/UI/ConfigFiles.pm
@@ -186,7 +186,7 @@ sub ds_data {
 	if ( $server->type->name =~ m/^MID/ ) {
 
 		# the mids will do all deliveryservices in this CDN
-		my $domain = $self->profile_param_value( $server->profile->id, 'CRConfig.json', 'domain_name', '' );
+		my $domain = $self->get_cdn_domain_by_profile_id( $server->profile->id );
 		$rs = $self->db->resultset('DeliveryServiceInfoForDomainList')->search( {}, { bind => [$domain] } );
 	}
 	else {
@@ -370,7 +370,7 @@ sub parent_data {
 	}
 
 	# get the server's cdn domain
-	my $server_domain = $self->profile_param_value( $server->profile->id, 'CRConfig.json', 'domain_name' );
+	my $server_domain = $self->get_cdn_domain_by_profile_id( $server->profile->id ); 
 
 	my %profile_cache;
 	my %deliveryservices;
@@ -388,6 +388,7 @@ sub parent_data {
 			my $rank           = $profile_cache{$pid}->{rank};
 			my $primary_parent         = $server->cachegroup->parent_cachegroup_id // -1;
 			my $secondary_parent      = $server->cachegroup->secondary_parent_cachegroup_id // -1;
+			print "ds_domain:" . $ds_domain . " server_domain: ". $server_domain . "\n";
 			if ( defined($ds_domain) && defined($server_domain) && $ds_domain eq $server_domain ) {
 				my %p = (
 					host_name      => $row->host_name,
@@ -424,7 +425,7 @@ sub cachegroup_profiles {
 		cachegroup => { -in => $ids }
 	);
 
-	my $rs_parent = $self->db->resultset('Server')->search( \%condition, { prefetch => [ 'cachegroup', 'status', 'type', 'profile' ] } );
+	my $rs_parent = $self->db->resultset('Server')->search( \%condition, { prefetch => [ 'cachegroup', 'status', 'type', 'profile', 'cdn' ] } );
 
 	while ( my $row = $rs_parent->next ) {
 
@@ -447,7 +448,7 @@ sub cachegroup_profiles {
 
 			# assign $ds_domain, $weight and $port, and cache the results %profile_cache
 			$profile_cache->{$pid} = {
-				domain_name    => $self->profile_param_value( $pid, 'CRConfig.json', 'domain_name',    undef ),
+				domain_name    => $row->cdn->domain_name,
 				weight         => $self->profile_param_value( $pid, 'parent.config', 'weight',         '0.999' ),
 				port           => $self->profile_param_value( $pid, 'parent.config', 'port',           undef ),
 				use_ip_address => $self->profile_param_value( $pid, 'parent.config', 'use_ip_address', 0 ),
@@ -1505,13 +1506,13 @@ sub ssl_multicert_dot_config {
 	# get a list of delivery services for the server
 	my $protocol_search = '> 0';
 	my @ds_list = $self->db->resultset('Deliveryservice')->search( { -and => [ 'server.id' => $server->id, 'me.protocol' => \$protocol_search ] },
-		{ join => { deliveryservice_servers => { server => undef } }, } );
+		{ prefetch => ['cdn'], join => { deliveryservice_servers => { server => undef } }, } );
 	foreach my $ds (@ds_list) {
 		my $ds_id        = $ds->id;
 		my $xml_id       = $ds->xml_id;
 		my $rs_ds        = $self->db->resultset('Deliveryservice')->search( { 'me.id' => $ds_id }, { prefetch => ['type'] } );
 		my $data         = $rs_ds->single;
-		my $domain_name  = UI::DeliveryService::get_cdn_domain( $self, $ds_id );
+		my $domain_name  = $ds->cdn->domain_name;
 		my $ds_regexes   = UI::DeliveryService::get_regexp_set( $self, $ds_id );
 		my @example_urls = UI::DeliveryService::get_example_urls( $self, $ds_id, $ds_regexes, $data, $domain_name, $data->protocol );
 

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/742d475c/traffic_ops/app/lib/UI/DataAll.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/UI/DataAll.pm b/traffic_ops/app/lib/UI/DataAll.pm
index d1ba298..0e4d61c 100644
--- a/traffic_ops/app/lib/UI/DataAll.pm
+++ b/traffic_ops/app/lib/UI/DataAll.pm
@@ -99,23 +99,20 @@ sub data_server {
 }
 
 # deprecated @see API/ProfileParameters#domains
+# TODO JvD - this is the 3rd copy of the exact same function!
 sub data_domains {
 	my $self = shift;
 	my @data;
 
-	my @ccrprofs = $self->db->resultset('Profile')->search( { name => { -like => 'CCR%' } } )->get_column('id')->all();
-	my $rs_pp =
-		$self->db->resultset('ProfileParameter')
-		->search( { profile => { -in => \@ccrprofs }, 'parameter.name' => 'domain_name', 'parameter.config_file' => 'CRConfig.json' },
-		{ prefetch => [ 'parameter', 'profile' ] } );
-	while ( my $row = $rs_pp->next ) {
+	my $rs = $self->db->resultset('Profile')->search( { 'me.name' => { -like => 'CCR%' } }, { prefetch => ['cdn'] } );
+	while ( my $row = $rs->next ) {
 		push(
 			@data, {
-				"domain_name"         => $row->parameter->value,
-				"parameter_id"        => $row->parameter->id,
-				"profile_id"          => $row->profile->id,
-				"profile_name"        => $row->profile->name,
-				"profile_description" => $row->profile->description,
+				"domainName"         => $row->cdn->domain_name,
+				"parameterId"        => -1,  # it's not a parameter anymore
+				"profileId"          => $row->id,
+				"profileName"        => $row->name,
+				"profileDescription" => $row->description,
 			}
 		);
 

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/742d475c/traffic_ops/app/lib/UI/DeliveryService.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/UI/DeliveryService.pm b/traffic_ops/app/lib/UI/DeliveryService.pm
index 31f4854..b40caa3 100644
--- a/traffic_ops/app/lib/UI/DeliveryService.pm
+++ b/traffic_ops/app/lib/UI/DeliveryService.pm
@@ -71,15 +71,8 @@ sub edit {
 sub get_cdn_domain {
 	my $self       = shift;
 	my $id         = shift;
-	my $cdn_domain = $self->db->resultset('Parameter')->search(
-		{ -and => [ 'me.name' => 'domain_name', 'deliveryservices.id' => $id ] },
-		{
-			join     => { profile_parameters => { profile => { deliveryservices => undef } } },
-			distinct => 1
-		}
-	)->get_column('value')->single();
-	# Always return a lowercase FQDN.
-	return lc($cdn_domain);
+
+	return $self->db->resultset('Deliveryservice')->search( { id => $id }, { prefetch => ['cdn']} )->get_column('domain_name')->single();
 }
 
 sub get_example_urls {

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/742d475c/traffic_ops/app/lib/UI/DnssecKeys.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/UI/DnssecKeys.pm b/traffic_ops/app/lib/UI/DnssecKeys.pm
index 70e5595..97ec1e9 100644
--- a/traffic_ops/app/lib/UI/DnssecKeys.pm
+++ b/traffic_ops/app/lib/UI/DnssecKeys.pm
@@ -239,21 +239,14 @@ sub create {
 		}
 
 		#create keys
-		my $name = $self->db->resultset('Parameter')->search(
-			{   -and => [
-					'me.name'        => 'domain_name',
-					'me.config_file' => 'CRConfig.json',
-					'profile.id'     => $profile_id
-				]
-			},
-			{ join => { profile_parameters => { profile => undef } }, }
-		)->get_column('value')->single();
+		my $profile = $self->db->resultset('Profile')->search( { id => $profile_id }, { prefetch => ['cdn'] } )->single();
+		my $domain_name = $profile->cdn->domain_name;
 
 		my $response_container = $self->riak_ping();
 		my $ping_response      = $response_container->{response};
 		if ( $ping_response->is_success ) {
 			my $response_container
-				= $self->generate_store_dnssec_keys( $cdn_name, $name, $ttl,
+				= $self->generate_store_dnssec_keys( $cdn_name, $domain_name, $ttl,
 				$k_expiry, $z_expiry, $effective_date );
 			my $response = $response_container->{response};
 			if ( $response->is_success ) {
@@ -264,7 +257,7 @@ sub create {
 			}
 			else {
 				$self->flash(
-					{   "DNSSEC keys for $name could not be created.  Response was"
+					{   "DNSSEC keys for $domain_name could not be created.  Response was"
 							. $response->{_content}
 					}
 				);

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/742d475c/traffic_ops/app/lib/UI/Server.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/UI/Server.pm b/traffic_ops/app/lib/UI/Server.pm
index 8103903..c46909f 100644
--- a/traffic_ops/app/lib/UI/Server.pm
+++ b/traffic_ops/app/lib/UI/Server.pm
@@ -449,6 +449,12 @@ sub check_server_input {
 	if ( defined( $paramHashRef->{'csv_line_number'} ) && length($err) > 0 ) {
 		$err = '</li><li>' . $errorCSVLineDelim . '[LINE #:' . $paramHashRef->{'csv_line_number'} . ']:  ' . $err . '\n';
 	}
+
+	my $profile = $self->db->resultset('Profile')->search( { 'me.id' => $paramHashRef->{'profile'}}, { prefetch => ['cdn'] } )->single();
+	my $cdn = $self->db->resultset('Cdn')->search( { 'me.id' => $paramHashRef->{'cdn'} } )->single();
+	if ( $profile->cdn->id != $cdn->id ) {
+		$err .= "the " . $paramHashRef->{'profile'} . " profile is not in the  " . $paramHashRef->{'cdn'} . " CDN." . $sep;
+	}
 	return $err;
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/742d475c/traffic_ops/app/lib/UI/Topology.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/UI/Topology.pm b/traffic_ops/app/lib/UI/Topology.pm
index 465131e..e34b6d7 100644
--- a/traffic_ops/app/lib/UI/Topology.pm
+++ b/traffic_ops/app/lib/UI/Topology.pm
@@ -124,7 +124,6 @@ sub gen_crconfig_json {
 
     # These params should have consistent values across all profiles used by servers in this CDN:
     my %requested_param_names = (
-        'domain_name'       => 1,
         'tld.soa.admin'     => 1,
         'tld.soa.expire'    => 1,
         'tld.soa.minimum'   => 1,
@@ -167,8 +166,8 @@ sub gen_crconfig_json {
         return undef, $msg;
     }
 
-    $data_obj->{'config'}->{'domain_name'} = $param_values->{'domain_name'};
-    $ccr_domain_name = $param_values->{'domain_name'};
+    $ccr_domain_name = $self->db->resultset('Cdn')->search( { id => $cdn_id } )->get_column('domain_name')->single();
+    $data_obj->{'config'}->{'domain_name'} = $ccr_domain_name;
     $cdn_soa_admin   = $param_values->{'tld.soa.admin'};
     $cdn_soa_expire  = $param_values->{'tld.soa.expire'};
     $cdn_soa_minimum = $param_values->{'tld.soa.minimum'};

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/742d475c/traffic_ops/app/t/api/1.1/deliveryservice/ssl_keys.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/api/1.1/deliveryservice/ssl_keys.t b/traffic_ops/app/t/api/1.1/deliveryservice/ssl_keys.t
index 4204955..2108cd1 100644
--- a/traffic_ops/app/t/api/1.1/deliveryservice/ssl_keys.t
+++ b/traffic_ops/app/t/api/1.1/deliveryservice/ssl_keys.t
@@ -146,7 +146,7 @@ ok $t->get_ok("/api/1.1/deliveryservices/xmlId/foo.bar/sslkeys.json")->json_has(
 	->or( sub { diag $t->tx->res->content->asset->{content}; } );
 
 #get key by hostname
-my $gen_hostname = "edge.foo.top.kabletown.com";
+my $gen_hostname = "edge.foo.top.kabletown.net";
 ok $t->get_ok("/api/1.1/deliveryservices/hostname/$gen_hostname/sslkeys.json")->json_has("/response")->json_has("/response/certificate/csr")
 	->json_has("/response/certificate/key")->json_has("/response/certificate/crt")->json_is( "/response/organization" => $org )
 	->json_is( "/response/state" => $state )->json_is( "/response/city" => $city )->json_is( "/response/businessUnit" => $unit )

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/742d475c/traffic_ops/app/t/api/1.2/deliveryservice.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/api/1.2/deliveryservice.t b/traffic_ops/app/t/api/1.2/deliveryservice.t
index 4e9e961..c5191f2 100644
--- a/traffic_ops/app/t/api/1.2/deliveryservice.t
+++ b/traffic_ops/app/t/api/1.2/deliveryservice.t
@@ -145,7 +145,7 @@ ok $t->post_ok('/api/1.2/deliveryservices/create' => {Accept => 'application/jso
         "protocol" => "1",
         "orgServerFqdn" => "http://10.75.168.91",
         "cdnName" => "cdn2",
-        "profileName" => "CCR1",
+        "profileName" => "CCR2",
         "type" => "HTTP",
         "multiSiteOrigin" => "0",
         "regionalGeoBlocking" => "1",
@@ -167,7 +167,7 @@ ok $t->post_ok('/api/1.2/deliveryservices/create' => {Accept => 'application/jso
     ->json_is( "/response/displayName" => "ds_displayname_1")
     ->json_is( "/response/orgServerFqdn" => "http://10.75.168.91")
     ->json_is( "/response/cdnName" => "cdn2")
-    ->json_is( "/response/profileName" => "CCR1")
+    ->json_is( "/response/profileName" => "CCR2")
     ->json_is( "/response/protocol" => "1")
     ->json_is( "/response/type" => "HTTP")
     ->json_is( "/response/multiSiteOrigin" => "0")
@@ -228,7 +228,7 @@ ok $t->put_ok('/api/1.2/deliveryservices/' . $ds_id . '/update' => {Accept => 'a
 		"protocol" => "1",
 		"orgServerFqdn" => "http://10.75.168.91",
 		"cdnName" => "cdn2",
-		"profileName" => "CCR1",
+		"profileName" => "CCR2",
 		"type" => "HTTP",
 		"multiSiteOrigin" => "0",
 		"regionalGeoBlocking" => "1",
@@ -251,7 +251,7 @@ ok $t->put_ok('/api/1.2/deliveryservices/' . $ds_id . '/update' => {Accept => 'a
 		->json_is( "/response/displayName" => "ds_displayname_1")
 		->json_is( "/response/orgServerFqdn" => "http://10.75.168.91")
 		->json_is( "/response/cdnName" => "cdn2")
-		->json_is( "/response/profileName" => "CCR1")
+		->json_is( "/response/profileName" => "CCR2")
 		->json_is( "/response/protocol" => "1")
 		->json_is( "/response/type" => "HTTP")
 		->json_is( "/response/multiSiteOrigin" => "0")


[16/44] incubator-trafficcontrol git commit: Use CDN for deliveryservice list

Posted by mi...@apache.org.
Use CDN for deliveryservice list


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

Branch: refs/heads/master
Commit: 5bf0ae78aee2781693c6d2fb09dba8846eea590c
Parents: a24dd9d
Author: Jan van Doorn <jv...@apache.org>
Authored: Sat Feb 11 23:07:15 2017 +0000
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:10 2017 +0000

----------------------------------------------------------------------
 traffic_ops/app/lib/UI/Topology.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/5bf0ae78/traffic_ops/app/lib/UI/Topology.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/UI/Topology.pm b/traffic_ops/app/lib/UI/Topology.pm
index e34b6d7..f76e49c 100644
--- a/traffic_ops/app/lib/UI/Topology.pm
+++ b/traffic_ops/app/lib/UI/Topology.pm
@@ -272,7 +272,7 @@ sub gen_crconfig_json {
     my $regexps;
     my $rs_ds = $self->db->resultset('Deliveryservice')->search(
         {
-            'me.profile' => { -in => \@{ $profile_cache->{'CCR'} } },
+			'me.cdn_id' => $cdn_id,
             'active'     => 1
         },
         { prefetch => [ 'deliveryservice_servers', 'deliveryservice_regexes', 'type' ] }


[31/44] incubator-trafficcontrol git commit: Move to 6.2 names for all params.

Posted by mi...@apache.org.
Move to 6.2 names for all params.


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

Branch: refs/heads/master
Commit: f0b9d96bd425c839ff3c60b32b7e2478dd6cb6c8
Parents: c1d2520
Author: Jan van Doorn <jv...@apache.org>
Authored: Sun Feb 12 23:12:49 2017 +0000
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:11 2017 +0000

----------------------------------------------------------------------
 .../20170205101432_cdn_table_domain_name.go     | 53 +++++++++++++++-----
 1 file changed, 40 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/f0b9d96b/traffic_ops/app/db/migrations/20170205101432_cdn_table_domain_name.go
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/migrations/20170205101432_cdn_table_domain_name.go b/traffic_ops/app/db/migrations/20170205101432_cdn_table_domain_name.go
index 3269f42..3b341c9 100644
--- a/traffic_ops/app/db/migrations/20170205101432_cdn_table_domain_name.go
+++ b/traffic_ops/app/db/migrations/20170205101432_cdn_table_domain_name.go
@@ -102,6 +102,10 @@ func Up_20170205101432(txn *sql.Tx) {
 
 	doExec("UPDATE deliveryservice SET profile=NULL", txn)
 
+	doExec("INSERT INTO parameter (name, config_file, value) VALUES ('mso.parent_retry', 'parent.config', 'simple_retry');", txn)
+	doExec("INSERT INTO parameter (name, config_file, value) VALUES ('mso.parent_retry', 'parent.config', 'unavailable_server_retry');", txn)
+	doExec("INSERT INTO parameter (name, config_file, value) VALUES ('mso.parent_retry', 'parent.config', 'both');", txn)
+
 	type Profile struct {
 		Id                 int64
 		Name               string
@@ -114,7 +118,7 @@ func Up_20170205101432(txn *sql.Tx) {
 	}
 	// move data
 	pmap := make(map[string]Profile)
-	rows, err := txn.Query("select id,xml_id,mid_header_rewrite,multi_site_origin,multi_site_origin_algorithm,cdn_id from deliveryservice where multi_site_origin=true")
+	rows, err := txn.Query("SELECT id,xml_id,mid_header_rewrite,multi_site_origin,multi_site_origin_algorithm,cdn_id FROM deliveryservice WHERE multi_site_origin=true")
 	if err != nil {
 		fmt.Println("Error:", err)
 		fmt.Println("Attempting Roll back!")
@@ -161,6 +165,7 @@ func Up_20170205101432(txn *sql.Tx) {
 		checkErr(err, txn)
 
 		remainingString := ""
+		parent_retry := ""
 		var regexpOne = regexp.MustCompile(`^\s*set-config\s+proxy.config.http.parent_origin.(\S+)\s+(.*)$`)
 		if prof.MidHeaderRewrite != "" {
 			remapParts := strings.Split(prof.MidHeaderRewrite, "__RETURN__")
@@ -173,19 +178,33 @@ func Up_20170205101432(txn *sql.Tx) {
 					newId, ok = existingParam[string(match[1])+string(match[2])]
 					//	fmt.Printf("%s -> %v %v\n", string(match[1])+string(match[2]), newId, ok)
 					if !ok {
-						fmt.Println("INSERT INTO PARAMETER (name, config_file, value) VALUES ($1, $2, $3) RETURNING id", "mso."+
-							string(match[1]), "parent.config", string(match[2]))
-						newRow := txn.QueryRow("INSERT INTO PARAMETER (name, config_file, value) VALUES ($1, $2, $3) RETURNING id", "mso."+
-							string(match[1]), "parent.config", string(match[2]))
-						err := newRow.Scan(&newId)
-						checkErr(err, txn)
-						existingParam[string(match[1])+string(match[2])] = newId
+						if string(match[1]) == "simple_retry_enabled" || string(match[1]) == "dead_server_retry_enabled" {
+							if parent_retry == "" {
+								parent_retry = string(match[1])
+							} else {
+								parent_retry = "both"
+							}
+						} else {
+							// unavailable_server_retry_responses is the only one that survives?
+							if string(match[1]) == "dead_server_retry_response_codes" {
+								pName := "mso.unavailable_server_retry_responses"
+								fmt.Println("INSERT INTO PARAMETER (name, config_file, value) VALUES ($1, $2, $3) RETURNING id",
+									pName, "parent.config", string(match[2]))
+								newRow := txn.QueryRow("INSERT INTO PARAMETER (name, config_file, value) VALUES ($1, $2, $3) RETURNING id",
+									pName, "parent.config", string(match[2]))
+								err := newRow.Scan(&newId)
+								checkErr(err, txn)
+								existingParam[string(match[1])+string(match[2])] = newId
+							}
+						}
 					} else {
 						newId = existingParam[string(match[1])+string(match[2])]
 					}
-					fmt.Println("INSERT INTO PROFILE_PARAMETER (parameter, profile) VALUES ($1, $2)", newId, newProfileId)
-					_, err = txn.Exec("INSERT INTO PROFILE_PARAMETER (parameter, profile) VALUES ($1, $2)", newId, newProfileId)
-					checkErr(err, txn)
+					if newId != 0 {
+						fmt.Println("INSERT INTO PROFILE_PARAMETER (parameter, profile) VALUES ($1, $2)", newId, newProfileId)
+						_, err = txn.Exec("INSERT INTO PROFILE_PARAMETER (parameter, profile) VALUES ($1, $2)", newId, newProfileId)
+						checkErr(err, txn)
+					}
 				} else {
 					if !strings.HasSuffix(line, "__RETURN__") {
 						remainingString = remainingString + line + "__RETURN__"
@@ -193,13 +212,14 @@ func Up_20170205101432(txn *sql.Tx) {
 				}
 			}
 		}
-		/* -- Not doing the remove at this time, so we can support both 5.x and 6.x - 6.x will have a warning if these are not removed from the DS, but
-		      should run just fine.
+		/* Not doing the removal of the header_rewrite stuff  at this time, so we can support both 5.x and 6.x - 6.x will have a warning if these are
+		   not removed from the DS, but should run just fine.
 
 		fmt.Printf("MHRW was: %s, \nMHRW now: %s\n", prof.MidHeaderRewrite, remainingString)
 
 		_, err = txn.Exec("UPDATE deliveryservice set mid_header_rewrite=$1 where xml_id=$2", remainingString, prof.XMLId)
 		checkErr(err, txn)
+
 		*/
 
 		var newId int64
@@ -220,6 +240,13 @@ func Up_20170205101432(txn *sql.Tx) {
 		fmt.Println("INSERT INTO PROFILE_PARAMETER (parameter, profile) VALUES ($1, $2)", newId, newProfileId)
 		_, err = txn.Exec("INSERT INTO PROFILE_PARAMETER (parameter, profile) VALUES ($1, $2)", newId, newProfileId)
 		checkErr(err, txn)
+
+		fmt.Println("INSERT INTO profile_parameter (profile, parameter) SELECT $1, id FROM parameter "+
+			"WHERE config_file='parent.config' AND name='mso.parent_retry' AND value=$2", newProfileId, parent_retry)
+		_, err = txn.Exec("INSERT INTO profile_parameter (profile, parameter) SELECT $1, id FROM parameter "+
+			"WHERE config_file='parent.config' AND name='mso.parent_retry' AND value=$2", newProfileId, parent_retry)
+		checkErr(err, txn)
+
 		_, err = txn.Exec("UPDATE deliveryservice SET profile=$1 WHERE xml_id=$2", newProfileId, prof.XMLId)
 		checkErr(err, txn)
 	}


[37/44] incubator-trafficcontrol git commit: remove comments, debugs

Posted by mi...@apache.org.
remove comments, debugs


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

Branch: refs/heads/master
Commit: 0449913ca4f3b0544ab1dab96c0d5d9dc63d752d
Parents: 02ece63
Author: Jan van Doorn <jv...@apache.org>
Authored: Sun Feb 12 17:44:37 2017 +0000
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:11 2017 +0000

----------------------------------------------------------------------
 .../20170205101432_cdn_table_domain_name.go     | 25 +-------------------
 1 file changed, 1 insertion(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/0449913c/traffic_ops/app/db/migrations/20170205101432_cdn_table_domain_name.go
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/migrations/20170205101432_cdn_table_domain_name.go b/traffic_ops/app/db/migrations/20170205101432_cdn_table_domain_name.go
index 072e225..3269f42 100644
--- a/traffic_ops/app/db/migrations/20170205101432_cdn_table_domain_name.go
+++ b/traffic_ops/app/db/migrations/20170205101432_cdn_table_domain_name.go
@@ -28,29 +28,6 @@ func doExec(stmt string, txn *sql.Tx) {
 	}
 }
 
-/*
- if ( $multi_site_origin_algorithm == 0 ) {
-1174                     $mso_algorithm = "consistent_hash";
-1175                     if ( $ds->{qstring_ignore} == 0 ) {
-1176                         $parent_qstring = "consider";
-1177                     }
-1178                 }
-1179                 elsif ( $multi_site_origin_algorithm == 1 ) {
-1180                     $mso_algorithm = "false";
-1181                 }
-1182                 elsif ( $multi_site_origin_algorithm == 2 ) {
-1183                     $mso_algorithm = "strict";
-1184                 }
-1185                 elsif ( $multi_site_origin_algorithm == 3 ) {
-1186                     $mso_algorithm = "true";
-1187                 }
-1188                 elsif ( $multi_site_origin_algorithm == 4 ) {
-1189                     $mso_algorithm = "latched";
-1190                 }
-1191                 else {
-1192                     $mso_algorithm = "consistent_hash";
-1193                 }
-*/
 // Up is executed when this migration is applied
 func Up_20170205101432(txn *sql.Tx) {
 
@@ -194,7 +171,7 @@ func Up_20170205101432(txn *sql.Tx) {
 					var newId int64
 					var ok bool
 					newId, ok = existingParam[string(match[1])+string(match[2])]
-					fmt.Printf("%s -> %v %v\n", string(match[1])+string(match[2]), newId, ok)
+					//	fmt.Printf("%s -> %v %v\n", string(match[1])+string(match[2]), newId, ok)
 					if !ok {
 						fmt.Println("INSERT INTO PARAMETER (name, config_file, value) VALUES ($1, $2, $3) RETURNING id", "mso."+
 							string(match[1]), "parent.config", string(match[2]))


[15/44] incubator-trafficcontrol git commit: Integration test fixtures

Posted by mi...@apache.org.
Integration test fixtures


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

Branch: refs/heads/master
Commit: 6832045e8e896307a186d4ffe8680810f048b716
Parents: d095923
Author: Jan van Doorn <ja...@cable.comcast.com>
Authored: Thu Dec 29 12:49:52 2016 -0700
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:10 2017 +0000

----------------------------------------------------------------------
 traffic_ops/app/lib/Fixtures/Cdn.pm              |  2 --
 traffic_ops/app/lib/Fixtures/Integration/Cdn.pm  | 11 +++++++----
 .../app/lib/Fixtures/Integration/Profile.pm      | 19 +++++++++++++++++++
 3 files changed, 26 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/6832045e/traffic_ops/app/lib/Fixtures/Cdn.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Fixtures/Cdn.pm b/traffic_ops/app/lib/Fixtures/Cdn.pm
index c62640a..de84382 100644
--- a/traffic_ops/app/lib/Fixtures/Cdn.pm
+++ b/traffic_ops/app/lib/Fixtures/Cdn.pm
@@ -19,7 +19,6 @@ use namespace::autoclean;
 use Digest::SHA1 qw(sha1_hex);
 
 my %definition_for = (
-	## id => 1
 	cdn1_cdn_name => {
 		new   => 'Cdn',
 		using => {
@@ -28,7 +27,6 @@ my %definition_for = (
 			domain_name => 'cdn1.kabletown.net',
 		},
 	},
-	## id => 2
 	cdn2_cdn_name => {
 		new   => 'Cdn',
 		using => {

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/6832045e/traffic_ops/app/lib/Fixtures/Integration/Cdn.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Fixtures/Integration/Cdn.pm b/traffic_ops/app/lib/Fixtures/Integration/Cdn.pm
index d3a7eef..b62cdf0 100644
--- a/traffic_ops/app/lib/Fixtures/Integration/Cdn.pm
+++ b/traffic_ops/app/lib/Fixtures/Integration/Cdn.pm
@@ -26,21 +26,24 @@ extends 'DBIx::Class::EasyFixture';
 use namespace::autoclean;
 
 my %definition_for = (
-	## id => 1
-	'0' => {
+	'cd1' => {
 		new => 'Cdn',
+
 		using => {
+			id => 1,
 			name => 'cdn_number_1',
 			dnssec_enabled => '0',
+			domain_name => 'cdn1.kabletown.net',
 			last_updated => '2015-12-10 15:43:45',
 		},
 	},
-	## id => 2
-	'1' => {
+	'cdn2' => {
 		new => 'Cdn',
 		using => {
+			id => 2,
 			name => 'cdn_number_2',
 			dnssec_enabled => '0',
+			domain_name => 'cdn2.kabletown.net',
 			last_updated => '2015-12-10 15:43:45',
 		},
 	},

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/6832045e/traffic_ops/app/lib/Fixtures/Integration/Profile.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Fixtures/Integration/Profile.pm b/traffic_ops/app/lib/Fixtures/Integration/Profile.pm
index 784f885..eea64cf 100644
--- a/traffic_ops/app/lib/Fixtures/Integration/Profile.pm
+++ b/traffic_ops/app/lib/Fixtures/Integration/Profile.pm
@@ -32,6 +32,7 @@ use namespace::autoclean;
 		using => {
 			name => 'CCR_CDN1',
 			description => 'Comcast Content Router for cdn1.cdn.net',
+			cdn => 1,
 			last_updated => '2015-12-10 15:43:48',
 		},
 	},
@@ -41,6 +42,7 @@ use namespace::autoclean;
 		using => {
 			name => 'CCR_CDN2',
 			description => 'Comcast Content Router for cdn2.comcast.net',
+			cdn => 2,
 			last_updated => '2015-12-10 15:43:48',
 		},
 	},
@@ -50,6 +52,7 @@ use namespace::autoclean;
 		using => {
 			name => 'EDGE1_CDN1_402',
 			description => 'Dell R720xd, Edge, CDN1 CDN, ATS v4.0.2',
+			cdn => 1,
 			last_updated => '2015-12-10 15:43:48',
 		},
 	},
@@ -59,6 +62,7 @@ use namespace::autoclean;
 		using => {
 			name => 'EDGE1_CDN1_421',
 			description => 'Dell R720xd, Edge, CDN1 CDN, ATS v4.2.1, Consistent Parent',
+			cdn => 1,
 			last_updated => '2015-12-10 15:43:48',
 		},
 	},
@@ -68,6 +72,7 @@ use namespace::autoclean;
 		using => {
 			name => 'EDGE1_CDN1_421_SSL',
 			description => 'Dell r720xd, Edge, CDN1 CDN, ATS v4.2.1, SSL enabled',
+			cdn => 1,
 			last_updated => '2015-12-10 15:43:48',
 		},
 	},
@@ -77,6 +82,7 @@ use namespace::autoclean;
 		using => {
 			name => 'EDGE1_CDN2_402',
 			last_updated => '2015-12-10 15:43:48',
+			cdn => 2,
 			description => 'Dell R720xd, Edge, CDN2 CDN, ATS v4.0.2',
 		},
 	},
@@ -86,6 +92,7 @@ use namespace::autoclean;
 		using => {
 			name => 'EDGE1_CDN2_421',
 			description => 'Dell R720xd, Edge, CDN2 CDN, ATS v4.2.1, Consistent Parent',
+			cdn => 2,
 			last_updated => '2015-12-10 15:43:48',
 		},
 	},
@@ -95,6 +102,7 @@ use namespace::autoclean;
 		using => {
 			name => 'EDGE2_CDN1',
 			description => 'HP DL380 Edge',
+			cdn => 1,
 			last_updated => '2015-12-10 15:43:48',
 		},
 	},
@@ -104,6 +112,7 @@ use namespace::autoclean;
 		using => {
 			name => 'EDGE2_CDN1_402',
 			description => 'HP DL380, Edge, CDN1 CDN, ATS v4.0.x',
+			cdn => 1,
 			last_updated => '2015-12-10 15:43:48',
 		},
 	},
@@ -113,6 +122,7 @@ use namespace::autoclean;
 		using => {
 			name => 'EDGE2_CDN2_402',
 			description => 'HP DL380, Edge, CDN2 CDN, ATS v4.0.x',
+			cdn => 2,
 			last_updated => '2015-12-10 15:43:48',
 		},
 	},
@@ -122,6 +132,7 @@ use namespace::autoclean;
 		using => {
 			name => 'EDGE2_CDN2_421',
 			description => 'HP DL380, Edge, CDN2 CDN, ATS v4.2.1, Consistent Parent',
+			cdn => 2,
 			last_updated => '2015-12-10 15:43:48',
 		},
 	},
@@ -140,6 +151,7 @@ use namespace::autoclean;
 		using => {
 			name => 'MID1_CDN1_421',
 			description => 'Dell R720xd, Mid, CDN1 CDN, ATS v4.2.1',
+			cdn => 1,
 			last_updated => '2015-12-10 15:43:48',
 		},
 	},
@@ -149,6 +161,7 @@ use namespace::autoclean;
 		using => {
 			name => 'MID1_CDN2_402',
 			description => 'Dell R720xd, Mid, CDN2 CDN, new vol config, ATS v4.0.x',
+			cdn => 2,
 			last_updated => '2015-12-10 15:43:48',
 		},
 	},
@@ -158,6 +171,7 @@ use namespace::autoclean;
 		using => {
 			name => 'MID1_CDN2_421',
 			description => 'Dell R720xd, Mid, CDN2 CDN, ATS v4.2.1',
+			cdn => 2,
 			last_updated => '2015-12-10 15:43:48',
 		},
 	},
@@ -167,6 +181,7 @@ use namespace::autoclean;
 		using => {
 			name => 'MID2_CDN1',
 			description => 'HP DL380 Mid',
+			cdn => 1,
 			last_updated => '2015-12-10 15:43:48',
 		},
 	},
@@ -176,6 +191,7 @@ use namespace::autoclean;
 		using => {
 			name => 'ORG1_CDN1',
 			last_updated => '2015-12-10 15:43:48',
+			cdn => 1,
 			description => 'Multi site origin profile 1',
 		},
 	},
@@ -185,6 +201,7 @@ use namespace::autoclean;
 		using => {
 			name => 'ORG2_CDN1',
 			description => 'Multi site origin profile 2',
+			cdn => 1,
 			last_updated => '2015-12-10 15:43:48',
 		},
 	},
@@ -194,6 +211,7 @@ use namespace::autoclean;
 		using => {
 			name => 'RASCAL_CDN1',
 			description => 'TrafficMonitor for CDN1',
+			cdn => 1,
 			last_updated => '2015-12-10 15:43:48',
 		},
 	},
@@ -202,6 +220,7 @@ use namespace::autoclean;
 		new => 'Profile',
 		using => {
 			name => 'RASCAL_CDN2',
+			cdn => 2,
 			last_updated => '2015-12-10 15:43:48',
 			description => 'TrafficMonitor for CDN2 ',
 		},


[41/44] incubator-trafficcontrol git commit: fixes test

Posted by mi...@apache.org.
fixes test


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

Branch: refs/heads/master
Commit: 7a6e727bede5595fb09f322ebfc6de4b36ca06b9
Parents: 3b1df01
Author: Jeremy Mitchell <mi...@gmail.com>
Authored: Thu Mar 9 11:51:27 2017 -0700
Committer: Jeremy Mitchell <mi...@gmail.com>
Committed: Thu Mar 9 11:51:27 2017 -0700

----------------------------------------------------------------------
 traffic_ops/app/t/api/1.1/cachegroupparameter.t | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/7a6e727b/traffic_ops/app/t/api/1.1/cachegroupparameter.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/api/1.1/cachegroupparameter.t b/traffic_ops/app/t/api/1.1/cachegroupparameter.t
index ef65b66..504f15b 100644
--- a/traffic_ops/app/t/api/1.1/cachegroupparameter.t
+++ b/traffic_ops/app/t/api/1.1/cachegroupparameter.t
@@ -46,7 +46,7 @@ $t->get_ok("/api/1.1/cachegroupparameters.json")->status_is(200)->or( sub { diag
   ->json_is( '/response/cachegroupParameters/0/cachegroup', 'mid-northeast-group' )->json_is( '/response/cachegroupParameters/0/parameter', "60" )
   ->json_is( '/response/cachegroupParameters/1/cachegroup', 'mid-northeast-group' )->json_is( '/response/cachegroupParameters/0/parameter', "60" )
   ->json_is( '/response/cachegroupParameters/1/cachegroup', 'mid-northeast-group' )->json_is( '/response/cachegroupParameters/1/parameter', "61" )
-  ->json_is( '/response/cachegroupParameters/2/cachegroup', 'mid-northwest-group' )->json_is( '/response/cachegroupParameters/2/parameter', "61" );
+  ->json_is( '/response/cachegroupParameters/2/cachegroup', 'mid-northwest-group' )->json_is( '/response/cachegroupParameters/2/parameter', "60" );
 
 ok $t->get_ok('/logout')->status_is(302)->or( sub { diag $t->tx->res->content->asset->{content}; } );
 $dbh->disconnect();


[39/44] incubator-trafficcontrol git commit: removes commented out code and print statements and adds more api validation and fixes some tests a annd adds some docs

Posted by mi...@apache.org.
removes commented out code and print statements and adds more api validation and fixes some tests a annd adds some docs


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

Branch: refs/heads/master
Commit: 3b1df01eb776e8dca82ef8cb6b1e9a3f12dc250f
Parents: e695229
Author: Jeremy Mitchell <mi...@gmail.com>
Authored: Wed Mar 8 16:06:09 2017 -0700
Committer: Jeremy Mitchell <mi...@gmail.com>
Committed: Thu Mar 9 08:04:20 2017 -0700

----------------------------------------------------------------------
 .../development/traffic_ops_api/v12/cdn.rst     |  54 +++++--
 .../traffic_ops_api/v12/deliveryservice.rst     |   6 -
 .../development/traffic_ops_api/v12/profile.rst | 151 +++++++++++--------
 traffic_ops/app/lib/API/Cdn.pm                  |  32 ++--
 traffic_ops/app/lib/API/Deliveryservice.pm      |   6 +-
 traffic_ops/app/lib/API/Profile.pm              |  31 ++--
 .../lib/Fixtures/Integration/Deliveryservice.pm |   8 -
 traffic_ops/app/lib/Fixtures/Parameter.pm       |   9 --
 traffic_ops/app/lib/UI/Cdn.pm                   |   4 -
 traffic_ops/app/t/api/1.1/cachegroupparameter.t |   2 +-
 10 files changed, 175 insertions(+), 128 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3b1df01e/docs/source/development/traffic_ops_api/v12/cdn.rst
----------------------------------------------------------------------
diff --git a/docs/source/development/traffic_ops_api/v12/cdn.rst b/docs/source/development/traffic_ops_api/v12/cdn.rst
index da10799..650b0a9 100644
--- a/docs/source/development/traffic_ops_api/v12/cdn.rst
+++ b/docs/source/development/traffic_ops_api/v12/cdn.rst
@@ -38,6 +38,8 @@ CDN
   +-------------------+--------+-------------------------------------------------+
   | ``name``          | string | CDN name.                                       |
   +-------------------+--------+-------------------------------------------------+
+  | ``domainName``    | string | TLD of the CDN.                                 |
+  +-------------------+--------+-------------------------------------------------+
   | ``dnssecEnabled`` |  bool  | DNSSEC enabled.                                 |
   +-------------------+--------+-------------------------------------------------+
   | ``lastUpdated``   | string |                                                 |
@@ -49,13 +51,15 @@ CDN
      "response": [
            {
               "id": "1"
-              "name": "over-the-top",
+              "name": "cdn1",
+              "domainName": "cdn1.foo.com",
               "dnssecEnabled": false,
               "lastUpdated": "2014-10-02 08:22:43"
            },
            {
               "id": "2"
               "name": "cdn2",
+              "domainName": "cdn2.foo.com",
               "dnssecEnabled": true,
               "lastUpdated": "2014-10-02 08:22:43"
            }
@@ -87,6 +91,8 @@ CDN
   +-------------------+--------+-------------------------------------------------+
   | ``name``          | string | CDN name.                                       |
   +-------------------+--------+-------------------------------------------------+
+  | ``domainName``    | string | TLD of the CDN.                                 |
+  +-------------------+--------+-------------------------------------------------+
   | ``dnssecEnabled`` |  bool  | DNSSEC enabled.                                 |
   +-------------------+--------+-------------------------------------------------+
   | ``lastUpdated``   | string |                                                 |
@@ -99,6 +105,7 @@ CDN
            {
               "id": "2"
               "name": "cdn2",
+              "domainName": "cdn2.foo.com",
               "dnssecEnabled": false,
               "lastUpdated": "2014-10-02 08:22:43"
            }
@@ -130,6 +137,8 @@ CDN
   +-------------------+--------+-------------------------------------------------+
   | ``name``          | string | CDN name.                                       |
   +-------------------+--------+-------------------------------------------------+
+  | ``domainName``    | string | TLD of the CDN.                                 |
+  +-------------------+--------+-------------------------------------------------+
   | ``dnssecEnabled`` |  bool  | DNSSEC enabled.                                 |
   +-------------------+--------+-------------------------------------------------+
   | ``lastUpdated``   | string |                                                 |
@@ -142,6 +151,7 @@ CDN
            {
               "id": "2"
               "name": "cdn2",
+              "domainName": "cdn2.foo.com",
               "dnssecEnabled": false,
               "lastUpdated": "2014-10-02 08:22:43"
            }
@@ -165,16 +175,19 @@ CDN
   +===================+========+=================================================+
   | ``name``          | string | CDN name.                                       |
   +-------------------+--------+-------------------------------------------------+
-  | ``dnssecEnabled`` |  int   | Whether dnssec is enabled.                      |
-  |                   |        | - 0: disabled                                   |
-  |                   |        | - 1: enabled                                    |
+  | ``domainName``    | string | TLD of the CDN.                                 |
+  +-------------------+--------+-------------------------------------------------+
+  | ``dnssecEnabled`` |  bool  | Whether dnssec is enabled.                      |
+  |                   |        | - false: disabled                               |
+  |                   |        | - true: enabled                                 |
   +-------------------+--------+-------------------------------------------------+
 
   **Request Example** ::
 
     {
         "name": "cdn_test",
-        "dnssecEnabled": 0
+        "domainName": "cdn3.foo.com",
+        "dnssecEnabled": true
     }
 
   **Response Properties**
@@ -184,12 +197,14 @@ CDN
   +====================+========+=================================================+
   | ``response``       |  hash  | The details of the creation, if success.        |
   +--------------------+--------+-------------------------------------------------+
-  | ``>name``          | string | CDN name.                                       |
-  +--------------------+--------+-------------------------------------------------+
   | ``>id``            |  int   | CDN id.                                         |
   +--------------------+--------+-------------------------------------------------+
+  | ``>name``          | string | CDN name.                                       |
+  +--------------------+--------+-------------------------------------------------+
   | ``>dnssecEnabled`` | string | Whether dnssec is enabled.                      |
   +--------------------+--------+-------------------------------------------------+
+  | ``>domainName``    | string | TLD of the CDN.                                 |
+  +--------------------+--------+-------------------------------------------------+
   | ``alerts``         | array  | A collection of alert messages.                 |
   +--------------------+--------+-------------------------------------------------+
   | ``>level``         | string | Success, info, warning or error.                |
@@ -202,9 +217,10 @@ CDN
 
     {
         "response":{
-            "name": "cdn_test",
             "id": 3
-            "dnssecEnabled": 0
+            "name": "cdn_test",
+            "domainName": "cdn3.foo.com",
+            "dnssecEnabled": true
         },
         "alerts":[
             {
@@ -239,9 +255,11 @@ CDN
   +===================+========+=================================================+
   | ``name``          | string | CDN name.                                       |
   +-------------------+--------+-------------------------------------------------+
-  | ``dnssecEnabled`` | int    | Whether dnssec is enabled.                      |
-  |                   |        | - 0: disabled                                   |
-  |                   |        | - 1: enabled                                    |
+  | ``domainName``    | string | TLD of the CDN.                                 |
+  +-------------------+--------+-------------------------------------------------+
+  | ``dnssecEnabled`` |  bool  | Whether dnssec is enabled.                      |
+  |                   |        | - false: disabled                               |
+  |                   |        | - true: enabled                                 |
   +-------------------+--------+-------------------------------------------------+
 
 
@@ -249,7 +267,8 @@ CDN
 
     {
         "name": "cdn_test2",
-        "dnssecEnabled": 0
+        "domainName": "cdn3.foo.com",
+        "dnssecEnabled": false
     }
 
   **Response Properties**
@@ -263,7 +282,9 @@ CDN
   +--------------------+--------+-------------------------------------------------+
   | ``>id``            |  int   | CDN id.                                         |
   +--------------------+--------+-------------------------------------------------+
-  | ``>dnssecEnabled`` | string | Whether dnssec is enabled.                      |
+  | ``>domainName``    | string | TLD of the CDN.                                 |
+  +--------------------+--------+-------------------------------------------------+
+  | ``>dnssecEnabled`` |  bool  | Whether dnssec is enabled.                      |
   +--------------------+--------+-------------------------------------------------+
   | ``alerts``         | array  | A collection of alert messages.                 |
   +--------------------+--------+-------------------------------------------------+
@@ -276,9 +297,10 @@ CDN
 
     {
         "response":{
+            "id": 3,
             "name": "cdn_test2",
-            "id": 3
-            "dnssecEnabled": 0
+            "domainName": "cdn3.foo.com",
+            "dnssecEnabled": false
         },
         "alerts":[
             {

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3b1df01e/docs/source/development/traffic_ops_api/v12/deliveryservice.rst
----------------------------------------------------------------------
diff --git a/docs/source/development/traffic_ops_api/v12/deliveryservice.rst b/docs/source/development/traffic_ops_api/v12/deliveryservice.rst
index 9e81b92..6ceb1d7 100644
--- a/docs/source/development/traffic_ops_api/v12/deliveryservice.rst
+++ b/docs/source/development/traffic_ops_api/v12/deliveryservice.rst
@@ -132,8 +132,6 @@ Delivery Service
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``multiSiteOrigin``      |  bool  | Is the Multi Site Origin feature enabled for this delivery service (0=false, 1=true). See :ref:`rl-multi-site-origin`                |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
-  | ``multiSiteOriginAlgor`` |  bool  | Is the Multi Site Origin feature enabled for this delivery service (0=false, 1=true). See :ref:`rl-multi-site-origin`                |
-  +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``orgServerFqdn``        | string | The origin server base URL (FQDN when used in this instance, includes the                                                            |
   |                          |        | protocol (http:// or https://) for use in retrieving content from the origin server.                                                 |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
@@ -227,7 +225,6 @@ Delivery Service
             "missLat": "41.881944",
             "missLong": "-87.627778",
             "multiSiteOrigin": false,
-            "multiSiteOriginAlgorithm": null,
             "orgServerFqdn": "http://baz.boo.net",
             "originShield": null,
             "profileDescription": "Content Router for over-the-top",
@@ -364,8 +361,6 @@ Delivery Service
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``multiSiteOrigin``      |  bool  | Is the Multi Site Origin feature enabled for this delivery service (0=false, 1=true). See :ref:`rl-multi-site-origin`                |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
-  | ``multiSiteOriginAlgor`` |  bool  | Is the Multi Site Origin feature enabled for this delivery service (0=false, 1=true). See :ref:`rl-multi-site-origin`                |
-  +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``orgServerFqdn``        | string | The origin server base URL (FQDN when used in this instance, includes the                                                            |
   |                          |        | protocol (http:// or https://) for use in retrieving content from the origin server.                                                 |
   +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
@@ -462,7 +457,6 @@ Delivery Service
             "missLat": "41.881944",
             "missLong": "-87.627778",
             "multiSiteOrigin": false,
-            "multiSiteOriginAlgorithm": null,
             "orgServerFqdn": "http://baz.boo.net",
             "originShield": null,
             "profileDescription": "Content Router for over-the-top",

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3b1df01e/docs/source/development/traffic_ops_api/v12/profile.rst
----------------------------------------------------------------------
diff --git a/docs/source/development/traffic_ops_api/v12/profile.rst b/docs/source/development/traffic_ops_api/v12/profile.rst
index bec8f9f..546222b 100644
--- a/docs/source/development/traffic_ops_api/v12/profile.rst
+++ b/docs/source/development/traffic_ops_api/v12/profile.rst
@@ -35,7 +35,7 @@ Profiles
 	+---------------+----------+----------------------------------------------------+
 	|    Name       | Required |                    Description                     |
 	+===============+==========+====================================================+
-	| ``param``     |   no     | Used to filter profiles by parameter.              |
+	| ``param``     |   no     | Used to filter profiles by parameter ID.           |
 	+---------------+----------+----------------------------------------------------+
 
 	**Response Properties**
@@ -43,24 +43,33 @@ Profiles
 	+-----------------+--------+----------------------------------------------------+
 	|    Parameter    |  Type  |                    Description                     |
 	+=================+========+====================================================+
-	| ``lastUpdated`` | array  | The Time / Date this server entry was last updated |
+	| ``id``          | string | Primary key                                        |
 	+-----------------+--------+----------------------------------------------------+
 	| ``name``        | string | The name for the profile                           |
 	+-----------------+--------+----------------------------------------------------+
-	| ``id``          | string | Primary key                                        |
-	+-----------------+--------+----------------------------------------------------+
 	| ``description`` | string | The description for the profile                    |
 	+-----------------+--------+----------------------------------------------------+
+	| ``cdn``         |  int   | The CDN ID                                         |
+	+-----------------+--------+----------------------------------------------------+
+	| ``cdnName``     | string | The CDN name                                       |
+	+-----------------+--------+----------------------------------------------------+
+	| ``type``        | string | Profile type                                       |
+	+-----------------+--------+----------------------------------------------------+
+	| ``lastUpdated`` | array  | The Time / Date this server entry was last updated |
+	+-----------------+--------+----------------------------------------------------+
 
   **Response Example** ::
 
     {
      "response": [
         {
-            "lastUpdated": "2012-10-08 19:34:45",
-            "name": "CCR_TOP",
             "id": "8",
-            "description": "Content Router for top.foobar.net"
+            "name": "EDGE_27_PROFILE",
+            "description": "A profile with all the Foo parameters"
+            "cdn": 1
+            "cdnName": "cdn1"
+            "type": "ATS_PROFILE"
+            "lastUpdated": "2012-10-08 19:34:45",
         }
      ]
     }
@@ -86,7 +95,7 @@ Profiles
     {
      "response": [
         {
-            "name": "CCR_TOP"
+            "name": "EDGE_27_PROFILE"
         }
      ]
     }
@@ -112,24 +121,33 @@ Profiles
 	+-----------------+--------+----------------------------------------------------+
 	|    Parameter    |  Type  |                    Description                     |
 	+=================+========+====================================================+
-	| ``lastUpdated`` | array  | The Time / Date this server entry was last updated |
+	| ``id``          | string | Primary key                                        |
 	+-----------------+--------+----------------------------------------------------+
 	| ``name``        | string | The name for the profile                           |
 	+-----------------+--------+----------------------------------------------------+
-	| ``id``          | string | Primary key                                        |
-	+-----------------+--------+----------------------------------------------------+
 	| ``description`` | string | The description for the profile                    |
 	+-----------------+--------+----------------------------------------------------+
+	| ``cdn``         |  int   | The CDN ID                                         |
+	+-----------------+--------+----------------------------------------------------+
+	| ``cdnName``     | string | The CDN name                                       |
+	+-----------------+--------+----------------------------------------------------+
+	| ``type``        | string | Profile type                                       |
+	+-----------------+--------+----------------------------------------------------+
+	| ``lastUpdated`` | array  | The Time / Date this server entry was last updated |
+	+-----------------+--------+----------------------------------------------------+
 
   **Response Example** ::
 
     {
      "response": [
         {
-            "lastUpdated": "2012-10-08 19:34:45",
-            "name": "CCR_TOP",
             "id": "8",
-            "description": "Content Router for top.foobar.net"
+            "name": "EDGE_27_PROFILE",
+            "description": "A profile with all the Foo parameters"
+            "cdn": 1
+            "cdnName": "cdn1"
+            "type": "ATS_PROFILE"
+            "lastUpdated": "2012-10-08 19:34:45",
         }
      ]
     }
@@ -138,7 +156,7 @@ Profiles
 
 
 **POST /api/1.2/profiles**
-    Create a new empty  profile. 
+    Create a new empty profile.
 
 	Authentication Required: Yes
 
@@ -146,19 +164,26 @@ Profiles
 
 	**Request Properties**
 
-	+-----------------------+--------+----------------------------------------------------+
-	|    Parameter          |  Type  |                    Description                     |
-	+=======================+========+====================================================+
-	| ``name``              | string | The name of the new profile                        |
-	+-----------------------+--------+----------------------------------------------------+
-	| ``description``       | string | new profile description                            |
-	+-----------------------+--------+----------------------------------------------------+
+	+-----------------------+--------+----------+-----------------------------------------+
+	|  Parameter            |  Type  | Required |           Description                   |
+	+=======================+========+==========+=========================================+
+	| ``name``              | string | yes      | Profile name                            |
+	+-----------------------+--------+----------+-----------------------------------------+
+	| ``description``       | string | yes      | Profile description                     |
+	+-----------------------+--------+----------+-----------------------------------------+
+	| ``cdn``               |  int   | no       | CDN ID                                  |
+	+-----------------------+--------+----------+-----------------------------------------+
+	| ``type``              | string | yes      | Profile type                            |
+	+-----------------------+--------+----------+-----------------------------------------+
+
 
   **Request Example** ::
 
     {
-      "name": "CCR_COPY",
-      "description": "CCR_COPY description",
+      "name": "EDGE_28_PROFILE",
+      "description": "EDGE_28_PROFILE description",
+      "cdn": 1,
+      "type": "ATS_PROFILE"
     }
 
 |
@@ -168,11 +193,15 @@ Profiles
 	+-----------------------+--------+----------------------------------------------------+
 	|    Parameter          |  Type  |                    Description                     |
 	+=======================+========+====================================================+
-	| ``id``                | string | Id of the new profile                              |
+	| ``id``                | string | Profile ID                                         |
 	+-----------------------+--------+----------------------------------------------------+
-	| ``name``              | string | The name of the new profile                        |
+	| ``name``              | string | Profile name                                       |
+	+-----------------------+--------+----------------------------------------------------+
+	| ``description``       | string | Profile description                                |
+	+-----------------------+--------+----------------------------------------------------+
+	| ``cdn``               |  int   | CDN ID                                             |
 	+-----------------------+--------+----------------------------------------------------+
-	| ``description``       | string | new profile description                            |
+	| ``type``              | string | Profile type                                       |
 	+-----------------------+--------+----------------------------------------------------+
 
   **Response Example** ::
@@ -181,8 +210,10 @@ Profiles
      "response": [
         {
             "id": "66",
-            "name": "CCR_COPY",
-            "description": "CCR_COPY description",
+            "name": "EDGE_28_PROFILE",
+            "description": "EDGE_28_PROFILE description",
+		  	"cdn": 1,
+      		"type": "ATS_PROFILE"
         }
      ]
     }
@@ -257,50 +288,52 @@ Profiles
 
 	**Request Properties**
 
-	+-----------------+----------+---------------------------------------------------+
-	| Parameter       | Required | Description                                       |
-	+=================+==========+===================================================+
-	| ``name``        | yes      | The new name for the profile.                     |
-	+-----------------+----------+---------------------------------------------------+
-	| ``description`` | yes      | The new description for the profile.              |
-	+-----------------+----------+---------------------------------------------------+
+	+-----------------------+--------+----------+-----------------------------------------+
+	|  Parameter            |  Type  | Required |           Description                   |
+	+=======================+========+==========+=========================================+
+	| ``name``              | string | yes      | Profile name                            |
+	+-----------------------+--------+----------+-----------------------------------------+
+	| ``description``       | string | yes      | Profile description                     |
+	+-----------------------+--------+----------+-----------------------------------------+
+	| ``cdn``               |  int   | no       | CDN ID                                  |
+	+-----------------------+--------+----------+-----------------------------------------+
+	| ``type``              | string | yes      | Profile type                            |
+	+-----------------------+--------+----------+-----------------------------------------+
 
   **Request Example** ::
 
     {
-      "name": "CCR_UPDATE",
-      "description": "CCR_UPDATE description"
+      "name": "EDGE_28_PROFILE",
+      "description": "EDGE_28_PROFILE description",
+      "cdn": 1,
+      "type": "ATS_PROFILE"
     }
 
  	**Response Properties**
 
-	+------------------+--------+----------------------------------+
-	|  Parameter       |  Type  |           Description            |
-	+==================+========+==================================+
-	| ``response``     |        | The updated profile info.        |
-	+------------------+--------+----------------------------------+
-	| ``>id``          | string | Profile id.                      |
-	+------------------+--------+----------------------------------+
-	| ``>name``        | string | Profile name.                    |
-	+------------------+--------+----------------------------------+
-	| ``>description`` | string | Profile description.             |
-	+------------------+--------+----------------------------------+
-	| ``alerts``       | array  | A collection of alert messages.  |
-	+------------------+--------+----------------------------------+
-	| ``>level``       | string | success, info, warning or error. |
-	+------------------+--------+----------------------------------+
-	| ``>text``        | string | Alert message.                   |
-	+------------------+--------+----------------------------------+
-	| ``version``      | string |                                  |
-	+------------------+--------+----------------------------------+
+	+-----------------------+--------+----------------------------------------------------+
+	|    Parameter          |  Type  |                    Description                     |
+	+=======================+========+====================================================+
+	| ``id``                | string | Profile ID                                         |
+	+-----------------------+--------+----------------------------------------------------+
+	| ``name``              | string | Profile name                                       |
+	+-----------------------+--------+----------------------------------------------------+
+	| ``description``       | string | Profile description                                |
+	+-----------------------+--------+----------------------------------------------------+
+	| ``cdn``               |  int   | CDN ID                                             |
+	+-----------------------+--------+----------------------------------------------------+
+	| ``type``              | string | Profile type                                       |
+	+-----------------------+--------+----------------------------------------------------+
 
   **Response Example** ::
 
     {
       "response":{
         "id": "219",
-        "name": "CCR_UPDATE",
-        "description": "CCR_UPDATE description"
+        "name": "EDGE_28_PROFILE",
+        "description": "EDGE_28_PROFILE description"
+        "cdn": 1
+        "type": "ATS_PROFILE"
       }
       "alerts":[
         {

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3b1df01e/traffic_ops/app/lib/API/Cdn.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/Cdn.pm b/traffic_ops/app/lib/API/Cdn.pm
index af7c0f5..dca96cc 100644
--- a/traffic_ops/app/lib/API/Cdn.pm
+++ b/traffic_ops/app/lib/API/Cdn.pm
@@ -37,10 +37,10 @@ sub index {
 		push(
 			@data, {
 				"id"            => $row->id,
+				"name"          => $row->name,
+				"domainName"    => $row->domain_name,
 				"dnssecEnabled" => \$row->dnssec_enabled,
 				"lastUpdated" 	=> $row->last_updated,
-				"name"          => $row->name,
-				"domainName"    => $row->domain_name
 			}
 		);
 	}
@@ -57,10 +57,10 @@ sub show {
 		push(
 			@data, {
 				"id"            => $row->id,
+				"name"          => $row->name,
+				"domainName"    => $row->domain_name,
 				"dnssecEnabled" => \$row->dnssec_enabled,
 				"lastUpdated" 	=> $row->last_updated,
-				"name"          => $row->name,
-				"domainName"    => $row->domain_name
 			}
 		);
 	}
@@ -77,10 +77,10 @@ sub name {
 		push(
 			@data, {
 				"id"            => $row->id,
+				"name"          => $row->name,
+				"domainName"    => $row->domain_name,
 				"dnssecEnabled" => \$row->dnssec_enabled,
 				"lastUpdated"   => $row->last_updated,
-				"name"          => $row->name,
-				"domainName"    => $row->domain_name
 			}
 		);
 	}
@@ -159,10 +159,6 @@ sub update {
 		return $self->not_found();
 	}
 
-	if ( !defined($params) ) {
-		return $self->alert("parameters must be in JSON format.");
-	}
-
 	if ( !defined( $params->{name} ) ) {
 		return $self->alert("Name is required.");
 	}
@@ -171,22 +167,32 @@ sub update {
 		return $self->alert("dnssecEnabled is required.");
 	}
 
+	if ( !defined( $params->{domainName} ) ) {
+		return $self->alert("Domain Name is required.");
+	}
+
 	my $existing = $self->db->resultset('Cdn')->search( { name => $params->{name} } )->single();
 	if ( $existing && $existing->id != $cdn->id ) {
-		$self->app->log->error( "a cdn with name '" . $params->{name} . "' already exists." );
 		return $self->alert( "a cdn with name " . $params->{name} . " already exists." );
 	}
 
+	$existing = $self->db->resultset('Cdn')->search( { domain_name => $params->{domainName} } )->single();
+	if ( $existing && $existing->id != $cdn->id ) {
+		return $self->alert( "a cdn with domain name " . $params->{domainName} . " already exists." );
+	}
+
 	my $values = {
 		name => $params->{name},
 		dnssec_enabled => $params->{dnssecEnabled},
+		domain_name => $params->{domainName},
 	};
 
 	my $rs = $cdn->update($values);
 	if ( $rs ) {
 		my $response;
-		$response->{id}            = $rs->id;
-		$response->{name}          = $rs->name;
+		$response->{id}            	= $rs->id;
+		$response->{name}          	= $rs->name;
+		$response->{domainName}		= $rs->domain_name;
 		$response->{dnssecEnabled} = \$rs->dnssec_enabled;
 		&log( $self, "Updated CDN name '" . $rs->name . "' for id: " . $rs->id, "APICHANGE" );
 		return $self->success( $response, "CDN update was successful." );

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3b1df01e/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 fd91af2..88935fc 100644
--- a/traffic_ops/app/lib/API/Deliveryservice.pm
+++ b/traffic_ops/app/lib/API/Deliveryservice.pm
@@ -191,9 +191,9 @@ sub show {
 				"multiSiteOrigin"          => \$row->multi_site_origin,
 				"orgServerFqdn"            => $row->org_server_fqdn,
 				"originShield"             => $row->origin_shield,
-				"profileId"                => $row->profile->id,
-				"profileName"              => $row->profile->name,
-				"profileDescription"       => $row->profile->description,
+				"profileId"                => defined($row->profile) ? $row->profile->id : undef,
+				"profileName"              => defined($row->profile) ? $row->profile->name : undef,
+				"profileDescription"       => defined($row->profile) ? $row->profile->description : undef,
 				"protocol"                 => $row->protocol,
 				"qstringIgnore"            => $row->qstring_ignore,
 				"rangeRequestHandling"     => $row->range_request_handling,

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3b1df01e/traffic_ops/app/lib/API/Profile.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/Profile.pm b/traffic_ops/app/lib/API/Profile.pm
index 065cd59..8a0793e 100644
--- a/traffic_ops/app/lib/API/Profile.pm
+++ b/traffic_ops/app/lib/API/Profile.pm
@@ -30,16 +30,17 @@ sub index {
 	my $parameter_id = $self->param('param');
 
 	if ( defined $parameter_id ) {
-		my $rs = $self->db->resultset('ProfileParameter')->search( { parameter => $parameter_id },  { prefetch => [ 'profile' ], order_by => $orderby }  );
+		my $rs = $self->db->resultset('ProfileParameter')->search( { parameter => $parameter_id },  { prefetch => [ 'profile' ] }  );
 		while ( my $row = $rs->next ) {
 			push(
 				@data, {
-					"id" => $row->profile->id,
-					"name" => $row->profile->name,
-					"description" => $row->profile->description,
-					"cdn" => $row->profile->cdn,
-					"type" => $row->profile->type,
-					"lastUpdated" => $row->profile->last_updated
+					"id" 			=> $row->profile->id,
+					"name" 			=> $row->profile->name,
+					"description" 	=> $row->profile->description,
+					"cdn" 			=> defined($row->profile->cdn) ? $row->profile->cdn->id : undef,
+					"cdnName" 		=> defined($row->profile->cdn) ? $row->profile->cdn->name : undef,
+					"type" 			=> $row->profile->type,
+					"lastUpdated" 	=> $row->profile->last_updated
 				}
 			);
 		}
@@ -51,7 +52,8 @@ sub index {
 					"id"          => $row->id,
 					"name"        => $row->name,
 					"description" => $row->description,
-					"cdn"         => defined($row->cdn) ? $row->cdn->name : "-",
+					"cdn"         => defined($row->cdn) ? $row->cdn->id : undef,
+					"cdnName"     => defined($row->cdn) ? $row->cdn->name : undef,
 					"type"        => $row->type,
 					"lastUpdated" => $row->last_updated
 				}
@@ -107,7 +109,7 @@ sub show {
 	my $self = shift;
 	my $id   = $self->param('id');
 
-	my $rs_data = $self->db->resultset("Profile")->search( { id => $id } );
+	my $rs_data = $self->db->resultset("Profile")->search( { 'me.id' => $id }, { prefetch => [ 'cdn' ] } );
 	my @data = ();
 	while ( my $row = $rs_data->next ) {
 		push(
@@ -115,6 +117,9 @@ sub show {
 				"id"          => $row->id,
 				"name"        => $row->name,
 				"description" => $row->description,
+				"cdn"         => defined($row->cdn) ? $row->cdn->id : undef,
+				"cdnName"     => defined($row->cdn) ? $row->cdn->name : undef,
+				"type"        => $row->type,
 				"lastUpdated" => $row->last_updated
 			}
 		);
@@ -143,6 +148,10 @@ sub create {
 		return $self->alert("profile 'description' is required.");
 	}
 
+	if ( !defined( $params->{type} ) ) {
+		return $self->alert("Profile type is required.");
+	}
+
 	my $existing_profile = $self->db->resultset('Profile')->search( { name => $name } )->get_column('name')->single();
 	if ( $existing_profile && $name eq $existing_profile ) {
 		return $self->alert("profile with name $name already exists.");
@@ -285,6 +294,10 @@ sub update {
 		}
 	}
 
+	if ( !defined( $params->{type} ) ) {
+		return $self->alert("Profile type is required.");
+	}
+
 	my $cdn = $params->{cdn};
 	my $type = $params->{type};
 	my $values = {

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3b1df01e/traffic_ops/app/lib/Fixtures/Integration/Deliveryservice.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Fixtures/Integration/Deliveryservice.pm b/traffic_ops/app/lib/Fixtures/Integration/Deliveryservice.pm
index 146a5da..80f475d 100644
--- a/traffic_ops/app/lib/Fixtures/Integration/Deliveryservice.pm
+++ b/traffic_ops/app/lib/Fixtures/Integration/Deliveryservice.pm
@@ -72,7 +72,6 @@ my %definition_for = (
 			dns_bypass_ip               => '',
 			edge_header_rewrite         => 'add-header X-Powered-By: KBLTN [L]',
 			multi_site_origin           => undef,
-			# multi_site_origin_algorithm => undef,
 			tr_request_headers          => undef,
 		},
 	},
@@ -83,7 +82,6 @@ my %definition_for = (
 			xml_id                      => 'games-c1',
 			regional_geo_blocking       => 0,
 			multi_site_origin           => undef,
-			# multi_site_origin_algorithm => undef,
 			protocol                    => '0',
 			dns_bypass_ttl              => undef,
 			edge_header_rewrite         => 'cond %{SEND_RESPONSE_HDR_HOOK} __RETURN__ add-header X-CDN-Info "KableTown___CACHE_IPV4__" [L]',
@@ -138,7 +136,6 @@ my %definition_for = (
 			type                        => '10',
 			dns_bypass_cname            => undef,
 			multi_site_origin           => undef,
-			# multi_site_origin_algorithm => undef,
 			qstring_ignore              => '0',
 			ccr_dns_ttl                 => '3600',
 			dscp                        => '40',
@@ -208,7 +205,6 @@ my %definition_for = (
 			long_desc_1                 => 'test-ds1 long_desc_1',
 			max_dns_answers             => '0',
 			multi_site_origin           => '1',
-			# multi_site_origin_algorithm => '0',
 			active                      => '1',
 			edge_header_rewrite         => 'cond %{REMAP_PSEUDO_HOOK} __RETURN__ set-config proxy.config.http.transaction_active_timeout_out 5 [L]',
 			global_max_mbps             => '0',
@@ -252,7 +248,6 @@ my %definition_for = (
 			ipv6_routing_enabled        => undef,
 			mid_header_rewrite          => undef,
 			multi_site_origin           => undef,
-			# multi_site_origin_algorithm => undef,
 			qstring_ignore              => '0',
 			active                      => '1',
 			cacheurl                    => undef,
@@ -305,7 +300,6 @@ my %definition_for = (
 			miss_long                   => '-87.627778',
 			org_server_fqdn             => 'https://games.origin.kabletown.net',
 			multi_site_origin           => undef,
-			# multi_site_origin_algorithm => undef,
 			cacheurl                    => undef,
 			dns_bypass_ip               => '',
 			dns_bypass_ip6              => undef,
@@ -352,7 +346,6 @@ my %definition_for = (
 			global_max_tps              => '0',
 			initial_dispersion          => '1',
 			multi_site_origin           => undef,
-			# multi_site_origin_algorithm => undef,
 			org_server_fqdn             => 'http://national-tv.origin.kabletown.net',
 			signed                      => '0',
 			display_name                => 'tv-nat-c2',
@@ -392,7 +385,6 @@ my %definition_for = (
 			long_desc                   => 'test- long_desc',
 			long_desc_2                 => 'test- long_desc_2',
 			multi_site_origin           => undef,
-			# multi_site_origin_algorithm => undef,
 			origin_shield               => undef,
 			protocol                    => '0',
 			ipv6_routing_enabled        => undef,

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3b1df01e/traffic_ops/app/lib/Fixtures/Parameter.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Fixtures/Parameter.pm b/traffic_ops/app/lib/Fixtures/Parameter.pm
index d8e4d69..1d645e9 100644
--- a/traffic_ops/app/lib/Fixtures/Parameter.pm
+++ b/traffic_ops/app/lib/Fixtures/Parameter.pm
@@ -19,15 +19,6 @@ use namespace::autoclean;
 use Digest::SHA1 qw(sha1_hex);
 
 my %definition_for = (
-	# domain_name => {
-	# 	new   => 'Parameter',
-	# 	using => {
-	# 		id          => 3,
-	# 		name        => 'domain_name',
-	# 		value       => 'foo.com',
-	# 		config_file => 'CRConfig.json',
-	# 	},
-	# },
 	health_threadhold_loadavg => {
 		new   => 'Parameter',
 		using => {

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3b1df01e/traffic_ops/app/lib/UI/Cdn.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/UI/Cdn.pm b/traffic_ops/app/lib/UI/Cdn.pm
index 3f2f160..5a80899 100644
--- a/traffic_ops/app/lib/UI/Cdn.pm
+++ b/traffic_ops/app/lib/UI/Cdn.pm
@@ -114,10 +114,6 @@ sub create {
     my $data = $self->get_cdns();
     my $cdns = $data->{'cdn'};
 
-    foreach my $f ($self->param) {
-      print $f . " => " . Dumper($self->param($f)) . "\n";
-    }
-
     if ( !$self->isValidCdn() ) {
         $self->stash(
             fbox_layout => 1,

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3b1df01e/traffic_ops/app/t/api/1.1/cachegroupparameter.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/api/1.1/cachegroupparameter.t b/traffic_ops/app/t/api/1.1/cachegroupparameter.t
index 504f15b..ef65b66 100644
--- a/traffic_ops/app/t/api/1.1/cachegroupparameter.t
+++ b/traffic_ops/app/t/api/1.1/cachegroupparameter.t
@@ -46,7 +46,7 @@ $t->get_ok("/api/1.1/cachegroupparameters.json")->status_is(200)->or( sub { diag
   ->json_is( '/response/cachegroupParameters/0/cachegroup', 'mid-northeast-group' )->json_is( '/response/cachegroupParameters/0/parameter', "60" )
   ->json_is( '/response/cachegroupParameters/1/cachegroup', 'mid-northeast-group' )->json_is( '/response/cachegroupParameters/0/parameter', "60" )
   ->json_is( '/response/cachegroupParameters/1/cachegroup', 'mid-northeast-group' )->json_is( '/response/cachegroupParameters/1/parameter', "61" )
-  ->json_is( '/response/cachegroupParameters/2/cachegroup', 'mid-northwest-group' )->json_is( '/response/cachegroupParameters/2/parameter', "60" );
+  ->json_is( '/response/cachegroupParameters/2/cachegroup', 'mid-northwest-group' )->json_is( '/response/cachegroupParameters/2/parameter', "61" );
 
 ok $t->get_ok('/logout')->status_is(302)->or( sub { diag $t->tx->res->content->asset->{content}; } );
 $dbh->disconnect();



[21/44] incubator-trafficcontrol git commit: Move migration to .go file, and do all the work there

Posted by mi...@apache.org.
Move migration to .go file, and do all the work there


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

Branch: refs/heads/master
Commit: 51101574f3bc1e3fe8a0d0922d866a97859c89b4
Parents: 4a1af46
Author: Jan van Doorn <ja...@cable.comcast.com>
Authored: Tue Feb 7 12:56:36 2017 -0700
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:10 2017 +0000

----------------------------------------------------------------------
 .../20161226000000_cdn_domain_name.sql          |  87 --------
 .../20170205101432_cdn_table_domain_name.go     | 205 +++++++++++++++++++
 2 files changed, 205 insertions(+), 87 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/51101574/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql b/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql
deleted file mode 100644
index 45da0a8..0000000
--- a/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
-
-    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.
-*/
-
--- +goose Up
--- SQL in section 'Up' is executed when this migration is applied
-
-CREATE TYPE profile_type AS ENUM ('ATS_PROFILE', 'TR_PROFILE', 'TM_PROFILE', 'TS_PROFILE', 'TP_PROFILE', 'INFLUXDB_PROFILE', 
-  'RIAK_PROFILE', 'SPLUNK_PROFILE', 'DS_PROFILE', 'ORG_PROFILE', 'KAFKA_PROFILE', 'LOGSTASH_PROFILE', 'ES_PROFILE', 'UNK_PROFILE');
-
-CREATE OR REPLACE VIEW "profile_type_values" AS SELECT unnest(enum_range(NULL::profile_type )) AS value ORDER BY value;
-  
-ALTER TABLE public.profile ADD COLUMN type profile_type;
-UPDATE public.profile SET type='UNK_PROFILE'; -- So we don't get any NULL, these should be checked.
-UPDATE public.profile SET type='TR_PROFILE' WHERE name like 'CCR_%' OR name like 'TR_%';
-UPDATE public.profile SET type='TM_PROFILE' WHERE name like 'RASCAL_%' OR name like 'TM_%';
-UPDATE public.profile SET type='TS_PROFILE' WHERE name like 'TRAFFIC_STATS%';
-UPDATE public.profile SET type='TP_PROFILE' WHERE name like 'TRAFFIC_PORTAL%';
-UPDATE public.profile SET type='INFLUXDB_PROFILE' WHERE name like 'INFLUXDB%';
-UPDATE public.profile SET type='RIAK_PROFILE' WHERE name like 'RIAK%';
-UPDATE public.profile SET type='SPLUNK_PROFILE' WHERE name like 'SPLUNK%';
-UPDATE public.profile SET type='ORG_PROFILE' WHERE name like '%ORG%' or name like 'MSO%' or name like '%ORIGIN%';
-UPDATE public.profile SET type='KAFKA_PROFILE' WHERE name like 'KAFKA%';
-UPDATE public.profile SET type='LOGSTASH_PROFILE' WHERE name like 'LOGSTASH_%';
-UPDATE public.profile SET type='ES_PROFILE' WHERE name like 'ELASTICSEARCH%';
-UPDATE public.profile SET type='ATS_PROFILE' WHERE name like 'EDGE%' or name like 'MID%';
-
-ALTER TABLE public.profile ALTER type SET NOT NULL;
-
-ALTER TABLE public.cdn ADD COLUMN domain_name text;
-UPDATE cdn SET domain_name=domainlist.value
-  FROM (SELECT distinct cdn_id,value FROM server,parameter WHERE type=(SELECT id FROM type WHERE name='EDGE') 
-    AND parameter.id in (select parameter from profile_parameter WHERE profile_parameter.profile=server.profile) 
-    AND parameter.name='domain_name' 
-    AND config_file='CRConfig.json') AS domainlist
-WHERE id = domainlist.cdn_id;
-UPDATE public.cdn SET domain_name='-' WHERE name='ALL';
-ALTER TABLE public.cdn ALTER COLUMN domain_name SET NOT NULL;
-
-ALTER TABLE public.profile ADD COLUMN cdn bigint;
-
-ALTER TABLE public.profile
-  ADD CONSTRAINT fk_cdn1 FOREIGN KEY (cdn)
-      REFERENCES public.cdn (id) MATCH SIMPLE
-      ON UPDATE RESTRICT ON DELETE RESTRICT;
-CREATE INDEX idx_181818_fk_cdn1
-  ON public.profile
-  USING btree
-  (cdn);
-
-UPDATE profile set cdn=domainlist.cdn_id
-  FROM (SELECT distinct profile.id AS profile_id, value AS profile_domain_name, cdn.id cdn_id 
-    FROM profile, parameter, cdn, profile_parameter
-    WHERE parameter.name='domain_name'
-    AND parameter.config_file='CRConfig.json'
-    AND parameter.value = cdn.domain_name
-    AND parameter.id in (select parameter from profile_parameter where profile=profile.id)) as domainlist
-WHERE id = domainlist.profile_id;
-
-ALTER TABLE deliveryservice ALTER profile DROP NOT NULL;
-
-ALTER TABLE deliveryservice DROP COLUMN multi_site_origin_algorithm;
-
-
--- +goose Down
--- SQL section 'Down' is executed when this migration is rolled back
-
-ALTER TABLE public.cdn DROP COLUMN domain_name;
-
-ALTER TABLE public.profile DROP COLUMN cdn;
-
-ALTER TABLE deliveryservice ALTER profile SET NOT NULL;
-
-ALTER TABLE public.profile DROP COLUMN type;
-
-DROP type profile_type;

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/51101574/traffic_ops/app/db/migrations/20170205101432_cdn_table_domain_name.go
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/migrations/20170205101432_cdn_table_domain_name.go b/traffic_ops/app/db/migrations/20170205101432_cdn_table_domain_name.go
new file mode 100644
index 0000000..af24643
--- /dev/null
+++ b/traffic_ops/app/db/migrations/20170205101432_cdn_table_domain_name.go
@@ -0,0 +1,205 @@
+package main
+
+import (
+	"database/sql"
+	"fmt"
+	"os"
+	"regexp"
+	"strings"
+)
+
+func checkErr(err error, txn *sql.Tx) {
+	if err != nil {
+		fmt.Println("Error 33:", err)
+		fmt.Println("Attempting Roll back!")
+		txn.Rollback()
+		os.Exit(1)
+	}
+}
+
+func doExec(stmt string, txn *sql.Tx) {
+	fmt.Println("  " + stmt)
+	_, err := txn.Exec(stmt)
+	if err != nil {
+		fmt.Println("Error:", err)
+		fmt.Println("Attempting Roll back!")
+		txn.Rollback()
+		os.Exit(1)
+	}
+}
+
+// Up is executed when this migration is applied
+func Up_20170205101432(txn *sql.Tx) {
+	fmt.Println("  Starting migration 20130106222315...")
+	doExec("CREATE TYPE profile_type AS ENUM ("+
+		"'ATS_PROFILE', 'TR_PROFILE', 'TM_PROFILE', 'TS_PROFILE', 'TP_PROFILE', 'INFLUXDB_PROFILE',"+
+		"'RIAK_PROFILE', 'SPLUNK_PROFILE', 'DS_PROFILE', 'ORG_PROFILE', 'KAFKA_PROFILE', 'LOGSTASH_PROFILE',"+
+		"'ES_PROFILE', 'UNK_PROFILE')", txn)
+
+	doExec("CREATE OR REPLACE VIEW \"profile_type_values\" AS SELECT unnest(enum_range(NULL::profile_type )) AS value ORDER BY value", txn)
+
+	doExec("ALTER TABLE public.profile ADD COLUMN type profile_type", txn)
+	doExec("UPDATE public.profile SET type='UNK_PROFILE'", txn) // So we don't get any NULL, these should be checked.
+	doExec("UPDATE public.profile SET type='TR_PROFILE' WHERE name like 'CCR_%' OR name like 'TR_%'", txn)
+	doExec("UPDATE public.profile SET type='TM_PROFILE' WHERE name like 'RASCAL_%' OR name like 'TM_%'", txn)
+	doExec("UPDATE public.profile SET type='TS_PROFILE' WHERE name like 'TRAFFIC_STATS%'", txn)
+	doExec("UPDATE public.profile SET type='TP_PROFILE' WHERE name like 'TRAFFIC_PORTAL%'", txn)
+	doExec("UPDATE public.profile SET type='INFLUXDB_PROFILE' WHERE name like 'INFLUXDB%'", txn)
+	doExec("UPDATE public.profile SET type='RIAK_PROFILE' WHERE name like 'RIAK%'", txn)
+	doExec("UPDATE public.profile SET type='SPLUNK_PROFILE' WHERE name like 'SPLUNK%'", txn)
+	doExec("UPDATE public.profile SET type='ORG_PROFILE' WHERE name like '%ORG%' or name like 'MSO%' or name like '%ORIGIN%'", txn)
+	doExec("UPDATE public.profile SET type='KAFKA_PROFILE' WHERE name like 'KAFKA%'", txn)
+	doExec("UPDATE public.profile SET type='LOGSTASH_PROFILE' WHERE name like 'LOGSTASH_%'", txn)
+	doExec("UPDATE public.profile SET type='ES_PROFILE' WHERE name like 'ELASTICSEARCH%'", txn)
+	doExec("UPDATE public.profile SET type='ATS_PROFILE' WHERE name like 'EDGE%' or name like 'MID%'", txn)
+
+	doExec("ALTER TABLE public.profile ALTER type SET NOT NULL", txn)
+
+	doExec("ALTER TABLE public.cdn ADD COLUMN domain_name text", txn)
+
+	doExec("UPDATE cdn SET domain_name=domainlist.value "+
+		"FROM (SELECT distinct cdn_id,value FROM server,parameter WHERE type=(SELECT id FROM type WHERE name='EDGE') "+
+		"AND parameter.id in (select parameter from profile_parameter WHERE profile_parameter.profile=server.profile) "+
+		"AND parameter.name='domain_name' "+
+		"AND config_file='CRConfig.json') AS domainlist "+
+		"WHERE id = domainlist.cdn_id", txn)
+
+	doExec("UPDATE public.cdn SET domain_name='-' WHERE name='ALL'", txn)
+
+	doExec("ALTER TABLE public.cdn ALTER COLUMN domain_name SET NOT NULL", txn)
+
+	doExec("ALTER TABLE public.profile ADD COLUMN cdn bigint", txn)
+
+	doExec("ALTER TABLE public.profile "+
+		"ADD CONSTRAINT fk_cdn1 FOREIGN KEY (cdn) "+
+		"REFERENCES public.cdn (id) MATCH SIMPLE "+
+		"ON UPDATE RESTRICT ON DELETE RESTRICT", txn)
+
+	doExec("CREATE INDEX idx_181818_fk_cdn1 "+
+		"ON public.profile "+
+		"USING btree "+
+		"(cdn)", txn)
+
+	doExec("UPDATE profile set cdn=domainlist.cdn_id "+
+		"FROM (SELECT distinct profile.id AS profile_id, value AS profile_domain_name, cdn.id cdn_id "+
+		"FROM profile, parameter, cdn, profile_parameter "+
+		"WHERE parameter.name='domain_name' "+
+		"AND parameter.config_file='CRConfig.json' "+
+		"AND parameter.value = cdn.domain_name "+
+		"AND parameter.id in (select parameter from profile_parameter where profile=profile.id)) as domainlist "+
+		"WHERE id = domainlist.profile_id", txn)
+
+	doExec("ALTER TABLE deliveryservice ALTER profile DROP NOT NULL", txn)
+
+	doExec("UPDATE deliveryservice SET profile=NULL", txn)
+
+	type Profile struct {
+		Id                 int64
+		Name               string
+		Desc               string
+		Type               string
+		Cdn                int64
+		MidHeaderRewrite   string
+		MultiSiteOriginAlg int64
+		XMLId              string
+	}
+	// move data
+	pmap := make(map[string]Profile)
+	rows, err := txn.Query("select id,xml_id,mid_header_rewrite,multi_site_origin,multi_site_origin_algorithm,cdn_id from deliveryservice where multi_site_origin=true")
+	if err != nil {
+		fmt.Println("Error:", err)
+		fmt.Println("Attempting Roll back!")
+		txn.Rollback()
+		os.Exit(1)
+	}
+	existingParam := make(map[string]int64)
+	for rows.Next() {
+		var (
+			id                          int64
+			xml_id                      string
+			mid_header_rewrite          sql.NullString
+			multi_site_origin           sql.NullBool
+			multi_site_origin_algorithm sql.NullInt64
+			cdn_id                      int64
+		)
+		err := rows.Scan(&id, &xml_id, &mid_header_rewrite, &multi_site_origin, &multi_site_origin_algorithm, &cdn_id)
+		checkErr(err, txn)
+
+		pName := "DS_" + xml_id
+		pDesc := "Deliveryservice profile for " + xml_id
+		pType := "DS_PROFILE"
+		mhrString := mid_header_rewrite.String
+		pmap[pName] = Profile{Id: -1, Name: pName, Desc: pDesc, Type: pType, Cdn: cdn_id, MidHeaderRewrite: mhrString, MultiSiteOriginAlg: multi_site_origin_algorithm.Int64, XMLId: xml_id}
+	}
+	err = rows.Err()
+	checkErr(err, txn)
+	rows.Close()
+
+	for _, prof := range pmap {
+		fmt.Println("--\nINSERT INTO PROFILE (name, description, type, cdn) VALUES($1, $2, $3, $4) RETURNING id", prof.Name, prof.Desc, prof.Type, prof.Cdn)
+		newRow := txn.QueryRow("INSERT INTO PROFILE (name, description, type, cdn) VALUES($1, $2, $3, $4) RETURNING id", prof.Name, prof.Desc, prof.Type, prof.Cdn)
+		var newProfileId int64
+		err := newRow.Scan(&newProfileId)
+		checkErr(err, txn)
+
+		remainingString := ""
+		var regexpOne = regexp.MustCompile(`^\s*set-config\s+proxy.config.http.parent_origin.(\S+)\s+(.*)$`)
+		if prof.MidHeaderRewrite != "" {
+			remapParts := strings.Split(prof.MidHeaderRewrite, "__RETURN__")
+			for _, line := range remapParts {
+				fmt.Println(line)
+				match := regexpOne.FindSubmatch([]byte(line))
+				if len(match) != 0 {
+					var newId int64
+					var ok bool
+					newId, ok = existingParam[string(match[1])+string(match[2])]
+					fmt.Printf("%s -> %v %v\n", string(match[1])+string(match[2]), newId, ok)
+					if !ok {
+						fmt.Println("INSERT INTO PARAMETER (name, config_file, value) VALUES ($1, $2, $3) RETURNING id", "mso."+string(match[1]), "parent.config", string(match[2]))
+						newRow := txn.QueryRow("INSERT INTO PARAMETER (name, config_file, value) VALUES ($1, $2, $3) RETURNING id", "mso."+string(match[1]), "parent.config", string(match[2]))
+						err := newRow.Scan(&newId)
+						checkErr(err, txn)
+						existingParam[string(match[1])+string(match[2])] = newId
+					} else {
+						newId = existingParam[string(match[1])+string(match[2])]
+					}
+					fmt.Println("INSERT INTO PROFILE_PARAMETER (parameter, profile) VALUES ($1, $2)", newId, newProfileId)
+					_, err = txn.Exec("INSERT INTO PROFILE_PARAMETER (parameter, profile) VALUES ($1, $2)", newId, newProfileId)
+					checkErr(err, txn)
+				} else {
+					if !strings.HasSuffix(line, "__RETURN__") {
+						remainingString = remainingString + line + "__RETURN__"
+					}
+				}
+			}
+		}
+		fmt.Printf("MHRW was: %s, \nMHRW now: %s\n", prof.MidHeaderRewrite, remainingString)
+
+		_, err = txn.Exec("UPDATE deliveryservice set mid_header_rewrite=$1 where xml_id=$2", remainingString, prof.XMLId)
+		checkErr(err, txn)
+
+		var newId int64
+		var ok bool
+		newId, ok = existingParam["mso.algorithm"+"parent.config"+string(prof.MultiSiteOriginAlg)]
+		if !ok {
+			fmt.Println("INSERT INTO PARAMETER (name, config_file, value) VALUES ($1, $2, $3) RETURNING id", "mso.algorithm", "parent.config", prof.MultiSiteOriginAlg)
+			newRow = txn.QueryRow("INSERT INTO PARAMETER (name, config_file, value) VALUES ($1, $2, $3) RETURNING id", "mso.algorithm", "parent.config", prof.MultiSiteOriginAlg)
+			err = newRow.Scan(&newId)
+			checkErr(err, txn)
+			existingParam["mso.algorithm"+"parent.config"+string(prof.MultiSiteOriginAlg)] = newId
+		} else {
+			newId = existingParam["mso.algorithm"+"parent.config"+string(prof.MultiSiteOriginAlg)]
+		}
+
+		fmt.Println("INSERT INTO PROFILE_PARAMETER (parameter, profile) VALUES ($1, $2)", newId, newProfileId)
+		_, err = txn.Exec("INSERT INTO PROFILE_PARAMETER (parameter, profile) VALUES ($1, $2)", newId, newProfileId)
+		checkErr(err, txn)
+		_, err = txn.Exec("UPDATE deliveryservice SET profile=$1 WHERE xml_id=$2", newProfileId, prof.XMLId)
+		checkErr(err, txn)
+	}
+}
+
+// Down is executed when this migration is rolled back
+func Down_20170205101432(txn *sql.Tx) {
+	//
+}


[06/44] incubator-trafficcontrol git commit: Migration script - use with caution

Posted by mi...@apache.org.
Migration script - use with caution


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

Branch: refs/heads/master
Commit: 065a31101e6be7fe1a6c2bda009ccb69441a30ac
Parents: 62d883f
Author: Jan van Doorn <ja...@cable.comcast.com>
Authored: Fri Dec 23 17:11:48 2016 -0700
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:10 2017 +0000

----------------------------------------------------------------------
 traffic_ops/app/db/ats_6_mso_migrate.pl | 79 ++++++++++++++++++++++++++++
 1 file changed, 79 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/065a3110/traffic_ops/app/db/ats_6_mso_migrate.pl
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/ats_6_mso_migrate.pl b/traffic_ops/app/db/ats_6_mso_migrate.pl
new file mode 100755
index 0000000..0604f03
--- /dev/null
+++ b/traffic_ops/app/db/ats_6_mso_migrate.pl
@@ -0,0 +1,79 @@
+#!/usr/bin/perl
+#
+#
+# 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.
+#
+
+# Script to create profiles / parameters from the header_rewrite settings to move to ATS 6.2
+# support.
+#
+# Please be careful using this script, it was created for a very specific usecase, and only
+# tested our env - JvD
+
+use strict;
+use warnings;
+use DBI;
+
+my $driver   = "Pg";
+my $database = $ARGV[0];
+my $userid   = $ARGV[1];
+my $password = $ARGV[2];
+
+my $dsn = "DBI:$driver:dbname=$database;host=127.0.0.1;port=5432";
+my $dbh = DBI->connect( $dsn, $userid, $password, { RaiseError => 1 } )
+	or die $DBI::errstr;
+
+print "Opened database successfully\n";
+
+my $sql = 'select id,xml_id,mid_header_rewrite from deliveryservice where multi_site_origin=true;';
+
+my $sth = $dbh->prepare_cached($sql);
+$sth->execute || die "Couldn't execute statement: " . $sth->errstr;
+while ( my @data = $sth->fetchrow_array() ) {
+	if ( !defined( $data[2] ) ) {
+		next;
+	}
+	my @lines = split( /__RETURN__/, $data[2] );
+	my %profile_ids;
+	foreach my $line (@lines) {
+		if ( !defined( $profile_ids{ $data[1] } ) ) {
+			my $insp = $dbh->prepare('INSERT INTO PROFILE ("name", "description") VALUES(?, ?);');
+			$insp->bind_param( 1, "MIDMSO_" . $data[1] );
+			$insp->bind_param( 2, "Profile for " . $data[1] . " MSO settings" );
+			$insp->execute();
+			my $profile_id = $dbh->last_insert_id( undef, undef, "profile", undef );
+			$profile_ids{ $data[1] } = $profile_id;
+		}
+		if ( $line =~ /set-config proxy.config.http.parent_origin/ ) {
+			my $setting = $line;
+			$setting =~ s/set-config //;
+			print $data[1] . " ->" . $setting . "\n";
+			$setting =~ s/^ *//;
+			my ( $name, $value ) = split( /\s+/, $setting );
+			print $name . " -> " . $value . "\n";
+			my $insh = $dbh->prepare('INSERT INTO PARAMETER ("name", "config_file", "value") VALUES (?, ?, ?);');
+			$insh->bind_param( 1, $name );
+			$insh->bind_param( 2, 'parent.config' );
+			$insh->bind_param( 3, $value );
+			$insh->execute();
+			my $param_id = $dbh->last_insert_id( undef, undef, "parameter", undef );
+			print "Last inserted: " . $param_id;
+			my $inspp = $dbh->prepare('INSERT INTO PROFILE_PARAMETER ("parameter", "profile") VALUES (?, ?);');
+			$inspp->bind_param( 1, $param_id );
+			$inspp->bind_param( 2, $profile_ids{ $data[1] } );
+			$inspp->execute();
+		}
+	}
+}
+
+$dbh->disconnect();


[43/44] incubator-trafficcontrol git commit: Merge branch 'cdn-3' of https://github.com/knutsel/incubator-trafficcontrol

Posted by mi...@apache.org.
Merge branch 'cdn-3' of https://github.com/knutsel/incubator-trafficcontrol


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

Branch: refs/heads/master
Commit: b345b30835dc29b2f54b4803492b73ef207d1419
Parents: f90fa69 e3d2027
Author: Jeremy Mitchell <mi...@gmail.com>
Authored: Thu Mar 9 12:06:27 2017 -0700
Committer: Jeremy Mitchell <mi...@gmail.com>
Committed: Thu Mar 9 12:06:27 2017 -0700

----------------------------------------------------------------------
 docs/source/admin/quick_howto/index.rst         |   1 +
 .../admin/quick_howto/multi_site_ats5.rst       |  95 +++++++
 docs/source/admin/traffic_ops_config.rst        |   6 +-
 docs/source/admin/traffic_ops_using.rst         |  68 +++--
 .../development/traffic_ops_api/v12/cdn.rst     |  54 ++--
 .../traffic_ops_api/v12/deliveryservice.rst     |   6 -
 .../development/traffic_ops_api/v12/profile.rst | 151 ++++++----
 docs/source/overview/traffic_router.rst         |   1 +
 docs/source/overview/traffic_server.rst         |   2 +-
 .../20170205101432_cdn_table_domain_name.go     | 272 +++++++++++++++++++
 traffic_ops/app/lib/API/Cdn.pm                  |  70 +++--
 .../app/lib/API/DeliveryService/SslKeys.pm      |  11 +-
 .../app/lib/API/DeliveryServiceServer.pm        |  20 +-
 traffic_ops/app/lib/API/Deliveryservice.pm      |  21 +-
 traffic_ops/app/lib/API/Deliveryservice2.pm     |  21 +-
 traffic_ops/app/lib/API/Profile.pm              |  47 +++-
 traffic_ops/app/lib/API/ServerCheck.pm          |   2 +-
 traffic_ops/app/lib/Fixtures/Cdn.pm             |   4 +-
 traffic_ops/app/lib/Fixtures/Integration/Cdn.pm |  11 +-
 .../lib/Fixtures/Integration/Deliveryservice.pm |   8 -
 .../app/lib/Fixtures/Integration/Parameter.pm   |  12 +-
 .../app/lib/Fixtures/Integration/Profile.pm     |  41 +++
 .../Fixtures/Integration/ProfileParameter.pm    |  51 ++++
 traffic_ops/app/lib/Fixtures/Parameter.pm       |   9 -
 traffic_ops/app/lib/Fixtures/Profile.pm         |  23 ++
 .../app/lib/Fixtures/ProfileParameter.pm        |  42 ---
 .../app/lib/MojoPlugins/DeliveryService.pm      |  21 +-
 traffic_ops/app/lib/MojoPlugins/Enum.pm         |  42 +++
 traffic_ops/app/lib/MojoPlugins/Stash.pm        |  91 +++++++
 traffic_ops/app/lib/Schema/Result/Cdn.pm        |  30 +-
 .../Result/DeliveryServiceInfoForDomainList.pm  |  14 +-
 .../Result/DeliveryServiceInfoForServerList.pm  |  13 +-
 .../app/lib/Schema/Result/Deliveryservice.pm    |  30 +-
 traffic_ops/app/lib/Schema/Result/Profile.pm    |  66 ++++-
 .../app/lib/Schema/Result/ProfileTypeValue.pm   |  69 +++++
 traffic_ops/app/lib/Test/TestHelper.pm          |   2 +-
 traffic_ops/app/lib/UI/Cdn.pm                   |  21 +-
 traffic_ops/app/lib/UI/ConfigFiles.pm           | 192 +++++++------
 traffic_ops/app/lib/UI/DataAll.pm               |  19 +-
 traffic_ops/app/lib/UI/DeliveryService.pm       |  42 +--
 traffic_ops/app/lib/UI/DeliveryServiceServer.pm |   3 +-
 traffic_ops/app/lib/UI/DnssecKeys.pm            |  15 +-
 traffic_ops/app/lib/UI/Profile.pm               |  26 +-
 traffic_ops/app/lib/UI/Server.pm                |   6 +
 traffic_ops/app/lib/UI/Topology.pm              |   7 +-
 .../app/t/api/1.1/deliveryservice/ssl_keys.t    |   2 +-
 traffic_ops/app/t/api/1.1/profile.t             |  10 +-
 traffic_ops/app/t/api/1.2/cdn.t                 |   2 +-
 traffic_ops/app/t/api/1.2/deliveryservice.t     |   8 +-
 traffic_ops/app/t/api/1.2/profile.t             |   6 +-
 traffic_ops/app/t/deliveryservice.t             |   4 +-
 traffic_ops/app/t/profile.t                     |   8 +-
 traffic_ops/app/templates/cdn/_form.html.ep     |  21 +-
 traffic_ops/app/templates/cdn/index.html.ep     |   1 +
 .../templates/delivery_service/_form.html.ep    |  27 +-
 .../app/templates/delivery_service/edit.html.ep |  23 --
 traffic_ops/app/templates/profile/_form.html.ep |  17 +-
 traffic_ops/app/templates/profile/index.html.ep |   2 +
 traffic_ops/app/templates/profile/view.html.ep  |   8 +
 59 files changed, 1357 insertions(+), 540 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/b345b308/docs/source/admin/traffic_ops_using.rst
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/b345b308/traffic_ops/app/lib/API/Cdn.pm
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/b345b308/traffic_ops/app/lib/UI/Cdn.pm
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/b345b308/traffic_ops/app/lib/UI/DeliveryService.pm
----------------------------------------------------------------------


[20/44] incubator-trafficcontrol git commit: Schema changes for mso_profile on deliveryservice table

Posted by mi...@apache.org.
Schema changes for mso_profile on deliveryservice table


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

Branch: refs/heads/master
Commit: 62d883f427b97c143cc13a5f695ee8c33948e8ba
Parents: 6d9cd74
Author: Jan van Doorn <ja...@cable.comcast.com>
Authored: Fri Dec 23 15:33:22 2016 -0700
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:10 2017 +0000

----------------------------------------------------------------------
 .../20161222000000_add_mso_profile.sql          | 29 ++++++++++++++
 .../app/lib/Schema/Result/Deliveryservice.pm    | 40 +++++++++++++++++---
 traffic_ops/app/lib/Schema/Result/Profile.pm    | 23 +++++++++--
 3 files changed, 82 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/62d883f4/traffic_ops/app/db/migrations/20161222000000_add_mso_profile.sql
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/migrations/20161222000000_add_mso_profile.sql b/traffic_ops/app/db/migrations/20161222000000_add_mso_profile.sql
new file mode 100644
index 0000000..69b8592
--- /dev/null
+++ b/traffic_ops/app/db/migrations/20161222000000_add_mso_profile.sql
@@ -0,0 +1,29 @@
+/*
+
+    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.
+*/
+
+-- +goose Up
+-- SQL in section 'Up' is executed when this migration is applied
+ALTER TABLE public.deliveryservice ADD COLUMN mso_profile bigint;
+ALTER TABLE public.deliveryservice
+  ADD CONSTRAINT fk_deliveryservice_profile2 FOREIGN KEY (mso_profile)
+      REFERENCES public.profile (id) MATCH SIMPLE
+      ON UPDATE NO ACTION ON DELETE NO ACTION;
+CREATE INDEX idx_18221_fk_deliveryservice_mso_profile1
+  ON public.deliveryservice
+  USING btree
+  (mso_profile);
+-- +goose Down
+-- SQL section 'Down' is executed when this migration is rolled back
+ALTER TABLE public.deliveryservice DROP COLUMN mso_profile;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/62d883f4/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm b/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm
index afb1877..93bc2a3 100644
--- a/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm
+++ b/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm
@@ -288,6 +288,12 @@ __PACKAGE__->table("deliveryservice");
   data_type: 'text'
   is_nullable: 1
 
+=head2 mso_profile
+
+  data_type: 'bigint'
+  is_foreign_key: 1
+  is_nullable: 1
+
 =cut
 
 __PACKAGE__->add_columns(
@@ -399,6 +405,8 @@ __PACKAGE__->add_columns(
   { data_type => "smallint", is_nullable => 1 },
   "geolimit_redirect_url",
   { data_type => "text", is_nullable => 1 },
+  "mso_profile",
+  { data_type => "bigint", is_foreign_key => 1, is_nullable => 1 },
 );
 
 =head1 PRIMARY KEY
@@ -417,7 +425,7 @@ __PACKAGE__->set_primary_key("id", "type");
 
 =head1 UNIQUE CONSTRAINTS
 
-=head2 C<idx_54278_ds_id_unique>
+=head2 C<idx_18221_ds_id_unique>
 
 =over 4
 
@@ -427,9 +435,9 @@ __PACKAGE__->set_primary_key("id", "type");
 
 =cut
 
-__PACKAGE__->add_unique_constraint("idx_54278_ds_id_unique", ["id"]);
+__PACKAGE__->add_unique_constraint("idx_18221_ds_id_unique", ["id"]);
 
-=head2 C<idx_54278_ds_name_unique>
+=head2 C<idx_18221_ds_name_unique>
 
 =over 4
 
@@ -439,7 +447,7 @@ __PACKAGE__->add_unique_constraint("idx_54278_ds_id_unique", ["id"]);
 
 =cut
 
-__PACKAGE__->add_unique_constraint("idx_54278_ds_name_unique", ["xml_id"]);
+__PACKAGE__->add_unique_constraint("idx_18221_ds_name_unique", ["xml_id"]);
 
 =head1 RELATIONS
 
@@ -533,6 +541,26 @@ __PACKAGE__->has_many(
   { cascade_copy => 0, cascade_delete => 0 },
 );
 
+=head2 mso_profile
+
+Type: belongs_to
+
+Related object: L<Schema::Result::Profile>
+
+=cut
+
+__PACKAGE__->belongs_to(
+  "mso_profile",
+  "Schema::Result::Profile",
+  { id => "mso_profile" },
+  {
+    is_deferrable => 0,
+    join_type     => "LEFT",
+    on_delete     => "NO ACTION",
+    on_update     => "NO ACTION",
+  },
+);
+
 =head2 profile
 
 Type: belongs_to
@@ -609,8 +637,8 @@ __PACKAGE__->belongs_to(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.07046 @ 2016-11-18 22:45:19
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:OGL35PLFXtZ8BuzgP7IHzQ
+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2016-12-23 15:30:11
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:aULX21NuOuu6Ow8dfmQ9Ig
 
 # You can replace this text with custom code or comments, and it will be preserved on regeneration
 #

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/62d883f4/traffic_ops/app/lib/Schema/Result/Profile.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Schema/Result/Profile.pm b/traffic_ops/app/lib/Schema/Result/Profile.pm
index 5e7bc7f..05deb14 100644
--- a/traffic_ops/app/lib/Schema/Result/Profile.pm
+++ b/traffic_ops/app/lib/Schema/Result/Profile.pm
@@ -84,7 +84,7 @@ __PACKAGE__->set_primary_key("id");
 
 =head1 UNIQUE CONSTRAINTS
 
-=head2 C<idx_54441_name_unique>
+=head2 C<idx_18384_name_unique>
 
 =over 4
 
@@ -94,10 +94,25 @@ __PACKAGE__->set_primary_key("id");
 
 =cut
 
-__PACKAGE__->add_unique_constraint("idx_54441_name_unique", ["name"]);
+__PACKAGE__->add_unique_constraint("idx_18384_name_unique", ["name"]);
 
 =head1 RELATIONS
 
+=head2 deliveryservice_mso_profiles
+
+Type: has_many
+
+Related object: L<Schema::Result::Deliveryservice>
+
+=cut
+
+__PACKAGE__->has_many(
+  "deliveryservice_mso_profiles",
+  "Schema::Result::Deliveryservice",
+  { "foreign.mso_profile" => "self.id" },
+  { cascade_copy => 0, cascade_delete => 0 },
+);
+
 =head2 deliveryservices
 
 Type: has_many
@@ -144,8 +159,8 @@ __PACKAGE__->has_many(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.07046 @ 2016-11-18 22:45:19
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:tmTPl52VUdJsn+y6JuSLlw
+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2016-12-23 15:30:11
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:w9Yffpzp/V9wfVSGxX8kaw
 
 
 # You can replace this text with custom code or comments, and it will be preserved on regeneration


[29/44] incubator-trafficcontrol git commit: Checkpoint - all integration and unit testst pass

Posted by mi...@apache.org.
Checkpoint - all integration and unit testst pass


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

Branch: refs/heads/master
Commit: 85e5d8b3ea877cab4c57ca83e9413d11092a3030
Parents: 6832045
Author: Jan van Doorn <ja...@cable.comcast.com>
Authored: Thu Dec 29 16:42:42 2016 -0700
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:10 2017 +0000

----------------------------------------------------------------------
 traffic_ops/app/lib/API/Cdn.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/85e5d8b3/traffic_ops/app/lib/API/Cdn.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/Cdn.pm b/traffic_ops/app/lib/API/Cdn.pm
index cec6a24..af7c0f5 100644
--- a/traffic_ops/app/lib/API/Cdn.pm
+++ b/traffic_ops/app/lib/API/Cdn.pm
@@ -117,7 +117,7 @@ sub create {
 		return $self->alert( "a cdn with name " . $params->{name} . " already exists." );
 	}
 
-	my $existing = $self->db->resultset('Cdn')->search( { domain_name => $params->{domainName} } )->single();
+	$existing = $self->db->resultset('Cdn')->search( { domain_name => $params->{domainName} } )->single();
 	if ($existing) {
 		$self->app->log->error( "a cdn with domain name '" . $params->{domainName} . "' already exists." );
 		return $self->alert( "a cdn with domain " . $params->{domainName} . " already exists." );


[23/44] incubator-trafficcontrol git commit: remove mso_profile, will use profile link

Posted by mi...@apache.org.
remove mso_profile, will use profile link


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

Branch: refs/heads/master
Commit: 898611babc9b12f042718e11897d2d2e76839249
Parents: 76cf848
Author: Jan van Doorn <ja...@cable.comcast.com>
Authored: Mon Dec 26 10:47:38 2016 -0700
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:10 2017 +0000

----------------------------------------------------------------------
 .../app/lib/Schema/Result/Deliveryservice.pm    | 32 ++------------------
 traffic_ops/app/lib/Schema/Result/Profile.pm    | 19 ++----------
 2 files changed, 4 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/898611ba/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm b/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm
index 93bc2a3..27d48a0 100644
--- a/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm
+++ b/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm
@@ -288,12 +288,6 @@ __PACKAGE__->table("deliveryservice");
   data_type: 'text'
   is_nullable: 1
 
-=head2 mso_profile
-
-  data_type: 'bigint'
-  is_foreign_key: 1
-  is_nullable: 1
-
 =cut
 
 __PACKAGE__->add_columns(
@@ -405,8 +399,6 @@ __PACKAGE__->add_columns(
   { data_type => "smallint", is_nullable => 1 },
   "geolimit_redirect_url",
   { data_type => "text", is_nullable => 1 },
-  "mso_profile",
-  { data_type => "bigint", is_foreign_key => 1, is_nullable => 1 },
 );
 
 =head1 PRIMARY KEY
@@ -541,26 +533,6 @@ __PACKAGE__->has_many(
   { cascade_copy => 0, cascade_delete => 0 },
 );
 
-=head2 mso_profile
-
-Type: belongs_to
-
-Related object: L<Schema::Result::Profile>
-
-=cut
-
-__PACKAGE__->belongs_to(
-  "mso_profile",
-  "Schema::Result::Profile",
-  { id => "mso_profile" },
-  {
-    is_deferrable => 0,
-    join_type     => "LEFT",
-    on_delete     => "NO ACTION",
-    on_update     => "NO ACTION",
-  },
-);
-
 =head2 profile
 
 Type: belongs_to
@@ -637,8 +609,8 @@ __PACKAGE__->belongs_to(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.07046 @ 2016-12-23 15:30:11
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:aULX21NuOuu6Ow8dfmQ9Ig
+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2016-12-26 10:44:56
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:+HFlbMehDLwkF/hmfifkjw
 
 # You can replace this text with custom code or comments, and it will be preserved on regeneration
 #

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/898611ba/traffic_ops/app/lib/Schema/Result/Profile.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Schema/Result/Profile.pm b/traffic_ops/app/lib/Schema/Result/Profile.pm
index 05deb14..4ece9ed 100644
--- a/traffic_ops/app/lib/Schema/Result/Profile.pm
+++ b/traffic_ops/app/lib/Schema/Result/Profile.pm
@@ -98,21 +98,6 @@ __PACKAGE__->add_unique_constraint("idx_18384_name_unique", ["name"]);
 
 =head1 RELATIONS
 
-=head2 deliveryservice_mso_profiles
-
-Type: has_many
-
-Related object: L<Schema::Result::Deliveryservice>
-
-=cut
-
-__PACKAGE__->has_many(
-  "deliveryservice_mso_profiles",
-  "Schema::Result::Deliveryservice",
-  { "foreign.mso_profile" => "self.id" },
-  { cascade_copy => 0, cascade_delete => 0 },
-);
-
 =head2 deliveryservices
 
 Type: has_many
@@ -159,8 +144,8 @@ __PACKAGE__->has_many(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.07046 @ 2016-12-23 15:30:11
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:w9Yffpzp/V9wfVSGxX8kaw
+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2016-12-26 10:44:56
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:lLgKBTaWgSw4T1NXk7jh/g
 
 
 # You can replace this text with custom code or comments, and it will be preserved on regeneration


[04/44] incubator-trafficcontrol git commit: CDN form & UI

Posted by mi...@apache.org.
CDN form & UI


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

Branch: refs/heads/master
Commit: 8cf46ac7b8096a56edc7cfdb3483acd77203f6fa
Parents: 05798ae
Author: Jan van Doorn <ja...@cable.comcast.com>
Authored: Sat Dec 31 16:56:56 2016 -0700
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:10 2017 +0000

----------------------------------------------------------------------
 traffic_ops/app/lib/UI/Cdn.pm               | 19 ++++++++++++++++---
 traffic_ops/app/templates/cdn/_form.html.ep | 21 +++++++++++++++++++--
 traffic_ops/app/templates/cdn/index.html.ep |  1 +
 3 files changed, 36 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/8cf46ac7/traffic_ops/app/lib/UI/Cdn.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/UI/Cdn.pm b/traffic_ops/app/lib/UI/Cdn.pm
index d9f9d80..f36bd07 100644
--- a/traffic_ops/app/lib/UI/Cdn.pm
+++ b/traffic_ops/app/lib/UI/Cdn.pm
@@ -79,6 +79,8 @@ sub update {
         cdn_data    => {
             id   => $id,
             name => $self->param('cdn_data.name'),
+            domain_name => $self->param('cdn_data.domain_name'),
+            dnssec_enabled => $self->param('cdn_data.dnssec_enabled'),
         }
     );
 
@@ -107,14 +109,22 @@ sub update {
 sub create {
     my $self = shift;
     my $name = $self->param('cdn_data.name');
+    my $dnssec_enabled = defined($self->param('cdn_data.dnssec_enabled')) ? $self->param('cdn_data.dnssec_enabled') : 0;
+    my $domain_name = $self->param('cdn_data.domain_name');
     my $data = $self->get_cdns();
     my $cdns = $data->{'cdn'};
 
+    foreach my $f ($self->param) {
+      print $f . " => " . Dumper($self->param($f)) . "\n";
+    }
+
     if ( !$self->isValidCdn() ) {
         $self->stash(
             fbox_layout => 1,
             cdn_data    => {
                 name => $name,
+                domain_name => $domain_name,
+                dnssec_enabled => $dnssec_enabled,
             }
         );
         return $self->render('cdn/add');
@@ -125,6 +135,8 @@ sub create {
             fbox_layout => 1,
             cdn_data    => {
                 name => $name,
+                domain_name => $domain_name,
+                dnssec_enabled => $dnssec_enabled,
             }
         );
         return $self->render('cdn/add');
@@ -136,7 +148,7 @@ sub create {
         return $self->redirect_to( '/cdn/edit/' . $new_id );
     }
     else {
-        my $insert = $self->db->resultset('Cdn')->create( { name => $name } );
+        my $insert = $self->db->resultset('Cdn')->create( { name => $name, domain_name => $domain_name, dnssec_enabled => $dnssec_enabled } );
         $insert->insert();
         $new_id = $insert->id;
     }
@@ -445,9 +457,10 @@ sub adeliveryservice {
         # This will be undefined for 'Steering' delivery services
         my $org_server_fqdn = defined($row->org_server_fqdn) ? $row->org_server_fqdn : "";
 
+        my $ptext = defined($row->profile) ? $row->profile->name : "-";
         my $line = [
             $row->id,                       $row->xml_id,                $org_server_fqdn,                "dummy",
-            $cdn_name,                      $row->profile->name,         $row->ccr_dns_ttl,                    $yesno{ $row->active },
+            $cdn_name,                      $ptext,                      $row->ccr_dns_ttl,                    $yesno{ $row->active },
             $row->type->name,               $row->dscp,                  $yesno{ $row->signed },               $row->qstring_ignore,
             $geo_limits{ $row->geo_limit }, $protocol{ $row->protocol }, $yesno{ $row->ipv6_routing_enabled }, $row->range_request_handling,
             $row->http_bypass_fqdn,         $row->dns_bypass_ip,         $row->dns_bypass_ip6,                 $row->dns_bypass_ttl,
@@ -586,7 +599,7 @@ sub acdn {
 
     $rs = $self->db->resultset('Cdn')->search(undef);
     while ( my $row = $rs->next ) {
-        my @line = [ $row->id, $row->name, $yesno{ $row->dnssec_enabled }, $row->last_updated ];
+        my @line = [ $row->id, $row->name, $row->domain_name, $yesno{ $row->dnssec_enabled }, $row->last_updated ];
         push( @{ $data{'aaData'} }, @line );
     }
     $self->render( json => \%data );

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/8cf46ac7/traffic_ops/app/templates/cdn/_form.html.ep
----------------------------------------------------------------------
diff --git a/traffic_ops/app/templates/cdn/_form.html.ep b/traffic_ops/app/templates/cdn/_form.html.ep
index b886a36..68edabf 100644
--- a/traffic_ops/app/templates/cdn/_form.html.ep
+++ b/traffic_ops/app/templates/cdn/_form.html.ep
@@ -18,7 +18,24 @@
 			<span class="field-with-error"><%= field('cdn_data.name')->error %></span>
 		<% } %>
 		%= label_for 'name' => '* Name', class => 'label'
-		%= field('cdn_data.name')->text(class => 'field', required => 'required', size => 10, name => 'cdn_data.name', id => 'cdn_data.name')
+          %= field('cdn_data.name')->text(class => 'field', required => 'required', size => 10, name => 'cdn_data.name', id => 'cdn_data.name')
 	</div>
-	<br>
+     <div class="block">
+          <% unless (field('cdn_data.domain_name')->valid) { %>
+               <span class="field-with-error"><%= field('cdn_data.domain_name')->error %></span>
+          <% } %>
+          %= label_for 'domain_name' => '* Domain Name', class => 'label'
+          %= field('cdn_data.domain_name')->text(class => 'field', required => 'required', size => 10, name => 'cdn_data.domain_name', id => 'cdn_data.domain_name')
+    </div>
+    <div class="block">
+    <% unless(field('cdn_data.dnssec_enabled')->valid) { %>
+     <span class="field-with-error"><%= field('cdn_data.dnssec_enabled')->error %></span>
+    <% } %>
+    %= label_for 'dnssec_enabled' => '* DNSSEC Enabled', class => 'label'
+    <% if (field('cdn_data.dnssec_enabled') == 0) { %>
+        %= check_box 'cdn_data.dnssec_enabled' => 1
+    <% } else { %>
+        %= check_box 'cdn_data.dnssec_enabled' => 1, checked => 1
+    <% } %>
+</div><br>
 </div>

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/8cf46ac7/traffic_ops/app/templates/cdn/index.html.ep
----------------------------------------------------------------------
diff --git a/traffic_ops/app/templates/cdn/index.html.ep b/traffic_ops/app/templates/cdn/index.html.ep
index b086d0c..bc16a03 100644
--- a/traffic_ops/app/templates/cdn/index.html.ep
+++ b/traffic_ops/app/templates/cdn/index.html.ep
@@ -82,6 +82,7 @@ $(function () {
 					<tr>
 						<td></td>
 						<td>Name</td>
+						<td>Domain Name</td>
 						<td>DNSSEC enabled?</td>
 						<td>Last Updated</td>
 					</tr>


[07/44] incubator-trafficcontrol git commit: Profiles UI with extended types and CDN

Posted by mi...@apache.org.
Profiles UI with extended types and CDN


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

Branch: refs/heads/master
Commit: 613e4ba6c49404d38440800e01a8535af984d344
Parents: 8cf46ac
Author: Jan van Doorn <ja...@cable.comcast.com>
Authored: Mon Jan 2 13:44:49 2017 -0700
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:10 2017 +0000

----------------------------------------------------------------------
 .../20161226000000_cdn_domain_name.sql          | 22 +++++---
 traffic_ops/app/lib/API/Profile.pm              |  4 ++
 traffic_ops/app/lib/Fixtures/Profile.pm         |  7 +++
 traffic_ops/app/lib/MojoPlugins/Enum.pm         | 44 +++++++++++++++
 traffic_ops/app/lib/UI/Cdn.pm                   |  6 +--
 traffic_ops/app/lib/UI/DeliveryService.pm       |  7 ++-
 traffic_ops/app/lib/UI/Profile.pm               | 57 ++++++++++++++++++--
 traffic_ops/app/templates/profile/_form.html.ep | 17 +++++-
 traffic_ops/app/templates/profile/index.html.ep |  2 +
 traffic_ops/app/templates/profile/view.html.ep  |  8 +++
 10 files changed, 158 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/613e4ba6/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql b/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql
index 22e855a..d7e0d8c 100644
--- a/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql
+++ b/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql
@@ -16,13 +16,23 @@
 -- +goose Up
 -- SQL in section 'Up' is executed when this migration is applied
 
--- INSERT INTO TYPE (name, description, use_in_table) VALUES ('SERVER_PROFILE', 'Profile to be assigned to server', 'profile');
--- INSERT INTO TYPE (name, description, use_in_table) VALUES ('DS_PROFILE', 'Profile to be assigned to deliveryservice', 'profile');
--- better to use ENUMs, I think
-
-CREATE TYPE profile_type AS ENUM ('SERVER_PROFILE', 'DS_PROFILE');
+CREATE TYPE profile_type AS ENUM ('ATS_PROFILE', 'TR_PROFILE', 'TM_PROFILE', 'TS_PROFILE', 'TP_PROFILE', 'INFLUXDB_PROFILE', 
+  'RIAK_PROFILE', 'SPLUNK_PROFILE', 'DS_PROFILE', 'ORG_PROFILE', 'KAFKA_PROFILE', 'LOGSTASH_PROFILE', 'ES_PROFILE', 'UNK_PROFILE');
 ALTER TABLE public.profile ADD COLUMN type profile_type;
-UPDATE public.profile SET type='SERVER_PROFILE';
+UPDATE public.profile SET type='UNK_PROFILE'; -- So we don't get any NULL, these should be checked.
+UPDATE public.profile SET type='TR_PROFILE' WHERE name like 'CCR_%' OR name like 'TR_%';
+UPDATE public.profile SET type='TM_PROFILE' WHERE name like 'RASCAL_%' OR name like 'TM_%';
+UPDATE public.profile SET type='TS_PROFILE' WHERE name like 'TRAFFIC_STATS%';
+UPDATE public.profile SET type='TP_PROFILE' WHERE name like 'TRAFFIC_PORTAL%';
+UPDATE public.profile SET type='INFLUXDB_PROFILE' WHERE name like 'INFLUXDB%';
+UPDATE public.profile SET type='RIAK_PROFILE' WHERE name like 'RIAK%';
+UPDATE public.profile SET type='SPLUNK_PROFILE' WHERE name like 'SPLUNK%';
+UPDATE public.profile SET type='ORG_PROFILE' WHERE name like '%ORG%' or name like 'MSO%' or name like '%ORIGIN%';
+UPDATE public.profile SET type='KAFKA_PROFILE' WHERE name like 'KAFKA%';
+UPDATE public.profile SET type='LOGSTASH_PROFILE' WHERE name like 'LOGSTASH_%';
+UPDATE public.profile SET type='ES_PROFILE' WHERE name like 'ELASTICSEARCH%';
+UPDATE public.profile SET type='ATS_PROFILE' WHERE name like 'EDGE%' or name like 'MID%';
+
 ALTER TABLE public.profile ALTER type SET NOT NULL;
 
 ALTER TABLE public.cdn ADD COLUMN domain_name text;

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/613e4ba6/traffic_ops/app/lib/API/Profile.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/Profile.pm b/traffic_ops/app/lib/API/Profile.pm
index b41b835..1de9c8c 100644
--- a/traffic_ops/app/lib/API/Profile.pm
+++ b/traffic_ops/app/lib/API/Profile.pm
@@ -37,6 +37,8 @@ sub index {
 					"id" => $row->profile->id,
 					"name" => $row->profile->name,
 					"description" => $row->profile->description,
+					"cdn" => $row->profile->cdn,
+					"type" => $row->profile->type,
 					"lastUpdated" => $row->profile->last_updated
 				}
 			);
@@ -49,6 +51,8 @@ sub index {
 					"id"          => $row->id,
 					"name"        => $row->name,
 					"description" => $row->description,
+					"cdn"         => defined($row->cdn) ? $row->cdn->name : "-",
+					"type"        => $row->type,
 					"lastUpdated" => $row->last_updated
 				}
 			);

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/613e4ba6/traffic_ops/app/lib/Fixtures/Profile.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Fixtures/Profile.pm b/traffic_ops/app/lib/Fixtures/Profile.pm
index be05f9c..f4370fd 100644
--- a/traffic_ops/app/lib/Fixtures/Profile.pm
+++ b/traffic_ops/app/lib/Fixtures/Profile.pm
@@ -25,6 +25,7 @@ my %definition_for = (
 			name        => 'EDGE1',
 			description => 'edge description',
 			cdn         => 1,
+			type        => 'SERVER_PROFILE',
 		},
 	},
 	MID1 => {
@@ -34,6 +35,7 @@ my %definition_for = (
 			name        => 'MID1',
 			description => 'mid description',
 			cdn         => 1,
+			type        => 'SERVER_PROFILE',
 		},
 	},
 	CCR1 => {
@@ -43,6 +45,7 @@ my %definition_for = (
 			name        => 'CCR1',
 			description => 'ccr description',
 			cdn         => 1,
+			type        => 'SERVER_PROFILE',
 		},
 	},
 	CCR2 => {
@@ -52,6 +55,7 @@ my %definition_for = (
 			name        => 'CCR2',
 			description => 'ccr description',
 			cdn         => 2,
+			type        => 'SERVER_PROFILE',
 		},
 	},
 	RIAK1 => {
@@ -61,6 +65,7 @@ my %definition_for = (
 			name        => 'RIAK1',
 			description => 'riak description',
 			cdn         => 1,
+			type        => 'SERVER_PROFILE',
 		},
 	},
 	RASCAL1 => {
@@ -70,6 +75,7 @@ my %definition_for = (
 			name        => 'RASCAL1',
 			description => 'rascal description',
 			cdn         => 1,
+			type        => 'SERVER_PROFILE',
 		},
 	},
 	RASCAL2 => {
@@ -79,6 +85,7 @@ my %definition_for = (
 			name        => 'RASCAL2',
 			description => 'rascal2 description',
 			cdn         => 2,
+			type        => 'SERVER_PROFILE',
 		},
 	},
 	MISC => {

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/613e4ba6/traffic_ops/app/lib/MojoPlugins/Enum.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/MojoPlugins/Enum.pm b/traffic_ops/app/lib/MojoPlugins/Enum.pm
new file mode 100644
index 0000000..b132b61
--- /dev/null
+++ b/traffic_ops/app/lib/MojoPlugins/Enum.pm
@@ -0,0 +1,44 @@
+package MojoPlugins::Enum;
+#
+#
+# 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 Mojo::Base 'Mojolicious::Plugin';
+
+sub register {
+	my ( $self, $app, $conf ) = @_;
+
+	$app->renderer->add_helper(
+
+		# Returns an array with the possible values for the enum.
+		# Note that for now this is postgres specific; if we need to support other databases, we need to add support here.
+		enum_values => sub {
+			my $self = shift;
+			my $enum_name = shift;
+
+			my @possible;
+			my $dbh    = Schema->database_handle;
+			my $h = $dbh->prepare('SELECT unnest(enum_range(NULL:: ' . $enum_name . ' )) as value ORDER BY value');
+			$h->execute || print "ERR";
+			while ( my @data = $h->fetchrow_array() ) {
+				push(@possible, $data[0]);
+			}
+			return \@possible;
+		}
+	);
+}
+
+1;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/613e4ba6/traffic_ops/app/lib/UI/Cdn.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/UI/Cdn.pm b/traffic_ops/app/lib/UI/Cdn.pm
index f36bd07..3f2f160 100644
--- a/traffic_ops/app/lib/UI/Cdn.pm
+++ b/traffic_ops/app/lib/UI/Cdn.pm
@@ -693,11 +693,11 @@ sub aprofile {
     my $self = shift;
     my %data = ( "aaData" => [] );
 
-    my $rs = $self->db->resultset('Profile')->search(undef);
+    my $rs = $self->db->resultset('Profile')->search(undef, { prefetch => ['cdn'] } );
 
     while ( my $row = $rs->next ) {
-
-        my @line = [ $row->id, $row->name, $row->name, $row->description, $row->last_updated ];
+        my $ctext = defined( $row->cdn ) ? $row->cdn->name : "-";
+        my @line = [ $row->id, $row->name, $row->name, $row->description, $row->type, $ctext, $row->last_updated ];
         push( @{ $data{'aaData'} }, @line );
     }
     $self->render( json => \%data );

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/613e4ba6/traffic_ops/app/lib/UI/DeliveryService.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/UI/DeliveryService.pm b/traffic_ops/app/lib/UI/DeliveryService.pm
index b40caa3..069175e 100644
--- a/traffic_ops/app/lib/UI/DeliveryService.pm
+++ b/traffic_ops/app/lib/UI/DeliveryService.pm
@@ -45,9 +45,12 @@ sub edit {
 	my $self = shift;
 	my $id   = $self->param('id');
 
-	my $rs_ds =
-		$self->db->resultset('Deliveryservice')->search( { 'me.id' => $id }, { prefetch => [ 'cdn', { 'type' => undef }, { 'profile' => undef } ] } );
+	my $rs_ds = $self->db->resultset('Deliveryservice')->search( { 'me.id' => $id }, { prefetch => [ 'cdn', 'type', 'profile' ] } );
 	my $data = $rs_ds->single;
+	print Dumper($data);
+	if (!defined($data->profile)) {
+		$data->profile(-1);
+	}
 	my $action;
 	my $regexp_set   = &get_regexp_set( $self, $id );
 	my $cdn_domain   = $self->get_cdn_domain_by_ds_id($id);

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/613e4ba6/traffic_ops/app/lib/UI/Profile.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/UI/Profile.pm b/traffic_ops/app/lib/UI/Profile.pm
index 2966750..e386341 100644
--- a/traffic_ops/app/lib/UI/Profile.pm
+++ b/traffic_ops/app/lib/UI/Profile.pm
@@ -31,10 +31,46 @@ sub index {
 	$self->stash( profile => {} );
 }
 
+sub stash_cdn_selector {
+	my $self = shift;
+	my $selected = shift || -1;
+
+	my $rs = $self->db->resultset('Cdn')->search(undef);
+	my @cdns;
+    while ( my $row = $rs->next ) {
+    	if ($row->id == $selected) {
+			push(@cdns, [ $row->name => $row->id, selected => 'true' ] );
+    	} else {
+			push(@cdns, [ $row->name => $row->id ] );
+    	}
+	}
+	$self->stash( cdns => \@cdns );
+}
+
+sub stash_profile_type_selector {
+	my $self = shift;
+	my $selected = shift || -1;
+
+	my $enum_possible = $self->enum_values("profile_type");
+	my @possible;
+    foreach my $val ( @{$enum_possible} ) {
+    	if ($val eq $selected) {
+			push(@possible, [ $val => $val , selected => 'true' ] );
+    	} else {
+			push(@possible, [ $val => $val ] );
+    	}
+	}
+	$self->stash( profile_type_possible  => \@possible );
+}
+
 # for the fancybox view
 sub add {
 	my $self     = shift;
 	my %profiles = get_profiles($self);
+
+	$self->stash_cdn_selector();
+	$self->stash_profile_type_selector();
+
 	$self->stash( profile => {}, profiles => \%profiles, fbox_layout => 1 );
 }
 
@@ -43,6 +79,10 @@ sub edit {
 	my $id     = $self->param('id');
 	my $cursor = $self->db->resultset('Profile')->search( { id => $id } );
 	my $data   = $cursor->single;
+
+	$self->stash_cdn_selector($data->cdn->id);
+	$self->stash_profile_type_selector($data->type);
+
 	&stash_role($self);
 	$self->stash( profile => $data, id => $data->id, fbox_layout => 1 );
 	return $self->render('profile/edit');
@@ -62,10 +102,9 @@ sub view {
 	my $id = $self->param('id');
 
 	my $rs_param = $self->db->resultset('Profile')->search( { id => $id } );
+	my $data = $rs_param->single;
 	my $param_count = $self->db->resultset('ProfileParameter')->search( { profile => $id } )->count();
 
-	# if ( $mode eq "view" ) {
-	my $data = $rs_param->single;
 	$self->stash( profile     => $data );
 	$self->stash( param_count => $param_count );
 
@@ -73,7 +112,6 @@ sub view {
 
 	$self->stash( fbox_layout => 1 );
 
-	# }
 }
 
 # Read
@@ -82,12 +120,14 @@ sub readprofile {
 	my @data;
 	my $orderby = "name";
 	$orderby = $self->param('orderby') if ( defined $self->param('orderby') );
-	my $rs_data = $self->db->resultset("Profile")->search( undef, { order_by => 'me.' . $orderby } );
+	my $rs_data = $self->db->resultset("Profile")->search( undef, { prefetch => ['cdn'], order_by => 'me.' . $orderby } );
 	while ( my $row = $rs_data->next ) {
 		push(
 			@data, {
 				"id"           => $row->id,
 				"name"         => $row->name,
+				"type"         => $row->type,
+				"cdn"          => $row->cdn->name,
 				"description"  => $row->description,
 				"last_updated" => $row->last_updated,
 			}
@@ -194,12 +234,16 @@ sub update {
 	my $id          = $self->param('id');
 	my $name        = $self->param('profile.name');
 	my $description = $self->param('profile.description');
+	my $cdn         = $self->param('profile.cdn');
+	my $type        = $self->param('profile.type');
 
 	if ( $self->check_profile_input("edit") ) {
 
 		my $update = $self->db->resultset('Profile')->find( { id => $id } );
 		$update->name($name);
 		$update->description($description);
+		$update->cdn($cdn);
+		$update->type($type);
 		$update->update();
 
 		# if the update has failed, we don't even get here, we go to the exception page.
@@ -221,6 +265,9 @@ sub create {
 	my $new_id = -1;
 	my $p_name = $self->param('profile.name');
 	my $p_desc = $self->param('profile.description');
+	my $p_cdn         = $self->param('profile.cdn');
+	my $p_type        = $self->param('profile.type');
+
 	if ( !&is_admin($self) ) {
 		my $err = "You must be an ADMIN to perform this operation!" . "__NEWLINE__";
 		return $self->flash( message => $err );
@@ -230,6 +277,8 @@ sub create {
 			{
 				name        => $p_name,
 				description => $p_desc,
+				cdn         => $p_cdn,
+				type        => $p_type,
 			}
 		);
 		$insert->insert();

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/613e4ba6/traffic_ops/app/templates/profile/_form.html.ep
----------------------------------------------------------------------
diff --git a/traffic_ops/app/templates/profile/_form.html.ep b/traffic_ops/app/templates/profile/_form.html.ep
index 5073c43..3301d37 100644
--- a/traffic_ops/app/templates/profile/_form.html.ep
+++ b/traffic_ops/app/templates/profile/_form.html.ep
@@ -26,4 +26,19 @@
     <% } %>
     %= label_for 'description' => '* Description', class => 'label'
     %= field('profile.description')->text(class => 'field', required=> 'required')
-</div><br>
+</div>
+<br>
+<div class="block">
+    <% unless (field('profile.cdn')->valid) { %>
+        <span class="field-with-error"><%= field('profile.cdn')->error %></span>
+    <% } %>
+    %= label_for 'profile.cdn' => '* CDN', class => 'label'
+    %= field('profile.cdn')->select( \@{$cdns} )
+</div>
+<div class="block">
+    <% unless (field('profile.type')->valid) { %>
+        <span class="field-with-error"><%= field('profile.type')->error %></span>
+    <% } %>
+    %= label_for 'profile.type' => '* Profile Type', class => 'label'
+    %= field('profile.type')->select( \@{$profile_type_possible} )
+</div>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/613e4ba6/traffic_ops/app/templates/profile/index.html.ep
----------------------------------------------------------------------
diff --git a/traffic_ops/app/templates/profile/index.html.ep b/traffic_ops/app/templates/profile/index.html.ep
index 6df8688..de0e9c9 100644
--- a/traffic_ops/app/templates/profile/index.html.ep
+++ b/traffic_ops/app/templates/profile/index.html.ep
@@ -92,6 +92,8 @@ $("a.fancybox").fancybox({
 							<td></td>						
 							<td>Profile Name</td>
 							<td>Profile Description</td>
+							<td>Type</td>
+							<td>Cdn</td>
 							<td>Last updated</td>
 						</tr>
 					</thead>

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/613e4ba6/traffic_ops/app/templates/profile/view.html.ep
----------------------------------------------------------------------
diff --git a/traffic_ops/app/templates/profile/view.html.ep b/traffic_ops/app/templates/profile/view.html.ep
index c24f53e..d65b646 100644
--- a/traffic_ops/app/templates/profile/view.html.ep
+++ b/traffic_ops/app/templates/profile/view.html.ep
@@ -63,6 +63,14 @@ function deletefunction() {
 							<td>Description</td>
 							<td class="editable" id="description"><%= $profile->description %></td>
 						</tr>
+						<tr>
+							<td>CDN</td>
+							<td class="editable" id="cdn"><%= defined($profile->cdn) ? $profile->cdn->name : "-" %></td>
+						</tr>
+						<tr>
+							<td>Type</td>
+							<td class="editable" id="type"><%= $profile->type %></td>
+						</tr>
 					</table>
 					<div id="parameter_link">
 					<br>


[44/44] incubator-trafficcontrol git commit: This closes #290

Posted by mi...@apache.org.
This closes #290


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

Branch: refs/heads/master
Commit: b1842dc0a67731c551bbfd8efa3a6d4356ff38c7
Parents: b345b30
Author: Jeremy Mitchell <mi...@gmail.com>
Authored: Thu Mar 9 12:08:58 2017 -0700
Committer: Jeremy Mitchell <mi...@gmail.com>
Committed: Thu Mar 9 12:08:58 2017 -0700

----------------------------------------------------------------------

----------------------------------------------------------------------



[14/44] incubator-trafficcontrol git commit: Deliveryservice UI; move stash stuff to MojoPlugin

Posted by mi...@apache.org.
Deliveryservice UI; move stash stuff to MojoPlugin


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

Branch: refs/heads/master
Commit: 9ede7b67eb76b5137b73ef315da5b56a4e0869a8
Parents: f84a4e2
Author: Jan van Doorn <ja...@cable.comcast.com>
Authored: Mon Jan 2 16:11:12 2017 -0700
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:10 2017 +0000

----------------------------------------------------------------------
 .../20161226000000_cdn_domain_name.sql          |  2 +
 traffic_ops/app/lib/MojoPlugins/Stash.pm        | 91 ++++++++++++++++++++
 .../app/lib/Schema/Result/Deliveryservice.pm    | 19 ++--
 traffic_ops/app/lib/Schema/Result/Profile.pm    | 27 ++++--
 traffic_ops/app/lib/UI/DeliveryService.pm       | 26 +++---
 traffic_ops/app/lib/UI/Profile.pm               | 34 --------
 .../templates/delivery_service/_form.html.ep    | 27 +-----
 .../app/templates/delivery_service/edit.html.ep | 23 -----
 8 files changed, 137 insertions(+), 112 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/9ede7b67/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql b/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql
index d7e0d8c..b84cc35 100644
--- a/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql
+++ b/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql
@@ -67,6 +67,8 @@ WHERE id = domainlist.profile_id;
 
 ALTER TABLE deliveryservice ALTER profile DROP NOT NULL;
 
+ALTER TABLE deliveryservice DROP COLUMN multi_site_origin_algorithm;
+
 
 -- +goose Down
 -- SQL section 'Down' is executed when this migration is rolled back

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/9ede7b67/traffic_ops/app/lib/MojoPlugins/Stash.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/MojoPlugins/Stash.pm b/traffic_ops/app/lib/MojoPlugins/Stash.pm
new file mode 100644
index 0000000..adb7f0d
--- /dev/null
+++ b/traffic_ops/app/lib/MojoPlugins/Stash.pm
@@ -0,0 +1,91 @@
+package MojoPlugins::Stash;
+#
+#
+# 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 Mojo::Base 'Mojolicious::Plugin';
+use Carp qw(cluck confess);
+
+sub register {
+	my ( $self, $app, $conf ) = @_;
+
+	$app->renderer->add_helper(
+
+		# stash the cdn array for a form select.. optional second arg is the one that is selected.
+		stash_cdn_selector => sub {
+			my $self     = shift || confess("Call on an instance of MojoPlugins::Stash");
+			my $selected = shift || -1;
+
+			my $rs = $self->db->resultset('Cdn')->search(undef);
+			my @cdns;
+			while ( my $row = $rs->next ) {
+				if ( $row->id == $selected ) {
+					push( @cdns, [ $row->name => $row->id, selected => 'true' ] );
+				}
+				else {
+					push( @cdns, [ $row->name => $row->id ] );
+				}
+			}
+			$self->stash( cdns => \@cdns );
+		}
+	);
+
+	$app->renderer->add_helper(
+		# stash the profile_type array for a form select. optional second arg is the one that is selected.
+		stash_profile_type_selector => sub {
+			my $self     = shift || confess("Call on an instance of MojoPlugins::Stash");
+			my $selected = shift || -1;
+
+			my $enum_possible = $self->enum_values("profile_type");
+			my @types;
+			foreach my $val ( @{$enum_possible} ) {
+				if ( $val eq $selected ) {
+					push( @types, [ $val => $val, selected => 'true' ] );
+				}
+				else {
+					push( @types, [ $val => $val ] );
+				}
+			}
+			$self->stash( profile_types => \@types );
+		}
+	);
+
+	$app->renderer->add_helper(
+		# stash the profile array for a form select.. optional second arg is the one that is selected.
+		stash_profile_selector => sub {
+			my $self     = shift || confess("Call on an instance of MojoPlugins::Stash");
+			my $ptype    = shift || confess("Please supply a profile type");
+			my $selected = shift || -1;
+
+			my @profiles;
+			if ( $selected == -1 ) {
+				push( @profiles, [ "No Profile" => -1, selected => 'true' ] );
+			}
+			my $rs = $self->db->resultset('Profile')->search( { type => $ptype } );
+			while ( my $row = $rs->next ) {
+				if ( $row->id == $selected ) {
+					push( @profiles, [ $row->name => $row->id, selected => 'true' ] );
+				}
+				else {
+					push( @profiles, [ $row->name => $row->id ] );
+				}
+			}
+			$self->stash( profiles => \@profiles );
+		}
+	);
+}
+
+1;

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/9ede7b67/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm b/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm
index 8f81857..a179d7f 100644
--- a/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm
+++ b/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm
@@ -278,11 +278,6 @@ __PACKAGE__->table("deliveryservice");
   default_value: false
   is_nullable: 1
 
-=head2 multi_site_origin_algorithm
-
-  data_type: 'smallint'
-  is_nullable: 1
-
 =head2 geolimit_redirect_url
 
   data_type: 'text'
@@ -395,8 +390,6 @@ __PACKAGE__->add_columns(
   { data_type => "text", is_nullable => 1 },
   "logs_enabled",
   { data_type => "boolean", default_value => \"false", is_nullable => 1 },
-  "multi_site_origin_algorithm",
-  { data_type => "smallint", is_nullable => 1 },
   "geolimit_redirect_url",
   { data_type => "text", is_nullable => 1 },
 );
@@ -417,7 +410,7 @@ __PACKAGE__->set_primary_key("id", "type");
 
 =head1 UNIQUE CONSTRAINTS
 
-=head2 C<idx_90606_ds_id_unique>
+=head2 C<idx_101208_ds_id_unique>
 
 =over 4
 
@@ -427,9 +420,9 @@ __PACKAGE__->set_primary_key("id", "type");
 
 =cut
 
-__PACKAGE__->add_unique_constraint("idx_90606_ds_id_unique", ["id"]);
+__PACKAGE__->add_unique_constraint("idx_101208_ds_id_unique", ["id"]);
 
-=head2 C<idx_90606_ds_name_unique>
+=head2 C<idx_101208_ds_name_unique>
 
 =over 4
 
@@ -439,7 +432,7 @@ __PACKAGE__->add_unique_constraint("idx_90606_ds_id_unique", ["id"]);
 
 =cut
 
-__PACKAGE__->add_unique_constraint("idx_90606_ds_name_unique", ["xml_id"]);
+__PACKAGE__->add_unique_constraint("idx_101208_ds_name_unique", ["xml_id"]);
 
 =head1 RELATIONS
 
@@ -614,8 +607,8 @@ __PACKAGE__->belongs_to(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.07046 @ 2016-12-31 13:55:06
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:+2cW0kP4B6YbySGBBtDp0Q
+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2017-01-02 16:07:07
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:qCU9AxWN09+5k2ETT6tqSQ
 
 # You can replace this text with custom code or comments, and it will be preserved on regeneration
 #

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/9ede7b67/traffic_ops/app/lib/Schema/Result/Profile.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Schema/Result/Profile.pm b/traffic_ops/app/lib/Schema/Result/Profile.pm
index f7ccd98..efc1ee3 100644
--- a/traffic_ops/app/lib/Schema/Result/Profile.pm
+++ b/traffic_ops/app/lib/Schema/Result/Profile.pm
@@ -50,7 +50,7 @@ __PACKAGE__->table("profile");
 =head2 type
 
   data_type: 'enum'
-  extra: {custom_type_name => "profile_type",list => ["SERVER_PROFILE","DS_PROFILE"]}
+  extra: {custom_type_name => "profile_type",list => ["ATS_PROFILE","TR_PROFILE","TM_PROFILE","TS_PROFILE","TP_PROFILE","INFLUXDB_PROFILE","RIAK_PROFILE","SPLUNK_PROFILE","DS_PROFILE","ORG_PROFILE","KAFKA_PROFILE","LOGSTASH_PROFILE","ES_PROFILE","UNK_PROFILE"]}
   is_nullable: 0
 
 =head2 cdn
@@ -85,7 +85,22 @@ __PACKAGE__->add_columns(
     data_type => "enum",
     extra => {
       custom_type_name => "profile_type",
-      list => ["SERVER_PROFILE", "DS_PROFILE"],
+      list => [
+        "ATS_PROFILE",
+        "TR_PROFILE",
+        "TM_PROFILE",
+        "TS_PROFILE",
+        "TP_PROFILE",
+        "INFLUXDB_PROFILE",
+        "RIAK_PROFILE",
+        "SPLUNK_PROFILE",
+        "DS_PROFILE",
+        "ORG_PROFILE",
+        "KAFKA_PROFILE",
+        "LOGSTASH_PROFILE",
+        "ES_PROFILE",
+        "UNK_PROFILE",
+      ],
     },
     is_nullable => 0,
   },
@@ -107,7 +122,7 @@ __PACKAGE__->set_primary_key("id");
 
 =head1 UNIQUE CONSTRAINTS
 
-=head2 C<idx_90769_name_unique>
+=head2 C<idx_101371_name_unique>
 
 =over 4
 
@@ -117,7 +132,7 @@ __PACKAGE__->set_primary_key("id");
 
 =cut
 
-__PACKAGE__->add_unique_constraint("idx_90769_name_unique", ["name"]);
+__PACKAGE__->add_unique_constraint("idx_101371_name_unique", ["name"]);
 
 =head1 RELATIONS
 
@@ -187,8 +202,8 @@ __PACKAGE__->has_many(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.07046 @ 2016-12-31 13:55:06
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:NyNmb9qs7HXNZ13aV1VvuQ
+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2017-01-02 16:07:07
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:1LR3Lov3kmopJD1mJF08EQ
 
 
 # You can replace this text with custom code or comments, and it will be preserved on regeneration

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/9ede7b67/traffic_ops/app/lib/UI/DeliveryService.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/UI/DeliveryService.pm b/traffic_ops/app/lib/UI/DeliveryService.pm
index 069175e..834b08d 100644
--- a/traffic_ops/app/lib/UI/DeliveryService.pm
+++ b/traffic_ops/app/lib/UI/DeliveryService.pm
@@ -41,23 +41,23 @@ sub index {
 	&navbarpage($self);
 }
 
+
 sub edit {
 	my $self = shift;
 	my $id   = $self->param('id');
 
 	my $rs_ds = $self->db->resultset('Deliveryservice')->search( { 'me.id' => $id }, { prefetch => [ 'cdn', 'type', 'profile' ] } );
 	my $data = $rs_ds->single;
-	print Dumper($data);
-	if (!defined($data->profile)) {
-		$data->profile(-1);
-	}
-	my $action;
+
 	my $regexp_set   = &get_regexp_set( $self, $id );
 	my $cdn_domain   = $self->get_cdn_domain_by_ds_id($id);
 	my @example_urls = &get_example_urls( $self, $id, $regexp_set, $data, $cdn_domain, $data->protocol );
 
 	my $server_count = $self->db->resultset('DeliveryserviceServer')->search( { deliveryservice => $id } )->count();
 	my $static_count = $self->db->resultset('Staticdnsentry')->search( { deliveryservice => $id } )->count();
+
+	$self->stash_profile_selector('DS_PROFILE', defined($data->profile) ? $data->profile->id : undef);
+	$self->stash_cdn_selector($data->cdn->id);
 	&stash_role($self);
 	$self->stash(
 		ds           => $data,
@@ -233,7 +233,6 @@ sub read {
 				"dns_bypass_ttl"              => $row->dns_bypass_ttl,
 				"org_server_fqdn"             => $row->org_server_fqdn,
 				"multi_site_origin"           => \$row->multi_site_origin,
-				"multi_site_origin_algorithm" => \$row->multi_site_origin_algorithm,
 				"ccr_dns_ttl"                 => $row->ccr_dns_ttl,
 				"type"                        => $row->type->id,
 				"cdn_name"                    => $cdn_name,
@@ -342,8 +341,8 @@ sub check_deliveryservice_input {
 		$self->field('ds.regex_remap')->is_equal( "", "Regex Remap can not be used when qstring_ignore is 2" );
 	}
 
-	my $profile_id = $self->param('ds.profile');
-	my $cdn_domain = $self->get_cdn_domain_by_profile_id($profile_id);
+	# my $profile_id = $self->param('ds.profile.id');
+	my $cdn_domain = $self->db->resultset('Cdn')->search( { id => $cdn_id } )->get_column('domain_name')->single();
 
 	my $match_one = 0;
 	my $dbl_check = {};
@@ -735,6 +734,9 @@ sub update {
 		my $referer = $self->req->headers->header('referer');
 		return $self->redirect_to($referer);
 	}
+	foreach my $f ($self->param) {
+		print $f . " => " . $self->param($f) . "\n";
+	}
 
 	if ( $self->check_deliveryservice_input( $self->param('ds.cdn_id'), $id ) ) {
 
@@ -752,11 +754,10 @@ sub update {
 			geo_provider                => $self->paramAsScalar('ds.geo_provider'),
 			org_server_fqdn             => $self->paramAsScalar('ds.org_server_fqdn'),
 			multi_site_origin           => $self->paramAsScalar('ds.multi_site_origin'),
-			multi_site_origin_algorithm => $self->paramAsScalar('ds.multi_site_origin_algorithm'),
 			ccr_dns_ttl                 => $self->paramAsScalar('ds.ccr_dns_ttl'),
 			type                        => $self->typeid(),
 			cdn_id                      => $self->paramAsScalar('ds.cdn_id'),
-			profile                     => $self->paramAsScalar('ds.profile'),
+			profile                     => ($self->paramAsScalar('ds.profile') == -1) ? undef : $self->paramAsScalar('ds.profile'),
 			global_max_mbps             => $self->hr_string_to_mbps( $self->paramAsScalar( 'ds.global_max_mbps', 0 ) ),
 			global_max_tps              => $self->paramAsScalar( 'ds.global_max_tps', 0 ),
 			miss_lat                    => $self->paramAsScalar('ds.miss_lat'),
@@ -798,7 +799,7 @@ sub update {
 			$hash{http_bypass_fqdn} = $self->param('ds.http_bypass_fqdn');
 		}
 
-		# print Dumper( \%hash );
+		print Dumper( \%hash );
 		my $update = $self->db->resultset('Deliveryservice')->find( { id => $id } );
 		$update->update( \%hash );
 		$update->update();
@@ -975,7 +976,6 @@ sub create {
 				dns_bypass_ttl              => $self->paramAsScalar('ds.dns_bypass_ttl'),
 				org_server_fqdn             => $self->paramAsScalar('ds.org_server_fqdn'),
 				multi_site_origin           => $self->paramAsScalar('ds.multi_site_origin'),
-				multi_site_origin_algorithm => $self->paramAsScalar('ds.multi_site_origin_algorithm'),
 				ccr_dns_ttl                 => $self->paramAsScalar('ds.ccr_dns_ttl'),
 				type                        => $self->paramAsScalar('ds.type'),
 				cdn_id                      => $cdn_id,
@@ -1187,6 +1187,8 @@ sub get_key_ttl {
 # for the add delivery service view
 sub add {
 	my $self = shift;
+
+	$self->stash_profile_selector();
 	&stash_role($self);
 	$self->stash(
 		fbox_layout      => 1,

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/9ede7b67/traffic_ops/app/lib/UI/Profile.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/UI/Profile.pm b/traffic_ops/app/lib/UI/Profile.pm
index 996555b..550f18b 100644
--- a/traffic_ops/app/lib/UI/Profile.pm
+++ b/traffic_ops/app/lib/UI/Profile.pm
@@ -31,40 +31,6 @@ sub index {
 	$self->stash( profile => {} );
 }
 
-# stash the cdn array for a form select.. optional second arg is the one that is selected.
-sub stash_cdn_selector {
-	my $self = shift;
-	my $selected = shift || -1;
-
-	my $rs = $self->db->resultset('Cdn')->search(undef);
-	my @cdns;
-    while ( my $row = $rs->next ) {
-    	if ($row->id == $selected) {
-			push(@cdns, [ $row->name => $row->id, selected => 'true' ] );
-    	} else {
-			push(@cdns, [ $row->name => $row->id ] );
-    	}
-	}
-	$self->stash( cdns => \@cdns );
-}
-
-# stash the profile_type array for a form select. optional second arg is the one that is selected.
-sub stash_profile_type_selector {
-	my $self = shift;
-	my $selected = shift || -1;
-
-	my $enum_possible = $self->enum_values("profile_type");
-	my @types;
-    foreach my $val ( @{$enum_possible} ) {
-    	if ($val eq $selected) {
-			push(@types, [ $val => $val , selected => 'true' ] );
-    	} else {
-			push(@types, [ $val => $val ] );
-    	}
-	}
-	$self->stash( profile_types  => \@types );
-}
-
 # for the fancybox view
 sub add {
 	my $self     = shift;

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/9ede7b67/traffic_ops/app/templates/delivery_service/_form.html.ep
----------------------------------------------------------------------
diff --git a/traffic_ops/app/templates/delivery_service/_form.html.ep b/traffic_ops/app/templates/delivery_service/_form.html.ep
index 5f1cff5..05f871b 100644
--- a/traffic_ops/app/templates/delivery_service/_form.html.ep
+++ b/traffic_ops/app/templates/delivery_service/_form.html.ep
@@ -47,7 +47,7 @@
 		<% } %>
 		%= label_for 'cdn' => '* CDN', class => 'label'
 		<% if ($priv_level >= 20) { %>
-		%= field('ds.cdn_id')->select(class => 'field', id => 'cdn', name => 'ds.cdn_id');
+		%= field('ds.cdn_id')->select( \@{$cdns} );
 		<% } else { %>
 		%= field('ds.cdn.name')->text(class => 'field', readonly => 'readonly');
 		<% }  %>
@@ -366,34 +366,13 @@
 			<% } %>
 		<% } %>
 	</div><br>
-	<div class="block form-row" id="multi_site_origin_algorithm_row">
-		<% unless (field('ds.multi_site_origin_algorithm')->valid) { %>
-			<span class="field-with-error"><%= field('ds.multi_site_origin_algorithm')->error %></span>
-		<% } %>
-		%= label_for 'multi_site_origin_algorithm' => 'Multi Site Origin Algorithm', class => 'label'
-		<% if ($priv_level >= 20) { %>
-		%= field('ds.multi_site_origin_algorithm')->select([['Consistent hash' => 0], ['Primary/backup' => 1], ['Strict round-robin' => 2], ['IP based round-robin' => 3], ['Latch on failover' => 4]]);
-		<% } else { %>
-			<% if ($ds->multi_site_origin_algorithm == 1) { %>
-				%= field('ds.multi_site_origin_algorithm')->text(class => 'field', value =>  'Primary/backup', readonly => 'readonly');
-			<% } elsif ($ds->multi_site_origin_algorithm == 2) { %>
-				%= field('ds.multi_site_origin_algorithm')->text(class => 'field', value =>  'Strict round-robin', readonly => 'readonly');
-			<% } elsif ($ds->multi_site_origin_algorithm == 3) { %>
-  			        %= field('ds.multi_site_origin_algorithm')->text(class => 'field', value =>  'IP based round-robin', readonly => 'readonly');
-			<% } elsif ($ds->multi_site_origin_algorithm == 4) { %>
-				%= field('ds.multi_site_origin_algorithm')->text(class => 'field', value =>  'Latch on failover', readonly => 'readonly');                        
-			<% } else { %>
-                %= field('ds.multi_site_origin_algorithm')->text(class => 'field', value =>  'Consistent hash', readonly => 'readonly');
-			<% } %>
-		<% } %>
-	</div>
 	<div class="block form-row" id="profile_row">
 		<% unless (field('ds.profile')->valid) { %>
 			<span class="field-with-error"><%= field('ds.profile')->error %></span>
 		<% } %>
-		%= label_for 'profile' => '* CCR profile', class => 'label'
+		%= label_for 'profile' => '* Delivery Service profile', class => 'label'
 		<% if ($priv_level >= 20) { %>
-		%= field('ds.profile')->select(class => 'field', id => 'profile', name => 'ds.profile');
+		%= field('ds.profile')->select( \@{$profiles} );
 		<% } else { %>
 		%= field('ds.profile.name')->text(class => 'field', readonly => 'readonly');
 		<% }  %>

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/9ede7b67/traffic_ops/app/templates/delivery_service/edit.html.ep
----------------------------------------------------------------------
diff --git a/traffic_ops/app/templates/delivery_service/edit.html.ep b/traffic_ops/app/templates/delivery_service/edit.html.ep
index 807fc8a..f6270ae 100644
--- a/traffic_ops/app/templates/delivery_service/edit.html.ep
+++ b/traffic_ops/app/templates/delivery_service/edit.html.ep
@@ -167,29 +167,6 @@
 			setup_form('fast');
 		}, "json");
 
-		$.get("/datadomains", function(data){
-			$.each(data, function(idx, val) {
-				if(data[idx].profile_id == "<%= $ds->profile->id %>") {
-					$("#profile").append("<option value=" + data[idx].profile_id + " selected=\"selected\">" + data[idx].profile_name +
-					" (" + data[idx].profile_description + ")</option>");
-				} else {
-					$("#profile").append("<option value=" + data[idx].profile_id + ">" + data[idx].profile_name +
-					" (" + data[idx].profile_description + ")</option>");
-				}
-			});
-		}, "json");
-
-		$.get("/api/1.2/cdns.json", function(data){
-			var response = data['response'];
-			$.each(response, function(idx, val) {
-				if (response[idx].name == "<%= $ds->cdn->name %>") {
-					$("#cdn").append("<option selected=\"selected\" value=" + response[idx].id + ">" + response[idx].name + "</option>");
-				} else {
-					$("#cdn").append("<option value=" + response[idx].id + ">" + response[idx].name + "</option>");
-				}
-			});
-		}, "json");
-
 			$('#type').change(function() {
 				show_hide_bypass_rows('slow');
 			});


[30/44] incubator-trafficcontrol git commit: Remove (or rename) the original domain_name parameter in the test fixtures.

Posted by mi...@apache.org.
Remove (or rename) the original domain_name parameter in the test fixtures.


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

Branch: refs/heads/master
Commit: 9a602f5b64642da30d50fdfeeea887e5ae8f6ae5
Parents: 85e5d8b
Author: Jan van Doorn <ja...@cable.comcast.com>
Authored: Sat Dec 31 10:23:43 2016 -0700
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:10 2017 +0000

----------------------------------------------------------------------
 .../app/lib/Fixtures/Integration/Parameter.pm   | 12 +--
 traffic_ops/app/lib/Fixtures/Parameter.pm       | 18 ++---
 .../app/lib/Fixtures/ProfileParameter.pm        | 84 ++++++++++----------
 3 files changed, 57 insertions(+), 57 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/9a602f5b/traffic_ops/app/lib/Fixtures/Integration/Parameter.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Fixtures/Integration/Parameter.pm b/traffic_ops/app/lib/Fixtures/Integration/Parameter.pm
index 53a0640..9633bdb 100644
--- a/traffic_ops/app/lib/Fixtures/Integration/Parameter.pm
+++ b/traffic_ops/app/lib/Fixtures/Integration/Parameter.pm
@@ -18,8 +18,8 @@ package Fixtures::Integration::Parameter;
 # under the License.
 
 
-# Do not edit! Generated code.
-# See https://github.com/Comcast/traffic_control/wiki/The%20Kabletown%20example
+# Note - removing the NODNAME parameter wreaks all kinds of havoc because of ordering / id problems, so I renamed
+# it to NODNAME - JvD
 
 use Moose;
 extends 'DBIx::Class::EasyFixture';
@@ -2931,7 +2931,7 @@ use namespace::autoclean;
 	'290' => {
 		new => 'Parameter',
 		using => {
-			name => 'domain_name',
+			name => 'NODNAME',
 			config_file => 'CRConfig.xml',
 			last_updated => '2015-12-10 15:43:46',
 			value => 'cdn1.kabletown.net',
@@ -2941,7 +2941,7 @@ use namespace::autoclean;
 	'291' => {
 		new => 'Parameter',
 		using => {
-			name => 'domain_name',
+			name => 'NODNAME',
 			config_file => 'CRConfig.xml',
 			last_updated => '2015-12-10 15:43:46',
 			value => 'cdn2.kabletown.net',
@@ -2951,7 +2951,7 @@ use namespace::autoclean;
 	'292' => {
 		new => 'Parameter',
 		using => {
-			name => 'domain_name',
+			name => 'NODNAME',
 			last_updated => '2015-12-10 15:43:47',
 			value => 'cdn1.kabletown.net',
 			config_file => 'CRConfig.json',
@@ -2961,7 +2961,7 @@ use namespace::autoclean;
 	'293' => {
 		new => 'Parameter',
 		using => {
-			name => 'domain_name',
+			name => 'NODNAME',
 			value => 'cdn2.kabletown.net',
 			config_file => 'CRConfig.json',
 			last_updated => '2015-12-10 15:43:47',

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/9a602f5b/traffic_ops/app/lib/Fixtures/Parameter.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Fixtures/Parameter.pm b/traffic_ops/app/lib/Fixtures/Parameter.pm
index eb121e5..d8e4d69 100644
--- a/traffic_ops/app/lib/Fixtures/Parameter.pm
+++ b/traffic_ops/app/lib/Fixtures/Parameter.pm
@@ -19,15 +19,15 @@ use namespace::autoclean;
 use Digest::SHA1 qw(sha1_hex);
 
 my %definition_for = (
-	domain_name => {
-		new   => 'Parameter',
-		using => {
-			id          => 3,
-			name        => 'domain_name',
-			value       => 'foo.com',
-			config_file => 'CRConfig.json',
-		},
-	},
+	# domain_name => {
+	# 	new   => 'Parameter',
+	# 	using => {
+	# 		id          => 3,
+	# 		name        => 'domain_name',
+	# 		value       => 'foo.com',
+	# 		config_file => 'CRConfig.json',
+	# 	},
+	# },
 	health_threadhold_loadavg => {
 		new   => 'Parameter',
 		using => {

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/9a602f5b/traffic_ops/app/lib/Fixtures/ProfileParameter.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Fixtures/ProfileParameter.pm b/traffic_ops/app/lib/Fixtures/ProfileParameter.pm
index e2503ee..20864b2 100644
--- a/traffic_ops/app/lib/Fixtures/ProfileParameter.pm
+++ b/traffic_ops/app/lib/Fixtures/ProfileParameter.pm
@@ -19,48 +19,48 @@ use namespace::autoclean;
 use Digest::SHA1 qw(sha1_hex);
 
 my %definition_for = (
-    domain_name => {
-        new   => 'ProfileParameter',
-        using => {
-            profile   => 100,
-            parameter => 3,
-        },
-    },
-    domain_name2 => {
-        new   => 'ProfileParameter',
-        using => {
-            profile   => 200,
-            parameter => 3,
-        },
-    },
-    domain_name3 => {
-        new   => 'ProfileParameter',
-        using => {
-            profile   => 300,
-            parameter => 3,
-        },
-    },
-    domain_name5 => {
-        new   => 'ProfileParameter',
-        using => {
-            profile   => 500,
-            parameter => 3,
-        },
-    },
-    domain_name6 => {
-        new   => 'ProfileParameter',
-        using => {
-            profile   => 600,
-            parameter => 3,
-        },
-    },
-    domain_name7 => {
-        new   => 'ProfileParameter',
-        using => {
-            profile   => 700,
-            parameter => 3,
-        },
-    },
+    # domain_name => {
+    #     new   => 'ProfileParameter',
+    #     using => {
+    #         profile   => 100,
+    #         parameter => 3,
+    #     },
+    # },
+    # domain_name2 => {
+    #     new   => 'ProfileParameter',
+    #     using => {
+    #         profile   => 200,
+    #         parameter => 3,
+    #     },
+    # },
+    # domain_name3 => {
+    #     new   => 'ProfileParameter',
+    #     using => {
+    #         profile   => 300,
+    #         parameter => 3,
+    #     },
+    # },
+    # domain_name5 => {
+    #     new   => 'ProfileParameter',
+    #     using => {
+    #         profile   => 500,
+    #         parameter => 3,
+    #     },
+    # },
+    # domain_name6 => {
+    #     new   => 'ProfileParameter',
+    #     using => {
+    #         profile   => 600,
+    #         parameter => 3,
+    #     },
+    # },
+    # domain_name7 => {
+    #     new   => 'ProfileParameter',
+    #     using => {
+    #         profile   => 700,
+    #         parameter => 3,
+    #     },
+    # },
     rascal_properties1 => {
         new   => 'ProfileParameter',
         using => {