From: Gunnar Beutner Date: Sat, 16 Feb 2013 08:28:05 +0000 (+0100) Subject: Redesign how templates are specified for slave services/notifications X-Git-Tag: v0.0.2~391 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=22913c96bfd8421a73400e4b07efe52bf290e710;p=icinga2 Redesign how templates are specified for slave services/notifications Fixes #3706 --- diff --git a/itl/types.conf b/itl/types.conf index 5301b6d2a..bd595934c 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 82754346a..5adcb455e 100644 --- a/lib/icinga/host.cpp +++ b/lib/icinga/host.cpp @@ -223,11 +223,16 @@ void Host::UpdateSlaveServices(void) } else if (svcdesc.IsObjectType()) { 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(service, builder); } else { diff --git a/lib/icinga/service-notification.cpp b/lib/icinga/service-notification.cpp index 2605e44bd..1d5fa9e9f 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::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 {