From: Gunnar Beutner Date: Sat, 4 Aug 2012 08:23:18 +0000 (+0200) Subject: Fixed remote replication of non-config attributes. X-Git-Tag: v0.0.1~167 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b9ee3b26ebe9342b9bf27b549b5a796d0e4a64f8;p=icinga2 Fixed remote replication of non-config attributes. --- diff --git a/base/dynamicobject.cpp b/base/dynamicobject.cpp index da9ec8468..78a4ea2ad 100644 --- a/base/dynamicobject.cpp +++ b/base/dynamicobject.cpp @@ -468,16 +468,16 @@ void DynamicObject::RegisterClass(const String& type, DynamicObject::Factory fac GetClasses()[type] = factory; } -DynamicObject::Ptr DynamicObject::Create(const String& type, const Dictionary::Ptr& properties) +DynamicObject::Ptr DynamicObject::Create(const String& type, const Dictionary::Ptr& serializedUpdate) { DynamicObject::ClassMap::iterator ct; ct = GetClasses().find(type); DynamicObject::Ptr obj; if (ct != GetClasses().end()) { - obj = ct->second(properties); + obj = ct->second(serializedUpdate); } else { - obj = boost::make_shared(properties); + obj = boost::make_shared(serializedUpdate); Logger::Write(LogCritical, "base", "Creating generic DynamicObject for type '" + type + "'"); } @@ -494,6 +494,9 @@ DynamicObject::Ptr DynamicObject::Create(const String& type, const Dictionary::P m_PersistentUpdates.erase(st); } + /* apply the object's non-config attributes */ + obj->ApplyUpdate(serializedUpdate, Attribute_All & ~Attribute_Config); + return obj; } diff --git a/base/dynamicobject.h b/base/dynamicobject.h index ab3fb6f6a..d44d8316c 100644 --- a/base/dynamicobject.h +++ b/base/dynamicobject.h @@ -118,7 +118,7 @@ public: static void RestoreObjects(const String& filename); static void RegisterClass(const String& type, Factory factory); - static DynamicObject::Ptr Create(const String& type, const Dictionary::Ptr& properties); + static DynamicObject::Ptr Create(const String& type, const Dictionary::Ptr& serializedUpdate); static double GetCurrentTx(void); static void BeginTx(void); diff --git a/components/cibsync/cibsynccomponent.cpp b/components/cibsync/cibsynccomponent.cpp index 3093ae212..e1727f819 100644 --- a/components/cibsync/cibsynccomponent.cpp +++ b/components/cibsync/cibsynccomponent.cpp @@ -26,8 +26,6 @@ using namespace icinga; */ void CIBSyncComponent::Start(void) { - m_SyncingConfig = false; - m_Endpoint = boost::make_shared(); /* config objects */ @@ -148,10 +146,6 @@ void CIBSyncComponent::FetchObjectsHandler(const Endpoint::Ptr& sender) void CIBSyncComponent::LocalObjectRegisteredHandler(const DynamicObject::Ptr& object) { - /* don't send messages when we're currently processing a remote update */ - if (m_SyncingConfig) - return; - if (!ShouldReplicateObject(object)) return; @@ -161,10 +155,6 @@ void CIBSyncComponent::LocalObjectRegisteredHandler(const DynamicObject::Ptr& ob void CIBSyncComponent::LocalObjectUnregisteredHandler(const DynamicObject::Ptr& object) { - /* don't send messages when we're currently processing a remote update */ - if (m_SyncingConfig) - return; - if (!ShouldReplicateObject(object)) return; @@ -259,14 +249,7 @@ void CIBSyncComponent::RemoteObjectRemovedHandler(const RequestMessage& request) return; if (!object->IsLocal()) { - try { - m_SyncingConfig = true; - object->Unregister(); - m_SyncingConfig = false; - } catch (...) { - m_SyncingConfig = false; - throw; - } + object->Unregister(); } } diff --git a/components/cibsync/cibsynccomponent.h b/components/cibsync/cibsynccomponent.h index 7188fef12..56456682f 100644 --- a/components/cibsync/cibsynccomponent.h +++ b/components/cibsync/cibsynccomponent.h @@ -34,7 +34,6 @@ public: private: VirtualEndpoint::Ptr m_Endpoint; - bool m_SyncingConfig; static void ServiceStateChangeRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request); diff --git a/icinga-app/icinga-c2.pem b/icinga-app/icinga-c2.pem index e1bc7de13..420d800e8 100644 --- a/icinga-app/icinga-c2.pem +++ b/icinga-app/icinga-c2.pem @@ -14,7 +14,8 @@ MBaAFNVJHVPJNwqEcG51lpqZJWVPaysFMA0GCSqGSIb3DQEBBQUAA4GBAIhhjKWw 5JKirNidgG9PuD8x47VsRTkESLlq/pS7KjkE1nWCG9JpR5oVSzx2WXomiaAZ4q2C WS1z4HD9HF4NbhY+xVBi0Fj/kotuXCCweRo5EVp7Q4fabm1maJemFwMTHGhBLu7a v4dquYyOk9Dhkwcjajyn+KWceCoUTdI3LB2t ------END CERTIFICATE----------BEGIN PRIVATE KEY----- +-----END CERTIFICATE----- +-----BEGIN PRIVATE KEY----- MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAKznFbotQFqI2z7i v+1nvbsCAS2ji3wcUESN/pOj8843bWl0+Io0/w0mr0OVOMBji2IdMrksqkvPEF/w 7Kgxi150lbPJk9+24qDDsNl4p6mjUOsSuL8otBWMUnsCOmDpGIu9d+TRGklIHfNo diff --git a/icinga-app/icinga-checker1.conf b/icinga-app/icinga-checker1.conf index 15b09ff75..b32ccb83a 100644 --- a/icinga-app/icinga-checker1.conf +++ b/icinga-app/icinga-checker1.conf @@ -1,25 +1,30 @@ -local object application "icinga" { - ca = "ca.crt", - cert = "icinga-c2.pem" +local object Application "icinga" { + cert = "icinga-c2.pem", + ca = "ca.crt", + + pidpath = "icinga-checker1.pid", + + macros = { + plugindir = "/usr/local/icinga/libexec" + } } -local object component "checker" { +local object Component "checker" { } -local object component "discovery" { - broker = 0 +local object Component "discovery" { + broker = 0 } /* trusted upstream endpoint */ -local object endpoint "icinga-c1" { - node = "192.168.5.46", - service = 7777, +local object Endpoint "icinga-c1" { + node = "192.168.5.46", + service = 7777, - roles = { "all" } + roles = { "all" } } -local object role "all" { - publications = { "*" }, - subscriptions = { "*" } +local object Role "all" { + publications = { "*" }, + subscriptions = { "*" } } -