Search in sources :

Example 1 with UnusedImageRule

use of com.netflix.simianarmy.aws.janitor.rule.ami.UnusedImageRule 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);
}
Also used : UntaggedRule(com.netflix.simianarmy.aws.janitor.rule.generic.UntaggedRule) UnusedImageRule(com.netflix.simianarmy.aws.janitor.rule.ami.UnusedImageRule)

Aggregations

UnusedImageRule (com.netflix.simianarmy.aws.janitor.rule.ami.UnusedImageRule)1 UntaggedRule (com.netflix.simianarmy.aws.janitor.rule.generic.UntaggedRule)1