@Override @Transactional public Application start(Application application) throws ServiceException { try { User user = authentificationUtils.getAuthentificatedUser(); logger.debug("start : Methods parameters : " + application); List<Module> modules = application.getModules(); for (Module module : modules) { try { module = moduleService.startModule(module); } catch (ServiceException e) { logger.error("failed to start " + application.toString(), e); } } List<Server> servers = application.getServers(); for (Server server : servers) { logger.info("old server ip : " + server.getContainerIP()); server = serverService.startServer(server); } if (application.getAliases() != null && !application.getAliases().isEmpty()) { updateAliases(application); } logger.info("ApplicationService : Application successfully started "); } catch (PersistenceException e) { throw new ServiceException(e.getLocalizedMessage(), e); } return application; }
@Override @Transactional public Application saveGitPush(Application application, String login) throws ServiceException, CheckException { logger.info("parameters - application : " + application.toString()); deploymentService.create(application, Type.GITPUSH); return application; }
public List<ContainerUnit> listContainers(String applicationName, boolean withModules) throws ServiceException { List<ContainerUnit> containers = new ArrayList<>(); try { Application application = findByNameAndUser(authentificationUtils.getAuthentificatedUser(), applicationName); if (application != null) { try { // Serveurs List<Server> servers = application.getServers(); // Ajout des containers de type server for (Server server : servers) { DockerContainer dockerContainer = new DockerContainer(); dockerContainer.setName(server.getName()); dockerContainer = DockerContainer.findOne(dockerContainer, application.getManagerIp()); server = containerMapper.mapDockerContainerToServer(dockerContainer, server); ContainerUnit containerUnit = new ContainerUnit(server.getName(), server.getContainerID(), "server"); containers.add(containerUnit); } if (withModules) { // Ajout des containers de type module List<Module> modules = application.getModules(); for (Module module : modules) { // on evite de remonter les modules de type toolkit // (git, maven...) if (module.isTool()) { continue; } DockerContainer dockerContainer = new DockerContainer(); dockerContainer.setName(module.getName()); dockerContainer = DockerContainer.findOne(dockerContainer, application.getManagerIp()); module = containerMapper.mapDockerContainerToModule(dockerContainer, module); ContainerUnit containerUnit = new ContainerUnit(module.getName(), module.getContainerID(), "module"); containers.add(containerUnit); } } } catch (Exception ex) { // Si une application sort en erreur, il ne faut pas // arrĂȘter la suite des traitements logger.error(application.toString(), ex); } } } catch (Exception e) { throw new ServiceException(e.getLocalizedMessage(), e); } return containers; }