[icinga-checkins] icinga.org: icinga2/master: Copy service and host dependencies into service items.

git at icinga.org git at icinga.org
Fri Feb 8 21:38:59 CET 2013


Module: icinga2
Branch: master
Commit: f725c6ee7a0269e8cca2630106f82401838ccf4b
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=f725c6ee7a0269e8cca2630106f82401838ccf4b

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Fri Feb  8 21:38:34 2013 +0100

Copy service and host dependencies into service items.

---

 lib/icinga/host.cpp |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/lib/icinga/host.cpp b/lib/icinga/host.cpp
index 8be4194..743bc26 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<typename TDict>
+template<bool copyServiceAttrs, typename TDict>
 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<false>(this, builder);
 
 			if (svcdesc.IsScalar()) {
 				builder->AddParent(svcdesc);
@@ -249,7 +259,7 @@ void Host::UpdateSlaveServices(void)
 
 				builder->AddParent(parent);
 
-				CopyServiceAttributes(service, builder);
+				CopyServiceAttributes<true>(service, builder);
 			} else {
 				BOOST_THROW_EXCEPTION(invalid_argument("Service description must be either a string or a dictionary."));
 			}





More information about the icinga-checkins mailing list