[ Agent ] [ Executor ] 优化Executor部分的代码 - 完成

This commit is contained in:
zeaslity
2023-08-14 11:35:28 +08:00
parent 129886bd57
commit 497677d727
9 changed files with 102 additions and 11 deletions

View File

@@ -4,11 +4,10 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.wdd.common.response.R;
import io.wdd.rpc.beans.request.ExecutionEntity;
import io.wdd.rpc.execute.service.ExecutionService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Nullable;
import javax.annotation.Resource;
@@ -100,20 +99,23 @@ public class ExecutionController {
@PostMapping("/command/sync/one")
@ApiOperation("[命令] [同步] - 单机-等待命令结果")
public R<List<String>> SyncPatchCommandToAgent(
public R<List<String>> SyncCommandToAgent(
@RequestParam(value = "topicName") @ApiParam(name = "topicName", value = "目标主机名称") String topicName,
@RequestParam(value = "commandList", required = false)
@ApiParam(name = "commandList", value = "命令行") @Nullable List<String> commandList,
@RequestParam(value = "completeCommandList", required = false)
@ApiParam(name = "completeCommandList", value = "完整命令行,优先,可为空") @Nullable List<List<String>> completeCommandList,
@RequestParam(value = "type", required = false) @ApiParam(name = "type", value = "执行命令类型") @Nullable String type
@RequestParam(value = "pipeLineCommand", required = false)
@ApiParam(name = "pipeLineCommand", value = "完整命令行,优先,可为空") @Nullable List<List<String>> pipeLineCommand,
@RequestParam(value = "executionType", required = false) @ApiParam(name = "executionType", value = "执行命令类型") @Nullable String executionType
) {
ArrayList<String> resultLog = executionService
.SendCommandToAgent(
topicName,
type,
executionType,
null,
pipeLineCommand,
commandList,
completeCommandList,
true,
@@ -124,6 +126,27 @@ public class ExecutionController {
}
@PostMapping("/command/sync/one/body")
@ApiOperation("[命令] [同步] - 单机-等待命令结果")
public R<List<String>> SyncCommandToAgentBody(
@RequestBody @Validated ExecutionEntity executionEntity
) {
ArrayList<String> resultLog = executionService
.SendCommandToAgent(
executionEntity.getAgentTopicName(),
executionEntity.getExecutionType(),
executionEntity.getFuncContent(),
executionEntity.getPipeLineCommand(),
executionEntity.getSingleLineCommand(),
executionEntity.getMultiLineCommand(),
executionEntity.isNeedResultReplay(),
executionEntity.isDurationTask()
);
return R.ok(resultLog);
}
@PostMapping("/command/sync/batch")
@ApiOperation("[命令] [同步] - 批量-等待命令结果")
public R<List<ArrayList<String>>> SyncPatchCommandToAgentBatch(