Search in sources :

Example 1 with Server

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

the class DeployHistoryServiceImplTest method getServerIds.

private int[] getServerIds(InitTestDataService.InitData data) {
    List<Server> servers = data.module.getServerGroups().get(0).getServers();
    int[] serverIds = new int[servers.size()];
    int count = 0;
    for (Server server : servers) {
        serverIds[count++] = server.getServerId();
    }
    return serverIds;
}
Also used : Server(com.ibeiliao.deployment.admin.vo.server.Server)

Example 2 with Server

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

the class InitTestDataService method createServer.

private Server createServer(int i) {
    i = i + 1;
    Server server = new Server();
    server.setIp("12.34.56." + (10 + i));
    server.setServerName("test-server-" + i);
    return server;
}
Also used : Server(com.ibeiliao.deployment.admin.vo.server.Server)

Example 3 with Server

use of com.ibeiliao.deployment.admin.vo.server.Server 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 4 with Server

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

the class CreateDeploymentController method queryModuleServer.

/**
 * 查询模块在某个环境的服务器列表
 *
 * @param moduleId 模块ID
 * @param envId    环境ID,必定大于0
 * @return
 */
@RequestMapping("queryModuleServer")
@ResponseBody
@MenuResource("查询模块服务器列表")
public RestResult<Map<String, Object>> queryModuleServer(int moduleId, int envId) {
    Assert.isTrue(moduleId > 0);
    Assert.isTrue(envId > 0);
    List<ServerGroup> groups = serverGroupService.getByModuleAndEnv(moduleId, envId);
    List<Integer> groupIds = new ArrayList<>(groups.size());
    for (ServerGroup group : groups) {
        groupIds.add(group.getGroupId());
    }
    List<Server> servers = serverService.getByGroupIds(groupIds);
    Map<String, Object> result = new HashMap<>(4);
    result.put("servers", servers);
    result.put("groups", groups);
    return new RestResult<>(result);
}
Also used : ServerGroup(com.ibeiliao.deployment.admin.vo.server.ServerGroup) RestResult(com.ibeiliao.deployment.admin.common.RestResult) Server(com.ibeiliao.deployment.admin.vo.server.Server) MenuResource(com.ibeiliao.deployment.admin.utils.resource.MenuResource) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 5 with Server

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

the class ProjectModuleServiceImpl method insertServerGroupAndServer.

private void insertServerGroupAndServer(List<ServerGroup> groups, int moduleId) {
    if (CollectionUtils.isEmpty(groups)) {
        return;
    }
    List<ServerGroup> needInsertGroups = Lists.newArrayList();
    List<ServerGroup> oldGroups = Lists.newArrayList();
    for (ServerGroup group : groups) {
        group.setModuleId(moduleId);
        if (group.getGroupId() == 0) {
            needInsertGroups.add(group);
        } else {
            oldGroups.add(group);
        }
    }
    List<ServerGroup> serverGroups = serverGroupService.batchInsertGroups(needInsertGroups);
    List<Server> servers = Lists.newArrayList();
    // 新增的group的server
    for (ServerGroup group : serverGroups) {
        List<Server> serverList = group.getServers();
        if (CollectionUtils.isNotEmpty(serverList)) {
            for (Server server : serverList) {
                server.setGroupId(group.getGroupId());
                servers.add(server);
            }
        }
    }
    // 旧的group新增的server
    for (ServerGroup oldGroup : oldGroups) {
        if (CollectionUtils.isNotEmpty(oldGroup.getServers())) {
            for (Server server : oldGroup.getServers()) {
                server.setGroupId(oldGroup.getGroupId());
                if (server.getServerId() == 0) {
                    servers.add(server);
                }
            }
        }
    }
    if (CollectionUtils.isNotEmpty(servers)) {
        serverService.batchInsertServer(servers);
    }
}
Also used : ServerGroup(com.ibeiliao.deployment.admin.vo.server.ServerGroup) Server(com.ibeiliao.deployment.admin.vo.server.Server)

Aggregations

Server (com.ibeiliao.deployment.admin.vo.server.Server)15 ServerGroup (com.ibeiliao.deployment.admin.vo.server.ServerGroup)11 ServerDeployHistoryPO (com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO)3 ProjectModule (com.ibeiliao.deployment.admin.vo.project.ProjectModule)3 DeployHistoryPO (com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO)2 ProjectEnv (com.ibeiliao.deployment.admin.vo.global.ProjectEnv)2 ResinConf (com.ibeiliao.deployment.transfer.vo.ResinConf)2 RestResult (com.ibeiliao.deployment.admin.common.RestResult)1 ModuleConfPO (com.ibeiliao.deployment.admin.po.project.ModuleConfPO)1 ProjectModulePO (com.ibeiliao.deployment.admin.po.project.ProjectModulePO)1 MenuResource (com.ibeiliao.deployment.admin.utils.resource.MenuResource)1 AdminAccount (com.ibeiliao.deployment.admin.vo.account.AdminAccount)1 DeployHistory (com.ibeiliao.deployment.admin.vo.deploy.DeployHistory)1 TransferRequest (com.ibeiliao.deployment.transfer.vo.TransferRequest)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Transactional (org.springframework.transaction.annotation.Transactional)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1