🔨 是否使用脚本执行.
This commit is contained in:
@@ -6,6 +6,7 @@ Authorization: {{token}}
|
|||||||
{
|
{
|
||||||
"description": 1,
|
"description": 1,
|
||||||
"timeout": 10,
|
"timeout": 10,
|
||||||
|
"scriptExec": 0,
|
||||||
"command": "echo 这是日志@{{ hostAddress }}\nsleep 1\necho @{{ hostName }}",
|
"command": "echo 这是日志@{{ hostAddress }}\nsleep 1\necho @{{ hostName }}",
|
||||||
"parameterSchema": "[]",
|
"parameterSchema": "[]",
|
||||||
"hostIdList": [1]
|
"hostIdList": [1]
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ Authorization: {{token}}
|
|||||||
{
|
{
|
||||||
"name": "测试 1",
|
"name": "测试 1",
|
||||||
"expression": "0 */3 * * * ?",
|
"expression": "0 */3 * * * ?",
|
||||||
"timeout": "0",
|
"timeout": 0,
|
||||||
|
"scriptExec": 0,
|
||||||
"command": "echo 123",
|
"command": "echo 123",
|
||||||
"parameterSchema": "[]",
|
"parameterSchema": "[]",
|
||||||
"hostIdList": [1]
|
"hostIdList": [1]
|
||||||
@@ -22,7 +23,8 @@ Authorization: {{token}}
|
|||||||
"id": 5,
|
"id": 5,
|
||||||
"name": "测试 1",
|
"name": "测试 1",
|
||||||
"expression": "0 */10 * * * ?",
|
"expression": "0 */10 * * * ?",
|
||||||
"timeout": "0",
|
"timeout": 0,
|
||||||
|
"scriptExec": 0,
|
||||||
"command": "echo 123",
|
"command": "echo 123",
|
||||||
"parameterSchema": "[]",
|
"parameterSchema": "[]",
|
||||||
"hostIdList": [
|
"hostIdList": [
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ Authorization: {{token}}
|
|||||||
{
|
{
|
||||||
"name": "",
|
"name": "",
|
||||||
"command": "",
|
"command": "",
|
||||||
"timeout": "",
|
"timeout": 0,
|
||||||
|
"scriptExec": 0,
|
||||||
"parameterSchema": ""
|
"parameterSchema": ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,7 +21,8 @@ Authorization: {{token}}
|
|||||||
"id": "",
|
"id": "",
|
||||||
"name": "",
|
"name": "",
|
||||||
"command": "",
|
"command": "",
|
||||||
"timeout": "",
|
"timeout": 0,
|
||||||
|
"scriptExec": 0,
|
||||||
"parameterSchema": ""
|
"parameterSchema": ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +49,8 @@ Authorization: {{token}}
|
|||||||
"id": "",
|
"id": "",
|
||||||
"name": "",
|
"name": "",
|
||||||
"command": "",
|
"command": "",
|
||||||
"timeout": "",
|
"timeout": 0,
|
||||||
|
"scriptExec": 0,
|
||||||
"parameterSchema": ""
|
"parameterSchema": ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,6 +68,10 @@ public class ExecHostLogDO extends BaseDO {
|
|||||||
@TableField("log_path")
|
@TableField("log_path")
|
||||||
private String logPath;
|
private String logPath;
|
||||||
|
|
||||||
|
@Schema(description = "脚本路径")
|
||||||
|
@TableField("script_path")
|
||||||
|
private String scriptPath;
|
||||||
|
|
||||||
@Schema(description = "错误信息")
|
@Schema(description = "错误信息")
|
||||||
@TableField("error_message")
|
@TableField("error_message")
|
||||||
private String errorMessage;
|
private String errorMessage;
|
||||||
|
|||||||
@@ -46,6 +46,10 @@ public class ExecJobDO extends BaseDO {
|
|||||||
@TableField("timeout")
|
@TableField("timeout")
|
||||||
private Integer timeout;
|
private Integer timeout;
|
||||||
|
|
||||||
|
@Schema(description = "是否使用脚本执行")
|
||||||
|
@TableField("script_exec")
|
||||||
|
private Integer scriptExec;
|
||||||
|
|
||||||
@Schema(description = "执行命令")
|
@Schema(description = "执行命令")
|
||||||
@TableField("command")
|
@TableField("command")
|
||||||
private String command;
|
private String command;
|
||||||
|
|||||||
@@ -68,6 +68,10 @@ public class ExecLogDO extends BaseDO {
|
|||||||
@TableField("timeout")
|
@TableField("timeout")
|
||||||
private Integer timeout;
|
private Integer timeout;
|
||||||
|
|
||||||
|
@Schema(description = "是否使用脚本执行")
|
||||||
|
@TableField("script_exec")
|
||||||
|
private Integer scriptExec;
|
||||||
|
|
||||||
@Schema(description = "执行状态")
|
@Schema(description = "执行状态")
|
||||||
@TableField("status")
|
@TableField("status")
|
||||||
private String status;
|
private String status;
|
||||||
|
|||||||
@@ -42,6 +42,10 @@ public class ExecTemplateDO extends BaseDO {
|
|||||||
@TableField("timeout")
|
@TableField("timeout")
|
||||||
private Integer timeout;
|
private Integer timeout;
|
||||||
|
|
||||||
|
@Schema(description = "是否使用脚本执行")
|
||||||
|
@TableField("script_exec")
|
||||||
|
private Integer scriptExec;
|
||||||
|
|
||||||
@Schema(description = "参数定义")
|
@Schema(description = "参数定义")
|
||||||
@TableField("parameter_schema")
|
@TableField("parameter_schema")
|
||||||
private String parameterSchema;
|
private String parameterSchema;
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ public class ExecCommandExecRequest {
|
|||||||
@Schema(description = "超时时间")
|
@Schema(description = "超时时间")
|
||||||
private Integer timeout;
|
private Integer timeout;
|
||||||
|
|
||||||
|
@Schema(description = "是否使用脚本执行")
|
||||||
|
private Integer scriptExec;
|
||||||
|
|
||||||
@Schema(description = "执行命令")
|
@Schema(description = "执行命令")
|
||||||
private String command;
|
private String command;
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ public class ExecCommandRequest {
|
|||||||
@Schema(description = "超时时间")
|
@Schema(description = "超时时间")
|
||||||
private Integer timeout;
|
private Integer timeout;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Schema(description = "是否使用脚本执行")
|
||||||
|
private Integer scriptExec;
|
||||||
|
|
||||||
@NotBlank
|
@NotBlank
|
||||||
@Schema(description = "执行命令")
|
@Schema(description = "执行命令")
|
||||||
private String command;
|
private String command;
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
package com.orion.ops.module.asset.entity.request.exec;
|
package com.orion.ops.module.asset.entity.request.exec;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.*;
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
@@ -43,6 +40,10 @@ public class ExecJobCreateRequest implements Serializable {
|
|||||||
@Schema(description = "超时时间")
|
@Schema(description = "超时时间")
|
||||||
private Integer timeout;
|
private Integer timeout;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Schema(description = "是否使用脚本执行")
|
||||||
|
private Integer scriptExec;
|
||||||
|
|
||||||
@NotBlank
|
@NotBlank
|
||||||
@Schema(description = "执行命令")
|
@Schema(description = "执行命令")
|
||||||
private String command;
|
private String command;
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
package com.orion.ops.module.asset.entity.request.exec;
|
package com.orion.ops.module.asset.entity.request.exec;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.*;
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
@@ -47,6 +44,10 @@ public class ExecJobUpdateRequest implements Serializable {
|
|||||||
@Schema(description = "超时时间")
|
@Schema(description = "超时时间")
|
||||||
private Integer timeout;
|
private Integer timeout;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Schema(description = "是否使用脚本执行")
|
||||||
|
private Integer scriptExec;
|
||||||
|
|
||||||
@NotBlank
|
@NotBlank
|
||||||
@Schema(description = "执行命令")
|
@Schema(description = "执行命令")
|
||||||
private String command;
|
private String command;
|
||||||
|
|||||||
@@ -40,6 +40,10 @@ public class ExecTemplateCreateRequest implements Serializable {
|
|||||||
@Schema(description = "超时时间秒 0不超时")
|
@Schema(description = "超时时间秒 0不超时")
|
||||||
private Integer timeout;
|
private Integer timeout;
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Schema(description = "是否使用脚本执行")
|
||||||
|
private Integer scriptExec;
|
||||||
|
|
||||||
@Schema(description = "参数定义")
|
@Schema(description = "参数定义")
|
||||||
private String parameterSchema;
|
private String parameterSchema;
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,10 @@ public class ExecTemplateUpdateRequest implements Serializable {
|
|||||||
@Schema(description = "超时时间秒 0不超时")
|
@Schema(description = "超时时间秒 0不超时")
|
||||||
private Integer timeout;
|
private Integer timeout;
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Schema(description = "是否使用脚本执行")
|
||||||
|
private Integer scriptExec;
|
||||||
|
|
||||||
@Schema(description = "参数定义")
|
@Schema(description = "参数定义")
|
||||||
private String parameterSchema;
|
private String parameterSchema;
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ public class ExecJobVO implements Serializable {
|
|||||||
@Schema(description = "超时时间")
|
@Schema(description = "超时时间")
|
||||||
private Integer timeout;
|
private Integer timeout;
|
||||||
|
|
||||||
|
@Schema(description = "是否使用脚本执行")
|
||||||
|
private Integer scriptExec;
|
||||||
|
|
||||||
@Schema(description = "执行命令")
|
@Schema(description = "执行命令")
|
||||||
private String command;
|
private String command;
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,9 @@ public class ExecLogVO implements Serializable {
|
|||||||
@Schema(description = "超时时间")
|
@Schema(description = "超时时间")
|
||||||
private Integer timeout;
|
private Integer timeout;
|
||||||
|
|
||||||
|
@Schema(description = "是否使用脚本执行")
|
||||||
|
private Integer scriptExec;
|
||||||
|
|
||||||
@Schema(description = "执行状态")
|
@Schema(description = "执行状态")
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,9 @@ public class ExecTemplateVO implements Serializable {
|
|||||||
@Schema(description = "超时时间秒 0不超时")
|
@Schema(description = "超时时间秒 0不超时")
|
||||||
private Integer timeout;
|
private Integer timeout;
|
||||||
|
|
||||||
|
@Schema(description = "是否使用脚本执行")
|
||||||
|
private Integer scriptExec;
|
||||||
|
|
||||||
@Schema(description = "参数定义")
|
@Schema(description = "参数定义")
|
||||||
private String parameterSchema;
|
private String parameterSchema;
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ public class ExecCommandDTO {
|
|||||||
@Schema(description = "超时时间")
|
@Schema(description = "超时时间")
|
||||||
private Integer timeout;
|
private Integer timeout;
|
||||||
|
|
||||||
|
@Schema(description = "是否使用脚本执行")
|
||||||
|
private Integer scriptExec;
|
||||||
|
|
||||||
@Schema(description = "主机")
|
@Schema(description = "主机")
|
||||||
private List<ExecCommandHostDTO> hosts;
|
private List<ExecCommandHostDTO> hosts;
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ public class ExecCommandHostDTO {
|
|||||||
@Schema(description = "日志文件路径")
|
@Schema(description = "日志文件路径")
|
||||||
private String logPath;
|
private String logPath;
|
||||||
|
|
||||||
|
@Schema(description = "脚本路径")
|
||||||
|
private String scriptPath;
|
||||||
|
|
||||||
@Schema(description = "执行命令")
|
@Schema(description = "执行命令")
|
||||||
private String command;
|
private String command;
|
||||||
|
|
||||||
|
|||||||
@@ -82,13 +82,14 @@ public class ExecCommandServiceImpl implements ExecCommandService {
|
|||||||
@Resource
|
@Resource
|
||||||
private AssetAuthorizedDataService assetAuthorizedDataService;
|
private AssetAuthorizedDataService assetAuthorizedDataService;
|
||||||
|
|
||||||
|
// TODO 新增 修改 时候先检查 scriptExec, 然后测试一下
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public ExecLogVO execCommand(ExecCommandRequest request) {
|
public ExecLogVO execCommand(ExecCommandRequest request) {
|
||||||
log.info("ExecService.startExecCommand start params: {}", JSON.toJSONString(request));
|
log.info("ExecService.startExecCommand start params: {}", JSON.toJSONString(request));
|
||||||
LoginUser user = Objects.requireNonNull(SecurityUtils.getLoginUser());
|
LoginUser user = Objects.requireNonNull(SecurityUtils.getLoginUser());
|
||||||
Long userId = user.getId();
|
Long userId = user.getId();
|
||||||
String command = request.getCommand();
|
|
||||||
List<Long> hostIdList = request.getHostIdList();
|
List<Long> hostIdList = request.getHostIdList();
|
||||||
// 检查主机权限
|
// 检查主机权限
|
||||||
List<Long> authorizedHostIdList = assetAuthorizedDataService.getUserAuthorizedHostId(userId, HostConfigTypeEnum.SSH);
|
List<Long> authorizedHostIdList = assetAuthorizedDataService.getUserAuthorizedHostId(userId, HostConfigTypeEnum.SSH);
|
||||||
@@ -126,6 +127,7 @@ public class ExecCommandServiceImpl implements ExecCommandService {
|
|||||||
.command(command)
|
.command(command)
|
||||||
.parameterSchema(request.getParameterSchema())
|
.parameterSchema(request.getParameterSchema())
|
||||||
.timeout(request.getTimeout())
|
.timeout(request.getTimeout())
|
||||||
|
.scriptExec(request.getScriptExec())
|
||||||
.status(ExecStatusEnum.WAITING.name())
|
.status(ExecStatusEnum.WAITING.name())
|
||||||
.build();
|
.build();
|
||||||
execLogDAO.insert(execLog);
|
execLogDAO.insert(execLog);
|
||||||
@@ -145,6 +147,8 @@ public class ExecCommandServiceImpl implements ExecCommandService {
|
|||||||
.command(FORMATTER.format(command, parameter))
|
.command(FORMATTER.format(command, parameter))
|
||||||
.parameter(parameter)
|
.parameter(parameter)
|
||||||
.logPath(this.buildLogPath(execId, s.getId()))
|
.logPath(this.buildLogPath(execId, s.getId()))
|
||||||
|
// FIXME 测试 添加用户名
|
||||||
|
// .scriptPath()
|
||||||
.build();
|
.build();
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
execHostLogDAO.insertBatch(execHostLogs);
|
execHostLogDAO.insertBatch(execHostLogs);
|
||||||
@@ -176,6 +180,7 @@ public class ExecCommandServiceImpl implements ExecCommandService {
|
|||||||
ExecCommandRequest request = ExecCommandRequest.builder()
|
ExecCommandRequest request = ExecCommandRequest.builder()
|
||||||
.description(execLog.getDescription())
|
.description(execLog.getDescription())
|
||||||
.timeout(execLog.getTimeout())
|
.timeout(execLog.getTimeout())
|
||||||
|
.scriptExec(execLog.getScriptExec())
|
||||||
.command(execLog.getCommand())
|
.command(execLog.getCommand())
|
||||||
.parameterSchema(execLog.getParameterSchema())
|
.parameterSchema(execLog.getParameterSchema())
|
||||||
.hostIdList(hostIdList)
|
.hostIdList(hostIdList)
|
||||||
@@ -193,6 +198,7 @@ public class ExecCommandServiceImpl implements ExecCommandService {
|
|||||||
ExecCommandDTO exec = ExecCommandDTO.builder()
|
ExecCommandDTO exec = ExecCommandDTO.builder()
|
||||||
.logId(execLog.getId())
|
.logId(execLog.getId())
|
||||||
.timeout(execLog.getTimeout())
|
.timeout(execLog.getTimeout())
|
||||||
|
.scriptExec(execLog.getScriptExec())
|
||||||
.hosts(execHostLogs.stream()
|
.hosts(execHostLogs.stream()
|
||||||
.map(s -> ExecCommandHostDTO.builder()
|
.map(s -> ExecCommandHostDTO.builder()
|
||||||
.hostId(s.getHostId())
|
.hostId(s.getHostId())
|
||||||
@@ -200,6 +206,7 @@ public class ExecCommandServiceImpl implements ExecCommandService {
|
|||||||
.command(s.getCommand())
|
.command(s.getCommand())
|
||||||
.timeout(execLog.getTimeout())
|
.timeout(execLog.getTimeout())
|
||||||
.logPath(s.getLogPath())
|
.logPath(s.getLogPath())
|
||||||
|
.scriptPath(s.getScriptPath())
|
||||||
.build())
|
.build())
|
||||||
.collect(Collectors.toList()))
|
.collect(Collectors.toList()))
|
||||||
.build();
|
.build();
|
||||||
@@ -231,6 +238,7 @@ public class ExecCommandServiceImpl implements ExecCommandService {
|
|||||||
params.put("timestamp", date.getTime() / Dates.SECOND_STAMP);
|
params.put("timestamp", date.getTime() / Dates.SECOND_STAMP);
|
||||||
params.put("date", Dates.format(date, Dates.YMD));
|
params.put("date", Dates.format(date, Dates.YMD));
|
||||||
params.put("datetime", Dates.format(date, Dates.YMD_HMS));
|
params.put("datetime", Dates.format(date, Dates.YMD_HMS));
|
||||||
|
// TODO script Exec
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,6 +258,8 @@ public class ExecCommandServiceImpl implements ExecCommandService {
|
|||||||
params.put("hostAddress", host.getAddress());
|
params.put("hostAddress", host.getAddress());
|
||||||
params.put("hostUuid", uuid);
|
params.put("hostUuid", uuid);
|
||||||
params.put("hostUuidShort", uuid.replace("-", Strings.EMPTY));
|
params.put("hostUuidShort", uuid.replace("-", Strings.EMPTY));
|
||||||
|
// TODO host username
|
||||||
|
// TODO scriptPath
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -286,6 +286,7 @@ public class ExecJobServiceImpl implements ExecJobService {
|
|||||||
.execSeq(execSeq)
|
.execSeq(execSeq)
|
||||||
.description(job.getName())
|
.description(job.getName())
|
||||||
.timeout(job.getTimeout())
|
.timeout(job.getTimeout())
|
||||||
|
.scriptExec(job.getScriptExec())
|
||||||
.command(job.getCommand())
|
.command(job.getCommand())
|
||||||
.parameterSchema(job.getParameterSchema())
|
.parameterSchema(job.getParameterSchema())
|
||||||
.hostIdList(hostIdList)
|
.hostIdList(hostIdList)
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
<result column="parameter" property="parameter"/>
|
<result column="parameter" property="parameter"/>
|
||||||
<result column="exit_status" property="exitStatus"/>
|
<result column="exit_status" property="exitStatus"/>
|
||||||
<result column="log_path" property="logPath"/>
|
<result column="log_path" property="logPath"/>
|
||||||
|
<result column="script_path" property="scriptPath"/>
|
||||||
<result column="error_message" property="errorMessage"/>
|
<result column="error_message" property="errorMessage"/>
|
||||||
<result column="start_time" property="startTime"/>
|
<result column="start_time" property="startTime"/>
|
||||||
<result column="finish_time" property="finishTime"/>
|
<result column="finish_time" property="finishTime"/>
|
||||||
@@ -26,7 +27,7 @@
|
|||||||
|
|
||||||
<!-- 通用查询结果列 -->
|
<!-- 通用查询结果列 -->
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
id, log_id, host_id, host_name, host_address, status, command, parameter, exit_status, log_path, error_message, start_time, finish_time, create_time, update_time, creator, updater, deleted
|
id, log_id, host_id, host_name, host_address, status, command, parameter, exit_status, log_path, script_path, error_message, start_time, finish_time, create_time, update_time, creator, updater, deleted
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
<result column="exec_seq" property="execSeq"/>
|
<result column="exec_seq" property="execSeq"/>
|
||||||
<result column="expression" property="expression"/>
|
<result column="expression" property="expression"/>
|
||||||
<result column="timeout" property="timeout"/>
|
<result column="timeout" property="timeout"/>
|
||||||
|
<result column="script_exec" property="scriptExec"/>
|
||||||
<result column="command" property="command"/>
|
<result column="command" property="command"/>
|
||||||
<result column="parameter_schema" property="parameterSchema"/>
|
<result column="parameter_schema" property="parameterSchema"/>
|
||||||
<result column="status" property="status"/>
|
<result column="status" property="status"/>
|
||||||
@@ -22,7 +23,7 @@
|
|||||||
|
|
||||||
<!-- 通用查询结果列 -->
|
<!-- 通用查询结果列 -->
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
id, name, exec_seq, expression, timeout, command, parameter_schema, status, recent_log_id, create_time, update_time, creator, updater, deleted
|
id, name, exec_seq, expression, timeout, script_exec, command, parameter_schema, status, recent_log_id, create_time, update_time, creator, updater, deleted
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<update id="incrExecSeq">
|
<update id="incrExecSeq">
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
<result column="command" property="command"/>
|
<result column="command" property="command"/>
|
||||||
<result column="parameter_schema" property="parameterSchema"/>
|
<result column="parameter_schema" property="parameterSchema"/>
|
||||||
<result column="timeout" property="timeout"/>
|
<result column="timeout" property="timeout"/>
|
||||||
|
<result column="script_exec" property="scriptExec"/>
|
||||||
<result column="status" property="status"/>
|
<result column="status" property="status"/>
|
||||||
<result column="start_time" property="startTime"/>
|
<result column="start_time" property="startTime"/>
|
||||||
<result column="finish_time" property="finishTime"/>
|
<result column="finish_time" property="finishTime"/>
|
||||||
@@ -26,7 +27,7 @@
|
|||||||
|
|
||||||
<!-- 通用查询结果列 -->
|
<!-- 通用查询结果列 -->
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
id, user_id, username, source, source_id, description, exec_seq, command, parameter_schema, timeout, status, start_time, finish_time, create_time, update_time, creator, updater, deleted
|
id, user_id, username, source, source_id, description, exec_seq, command, parameter_schema, timeout, script_exec, status, start_time, finish_time, create_time, update_time, creator, updater, deleted
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="getExecHistory" resultMap="BaseResultMap">
|
<select id="getExecHistory" resultMap="BaseResultMap">
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
<result column="name" property="name"/>
|
<result column="name" property="name"/>
|
||||||
<result column="command" property="command"/>
|
<result column="command" property="command"/>
|
||||||
<result column="timeout" property="timeout"/>
|
<result column="timeout" property="timeout"/>
|
||||||
|
<result column="script_exec" property="scriptExec"/>
|
||||||
<result column="parameter_schema" property="parameterSchema"/>
|
<result column="parameter_schema" property="parameterSchema"/>
|
||||||
<result column="create_time" property="createTime"/>
|
<result column="create_time" property="createTime"/>
|
||||||
<result column="update_time" property="updateTime"/>
|
<result column="update_time" property="updateTime"/>
|
||||||
@@ -18,7 +19,7 @@
|
|||||||
|
|
||||||
<!-- 通用查询结果列 -->
|
<!-- 通用查询结果列 -->
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
id, name, command, timeout, parameter_schema, create_time, update_time, creator, updater, deleted
|
id, name, command, timeout, script_exec,parameter_schema, create_time, update_time, creator, updater, deleted
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ export interface ExecCommandRequest {
|
|||||||
logId?: number;
|
logId?: number;
|
||||||
description?: string;
|
description?: string;
|
||||||
timeout?: number;
|
timeout?: number;
|
||||||
|
scriptExec?: number;
|
||||||
command?: string;
|
command?: string;
|
||||||
parameterSchema?: string;
|
parameterSchema?: string;
|
||||||
hostIdList?: Array<number>;
|
hostIdList?: Array<number>;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ export interface ExecJobCreateRequest {
|
|||||||
name?: string;
|
name?: string;
|
||||||
expression?: string;
|
expression?: string;
|
||||||
timeout?: number;
|
timeout?: number;
|
||||||
|
scriptExec?: number;
|
||||||
command?: string;
|
command?: string;
|
||||||
parameterSchema?: string;
|
parameterSchema?: string;
|
||||||
hostIdList?: Array<number>;
|
hostIdList?: Array<number>;
|
||||||
@@ -49,6 +50,7 @@ export interface ExecJobQueryResponse extends TableData {
|
|||||||
name: string;
|
name: string;
|
||||||
expression: string;
|
expression: string;
|
||||||
timeout: number;
|
timeout: number;
|
||||||
|
scriptExec?: number;
|
||||||
command: string;
|
command: string;
|
||||||
parameterSchema: string;
|
parameterSchema: string;
|
||||||
status: number;
|
status: number;
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ export interface ExecLogQueryResponse extends TableData, ExecLogQueryExtraRespon
|
|||||||
command: string;
|
command: string;
|
||||||
parameterSchema: string;
|
parameterSchema: string;
|
||||||
timeout: number;
|
timeout: number;
|
||||||
|
scriptExec?: number;
|
||||||
status: string;
|
status: string;
|
||||||
startTime: number;
|
startTime: number;
|
||||||
finishTime: number;
|
finishTime: number;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ export interface ExecTemplateCreateRequest {
|
|||||||
name?: string;
|
name?: string;
|
||||||
command?: string;
|
command?: string;
|
||||||
timeout?: number;
|
timeout?: number;
|
||||||
|
scriptExec?: number;
|
||||||
parameterSchema?: string;
|
parameterSchema?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,6 +37,7 @@ export interface ExecTemplateQueryResponse extends TableData {
|
|||||||
name: string;
|
name: string;
|
||||||
command: string;
|
command: string;
|
||||||
timeout: number;
|
timeout: number;
|
||||||
|
scriptExec?: number;
|
||||||
parameterSchema: string;
|
parameterSchema: string;
|
||||||
createTime: number;
|
createTime: number;
|
||||||
updateTime: number;
|
updateTime: number;
|
||||||
|
|||||||
@@ -258,6 +258,13 @@ body {
|
|||||||
margin-left: 4px;
|
margin-left: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.question-right {
|
||||||
|
font-size: 18px;
|
||||||
|
margin-left: 8px;
|
||||||
|
color: rgb(var(--gray-6));
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
.span-blue {
|
.span-blue {
|
||||||
color: rgb(var(--arcoblue-6));
|
color: rgb(var(--arcoblue-6));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,11 +12,10 @@
|
|||||||
ref="formRef"
|
ref="formRef"
|
||||||
class="form-wrapper"
|
class="form-wrapper"
|
||||||
label-align="right"
|
label-align="right"
|
||||||
|
:auto-label-width="true"
|
||||||
:rules="formRules">
|
:rules="formRules">
|
||||||
<!-- 执行主机 -->
|
<!-- 执行主机 -->
|
||||||
<a-form-item field="hostIdList"
|
<a-form-item field="hostIdList" label="执行主机">
|
||||||
label="执行主机"
|
|
||||||
label-col-flex="72px">
|
|
||||||
<div class="selected-host">
|
<div class="selected-host">
|
||||||
<!-- 已选择数量 -->
|
<!-- 已选择数量 -->
|
||||||
<span class="usn" v-if="formModel.hostIdList?.length">
|
<span class="usn" v-if="formModel.hostIdList?.length">
|
||||||
@@ -28,17 +27,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<!-- 执行描述 -->
|
<!-- 执行描述 -->
|
||||||
<a-form-item field="description"
|
<a-form-item field="description" label="执行描述">
|
||||||
label="执行描述"
|
|
||||||
label-col-flex="72px">
|
|
||||||
<a-input v-model="formModel.description"
|
<a-input v-model="formModel.description"
|
||||||
placeholder="请输入执行描述"
|
placeholder="请输入执行描述"
|
||||||
allow-clear />
|
allow-clear />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<!-- 超时时间 -->
|
<!-- 超时时间 -->
|
||||||
<a-form-item field="timeout"
|
<a-form-item field="timeout" label="超时时间">
|
||||||
label="超时时间"
|
|
||||||
label-col-flex="72px">
|
|
||||||
<a-input-number v-model="formModel.timeout"
|
<a-input-number v-model="formModel.timeout"
|
||||||
placeholder="为0则不超时"
|
placeholder="为0则不超时"
|
||||||
:min="0"
|
:min="0"
|
||||||
@@ -49,6 +44,20 @@
|
|||||||
</template>
|
</template>
|
||||||
</a-input-number>
|
</a-input-number>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
|
<!-- 脚本执行 -->
|
||||||
|
<a-form-item field="scriptExec" label="脚本执行">
|
||||||
|
<div class="flex-center">
|
||||||
|
<a-switch v-model="formModel.scriptExec"
|
||||||
|
type="round"
|
||||||
|
:checked-value="EnabledStatus.ENABLED"
|
||||||
|
:unchecked-value="EnabledStatus.DISABLED" />
|
||||||
|
<div class="question-right ml8">
|
||||||
|
<a-tooltip content="启用后会将命令写入脚本文件 传输到主机后执行">
|
||||||
|
<icon-question-circle />
|
||||||
|
</a-tooltip>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</a-form-item>
|
||||||
</a-form>
|
</a-form>
|
||||||
</template>
|
</template>
|
||||||
<!-- 参数表单 -->
|
<!-- 参数表单 -->
|
||||||
@@ -60,7 +69,6 @@
|
|||||||
:key="item.name"
|
:key="item.name"
|
||||||
:field="item.name as string"
|
:field="item.name as string"
|
||||||
:label="item.name"
|
:label="item.name"
|
||||||
label-col-flex="72px"
|
|
||||||
required>
|
required>
|
||||||
<a-input v-model="parameterFormModel[item.name as string]"
|
<a-input v-model="parameterFormModel[item.name as string]"
|
||||||
:placeholder="item.desc"
|
:placeholder="item.desc"
|
||||||
@@ -104,6 +112,7 @@
|
|||||||
import formRules from '../types/form.rules';
|
import formRules from '../types/form.rules';
|
||||||
import useLoading from '@/hooks/loading';
|
import useLoading from '@/hooks/loading';
|
||||||
import { batchExecCommand } from '@/api/exec/exec-command';
|
import { batchExecCommand } from '@/api/exec/exec-command';
|
||||||
|
import { EnabledStatus } from '@/types/const';
|
||||||
import { Message } from '@arco-design/web-vue';
|
import { Message } from '@arco-design/web-vue';
|
||||||
import ExecEditor from '@/components/view/exec-editor/index.vue';
|
import ExecEditor from '@/components/view/exec-editor/index.vue';
|
||||||
import AuthorizedHostModal from '@/components/asset/host/authorized-host-modal/index.vue';
|
import AuthorizedHostModal from '@/components/asset/host/authorized-host-modal/index.vue';
|
||||||
@@ -116,8 +125,12 @@
|
|||||||
|
|
||||||
const defaultForm = (): ExecCommandRequest => {
|
const defaultForm = (): ExecCommandRequest => {
|
||||||
return {
|
return {
|
||||||
|
description: '',
|
||||||
command: '',
|
command: '',
|
||||||
timeout: 0,
|
timeout: 0,
|
||||||
|
scriptExec: EnabledStatus.DISABLED,
|
||||||
|
parameterSchema: '[]',
|
||||||
|
hostIdList: [],
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -149,6 +162,7 @@
|
|||||||
command: record.command,
|
command: record.command,
|
||||||
description: record.name,
|
description: record.name,
|
||||||
timeout: record.timeout,
|
timeout: record.timeout,
|
||||||
|
scriptExec: record.scriptExec,
|
||||||
};
|
};
|
||||||
parameterSchema.value = record.parameterSchema ? JSON.parse(record.parameterSchema) : [];
|
parameterSchema.value = record.parameterSchema ? JSON.parse(record.parameterSchema) : [];
|
||||||
if (parameterSchema.value.length) {
|
if (parameterSchema.value.length) {
|
||||||
@@ -168,6 +182,7 @@
|
|||||||
command: record.command,
|
command: record.command,
|
||||||
description: record.description,
|
description: record.description,
|
||||||
timeout: record.timeout,
|
timeout: record.timeout,
|
||||||
|
scriptExec: record.scriptExec,
|
||||||
hostIdList: record.hostIdList
|
hostIdList: record.hostIdList
|
||||||
};
|
};
|
||||||
parameterSchema.value = record.parameterSchema ? JSON.parse(record.parameterSchema) : [];
|
parameterSchema.value = record.parameterSchema ? JSON.parse(record.parameterSchema) : [];
|
||||||
|
|||||||
@@ -25,9 +25,15 @@ export const timeout = [{
|
|||||||
message: '超时时间需要在 0 - 100000 之间'
|
message: '超时时间需要在 0 - 100000 之间'
|
||||||
}] as FieldRule[];
|
}] as FieldRule[];
|
||||||
|
|
||||||
|
export const scriptExec = [{
|
||||||
|
required: true,
|
||||||
|
message: '请选择是否使用脚本执行'
|
||||||
|
}] as FieldRule[];
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
description,
|
description,
|
||||||
hostIdList,
|
hostIdList,
|
||||||
command,
|
command,
|
||||||
timeout,
|
timeout,
|
||||||
|
scriptExec,
|
||||||
} as Record<string, FieldRule | FieldRule[]>;
|
} as Record<string, FieldRule | FieldRule[]>;
|
||||||
|
|||||||
@@ -42,6 +42,14 @@
|
|||||||
{{ getDictValue(execJobStatusKey, record.status) }}
|
{{ getDictValue(execJobStatusKey, record.status) }}
|
||||||
</a-tag>
|
</a-tag>
|
||||||
</a-descriptions-item>
|
</a-descriptions-item>
|
||||||
|
<!-- 脚本执行 -->
|
||||||
|
<a-descriptions-item label="脚本执行">
|
||||||
|
{{ record.scriptExec === EnabledStatus.ENABLED ? '是' : '否' }}
|
||||||
|
</a-descriptions-item>
|
||||||
|
<!-- 创建时间 -->
|
||||||
|
<a-descriptions-item label="创建时间">
|
||||||
|
{{ dateFormat(new Date(record.createTime)) }}
|
||||||
|
</a-descriptions-item>
|
||||||
<!-- 修改时间 -->
|
<!-- 修改时间 -->
|
||||||
<a-descriptions-item label="修改时间">
|
<a-descriptions-item label="修改时间">
|
||||||
{{ dateFormat(new Date(record.updateTime)) }}
|
{{ dateFormat(new Date(record.updateTime)) }}
|
||||||
@@ -86,7 +94,8 @@
|
|||||||
import { dateFormat } from '@/utils';
|
import { dateFormat } from '@/utils';
|
||||||
import { copy } from '@/hooks/copy';
|
import { copy } from '@/hooks/copy';
|
||||||
import { getExecJob } from '@/api/exec/exec-job';
|
import { getExecJob } from '@/api/exec/exec-job';
|
||||||
import { execJobStatusKey } from '@/views/exec/exec-job/types/const';
|
import { EnabledStatus } from '@/types/const';
|
||||||
|
import { execJobStatusKey } from '../types/const';
|
||||||
|
|
||||||
const { getDictValue, toOptions } = useDictStore();
|
const { getDictValue, toOptions } = useDictStore();
|
||||||
const { visible, setVisible } = useVisible();
|
const { visible, setVisible } = useVisible();
|
||||||
|
|||||||
@@ -11,12 +11,12 @@
|
|||||||
<a-spin class="full spin-wrapper" :loading="loading">
|
<a-spin class="full spin-wrapper" :loading="loading">
|
||||||
<a-form :model="formModel"
|
<a-form :model="formModel"
|
||||||
ref="formRef"
|
ref="formRef"
|
||||||
label-align="left"
|
label-align="right"
|
||||||
:auto-label-width="true"
|
:auto-label-width="true"
|
||||||
:rules="formRules">
|
:rules="formRules">
|
||||||
<a-row :gutter="16">
|
<a-row :gutter="16">
|
||||||
<!-- 任务名称 -->
|
<!-- 任务名称 -->
|
||||||
<a-col :span="14">
|
<a-col :span="13">
|
||||||
<a-form-item field="name" label="任务名称">
|
<a-form-item field="name" label="任务名称">
|
||||||
<a-input v-model="formModel.name"
|
<a-input v-model="formModel.name"
|
||||||
placeholder="请输入任务名称"
|
placeholder="请输入任务名称"
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<!-- 执行主机 -->
|
<!-- 执行主机 -->
|
||||||
<a-col :span="10">
|
<a-col :span="11">
|
||||||
<a-form-item field="hostIdList" label="执行主机">
|
<a-form-item field="hostIdList" label="执行主机">
|
||||||
<div class="selected-host">
|
<div class="selected-host">
|
||||||
<!-- 已选择数量 -->
|
<!-- 已选择数量 -->
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<!-- cron -->
|
<!-- cron -->
|
||||||
<a-col :span="14">
|
<a-col :span="13">
|
||||||
<a-form-item field="expression" label="cron">
|
<a-form-item field="expression" label="cron">
|
||||||
<a-input v-model="formModel.expression"
|
<a-input v-model="formModel.expression"
|
||||||
placeholder="请输入 cron 表达式"
|
placeholder="请输入 cron 表达式"
|
||||||
@@ -54,7 +54,7 @@
|
|||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<!-- 超时时间 -->
|
<!-- 超时时间 -->
|
||||||
<a-col :span="10">
|
<a-col :span="6">
|
||||||
<a-form-item field="timeout" label="超时时间">
|
<a-form-item field="timeout" label="超时时间">
|
||||||
<a-input-number v-model="formModel.timeout"
|
<a-input-number v-model="formModel.timeout"
|
||||||
placeholder="为0则不超时"
|
placeholder="为0则不超时"
|
||||||
@@ -67,6 +67,22 @@
|
|||||||
</a-input-number>
|
</a-input-number>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
|
<!-- 脚本执行 -->
|
||||||
|
<a-col :span="5">
|
||||||
|
<a-form-item field="scriptExec" label="脚本执行">
|
||||||
|
<div class="flex-center">
|
||||||
|
<a-switch v-model="formModel.scriptExec"
|
||||||
|
type="round"
|
||||||
|
:checked-value="EnabledStatus.ENABLED"
|
||||||
|
:unchecked-value="EnabledStatus.DISABLED" />
|
||||||
|
<div class="question-right ml8">
|
||||||
|
<a-tooltip position="tr" content="启用后会将命令写入脚本文件 传输到主机后执行">
|
||||||
|
<icon-question-circle />
|
||||||
|
</a-tooltip>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
<!-- 执行命令 -->
|
<!-- 执行命令 -->
|
||||||
<a-col :span="24">
|
<a-col :span="24">
|
||||||
<a-form-item class="command-item"
|
<a-form-item class="command-item"
|
||||||
@@ -111,6 +127,7 @@
|
|||||||
import { jobBuiltinsParams } from '../types/const';
|
import { jobBuiltinsParams } from '../types/const';
|
||||||
import { createExecJob, getExecJob, updateExecJob } from '@/api/exec/exec-job';
|
import { createExecJob, getExecJob, updateExecJob } from '@/api/exec/exec-job';
|
||||||
import { Message } from '@arco-design/web-vue';
|
import { Message } from '@arco-design/web-vue';
|
||||||
|
import { EnabledStatus } from '@/types/const';
|
||||||
import { useDictStore } from '@/store';
|
import { useDictStore } from '@/store';
|
||||||
import ExecEditor from '@/components/view/exec-editor/index.vue';
|
import ExecEditor from '@/components/view/exec-editor/index.vue';
|
||||||
|
|
||||||
@@ -131,6 +148,7 @@
|
|||||||
name: undefined,
|
name: undefined,
|
||||||
expression: undefined,
|
expression: undefined,
|
||||||
timeout: 0,
|
timeout: 0,
|
||||||
|
scriptExec: EnabledStatus.DISABLED,
|
||||||
command: undefined,
|
command: undefined,
|
||||||
parameterSchema: '[]',
|
parameterSchema: '[]',
|
||||||
hostIdList: []
|
hostIdList: []
|
||||||
@@ -169,6 +187,7 @@
|
|||||||
name: record.name,
|
name: record.name,
|
||||||
expression: record.expression,
|
expression: record.expression,
|
||||||
timeout: record.timeout,
|
timeout: record.timeout,
|
||||||
|
scriptExec: record.scriptExec,
|
||||||
command: record.command,
|
command: record.command,
|
||||||
parameterSchema: record.parameterSchema,
|
parameterSchema: record.parameterSchema,
|
||||||
hostIdList: record.hostIdList,
|
hostIdList: record.hostIdList,
|
||||||
|
|||||||
@@ -24,6 +24,16 @@ export const expression = [{
|
|||||||
export const timeout = [{
|
export const timeout = [{
|
||||||
required: true,
|
required: true,
|
||||||
message: '请输入超时时间'
|
message: '请输入超时时间'
|
||||||
|
}, {
|
||||||
|
type: 'number',
|
||||||
|
min: 0,
|
||||||
|
max: 100000,
|
||||||
|
message: '超时时间需要在 0 - 100000 之间'
|
||||||
|
}] as FieldRule[];
|
||||||
|
|
||||||
|
export const scriptExec = [{
|
||||||
|
required: true,
|
||||||
|
message: '请选择是否使用脚本执行'
|
||||||
}] as FieldRule[];
|
}] as FieldRule[];
|
||||||
|
|
||||||
export const command = [{
|
export const command = [{
|
||||||
@@ -36,5 +46,6 @@ export default {
|
|||||||
hostIdList,
|
hostIdList,
|
||||||
expression,
|
expression,
|
||||||
timeout,
|
timeout,
|
||||||
|
scriptExec,
|
||||||
command,
|
command,
|
||||||
} as Record<string, FieldRule | FieldRule[]>;
|
} as Record<string, FieldRule | FieldRule[]>;
|
||||||
|
|||||||
@@ -12,32 +12,18 @@
|
|||||||
<!-- 命令表单 -->
|
<!-- 命令表单 -->
|
||||||
<a-form :model="formModel"
|
<a-form :model="formModel"
|
||||||
ref="formRef"
|
ref="formRef"
|
||||||
label-align="left"
|
label-align="right"
|
||||||
:auto-label-width="true"
|
:auto-label-width="true"
|
||||||
:rules="formRules">
|
:rules="formRules">
|
||||||
<a-row :gutter="16">
|
<a-row :gutter="16">
|
||||||
<!-- 执行描述 -->
|
<!-- 执行描述 -->
|
||||||
<a-col :span="10">
|
<a-col :span="16">
|
||||||
<a-form-item field="description" label="执行描述">
|
<a-form-item field="description" label="执行描述">
|
||||||
<a-input v-model="formModel.description"
|
<a-input v-model="formModel.description"
|
||||||
placeholder="请输入执行描述"
|
placeholder="请输入执行描述"
|
||||||
allow-clear />
|
allow-clear />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<!-- 执行主机 -->
|
|
||||||
<a-col :span="7">
|
|
||||||
<a-form-item field="hostIdList" label="执行主机">
|
|
||||||
<div class="selected-host">
|
|
||||||
<!-- 已选择数量 -->
|
|
||||||
<span class="usn" v-if="formModel.hostIdList?.length">
|
|
||||||
已选择<span class="selected-host-count span-blue">{{ formModel.hostIdList?.length }}</span>台主机
|
|
||||||
</span>
|
|
||||||
<span class="usn pointer span-blue" @click="openSelectHost">
|
|
||||||
{{ formModel.hostIdList?.length ? '重新选择' : '选择主机' }}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</a-form-item>
|
|
||||||
</a-col>
|
|
||||||
<!-- 超时时间 -->
|
<!-- 超时时间 -->
|
||||||
<a-col :span="7">
|
<a-col :span="7">
|
||||||
<a-form-item field="timeout"
|
<a-form-item field="timeout"
|
||||||
@@ -53,6 +39,36 @@
|
|||||||
</a-input-number>
|
</a-input-number>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
|
<!-- 执行主机 -->
|
||||||
|
<a-col :span="16">
|
||||||
|
<a-form-item field="hostIdList" label="执行主机">
|
||||||
|
<div class="selected-host">
|
||||||
|
<!-- 已选择数量 -->
|
||||||
|
<span class="usn" v-if="formModel.hostIdList?.length">
|
||||||
|
已选择<span class="selected-host-count span-blue">{{ formModel.hostIdList?.length }}</span>台主机
|
||||||
|
</span>
|
||||||
|
<span class="usn pointer span-blue" @click="openSelectHost">
|
||||||
|
{{ formModel.hostIdList?.length ? '重新选择' : '选择主机' }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<!-- 脚本执行 -->
|
||||||
|
<a-col :span="8">
|
||||||
|
<a-form-item field="scriptExec" label="脚本执行">
|
||||||
|
<div class="flex-center">
|
||||||
|
<a-switch v-model="formModel.scriptExec"
|
||||||
|
type="round"
|
||||||
|
:checked-value="EnabledStatus.ENABLED"
|
||||||
|
:unchecked-value="EnabledStatus.DISABLED" />
|
||||||
|
<div class="question-right ml8">
|
||||||
|
<a-tooltip position="tr" content="启用后会将命令写入脚本文件 传输到主机后执行">
|
||||||
|
<icon-question-circle />
|
||||||
|
</a-tooltip>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
<!-- 执行命令 -->
|
<!-- 执行命令 -->
|
||||||
<a-col :span="24">
|
<a-col :span="24">
|
||||||
<a-form-item field="command"
|
<a-form-item field="command"
|
||||||
@@ -113,6 +129,7 @@
|
|||||||
import useVisible from '@/hooks/visible';
|
import useVisible from '@/hooks/visible';
|
||||||
import formRules from '../../exec-command/types/form.rules';
|
import formRules from '../../exec-command/types/form.rules';
|
||||||
import { Message } from '@arco-design/web-vue';
|
import { Message } from '@arco-design/web-vue';
|
||||||
|
import { EnabledStatus } from '@/types/const';
|
||||||
import { batchExecCommand } from '@/api/exec/exec-command';
|
import { batchExecCommand } from '@/api/exec/exec-command';
|
||||||
import ExecEditor from '@/components/view/exec-editor/index.vue';
|
import ExecEditor from '@/components/view/exec-editor/index.vue';
|
||||||
|
|
||||||
@@ -138,6 +155,7 @@
|
|||||||
formModel.value = {
|
formModel.value = {
|
||||||
description: record.name,
|
description: record.name,
|
||||||
timeout: record.timeout,
|
timeout: record.timeout,
|
||||||
|
scriptExec: record.scriptExec,
|
||||||
command: record.command,
|
command: record.command,
|
||||||
hostIdList: []
|
hostIdList: []
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,12 +11,12 @@
|
|||||||
<a-spin class="full modal-form" :loading="loading">
|
<a-spin class="full modal-form" :loading="loading">
|
||||||
<a-form :model="formModel"
|
<a-form :model="formModel"
|
||||||
ref="formRef"
|
ref="formRef"
|
||||||
label-align="left"
|
label-align="right"
|
||||||
:auto-label-width="true"
|
:auto-label-width="true"
|
||||||
:rules="formRules">
|
:rules="formRules">
|
||||||
<a-row :gutter="16">
|
<a-row :gutter="16">
|
||||||
<!-- 模板名称 -->
|
<!-- 模板名称 -->
|
||||||
<a-col :span="14">
|
<a-col :span="12">
|
||||||
<a-form-item field="name" label="模板名称">
|
<a-form-item field="name" label="模板名称">
|
||||||
<a-input v-model="formModel.name"
|
<a-input v-model="formModel.name"
|
||||||
placeholder="请输入模板名称"
|
placeholder="请输入模板名称"
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<!-- 超时时间 -->
|
<!-- 超时时间 -->
|
||||||
<a-col :span="10">
|
<a-col :span="7">
|
||||||
<a-form-item field="timeout" label="超时时间">
|
<a-form-item field="timeout" label="超时时间">
|
||||||
<a-input-number v-model="formModel.timeout"
|
<a-input-number v-model="formModel.timeout"
|
||||||
placeholder="为0则不超时"
|
placeholder="为0则不超时"
|
||||||
@@ -37,6 +37,22 @@
|
|||||||
</a-input-number>
|
</a-input-number>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
|
<!-- 脚本执行 -->
|
||||||
|
<a-col :span="5">
|
||||||
|
<a-form-item field="scriptExec" label="脚本执行">
|
||||||
|
<div class="flex-center">
|
||||||
|
<a-switch v-model="formModel.scriptExec"
|
||||||
|
type="round"
|
||||||
|
:checked-value="EnabledStatus.ENABLED"
|
||||||
|
:unchecked-value="EnabledStatus.DISABLED" />
|
||||||
|
<div class="question-right ml8">
|
||||||
|
<a-tooltip position="tr" content="启用后会将命令写入脚本文件 传输到主机后执行">
|
||||||
|
<icon-question-circle />
|
||||||
|
</a-tooltip>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
<!-- 模板命令 -->
|
<!-- 模板命令 -->
|
||||||
<a-col :span="24">
|
<a-col :span="24">
|
||||||
<a-form-item field="command"
|
<a-form-item field="command"
|
||||||
@@ -115,6 +131,7 @@
|
|||||||
import formRules from '../types/form.rules';
|
import formRules from '../types/form.rules';
|
||||||
import { createExecTemplate, updateExecTemplate } from '@/api/exec/exec-template';
|
import { createExecTemplate, updateExecTemplate } from '@/api/exec/exec-template';
|
||||||
import { Message } from '@arco-design/web-vue';
|
import { Message } from '@arco-design/web-vue';
|
||||||
|
import { EnabledStatus } from '@/types/const';
|
||||||
import ExecEditor from '@/components/view/exec-editor/index.vue';
|
import ExecEditor from '@/components/view/exec-editor/index.vue';
|
||||||
|
|
||||||
const { visible, setVisible } = useVisible();
|
const { visible, setVisible } = useVisible();
|
||||||
@@ -129,6 +146,7 @@
|
|||||||
name: undefined,
|
name: undefined,
|
||||||
command: undefined,
|
command: undefined,
|
||||||
timeout: 0,
|
timeout: 0,
|
||||||
|
scriptExec: EnabledStatus.DISABLED,
|
||||||
parameterSchema: undefined,
|
parameterSchema: undefined,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -23,8 +23,14 @@ export const timeout = [{
|
|||||||
message: '超时时间需要在 0 - 100000 之间'
|
message: '超时时间需要在 0 - 100000 之间'
|
||||||
}] as FieldRule[];
|
}] as FieldRule[];
|
||||||
|
|
||||||
|
export const scriptExec = [{
|
||||||
|
required: true,
|
||||||
|
message: '请选择是否使用脚本执行'
|
||||||
|
}] as FieldRule[];
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name,
|
name,
|
||||||
command,
|
command,
|
||||||
timeout,
|
timeout,
|
||||||
|
scriptExec,
|
||||||
} as Record<string, FieldRule | FieldRule[]>;
|
} as Record<string, FieldRule | FieldRule[]>;
|
||||||
|
|||||||
Reference in New Issue
Block a user