use of com.amazonaws.services.autoscaling.model.TagDescription in project SimianArmy by Netflix.
the class TestASGChaosCrawler method testFindAggressionCoefficient_null.
@Test
public void testFindAggressionCoefficient_null() {
AutoScalingGroup asg1 = mkAsg("asg1", "i-123456789012345670");
Set<TagDescription> tagDescriptions = new HashSet<>();
tagDescriptions.add(makeTunableTag(null));
asg1.setTags(tagDescriptions);
double aggression = crawler.findAggressionCoefficient(asg1);
Assert.assertEquals(aggression, 1.0);
}
use of com.amazonaws.services.autoscaling.model.TagDescription in project SimianArmy by Netflix.
the class TestASGChaosCrawler method makeTunableTag.
private TagDescription makeTunableTag(String value) {
TagDescription desc = new TagDescription();
desc.setKey("chaosMonkey.aggressionCoefficient");
desc.setValue(value);
return desc;
}
use of com.amazonaws.services.autoscaling.model.TagDescription in project SimianArmy by Netflix.
the class TestFilterASGChaosCrawler method testFilterGroups.
@Test
public void testFilterGroups() {
List<TagDescription> tagList = new ArrayList<TagDescription>();
TagDescription td = new TagDescription();
td.setKey(tagKey);
td.setValue(tagValue);
tagList.add(td);
List<InstanceGroup> listGroup = new LinkedList<InstanceGroup>();
listGroup.add(new BasicInstanceGroup("asg1", Types.ASG, "region1", tagList));
listGroup.add(new BasicInstanceGroup("asg2", Types.ASG, "region2", Collections.<TagDescription>emptyList()));
listGroup.add(new BasicInstanceGroup("asg3", Types.ASG, "region3", tagList));
listGroup.add(new BasicInstanceGroup("asg4", Types.ASG, "region4", Collections.<TagDescription>emptyList()));
when(crawlerMock.groups()).thenReturn(listGroup);
List<InstanceGroup> groups = crawlerMock.groups();
assertEquals(groups.size(), 4);
groups = crawler.groups();
assertEquals(groups.size(), 2);
assertEquals(groups.get(0).name(), "asg1");
assertEquals(groups.get(1).name(), "asg3");
}
use of com.amazonaws.services.autoscaling.model.TagDescription 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.TagDescription in project SimianArmy by Netflix.
the class TestASGOwnerEmailTag method makeASG.
private AutoScalingGroup makeASG(String asgName, String ownerEmail) {
TagDescription tag = new TagDescription().withKey(OWNER_TAG_KEY).withValue(ownerEmail);
AutoScalingGroup asg = new AutoScalingGroup().withAutoScalingGroupName(asgName).withTags(tag);
return asg;
}
Aggregations