[server] - 优化大量代码
This commit is contained in:
@@ -6,7 +6,6 @@ import io.swagger.annotations.ApiParam;
|
||||
import io.wdd.common.beans.response.R;
|
||||
import io.wdd.rpc.execute.result.BuildStreamReader;
|
||||
import io.wdd.rpc.execute.service.CoreExecutionService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@@ -17,6 +16,7 @@ import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static io.wdd.rpc.execute.result.RedisStreamReaderConfig.AGENT_STATUS_REDIS_STREAM_LISTENER_CONTAINER;
|
||||
import static io.wdd.rpc.init.ServerBootUpEnvironment.ALL_AGENT_TOPIC_NAME_LIST;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/octopus/server/executor")
|
||||
@@ -25,12 +25,10 @@ public class ExecutionController {
|
||||
|
||||
@Resource
|
||||
CoreExecutionService coreExecutionService;
|
||||
|
||||
@Resource
|
||||
BuildStreamReader buildStreamReader;
|
||||
|
||||
|
||||
@PostMapping("command")
|
||||
@PostMapping("/command/one")
|
||||
@ApiOperation("[命令]-手动发送命令")
|
||||
public R<String> patchCommandToAgent(
|
||||
@RequestParam(value = "topicName") String topicName,
|
||||
@@ -38,24 +36,49 @@ public class ExecutionController {
|
||||
@RequestParam(value = "type", required = false) @Nullable String type
|
||||
) {
|
||||
|
||||
String streamKey = "";
|
||||
|
||||
if (StringUtils.isEmpty(type)) {
|
||||
streamKey = coreExecutionService.SendCommandToAgent(
|
||||
topicName,
|
||||
commandList
|
||||
);
|
||||
} else {
|
||||
streamKey = coreExecutionService.SendCommandToAgent(
|
||||
topicName,
|
||||
type,
|
||||
commandList
|
||||
);
|
||||
}
|
||||
String streamKey = coreExecutionService
|
||||
.SendCommandToAgent(
|
||||
topicName,
|
||||
type,
|
||||
commandList
|
||||
);
|
||||
|
||||
return R.ok(streamKey);
|
||||
}
|
||||
|
||||
@PostMapping("/command/batch")
|
||||
@ApiOperation("[命令]- 批量发送命令")
|
||||
public R<List<String>> patchCommandToAgentList(
|
||||
@RequestParam(value = "topicNameList")
|
||||
@ApiParam(name = "topicNameList", value = "目标机器列表") List<String> topicNameList,
|
||||
@RequestParam(value = "commandList", required = false)
|
||||
@ApiParam(name = "commandList", value = "命令行") @Nullable List<String> commandList,
|
||||
@RequestParam(value = "type", required = false) @Nullable String type
|
||||
) {
|
||||
|
||||
return R.ok(coreExecutionService.SendCommandToAgent(
|
||||
topicNameList,
|
||||
type,
|
||||
commandList
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/command/all")
|
||||
@ApiOperation("[命令]- 发送命令至所有的主机")
|
||||
public R<List<String>> patchCommandToAgentAll(
|
||||
@RequestParam(value = "commandList", required = false)
|
||||
@ApiParam(name = "commandList", value = "命令行") @Nullable List<String> commandList,
|
||||
@RequestParam(value = "type", required = false) @Nullable String type
|
||||
) {
|
||||
|
||||
return R.ok(coreExecutionService.SendCommandToAgent(
|
||||
ALL_AGENT_TOPIC_NAME_LIST,
|
||||
type,
|
||||
commandList
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/agentStatusStream")
|
||||
@ApiOperation("切换Console查看Agent状态日志")
|
||||
@@ -74,46 +97,49 @@ public class ExecutionController {
|
||||
|
||||
|
||||
// auth required
|
||||
@PostMapping("/AgentUpdate")
|
||||
@ApiOperation("控制Agent升级的接口")
|
||||
public R<String> AgentUpdate(
|
||||
@RequestParam(value = "agentTopicName") String agentTopicName
|
||||
@PostMapping("/function/update")
|
||||
@ApiOperation("升级")
|
||||
public R<List<String>> AgentUpdate(
|
||||
@RequestParam(value = "topicNameList")
|
||||
@ApiParam(name = "topicNameList", value = "目标机器列表") List<String> topicNameList
|
||||
) {
|
||||
|
||||
return R.ok(
|
||||
coreExecutionService
|
||||
.SendCommandToAgent(
|
||||
agentTopicName,
|
||||
topicNameList,
|
||||
"AgentUpdate",
|
||||
null
|
||||
));
|
||||
}
|
||||
|
||||
@PostMapping("/AgentReboot")
|
||||
@ApiOperation("控制Agent重启的接口")
|
||||
public R<String> AgentReboot(
|
||||
@RequestParam(value = "agentTopicName") String agentTopicName
|
||||
@PostMapping("/function/reboot")
|
||||
@ApiOperation("重启")
|
||||
public R<List<String>> AgentReboot(
|
||||
@RequestParam(value = "topicNameList")
|
||||
@ApiParam(name = "topicNameList", value = "目标机器列表") List<String> topicNameList
|
||||
) {
|
||||
|
||||
return R.ok(
|
||||
coreExecutionService
|
||||
.SendCommandToAgent(
|
||||
agentTopicName,
|
||||
"AgentRestart",
|
||||
topicNameList,
|
||||
"AgentReboot",
|
||||
null
|
||||
));
|
||||
}
|
||||
|
||||
@PostMapping("/AgentShutdown")
|
||||
@ApiOperation("控制Agent关闭的接口")
|
||||
public R<String> AgentShutdown(
|
||||
@RequestParam(value = "agentTopicName") String agentTopicName
|
||||
@PostMapping("/function/shutdown")
|
||||
@ApiOperation("关闭")
|
||||
public R<List<String>> AgentShutdown(
|
||||
@RequestParam(value = "topicNameList")
|
||||
@ApiParam(name = "topicNameList", value = "目标机器列表") List<String> topicNameList
|
||||
) {
|
||||
|
||||
return R.ok(
|
||||
coreExecutionService
|
||||
.SendCommandToAgent(
|
||||
agentTopicName,
|
||||
topicNameList,
|
||||
"AgentShutdown",
|
||||
null
|
||||
));
|
||||
|
||||
Reference in New Issue
Block a user