mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-27 07:34:15 +02:00
Update execMacros
This commit is contained in:
parent
ee2f7bafdd
commit
f2e9aee158
@ -592,12 +592,10 @@ Dictionary::Ptr ApiActions::ExecuteCommand(const ConfigObject::Ptr& object,
|
|||||||
endpoint = HttpUtility::GetLastParameter(params, "endpoint");
|
endpoint = HttpUtility::GetLastParameter(params, "endpoint");
|
||||||
|
|
||||||
MacroProcessor::ResolverList resolvers;
|
MacroProcessor::ResolverList resolvers;
|
||||||
Dictionary::Ptr macros;
|
|
||||||
if (params->Contains("macros")) {
|
if (params->Contains("macros")) {
|
||||||
Value vmacros = HttpUtility::GetLastParameter(params, "macros");
|
Value macros = HttpUtility::GetLastParameter(params, "macros");
|
||||||
if (vmacros.IsObjectType<Dictionary>()) {
|
if (macros.IsObjectType<Dictionary>()) {
|
||||||
resolvers.emplace_back("override", vmacros);
|
resolvers.emplace_back("override", macros);
|
||||||
macros = vmacros;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return ApiActions::CreateResult(400, "Parameter macros must be a dictionary.");
|
return ApiActions::CreateResult(400, "Parameter macros must be a dictionary.");
|
||||||
@ -683,6 +681,25 @@ Dictionary::Ptr ApiActions::ExecuteCommand(const ConfigObject::Ptr& object,
|
|||||||
MessageOrigin::Ptr origin = new MessageOrigin();
|
MessageOrigin::Ptr origin = new MessageOrigin();
|
||||||
listener->RelayMessage(origin, checkable, updateMessage, true);
|
listener->RelayMessage(origin, checkable, updateMessage, true);
|
||||||
|
|
||||||
|
double scheduled_start = checkable->GetNextCheck();
|
||||||
|
double before_check = Utility::GetTime();
|
||||||
|
|
||||||
|
CheckResult::Ptr cr = new CheckResult();
|
||||||
|
cr->SetScheduleStart(scheduled_start);
|
||||||
|
cr->SetExecutionStart(before_check);
|
||||||
|
|
||||||
|
Dictionary::Ptr execMacros = new Dictionary();
|
||||||
|
if (command_type == "CheckCommand") {
|
||||||
|
CheckCommand::Ptr cmd = CheckCommand::GetByName(resolved_command);
|
||||||
|
cmd->Execute(checkable, cr, execMacros, false);
|
||||||
|
} else if (command_type == "EventCommand") {
|
||||||
|
EventCommand::Ptr cmd = EventCommand::GetByName(resolved_command);
|
||||||
|
cmd->Execute(checkable, execMacros, false);
|
||||||
|
} else if (command_type == "NotificationCommand") {
|
||||||
|
/* TODO */
|
||||||
|
return ApiActions::CreateResult(501, "Not implementd.");
|
||||||
|
}
|
||||||
|
|
||||||
/* Create execution parameters */
|
/* Create execution parameters */
|
||||||
Dictionary::Ptr execParams = new Dictionary();
|
Dictionary::Ptr execParams = new Dictionary();
|
||||||
execParams->Set("command_type", command_type);
|
execParams->Set("command_type", command_type);
|
||||||
@ -700,8 +717,7 @@ Dictionary::Ptr ApiActions::ExecuteCommand(const ConfigObject::Ptr& object,
|
|||||||
|
|
||||||
execParams->Set("source", uuid);
|
execParams->Set("source", uuid);
|
||||||
execParams->Set("deadline", deadline);
|
execParams->Set("deadline", deadline);
|
||||||
if (macros)
|
execParams->Set("macros", execMacros);
|
||||||
execParams->Set("macros", macros);
|
|
||||||
|
|
||||||
/* Execute command */
|
/* Execute command */
|
||||||
bool local = endpointPtr == Endpoint::GetLocalEndpoint();
|
bool local = endpointPtr == Endpoint::GetLocalEndpoint();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user