mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-27 07:34:15 +02:00
Use RelayMessage to broadcast the updated executions
This commit is contained in:
parent
626080f610
commit
cb32786880
@ -659,6 +659,25 @@ Dictionary::Ptr ApiActions::ExecuteCommand(const ConfigObject::Ptr& object,
|
|||||||
executions->Set(uuid, pending_execution);
|
executions->Set(uuid, pending_execution);
|
||||||
checkable->SetExecutions(executions);
|
checkable->SetExecutions(executions);
|
||||||
|
|
||||||
|
/* Broadcast the update */
|
||||||
|
ApiListener::Ptr listener = ApiListener::GetInstance();
|
||||||
|
if (!listener)
|
||||||
|
return ApiActions::CreateResult(404, "No ApiListener instance available.");
|
||||||
|
|
||||||
|
Dictionary::Ptr updateParams = new Dictionary();
|
||||||
|
updateParams->Set("host", host->GetName());
|
||||||
|
if (service)
|
||||||
|
updateParams->Set("service", service->GetShortName());
|
||||||
|
updateParams->Set("executions", executions);
|
||||||
|
|
||||||
|
Dictionary::Ptr updateMessage = new Dictionary();
|
||||||
|
updateMessage->Set("jsonrpc", "2.0");
|
||||||
|
updateMessage->Set("method", "event::UpdateExecutions");
|
||||||
|
updateMessage->Set("params", updateParams);
|
||||||
|
|
||||||
|
MessageOrigin::Ptr origin = new MessageOrigin();
|
||||||
|
listener->RelayMessage(origin, checkable, updateMessage, true);
|
||||||
|
|
||||||
/* Create execution parameters */
|
/* Create execution parameters */
|
||||||
Dictionary::Ptr execParams = new Dictionary();
|
Dictionary::Ptr execParams = new Dictionary();
|
||||||
execParams->Set("command_type", command_type);
|
execParams->Set("command_type", command_type);
|
||||||
@ -677,30 +696,11 @@ Dictionary::Ptr ApiActions::ExecuteCommand(const ConfigObject::Ptr& object,
|
|||||||
execParams->Set("source", uuid);
|
execParams->Set("source", uuid);
|
||||||
execParams->Set("deadline", deadline);
|
execParams->Set("deadline", deadline);
|
||||||
|
|
||||||
|
/* Execute command */
|
||||||
bool local = endpointPtr == Endpoint::GetLocalEndpoint();
|
bool local = endpointPtr == Endpoint::GetLocalEndpoint();
|
||||||
if (local) {
|
if (local) {
|
||||||
MessageOrigin::Ptr origin = new MessageOrigin();
|
|
||||||
ClusterEvents::ExecuteCommandAPIHandler(origin, execParams);
|
ClusterEvents::ExecuteCommandAPIHandler(origin, execParams);
|
||||||
} else {
|
} else {
|
||||||
/* Broadcast the update */
|
|
||||||
ApiListener::Ptr listener = ApiListener::GetInstance();
|
|
||||||
if (!listener)
|
|
||||||
return ApiActions::CreateResult(404, "No ApiListener instance available.");
|
|
||||||
|
|
||||||
Dictionary::Ptr updateParams = new Dictionary();
|
|
||||||
updateParams->Set("host", host->GetName());
|
|
||||||
if (service)
|
|
||||||
updateParams->Set("service", service->GetShortName());
|
|
||||||
updateParams->Set("executions", executions);
|
|
||||||
|
|
||||||
Dictionary::Ptr updateMessage = new Dictionary();
|
|
||||||
updateMessage->Set("jsonrpc", "2.0");
|
|
||||||
updateMessage->Set("method", "event::UpdateExecutions");
|
|
||||||
updateMessage->Set("params", updateParams);
|
|
||||||
|
|
||||||
listener->SyncSendMessage(endpointPtr, updateMessage);
|
|
||||||
|
|
||||||
/* Execute command */
|
|
||||||
Dictionary::Ptr execMessage = new Dictionary();
|
Dictionary::Ptr execMessage = new Dictionary();
|
||||||
execMessage->Set("jsonrpc", "2.0");
|
execMessage->Set("jsonrpc", "2.0");
|
||||||
execMessage->Set("method", "event::ExecuteCommand");
|
execMessage->Set("method", "event::ExecuteCommand");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user