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/07/25 18:56:42 UTC

[11/17] incubator-trafficcontrol git commit: DS tenancy - fixes due to moving TenantUtils

DS tenancy - fixes due to moving TenantUtils


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

Branch: refs/heads/master
Commit: 1b11995c3cc39413cd48e5cc912c4e725cd80d64
Parents: fda2a92
Author: nir-sopher <ni...@qwilt.com>
Authored: Mon Jun 26 21:28:51 2017 +0300
Committer: Jeremy Mitchell <mi...@gmail.com>
Committed: Tue Jul 25 12:55:59 2017 -0600

----------------------------------------------------------------------
 traffic_ops/app/lib/API/Deliveryservice.pm | 16 ++++++++--------
 traffic_ops/app/lib/UI/Cdn.pm              |  2 +-
 traffic_ops/app/lib/UI/DeliveryService.pm  |  5 +++--
 3 files changed, 12 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/1b11995c/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 e60b066..b0c2b25 100644
--- a/traffic_ops/app/lib/API/Deliveryservice.pm
+++ b/traffic_ops/app/lib/API/Deliveryservice.pm
@@ -54,7 +54,7 @@ sub index {
 		$criteria{'me.logs_enabled'} = $logs_enabled ? 1 : 0;    # converts bool to 0|1
 	}
 
-	my $tenant_utils = UI::TenantUtils->new($self);
+	my $tenant_utils = Utils::Tenant->new($self);
 	my $tenants_data = $tenant_utils->create_tenants_data_from_db();
 
 	if ( !&is_privileged($self) and !$tenant_utils->ignore_ds_users_table()) {
@@ -158,7 +158,7 @@ sub show {
 	my $current_user = $self->current_user()->{username};
 	my @data;
 
-	my $tenant_utils = UI::TenantUtils->new($self);
+	my $tenant_utils = Utils::Tenant->new($self);
 	my $tenants_data = $tenant_utils->create_tenants_data_from_db();
 
 	if ( !&is_privileged($self) and !$tenant_utils->ignore_ds_users_table()) {
@@ -288,7 +288,7 @@ sub update {
 		return $self->not_found();
 	}
 
-	my $tenant_utils = UI::TenantUtils->new($self);
+	my $tenant_utils = Utils::Tenant->new($self);
 	my $tenants_data = $tenant_utils->create_tenants_data_from_db();
 	if (!$tenant_utils->is_ds_resource_accessible($tenants_data, $ds->tenant_id)) {
 		return $self->forbidden();
@@ -784,7 +784,7 @@ sub delete {
 		return $self->not_found();
 	}
 
-	my $tenant_utils = UI::TenantUtils->new($self);
+	my $tenant_utils = Utils::Tenant->new($self);
 	my $tenants_data = $tenant_utils->create_tenants_data_from_db();
 	#setting tenant_id to the user id if tenant is not set.
 	my $tenant_id = $ds->tenant_id;
@@ -1027,7 +1027,7 @@ sub routing {
 	my $id = $self->param('id');
 
 	if ( $self->is_valid_delivery_service($id) ) {
-		my $tenant_utils = UI::TenantUtils->new($self);
+		my $tenant_utils = Utils::Tenant->new($self);
 		my $tenants_data = $tenant_utils->create_tenants_data_from_db();
 		if ( $self->is_delivery_service_assigned($id) || $tenant_utils->ignore_ds_users_table() || &is_admin($self) || &is_oper($self) ) {
 			my $result = $self->db->resultset("Deliveryservice")->search( { 'me.id' => $id }, { prefetch => [ 'cdn', 'type' ] } )->single();
@@ -1067,7 +1067,7 @@ sub capacity {
 	my $id = $self->param('id');
 
 	if ( $self->is_valid_delivery_service($id) ) {
-		my $tenant_utils = UI::TenantUtils->new($self);
+		my $tenant_utils = Utils::Tenant->new($self);
 		my $tenants_data = $tenant_utils->create_tenants_data_from_db();
 		if ( $self->is_delivery_service_assigned($id) || $tenant_utils->ignore_ds_users_table() || &is_admin($self) || &is_oper($self) ) {
 			my $result = $self->db->resultset("Deliveryservice")->search( { 'me.id' => $id }, { prefetch => ['cdn'] } )->single();
@@ -1092,7 +1092,7 @@ sub health {
 	my $id   = $self->param('id');
 
 	if ( $self->is_valid_delivery_service($id) ) {
-		my $tenant_utils = UI::TenantUtils->new($self);
+		my $tenant_utils = Utils::Tenant->new($self);
 		my $tenants_data = $tenant_utils->create_tenants_data_from_db();
 		if ( $self->is_delivery_service_assigned($id) || $tenant_utils->ignore_ds_users_table() || &is_admin($self) || &is_oper($self) ) {
 			my $result = $self->db->resultset("Deliveryservice")->search( { 'me.id' => $id }, { prefetch => ['cdn'] } )->single();
@@ -1118,7 +1118,7 @@ sub state {
 	my $id   = $self->param('id');
 
 	if ( $self->is_valid_delivery_service($id) ) {
-		my $tenant_utils = UI::TenantUtils->new($self);
+		my $tenant_utils = Utils::Tenant->new($self);
 		my $tenants_data = $tenant_utils->create_tenants_data_from_db();
 		if ( $self->is_delivery_service_assigned($id) || $tenant_utils->ignore_ds_users_table() || &is_admin($self) || &is_oper($self) ) {
 			my $result      = $self->db->resultset("Deliveryservice")->search( { 'me.id' => $id }, { prefetch => ['cdn'] } )->single();

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/1b11995c/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 cfc940f..c3a27ac 100644
--- a/traffic_ops/app/lib/UI/Cdn.pm
+++ b/traffic_ops/app/lib/UI/Cdn.pm
@@ -464,7 +464,7 @@ sub adeliveryservice {
         }
     );
 
-    my $tenant_utils = UI::TenantUtils->new($self);
+    my $tenant_utils = Utils::Tenant->new($self);
     my $tenants_data = $tenant_utils->create_tenants_data_from_db();
 
     while ( my $row = $rs->next ) {

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/1b11995c/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 63af8e3..c516b9d 100644
--- a/traffic_ops/app/lib/UI/DeliveryService.pm
+++ b/traffic_ops/app/lib/UI/DeliveryService.pm
@@ -1010,7 +1010,8 @@ sub create {
 	$self->stash_cdn_selector();
 	&stash_role($self);
 	if ( $self->check_deliveryservice_input($cdn_id) ) {
-		my $tenantUtils = Utils::Tenant->new($self);
+		my $tenant_utils = Utils::Tenant->new($self);
+		my $tenant_id = $tenant_utils->current_user_tenant();
 		my $insert = $self->db->resultset('Deliveryservice')->create(
 			{
 				xml_id                      => $self->paramAsScalar('ds.xml_id'),
@@ -1056,7 +1057,7 @@ sub create {
 				remap_text         => $self->paramAsScalar( 'ds.remap_text',         undef ),
 				initial_dispersion => $self->paramAsScalar( 'ds.initial_dispersion', 1 ),
 				logs_enabled       => $self->paramAsScalar('ds.logs_enabled'),
-				tenant_id => $tenantUtils->current_user_tenant(),#Tenancy is not dealt by the UI for now. getting the tenancy from the user
+				tenant_id => $tenant_id,
 			}
 		);
 		$insert->insert();