mirror of https://github.com/Icinga/icinga2.git
parent
0f9f9a12b3
commit
8d3632caf8
|
@ -62,15 +62,39 @@ void Dependency::OnStateLoaded(void)
|
||||||
|
|
||||||
ASSERT(!OwnsLock());
|
ASSERT(!OwnsLock());
|
||||||
|
|
||||||
if (!GetChild())
|
Host::Ptr childHost = Host::GetByName(GetChildHostName());
|
||||||
|
|
||||||
|
if (childHost) {
|
||||||
|
if (GetChildServiceName().IsEmpty()) {
|
||||||
|
Log(LogDebug, "Dependency", "Dependency '" + GetName() + "' child host '" + GetChildHostName() + ".");
|
||||||
|
m_Child = childHost;
|
||||||
|
} else {
|
||||||
|
Log(LogDebug, "Dependency", "Dependency '" + GetName() + "' child host '" + GetChildHostName() + "' service '" + GetChildServiceName() + "' .");
|
||||||
|
m_Child = childHost->GetServiceByShortName(GetChildServiceName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_Child)
|
||||||
Log(LogWarning, "Dependency", "Dependency '" + GetName() + "' references an invalid child object and will be ignored.");
|
Log(LogWarning, "Dependency", "Dependency '" + GetName() + "' references an invalid child object and will be ignored.");
|
||||||
else
|
else
|
||||||
GetChild()->AddDependency(GetSelf());
|
m_Child->AddDependency(GetSelf());
|
||||||
|
|
||||||
if (!GetParent())
|
Host::Ptr parentHost = Host::GetByName(GetParentHostName());
|
||||||
|
|
||||||
|
if (parentHost) {
|
||||||
|
if (GetParentServiceName().IsEmpty()) {
|
||||||
|
Log(LogDebug, "Dependency", "Dependency '" + GetName() + "' parent host '" + GetParentHostName() + ".");
|
||||||
|
m_Parent = parentHost;
|
||||||
|
} else {
|
||||||
|
Log(LogDebug, "Dependency", "Dependency '" + GetName() + "' parent host '" + GetParentHostName() + "' service '" + GetParentServiceName() + "' .");
|
||||||
|
m_Parent = parentHost->GetServiceByShortName(GetParentServiceName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_Parent)
|
||||||
Log(LogWarning, "Dependency", "Dependency '" + GetName() + "' references an invalid parent object and will always fail.");
|
Log(LogWarning, "Dependency", "Dependency '" + GetName() + "' references an invalid parent object and will always fail.");
|
||||||
else
|
else
|
||||||
GetParent()->AddReverseDependency(GetSelf());
|
m_Parent->AddReverseDependency(GetSelf());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dependency::Stop(void)
|
void Dependency::Stop(void)
|
||||||
|
@ -149,31 +173,12 @@ bool Dependency::IsAvailable(DependencyType dt) const
|
||||||
|
|
||||||
Checkable::Ptr Dependency::GetChild(void) const
|
Checkable::Ptr Dependency::GetChild(void) const
|
||||||
{
|
{
|
||||||
Host::Ptr host = Host::GetByName(GetChildHostName());
|
return m_Child;
|
||||||
|
|
||||||
if (!host)
|
|
||||||
return Service::Ptr();
|
|
||||||
|
|
||||||
if (GetChildServiceName().IsEmpty())
|
|
||||||
return host;
|
|
||||||
else
|
|
||||||
return host->GetServiceByShortName(GetChildServiceName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Checkable::Ptr Dependency::GetParent(void) const
|
Checkable::Ptr Dependency::GetParent(void) const
|
||||||
{
|
{
|
||||||
Host::Ptr host = Host::GetByName(GetParentHostName());
|
return m_Parent;
|
||||||
|
|
||||||
if (!host)
|
|
||||||
return Service::Ptr();
|
|
||||||
|
|
||||||
if (GetParentServiceName().IsEmpty()) {
|
|
||||||
Log(LogDebug, "Dependency", "Dependency '" + GetName() + "' parent host '" + GetParentHostName() + ".");
|
|
||||||
return host;
|
|
||||||
} else {
|
|
||||||
Log(LogDebug, "Dependency", "Dependency '" + GetName() + "' parent host '" + GetParentHostName() + "' service '" + GetParentServiceName() + "' .");
|
|
||||||
return host->GetServiceByShortName(GetParentServiceName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TimePeriod::Ptr Dependency::GetPeriod(void) const
|
TimePeriod::Ptr Dependency::GetPeriod(void) const
|
||||||
|
|
|
@ -57,6 +57,9 @@ protected:
|
||||||
virtual void Stop(void);
|
virtual void Stop(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Checkable::Ptr m_Parent;
|
||||||
|
Checkable::Ptr m_Child;
|
||||||
|
|
||||||
static bool EvaluateApplyRuleOne(const Checkable::Ptr& checkable, const ApplyRule& rule);
|
static bool EvaluateApplyRuleOne(const Checkable::Ptr& checkable, const ApplyRule& rule);
|
||||||
static void EvaluateApplyRule(const ApplyRule& rule);
|
static void EvaluateApplyRule(const ApplyRule& rule);
|
||||||
static void EvaluateApplyRules(const std::vector<ApplyRule>& rules);
|
static void EvaluateApplyRules(const std::vector<ApplyRule>& rules);
|
||||||
|
|
Loading…
Reference in New Issue