From f725c6ee7a0269e8cca2630106f82401838ccf4b Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Fri, 8 Feb 2013 21:38:34 +0100 Subject: [PATCH] Copy service and host dependencies into service items. --- lib/icinga/host.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/icinga/host.cpp b/lib/icinga/host.cpp index 8be419460..743bc2662 100644 --- a/lib/icinga/host.cpp +++ b/lib/icinga/host.cpp @@ -178,7 +178,7 @@ bool Host::IsUp(void) const return (!service || service->GetState() == StateOK || service->GetState() == StateWarning); } -template +template static void CopyServiceAttributes(TDict serviceDesc, const ConfigItemBuilder::Ptr& builder) { /* TODO: we only need to copy macros if this is an inline definition, @@ -203,6 +203,16 @@ static void CopyServiceAttributes(TDict serviceDesc, const ConfigItemBuilder::Pt Value checkers = serviceDesc->Get("checkers"); if (!checkers.IsEmpty()) builder->AddExpression("checkers", OperatorSet, checkers); + + if (copyServiceAttrs) { + Value servicedependencies = serviceDesc->Get("servicedependencies"); + if (!servicedependencies.IsEmpty()) + builder->AddExpression("servicedependencies", OperatorPlus, servicedependencies); + + Value hostdependencies = serviceDesc->Get("hostdependencies"); + if (!hostdependencies.IsEmpty()) + builder->AddExpression("hostdependencies", OperatorPlus, hostdependencies); + } } void Host::UpdateSlaveServices(void) @@ -236,7 +246,7 @@ void Host::UpdateSlaveServices(void) builder->AddExpression("alias", OperatorSet, svcname); builder->AddExpression("short_name", OperatorSet, svcname); - CopyServiceAttributes(this, builder); + CopyServiceAttributes(this, builder); if (svcdesc.IsScalar()) { builder->AddParent(svcdesc); @@ -249,7 +259,7 @@ void Host::UpdateSlaveServices(void) builder->AddParent(parent); - CopyServiceAttributes(service, builder); + CopyServiceAttributes(service, builder); } else { BOOST_THROW_EXCEPTION(invalid_argument("Service description must be either a string or a dictionary.")); }