use of com.ibeiliao.deployment.admin.vo.global.ProjectEnv in project Corgi by kevinYin.
the class ViewProjectController method createTransferRequest.
private TransferRequest createTransferRequest(int serverId, boolean restart) throws Exception {
Server server = serverService.getById(serverId);
Assert.notNull(server, "server不存在");
ServerGroup serverGroup = serverGroupService.getById(server.getGroupId());
Assert.notNull(serverGroup, "serverGroup不存在");
ProjectModule module = projectModuleService.getByModuleId(serverGroup.getModuleId());
Project project = projectService.getProject(module.getProjectId());
ProjectEnv env = projectEnvService.getById(serverGroup.getEnvId());
long accountId = AdminContext.getAccountId();
// if (projectAccountRelationService.canModify(accountId, project.getProjectId())) {
DeployHistory deployHistory = null;
if (restart) {
deployHistory = deployHistoryService.createRestartHistory(accountId, serverId);
} else {
deployHistory = deployHistoryService.createStopHistory(accountId, serverId);
}
TransferRequest request = new TransferRequest();
request.setHistoryId(deployHistory.getHistoryId());
request.setSaveFileName(null);
request.setModuleName(module.getModuleName());
request.setEnv(env.getEnvName());
request.setProjectName(project.getProjectNo());
request.setRestartShell(module.getRestartShell());
request.setJvmArgs(getModuleJvmArgs(module.getModuleId(), serverGroup.getEnvId()));
request.setPreDeployShell(module.getPreShell());
request.setPostDeployShell(module.getPostShell());
request.setStopShell(module.getStopShell());
request.setModuleType(module.getModuleType());
List<String> serverIps = new ArrayList<>();
serverIps.add(server.getIp());
request.setTargetServerIps(serverIps);
if (module.getModuleType() == ModuleType.WEB_PROJECT.getValue()) {
ResinConf resinConf = module.getResinConf();
// 设置 [当前环境] 的域名
resinConf.setDomain(ModuleUtil.getDomainForEnv(resinConf.getDomain(), env.getEnvName()));
resinConf.setAliasDomain(ModuleUtil.getAliasDomainForEnv(resinConf.getAliasDomain(), env.getEnvName()));
request.setModuleFinalName(readFinalName(module, deployHistory.getTagName()));
request.setResinConf(resinConf);
if (!projectModuleService.isResinConfCreated(deployHistory.getModuleId()) || resinConf.isCreateEveryTime()) {
request.setCreateResinConf(true);
}
}
return request;
// }
// throw new IllegalStateException("你没有权限操作,请联系项目负责人或超级管理员");
}
use of com.ibeiliao.deployment.admin.vo.global.ProjectEnv in project Corgi by kevinYin.
the class ListEnvironmentController method delete.
/**
* save
*/
@ResponseBody
@RequestMapping("save.do")
@MenuResource("保存环境")
public RestResult<Object> delete(int envId, String envName, int onlineFlag) {
if (StringUtils.isBlank(envName)) {
return new RestResult<>(ApiCode.PARAMETER_ERROR, "环境名称不能为空");
}
ProjectEnv projectEnv = new ProjectEnv();
projectEnv.setEnvId(envId);
projectEnv.setEnvName(envName.trim());
projectEnv.setOnlineFlag(onlineFlag);
projectEnvService.saveEnv(projectEnv);
return new RestResult<>(null);
}
use of com.ibeiliao.deployment.admin.vo.global.ProjectEnv in project Corgi by kevinYin.
the class InitTestDataService method createModule.
private ProjectModule createModule(long accountId, Project project, List<ProjectEnv> envs) {
ProjectModule module = new ProjectModule();
module.setProjectId(project.getProjectId());
module.setCompileShell("mvn -P=dev");
module.setNeedAudit(Constants.TRUE);
module.setModuleName("test-module");
module.setModuleNameZh("测试模块");
module.setModuleType(ModuleType.SERVICE.getValue());
module.setLogName("");
module.setPreShell("");
module.setPostShell("");
module.setRestartShell("/usr/local/resinpro/bin/resin.sh restart");
module.setRepoUrl("https://a.b.com/test-project");
module.setRepoType(ModuleRepoType.SVN.getValue());
module.setSrcPath("");
module.setStopShell("");
module.setSvnAccount("test-account");
module.setSvnPassword("test-password");
module.setNeedAudit(Constants.TRUE);
ProjectEnv env = envs.get(0);
List<ServerGroup> serverGroups = new ArrayList<>();
ServerGroup group1 = new ServerGroup();
group1.setEnvId(env.getEnvId());
group1.setGroupName("dev test");
serverGroups.add(group1);
projectModuleService.saveProjectModule(accountId, module);
List<Server> servers = new ArrayList<>();
final int MAX_SERVERS = 8;
for (int i = 0; i < MAX_SERVERS; i++) {
servers.add(createServer(i));
}
group1.setServers(servers);
module.setServerGroups(serverGroups);
projectModuleService.saveProjectModule(accountId, module);
ProjectModule tmpModule = projectModuleService.getByModuleId(module.getModuleId());
Assert.notNull(tmpModule);
Assert.isTrue(tmpModule.getNeedAudit() == Constants.TRUE);
// 要重新读一次数据
List<ServerGroup> newServerGroups = serverGroupService.getByModuleIds(Lists.newArrayList(module.getModuleId()), false);
module.setServerGroups(newServerGroups);
for (ServerGroup tmpGroup : newServerGroups) {
List<Integer> groupIds = new LinkedList<>();
groupIds.add(tmpGroup.getGroupId());
List<Server> newServers = serverService.getByGroupIds(groupIds);
tmpGroup.setServers(newServers);
}
return module;
}
use of com.ibeiliao.deployment.admin.vo.global.ProjectEnv in project Corgi by kevinYin.
the class InitTestDataService method createProjectEnv.
private List<ProjectEnv> createProjectEnv() {
ProjectEnv test = new ProjectEnv();
test.setEnvId(10000001);
test.setEnvName("test");
projectEnvService.saveEnv(test);
ProjectEnv online = new ProjectEnv();
online.setEnvName("online");
online.setEnvId(10000002);
projectEnvService.saveEnv(online);
List<ProjectEnv> envs = new ArrayList<>();
envs.add(test);
envs.add(online);
return envs;
}
Aggregations