From b189c5d9d0fd67dcd5487928a93cdf021fe9aba5 Mon Sep 17 00:00:00 2001 From: zhangshuai Date: Tue, 26 Nov 2024 10:13:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20ASW-192=20playbook=E6=94=AF=E6=8C=81pyt?= =?UTF-8?q?hon=20=E8=84=9A=E6=9C=AC=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../runner/job/JobPlaybookExecResultChecker.java | 2 +- .../asw/module/runner/job/JobPlaybookExecutor.java | 1 + .../runner/service/impl/PlaybookServiceImpl.java | 12 ++++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/geedge/asw/module/runner/job/JobPlaybookExecResultChecker.java b/src/main/java/net/geedge/asw/module/runner/job/JobPlaybookExecResultChecker.java index 2860c34..d5c4aba 100644 --- a/src/main/java/net/geedge/asw/module/runner/job/JobPlaybookExecResultChecker.java +++ b/src/main/java/net/geedge/asw/module/runner/job/JobPlaybookExecResultChecker.java @@ -116,7 +116,7 @@ public class JobPlaybookExecResultChecker extends QuartzJobBean { Constants.RUNNING_JOB_THREAD.computeIfAbsent(id, jobId -> startGetJobLogThread(job, environment)); break; case "error": - Constants.RESULT_JOB_THREAD.computeIfAbsent(id, jobId -> startGetJobResultThread(job, environment, RunnerConstant.JobStatus.FAILED.getValue())); + Constants.RESULT_JOB_THREAD.computeIfAbsent(id, jobId -> startGetJobResultThread(job, environment,RunnerConstant.JobStatus.FAILED.getValue())); break; case "done": Constants.RESULT_JOB_THREAD.computeIfAbsent(id, jobId -> startGetJobResultThread(job, environment, RunnerConstant.JobStatus.PASSED.getValue())); diff --git a/src/main/java/net/geedge/asw/module/runner/job/JobPlaybookExecutor.java b/src/main/java/net/geedge/asw/module/runner/job/JobPlaybookExecutor.java index 43843aa..4692d6a 100644 --- a/src/main/java/net/geedge/asw/module/runner/job/JobPlaybookExecutor.java +++ b/src/main/java/net/geedge/asw/module/runner/job/JobPlaybookExecutor.java @@ -212,6 +212,7 @@ public class JobPlaybookExecutor extends QuartzJobBean { request.form("file", zipFile); request.form("id", job.getId()); request.form("packageName", packageName); + request.form("type", playbook.getType()); for (Map.Entry param : params.entrySet()) { request.form(param.getKey(), param.getValue()); } diff --git a/src/main/java/net/geedge/asw/module/runner/service/impl/PlaybookServiceImpl.java b/src/main/java/net/geedge/asw/module/runner/service/impl/PlaybookServiceImpl.java index 7c02ce7..e48ec2c 100644 --- a/src/main/java/net/geedge/asw/module/runner/service/impl/PlaybookServiceImpl.java +++ b/src/main/java/net/geedge/asw/module/runner/service/impl/PlaybookServiceImpl.java @@ -70,6 +70,7 @@ public class PlaybookServiceImpl extends ServiceImpl fileList = Arrays.stream(unzip.listFiles()).toList(); if (T.CollUtil.isEmpty(fileList) || fileList.size() != 1) { @@ -87,6 +88,17 @@ public class PlaybookServiceImpl extends ServiceImpl fileList = Arrays.stream(unzip.listFiles()).toList(); + fileList = fileList.stream().filter(x -> { + return T.StrUtil.equals("main.py", x.getName()); + }).toList(); + if (T.CollUtil.isEmpty(fileList)) { + throw new ASWException(RCode.PLAYBOOK_INVALID_FILE); + } + } this.save(playbook); } catch (Exception e) { log.error(e, "[savePlaybook] [error] [file: {}]", file.getName());