You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by jv...@apache.org on 2017/02/27 17:16:47 UTC

[04/20] incubator-trafficcontrol git commit: fixes for CDN DS data and schema file and stop passing scope when not needed

fixes for CDN DS data and schema file and stop passing scope when not needed


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

Branch: refs/heads/master
Commit: f8538165a7a8711ba8fe810c0219bc4366df6106
Parents: 253350a
Author: Derek Gelinas <de...@cable.comcast.com>
Authored: Thu Jan 19 13:33:55 2017 -0500
Committer: Jan van Doorn <jv...@apache.org>
Committed: Mon Feb 27 16:57:46 2017 +0000

----------------------------------------------------------------------
 .../app/lib/API/Configs/ApacheTrafficServer.pm  | 88 ++++++++------------
 .../Result/DeliveryServiceInfoForCdnList.pm     |  8 +-
 2 files changed, 37 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/f8538165/traffic_ops/app/lib/API/Configs/ApacheTrafficServer.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/Configs/ApacheTrafficServer.pm b/traffic_ops/app/lib/API/Configs/ApacheTrafficServer.pm
index 3c97d57..caf1836 100644
--- a/traffic_ops/app/lib/API/Configs/ApacheTrafficServer.pm
+++ b/traffic_ops/app/lib/API/Configs/ApacheTrafficServer.pm
@@ -108,20 +108,20 @@ sub get_server_config {
 
 	#generate the config file using the appropriate function
 	my $file_contents;
-	if ( $filename eq "12M_facts" ) { $file_contents = $self->facts( $server_obj, $filename, $scope ); }
-	elsif ( $filename =~ /to_ext_.*\.config/ ) { $file_contents = $self->to_ext_dot_config( $server_obj, $filename, $scope ); }
-	elsif ( $filename eq "ip_allow.config" ) { $file_contents = $self->ip_allow_dot_config( $server_obj, $filename, $scope ); }
-	elsif ( $filename eq "parent.config" ) { $file_contents = $self->parent_dot_config( $server_obj, $filename, $scope ); }
-	elsif ( $filename eq "records.config" ) { $file_contents = $self->generic_server_config( $server_obj, $filename, $scope ); }
-	elsif ( $filename eq "remap.config" ) { $file_contents = $self->remap_dot_config( $server_obj, $filename, $scope ); }
-	elsif ( $filename eq "hosting.config" ) { $file_contents = $self->hosting_dot_config( $server_obj, $filename, $scope ); }
-	elsif ( $filename eq "cache.config" ) { $file_contents = $self->cache_dot_config( $server_obj, $filename, $scope ); }
+	if ( $filename eq "12M_facts" ) { $file_contents = $self->facts( $server_obj, $filename ); }
+	elsif ( $filename =~ /to_ext_.*\.config/ ) { $file_contents = $self->to_ext_dot_config( $server_obj, $filename ); }
+	elsif ( $filename eq "ip_allow.config" ) { $file_contents = $self->ip_allow_dot_config( $server_obj, $filename ); }
+	elsif ( $filename eq "parent.config" ) { $file_contents = $self->parent_dot_config( $server_obj, $filename ); }
+	elsif ( $filename eq "records.config" ) { $file_contents = $self->generic_server_config( $server_obj, $filename ); }
+	elsif ( $filename eq "remap.config" ) { $file_contents = $self->remap_dot_config( $server_obj, $filename ); }
+	elsif ( $filename eq "hosting.config" ) { $file_contents = $self->hosting_dot_config( $server_obj, $filename ); }
+	elsif ( $filename eq "cache.config" ) { $file_contents = $self->cache_dot_config( $server_obj, $filename ); }
 	elsif ( $filename eq "packages" ) {
-		$file_contents = $self->get_package_versions( $server_obj, $filename, $scope );
+		$file_contents = $self->get_package_versions( $server_obj, $filename );
 		$file_contents = encode_json($file_contents);
 	}
 	elsif ( $filename eq "chkconfig" ) {
-		$file_contents = $self->get_chkconfig( $server_obj, $filename, $scope );
+		$file_contents = $self->get_chkconfig( $server_obj, $filename );
 		$file_contents = encode_json($file_contents);
 	}
 	else {
@@ -129,7 +129,7 @@ sub get_server_config {
 		if ( !defined($file_param) ) {
 			return $self->not_found();
 		}
-		$file_contents = $self->take_and_bake_server( $server_obj, $filename, $scope );
+		$file_contents = $self->take_and_bake_server( $server_obj, $filename );
 	}
 
 	#if we get an empty file, just send back an error.
@@ -166,13 +166,13 @@ sub get_cdn_config {
 
 	#generate the config file using the appropriate function
 	my $file_contents;
-	if ( $filename eq "bg_fetch.config" ) { $file_contents = $self->bg_fetch_dot_config( $cdn_obj, $filename, $scope ); }
-	elsif ( $filename =~ /cacheurl.*\.config/ ) { $file_contents = $self->cacheurl_dot_config( $cdn_obj, $filename, $scope ); }
-	elsif ( $filename =~ /hdr_rw_.*\.config/ ) { $file_contents = $self->header_rewrite_dot_config( $cdn_obj, $filename, $scope ); }
-	elsif ( $filename =~ /regex_remap_.*\.config/ ) { $file_contents = $self->regex_remap_dot_config( $cdn_obj, $filename, $scope ); }
-	elsif ( $filename eq "regex_revalidate.config" ) { $file_contents = $self->regex_revalidate_dot_config( $cdn_obj, $filename, $scope ); }
-	elsif ( $filename =~ /set_dscp_.*\.config/ ) { $file_contents = $self->set_dscp_dot_config( $cdn_obj, $filename, $scope ); }
-	elsif ( $filename eq "ssl_multicert.config" ) { $file_contents = $self->ssl_multicert_dot_config( $cdn_obj, $filename, $scope ); }
+	if ( $filename eq "bg_fetch.config" ) { $file_contents = $self->bg_fetch_dot_config( $cdn_obj, $filename ); }
+	elsif ( $filename =~ /cacheurl.*\.config/ ) { $file_contents = $self->cacheurl_dot_config( $cdn_obj, $filename ); }
+	elsif ( $filename =~ /hdr_rw_.*\.config/ ) { $file_contents = $self->header_rewrite_dot_config( $cdn_obj, $filename ); }
+	elsif ( $filename =~ /regex_remap_.*\.config/ ) { $file_contents = $self->regex_remap_dot_config( $cdn_obj, $filename ); }
+	elsif ( $filename eq "regex_revalidate.config" ) { $file_contents = $self->regex_revalidate_dot_config( $cdn_obj, $filename ); }
+	elsif ( $filename =~ /set_dscp_.*\.config/ ) { $file_contents = $self->set_dscp_dot_config( $cdn_obj, $filename ); }
+	elsif ( $filename eq "ssl_multicert.config" ) { $file_contents = $self->ssl_multicert_dot_config( $cdn_obj, $filename ); }
 	else                                          { return $self->not_found(); }
 
 	if ( !defined($file_contents) ) {
@@ -207,21 +207,21 @@ sub get_profile_config {
 
 	#generate the config file using the appropriate function
 	my $file_contents;
-	if ( $filename eq "50-ats.rules" ) { $file_contents = $self->ats_dot_rules( $profile_obj, $filename, $scope ); }
-	elsif ( $filename eq "astats.config" ) { $file_contents = $self->generic_profile_config( $profile_obj, $filename, $scope ); }
-	elsif ( $filename eq "drop_qstring.config" ) { $file_contents = $self->drop_qstring_dot_config( $profile_obj, $filename, $scope ); }
-	elsif ( $filename eq "logs_xml.config" ) { $file_contents = $self->logs_xml_dot_config( $profile_obj, $filename, $scope ); }
-	elsif ( $filename eq "plugin.config" ) { $file_contents = $self->generic_profile_config( $profile_obj, $filename, $scope ); }
-	elsif ( $filename eq "storage.config" ) { $file_contents = $self->storage_dot_config( $profile_obj, $filename, $scope ); }
-	elsif ( $filename eq "sysctl.conf" ) { $file_contents = $self->generic_profile_config( $profile_obj, $filename, $scope ); }
-	elsif ( $filename =~ /url_sig_.*\.config/ ) { $file_contents = $self->url_sig_dot_config( $profile_obj, $filename, $scope ); }
-	elsif ( $filename eq "volume.config" ) { $file_contents = $self->volume_dot_config( $profile_obj, $filename, $scope ); }
+	if ( $filename eq "50-ats.rules" ) { $file_contents = $self->ats_dot_rules( $profile_obj, $filename ); }
+	elsif ( $filename eq "astats.config" ) { $file_contents = $self->generic_profile_config( $profile_obj, $filename ); }
+	elsif ( $filename eq "drop_qstring.config" ) { $file_contents = $self->drop_qstring_dot_config( $profile_obj, $filename ); }
+	elsif ( $filename eq "logs_xml.config" ) { $file_contents = $self->logs_xml_dot_config( $profile_obj, $filename ); }
+	elsif ( $filename eq "plugin.config" ) { $file_contents = $self->generic_profile_config( $profile_obj, $filename ); }
+	elsif ( $filename eq "storage.config" ) { $file_contents = $self->storage_dot_config( $profile_obj, $filename ); }
+	elsif ( $filename eq "sysctl.conf" ) { $file_contents = $self->generic_profile_config( $profile_obj, $filename ); }
+	elsif ( $filename =~ /url_sig_.*\.config/ ) { $file_contents = $self->url_sig_dot_config( $profile_obj, $filename ); }
+	elsif ( $filename eq "volume.config" ) { $file_contents = $self->volume_dot_config( $profile_obj, $filename ); }
 	else {
 		my $file_param = $self->db->resultset('Parameter')->search( [ config_file => $filename ] )->single;
 		if ( !defined($file_param) ) {
 			return $self->not_found();
 		}
-		$file_contents = $self->take_and_bake_profile( $profile_obj, $filename, $scope );
+		$file_contents = $self->take_and_bake_profile( $profile_obj, $filename );
 	}
 
 	if ( !defined($file_contents) ) {
@@ -451,7 +451,11 @@ sub cdn_ds_data {
 
 		if ( $re_type eq 'HOST_REGEXP' ) {
 			my $host_re = $row->pattern;
-			my $map_to  = $org_server . "/";
+			#my $map_to  = $org_server . "/";
+			my $map_to;
+			if ( defined($org_server) ) {
+				$map_to  = $org_server . "/";
+			}
 			if ( $host_re =~ /\.\*$/ ) {
 				my $re = $host_re;
 				$re =~ s/\\//g;
@@ -667,7 +671,6 @@ sub facts {
 	my $self       = shift;
 	my $server_obj = shift;
 	my $filename   = shift;
-	my $scope      = shift;
 	my $text       = $self->header_comment( $server_obj->host_name );
 	$text .= "profile:" . $server_obj->profile->name . "\n";
 
@@ -679,7 +682,6 @@ sub take_and_bake_server {
 	my $self       = shift;
 	my $server_obj = shift;
 	my $filename   = shift;
-	my $scope      = shift;
 
 	my $data = $self->param_data( $server_obj, $filename );
 	my $text = $self->header_comment( $server_obj->host_name );
@@ -694,7 +696,6 @@ sub take_and_bake_profile {
 	my $self        = shift;
 	my $profile_obj = shift;
 	my $filename    = shift;
-	my $scope       = shift;
 
 	my $data = $self->profile_param_data( $profile_obj->id, $filename );
 	my $text = $self->header_comment( $profile_obj->name );
@@ -710,7 +711,6 @@ sub generic_profile_config {
 	my $self        = shift;
 	my $profile_obj = shift;
 	my $filename    = shift;
-	my $scope       = shift;
 
 	my $sep = defined( $separator->{$filename} ) ? $separator->{$filename} : " = ";
 
@@ -731,7 +731,6 @@ sub generic_server_config {
 	my $self       = shift;
 	my $server_obj = shift;
 	my $filename   = shift;
-	my $scope      = shift;
 
 	my $sep = defined( $separator->{$filename} ) ? $separator->{$filename} : " = ";
 
@@ -750,7 +749,6 @@ sub ats_dot_rules {
 	my $self        = shift;
 	my $profile_obj = shift;
 	my $filename    = shift;
-	my $scope       = shift;
 
 	my $text = $self->header_comment( $profile_obj->name );
 	my $data = $self->profile_param_data( $profile_obj->id, "storage.config" );    # ats.rules is based on the storage.config params
@@ -777,7 +775,6 @@ sub drop_qstring_dot_config {
 	my $self        = shift;
 	my $profile_obj = shift;
 	my $filename    = shift;
-	my $scope       = shift;
 
 	my $text = $self->header_comment( $profile_obj->name );
 
@@ -797,7 +794,6 @@ sub logs_xml_dot_config {
 	my $self        = shift;
 	my $profile_obj = shift;
 	my $filename    = shift;
-	my $scope       = shift;
 
 	my $data = $self->profile_param_data( $profile_obj->id, "logs_xml.config" );
 	my $text = $self->header_comment( $profile_obj->name );
@@ -846,7 +842,6 @@ sub storage_dot_config {
 	my $self        = shift;
 	my $profile_obj = shift;
 	my $filename    = shift;
-	my $scope       = shift;
 
 	my $text = $self->header_comment( $profile_obj->name );
 	my $data = $self->profile_param_data( $profile_obj->id, "storage.config" );
@@ -874,7 +869,6 @@ sub to_ext_dot_config {
 	my $self       = shift;
 	my $server_obj = shift;
 	my $filename   = shift;
-	my $scope      = shift;
 
 	my $text = $self->header_comment( $server_obj->host_name );
 
@@ -921,7 +915,6 @@ sub volume_dot_config {
 	my $self        = shift;
 	my $profile_obj = shift;
 	my $filename    = shift;
-	my $scope       = shift;
 
 	my $data = $self->profile_param_data( $profile_obj->id, "storage.config" );
 	my $text = $self->header_comment( $profile_obj->name );
@@ -951,7 +944,6 @@ sub bg_fetch_dot_config {
 	my $self     = shift;
 	my $cdn_obj  = shift;
 	my $filename = shift;
-	my $scope    = shift;
 
 	my $text = $self->header_comment( $cdn_obj->name );
 	$text .= "include User-Agent *\n";
@@ -963,7 +955,6 @@ sub header_rewrite_dot_config {
 	my $self     = shift;
 	my $cdn_obj  = shift;
 	my $filename = shift;
-	my $scope    = shift;
 
 	my $text      = $self->header_comment( $cdn_obj->name );
 	my $ds_xml_id = undef;
@@ -989,7 +980,6 @@ sub cacheurl_dot_config {
 	my $self     = shift;
 	my $cdn_obj  = shift;
 	my $filename = shift;
-	my $scope    = shift;
 
 	my $text = $self->header_comment( $cdn_obj->name );
 	my $data = $self->cdn_ds_data( $cdn_obj->id );
@@ -1026,7 +1016,6 @@ sub regex_remap_dot_config {
 	my $self     = shift;
 	my $cdn_obj  = shift;
 	my $filename = shift;
-	my $scope    = shift;
 
 	my $text = $self->header_comment( $cdn_obj->name );
 
@@ -1045,7 +1034,6 @@ sub regex_revalidate_dot_config {
 	my $self     = shift;
 	my $cdn_obj  = shift;
 	my $filename = shift;
-	my $scope    = shift;
 
 	my $text = "# DO NOT EDIT - Generated for CDN " . $cdn_obj->name . " by " . &name_version_string($self) . " on " . `date`;
 
@@ -1120,7 +1108,6 @@ sub set_dscp_dot_config {
 	my $self     = shift;
 	my $cdn_obj  = shift;
 	my $filename = shift;
-	my $scope    = shift;
 
 	my $text = $self->header_comment( $cdn_obj->name );
 	my $dscp_decimal;
@@ -1139,7 +1126,6 @@ sub ssl_multicert_dot_config {
 	my $self     = shift;
 	my $cdn_obj  = shift;
 	my $filename = shift;
-	my $scope    = shift;
 
 	my $text = $self->header_comment( $cdn_obj->name );
 
@@ -1173,7 +1159,6 @@ sub url_sig_dot_config {
 	my $self        = shift;
 	my $profile_obj = shift;
 	my $filename    = shift;
-	my $scope       = shift;
 
 	my $sep = defined( $separator->{$filename} ) ? $separator->{$filename} : " = ";
 	my $data = $self->profile_param_data( $profile_obj->id, $filename );
@@ -1205,7 +1190,6 @@ sub cache_dot_config {
 	my $self       = shift;
 	my $server_obj = shift;
 	my $filename   = shift;
-	my $scope      = shift;
 
 	my $text = $self->header_comment( $server_obj->host_name );
 	my $data = $self->ds_data($server_obj);
@@ -1225,7 +1209,6 @@ sub hosting_dot_config {
 	my $self       = shift;
 	my $server_obj = shift;
 	my $filename   = shift;
-	my $scope      = shift;
 
 	my $storage_data = $self->param_data( $server_obj, "storage.config" );
 	my $text = $self->header_comment( $server_obj->host_name );
@@ -1409,7 +1392,6 @@ sub ip_allow_dot_config {
 	my $self       = shift;
 	my $server_obj = shift;
 	my $filename   = shift;
-	my $scope      = shift;
 
 	my $text = $self->header_comment( $server_obj->host_name );
 	my $data = $self->ip_allow_data( $server_obj, $filename );
@@ -1555,7 +1537,6 @@ sub parent_dot_config {
 	my $self       = shift;
 	my $server_obj = shift;
 	my $filename   = shift;
-	my $scope      = shift;
 
 	my $data;
 
@@ -1756,7 +1737,6 @@ sub remap_dot_config {
 	my $self       = shift;
 	my $server_obj = shift;
 	my $filename   = shift;
-	my $scope      = shift;
 	my $data;
 
 	my $pdata = $self->param_data( $server_obj, 'package' );
@@ -1933,7 +1913,6 @@ sub get_package_versions {
 	my $self       = shift;
 	my $server_obj = shift;
 	my $filename   = shift;
-	my $scope      = shift;
 
 	my $host_name = $server_obj->host_name;
 	my $data_obj = __get_json_parameter_list_by_host( $self, $host_name, "package", "name", "version" );
@@ -1945,7 +1924,6 @@ sub get_chkconfig {
 	my $self       = shift;
 	my $server_obj = shift;
 	my $filename   = shift;
-	my $scope      = shift;
 
 	my $host_name = $server_obj->host_name;
 	my $data_obj = __get_json_parameter_list_by_host( $self, $host_name, "chkconfig" );

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/f8538165/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForCdnList.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForCdnList.pm b/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForCdnList.pm
index e6d6787..8c842e1 100644
--- a/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForCdnList.pm
+++ b/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForCdnList.pm
@@ -39,7 +39,7 @@ __PACKAGE__->result_source_instance->is_virtual(1);
 __PACKAGE__->result_source_instance->view_definition( "
 SELECT
     deliveryservice.xml_id,
-    deliveryservice.id,
+    deliveryservice.id AS ds_id,
     deliveryservice.dscp,
     deliveryservice.signed,
     deliveryservice.qstring_ignore,
@@ -49,9 +49,9 @@ SELECT
     deliveryservice.range_request_handling,
     deliveryservice.origin_shield,
     regex.pattern,
-    retype.name,
-    dstype.name,
-    parameter.value,
+    retype.name AS re_type,
+    dstype.name AS ds_type,
+    parameter.value AS domain_name,
     deliveryservice_regex.set_number,
     deliveryservice.edge_header_rewrite,
     deliveryservice.mid_header_rewrite,