mirror of https://github.com/Icinga/icinga2.git
parent
d0ca16cdde
commit
9181d7ae05
|
@ -194,6 +194,17 @@ void Dictionary::Remove(Dictionary::Iterator it)
|
|||
m_Data.erase(it);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all dictionary items.
|
||||
*/
|
||||
void Dictionary::Clear(void)
|
||||
{
|
||||
ASSERT(!OwnsLock());
|
||||
ObjectLock olock(this);
|
||||
|
||||
m_Data.clear();
|
||||
}
|
||||
|
||||
void Dictionary::CopyTo(const Dictionary::Ptr& dest) const
|
||||
{
|
||||
ASSERT(!OwnsLock());
|
||||
|
|
|
@ -62,6 +62,8 @@ public:
|
|||
void Remove(const String& key);
|
||||
void Remove(Iterator it);
|
||||
|
||||
void Clear(void);
|
||||
|
||||
void CopyTo(const Dictionary::Ptr& dest) const;
|
||||
Dictionary::Ptr ShallowClone(void) const;
|
||||
|
||||
|
|
|
@ -1535,9 +1535,12 @@ Value ApiEvents::ExecuteCommandAPIHandler(const MessageOrigin& origin, const Dic
|
|||
|
||||
Deserialize(host, attrs, false, FAConfig);
|
||||
|
||||
if (params->Contains("service"))
|
||||
host->SetExtension("agent_service_name", params->Get("service"));
|
||||
|
||||
CheckResult::Ptr cr = new CheckResult();
|
||||
cr->SetState(ServiceUnknown);
|
||||
cr->SetOutput("'" + listener->GetName() + "' does not accept commands.");
|
||||
cr->SetOutput("Endpoint '" + Endpoint::GetLocalEndpoint()->GetName() + "' does not accept commands.");
|
||||
Dictionary::Ptr message = MakeCheckResultMessage(host, cr);
|
||||
listener->SyncSendMessage(sourceEndpoint, message);
|
||||
|
||||
|
@ -1551,6 +1554,11 @@ Value ApiEvents::ExecuteCommandAPIHandler(const MessageOrigin& origin, const Dic
|
|||
attrs->Set("__name", params->Get("host"));
|
||||
attrs->Set("type", "Host");
|
||||
|
||||
Deserialize(host, attrs, false, FAConfig);
|
||||
|
||||
if (params->Contains("service"))
|
||||
host->SetExtension("agent_service_name", params->Get("service"));
|
||||
|
||||
String command = params->Get("command");
|
||||
String command_type = params->Get("command_type");
|
||||
|
||||
|
@ -1569,14 +1577,12 @@ Value ApiEvents::ExecuteCommandAPIHandler(const MessageOrigin& origin, const Dic
|
|||
} else
|
||||
return Empty;
|
||||
|
||||
attrs->Clear();
|
||||
attrs->Set(command_type, params->Get("command"));
|
||||
attrs->Set("command_endpoint", sourceEndpoint->GetName());
|
||||
|
||||
Deserialize(host, attrs, false, FAConfig);
|
||||
|
||||
if (params->Contains("service"))
|
||||
host->SetExtension("agent_service_name", params->Get("service"));
|
||||
|
||||
host->SetExtension("agent_check", true);
|
||||
|
||||
static_pointer_cast<DynamicObject>(host)->OnStateLoaded();
|
||||
|
|
Loading…
Reference in New Issue