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

[03/13] incubator-trafficcontrol git commit: provides the ability to filter servers by phys location

provides the ability to filter servers by phys location


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

Branch: refs/heads/master
Commit: 489981758bcf216ff2bc79646203b21a31f60594
Parents: a991ef9
Author: Jeremy Mitchell <mi...@gmail.com>
Authored: Thu Dec 29 09:45:03 2016 -0700
Committer: Jeremy Mitchell <mi...@gmail.com>
Committed: Thu Dec 29 09:45:03 2016 -0700

----------------------------------------------------------------------
 .../development/traffic_ops_api/v12/server.rst   |  2 ++
 traffic_ops/app/lib/API/Server.pm                | 19 +++++++++++++++++++
 2 files changed, 21 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/48998175/docs/source/development/traffic_ops_api/v12/server.rst
----------------------------------------------------------------------
diff --git a/docs/source/development/traffic_ops_api/v12/server.rst b/docs/source/development/traffic_ops_api/v12/server.rst
index 3700160..0ddc0d1 100644
--- a/docs/source/development/traffic_ops_api/v12/server.rst
+++ b/docs/source/development/traffic_ops_api/v12/server.rst
@@ -44,6 +44,8 @@ Server
   +--------------------+----------+---------------------------------------------+
   | ``profileId``      | no       | Used to filter servers by profile.          |
   +--------------------+----------+---------------------------------------------+
+  | ``physLocation``   | no       | Used to filter servers by phys location ID. |
+  +--------------------+----------+---------------------------------------------+
 
   **Response Properties**
 

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/48998175/traffic_ops/app/lib/API/Server.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/Server.pm b/traffic_ops/app/lib/API/Server.pm
index 0a3a905..90ab79e 100644
--- a/traffic_ops/app/lib/API/Server.pm
+++ b/traffic_ops/app/lib/API/Server.pm
@@ -38,6 +38,7 @@ sub index {
 	my $profile_id   = $self->param('profileId');
 	my $cdn_id       = $self->param('cdnId');
 	my $cg_id        = $self->param('cachegroupId');
+	my $phys_loc_id	 = $self->param('physLocation');
 
 	my $servers;
 	my $forbidden;
@@ -59,6 +60,9 @@ sub index {
 	elsif ( defined $cg_id ) {
 		( $forbidden, $servers ) = $self->get_servers_by_cachegroup($cg_id);
 	}
+	elsif ( defined $phys_loc_id ) {
+		( $forbidden, $servers ) = $self->get_servers_by_phys_loc($phys_loc_id);
+	}
 	else {
 		$servers = $self->get_servers_by_status( $current_user, $status );
 	}
@@ -779,6 +783,21 @@ sub get_servers_by_cdn {
 	return ( $forbidden, $servers );
 }
 
+sub get_servers_by_phys_loc {
+	my $self   			= shift;
+	my $phys_loc_id 	= shift;
+
+	my $forbidden;
+	my $servers;
+	if ( !&is_oper($self) ) {
+		$forbidden = "Forbidden. You must have the operations role to perform this operation.";
+		return ( $forbidden, $servers );
+	}
+
+	my $servers = $self->db->resultset('Server')->search( { phys_location => $phys_loc_id } );
+	return ( $forbidden, $servers );
+}
+
 sub get_servers_by_cachegroup {
 	my $self  = shift;
 	my $cg_id = shift;