From 7dcf48f70774e67b3cb89fd79c222753caf63e45 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 26 Mar 2021 13:53:31 +0100 Subject: [PATCH] Icinga DB: dump the correct icinga:config:endpoint#zone_id --- lib/icingadb/icingadb-objects.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/icingadb/icingadb-objects.cpp b/lib/icingadb/icingadb-objects.cpp index 4d7e2f9f3..ad38a0486 100644 --- a/lib/icingadb/icingadb-objects.cpp +++ b/lib/icingadb/icingadb-objects.cpp @@ -1089,14 +1089,20 @@ bool IcingaDB::PrepareObject(const ConfigObject::Ptr& object, Dictionary::Ptr& a attributes->Set("environment_id", SHA1(GetEnvironment())); attributes->Set("name", object->GetName()); - Zone::Ptr ObjectsZone = static_pointer_cast(object->GetZone()); + Zone::Ptr ObjectsZone; + Type::Ptr type = object->GetReflectionType(); + + if (type == Endpoint::TypeInstance) { + ObjectsZone = static_cast(object.get())->GetZone(); + } else { + ObjectsZone = static_pointer_cast(object->GetZone()); + } + if (ObjectsZone) { attributes->Set("zone_id", GetObjectIdentifier(ObjectsZone)); attributes->Set("zone", ObjectsZone->GetName()); } - Type::Ptr type = object->GetReflectionType(); - if (type == Endpoint::TypeInstance) { return true; }