mirror of https://github.com/Icinga/icinga2.git
parent
1bfb91f065
commit
40d68fcce2
|
@ -243,7 +243,7 @@ Value ApiListener::ConfigDeleteObjectAPIHandler(const MessageOrigin::Ptr& origin
|
||||||
|
|
||||||
if (!object) {
|
if (!object) {
|
||||||
Log(LogNotice, "ApiListener")
|
Log(LogNotice, "ApiListener")
|
||||||
<< "Could not delete non-existent object '" << params->Get("name") << "'.";
|
<< "Could not delete non-existent object '" << params->Get("name") << "' with type '" << params->Get("type") << "'.";
|
||||||
return Empty;
|
return Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -689,7 +689,7 @@ void ApiListener::SyncSendMessage(const Endpoint::Ptr& endpoint, const Dictionar
|
||||||
|
|
||||||
if (!endpoint->GetSyncing()) {
|
if (!endpoint->GetSyncing()) {
|
||||||
Log(LogNotice, "ApiListener")
|
Log(LogNotice, "ApiListener")
|
||||||
<< "Sending message to '" << endpoint->GetName() << "'";
|
<< "Sending message '" << message->Get("method") << "' to '" << endpoint->GetName() << "'";
|
||||||
|
|
||||||
double maxTs = 0;
|
double maxTs = 0;
|
||||||
|
|
||||||
|
@ -713,9 +713,15 @@ bool ApiListener::RelayMessageOne(const Zone::Ptr& targetZone, const MessageOrig
|
||||||
|
|
||||||
Zone::Ptr myZone = Zone::GetLocalZone();
|
Zone::Ptr myZone = Zone::GetLocalZone();
|
||||||
|
|
||||||
/* only relay the message to a) the same zone, b) the parent zone and c) direct child zones */
|
/* only relay the message to a) the same zone, b) the parent zone and c) direct child zones. Exception is a global zone. */
|
||||||
if (targetZone != myZone && targetZone != myZone->GetParent() && targetZone->GetParent() != myZone)
|
if (!targetZone->GetGlobal() &&
|
||||||
|
targetZone != myZone &&
|
||||||
|
targetZone != myZone->GetParent() &&
|
||||||
|
targetZone->GetParent() != myZone) {
|
||||||
|
Log(LogCritical, "ApiListener")
|
||||||
|
<< "Not relaying message '" << message->Get("method") << "'. Not in the same/parent/child zone.";
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Endpoint::Ptr myEndpoint = GetLocalEndpoint();
|
Endpoint::Ptr myEndpoint = GetLocalEndpoint();
|
||||||
|
|
||||||
|
@ -723,7 +729,23 @@ bool ApiListener::RelayMessageOne(const Zone::Ptr& targetZone, const MessageOrig
|
||||||
|
|
||||||
bool relayed = false, log_needed = false, log_done = false;
|
bool relayed = false, log_needed = false, log_done = false;
|
||||||
|
|
||||||
for (const Endpoint::Ptr& endpoint : targetZone->GetEndpoints()) {
|
std::set<Endpoint::Ptr> targetEndpoints;
|
||||||
|
|
||||||
|
if (targetZone->GetGlobal()) {
|
||||||
|
targetEndpoints = myZone->GetEndpoints();
|
||||||
|
|
||||||
|
for (const Zone::Ptr& zone : ConfigType::GetObjectsByType<Zone>()) {
|
||||||
|
/* Fetch immediate child zone members */
|
||||||
|
if (zone->GetParent() == myZone) {
|
||||||
|
std::set<Endpoint::Ptr> endpoints = zone->GetEndpoints();
|
||||||
|
targetEndpoints.insert(endpoints.begin(), endpoints.end());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
targetEndpoints = targetZone->GetEndpoints();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const Endpoint::Ptr& endpoint : targetEndpoints) {
|
||||||
/* don't relay messages to ourselves */
|
/* don't relay messages to ourselves */
|
||||||
if (endpoint == GetLocalEndpoint())
|
if (endpoint == GetLocalEndpoint())
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -103,6 +103,9 @@ bool Zone::CanAccessObject(const ConfigObject::Ptr& object)
|
||||||
if (!object_zone)
|
if (!object_zone)
|
||||||
object_zone = Zone::GetLocalZone();
|
object_zone = Zone::GetLocalZone();
|
||||||
|
|
||||||
|
if (object_zone->GetGlobal())
|
||||||
|
return true;
|
||||||
|
|
||||||
return object_zone->IsChildOf(this);
|
return object_zone->IsChildOf(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue