use of com.netflix.simianarmy.aws.janitor.rule.generic.UntaggedRule in project SimianArmy by Netflix.
the class BasicJanitorMonkeyContext method getInstanceJanitor.
private InstanceJanitor getInstanceJanitor() {
JanitorRuleEngine ruleEngine = createJanitorRuleEngine();
if (configuration().getBoolOrElse("simianarmy.janitor.rule.orphanedInstanceRule.enabled", false)) {
ruleEngine.addRule(new OrphanedInstanceRule(monkeyCalendar, (int) configuration().getNumOrElse("simianarmy.janitor.rule.orphanedInstanceRule.instanceAgeThreshold", 2), (int) configuration().getNumOrElse("simianarmy.janitor.rule.orphanedInstanceRule.retentionDaysWithOwner", 3), (int) configuration().getNumOrElse("simianarmy.janitor.rule.orphanedInstanceRule.retentionDaysWithoutOwner", 8), configuration().getBoolOrElse("simianarmy.janitor.rule.orphanedInstanceRule.opsworks.parentage", false)));
}
if (configuration().getBoolOrElse("simianarmy.janitor.rule.untaggedRule.enabled", false) && getUntaggedRuleResourceSet().contains("INSTANCE")) {
ruleEngine.addRule(new UntaggedRule(monkeyCalendar, getPropertySet("simianarmy.janitor.rule.untaggedRule.requiredTags"), (int) configuration().getNumOrElse("simianarmy.janitor.rule.untaggedRule.retentionDaysWithOwner", 3), (int) configuration().getNumOrElse("simianarmy.janitor.rule.untaggedRule.retentionDaysWithoutOwner", 8)));
}
JanitorCrawler instanceCrawler;
if (configuration().getBoolOrElse("simianarmy.janitor.edda.enabled", false)) {
instanceCrawler = new EddaInstanceJanitorCrawler(createEddaClient(), awsClient().region());
} else {
instanceCrawler = new InstanceJanitorCrawler(awsClient());
}
BasicJanitorContext instanceJanitorCtx = new BasicJanitorContext(monkeyRegion, ruleEngine, instanceCrawler, janitorResourceTracker, monkeyCalendar, configuration(), recorder());
return new InstanceJanitor(awsClient(), instanceJanitorCtx);
}
use of com.netflix.simianarmy.aws.janitor.rule.generic.UntaggedRule in project SimianArmy by Netflix.
the class BasicJanitorMonkeyContext method getEBSVolumeJanitor.
private EBSVolumeJanitor getEBSVolumeJanitor() {
JanitorRuleEngine ruleEngine = createJanitorRuleEngine();
if (configuration().getBoolOrElse("simianarmy.janitor.rule.oldDetachedVolumeRule.enabled", false)) {
ruleEngine.addRule(new OldDetachedVolumeRule(monkeyCalendar, (int) configuration().getNumOrElse("simianarmy.janitor.rule.oldDetachedVolumeRule.detachDaysThreshold", 30), (int) configuration().getNumOrElse("simianarmy.janitor.rule.oldDetachedVolumeRule.retentionDays", 7)));
if (configuration().getBoolOrElse("simianarmy.janitor.edda.enabled", false) && configuration().getBoolOrElse("simianarmy.janitor.rule.deleteOnTerminationRule.enabled", false)) {
ruleEngine.addRule(new DeleteOnTerminationRule(monkeyCalendar, (int) configuration().getNumOrElse("simianarmy.janitor.rule.deleteOnTerminationRule.retentionDays", 3)));
}
}
if (configuration().getBoolOrElse("simianarmy.janitor.rule.untaggedRule.enabled", false) && getUntaggedRuleResourceSet().contains("EBS_VOLUME")) {
ruleEngine.addRule(new UntaggedRule(monkeyCalendar, getPropertySet("simianarmy.janitor.rule.untaggedRule.requiredTags"), (int) configuration().getNumOrElse("simianarmy.janitor.rule.untaggedRule.retentionDaysWithOwner", 3), (int) configuration().getNumOrElse("simianarmy.janitor.rule.untaggedRule.retentionDaysWithoutOwner", 8)));
}
JanitorCrawler volumeCrawler;
if (configuration().getBoolOrElse("simianarmy.janitor.edda.enabled", false)) {
volumeCrawler = new EddaEBSVolumeJanitorCrawler(createEddaClient(), awsClient().region());
} else {
volumeCrawler = new EBSVolumeJanitorCrawler(awsClient());
}
BasicJanitorContext volumeJanitorCtx = new BasicJanitorContext(monkeyRegion, ruleEngine, volumeCrawler, janitorResourceTracker, monkeyCalendar, configuration(), recorder());
return new EBSVolumeJanitor(awsClient(), volumeJanitorCtx);
}
use of com.netflix.simianarmy.aws.janitor.rule.generic.UntaggedRule in project SimianArmy by Netflix.
the class BasicJanitorMonkeyContext method getImageJanitor.
private ImageJanitor getImageJanitor() {
JanitorCrawler crawler;
if (configuration().getBoolOrElse("simianarmy.janitor.edda.enabled", false)) {
crawler = new EddaImageJanitorCrawler(createEddaClient(), configuration().getStr("simianarmy.janitor.image.ownerId"), (int) configuration().getNumOrElse("simianarmy.janitor.image.crawler.lookBackDays", 60), awsClient().region());
} else {
throw new RuntimeException("Image Janitor only works when Edda is enabled.");
}
JanitorRuleEngine ruleEngine = createJanitorRuleEngine();
if (configuration().getBoolOrElse("simianarmy.janitor.rule.unusedImageRule.enabled", false)) {
ruleEngine.addRule(new UnusedImageRule(monkeyCalendar, (int) configuration().getNumOrElse("simianarmy.janitor.rule.unusedImageRule.retentionDays", 3), (int) configuration().getNumOrElse("simianarmy.janitor.rule.unusedImageRule.lastReferenceDaysThreshold", 45)));
}
if (configuration().getBoolOrElse("simianarmy.janitor.rule.untaggedRule.enabled", false) && getUntaggedRuleResourceSet().contains("IMAGE")) {
ruleEngine.addRule(new UntaggedRule(monkeyCalendar, getPropertySet("simianarmy.janitor.rule.untaggedRule.requiredTags"), (int) configuration().getNumOrElse("simianarmy.janitor.rule.untaggedRule.retentionDaysWithOwner", 3), (int) configuration().getNumOrElse("simianarmy.janitor.rule.untaggedRule.retentionDaysWithoutOwner", 8)));
}
BasicJanitorContext janitorCtx = new BasicJanitorContext(monkeyRegion, ruleEngine, crawler, janitorResourceTracker, monkeyCalendar, configuration(), recorder());
return new ImageJanitor(awsClient(), janitorCtx);
}
use of com.netflix.simianarmy.aws.janitor.rule.generic.UntaggedRule in project SimianArmy by Netflix.
the class TestBasicJanitorMonkeyContext method testAddRuleWithUntaggedRuleResource.
@Test
public void testAddRuleWithUntaggedRuleResource() {
JanitorRuleEngine ruleEngine = new BasicJanitorRuleEngine();
Boolean untaggedRuleEnabled = new Boolean(true);
Rule rule = new UntaggedRule(monkeyCalendar, SIMIANARMY_JANITOR_RULE_UNTAGGEDRULE_REQUIREDTAGS, SIMIANARMY_JANITOR_RULE_UNTAGGEDRULE_RETENTIONDAYSWITHOWNER, SIMIANARMY_JANITOR_RULE_UNTAGGEDRULE_RETENTIONDAYSWITHOUTOWNER);
if (untaggedRuleEnabled && getUntaggedRuleResourceSet().contains("INSTANCE")) {
ruleEngine.addRule(rule);
}
Assert.assertTrue(ruleEngine.getRules().contains(rule));
}
use of com.netflix.simianarmy.aws.janitor.rule.generic.UntaggedRule in project SimianArmy by Netflix.
the class BasicJanitorMonkeyContext method getLaunchConfigJanitor.
private LaunchConfigJanitor getLaunchConfigJanitor() {
JanitorRuleEngine ruleEngine = createJanitorRuleEngine();
if (configuration().getBoolOrElse("simianarmy.janitor.rule.oldUnusedLaunchConfigRule.enabled", false)) {
ruleEngine.addRule(new OldUnusedLaunchConfigRule(monkeyCalendar, (int) configuration().getNumOrElse("simianarmy.janitor.rule.oldUnusedLaunchConfigRule.ageThreshold", 4), (int) configuration().getNumOrElse("simianarmy.janitor.rule.oldUnusedLaunchConfigRule.retentionDays", 3)));
}
if (configuration().getBoolOrElse("simianarmy.janitor.rule.untaggedRule.enabled", false) && getUntaggedRuleResourceSet().contains("LAUNCH_CONFIG")) {
ruleEngine.addRule(new UntaggedRule(monkeyCalendar, getPropertySet("simianarmy.janitor.rule.untaggedRule.requiredTags"), (int) configuration().getNumOrElse("simianarmy.janitor.rule.untaggedRule.retentionDaysWithOwner", 3), (int) configuration().getNumOrElse("simianarmy.janitor.rule.untaggedRule.retentionDaysWithoutOwner", 8)));
}
JanitorCrawler crawler;
if (configuration().getBoolOrElse("simianarmy.janitor.edda.enabled", false)) {
crawler = new EddaLaunchConfigJanitorCrawler(createEddaClient(), awsClient().region());
} else {
crawler = new LaunchConfigJanitorCrawler(awsClient());
}
BasicJanitorContext janitorCtx = new BasicJanitorContext(monkeyRegion, ruleEngine, crawler, janitorResourceTracker, monkeyCalendar, configuration(), recorder());
return new LaunchConfigJanitor(awsClient(), janitorCtx);
}
Aggregations