mirror of https://github.com/Icinga/icinga2.git
Get host by Deserialize
This commit is contained in:
parent
27f8bc5920
commit
4255fd9494
|
@ -104,24 +104,30 @@ void ClusterEvents::ExecuteCheckFromQueue(const MessageOrigin::Ptr& origin, cons
|
||||||
if (params->Contains("source")) {
|
if (params->Contains("source")) {
|
||||||
String uuid = params->Get("source");
|
String uuid = params->Get("source");
|
||||||
|
|
||||||
Host::Ptr host = Host::GetByName(params->Get("host"));
|
Host::Ptr host = new Host();
|
||||||
if (!host) {
|
Dictionary::Ptr attrs = new Dictionary();
|
||||||
Log(LogCritical, "ApiListener") << "Host '" << params->Get("host") << "' not found.";
|
|
||||||
return;
|
attrs->Set("__name", params->Get("host"));
|
||||||
}
|
attrs->Set("type", "Host");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Override the check timeout if the parent caller provided the value. Compatible with older versions not
|
||||||
|
* passing this inside the cluster message.
|
||||||
|
* This happens with host/service command_endpoint agents and the 'check_timeout' attribute being specified.
|
||||||
|
*/
|
||||||
|
if (params->Contains("check_timeout"))
|
||||||
|
attrs->Set("check_timeout", params->Get("check_timeout"));
|
||||||
|
|
||||||
|
Deserialize(host, attrs, false, FAConfig);
|
||||||
|
|
||||||
Checkable::Ptr checkable;
|
|
||||||
if (params->Contains("service"))
|
if (params->Contains("service"))
|
||||||
checkable = host->GetServiceByShortName(params->Get("service"));
|
host->SetExtension("agent_service_name", params->Get("service"));
|
||||||
else
|
|
||||||
checkable = host;
|
|
||||||
|
|
||||||
if (!checkable) {
|
attrs->Set(params->Get("command_type"), params->Get("command"));
|
||||||
Log(LogCritical, "ApiListener") << "Checkable '" << params->Get("host")
|
attrs->Set("command_endpoint", sourceEndpoint->GetName());
|
||||||
<< "!" << params->Get("service") << "' not found.";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Deserialize(host, attrs, false, FAConfig);
|
||||||
|
Checkable::Ptr checkable = host;
|
||||||
ObjectLock oLock (checkable);
|
ObjectLock oLock (checkable);
|
||||||
|
|
||||||
if (origin->FromZone && !origin->FromZone->CanAccessObject(checkable)) {
|
if (origin->FromZone && !origin->FromZone->CanAccessObject(checkable)) {
|
||||||
|
|
Loading…
Reference in New Issue