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));
}
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();
}
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());
}
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);
}
}
Aggregations