Icinga DB: dump the correct icinga:config:endpoint#zone_id

This commit is contained in:
Alexander A. Klimov 2021-03-26 13:53:31 +01:00
parent 9830dc194b
commit 7dcf48f707
1 changed files with 9 additions and 3 deletions

View File

@ -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<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;
}