[icinga-checkins] icinga.org: icinga2/master: Redesign how templates are specified for slave services/notifications

git at icinga.org git at icinga.org
Sat Feb 16 09:28:26 CET 2013


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

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Sat Feb 16 09:28:05 2013 +0100

Redesign how templates are specified for slave services/notifications

Fixes #3706

---

 itl/types.conf                      |    9 ++++++---
 lib/icinga/host.cpp                 |   15 ++++++++++-----
 lib/icinga/service-notification.cpp |   15 ++++++++++-----
 3 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/itl/types.conf b/itl/types.conf
index 5301b6d..bd59593 100644
--- a/itl/types.conf
+++ b/itl/types.conf
@@ -72,7 +72,9 @@ type Host {
 
 		%attribute string "*",
 		%attribute dictionary "*" {
-			%attribute string "service",
+			%attribute dictionary "templates" {
+				%attribute string "*"
+			},
 
 			%attribute string "short_name",
 
@@ -108,8 +110,9 @@ type Host {
 	%attribute dictionary "notifications" {
 		%attribute string "*",
 		%attribute dictionary "*" {
-			%require "notification",
-			%attribute string "notification",
+			%attribute dictionary "templates" {
+				%attribute string "*"
+			},
 
 			%attribute dictionary "macros" {
 				%attribute string "*"
diff --git a/lib/icinga/host.cpp b/lib/icinga/host.cpp
index 8275434..5adcb45 100644
--- a/lib/icinga/host.cpp
+++ b/lib/icinga/host.cpp
@@ -223,11 +223,16 @@ void Host::UpdateSlaveServices(void)
 			} else if (svcdesc.IsObjectType<Dictionary>()) {
 				Dictionary::Ptr service = svcdesc;
 
-				String parent = service->Get("service");
-				if (parent.IsEmpty())
-					parent = svcname;
-
-				builder->AddParent(parent);
+				Dictionary::Ptr templates = service->Get("templates");
+
+				if (templates) {
+					String tmpl;
+					BOOST_FOREACH(tie(tuples::ignore, tmpl), templates) {
+						builder->AddParent(tmpl);
+					}
+				} else {
+					builder->AddParent(svcname);
+				}
 
 				CopyServiceAttributes<true>(service, builder);
 			} else {
diff --git a/lib/icinga/service-notification.cpp b/lib/icinga/service-notification.cpp
index 2605e44..1d5fa9e 100644
--- a/lib/icinga/service-notification.cpp
+++ b/lib/icinga/service-notification.cpp
@@ -156,11 +156,16 @@ void Service::UpdateSlaveNotifications(void)
 			} else if (nfcdesc.IsObjectType<Dictionary>()) {
 				Dictionary::Ptr notification = nfcdesc;
 
-				String parent = notification->Get("notification");
-				if (parent.IsEmpty())
-					parent = nfcname;
-
-				builder->AddParent(parent);
+				Dictionary::Ptr templates = notification->Get("templates");
+
+				if (templates) {
+					String tmpl;
+					BOOST_FOREACH(tie(tuples::ignore, tmpl), templates) {
+						builder->AddParent(tmpl);
+					}
+				} else {
+					builder->AddParent(nfcname);
+				}
 
 				CopyNotificationAttributes(notification, builder);
 			} else {





More information about the icinga-checkins mailing list