[server][ executor]- 完成同步调用命令的部分代码
This commit is contained in:
@@ -5,7 +5,7 @@ import io.swagger.annotations.ApiOperation;
|
||||
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 io.wdd.rpc.execute.service.AsyncExecutionService;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@@ -17,26 +17,27 @@ import java.util.List;
|
||||
|
||||
import static io.wdd.rpc.execute.result.RedisStreamReaderConfig.AGENT_STATUS_REDIS_STREAM_LISTENER_CONTAINER;
|
||||
import static io.wdd.rpc.init.ServerCacheAgentStatus.ALL_AGENT_TOPIC_NAME_LIST;
|
||||
import static io.wdd.rpc.init.ServerCacheAgentStatus.ALL_HEALTHY_AGENT_TOPIC_NAME_LIST;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/octopus/server/executor")
|
||||
@Api("Agent执行命令的Controller")
|
||||
@Api(value = "Agent执行命令的Controller", tags = "Execution")
|
||||
public class ExecutionController {
|
||||
|
||||
@Resource
|
||||
CoreExecutionService coreExecutionService;
|
||||
AsyncExecutionService asyncExecutionService;
|
||||
@Resource
|
||||
BuildStreamReader buildStreamReader;
|
||||
|
||||
@PostMapping("/command/one")
|
||||
@ApiOperation("[命令]-手动发送命令")
|
||||
@ApiOperation("[命令] - 手动发送命令")
|
||||
public R<String> patchCommandToAgent(
|
||||
@RequestParam(value = "topicName") String topicName,
|
||||
@RequestParam(value = "topicName") @ApiParam(name = "topicName", value = "目标主机名称") String topicName,
|
||||
@RequestParam(value = "commandList", required = false) @Nullable List<String> commandList,
|
||||
@RequestParam(value = "type", required = false) @Nullable String type
|
||||
) {
|
||||
|
||||
String streamKey = coreExecutionService
|
||||
String streamKey = asyncExecutionService
|
||||
.SendCommandToAgent(
|
||||
topicName,
|
||||
type,
|
||||
@@ -47,7 +48,7 @@ public class ExecutionController {
|
||||
}
|
||||
|
||||
@PostMapping("/command/batch")
|
||||
@ApiOperation("[命令]- 批量发送命令")
|
||||
@ApiOperation("[命令] - 批量发送命令")
|
||||
public R<List<String>> patchCommandToAgentList(
|
||||
@RequestParam(value = "topicNameList")
|
||||
@ApiParam(name = "topicNameList", value = "目标机器列表") List<String> topicNameList,
|
||||
@@ -56,7 +57,7 @@ public class ExecutionController {
|
||||
@RequestParam(value = "type", required = false) @Nullable String type
|
||||
) {
|
||||
|
||||
return R.ok(coreExecutionService.SendCommandToAgent(
|
||||
return R.ok(asyncExecutionService.SendCommandToAgent(
|
||||
topicNameList,
|
||||
type,
|
||||
commandList
|
||||
@@ -65,20 +66,51 @@ public class ExecutionController {
|
||||
|
||||
|
||||
@PostMapping("/command/all")
|
||||
@ApiOperation("[命令]- 发送命令至所有的主机")
|
||||
public R<List<String>> patchCommandToAgentAll(
|
||||
@ApiOperation("[命令] - 发送命令至所有的主机")
|
||||
public R<List<String>> patchCommandToAllAgent(
|
||||
@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(
|
||||
return R.ok(asyncExecutionService.SendCommandToAgent(
|
||||
ALL_AGENT_TOPIC_NAME_LIST,
|
||||
type,
|
||||
commandList
|
||||
));
|
||||
}
|
||||
|
||||
@PostMapping("/command/healthy")
|
||||
@ApiOperation("[命令] - 发送命令至健康的主机")
|
||||
public R<List<String>> patchCommandToHealthyAgent(
|
||||
@RequestParam(value = "commandList", required = false)
|
||||
@ApiParam(name = "commandList", value = "命令行") @Nullable List<String> commandList,
|
||||
@RequestParam(value = "type", required = false) @Nullable String type
|
||||
) {
|
||||
|
||||
return R.ok(asyncExecutionService.SendCommandToAgent(
|
||||
ALL_HEALTHY_AGENT_TOPIC_NAME_LIST,
|
||||
type,
|
||||
commandList
|
||||
));
|
||||
}
|
||||
|
||||
@PostMapping("/command/sync/one")
|
||||
@ApiOperation("[命令] [同步] - 同步等待命令结果")
|
||||
public R<List<String>> SyncPatchCommandToAgent(
|
||||
@RequestParam(value = "topicName") @ApiParam(name = "topicName", value = "目标主机名称") String topicName,
|
||||
@RequestParam(value = "commandList", required = false)
|
||||
@ApiParam(name = "commandList", value = "命令行") @Nullable List<String> commandList,
|
||||
@RequestParam(value = "type", required = false) @ApiParam(name = "type", value = "执行命令类型") @Nullable String type
|
||||
) {
|
||||
|
||||
return R.ok(asyncExecutionService.SendCommandToAgent(
|
||||
ALL_HEALTHY_AGENT_TOPIC_NAME_LIST,
|
||||
type,
|
||||
commandList
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/agentStatusStream")
|
||||
@ApiOperation("切换Console查看Agent状态日志")
|
||||
@@ -105,7 +137,7 @@ public class ExecutionController {
|
||||
) {
|
||||
|
||||
return R.ok(
|
||||
coreExecutionService
|
||||
asyncExecutionService
|
||||
.SendCommandToAgent(
|
||||
topicNameList,
|
||||
"AgentUpdate",
|
||||
@@ -121,7 +153,7 @@ public class ExecutionController {
|
||||
) {
|
||||
|
||||
return R.ok(
|
||||
coreExecutionService
|
||||
asyncExecutionService
|
||||
.SendCommandToAgent(
|
||||
topicNameList,
|
||||
"AgentReboot",
|
||||
@@ -137,7 +169,7 @@ public class ExecutionController {
|
||||
) {
|
||||
|
||||
return R.ok(
|
||||
coreExecutionService
|
||||
asyncExecutionService
|
||||
.SendCommandToAgent(
|
||||
topicNameList,
|
||||
"AgentShutdown",
|
||||
@@ -145,5 +177,21 @@ public class ExecutionController {
|
||||
));
|
||||
}
|
||||
|
||||
@PostMapping("/function/bootUp")
|
||||
@ApiOperation("重新部署")
|
||||
public R<List<String>> AgentBootUp(
|
||||
@RequestParam(value = "topicNameList")
|
||||
@ApiParam(name = "topicNameList", value = "目标机器列表") List<String> topicNameList
|
||||
) {
|
||||
|
||||
return R.ok(
|
||||
asyncExecutionService
|
||||
.SendCommandToAgent(
|
||||
topicNameList,
|
||||
"AgentBootUp",
|
||||
null
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user