Merge pull request #8706 from Icinga/bugfix/icingadb-endpoint-zone

Icinga DB: dump the correct icinga:config:endpoint#zone_id
This commit is contained in:
Alexander Aleksandrovič Klimov 2021-04-26 11:31:51 +02:00 committed by GitHub
commit 7f5225ecaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 3 deletions

View File

@ -1088,14 +1088,20 @@ bool IcingaDB::PrepareObject(const ConfigObject::Ptr& object, Dictionary::Ptr& a
attributes->Set("environment_id", m_EnvironmentId);
attributes->Set("name", object->GetName());
Zone::Ptr ObjectsZone = static_pointer_cast<Zone>(object->GetZone());
Zone::Ptr ObjectsZone;
Type::Ptr type = object->GetReflectionType();
if (type == Endpoint::TypeInstance) {
ObjectsZone = static_cast<Endpoint*>(object.get())->GetZone();
} else {
ObjectsZone = static_pointer_cast<Zone>(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;
}