mirror of https://github.com/Icinga/icinga2.git
Implement GetAllChildren() for dependency resolution
refs #10896 refs #10897
This commit is contained in:
parent
86f162af85
commit
ea1f8727da
|
@ -128,3 +128,33 @@ std::set<Checkable::Ptr> Checkable::GetChildren(void) const
|
||||||
|
|
||||||
return parents;
|
return parents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::set<Checkable::Ptr> Checkable::GetAllChildren(void) const
|
||||||
|
{
|
||||||
|
std::set<Checkable::Ptr> children = GetChildren();
|
||||||
|
|
||||||
|
GetAllChildrenInternal(children, 0);
|
||||||
|
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Checkable::GetAllChildrenInternal(std::set<Checkable::Ptr>& children, int level) const
|
||||||
|
{
|
||||||
|
if (level > 32)
|
||||||
|
return;
|
||||||
|
|
||||||
|
std::set<Checkable::Ptr> localChildren;
|
||||||
|
|
||||||
|
for (const Checkable::Ptr& checkable : children) {
|
||||||
|
std::set<Checkable::Ptr> cChildren = checkable->GetChildren();
|
||||||
|
|
||||||
|
if (!checkable->GetChildren().empty()) {
|
||||||
|
GetAllChildrenInternal(cChildren, level + 1);
|
||||||
|
localChildren.insert(cChildren.begin(), cChildren.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
localChildren.insert(checkable);
|
||||||
|
}
|
||||||
|
|
||||||
|
children.insert(localChildren.begin(), localChildren.end());
|
||||||
|
}
|
||||||
|
|
|
@ -74,6 +74,7 @@ public:
|
||||||
|
|
||||||
std::set<Checkable::Ptr> GetParents(void) const;
|
std::set<Checkable::Ptr> GetParents(void) const;
|
||||||
std::set<Checkable::Ptr> GetChildren(void) const;
|
std::set<Checkable::Ptr> GetChildren(void) const;
|
||||||
|
std::set<Checkable::Ptr> GetAllChildren(void) const;
|
||||||
|
|
||||||
void AddGroup(const String& name);
|
void AddGroup(const String& name);
|
||||||
|
|
||||||
|
@ -217,6 +218,8 @@ private:
|
||||||
mutable boost::mutex m_DependencyMutex;
|
mutable boost::mutex m_DependencyMutex;
|
||||||
std::set<intrusive_ptr<Dependency> > m_Dependencies;
|
std::set<intrusive_ptr<Dependency> > m_Dependencies;
|
||||||
std::set<intrusive_ptr<Dependency> > m_ReverseDependencies;
|
std::set<intrusive_ptr<Dependency> > m_ReverseDependencies;
|
||||||
|
|
||||||
|
void GetAllChildrenInternal(std::set<Checkable::Ptr>& children, int level = 0) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1024,7 +1024,7 @@ void ExternalCommandProcessor::ScheduleAndPropagateHostDowntime(double, const st
|
||||||
Convert::ToBool(is_fixed), triggeredBy, Convert::ToDouble(arguments[5]));
|
Convert::ToBool(is_fixed), triggeredBy, Convert::ToDouble(arguments[5]));
|
||||||
|
|
||||||
/* Schedule downtime for all child hosts */
|
/* Schedule downtime for all child hosts */
|
||||||
BOOST_FOREACH(const Checkable::Ptr& child, host->GetChildren()) {
|
for (const Checkable::Ptr& child : host->GetAllChildren()) {
|
||||||
Host::Ptr host;
|
Host::Ptr host;
|
||||||
Service::Ptr service;
|
Service::Ptr service;
|
||||||
tie(host, service) = GetHostService(child);
|
tie(host, service) = GetHostService(child);
|
||||||
|
@ -1060,7 +1060,7 @@ void ExternalCommandProcessor::ScheduleAndPropagateTriggeredHostDowntime(double,
|
||||||
Convert::ToBool(is_fixed), triggeredBy, Convert::ToDouble(arguments[5]));
|
Convert::ToBool(is_fixed), triggeredBy, Convert::ToDouble(arguments[5]));
|
||||||
|
|
||||||
/* Schedule downtime for all child hosts and explicitely trigger them through the parent host's downtime */
|
/* Schedule downtime for all child hosts and explicitely trigger them through the parent host's downtime */
|
||||||
BOOST_FOREACH(const Checkable::Ptr& child, host->GetChildren()) {
|
for (const Checkable::Ptr& child : host->GetAllChildren()) {
|
||||||
Host::Ptr host;
|
Host::Ptr host;
|
||||||
Service::Ptr service;
|
Service::Ptr service;
|
||||||
tie(host, service) = GetHostService(child);
|
tie(host, service) = GetHostService(child);
|
||||||
|
|
Loading…
Reference in New Issue