Search in sources :

Example 11 with ProjectEnv

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("你没有权限操作,请联系项目负责人或超级管理员");
}
Also used : ResinConf(com.ibeiliao.deployment.transfer.vo.ResinConf) ProjectEnv(com.ibeiliao.deployment.admin.vo.global.ProjectEnv) ServerGroup(com.ibeiliao.deployment.admin.vo.server.ServerGroup) Server(com.ibeiliao.deployment.admin.vo.server.Server) ArrayList(java.util.ArrayList) DeployHistory(com.ibeiliao.deployment.admin.vo.deploy.DeployHistory) TransferRequest(com.ibeiliao.deployment.transfer.vo.TransferRequest)

Example 12 with ProjectEnv

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);
}
Also used : ProjectEnv(com.ibeiliao.deployment.admin.vo.global.ProjectEnv) RestResult(com.ibeiliao.deployment.admin.common.RestResult) MenuResource(com.ibeiliao.deployment.admin.utils.resource.MenuResource) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 13 with ProjectEnv

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;
}
Also used : ProjectModule(com.ibeiliao.deployment.admin.vo.project.ProjectModule) ProjectEnv(com.ibeiliao.deployment.admin.vo.global.ProjectEnv) ServerGroup(com.ibeiliao.deployment.admin.vo.server.ServerGroup) Server(com.ibeiliao.deployment.admin.vo.server.Server)

Example 14 with ProjectEnv

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;
}
Also used : ProjectEnv(com.ibeiliao.deployment.admin.vo.global.ProjectEnv)

Aggregations

ProjectEnv (com.ibeiliao.deployment.admin.vo.global.ProjectEnv)14 DeployHistory (com.ibeiliao.deployment.admin.vo.deploy.DeployHistory)3 ProjectModule (com.ibeiliao.deployment.admin.vo.project.ProjectModule)3 RestResult (com.ibeiliao.deployment.admin.common.RestResult)2 InitTestDataService (com.ibeiliao.deployment.admin.service.InitTestDataService)2 MenuResource (com.ibeiliao.deployment.admin.utils.resource.MenuResource)2 DeploymentOrder (com.ibeiliao.deployment.admin.vo.deploy.DeploymentOrder)2 ServerDeployHistory (com.ibeiliao.deployment.admin.vo.deploy.ServerDeployHistory)2 Project (com.ibeiliao.deployment.admin.vo.project.Project)2 Server (com.ibeiliao.deployment.admin.vo.server.Server)2 ServerGroup (com.ibeiliao.deployment.admin.vo.server.ServerGroup)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 AdminAccount (com.ibeiliao.deployment.admin.vo.account.AdminAccount)1 GlobalSetting (com.ibeiliao.deployment.admin.vo.global.GlobalSetting)1 ModuleJvm (com.ibeiliao.deployment.admin.vo.project.ModuleJvm)1 LowQualityRank (com.ibeiliao.deployment.admin.vo.stat.LowQualityRank)1 ResinConf (com.ibeiliao.deployment.transfer.vo.ResinConf)1 TransferRequest (com.ibeiliao.deployment.transfer.vo.TransferRequest)1 ArrayList (java.util.ArrayList)1