List of usage examples for com.amazonaws.services.ecs AmazonECS describeServices
DescribeServicesResult describeServices(DescribeServicesRequest describeServicesRequest);
Describes the specified services running in your cluster.
From source file:com.netflix.spinnaker.clouddriver.ecs.controllers.servergroup.EcsServerGroupController.java
License:Apache License
@RequestMapping(value = "/events", method = RequestMethod.GET) ResponseEntity getServerGroupEvents(@PathVariable String account, @PathVariable String serverGroupName, @RequestParam(value = "region", required = true) String region) { NetflixAmazonCredentials credentials = (NetflixAmazonCredentials) accountCredentialsProvider .getCredentials(account);//from ww w . j a v a 2s .c o m if (!(credentials instanceof NetflixECSCredentials)) { return new ResponseEntity(String.format("Account %s is not an ECS account", account), HttpStatus.BAD_REQUEST); } AmazonECS ecs = amazonClientProvider.getAmazonEcs(credentials, region, true); Service cachedService = serviceCacheClient.getAll(account, region).stream() .filter(service -> service.getServiceName().equals(serverGroupName)).findFirst().get(); DescribeServicesResult describeServicesResult = ecs.describeServices(new DescribeServicesRequest() .withServices(serverGroupName).withCluster(cachedService.getClusterArn())); if (describeServicesResult.getServices().size() == 0) { return new ResponseEntity( String.format("Server group %s was not found in account ", serverGroupName, account), HttpStatus.NOT_FOUND); } List<ServiceEvent> rawEvents = describeServicesResult.getServices().get(0).getEvents(); List<EcsServerGroupEvent> events = new ArrayList<>(); for (ServiceEvent rawEvent : rawEvents) { EcsServerGroupEvent newEvent = new EcsServerGroupEvent(rawEvent.getMessage(), rawEvent.getCreatedAt(), rawEvent.getId(), statusConverter.inferEventStatus(rawEvent)); events.add(newEvent); } return new ResponseEntity(events, HttpStatus.OK); }
From source file:com.netflix.spinnaker.clouddriver.ecs.provider.agent.ServiceCachingAgent.java
License:Apache License
@Override protected List<Service> getItems(AmazonECS ecs, ProviderCache providerCache) { List<Service> serviceList = new LinkedList<>(); Set<String> clusters = getClusters(ecs, providerCache); for (String cluster : clusters) { String nextToken = null;/* w w w. j a v a2s . c o m*/ do { ListServicesRequest listServicesRequest = new ListServicesRequest().withCluster(cluster); if (nextToken != null) { listServicesRequest.setNextToken(nextToken); } ListServicesResult listServicesResult = ecs.listServices(listServicesRequest); List<String> serviceArns = listServicesResult.getServiceArns(); if (serviceArns.size() == 0) { continue; } List<Service> services = ecs .describeServices( new DescribeServicesRequest().withCluster(cluster).withServices(serviceArns)) .getServices(); serviceList.addAll(services); nextToken = listServicesResult.getNextToken(); } while (nextToken != null && nextToken.length() != 0); } return serviceList; }