]> granicus.if.org Git - icinga2/commitdiff
Redesign how templates are specified for slave services/notifications
authorGunnar Beutner <gunnar.beutner@netways.de>
Sat, 16 Feb 2013 08:28:05 +0000 (09:28 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Sat, 16 Feb 2013 08:28:05 +0000 (09:28 +0100)
Fixes #3706

itl/types.conf
lib/icinga/host.cpp
lib/icinga/service-notification.cpp

index 5301b6d2a50f41974c73d764f6165227cee8b0f8..bd595934c89e89027ce5f0a175d2827b146d8339 100644 (file)
@@ -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 "*"
index 82754346a1af4c7a37f33dde5b71325cee14e81e..5adcb455ec5260fc77b37f8871609e7e8ed593d5 100644 (file)
@@ -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 {
index 2605e44bdb1ef36ff756afc3db05695ac08970f1..1d5fa9e9fec13aa08ae0eb1ab1a1f03e287a8ddf 100644 (file)
@@ -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 {