MCPcopy Create free account
hub / github.com/Icinga/icinga2 / EvaluateObjectRule

Method EvaluateObjectRule

lib/icinga/hostgroup.cpp:22–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20});
21
22bool HostGroup::EvaluateObjectRule(const Host::Ptr& host, const ConfigItem::Ptr& group)
23{
24 String groupName = group->GetName();
25
26 CONTEXT("Evaluating rule for group '" << groupName << "'");
27
28 ScriptFrame frame(true);
29 if (group->GetScope())
30 group->GetScope()->CopyTo(frame.Locals);
31 frame.Locals->Set("host", host);
32
33 if (!group->GetFilter()->Evaluate(frame).GetValue().ToBool())
34 return false;
35
36 Log(LogDebug, "HostGroup")
37 << "Assigning membership for group '" << groupName << "' to host '" << host->GetName() << "'";
38
39 Array::Ptr groups = host->GetGroups();
40
41 if (groups && !groups->Contains(groupName))
42 groups->Add(groupName);
43
44 return true;
45}
46
47void HostGroup::EvaluateObjectRules(const Host::Ptr& host)
48{

Callers

nothing calls this directly

Calls 11

LogClass · 0.85
EvaluateMethod · 0.80
GetNameMethod · 0.45
GetScopeMethod · 0.45
CopyToMethod · 0.45
SetMethod · 0.45
ToBoolMethod · 0.45
GetValueMethod · 0.45
GetFilterMethod · 0.45
ContainsMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected