diff --git a/lib/base/dynamicobject.cpp b/lib/base/dynamicobject.cpp index 569ff9e70..b3ad74084 100644 --- a/lib/base/dynamicobject.cpp +++ b/lib/base/dynamicobject.cpp @@ -484,9 +484,6 @@ void DynamicObject::FlushTx(void) void DynamicObject::OnAttributeChanged(const String&, const Value&) { } -void DynamicObject::OnInitCompleted(void) -{ } - DynamicObject::Ptr DynamicObject::GetObject(const String& type, const String& name) { DynamicType::Ptr dtype = DynamicType::GetByName(type); diff --git a/lib/base/dynamicobject.h b/lib/base/dynamicobject.h index 21e00c1d1..7260efa6a 100644 --- a/lib/base/dynamicobject.h +++ b/lib/base/dynamicobject.h @@ -133,7 +133,6 @@ public: protected: virtual void OnAttributeChanged(const String& name, const Value& oldValue); - virtual void OnInitCompleted(void); private: void InternalSetAttribute(const String& name, const Value& data, double tx, bool allowEditConfig = false); @@ -149,8 +148,6 @@ private: /* This has to be a set of raw pointers because the DynamicObject * constructor has to be able to insert objects into this list. */ static set m_ModifiedObjects; - - friend class DynamicType; /* for OnInitCompleted */ }; } diff --git a/lib/base/dynamictype.cpp b/lib/base/dynamictype.cpp index 8cb5edab0..05efe7b5a 100644 --- a/lib/base/dynamictype.cpp +++ b/lib/base/dynamictype.cpp @@ -93,9 +93,6 @@ DynamicObject::Ptr DynamicType::CreateObject(const Dictionary::Ptr& serializedUp /* apply the object's non-config attributes */ obj->ApplyUpdate(serializedUpdate, Attribute_All & ~Attribute_Config); - /* notify the object that it's "ready" */ - obj->OnInitCompleted(); - return obj; } diff --git a/lib/icinga/host.cpp b/lib/icinga/host.cpp index 742099348..b0df21bbe 100644 --- a/lib/icinga/host.cpp +++ b/lib/icinga/host.cpp @@ -27,7 +27,7 @@ bool Host::m_ServicesCacheValid = true; REGISTER_SCRIPTFUNCTION("native::ValidateServiceDictionary", &Host::ValidateServiceDictionary); static AttributeDescription hostAttributes[] = { - { "convenience_services", Attribute_Transient } + { "slave_services", Attribute_Transient } }; REGISTER_TYPE(Host, hostAttributes); @@ -36,18 +36,11 @@ Host::Host(const Dictionary::Ptr& properties) : DynamicObject(properties) { } -void Host::OnInitCompleted(void) -{ - HostGroup::InvalidateMembersCache(); - - UpdateSlaveServices(); -} - Host::~Host(void) { HostGroup::InvalidateMembersCache(); - Dictionary::Ptr services = Get("convenience_services"); + Dictionary::Ptr services = Get("slave_services"); if (services) { ConfigItem::Ptr service; diff --git a/lib/icinga/host.h b/lib/icinga/host.h index 472a1cdb5..7b4d18139 100644 --- a/lib/icinga/host.h +++ b/lib/icinga/host.h @@ -37,7 +37,6 @@ public: typedef weak_ptr WeakPtr; Host(const Dictionary::Ptr& properties); - void OnInitCompleted(void); ~Host(void); static bool Exists(const String& name); diff --git a/lib/icinga/hostgroup.cpp b/lib/icinga/hostgroup.cpp index b09946d7c..1e692e6dc 100644 --- a/lib/icinga/hostgroup.cpp +++ b/lib/icinga/hostgroup.cpp @@ -26,6 +26,10 @@ bool HostGroup::m_MembersCacheValid = true; REGISTER_TYPE(HostGroup, NULL); +HostGroup::HostGroup(const Dictionary::Ptr& properties) + : DynamicObject(properties) +{ } + String HostGroup::GetDisplayName(void) const { String value = Get("alias"); @@ -112,4 +116,3 @@ void HostGroup::ValidateMembersCache(void) m_MembersCacheValid = true; } - diff --git a/lib/icinga/hostgroup.h b/lib/icinga/hostgroup.h index a3c28760c..178544356 100644 --- a/lib/icinga/hostgroup.h +++ b/lib/icinga/hostgroup.h @@ -34,9 +34,7 @@ public: typedef shared_ptr Ptr; typedef weak_ptr WeakPtr; - HostGroup(const Dictionary::Ptr& properties) - : DynamicObject(properties) - { } + HostGroup(const Dictionary::Ptr& properties);; static bool Exists(const String& name); static HostGroup::Ptr GetByName(const String& name); diff --git a/lib/icinga/notification.cpp b/lib/icinga/notification.cpp index 905e85723..046d8c066 100644 --- a/lib/icinga/notification.cpp +++ b/lib/icinga/notification.cpp @@ -108,3 +108,9 @@ void Notification::NotificationCompletedHandler(const ScriptTask::Ptr& task) Logger::Write(LogWarning, "icinga", message); } } + +void Notification::OnAttributeChanged(const String& name, const Value& oldValue) +{ + if (name == "host_name" || name == "service") + Service::InvalidateNotificationsCache(); +} diff --git a/lib/icinga/notification.h b/lib/icinga/notification.h index f91ca946c..ae6071836 100644 --- a/lib/icinga/notification.h +++ b/lib/icinga/notification.h @@ -62,6 +62,9 @@ public: void SendNotification(NotificationType type); +protected: + void OnAttributeChanged(const String& name, const Value& oldValue); + private: set m_Tasks; diff --git a/lib/icinga/service.cpp b/lib/icinga/service.cpp index da7b19384..78bbb6000 100644 --- a/lib/icinga/service.cpp +++ b/lib/icinga/service.cpp @@ -47,12 +47,7 @@ REGISTER_TYPE(Service, serviceAttributes); Service::Service(const Dictionary::Ptr& serializedObject) : DynamicObject(serializedObject) -{ - ServiceGroup::InvalidateMembersCache(); - Host::InvalidateServicesCache(); - Service::InvalidateDowntimeCache(); - Service::InvalidateCommentCache(); -} +{ } Service::~Service(void) { diff --git a/lib/icinga/servicegroup.cpp b/lib/icinga/servicegroup.cpp index 3c4b09160..bba8789ef 100644 --- a/lib/icinga/servicegroup.cpp +++ b/lib/icinga/servicegroup.cpp @@ -26,6 +26,10 @@ bool ServiceGroup::m_MembersCacheValid; REGISTER_TYPE(ServiceGroup, NULL); +ServiceGroup::ServiceGroup(const Dictionary::Ptr& properties) + : DynamicObject(properties) +{ } + String ServiceGroup::GetDisplayName(void) const { String value = Get("alias"); @@ -112,4 +116,3 @@ void ServiceGroup::ValidateMembersCache(void) m_MembersCacheValid = true; } - diff --git a/lib/icinga/servicegroup.h b/lib/icinga/servicegroup.h index b7ed56318..631f943f9 100644 --- a/lib/icinga/servicegroup.h +++ b/lib/icinga/servicegroup.h @@ -34,9 +34,7 @@ public: typedef shared_ptr Ptr; typedef weak_ptr WeakPtr; - ServiceGroup(const Dictionary::Ptr& properties) - : DynamicObject(properties) - { } + ServiceGroup(const Dictionary::Ptr& properties); static bool Exists(const String& name); static ServiceGroup::Ptr GetByName(const String& name);