Search in sources :

Example 31 with AutoScalingGroup

use of com.amazonaws.services.autoscaling.model.AutoScalingGroup in project SimianArmy by Netflix.

the class TestASGChaosCrawler method testGetInstanceGroup_basic.

@Test
public void testGetInstanceGroup_basic() {
    AutoScalingGroup asg = mkAsg("asg1", "i-123456789012345670");
    InstanceGroup group = crawler.getInstanceGroup(asg, 1.0);
    Assert.assertTrue((group instanceof BasicInstanceGroup));
    Assert.assertFalse((group instanceof TunableInstanceGroup));
}
Also used : AutoScalingGroup(com.amazonaws.services.autoscaling.model.AutoScalingGroup) TunableInstanceGroup(com.netflix.simianarmy.tunable.TunableInstanceGroup) BasicInstanceGroup(com.netflix.simianarmy.basic.chaos.BasicInstanceGroup) InstanceGroup(com.netflix.simianarmy.chaos.ChaosCrawler.InstanceGroup) TunableInstanceGroup(com.netflix.simianarmy.tunable.TunableInstanceGroup) BasicInstanceGroup(com.netflix.simianarmy.basic.chaos.BasicInstanceGroup) Test(org.testng.annotations.Test)

Example 32 with AutoScalingGroup

use of com.amazonaws.services.autoscaling.model.AutoScalingGroup in project SimianArmy by Netflix.

the class TestVSpehereClient method flattenGroups.

private String flattenGroups(List<AutoScalingGroup> groups) {
    StringBuilder buf = new StringBuilder();
    for (AutoScalingGroup asg : groups) {
        List<Instance> instances = asg.getInstances();
        buf.append("group:").append(asg.getAutoScalingGroupName()).append(":");
        for (Instance instance : instances) {
            buf.append("id:").append(instance.getInstanceId()).append(":");
        }
    }
    return buf.toString();
}
Also used : AutoScalingGroup(com.amazonaws.services.autoscaling.model.AutoScalingGroup) Instance(com.amazonaws.services.autoscaling.model.Instance)

Example 33 with AutoScalingGroup

use of com.amazonaws.services.autoscaling.model.AutoScalingGroup in project SimianArmy by Netflix.

the class TestVSphereGroups method shouldReturnListContainigTwoASGWhenAddInstanceIsCalledTwice.

@Test
public void shouldReturnListContainigTwoASGWhenAddInstanceIsCalledTwice() {
    VSphereGroups groups = new VSphereGroups();
    groups.addInstance("anyInstanceId", "anyGroupName");
    groups.addInstance("anyOtherInstanceId", "anyOtherGroupName");
    List<AutoScalingGroup> list = groups.asList();
    assertEquals(2, list.size());
    AutoScalingGroup firstGroup = list.get(0);
    assertEquals("anyGroupName", firstGroup.getAutoScalingGroupName());
    List<Instance> firstGroupInstances = firstGroup.getInstances();
    assertEquals(1, firstGroupInstances.size());
    assertEquals("anyInstanceId", firstGroupInstances.get(0).getInstanceId());
    AutoScalingGroup secondGroup = list.get(1);
    assertEquals("anyOtherGroupName", secondGroup.getAutoScalingGroupName());
    List<Instance> secondGroupInstances = secondGroup.getInstances();
    assertEquals(1, secondGroupInstances.size());
    assertEquals("anyOtherInstanceId", secondGroupInstances.get(0).getInstanceId());
}
Also used : AutoScalingGroup(com.amazonaws.services.autoscaling.model.AutoScalingGroup) Instance(com.amazonaws.services.autoscaling.model.Instance) Test(org.testng.annotations.Test)

Example 34 with AutoScalingGroup

use of com.amazonaws.services.autoscaling.model.AutoScalingGroup 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: {}, asgAccount: {}", asgName, 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);
    }
}
Also used : DescribeAutoScalingGroupsRequest(com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsRequest) AutoScalingGroup(com.amazonaws.services.autoscaling.model.AutoScalingGroup) AmazonAutoScalingClient(com.amazonaws.services.autoscaling.AmazonAutoScalingClient) BasicSessionCredentials(com.amazonaws.auth.BasicSessionCredentials) AmazonAutoScaling(com.amazonaws.services.autoscaling.AmazonAutoScaling) DescribeAutoScalingGroupsResult(com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsResult) Credentials(com.amazonaws.services.securitytoken.model.Credentials) BasicSessionCredentials(com.amazonaws.auth.BasicSessionCredentials) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) ClientConfiguration(com.amazonaws.ClientConfiguration)

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