Search in sources :

Example 21 with KerberosConfig

use of com.sequenceiq.cloudbreak.domain.KerberosConfig in project cloudbreak by hortonworks.

the class AmbariClusterService method recreate.

@Override
public Cluster recreate(Long stackId, Long blueprintId, Set<HostGroup> hostGroups, boolean validateBlueprint, StackRepoDetails stackRepoDetails, String kerberosPassword, String kerberosPrincipal) {
    if (blueprintId == null || hostGroups == null) {
        throw new BadRequestException("Blueprint id and hostGroup assignments can not be null.");
    }
    Stack stack = stackService.getByIdWithLists(stackId);
    Cluster cluster = getCluster(stack);
    if (cluster != null && stack.getCluster().isSecure()) {
        List<String> missing = Stream.of(Pair.of("password", kerberosPassword), Pair.of("principal", kerberosPrincipal)).filter(p -> !StringUtils.hasLength(p.getRight())).map(Pair::getLeft).collect(Collectors.toList());
        if (!missing.isEmpty()) {
            throw new BadRequestException(String.format("Missing Kerberos credential detail(s): %s", String.join(", ", missing)));
        }
        KerberosConfig kerberosConfig = cluster.getKerberosConfig();
        kerberosConfig.setPassword(kerberosPassword);
        kerberosConfig.setPrincipal(kerberosPrincipal);
        kerberosConfigRepository.save(kerberosConfig);
    }
    Blueprint blueprint = blueprintService.get(blueprintId);
    if (!withEmbeddedAmbariDB(cluster)) {
        throw new BadRequestException("Ambari doesn't support resetting external DB automatically. To reset Ambari Server schema you must first drop " + "and then create it using DDL scripts from /var/lib/ambari-server/resources");
    }
    if (validateBlueprint) {
        blueprintValidator.validateBlueprintForStack(cluster, blueprint, hostGroups, stack.getInstanceGroups());
    }
    Boolean containerOrchestrator;
    try {
        containerOrchestrator = orchestratorTypeResolver.resolveType(stack.getOrchestrator()).containerOrchestrator();
    } catch (CloudbreakException ignored) {
        containerOrchestrator = false;
    }
    if (containerOrchestrator) {
        clusterTerminationService.deleteClusterComponents(cluster.getId());
        cluster = clusterRepository.findById(stack.getCluster().getId());
    }
    hostGroups = hostGroupService.saveOrUpdateWithMetadata(hostGroups, cluster);
    cluster = prepareCluster(hostGroups, stackRepoDetails, blueprint, stack, cluster);
    try {
        triggerClusterInstall(stack, cluster);
    } catch (CloudbreakException e) {
        throw new CloudbreakServiceException(e);
    }
    return stack.getCluster();
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) CloudbreakServiceException(com.sequenceiq.cloudbreak.service.CloudbreakServiceException) KerberosConfig(com.sequenceiq.cloudbreak.domain.KerberosConfig) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Aggregations

KerberosConfig (com.sequenceiq.cloudbreak.domain.KerberosConfig)21 Test (org.junit.Test)10 KerberosRequest (com.sequenceiq.cloudbreak.api.model.KerberosRequest)5 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)5 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)5 AbstractConverterTest (com.sequenceiq.cloudbreak.converter.AbstractConverterTest)4 Stack (com.sequenceiq.cloudbreak.domain.Stack)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 BlueprintPreparationObject (com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject)2 BlueprintTextProcessor (com.sequenceiq.cloudbreak.blueprint.BlueprintTextProcessor)2 GeneralClusterConfigs (com.sequenceiq.cloudbreak.blueprint.templates.GeneralClusterConfigs)2 FileSystem (com.sequenceiq.cloudbreak.domain.FileSystem)2 RDSConfig (com.sequenceiq.cloudbreak.domain.RDSConfig)2 CloudbreakServiceException (com.sequenceiq.cloudbreak.service.CloudbreakServiceException)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 BlueprintInputJson (com.sequenceiq.cloudbreak.api.model.BlueprintInputJson)1 BlueprintResponse (com.sequenceiq.cloudbreak.api.model.BlueprintResponse)1 FileSystemBase (com.sequenceiq.cloudbreak.api.model.FileSystemBase)1 FileSystemRequest (com.sequenceiq.cloudbreak.api.model.FileSystemRequest)1 GatewayJson (com.sequenceiq.cloudbreak.api.model.GatewayJson)1