mirror of https://github.com/Icinga/icinga2.git
parent
832b5bed2a
commit
81974adf65
|
@ -39,26 +39,20 @@ void Endpoint::OnAllConfigLoaded(void)
|
|||
{
|
||||
ObjectImpl<Endpoint>::OnAllConfigLoaded();
|
||||
|
||||
BOOST_FOREACH(const Zone::Ptr& zone, ConfigType::GetObjectsByType<Zone>()) {
|
||||
const std::set<Endpoint::Ptr> members = zone->GetEndpoints();
|
||||
|
||||
if (members.empty())
|
||||
continue;
|
||||
|
||||
if (members.find(this) != members.end()) {
|
||||
if (m_Zone)
|
||||
BOOST_THROW_EXCEPTION(ScriptError("Endpoint '" + GetName()
|
||||
+ "' is in more than one zone.", GetDebugInfo()));
|
||||
|
||||
m_Zone = zone;
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_Zone)
|
||||
BOOST_THROW_EXCEPTION(ScriptError("Endpoint '" + GetName() +
|
||||
"' does not belong to a zone.", GetDebugInfo()));
|
||||
}
|
||||
|
||||
void Endpoint::SetCachedZone(const Zone::Ptr& zone)
|
||||
{
|
||||
if (m_Zone)
|
||||
BOOST_THROW_EXCEPTION(ScriptError("Endpoint '" + GetName()
|
||||
+ "' is in more than one zone.", GetDebugInfo()));
|
||||
|
||||
m_Zone = zone;
|
||||
}
|
||||
|
||||
void Endpoint::AddClient(const JsonRpcConnection::Ptr& client)
|
||||
{
|
||||
bool was_master = ApiListener::GetInstance()->IsMaster();
|
||||
|
|
|
@ -54,6 +54,8 @@ public:
|
|||
|
||||
static Endpoint::Ptr GetLocalEndpoint(void);
|
||||
|
||||
void SetCachedZone(const intrusive_ptr<Zone>& zone);
|
||||
|
||||
protected:
|
||||
virtual void OnAllConfigLoaded(void) override;
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@ namespace icinga
|
|||
|
||||
class Endpoint : ConfigObject
|
||||
{
|
||||
load_after Zone;
|
||||
|
||||
[config] String host;
|
||||
[config, required] String port {
|
||||
default {{{ return "5665"; }}}
|
||||
|
|
|
@ -37,6 +37,14 @@ void Zone::OnAllConfigLoaded(void)
|
|||
Zone::Ptr zone = m_Parent;
|
||||
int levels = 0;
|
||||
|
||||
Array::Ptr endpoints = GetEndpointsRaw();
|
||||
|
||||
if (endpoints) {
|
||||
BOOST_FOREACH(const String& endpoint, endpoints) {
|
||||
Endpoint::GetByName(endpoint)->SetCachedZone(this);
|
||||
}
|
||||
}
|
||||
|
||||
while (zone) {
|
||||
m_AllParents.push_back(zone);
|
||||
|
||||
|
|
Loading…
Reference in New Issue