From b47288e12151ad95c2d0986d5d8a37e74e2b0659 Mon Sep 17 00:00:00 2001 From: Jeremy Mitchell Date: Wed, 7 Jun 2017 14:59:47 -0600 Subject: [PATCH 1/3] adds api to get eligible servers for ds --- .../traffic_ops_api/v12/deliveryservice.rst | 164 +++++++++++++++++- .../app/lib/API/DeliveryServiceServer.pm | 11 +- traffic_ops/app/lib/API/Server.pm | 78 +++++++++ traffic_ops/app/lib/TrafficOpsRoutes.pm | 3 +- traffic_ops/app/t/api/1.2/deliveryservice.t | 4 +- 5 files changed, 254 insertions(+), 6 deletions(-) diff --git a/docs/source/development/traffic_ops_api/v12/deliveryservice.rst b/docs/source/development/traffic_ops_api/v12/deliveryservice.rst index df674fa6fd..da17b7b673 100644 --- a/docs/source/development/traffic_ops_api/v12/deliveryservice.rst +++ b/docs/source/development/traffic_ops_api/v12/deliveryservice.rst @@ -641,7 +641,7 @@ Delivery Service | -**GET /api/1.2/deliveryservices/:id/unassigned_servers** +**GET /api/1.2/deliveryservices/:id/servers/unassigned** Retrieves properties of CDN EDGE or ORG servers not assigned to a delivery service. @@ -797,6 +797,162 @@ Delivery Service | +**GET /api/1.2/deliveryservices/:id/servers/eligible** + + Retrieves properties of CDN EDGE or ORG servers not eligible for assignment to a delivery service. + + Authentication Required: Yes + + Role(s) Required: Admin or Operations or delivery service must be assigned to user + + **Request Route Parameters** + + +-----------------+----------+---------------------------------------------------+ + | Name | Required | Description | + +=================+==========+===================================================+ + | ``id`` | yes | Delivery service ID. | + +-----------------+----------+---------------------------------------------------+ + + **Response Properties** + + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | Parameter | Type | Description | + +====================+========+============================================================================================================+ + | ``cachegroup`` | string | The cache group name (see :ref:`to-api-v11-cachegroup`). | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``cachegroupId`` | string | The cache group id. | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``cdnId`` | string | Id of the CDN to which the server belongs to. | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``cdnName`` | string | Name of the CDN to which the server belongs to. | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``domainName`` | string | The domain name part of the FQDN of the cache. | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``guid`` | string | An identifier used to uniquely identify the server. | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``hostName`` | string | The host name part of the cache. | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``httpsPort`` | string | The HTTPS port on which the main application listens (443 in most cases). | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``id`` | string | The server id (database row number). | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``iloIpAddress`` | string | The IPv4 address of the lights-out-management port. | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``iloIpGateway`` | string | The IPv4 gateway address of the lights-out-management port. | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``iloIpNetmask`` | string | The IPv4 netmask of the lights-out-management port. | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``iloPassword`` | string | The password of the of the lights-out-management user (displays as ****** unless you are an 'admin' user). | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``iloUsername`` | string | The user name for lights-out-management. | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``interfaceMtu`` | string | The Maximum Transmission Unit (MTU) to configure for ``interfaceName``. | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``interfaceName`` | string | The network interface name used for serving traffic. | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``ip6Address`` | string | The IPv6 address/netmask for ``interfaceName``. | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``ip6Gateway`` | string | The IPv6 gateway for ``interfaceName``. | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``ipAddress`` | string | The IPv4 address for ``interfaceName``. | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``ipGateway`` | string | The IPv4 gateway for ``interfaceName``. | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``ipNetmask`` | string | The IPv4 netmask for ``interfaceName``. | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``lastUpdated`` | string | The Time and Date for the last update for this server. | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``mgmtIpAddress`` | string | The IPv4 address of the management port (optional). | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``mgmtIpGateway`` | string | The IPv4 gateway of the management port (optional). | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``mgmtIpNetmask`` | string | The IPv4 netmask of the management port (optional). | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``offlineReason`` | string | A user-entered reason why the server is in ADMIN_DOWN or OFFLINE status. | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``physLocation`` | string | The physical location name (see :ref:`to-api-v11-phys-loc`). | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``physLocationId`` | string | The physical location id (see :ref:`to-api-v11-phys-loc`). | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``profile`` | string | The assigned profile name (see :ref:`to-api-v11-profile`). | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``profileDesc`` | string | The assigned profile description (see :ref:`to-api-v11-profile`). | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``profileId`` | string | The assigned profile Id (see :ref:`to-api-v11-profile`). | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``rack`` | string | A string indicating rack location. | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``routerHostName`` | string | The human readable name of the router. | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``routerPortName`` | string | The human readable name of the router port. | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``status`` | string | The Status string (See :ref:`to-api-v11-status`). | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``statusId`` | string | The Status id (See :ref:`to-api-v11-status`). | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``tcpPort`` | string | The default TCP port on which the main application listens (80 for a cache in most cases). | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``type`` | string | The name of the type of this server (see :ref:`to-api-v11-type`). | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``typeId`` | string | The id of the type of this server (see :ref:`to-api-v11-type`). | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + | ``updPending`` | bool | | + +--------------------+--------+------------------------------------------------------------------------------------------------------------+ + + **Response Example** :: + + { + "response": [ + { + "cachegroup": "us-il-chicago", + "cachegroupId": "3", + "cdnId": "3", + "cdnName": "CDN-1", + "domainName": "chi.kabletown.net", + "guid": null, + "hostName": "atsec-chi-00", + "id": "19", + "iloIpAddress": "172.16.2.6", + "iloIpGateway": "172.16.2.1", + "iloIpNetmask": "255.255.255.0", + "iloPassword": "********", + "iloUsername": "", + "interfaceMtu": "9000", + "interfaceName": "bond0", + "ip6Address": "2033:D0D0:3300::2:2/64", + "ip6Gateway": "2033:D0D0:3300::2:1", + "ipAddress": "10.10.2.2", + "ipGateway": "10.10.2.1", + "ipNetmask": "255.255.255.0", + "lastUpdated": "2015-03-08 15:57:32", + "mgmtIpAddress": "", + "mgmtIpGateway": "", + "mgmtIpNetmask": "", + "offlineReason": "N/A", + "physLocation": "plocation-chi-1", + "physLocationId": "9", + "profile": "EDGE1_CDN1_421_SSL", + "profileDesc": "EDGE1_CDN1_421_SSL profile", + "profileId": "12", + "rack": "RR 119.02", + "routerHostName": "rtr-chi.kabletown.net", + "routerPortName": "2", + "status": "ONLINE", + "statusId": "6", + "tcpPort": "80", + "httpsPort": "443", + "type": "EDGE", + "typeId": "3", + "updPending": false + }, + { + ... more server data + } + ] + } + +| + .. _to-api-v12-ds-health: @@ -1082,12 +1238,15 @@ Delivery Service Server +---------------------------------+----------+-------------------------------------------------------------------+ | ``servers`` | yes | An array of server IDs. | +---------------------------------+----------+-------------------------------------------------------------------+ + | ``replace`` | no | Replace existing ds/server assignments? (true|false) | + +---------------------------------+----------+-------------------------------------------------------------------+ **Request Example** :: { "dsId": 246, - "servers": [ 2, 3, 4, 5, 6 ] + "servers": [ 2, 3, 4, 5, 6 ], + "replace": true } **Response Properties** @@ -1112,6 +1271,7 @@ Delivery Service Server "response": { "dsId" : 246, "servers" : [ 2, 3, 4, 5, 6 ], + "replace" : true } } diff --git a/traffic_ops/app/lib/API/DeliveryServiceServer.pm b/traffic_ops/app/lib/API/DeliveryServiceServer.pm index c07be679d8..7d4bb1cc9e 100644 --- a/traffic_ops/app/lib/API/DeliveryServiceServer.pm +++ b/traffic_ops/app/lib/API/DeliveryServiceServer.pm @@ -73,6 +73,8 @@ sub assign_servers_to_ds { my $params = $self->req->json; my $ds_id = $params->{dsId}; my $servers = $params->{servers}; + my $replace = $params->{replace}; + my $count = 0; if ( !&is_oper($self) ) { return $self->forbidden(); @@ -87,6 +89,12 @@ sub assign_servers_to_ds { return $self->not_found(); } + if ( $replace ) { + # start fresh and delete existing deliveryservice/server associations + my $delete = $self->db->resultset('DeliveryserviceServer')->search( { deliveryservice => $ds_id } ); + $delete->delete(); + } + $self->db->txn_begin(); foreach my $server (@{ $servers }) { my $server_exist = $self->db->resultset('Server')->find( { id => $server } ); @@ -97,11 +105,12 @@ sub assign_servers_to_ds { my $ds_server_exist = $self->db->resultset('DeliveryserviceServer')->find( { deliveryservice => $ds_id, server => $server } ); if ( !defined($ds_server_exist) ) { $self->db->resultset('DeliveryserviceServer')->create( { deliveryservice => $ds_id, server => $server } )->insert(); + $count++; } } $self->db->txn_commit(); - &log( $self, "Servers were assigned to " . $ds->xml_id, "APICHANGE" ); + &log( $self, $count . " servers were assigned to " . $ds->xml_id, "APICHANGE" ); my $response = $params; return $self->success($response, "Server assignments complete."); diff --git a/traffic_ops/app/lib/API/Server.pm b/traffic_ops/app/lib/API/Server.pm index 68c7273c83..8423fa1833 100644 --- a/traffic_ops/app/lib/API/Server.pm +++ b/traffic_ops/app/lib/API/Server.pm @@ -639,6 +639,84 @@ sub get_unassigned_servers_by_dsid { return $self->success( \@data ); } +sub get_eligible_servers_by_dsid { + my $self = shift; + my $ds_id = $self->param('id'); + + my $ds = $self->db->resultset('Deliveryservice')->search( { id => $ds_id } )->single(); + if ( !defined($ds) ) { + return $self->not_found(); + } + + my %ds_server_criteria; + $ds_server_criteria{'deliveryservice.id'} = $ds_id; + + if ( !&is_privileged($self) && !$self->is_delivery_service_assigned($ds_id) ) { + return $self->alert("Forbidden. Delivery service not assigned to user."); + } + + my %server_criteria; # please fetch the following... + $server_criteria{'type.name'} = [ { -like => 'EDGE%' }, { -like => 'ORG' } ]; # ...of type EDGE% or ORG... + $server_criteria{'cdn.id'} = $ds->cdn_id; # ...that belongs to the same cdn as the ds... + + my $servers = $self->db->resultset('Server')->search( + \%server_criteria, + { prefetch => [ 'cdn', 'cachegroup', 'type', 'profile', 'status', 'phys_location' ] } + ); + + my @data; + if ( defined($servers) ) { + my $is_admin = &is_admin($self); + while ( my $row = $servers->next ) { + push( + @data, { + "cachegroup" => $row->cachegroup->name, + "cachegroupId" => $row->cachegroup->id, + "cdnId" => $row->cdn->id, + "cdnName" => $row->cdn->name, + "domainName" => $row->domain_name, + "guid" => $row->guid, + "hostName" => $row->host_name, + "httpsPort" => $row->https_port, + "id" => $row->id, + "iloIpAddress" => $row->ilo_ip_address, + "iloIpNetmask" => $row->ilo_ip_netmask, + "iloIpGateway" => $row->ilo_ip_gateway, + "iloUsername" => $row->ilo_username, + "iloPassword" => $is_admin ? $row->ilo_password : "", + "interfaceMtu" => $row->interface_mtu, + "interfaceName" => $row->interface_name, + "ip6Address" => $row->ip6_address, + "ip6Gateway" => $row->ip6_gateway, + "ipAddress" => $row->ip_address, + "ipNetmask" => $row->ip_netmask, + "ipGateway" => $row->ip_gateway, + "lastUpdated" => $row->last_updated, + "mgmtIpAddress" => $row->mgmt_ip_address, + "mgmtIpNetmask" => $row->mgmt_ip_netmask, + "mgmtIpGateway" => $row->mgmt_ip_gateway, + "offlineReason" => $row->offline_reason, + "physLocation" => $row->phys_location->name, + "physLocationId" => $row->phys_location->id, + "profile" => $row->profile->name, + "profileId" => $row->profile->id, + "profileDesc" => $row->profile->description, + "rack" => $row->rack, + "routerHostName" => $row->router_host_name, + "routerPortName" => $row->router_port_name, + "status" => $row->status->name, + "statusId" => $row->status->id, + "tcpPort" => $row->tcp_port, + "type" => $row->type->name, + "typeId" => $row->type->id, + "updPending" => \$row->upd_pending + } + ); + } + } + + return $self->success( \@data ); +} sub get_servers_by_type { my $self = shift; diff --git a/traffic_ops/app/lib/TrafficOpsRoutes.pm b/traffic_ops/app/lib/TrafficOpsRoutes.pm index e4db8f29a3..0b584834cb 100644 --- a/traffic_ops/app/lib/TrafficOpsRoutes.pm +++ b/traffic_ops/app/lib/TrafficOpsRoutes.pm @@ -705,7 +705,8 @@ sub api_routes { # get all edge servers associated with a delivery service (from deliveryservice_server table) $r->get( "/api/$version/deliveryservices/:id/servers" => [ id => qr/\d+/ ] )->over( authenticated => 1 )->to( 'Server#get_edge_servers_by_dsid', namespace => $namespace ); - $r->get( "/api/$version/deliveryservices/:id/unassigned_servers" => [ id => qr/\d+/ ] )->over( authenticated => 1 )->to( 'Server#get_unassigned_servers_by_dsid', namespace => $namespace ); + $r->get( "/api/$version/deliveryservices/:id/servers/unassigned" => [ id => qr/\d+/ ] )->over( authenticated => 1 )->to( 'Server#get_unassigned_servers_by_dsid', namespace => $namespace ); + $r->get( "/api/$version/deliveryservices/:id/servers/eligible" => [ id => qr/\d+/ ] )->over( authenticated => 1 )->to( 'Server#get_eligible_servers_by_dsid', namespace => $namespace ); # alternate server routes $r->post("/api/$version/servers/create")->over( authenticated => 1 )->to( 'Server2#create', namespace => $namespace ); diff --git a/traffic_ops/app/t/api/1.2/deliveryservice.t b/traffic_ops/app/t/api/1.2/deliveryservice.t index 0f23e71f3c..ca106f7e7f 100644 --- a/traffic_ops/app/t/api/1.2/deliveryservice.t +++ b/traffic_ops/app/t/api/1.2/deliveryservice.t @@ -49,7 +49,7 @@ my $count_response = sub { }; # there are currently 3 servers of type EDGE or ORG where server.cdn == ds.cdn not assigned to ds 100 -$t->get_ok('/api/1.2/deliveryservices/100/unassigned_servers')->status_is(200)->$count_response(4) +$t->get_ok('/api/1.2/deliveryservices/100/servers/unassigned')->status_is(200)->$count_response(4) ->or( sub { diag $t->tx->res->content->asset->{content}; } ); # we will assign 2 more servers to ds 100 @@ -63,7 +63,7 @@ ok $t->post_ok('/api/1.2/deliveryserviceserver' => {Accept => 'application/json' , 'Are the servers assigned to the delivery service?'; # there are now 2 servers of type EDGE or ORG where server.cdn == ds.cdn not assigned to ds 100 -$t->get_ok('/api/1.2/deliveryservices/100/unassigned_servers')->status_is(200)->$count_response(2) +$t->get_ok('/api/1.2/deliveryservices/100/servers/unassigned')->status_is(200)->$count_response(2) ->or( sub { diag $t->tx->res->content->asset->{content}; } ); # It gets existing delivery services From 6eaa2b14611b0d7b6445b3eebe98cf64392f0695 Mon Sep 17 00:00:00 2001 From: Jeremy Mitchell Date: Wed, 7 Jun 2017 15:18:24 -0600 Subject: [PATCH 2/3] changes the way servers are assigned to ds's. always shows all servers and puts a checkmark next to currently assigned servers --- .../src/common/api/DeliveryServiceService.js | 4 +- .../ui/app/src/common/api/ServerService.js | 6 +- .../TableDSServersUnassignedController.js | 59 +++++++++++++++---- .../TableDeliveryServiceServersController.js | 10 ++-- .../table.dsServersUnassigned.tpl.html | 6 +- 5 files changed, 64 insertions(+), 21 deletions(-) diff --git a/traffic_ops/experimental/ui/app/src/common/api/DeliveryServiceService.js b/traffic_ops/experimental/ui/app/src/common/api/DeliveryServiceService.js index 7c35224b6c..165d32012d 100644 --- a/traffic_ops/experimental/ui/app/src/common/api/DeliveryServiceService.js +++ b/traffic_ops/experimental/ui/app/src/common/api/DeliveryServiceService.js @@ -84,8 +84,8 @@ var DeliveryServiceService = function(Restangular, locationUtils, httpService, m ); }; - this.assignDeliveryServiceServers = function(dsServerMappings) { - return Restangular.service('deliveryserviceserver').post(dsServerMappings) + this.assignDeliveryServiceServers = function(dsId, servers) { + return Restangular.service('deliveryserviceserver').post( { dsId: dsId, servers: servers, replace: true }) .then( function() { messageModel.setMessages([ { level: 'success', text: 'Servers linked to delivery service' } ], false); diff --git a/traffic_ops/experimental/ui/app/src/common/api/ServerService.js b/traffic_ops/experimental/ui/app/src/common/api/ServerService.js index de05a0e2f7..3aaffedafc 100644 --- a/traffic_ops/experimental/ui/app/src/common/api/ServerService.js +++ b/traffic_ops/experimental/ui/app/src/common/api/ServerService.js @@ -69,7 +69,11 @@ var ServerService = function($http, $q, Restangular, locationUtils, messageModel }; this.getUnassignedDeliveryServiceServers = function(dsId) { - return Restangular.one('deliveryservices', dsId).getList('unassigned_servers'); + return Restangular.one('deliveryservices', dsId).getList('servers/unassigned'); + }; + + this.getEligibleDeliveryServiceServers = function(dsId) { + return Restangular.one('deliveryservices', dsId).getList('servers/eligible'); }; this.queueServerUpdates = function(id) { diff --git a/traffic_ops/experimental/ui/app/src/common/modules/table/deliveryServiceServers/TableDSServersUnassignedController.js b/traffic_ops/experimental/ui/app/src/common/modules/table/deliveryServiceServers/TableDSServersUnassignedController.js index a73059c4e3..ac7c42fb6a 100644 --- a/traffic_ops/experimental/ui/app/src/common/modules/table/deliveryServiceServers/TableDSServersUnassignedController.js +++ b/traffic_ops/experimental/ui/app/src/common/modules/table/deliveryServiceServers/TableDSServersUnassignedController.js @@ -17,22 +17,59 @@ * under the License. */ -var TableDSServersUnassignedController = function(deliveryService, servers, $scope, $uibModalInstance) { +var TableDSServersUnassignedController = function(deliveryService, eligibleServers, assignedServers, $scope, $uibModalInstance) { - var selectedServers = []; - - $scope.deliveryService = deliveryService; - - $scope.unassignedServers = servers; + var selectedServerIds = []; var addServer = function(serverId) { - if (_.indexOf(selectedServers, serverId) == -1) { - selectedServers.push(serverId); + if (_.indexOf(selectedServerIds, serverId) == -1) { + selectedServerIds.push(serverId); } }; var removeServer = function(serverId) { - selectedServers = _.without(selectedServers, serverId); + selectedServerIds = _.without(selectedServerIds, serverId); + }; + + var addAll = function() { + markServers(true); + selectedServerIds = _.pluck(eligibleServers, 'id'); + }; + + var removeAll = function() { + markServers(false); + selectedServerIds = []; + }; + + var markServers = function(selected) { + $scope.selectedServers = _.map(eligibleServers, function(server) { + server['selected'] = selected; + return server; + }); + }; + + $scope.deliveryService = deliveryService; + + $scope.selectedServers = _.map(eligibleServers, function(eligibleServer) { + var isAssigned = _.find(assignedServers, function(assignedServer) { return assignedServer.id == eligibleServer.id }); + if (isAssigned) { + eligibleServer['selected'] = true; // so the checkbox will be checked + selectedServerIds.push(eligibleServer.id); // so the server is added to selected servers + } + return eligibleServer; + }); + + $scope.allSelected = function() { + return eligibleServers.length == selectedServerIds.length; + }; + + $scope.selectAll = function($event) { + var checkbox = $event.target; + if (checkbox.checked) { + addAll(); + } else { + removeAll(); + } }; $scope.updateServers = function($event, serverId) { @@ -45,7 +82,7 @@ var TableDSServersUnassignedController = function(deliveryService, servers, $sco }; $scope.submit = function() { - $uibModalInstance.close(selectedServers); + $uibModalInstance.close(selectedServerIds); }; $scope.cancel = function () { @@ -66,5 +103,5 @@ var TableDSServersUnassignedController = function(deliveryService, servers, $sco }; -TableDSServersUnassignedController.$inject = ['deliveryService', 'servers', '$scope', '$uibModalInstance']; +TableDSServersUnassignedController.$inject = ['deliveryService', 'eligibleServers', 'assignedServers', '$scope', '$uibModalInstance']; module.exports = TableDSServersUnassignedController; diff --git a/traffic_ops/experimental/ui/app/src/common/modules/table/deliveryServiceServers/TableDeliveryServiceServersController.js b/traffic_ops/experimental/ui/app/src/common/modules/table/deliveryServiceServers/TableDeliveryServiceServersController.js index ec56313064..f27aaadbd3 100644 --- a/traffic_ops/experimental/ui/app/src/common/modules/table/deliveryServiceServers/TableDeliveryServiceServersController.js +++ b/traffic_ops/experimental/ui/app/src/common/modules/table/deliveryServiceServers/TableDeliveryServiceServersController.js @@ -45,14 +45,16 @@ var TableDeliveryServiceServersController = function(deliveryService, servers, $ deliveryService: function() { return deliveryService; }, - servers: function(serverService) { - return serverService.getUnassignedDeliveryServiceServers(deliveryService.id); + eligibleServers: function(serverService) { + return serverService.getEligibleDeliveryServiceServers(deliveryService.id); + }, + assignedServers: function() { + return servers; } } }); modalInstance.result.then(function(selectedServerIds) { - var serverAssignments = { dsId: deliveryService.id, servers: selectedServerIds }; - deliveryServiceService.assignDeliveryServiceServers(serverAssignments) + deliveryServiceService.assignDeliveryServiceServers(deliveryService.id, selectedServerIds) .then( function() { $scope.refresh(); diff --git a/traffic_ops/experimental/ui/app/src/common/modules/table/deliveryServiceServers/table.dsServersUnassigned.tpl.html b/traffic_ops/experimental/ui/app/src/common/modules/table/deliveryServiceServers/table.dsServersUnassigned.tpl.html index 0e43889b23..7c15cf144b 100644 --- a/traffic_ops/experimental/ui/app/src/common/modules/table/deliveryServiceServers/table.dsServersUnassigned.tpl.html +++ b/traffic_ops/experimental/ui/app/src/common/modules/table/deliveryServiceServers/table.dsServersUnassigned.tpl.html @@ -27,15 +27,15 @@ - + - - + + From be029bbf325d80a45859ab4c84c67cf934944209 Mon Sep 17 00:00:00 2001 From: Jeremy Mitchell Date: Wed, 7 Jun 2017 15:52:51 -0600 Subject: [PATCH 3/3] checks the count of eligible servers that can be assigned to a ds 100 --- traffic_ops/app/t/api/1.2/deliveryservice.t | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/traffic_ops/app/t/api/1.2/deliveryservice.t b/traffic_ops/app/t/api/1.2/deliveryservice.t index ca106f7e7f..58134afa91 100644 --- a/traffic_ops/app/t/api/1.2/deliveryservice.t +++ b/traffic_ops/app/t/api/1.2/deliveryservice.t @@ -66,6 +66,10 @@ ok $t->post_ok('/api/1.2/deliveryserviceserver' => {Accept => 'application/json' $t->get_ok('/api/1.2/deliveryservices/100/servers/unassigned')->status_is(200)->$count_response(2) ->or( sub { diag $t->tx->res->content->asset->{content}; } ); +# there are currently 6 servers of type EDGE or ORG that can be assigned to ds 100 +$t->get_ok('/api/1.2/deliveryservices/100/servers/eligible')->status_is(200)->$count_response(6) + ->or( sub { diag $t->tx->res->content->asset->{content}; } ); + # It gets existing delivery services ok $t->get_ok("/api/1.2/deliveryservices/list")->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content} } ) ->json_is( "/response/0/xmlId", "steering-ds1" )
hostName cachegroup profile
{{::server.hostName}} {{::server.cachegroup}} {{::server.profile}}