]> granicus.if.org Git - icinga2/commitdiff
Update DB IDO on changed object version (create, update, delete)
authorMichael Friedrich <michael.friedrich@netways.de>
Tue, 15 Sep 2015 09:59:09 +0000 (11:59 +0200)
committerMichael Friedrich <michael.friedrich@netways.de>
Thu, 17 Sep 2015 12:20:44 +0000 (14:20 +0200)
refs #9927

lib/db_ido/dbobject.cpp
lib/db_ido/dbobject.hpp

index 1689e91dc3afd9e79647284d6b412026fce24b64..3cb2470563b31c101fa92df7b977147565f43075 100644 (file)
@@ -49,6 +49,9 @@ void DbObject::StaticInitialize(void)
        /* triggered in ProcessCheckResult(), requires UpdateNextCheck() to be called before */
        ConfigObject::OnStateChanged.connect(boost::bind(&DbObject::StateChangedHandler, _1));
        CustomVarObject::OnVarsChanged.connect(boost::bind(&DbObject::VarsChangedHandler, _1));
+
+       /* triggered on create, update and delete objects */
+       ConfigObject::OnVersionChanged.connect(boost::bind(&DbObject::VersionChangedHandler, _1));
 }
 
 void DbObject::SetObject(const ConfigObject::Ptr& object)
@@ -355,6 +358,16 @@ void DbObject::VarsChangedHandler(const CustomVarObject::Ptr& object)
        dbobj->SendVarsStatusUpdate();
 }
 
+void DbObject::VersionChangedHandler(const ConfigObject::Ptr& object)
+{
+       DbObject::Ptr dbobj = DbObject::GetOrCreateByObject(object);
+
+       if (dbobj) {
+               dbobj->SendConfigUpdate();
+               dbobj->SendStatusUpdate();
+       }
+}
+
 boost::mutex& DbObject::GetStaticMutex(void)
 {
        static boost::mutex mutex;
index 9e808b68f2136eedeec9c3f16dfcf259f845f078..e4cfd330de1cf03d4bc0cec83b7b212f1562125b 100644 (file)
@@ -106,6 +106,8 @@ private:
 
        static void StateChangedHandler(const ConfigObject::Ptr& object);
        static void VarsChangedHandler(const CustomVarObject::Ptr& object);
+       static void VersionChangedHandler(const ConfigObject::Ptr& object);
+
        static boost::mutex& GetStaticMutex(void);
 
        friend class DbType;