Search in sources :

Example 11 with ServerGroup

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

the class ProjectModuleServiceImpl method checkResinPortOccupy.

@Override
public Map<String, String> checkResinPortOccupy(ProjectModule projectModule) {
    if (projectModule.getModuleType() == ModuleType.SERVICE.getValue() || projectModule.getResinConf() == null) {
        return Collections.emptyMap();
    }
    List<ServerGroup> serverGroups = projectModule.getServerGroups();
    if (CollectionUtils.isEmpty(serverGroups)) {
        return Collections.emptyMap();
    }
    List<Server> allServers = Lists.newArrayList();
    for (ServerGroup group : serverGroups) {
        if (CollectionUtils.isNotEmpty(group.getServers())) {
            allServers.addAll(group.getServers());
        }
    }
    if (CollectionUtils.isEmpty(allServers)) {
        return Collections.emptyMap();
    }
    return buildOccupyInfoMap(projectModule, allServers);
}
Also used : ServerGroup(com.ibeiliao.deployment.admin.vo.server.ServerGroup) Server(com.ibeiliao.deployment.admin.vo.server.Server)

Example 12 with ServerGroup

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

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

the class ModuleServiceTest method fillServerGroupInfo.

private void fillServerGroupInfo(ProjectModule module) {
    ServerGroup group = new ServerGroup();
    group.setGroupId(129);
    group.setModuleId(43);
    group.setCreateTime(new Date());
    group.setEnvId(1);
    group.setGroupName("online01111");
    Server server1 = new Server();
    server1.setServerId(22);
    server1.setGroupId(129);
    server1.setCreateTime(new Date());
    server1.setServerName("server00008888");
    server1.setIp("192.168.0.1");
    Server server2 = new Server();
    server2.setGroupId(129);
    server2.setCreateTime(new Date());
    server2.setServerName("server000099");
    server2.setIp("192.168.0.4");
    group.setServers(Lists.newArrayList(server1, server2));
    module.setServerGroups(Lists.newArrayList(group));
}
Also used : ServerGroup(com.ibeiliao.deployment.admin.vo.server.ServerGroup) Server(com.ibeiliao.deployment.admin.vo.server.Server) Date(java.util.Date)

Example 14 with ServerGroup

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

the class ServerGroupServiceImpl method fillInServer.

private void fillInServer(List<ServerGroup> groups) {
    List<Integer> groupIds = Lists.newArrayList();
    for (ServerGroup group : groups) {
        groupIds.add(group.getGroupId());
    }
    List<Server> servers = serverService.getByGroupIds(groupIds);
    if (CollectionUtils.isEmpty(servers)) {
        return;
    }
    ArrayListMultimap<Integer, Server> groupId2ServersMap = ArrayListMultimap.create();
    for (Server server : servers) {
        groupId2ServersMap.put(server.getGroupId(), server);
    }
    for (ServerGroup group : groups) {
        if (groupId2ServersMap.get(group.getGroupId()) != null) {
            group.setServers(groupId2ServersMap.get(group.getGroupId()));
        }
    }
}
Also used : ServerGroup(com.ibeiliao.deployment.admin.vo.server.ServerGroup) Server(com.ibeiliao.deployment.admin.vo.server.Server)

Aggregations

ServerGroup (com.ibeiliao.deployment.admin.vo.server.ServerGroup)14 Server (com.ibeiliao.deployment.admin.vo.server.Server)11 ProjectModule (com.ibeiliao.deployment.admin.vo.project.ProjectModule)3 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 DeployHistoryPO (com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO)1 ServerDeployHistoryPO (com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO)1 ModuleConfPO (com.ibeiliao.deployment.admin.po.project.ModuleConfPO)1 ProjectModulePO (com.ibeiliao.deployment.admin.po.project.ProjectModulePO)1 ServerPO (com.ibeiliao.deployment.admin.po.server.ServerPO)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 Test (org.junit.Test)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1