use of com.amazonaws.services.autoscaling.model.AutoScalingGroup in project SimianArmy by Netflix.
the class LaunchConfigJanitorCrawler method getLaunchConfigResources.
private List<Resource> getLaunchConfigResources(String... launchConfigNames) {
List<Resource> resources = Lists.newArrayList();
AWSClient awsClient = getAWSClient();
Set<String> usedLCs = Sets.newHashSet();
for (AutoScalingGroup asg : awsClient.describeAutoScalingGroups()) {
usedLCs.add(asg.getLaunchConfigurationName());
}
for (LaunchConfiguration launchConfiguration : awsClient.describeLaunchConfigurations(launchConfigNames)) {
String lcName = launchConfiguration.getLaunchConfigurationName();
Resource lcResource = new AWSResource().withId(lcName).withRegion(getAWSClient().region()).withResourceType(AWSResourceType.LAUNCH_CONFIG).withLaunchTime(launchConfiguration.getCreatedTime());
lcResource.setOwnerEmail(getOwnerEmailForResource(lcResource));
lcResource.setAdditionalField(LAUNCH_CONFIG_FIELD_USED_BY_ASG, String.valueOf(usedLCs.contains(lcName)));
resources.add(lcResource);
}
return resources;
}
use of com.amazonaws.services.autoscaling.model.AutoScalingGroup in project SimianArmy by Netflix.
the class ASGChaosCrawler method groups.
@Override
public List<InstanceGroup> groups(String... names) {
List<InstanceGroup> list = new LinkedList<InstanceGroup>();
for (AutoScalingGroup asg : awsClient.describeAutoScalingGroups(names)) {
InstanceGroup ig = getInstanceGroup(asg, findAggressionCoefficient(asg));
for (Instance inst : asg.getInstances()) {
ig.addInstance(inst.getInstanceId());
}
list.add(ig);
}
return list;
}
use of com.amazonaws.services.autoscaling.model.AutoScalingGroup in project SimianArmy by Netflix.
the class VSphereGroups method addInstance.
/**
* Add the given instance to the named group.
*/
public void addInstance(final String instanceId, final String groupName) {
if (!map.containsKey(groupName)) {
final AutoScalingGroup asg = new AutoScalingGroup();
asg.setAutoScalingGroupName(groupName);
map.put(groupName, asg);
}
final AutoScalingGroup asg = map.get(groupName);
Instance instance = new Instance();
instance.setInstanceId(instanceId);
asg.getInstances().add(instance);
}
use of com.amazonaws.services.autoscaling.model.AutoScalingGroup in project SimianArmy by Netflix.
the class TestASGJanitorCrawler method testInstancesWithResourceType.
@Test
public void testInstancesWithResourceType() {
List<AutoScalingGroup> asgList = createASGList();
AWSClient awsMock = createMockAWSClient(asgList);
ASGJanitorCrawler crawler = new ASGJanitorCrawler(awsMock);
for (AWSResourceType resourceType : AWSResourceType.values()) {
List<Resource> resources = crawler.resources(resourceType);
if (resourceType == AWSResourceType.ASG) {
verifyASGList(resources, asgList);
} else {
Assert.assertTrue(resources.isEmpty());
}
}
}
use of com.amazonaws.services.autoscaling.model.AutoScalingGroup in project SimianArmy by Netflix.
the class TestASGJanitorCrawler method testInstancesWithNames.
@Test
public void testInstancesWithNames() {
List<AutoScalingGroup> asgList = createASGList();
String[] asgNames = { "asg1", "asg2" };
AWSClient awsMock = createMockAWSClient(asgList, asgNames);
ASGJanitorCrawler crawler = new ASGJanitorCrawler(awsMock);
List<Resource> resources = crawler.resources(asgNames);
verifyASGList(resources, asgList);
}
Aggregations