mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 13:45:04 +02:00
Forward the execute command through the zones
This commit is contained in:
parent
c2f8d6df44
commit
951388797a
@ -806,6 +806,7 @@ Dictionary::Ptr ApiActions::ExecuteCommand(const ConfigObject::Ptr& object,
|
||||
execParams->Set("source", uuid);
|
||||
execParams->Set("deadline", deadline);
|
||||
execParams->Set("macros", execMacros);
|
||||
execParams->Set("endpoint", resolved_endpoint);
|
||||
|
||||
/* Execute command */
|
||||
bool local = endpointPtr == Endpoint::GetLocalEndpoint();
|
||||
@ -817,7 +818,7 @@ Dictionary::Ptr ApiActions::ExecuteCommand(const ConfigObject::Ptr& object,
|
||||
execMessage->Set("method", "event::ExecuteCommand");
|
||||
execMessage->Set("params", execParams);
|
||||
|
||||
listener->SyncSendMessage(endpointPtr, execMessage);
|
||||
listener->RelayMessage(origin, checkable, execMessage, true);
|
||||
}
|
||||
|
||||
Dictionary::Ptr result = new Dictionary();
|
||||
|
@ -619,7 +619,29 @@ Value ClusterEvents::AcknowledgementClearedAPIHandler(const MessageOrigin::Ptr&
|
||||
|
||||
Value ClusterEvents::ExecuteCommandAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params)
|
||||
{
|
||||
EnqueueCheck(origin, params);
|
||||
ApiListener::Ptr listener = ApiListener::GetInstance();
|
||||
if (!listener)
|
||||
return Empty;
|
||||
|
||||
Endpoint::Ptr execEndpoint = Endpoint::GetByName(params->Get("endpoint"));
|
||||
if (execEndpoint != Endpoint::GetLocalEndpoint()) {
|
||||
|
||||
Zone::Ptr endpointZone = execEndpoint->GetZone();
|
||||
Zone::Ptr localZone = Zone::GetLocalZone();
|
||||
|
||||
if (!endpointZone->IsChildOf(localZone)) {
|
||||
return Empty;
|
||||
}
|
||||
|
||||
Dictionary::Ptr execMessage = new Dictionary();
|
||||
execMessage->Set("jsonrpc", "2.0");
|
||||
execMessage->Set("method", "event::ExecuteCommand");
|
||||
execMessage->Set("params", params);
|
||||
|
||||
listener->RelayMessage(origin, endpointZone, execMessage, true);
|
||||
} else {
|
||||
EnqueueCheck(origin, params);
|
||||
}
|
||||
|
||||
return Empty;
|
||||
}
|
||||
@ -1084,5 +1106,21 @@ Value ClusterEvents::UpdateExecutionsAPIHandler(const MessageOrigin::Ptr& origin
|
||||
newExecutions->CopyTo(executions);
|
||||
checkable->SetExecutions(executions);
|
||||
|
||||
ApiListener::Ptr listener = ApiListener::GetInstance();
|
||||
if (!listener)
|
||||
return Empty;
|
||||
|
||||
Dictionary::Ptr updateMessage = new Dictionary();
|
||||
updateMessage->Set("jsonrpc", "2.0");
|
||||
updateMessage->Set("method", "event::UpdateExecutions");
|
||||
updateMessage->Set("params", params);
|
||||
|
||||
Zone::Ptr localZone = Zone::GetLocalZone();
|
||||
Zone::Ptr parentZone = localZone->GetParent();
|
||||
|
||||
if (localZone != parentZone) {
|
||||
listener->RelayMessage(origin, parentZone, updateMessage, true);
|
||||
}
|
||||
|
||||
return Empty;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user