Search in sources :

Example 6 with AutoScalingGroup

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;
}
Also used : AutoScalingGroup(com.amazonaws.services.autoscaling.model.AutoScalingGroup) LaunchConfiguration(com.amazonaws.services.autoscaling.model.LaunchConfiguration) AWSResource(com.netflix.simianarmy.aws.AWSResource) Resource(com.netflix.simianarmy.Resource) AWSResource(com.netflix.simianarmy.aws.AWSResource) AWSClient(com.netflix.simianarmy.client.aws.AWSClient)

Example 7 with AutoScalingGroup

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;
}
Also used : AutoScalingGroup(com.amazonaws.services.autoscaling.model.AutoScalingGroup) Instance(com.amazonaws.services.autoscaling.model.Instance) LinkedList(java.util.LinkedList) TunableInstanceGroup(com.netflix.simianarmy.tunable.TunableInstanceGroup) BasicInstanceGroup(com.netflix.simianarmy.basic.chaos.BasicInstanceGroup)

Example 8 with AutoScalingGroup

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);
}
Also used : AutoScalingGroup(com.amazonaws.services.autoscaling.model.AutoScalingGroup) Instance(com.amazonaws.services.autoscaling.model.Instance)

Example 9 with AutoScalingGroup

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());
        }
    }
}
Also used : AutoScalingGroup(com.amazonaws.services.autoscaling.model.AutoScalingGroup) AWSResourceType(com.netflix.simianarmy.aws.AWSResourceType) Resource(com.netflix.simianarmy.Resource) AWSClient(com.netflix.simianarmy.client.aws.AWSClient) Test(org.testng.annotations.Test)

Example 10 with AutoScalingGroup

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);
}
Also used : AutoScalingGroup(com.amazonaws.services.autoscaling.model.AutoScalingGroup) Resource(com.netflix.simianarmy.Resource) AWSClient(com.netflix.simianarmy.client.aws.AWSClient) Test(org.testng.annotations.Test)

Aggregations

AutoScalingGroup (com.amazonaws.services.autoscaling.model.AutoScalingGroup)34 Test (org.testng.annotations.Test)16 AWSClient (com.netflix.simianarmy.client.aws.AWSClient)11 Instance (com.amazonaws.services.autoscaling.model.Instance)9 TagDescription (com.amazonaws.services.autoscaling.model.TagDescription)9 Resource (com.netflix.simianarmy.Resource)8 DescribeAutoScalingGroupsRequest (com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsRequest)5 DescribeAutoScalingGroupsResult (com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsResult)4 HashSet (java.util.HashSet)4 SuspendedProcess (com.amazonaws.services.autoscaling.model.SuspendedProcess)3 LoadBalancerDescription (com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription)3 BasicInstanceGroup (com.netflix.simianarmy.basic.chaos.BasicInstanceGroup)3 TunableInstanceGroup (com.netflix.simianarmy.tunable.TunableInstanceGroup)3 AmazonAutoScaling (com.amazonaws.services.autoscaling.AmazonAutoScaling)2 AmazonAutoScalingClient (com.amazonaws.services.autoscaling.AmazonAutoScalingClient)2 LaunchConfiguration (com.amazonaws.services.autoscaling.model.LaunchConfiguration)2 AWSResource (com.netflix.simianarmy.aws.AWSResource)2 InstanceGroup (com.netflix.simianarmy.chaos.ChaosCrawler.InstanceGroup)2 Cluster (com.netflix.simianarmy.conformity.Cluster)2 ArrayList (java.util.ArrayList)2