Redesign how templates are specified for slave services/notifications

Fixes #3706
This commit is contained in:
Gunnar Beutner 2013-02-16 09:28:05 +01:00
parent f0093689fd
commit 22913c96bf
3 changed files with 24 additions and 11 deletions

View 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 "*"

View 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;
Dictionary::Ptr templates = service->Get("templates");
builder->AddParent(parent);
if (templates) {
String tmpl;
BOOST_FOREACH(tie(tuples::ignore, tmpl), templates) {
builder->AddParent(tmpl);
}
} else {
builder->AddParent(svcname);
}
CopyServiceAttributes<true>(service, builder);
} else {

View 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;
Dictionary::Ptr templates = notification->Get("templates");
builder->AddParent(parent);
if (templates) {
String tmpl;
BOOST_FOREACH(tie(tuples::ignore, tmpl), templates) {
builder->AddParent(tmpl);
}
} else {
builder->AddParent(nfcname);
}
CopyNotificationAttributes(notification, builder);
} else {