mirror of
				https://github.com/Icinga/icinga2.git
				synced 2025-11-03 21:25:56 +01:00 
			
		
		
		
	Redesign how templates are specified for slave services/notifications
Fixes #3706
This commit is contained in:
		
							parent
							
								
									f0093689fd
								
							
						
					
					
						commit
						22913c96bf
					
				@ -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 "*"
 | 
				
			||||||
 | 
				
			|||||||
@ -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 {
 | 
				
			||||||
 | 
				
			|||||||
@ -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 {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user