Search in sources :

Example 1 with ProjectModule

use of com.ibeiliao.deployment.admin.vo.project.ProjectModule in project Corgi by kevinYin.

the class InitTestDataService method init.

/**
 * 创建初始化数据
 */
public InitData init() {
    // 1. 创建 account
    // 2. 创建 project
    // 3. 创建 module
    // 4. 初始化 env
    // 5. 创建 server group & server
    List<ProjectEnv> envs = createProjectEnv();
    AdminAccount account = createAdminAccount();
    Project project = createProject(account);
    ProjectModule module = createModule(account.getUid(), project, envs);
    return new InitData(account, project, module, envs);
}
Also used : Project(com.ibeiliao.deployment.admin.vo.project.Project) ProjectEnv(com.ibeiliao.deployment.admin.vo.global.ProjectEnv) ProjectModule(com.ibeiliao.deployment.admin.vo.project.ProjectModule) AdminAccount(com.ibeiliao.deployment.admin.vo.account.AdminAccount)

Example 2 with ProjectModule

use of com.ibeiliao.deployment.admin.vo.project.ProjectModule in project Corgi by kevinYin.

the class ModuleServiceTest method testCheckResinPort.

@Test
public void testCheckResinPort() {
    ProjectModule module = moduleService.getByModuleId(6);
    List<ServerGroup> serverGroups = serverGroupService.getByModuleIds(Lists.newArrayList(6), true);
    module.setServerGroups(serverGroups);
    module.setModuleId(0);
    module.getResinConf().setHttpPort(8087);
    module.getResinConf().setServerPort(6807);
    module.getResinConf().setWatchdogPort(6608);
    Map<String, String> resinPort2OccupyInfoMap = moduleService.checkResinPortOccupy(module);
    assert !resinPort2OccupyInfoMap.isEmpty();
}
Also used : ProjectModule(com.ibeiliao.deployment.admin.vo.project.ProjectModule) ServerGroup(com.ibeiliao.deployment.admin.vo.server.ServerGroup) Test(org.junit.Test)

Example 3 with ProjectModule

use of com.ibeiliao.deployment.admin.vo.project.ProjectModule in project Corgi by kevinYin.

the class DeployHistoryServiceImpl method checkModuleStatus.

private void checkModuleStatus(int moduleId) {
    ProjectModule module = projectModuleService.getByModuleId(moduleId);
    if (module == null) {
        throw new IllegalArgumentException("模块不存在,moduleId=" + moduleId);
    }
    if (module.getModuleType() != ModuleType.STATIC.getValue()) {
        Assert.hasText(module.getRestartShell(), "重启脚本为空,请先完善模块配置");
    }
    Assert.hasText(module.getCompileShell(), "编译脚本为空,请先完善模块配置");
    Assert.hasText(module.getSvnAccount(), "svn/git帐号为空,请先完善模块配置");
    Assert.hasText(module.getSvnPassword(), "svn/git密码为空,请先完善模块配置");
}
Also used : ProjectModule(com.ibeiliao.deployment.admin.vo.project.ProjectModule)

Example 4 with ProjectModule

use of com.ibeiliao.deployment.admin.vo.project.ProjectModule in project Corgi by kevinYin.

the class DeployHistoryServiceImpl method createDeploymentOrder.

@Override
@Transactional
public void createDeploymentOrder(DeploymentOrder order) {
    validateParameterAndModule(order);
    // 检查服务器是否存在 & 环境是否为 envId
    List<Server> servers = checkServerStatus(order);
    checkProjectAuthorization(order);
    checkIfDeployingModuleWithEnv(order);
    logger.info("创建上线单 | order: " + JSON.toJSONString(order));
    ProjectModule module = projectModuleService.getByModuleId(order.getModuleId());
    DeployHistoryPO deployHistory = new DeployHistoryPO();
    VOUtil.copy(order, deployHistory);
    deployHistory.setCreateTime(new Date());
    deployHistory.setProjectId(module.getProjectId());
    deployHistory.setModuleName(module.getModuleName());
    deployHistory.setResult(DeployResult.NONE.getValue());
    // 如果模块需要审核,进入审核,否则进入发布阶段
    if (needAudit(module, deployHistory)) {
        deployHistory.setDeployStatus(DeployStatus.WAITING_FOR_AUDIT.getValue());
    } else {
        deployHistory.setDeployStatus(DeployStatus.WAITING_FOR_DEPLOYMENT.getValue());
    }
    deployHistory.setSuccessCount(0);
    deployHistory.setDeployServers(order.getServerId().length);
    if (!deployHistory.getTagName().startsWith("/")) {
        deployHistory.setTagName("/" + deployHistory.getTagName());
    }
    // 判断是不是回滚的请求
    if (deployHistory.getRollbackToDeployId() > 0) {
        deployHistory.setIsRollback(Constants.TRUE);
    }
    deployHistoryDao.insert(deployHistory);
    saveDeployServers(deployHistory, order, servers);
}
Also used : ProjectModule(com.ibeiliao.deployment.admin.vo.project.ProjectModule) Server(com.ibeiliao.deployment.admin.vo.server.Server) ServerDeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO) DeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with ProjectModule

use of com.ibeiliao.deployment.admin.vo.project.ProjectModule in project Corgi by kevinYin.

the class CreateDeploymentController method enoughServerRes.

/**
 * 判断服务器资源是否足够
 * @param order
 * @return ApiCode.SUCCESS=足够
 * @author linyi 2017/5/11
 */
private RestResult<Object> enoughServerRes(DeploymentOrder order) {
    List<DeployHistory> histories = deployHistoryService.queryDeployHistory(order.getEnvId(), order.getModuleId(), 1, 10);
    // 静态项目不做判断
    ProjectModule module = projectModuleService.getByModuleId(order.getModuleId());
    if (module.getModuleType() == ModuleType.STATIC.getValue()) {
        return new RestResult<>(ApiCode.SUCCESS, "");
    }
    /* if (CollectionUtils.isEmpty(histories)) {
            logger.info("第一次发布");
            String jvmArgs = getJvmArgs(order.getModuleId(), order.getEnvId());
            for (int serverId : order.getServerId()) {
                Server server = serverService.getById(serverId);
                if (server == null || StringUtils.isBlank(server.getIp())) {
                    return new RestResult<>(ApiCode.FAILURE, "serverId或IP不存在, serverId: " + serverId);
                }
                RestResult<Object> result = AliyunEcsUtil.isEnoughResByIp(server.getIp(), jvmArgs);
                if (!result.isSuccess()) {
                    return result;
                }
            }
        }*/
    return new RestResult<>(ApiCode.SUCCESS, "");
}
Also used : ProjectModule(com.ibeiliao.deployment.admin.vo.project.ProjectModule) RestResult(com.ibeiliao.deployment.admin.common.RestResult) DeployHistory(com.ibeiliao.deployment.admin.vo.deploy.DeployHistory)

Aggregations

ProjectModule (com.ibeiliao.deployment.admin.vo.project.ProjectModule)17 ProjectEnv (com.ibeiliao.deployment.admin.vo.global.ProjectEnv)3 Project (com.ibeiliao.deployment.admin.vo.project.Project)3 Server (com.ibeiliao.deployment.admin.vo.server.Server)3 ServerGroup (com.ibeiliao.deployment.admin.vo.server.ServerGroup)3 RestResult (com.ibeiliao.deployment.admin.common.RestResult)2 DeployHistoryPO (com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO)2 ServerDeployHistoryPO (com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO)2 ProjectModulePO (com.ibeiliao.deployment.admin.po.project.ProjectModulePO)2 MenuResource (com.ibeiliao.deployment.admin.utils.resource.MenuResource)2 AdminAccount (com.ibeiliao.deployment.admin.vo.account.AdminAccount)2 ModuleJvm (com.ibeiliao.deployment.admin.vo.project.ModuleJvm)2 Test (org.junit.Test)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ProjectPO (com.ibeiliao.deployment.admin.po.project.ProjectPO)1 DeployHistory (com.ibeiliao.deployment.admin.vo.deploy.DeployHistory)1 Transactional (org.springframework.transaction.annotation.Transactional)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1