use of com.amazonaws.services.autoscaling.model.AutoScalingGroup in project SimianArmy by Netflix.
the class TestELBJanitorCrawler method mkASG.
private AutoScalingGroup mkASG(String asgName, String elb) {
AutoScalingGroup asg = new AutoScalingGroup().withAutoScalingGroupName(asgName);
asg.setLoadBalancerNames(Arrays.asList(elb));
return asg;
}
use of com.amazonaws.services.autoscaling.model.AutoScalingGroup in project SimianArmy by Netflix.
the class TestELBJanitorCrawler method testElbsWithMultipleReferencedASGs.
@Test
public void testElbsWithMultipleReferencedASGs() {
boolean includeInstances = true;
boolean includeELbs = false;
AWSClient client = createMockAWSClient();
List<LoadBalancerDescription> elbs = createELBList(includeInstances);
List<AutoScalingGroup> asgs = createASGList(includeELbs);
asgs.get(0).setLoadBalancerNames(Arrays.asList("elb1", "elb2"));
addELBsToMock(client, elbs);
addASGsToMock(client, asgs);
ELBJanitorCrawler crawler = new ELBJanitorCrawler(client);
List<Resource> resources = crawler.resources();
verifyELBList(resources, elbs, 1);
}
use of com.amazonaws.services.autoscaling.model.AutoScalingGroup in project SimianArmy by Netflix.
the class TestASGJanitorCrawler method testInstancesWithNullNames.
@Test
public void testInstancesWithNullNames() {
List<AutoScalingGroup> asgList = createASGList();
AWSClient awsMock = createMockAWSClient(asgList);
ASGJanitorCrawler crawler = new ASGJanitorCrawler(awsMock);
List<Resource> resources = crawler.resources();
verifyASGList(resources, asgList);
}
use of com.amazonaws.services.autoscaling.model.AutoScalingGroup in project SimianArmy by Netflix.
the class ASGJanitorCrawler method getASGResources.
private List<Resource> getASGResources(String... asgNames) {
AWSClient awsClient = getAWSClient();
List<LaunchConfiguration> launchConfigurations = awsClient.describeLaunchConfigurations();
for (LaunchConfiguration lc : launchConfigurations) {
nameToLaunchConfig.put(lc.getLaunchConfigurationName(), lc);
}
List<Resource> resources = new LinkedList<Resource>();
for (AutoScalingGroup asg : awsClient.describeAutoScalingGroups(asgNames)) {
Resource asgResource = new AWSResource().withId(asg.getAutoScalingGroupName()).withResourceType(AWSResourceType.ASG).withRegion(awsClient.region()).withLaunchTime(asg.getCreatedTime());
for (TagDescription tag : asg.getTags()) {
asgResource.setTag(tag.getKey(), tag.getValue());
}
asgResource.setDescription(String.format("%d instances", asg.getInstances().size()));
asgResource.setOwnerEmail(getOwnerEmailForResource(asgResource));
if (asg.getStatus() != null) {
((AWSResource) asgResource).setAWSResourceState(asg.getStatus());
}
Integer maxSize = asg.getMaxSize();
if (maxSize != null) {
asgResource.setAdditionalField(ASG_FIELD_MAX_SIZE, String.valueOf(maxSize));
}
// Adds instances and ELBs as additional fields.
List<String> instances = new ArrayList<String>();
for (Instance instance : asg.getInstances()) {
instances.add(instance.getInstanceId());
}
asgResource.setAdditionalField(ASG_FIELD_INSTANCES, StringUtils.join(instances, ","));
asgResource.setAdditionalField(ASG_FIELD_ELBS, StringUtils.join(asg.getLoadBalancerNames(), ","));
String lcName = asg.getLaunchConfigurationName();
LaunchConfiguration lc = nameToLaunchConfig.get(lcName);
if (lc != null) {
asgResource.setAdditionalField(ASG_FIELD_LC_NAME, lcName);
}
if (lc != null && lc.getCreatedTime() != null) {
asgResource.setAdditionalField(ASG_FIELD_LC_CREATION_TIME, String.valueOf(lc.getCreatedTime().getTime()));
}
// sets the field for the time when the ASG's traffic is suspended from ELB
for (SuspendedProcess sp : asg.getSuspendedProcesses()) {
if ("AddToLoadBalancer".equals(sp.getProcessName())) {
String suspensionTime = getSuspensionTimeString(sp.getSuspensionReason());
if (suspensionTime != null) {
LOGGER.info(String.format("Suspension time of ASG %s is %s", asg.getAutoScalingGroupName(), suspensionTime));
asgResource.setAdditionalField(ASG_FIELD_SUSPENSION_TIME, suspensionTime);
break;
}
}
}
resources.add(asgResource);
}
return resources;
}
use of com.amazonaws.services.autoscaling.model.AutoScalingGroup in project SimianArmy by Netflix.
the class TestASGChaosCrawler method mkAsg.
private AutoScalingGroup mkAsg(String asgName, String instanceId) {
AutoScalingGroup asg = new AutoScalingGroup();
asg.setAutoScalingGroupName(asgName);
Instance inst = new Instance();
inst.setInstanceId(instanceId);
asg.setInstances(Arrays.asList(inst));
return asg;
}
Aggregations