mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-27 15:44:11 +02:00
Implement ClusterEvents::UpdateExecutionsAPIHandler
This commit is contained in:
parent
82444a59e2
commit
35bb329a59
@ -949,5 +949,47 @@ Value ClusterEvents::ExecutedCommandAPIHandler(const MessageOrigin::Ptr& origin,
|
|||||||
|
|
||||||
Value ClusterEvents::UpdateExecutionsAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params)
|
Value ClusterEvents::UpdateExecutionsAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params)
|
||||||
{
|
{
|
||||||
return "Not implemented";
|
Endpoint::Ptr endpoint = origin->FromClient->GetEndpoint();
|
||||||
|
if (!endpoint) {
|
||||||
|
Log(LogNotice, "ClusterEvents")
|
||||||
|
<< "Discarding 'update executions API handler' message from '" << origin->FromClient->GetIdentity()
|
||||||
|
<< "': Invalid endpoint origin (client not allowed).";
|
||||||
|
|
||||||
|
return Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
Host::Ptr host = Host::GetByName(params->Get("host"));
|
||||||
|
if (!host)
|
||||||
|
return Empty;
|
||||||
|
|
||||||
|
Checkable::Ptr checkable;
|
||||||
|
|
||||||
|
if (params->Contains("service"))
|
||||||
|
checkable = host->GetServiceByShortName(params->Get("service"));
|
||||||
|
else
|
||||||
|
checkable = host;
|
||||||
|
|
||||||
|
if (!checkable)
|
||||||
|
return Empty;
|
||||||
|
|
||||||
|
ObjectLock oLock (checkable);
|
||||||
|
|
||||||
|
if (origin->FromZone && !origin->FromZone->CanAccessObject(checkable)) {
|
||||||
|
Log(LogNotice, "ClusterEvents")
|
||||||
|
<< "Discarding 'update executions API handler' message for checkable '" << checkable->GetName()
|
||||||
|
<< "' from '" << origin->FromClient->GetIdentity() << "': Unauthorized access.";
|
||||||
|
return Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!params->Contains("executions")) {
|
||||||
|
Log(LogNotice, "ClusterEvents")
|
||||||
|
<< "Discarding 'update executions API handler' message for checkable '" << checkable->GetName()
|
||||||
|
<< "' from '" << origin->FromClient->GetIdentity() << "': missing executions.";
|
||||||
|
return Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
Dictionary::Ptr executions = params->Get("executions");
|
||||||
|
checkable->SetExecutions(executions);
|
||||||
|
|
||||||
|
return Empty;
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user