]> granicus.if.org Git - icinga2/commitdiff
Fix: State file doesn't work for generated service objects.
authorGunnar Beutner <gunnar@beutner.name>
Thu, 29 Aug 2013 14:53:57 +0000 (16:53 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Thu, 29 Aug 2013 14:53:57 +0000 (16:53 +0200)
lib/base/dynamicobject.cpp
lib/base/dynamicobject.h
lib/icinga/host.cpp
lib/icinga/host.h
lib/icinga/service.cpp
lib/icinga/service.h
lib/icinga/user.cpp
lib/icinga/user.h

index 983dbab6def0a41aeffa053e555a784ea0df9dc6..406cbff4d24adc4819babe255bc45f413a194af9 100644 (file)
@@ -68,9 +68,17 @@ Dictionary::Ptr DynamicObject::Serialize(int attributeTypes) const
 void DynamicObject::Deserialize(const Dictionary::Ptr& update, int attributeTypes)
 {
        ASSERT(!OwnsLock());
-       ObjectLock olock(this);
 
-       InternalDeserialize(update, attributeTypes);
+       {
+               ObjectLock olock(this);
+               InternalDeserialize(update, attributeTypes);
+       }
+
+       if (attributeTypes & Attribute_Config)
+               OnConfigLoaded();
+
+       if (attributeTypes & Attribute_State)
+               OnStateLoaded();
 }
 
 void DynamicObject::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
@@ -176,6 +184,16 @@ void DynamicObject::Stop(void)
        OnStopped(GetSelf());
 }
 
+void DynamicObject::OnConfigLoaded(void)
+{
+       /* Nothing to do here. */
+}
+
+void DynamicObject::OnStateLoaded(void)
+{
+       /* Nothing to do here. */
+}
+
 Value DynamicObject::InvokeMethod(const String& method,
     const std::vector<Value>& arguments)
 {
index 048fd5deb49422c8c99c1d45b351b2f5ac703ebd..204e0c0e3ec001fb644c75085fc8b0ab30c8be95 100644 (file)
@@ -102,6 +102,9 @@ protected:
        virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
        virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
 
+       virtual void OnConfigLoaded(void);
+       virtual void OnStateLoaded(void);
+
 private:
        String m_Name;
        String m_Type;
index 8e67483fae67b241958fceec110a0eea3a803c1c..b886504e77dc73047bc2808c215d18c91744f5b6 100644 (file)
@@ -56,7 +56,10 @@ void Host::Start(void)
                                hg->AddMember(GetSelf());
                }
        }
+}
 
+void Host::OnConfigLoaded(void)
+{
        UpdateSlaveServices();
 }
 
index c73cacfbb02591ecc8761a0fab37cd8ab80d9e61..68011d1f54b627b794f0b669d3f94e1a1b169487 100644 (file)
@@ -127,6 +127,8 @@ protected:
        virtual void Start(void);
        virtual void Stop(void);
 
+       virtual void OnConfigLoaded(void);
+
        virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
        virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
 
index 75c195bf587b166d97038a36d9a386e49c6270c2..2f5a068f9c6cd7cd71bc3ecc332c17b3a3658aaf 100644 (file)
@@ -44,6 +44,12 @@ void Service::Start(void)
        SetSchedulingOffset(rand());
        UpdateNextCheck();
 
+       AddDowntimesToCache();
+       AddCommentsToCache();
+}
+
+void Service::OnConfigLoaded(void)
+{
        Array::Ptr groups = GetGroups();
 
        if (groups) {
@@ -55,12 +61,11 @@ void Service::Start(void)
                }
        }
 
-       AddDowntimesToCache();
-       AddCommentsToCache();
-
        Host::Ptr host = GetHost();
        if (host)
                host->AddService(GetSelf());
+
+       UpdateSlaveNotifications();
 }
 
 String Service::GetDisplayName(void) const
index 428455b858742e821ccac959934042ab0b691fce..c38a537bedaf0e1237afb335f17f9d341d5faff4 100644 (file)
@@ -332,6 +332,8 @@ public:
 protected:
        virtual void Start(void);
 
+       virtual void OnConfigLoaded(void);
+
        virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
        virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
 
index b4dcb24d52babacfa4ee0de9e6411a72f24725d3..649792422d94e5d4c76bc150cf8ff62fcb7a65ff 100644 (file)
@@ -27,10 +27,8 @@ using namespace icinga;
 
 REGISTER_TYPE(User);
 
-void User::Start(void)
+void User::OnConfigLoaded(void)
 {
-       DynamicObject::Start();
-
        Array::Ptr groups = GetGroups();
 
        if (groups) {
index 26e65427c9cd4e0554b6f9c6ffb2a7832f6c6627..ed25f2a834189f4e932f54688aa104e50abe492f 100644 (file)
@@ -57,9 +57,10 @@ public:
        virtual bool ResolveMacro(const String& macro, const Dictionary::Ptr& cr, String *result) const;
 
 protected:
-       virtual void Start(void);
        virtual void Stop(void);
 
+       virtual void OnConfigLoaded(void);
+
        virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
        virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);