Merge pull request #6531 from Icinga/feature/zone-all_parents

Expose Zone#all_parents via API
This commit is contained in:
Michael Friedrich 2018-08-09 13:11:23 +02:00 committed by GitHub
commit f1e7e635a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 3 deletions

View File

@ -1003,7 +1003,7 @@ void ApiListener::SyncRelayMessage(const MessageOrigin::Ptr& origin,
bool need_log = !RelayMessageOne(target_zone, origin, message, master); bool need_log = !RelayMessageOne(target_zone, origin, message, master);
for (const Zone::Ptr& zone : target_zone->GetAllParents()) { for (const Zone::Ptr& zone : target_zone->GetAllParentsRaw()) {
if (!RelayMessageOne(zone, origin, message, master)) if (!RelayMessageOne(zone, origin, message, master))
need_log = true; need_log = true;
} }

View File

@ -20,6 +20,7 @@
#include "remote/zone.hpp" #include "remote/zone.hpp"
#include "remote/zone-ti.cpp" #include "remote/zone-ti.cpp"
#include "remote/jsonrpcconnection.hpp" #include "remote/jsonrpcconnection.hpp"
#include "base/array.hpp"
#include "base/objectlock.hpp" #include "base/objectlock.hpp"
#include "base/logger.hpp" #include "base/logger.hpp"
@ -89,11 +90,21 @@ std::set<Endpoint::Ptr> Zone::GetEndpoints() const
return result; return result;
} }
std::vector<Zone::Ptr> Zone::GetAllParents() const std::vector<Zone::Ptr> Zone::GetAllParentsRaw() const
{ {
return m_AllParents; return m_AllParents;
} }
Array::Ptr Zone::GetAllParents() const
{
auto result (new Array);
for (auto& parent : m_AllParents)
result->Add(parent->GetName());
return result;
}
bool Zone::CanAccessObject(const ConfigObject::Ptr& object) bool Zone::CanAccessObject(const ConfigObject::Ptr& object)
{ {
Zone::Ptr object_zone; Zone::Ptr object_zone;

View File

@ -40,7 +40,8 @@ public:
Zone::Ptr GetParent() const; Zone::Ptr GetParent() const;
std::set<Endpoint::Ptr> GetEndpoints() const; std::set<Endpoint::Ptr> GetEndpoints() const;
std::vector<Zone::Ptr> GetAllParents() const; std::vector<Zone::Ptr> GetAllParentsRaw() const;
Array::Ptr GetAllParents() const override;
bool CanAccessObject(const ConfigObject::Ptr& object); bool CanAccessObject(const ConfigObject::Ptr& object);
bool IsChildOf(const Zone::Ptr& zone); bool IsChildOf(const Zone::Ptr& zone);

View File

@ -34,6 +34,9 @@ class Zone : ConfigObject
[config] array(name(Endpoint)) endpoints (EndpointsRaw); [config] array(name(Endpoint)) endpoints (EndpointsRaw);
[config] bool global; [config] bool global;
[no_user_modify, no_storage] array(Value) all_parents {
get;
};
}; };
} }