| 1392 | } |
| 1393 | |
| 1394 | Value ClusterEvents::ExecutedCommandAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params) |
| 1395 | { |
| 1396 | ApiListener::Ptr listener = ApiListener::GetInstance(); |
| 1397 | |
| 1398 | if (!listener) |
| 1399 | return Empty; |
| 1400 | |
| 1401 | Endpoint::Ptr endpoint; |
| 1402 | |
| 1403 | if (origin->FromClient) { |
| 1404 | endpoint = origin->FromClient->GetEndpoint(); |
| 1405 | } else if (origin->IsLocal()) { |
| 1406 | endpoint = Endpoint::GetLocalEndpoint(); |
| 1407 | } |
| 1408 | |
| 1409 | if (!endpoint) { |
| 1410 | Log(LogNotice, "ClusterEvents") |
| 1411 | << "Discarding 'update executions API handler' message from '" << origin->FromClient->GetIdentity() |
| 1412 | << "': Invalid endpoint origin (client not allowed)."; |
| 1413 | |
| 1414 | return Empty; |
| 1415 | } |
| 1416 | |
| 1417 | Host::Ptr host = Host::GetByName(params->Get("host")); |
| 1418 | |
| 1419 | if (!host) |
| 1420 | return Empty; |
| 1421 | |
| 1422 | Checkable::Ptr checkable; |
| 1423 | |
| 1424 | if (params->Contains("service")) |
| 1425 | checkable = host->GetServiceByShortName(params->Get("service")); |
| 1426 | else |
| 1427 | checkable = host; |
| 1428 | |
| 1429 | if (!checkable) |
| 1430 | return Empty; |
| 1431 | |
| 1432 | ObjectLock oLock (checkable); |
| 1433 | |
| 1434 | if (!params->Contains("execution")) { |
| 1435 | Log(LogNotice, "ClusterEvents") |
| 1436 | << "Discarding 'update executions API handler' message for checkable '" << checkable->GetName() |
| 1437 | << "' from '" << origin->FromClient->GetIdentity() << "': Execution UUID missing."; |
| 1438 | return Empty; |
| 1439 | } |
| 1440 | |
| 1441 | String uuid = params->Get("execution"); |
| 1442 | |
| 1443 | Dictionary::Ptr executions = checkable->GetExecutions(); |
| 1444 | |
| 1445 | if (!executions) { |
| 1446 | Log(LogNotice, "ClusterEvents") |
| 1447 | << "Discarding 'update executions API handler' message for checkable '" << checkable->GetName() |
| 1448 | << "' from '" << origin->FromClient->GetIdentity() << "': Execution '" << uuid << "' missing."; |
| 1449 | return Empty; |
| 1450 | } |
| 1451 |
nothing calls this directly
no test coverage detected