use of com.amazonaws.services.autoscaling.AmazonAutoScalingClient in project SimianArmy by Netflix.
the class AWSClient method describeAutoScalingInstances.
/**
* Describe a set of specific auto-scaling instances.
*
* @param instanceIds the instance ids
* @return the instances
*/
public List<AutoScalingInstanceDetails> describeAutoScalingInstances(String... instanceIds) {
if (instanceIds == null || instanceIds.length == 0) {
LOGGER.info(String.format("Getting all auto-scaling instances in region %s.", region));
} else {
LOGGER.info(String.format("Getting auto-scaling instances for %d ids in region %s.", instanceIds.length, region));
}
List<AutoScalingInstanceDetails> instances = new LinkedList<AutoScalingInstanceDetails>();
AmazonAutoScalingClient asgClient = asgClient();
DescribeAutoScalingInstancesRequest request = new DescribeAutoScalingInstancesRequest();
if (instanceIds != null) {
request.setInstanceIds(Arrays.asList(instanceIds));
}
DescribeAutoScalingInstancesResult result = asgClient.describeAutoScalingInstances(request);
instances.addAll(result.getAutoScalingInstances());
while (result.getNextToken() != null) {
request = request.withNextToken(result.getNextToken());
result = asgClient.describeAutoScalingInstances(request);
instances.addAll(result.getAutoScalingInstances());
}
LOGGER.info(String.format("Got %d auto-scaling instances.", instances.size()));
return instances;
}
use of com.amazonaws.services.autoscaling.AmazonAutoScalingClient in project SimianArmy by Netflix.
the class AWSClient method describeLaunchConfigurations.
/**
* Describe a set of specific launch configurations.
*
* @param names the launch configuration names
* @return the launch configurations
*/
public List<LaunchConfiguration> describeLaunchConfigurations(String... names) {
if (names == null || names.length == 0) {
LOGGER.info(String.format("Getting all launch configurations in region %s.", region));
} else {
LOGGER.info(String.format("Getting launch configurations for %d names in region %s.", names.length, region));
}
List<LaunchConfiguration> lcs = new LinkedList<LaunchConfiguration>();
AmazonAutoScalingClient asgClient = asgClient();
DescribeLaunchConfigurationsRequest request = new DescribeLaunchConfigurationsRequest().withLaunchConfigurationNames(names);
DescribeLaunchConfigurationsResult result = asgClient.describeLaunchConfigurations(request);
lcs.addAll(result.getLaunchConfigurations());
while (result.getNextToken() != null) {
request.setNextToken(result.getNextToken());
result = asgClient.describeLaunchConfigurations(request);
lcs.addAll(result.getLaunchConfigurations());
}
LOGGER.info(String.format("Got %d launch configurations in region %s.", lcs.size(), region));
return lcs;
}
use of com.amazonaws.services.autoscaling.AmazonAutoScalingClient in project eureka by Netflix.
the class AwsAsgUtil method retrieveAutoScalingGroupCrossAccount.
private AutoScalingGroup retrieveAutoScalingGroupCrossAccount(String asgAccount, String asgName) {
logger.debug("Getting cross account ASG for asgName: " + asgName + ", asgAccount: " + asgAccount);
Credentials credentials = stsCredentials.get(asgAccount);
if (credentials == null || credentials.getExpiration().getTime() < System.currentTimeMillis() + 1000) {
stsCredentials.put(asgAccount, initializeStsSession(asgAccount));
credentials = stsCredentials.get(asgAccount);
}
ClientConfiguration clientConfiguration = new ClientConfiguration().withConnectionTimeout(serverConfig.getASGQueryTimeoutMs());
AmazonAutoScaling autoScalingClient = new AmazonAutoScalingClient(new BasicSessionCredentials(credentials.getAccessKeyId(), credentials.getSecretAccessKey(), credentials.getSessionToken()), clientConfiguration);
String region = clientConfig.getRegion();
if (!region.equals("us-east-1")) {
autoScalingClient.setEndpoint("autoscaling." + region + ".amazonaws.com");
}
DescribeAutoScalingGroupsRequest request = new DescribeAutoScalingGroupsRequest().withAutoScalingGroupNames(asgName);
DescribeAutoScalingGroupsResult result = autoScalingClient.describeAutoScalingGroups(request);
List<AutoScalingGroup> asgs = result.getAutoScalingGroups();
if (asgs.isEmpty()) {
return null;
} else {
return asgs.get(0);
}
}
Aggregations