[ Cmii ] [ Octopus ] - real project
This commit is contained in:
@@ -34,12 +34,15 @@ public class ProjectDeployContext {
|
||||
boolean cmiiHarborSynchronized;
|
||||
String currentSynchronizingProject;
|
||||
|
||||
// app
|
||||
List<BaseFunctionEnum> masterNodeProcedure;
|
||||
|
||||
List<BaseFunctionEnum> agentNodeProcedure;
|
||||
List<BaseFunctionEnum> masterNodeBaseProcedure;
|
||||
|
||||
List<BaseFunctionEnum> agentNodeBaseProcedure;
|
||||
|
||||
ArrayList<String> baseFunctionArgs;
|
||||
ArrayList<String> appFunctionArgs;
|
||||
|
||||
// app
|
||||
List<AppFunctionEnum> masterAppProcedure;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import io.wdd.server.coreService.CoreProjectService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
@@ -22,6 +23,24 @@ public class AppFuncScheduler {
|
||||
@Resource
|
||||
CoreProjectService coreProjectService;
|
||||
|
||||
public boolean runProcedure(ProjectDeployContext projectDeployContext) {
|
||||
|
||||
// before run
|
||||
// check base requirement
|
||||
beforeRunProcedure(projectDeployContext);
|
||||
|
||||
|
||||
// during run
|
||||
doRunProcedure(projectDeployContext);
|
||||
|
||||
|
||||
// after run
|
||||
afterRunProcedure(projectDeployContext);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数固定顺序为 A1C2IP SUPREME N1C2IP A1C1IP A1C1JS M2D2IP KIMMY JACLOVE
|
||||
* 1 2 3 4 5 6 7 8
|
||||
@@ -55,36 +74,15 @@ public class AppFuncScheduler {
|
||||
return appFuncArgs;
|
||||
}
|
||||
|
||||
public boolean runProcedure(ProjectDeployContext projectDeployContext) {
|
||||
private void beforeRunProcedure(ProjectDeployContext projectDeployContext) {
|
||||
|
||||
// before run
|
||||
// check base requirement
|
||||
beforeRunProcedure(projectDeployContext);
|
||||
// 检查是否符合规定
|
||||
|
||||
// 检查每一个Agent是否能够连通,调用命令返回结果
|
||||
|
||||
// during run
|
||||
doRunProcedure(projectDeployContext);
|
||||
|
||||
|
||||
// after run
|
||||
afterRunProcedure(projectDeployContext);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void afterRunProcedure(ProjectDeployContext projectDeployContext) {
|
||||
|
||||
// 检查是否安装完成, 对安装环境进行判定
|
||||
log.debug("afterRunProcedure complete!");
|
||||
}
|
||||
|
||||
private void doRunProcedure(ProjectDeployContext projectDeployContext) {
|
||||
// 打印施工信息
|
||||
|
||||
// 执行 基础功能施工的内容
|
||||
String masterTopicName = projectDeployContext
|
||||
.getMasterNode()
|
||||
.getTopicName();
|
||||
|
||||
ProjectInfoPO projectInfoPO = coreProjectService.projectGetOne(projectDeployContext.getProjectId());
|
||||
if (ObjectUtils.isEmpty(projectInfoPO)) {
|
||||
@@ -99,29 +97,36 @@ public class AppFuncScheduler {
|
||||
projectInfoPO
|
||||
);
|
||||
|
||||
List<AppFunctionEnum> appFunctionEnumList = List.of(
|
||||
// AppFunctionEnum.DEPLOY_CHRONY_SERVER,
|
||||
// AppFunctionEnum.DEPLOY_RKE
|
||||
// AppFunctionEnum.DEPLOY_K8S_DASHBOARD,
|
||||
// AppFunctionEnum.DEPLOY_NFS,
|
||||
// AppFunctionEnum.DEPLOY_TEST_NFS,
|
||||
// AppFunctionEnum.DEPLOY_K8S_NAMESPACE
|
||||
// AppFunctionEnum.DEPLOY_K8S_PVC,
|
||||
// AppFunctionEnum.DEPLOY_K8S_MYSQL,
|
||||
// AppFunctionEnum.DEPLOY_K8S_REDIS,
|
||||
// AppFunctionEnum.DEPLOY_K8S_MIDDLEWARES,
|
||||
// AppFunctionEnum.DEPLOY_INGRESS
|
||||
AppFunctionEnum.DEPLOY_FRONTEND
|
||||
// AppFunctionEnum.DEPLOY_BACKEND
|
||||
// AppFunctionEnum.DEPLOY_K8S_SRS
|
||||
projectDeployContext.setAppFunctionArgs(appFuncArgs);
|
||||
|
||||
);
|
||||
log.debug("beforeRunProcedure complete!");
|
||||
|
||||
}
|
||||
|
||||
for (AppFunctionEnum appFunctionEnum : appFunctionEnumList) {
|
||||
private void afterRunProcedure(ProjectDeployContext projectDeployContext) {
|
||||
|
||||
// 检查是否安装完成, 对安装环境进行判定
|
||||
log.debug("afterRunProcedure complete!");
|
||||
}
|
||||
|
||||
private void doRunProcedure(ProjectDeployContext projectDeployContext) {
|
||||
|
||||
String masterTopicName = projectDeployContext
|
||||
.getMasterNode()
|
||||
.getTopicName();
|
||||
|
||||
List<AppFunctionEnum> masterAppProcedure = projectDeployContext.getMasterAppProcedure();
|
||||
if (CollectionUtils.isEmpty(masterAppProcedure)) {
|
||||
log.info("app procedure is null !");
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList<String> appFunctionArgs = projectDeployContext.getAppFunctionArgs();
|
||||
|
||||
for (AppFunctionEnum appFunctionEnum : masterAppProcedure) {
|
||||
|
||||
// rebuild
|
||||
appFuncArgs.add(
|
||||
appFunctionArgs.add(
|
||||
0,
|
||||
appFunctionEnum.getAppOpname()
|
||||
);
|
||||
@@ -129,7 +134,7 @@ public class AppFuncScheduler {
|
||||
boolean appFuncJudge = funcService.callAppFuncAndJudge(
|
||||
masterTopicName,
|
||||
appFunctionEnum,
|
||||
appFuncArgs
|
||||
appFunctionArgs
|
||||
);
|
||||
|
||||
if (!appFuncJudge) {
|
||||
@@ -142,22 +147,10 @@ public class AppFuncScheduler {
|
||||
|
||||
|
||||
// must remove this one
|
||||
appFuncArgs.remove(0);
|
||||
appFunctionArgs.remove(0);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void beforeRunProcedure(ProjectDeployContext projectDeployContext) {
|
||||
|
||||
// 检查是否符合规定
|
||||
|
||||
// 检查每一个Agent是否能够连通,调用命令返回结果
|
||||
|
||||
// 打印施工信息
|
||||
|
||||
log.debug("beforeRunProcedure complete!");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -89,7 +89,6 @@ public class BaseFuncScheduler {
|
||||
|
||||
// base func args
|
||||
ArrayList<String> baseFuncArgList = new ArrayList<>();
|
||||
baseFuncArgList.add("20");
|
||||
baseFuncArgList.add(projectDeployContext
|
||||
.getMasterNode()
|
||||
.getServerIpInV4());
|
||||
@@ -132,9 +131,9 @@ public class BaseFuncScheduler {
|
||||
|
||||
List<BaseFunctionEnum> agentNodeProcedureList;
|
||||
if (masterNode) {
|
||||
agentNodeProcedureList = projectDeployContext.getMasterNodeProcedure();
|
||||
agentNodeProcedureList = projectDeployContext.getMasterNodeBaseProcedure();
|
||||
} else {
|
||||
agentNodeProcedureList = projectDeployContext.getAgentNodeProcedure();
|
||||
agentNodeProcedureList = projectDeployContext.getAgentNodeBaseProcedure();
|
||||
}
|
||||
|
||||
if (CollectionUtils.isEmpty(agentNodeProcedureList)) {
|
||||
|
||||
@@ -184,7 +184,8 @@ public class HarborFuncScheduler {
|
||||
syncHarborArgList.add(masterNode.getServerIpInV4());
|
||||
// second arg sourceHarborHost
|
||||
// String sourceHarborHost = getIPv4Address();
|
||||
syncHarborArgList.add("harbor.wdd.io");
|
||||
// syncHarborArgList.add("harbor.wdd.io"); // local
|
||||
syncHarborArgList.add("192.168.0.6:8034"); // public
|
||||
|
||||
// third arg sync project name
|
||||
syncHarborArgList.add(projectDeployContext.getCurrentSynchronizingProject());
|
||||
|
||||
@@ -18,7 +18,8 @@ import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static io.wdd.rpc.message.handler.OMessageHandler.*;
|
||||
import static io.wdd.rpc.message.handler.OMessageHandler.StopWaitingResult;
|
||||
import static io.wdd.rpc.message.handler.OMessageHandler.WaitFromAgent;
|
||||
import static io.wdd.rpc.status.AllAgentStatusCache.ALL_AGENT_TOPIC_NAME_SET;
|
||||
|
||||
@Service
|
||||
@@ -66,14 +67,14 @@ public class ExecutionServiceImpl implements ExecutionService {
|
||||
oMessageToAgentSender.send(octopusMessage);
|
||||
|
||||
// debug
|
||||
log.debug(
|
||||
"发送的 matchKey为 {}, 内容为 {}",
|
||||
GenerateOMessageMatchKey(
|
||||
octopusMessage.getOctopusMessageType(),
|
||||
octopusMessage.getInit_time()
|
||||
),
|
||||
octopusMessage
|
||||
);
|
||||
// log.debug(
|
||||
// "发送的 matchKey为 {}, 内容为 {}",
|
||||
// GenerateOMessageMatchKey(
|
||||
// octopusMessage.getOctopusMessageType(),
|
||||
// octopusMessage.getInit_time()
|
||||
// ),
|
||||
// octopusMessage
|
||||
// );
|
||||
|
||||
// 需要返回结果
|
||||
|
||||
@@ -116,25 +117,25 @@ public class ExecutionServiceImpl implements ExecutionService {
|
||||
commandResultLog = (ArrayList<String>) octopusMessage.getResult();
|
||||
|
||||
|
||||
Object executionContent;
|
||||
if (executionMessage
|
||||
.getExecutionType()
|
||||
.equals("BASE")) {
|
||||
executionContent = executionMessage.getExecutionType() + "==" + executionMessage.getFuncContent();
|
||||
} else if (executionMessage.getSingleLineCommand() != null) {
|
||||
executionContent = executionMessage.getSingleLineCommand();
|
||||
} else {
|
||||
executionContent = executionMessage.getMultiLineCommand();
|
||||
}
|
||||
|
||||
// debug
|
||||
log.debug(
|
||||
"执行命令 {} {} 在规定时间内结束, 结果为 {} 返回内容为 {}",
|
||||
executionContent,
|
||||
waitOK ? "已经" : "未",
|
||||
octopusMessage.getResultCode(),
|
||||
commandResultLog
|
||||
);
|
||||
// Object executionContent;
|
||||
// if (executionMessage
|
||||
// .getExecutionType()
|
||||
// .equals("BASE")) {
|
||||
// executionContent = executionMessage.getExecutionType() + "==" + executionMessage.getFuncContent();
|
||||
// } else if (executionMessage.getSingleLineCommand() != null) {
|
||||
// executionContent = executionMessage.getSingleLineCommand();
|
||||
// } else {
|
||||
// executionContent = executionMessage.getMultiLineCommand();
|
||||
// }
|
||||
//
|
||||
// // debug
|
||||
// log.debug(
|
||||
// "执行命令 {} {} 在规定时间内结束, 结果为 {} 返回内容为 {}",
|
||||
// executionContent,
|
||||
// waitOK ? "已经" : "未",
|
||||
// octopusMessage.getResultCode(),
|
||||
// commandResultLog
|
||||
// );
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.wdd.server.func;
|
||||
|
||||
import io.wdd.func.auto.beans.AppFunctionEnum;
|
||||
import io.wdd.func.auto.beans.BaseFunctionEnum;
|
||||
import io.wdd.func.auto.beans.ProjectDeployContext;
|
||||
import io.wdd.func.auto.service.AppFuncScheduler;
|
||||
@@ -93,28 +94,60 @@ public class TestBaseFuncScheduler {
|
||||
|
||||
List<BaseFunctionEnum> masterNodeProcedure = List.of(
|
||||
// BaseFunctionEnum.INSTALL_DOCKER,
|
||||
BaseFunctionEnum.INSTALL_DOCKER_COMPOSE,
|
||||
BaseFunctionEnum.MODIFY_DOCKER_CONFIG,
|
||||
BaseFunctionEnum.INSTALL_HARBOR
|
||||
// BaseFunctionEnum.INSTALL_DOCKER_COMPOSE,
|
||||
// BaseFunctionEnum.MODIFY_DOCKER_CONFIG,
|
||||
// BaseFunctionEnum.INSTALL_HARBOR
|
||||
// BaseFunctionEnum.INSTALL_DEFAULT_SSH_KEY
|
||||
BaseFunctionEnum.INSTALL_NFS_SERVER_ONLINE
|
||||
);
|
||||
|
||||
List<BaseFunctionEnum> agentNodeProcedure = List.of(
|
||||
BaseFunctionEnum.DISABLE_SWAP,
|
||||
BaseFunctionEnum.SHUTDOWN_FIREWALL,
|
||||
BaseFunctionEnum.INSTALL_DOCKER,
|
||||
BaseFunctionEnum.INSTALL_DOCKER_COMPOSE
|
||||
// BaseFunctionEnum.DISABLE_SWAP,
|
||||
// BaseFunctionEnum.SHUTDOWN_FIREWALL,
|
||||
// BaseFunctionEnum.INSTALL_DOCKER,
|
||||
// BaseFunctionEnum.INSTALL_DOCKER_COMPOSE
|
||||
// BaseFunctionEnum.MODIFY_DOCKER_CONFIG
|
||||
BaseFunctionEnum.INSTALL_DEFAULT_SSH_KEY
|
||||
);
|
||||
|
||||
projectDeployContext.setAgentNodeProcedure(agentNodeProcedure);
|
||||
projectDeployContext.setMasterNodeBaseProcedure(masterNodeProcedure);
|
||||
projectDeployContext.setAgentNodeBaseProcedure(agentNodeProcedure);
|
||||
|
||||
|
||||
baseFuncScheduler.runProcedure(projectDeployContext);
|
||||
// baseFuncScheduler.runProcedure(projectDeployContext);
|
||||
|
||||
|
||||
// harborFuncScheduler.runProcedure(projectDeployContext);
|
||||
|
||||
// appFuncScheduler.runProcedure(projectDeployContext);
|
||||
|
||||
List<AppFunctionEnum> appFunctionEnumList = List.of(
|
||||
// AppFunctionEnum.DEPLOY_CHRONY_SERVER,
|
||||
// AppFunctionEnum.DEPLOY_RKE
|
||||
AppFunctionEnum.DEPLOY_K8S_DASHBOARD,
|
||||
AppFunctionEnum.DEPLOY_NFS,
|
||||
AppFunctionEnum.DEPLOY_TEST_NFS,
|
||||
AppFunctionEnum.DEPLOY_K8S_NAMESPACE,
|
||||
AppFunctionEnum.DEPLOY_K8S_PVC,
|
||||
AppFunctionEnum.DEPLOY_K8S_MYSQL,
|
||||
AppFunctionEnum.DEPLOY_K8S_REDIS,
|
||||
AppFunctionEnum.DEPLOY_K8S_MIDDLEWARES,
|
||||
AppFunctionEnum.DEPLOY_INGRESS
|
||||
// AppFunctionEnum.DEPLOY_FRONTEND
|
||||
// AppFunctionEnum.DEPLOY_BACKEND
|
||||
// AppFunctionEnum.DEPLOY_K8S_SRS
|
||||
|
||||
);
|
||||
projectDeployContext.setMasterAppProcedure(appFunctionEnumList);
|
||||
|
||||
appFuncScheduler.runProcedure(projectDeployContext);
|
||||
|
||||
|
||||
masterNodeProcedure = List.of(BaseFunctionEnum.CHRONY_TO_MASTER);
|
||||
agentNodeProcedure = List.of(BaseFunctionEnum.CHRONY_TO_MASTER);
|
||||
|
||||
projectDeployContext.setMasterNodeBaseProcedure(masterNodeProcedure);
|
||||
projectDeployContext.setAgentNodeBaseProcedure(agentNodeProcedure);
|
||||
|
||||
// baseFuncScheduler.runProcedure(projectDeployContext);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user