Apply rules: import default templates first

... to allow to override the attributes they set.

refs #7914
This commit is contained in:
Alexander A. Klimov 2020-03-18 16:31:35 +01:00
parent b06ea2bef7
commit f311dfb775
4 changed files with 8 additions and 8 deletions

View File

@ -35,6 +35,8 @@ bool Dependency::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, cons
builder.SetScope(frame.Locals->ShallowClone());
builder.SetIgnoreOnError(rule.GetIgnoreOnError());
builder.AddExpression(new ImportDefaultTemplatesExpression());
Host::Ptr host;
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
@ -52,8 +54,6 @@ bool Dependency::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, cons
builder.AddExpression(new SetExpression(MakeIndexer(ScopeThis, "package"), OpSetLiteral, MakeLiteral(rule.GetPackage()), di));
builder.AddExpression(new ImportDefaultTemplatesExpression());
builder.AddExpression(new OwnedExpression(rule.GetExpression()));
ConfigItem::Ptr dependencyItem = builder.Compile();

View File

@ -35,6 +35,8 @@ bool Notification::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, co
builder.SetScope(frame.Locals->ShallowClone());
builder.SetIgnoreOnError(rule.GetIgnoreOnError());
builder.AddExpression(new ImportDefaultTemplatesExpression());
Host::Ptr host;
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
@ -53,8 +55,6 @@ bool Notification::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, co
builder.AddExpression(new OwnedExpression(rule.GetExpression()));
builder.AddExpression(new ImportDefaultTemplatesExpression());
ConfigItem::Ptr notificationItem = builder.Compile();
notificationItem->Register();

View File

@ -34,6 +34,8 @@ bool ScheduledDowntime::EvaluateApplyRuleInstance(const Checkable::Ptr& checkabl
builder.SetScope(frame.Locals->ShallowClone());
builder.SetIgnoreOnError(rule.GetIgnoreOnError());
builder.AddExpression(new ImportDefaultTemplatesExpression());
Host::Ptr host;
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
@ -52,8 +54,6 @@ bool ScheduledDowntime::EvaluateApplyRuleInstance(const Checkable::Ptr& checkabl
builder.AddExpression(new OwnedExpression(rule.GetExpression()));
builder.AddExpression(new ImportDefaultTemplatesExpression());
ConfigItem::Ptr downtimeItem = builder.Compile();
downtimeItem->Register();

View File

@ -34,6 +34,8 @@ bool Service::EvaluateApplyRuleInstance(const Host::Ptr& host, const String& nam
builder.SetScope(frame.Locals->ShallowClone());
builder.SetIgnoreOnError(rule.GetIgnoreOnError());
builder.AddExpression(new ImportDefaultTemplatesExpression());
builder.AddExpression(new SetExpression(MakeIndexer(ScopeThis, "host_name"), OpSetLiteral, MakeLiteral(host->GetName()), di));
builder.AddExpression(new SetExpression(MakeIndexer(ScopeThis, "name"), OpSetLiteral, MakeLiteral(name), di));
@ -47,8 +49,6 @@ bool Service::EvaluateApplyRuleInstance(const Host::Ptr& host, const String& nam
builder.AddExpression(new OwnedExpression(rule.GetExpression()));
builder.AddExpression(new ImportDefaultTemplatesExpression());
ConfigItem::Ptr serviceItem = builder.Compile();
serviceItem->Register();