MCPcopy Create free account
hub / github.com/Icinga/icinga2 / ExecutedCommandAPIHandler

Method ExecutedCommandAPIHandler

lib/icinga/clusterevents.cpp:1394–1510  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1392}
1393
1394Value 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

Callers

nothing calls this directly

Calls 13

LogClass · 0.85
GetEndpointMethod · 0.80
IsLocalMethod · 0.80
GetIdentityMethod · 0.80
GetServiceByShortNameMethod · 0.80
IsChildOfMethod · 0.80
RelayMessageMethod · 0.80
GetMethod · 0.45
ContainsMethod · 0.45
GetNameMethod · 0.45
GetZoneMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected