use of com.netflix.simianarmy.aws.janitor.rule.generic.UntaggedRule in project SimianArmy by Netflix.
the class BasicJanitorMonkeyContext method getASGJanitor.
private ASGJanitor getASGJanitor() {
JanitorRuleEngine ruleEngine = createJanitorRuleEngine();
boolean discoveryEnabled = configuration().getBoolOrElse("simianarmy.janitor.Eureka.enabled", false);
ASGInstanceValidator instanceValidator;
if (discoveryEnabled) {
LOGGER.info("Initializing Discovery client.");
Injector injector = Guice.createInjector(new EurekaModule());
DiscoveryClient discoveryClient = injector.getInstance(DiscoveryClient.class);
instanceValidator = new DiscoveryASGInstanceValidator(discoveryClient);
} else {
LOGGER.info("Discovery/Eureka is not enabled, use the dummy instance validator.");
instanceValidator = new DummyASGInstanceValidator();
}
if (configuration().getBoolOrElse("simianarmy.janitor.rule.oldEmptyASGRule.enabled", false)) {
ruleEngine.addRule(new OldEmptyASGRule(monkeyCalendar, (int) configuration().getNumOrElse("simianarmy.janitor.rule.oldEmptyASGRule.launchConfigAgeThreshold", 50), (int) configuration().getNumOrElse("simianarmy.janitor.rule.oldEmptyASGRule.retentionDays", 10), instanceValidator));
}
if (configuration().getBoolOrElse("simianarmy.janitor.rule.suspendedASGRule.enabled", false)) {
ruleEngine.addRule(new SuspendedASGRule(monkeyCalendar, (int) configuration().getNumOrElse("simianarmy.janitor.rule.suspendedASGRule.suspensionAgeThreshold", 2), (int) configuration().getNumOrElse("simianarmy.janitor.rule.suspendedASGRule.retentionDays", 5), instanceValidator));
}
if (configuration().getBoolOrElse("simianarmy.janitor.rule.untaggedRule.enabled", false) && getUntaggedRuleResourceSet().contains("ASG")) {
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 EddaASGJanitorCrawler(createEddaClient(), awsClient().region());
} else {
crawler = new ASGJanitorCrawler(awsClient());
}
BasicJanitorContext asgJanitorCtx = new BasicJanitorContext(monkeyRegion, ruleEngine, crawler, janitorResourceTracker, monkeyCalendar, configuration(), recorder());
return new ASGJanitor(awsClient(), asgJanitorCtx);
}
use of com.netflix.simianarmy.aws.janitor.rule.generic.UntaggedRule in project SimianArmy by Netflix.
the class BasicJanitorMonkeyContext method getEBSSnapshotJanitor.
private EBSSnapshotJanitor getEBSSnapshotJanitor() {
JanitorRuleEngine ruleEngine = createJanitorRuleEngine();
if (configuration().getBoolOrElse("simianarmy.janitor.rule.noGeneratedAMIRule.enabled", false)) {
ruleEngine.addRule(new NoGeneratedAMIRule(monkeyCalendar, (int) configuration().getNumOrElse("simianarmy.janitor.rule.noGeneratedAMIRule.ageThreshold", 30), (int) configuration().getNumOrElse("simianarmy.janitor.rule.noGeneratedAMIRule.retentionDays", 7), configuration().getStrOrElse("simianarmy.janitor.rule.noGeneratedAMIRule.ownerEmail", null)));
}
if (configuration().getBoolOrElse("simianarmy.janitor.rule.untaggedRule.enabled", false) && getUntaggedRuleResourceSet().contains("EBS_SNAPSHOT")) {
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 snapshotCrawler;
if (configuration().getBoolOrElse("simianarmy.janitor.edda.enabled", false)) {
snapshotCrawler = new EddaEBSSnapshotJanitorCrawler(configuration().getStr("simianarmy.janitor.snapshots.ownerId"), createEddaClient(), awsClient().region());
} else {
snapshotCrawler = new EBSSnapshotJanitorCrawler(awsClient());
}
BasicJanitorContext snapshotJanitorCtx = new BasicJanitorContext(monkeyRegion, ruleEngine, snapshotCrawler, janitorResourceTracker, monkeyCalendar, configuration(), recorder());
return new EBSSnapshotJanitor(awsClient(), snapshotJanitorCtx);
}
use of com.netflix.simianarmy.aws.janitor.rule.generic.UntaggedRule in project SimianArmy by Netflix.
the class TestBasicJanitorMonkeyContext method testAddRuleWithoutUntaggedRuleResource.
@Test
public void testAddRuleWithoutUntaggedRuleResource() {
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("ASG")) {
ruleEngine.addRule(rule);
}
Assert.assertFalse(ruleEngine.getRules().contains(rule));
}
Aggregations