mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-29 16:44:29 +02:00
Fix cloning attributes for service notifications.
This commit is contained in:
parent
711a8cb5e0
commit
bf27aad234
@ -170,13 +170,23 @@ std::set<Notification::Ptr> Service::GetNotifications(void) const
|
|||||||
void Service::UpdateSlaveNotifications(void)
|
void Service::UpdateSlaveNotifications(void)
|
||||||
{
|
{
|
||||||
Dictionary::Ptr oldNotifications;
|
Dictionary::Ptr oldNotifications;
|
||||||
std::vector<Dictionary::Ptr> notificationDescsList;
|
ConfigItem::Ptr serviceItem, hostItem;
|
||||||
ConfigItem::Ptr item;
|
|
||||||
|
|
||||||
item = ConfigItem::GetObject("Service", GetName());
|
serviceItem = ConfigItem::GetObject("Service", GetName());
|
||||||
|
|
||||||
/* Don't create slave notifications unless we own this object */
|
/* Don't create slave notifications unless we own this object */
|
||||||
if (!item)
|
if (!serviceItem)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Host::Ptr host = GetHost();
|
||||||
|
|
||||||
|
if (!host)
|
||||||
|
return;
|
||||||
|
|
||||||
|
hostItem = ConfigItem::GetObject("Host", host->GetName());
|
||||||
|
|
||||||
|
/* Don't create slave notifications unless we own the host */
|
||||||
|
if (!hostItem)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -184,27 +194,37 @@ void Service::UpdateSlaveNotifications(void)
|
|||||||
oldNotifications = m_SlaveNotifications;
|
oldNotifications = m_SlaveNotifications;
|
||||||
}
|
}
|
||||||
|
|
||||||
notificationDescsList.push_back(Get("notifications"));
|
std::vector<Dictionary::Ptr> descLists;
|
||||||
|
|
||||||
|
descLists.push_back(Get("notifications"));
|
||||||
|
|
||||||
Dictionary::Ptr newNotifications;
|
Dictionary::Ptr newNotifications;
|
||||||
newNotifications = boost::make_shared<Dictionary>();
|
newNotifications = boost::make_shared<Dictionary>();
|
||||||
|
|
||||||
Host::Ptr host = GetHost();
|
descLists.push_back(host->Get("notifications"));
|
||||||
|
|
||||||
if (!host)
|
for (int i = 0; i < 2; i++) {
|
||||||
return;
|
Dictionary::Ptr descs;
|
||||||
|
ConfigItem::Ptr item;
|
||||||
|
|
||||||
notificationDescsList.push_back(host->Get("notifications"));
|
if (i == 0) {
|
||||||
|
/* Host notification descs */
|
||||||
|
descs = host->Get("notifications");
|
||||||
|
item = hostItem;
|
||||||
|
} else {
|
||||||
|
/* Service notification descs */
|
||||||
|
descs = Get("notifications");
|
||||||
|
item = serviceItem;
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_FOREACH(const Dictionary::Ptr& notificationDescs, notificationDescsList) {
|
if (!descs)
|
||||||
if (!notificationDescs)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ObjectLock olock(notificationDescs);
|
ObjectLock olock(descs);
|
||||||
|
|
||||||
String nfcname;
|
String nfcname;
|
||||||
Value nfcdesc;
|
Value nfcdesc;
|
||||||
BOOST_FOREACH(boost::tie(nfcname, nfcdesc), notificationDescs) {
|
BOOST_FOREACH(boost::tie(nfcname, nfcdesc), descs) {
|
||||||
std::ostringstream namebuf;
|
std::ostringstream namebuf;
|
||||||
namebuf << GetName() << "-" << nfcname;
|
namebuf << GetName() << "-" << nfcname;
|
||||||
String name = namebuf.str();
|
String name = namebuf.str();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user