mirror of https://github.com/Icinga/icinga2.git
Fix variable scope for object rules
This commit is contained in:
parent
83e6fb3083
commit
f69f7d61f2
|
@ -65,10 +65,7 @@ void ObjectRule::AddRule(const String& sourceType, const String& name,
|
||||||
|
|
||||||
bool ObjectRule::EvaluateFilter(const Dictionary::Ptr& scope) const
|
bool ObjectRule::EvaluateFilter(const Dictionary::Ptr& scope) const
|
||||||
{
|
{
|
||||||
scope->Set("__parent", m_Scope);
|
return m_Filter->Evaluate(scope);
|
||||||
bool result = m_Filter->Evaluate(scope);
|
|
||||||
scope->Remove("__parent");
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectRule::EvaluateRules(bool clear)
|
void ObjectRule::EvaluateRules(bool clear)
|
||||||
|
|
|
@ -46,6 +46,7 @@ bool HostGroup::EvaluateObjectRuleOne(const Host::Ptr& host, const ObjectRule& r
|
||||||
CONTEXT(msgbuf.str());
|
CONTEXT(msgbuf.str());
|
||||||
|
|
||||||
Dictionary::Ptr locals = make_shared<Dictionary>();
|
Dictionary::Ptr locals = make_shared<Dictionary>();
|
||||||
|
locals->Set("__parent", rule.GetScope());
|
||||||
locals->Set("host", host);
|
locals->Set("host", host);
|
||||||
|
|
||||||
if (!rule.EvaluateFilter(locals))
|
if (!rule.EvaluateFilter(locals))
|
||||||
|
|
|
@ -48,6 +48,7 @@ bool ServiceGroup::EvaluateObjectRuleOne(const Service::Ptr& service, const Obje
|
||||||
Host::Ptr host = service->GetHost();
|
Host::Ptr host = service->GetHost();
|
||||||
|
|
||||||
Dictionary::Ptr locals = make_shared<Dictionary>();
|
Dictionary::Ptr locals = make_shared<Dictionary>();
|
||||||
|
locals->Set("__parent", rule.GetScope());
|
||||||
locals->Set("host", host);
|
locals->Set("host", host);
|
||||||
locals->Set("service", service);
|
locals->Set("service", service);
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@ bool UserGroup::EvaluateObjectRuleOne(const User::Ptr& user, const ObjectRule& r
|
||||||
CONTEXT(msgbuf.str());
|
CONTEXT(msgbuf.str());
|
||||||
|
|
||||||
Dictionary::Ptr locals = make_shared<Dictionary>();
|
Dictionary::Ptr locals = make_shared<Dictionary>();
|
||||||
|
locals->Set("__parent", rule.GetScope());
|
||||||
locals->Set("user", user);
|
locals->Set("user", user);
|
||||||
|
|
||||||
if (!rule.EvaluateFilter(locals))
|
if (!rule.EvaluateFilter(locals))
|
||||||
|
|
Loading…
Reference in New Issue