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 string "*",
%attribute dictionary "*" { %attribute dictionary "*" {
%attribute string "service", %attribute dictionary "templates" {
%attribute string "*"
},
%attribute string "short_name", %attribute string "short_name",
@ -108,8 +110,9 @@ type Host {
%attribute dictionary "notifications" { %attribute dictionary "notifications" {
%attribute string "*", %attribute string "*",
%attribute dictionary "*" { %attribute dictionary "*" {
%require "notification", %attribute dictionary "templates" {
%attribute string "notification", %attribute string "*"
},
%attribute dictionary "macros" { %attribute dictionary "macros" {
%attribute string "*" %attribute string "*"

View File

@ -223,11 +223,16 @@ void Host::UpdateSlaveServices(void)
} else if (svcdesc.IsObjectType<Dictionary>()) { } else if (svcdesc.IsObjectType<Dictionary>()) {
Dictionary::Ptr service = svcdesc; Dictionary::Ptr service = svcdesc;
String parent = service->Get("service"); Dictionary::Ptr templates = service->Get("templates");
if (parent.IsEmpty())
parent = svcname;
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); CopyServiceAttributes<true>(service, builder);
} else { } else {

View File

@ -156,11 +156,16 @@ void Service::UpdateSlaveNotifications(void)
} else if (nfcdesc.IsObjectType<Dictionary>()) { } else if (nfcdesc.IsObjectType<Dictionary>()) {
Dictionary::Ptr notification = nfcdesc; Dictionary::Ptr notification = nfcdesc;
String parent = notification->Get("notification"); Dictionary::Ptr templates = notification->Get("templates");
if (parent.IsEmpty())
parent = nfcname;
builder->AddParent(parent); if (templates) {
String tmpl;
BOOST_FOREACH(tie(tuples::ignore, tmpl), templates) {
builder->AddParent(tmpl);
}
} else {
builder->AddParent(nfcname);
}
CopyNotificationAttributes(notification, builder); CopyNotificationAttributes(notification, builder);
} else { } else {