[ server ] [ scheduler ]- script scheduler add function

This commit is contained in:
zeaslity
2023-02-06 15:35:18 +08:00
parent 2fb0252b15
commit f347cedce3
3 changed files with 38 additions and 2 deletions

View File

@@ -10,6 +10,7 @@ import lombok.experimental.SuperBuilder;
import javax.annotation.Nullable;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.time.LocalDateTime;
@Data
@@ -53,9 +54,16 @@ public class ScriptSchedulerVO {
* 脚本任务的内容
*/
@TableField(value = "script_content")
@NotNull
@Nullable
private String scriptContent;
/**
* 脚本任务的类型
*/
@TableField(value = "script_type")
@Nullable
private String scriptType;
/**
* 执行目标机器agent_topic_name列表使用, 分隔
*/

View File

@@ -5,6 +5,7 @@ import io.wdd.rpc.execute.service.CoreExecutionService;
import io.wdd.rpc.scheduler.beans.ScriptSchedulerDTO;
import io.wdd.rpc.scheduler.config.QuartzSchedulerUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@@ -31,9 +32,15 @@ public class AgentApplyScheduledScript {
HashMap<String, String> futureResultKeyMap = scriptSchedulerDTO.getAgentTopicNameToFutureResultKeyMap();
// 新增-定时调用Nacos中预编辑脚本的内容
String scriptType = scriptSchedulerDTO.getScriptType();
if (StringUtils.isEmpty(scriptType)) {
scriptType = "Scheduled Script";
}
List<String> resultKeyList = coreExecutionService.SendCommandToAgentComplete(
targetMachineList,
"Scheduled Script",
scriptType,
completeCommandList,
futureResultKeyMap
);