Search in sources :

Example 41 with InstanceMetaData

use of com.sequenceiq.freeipa.entity.InstanceMetaData in project cloudbreak by hortonworks.

the class FreeIpaScalingService method upscale.

public UpscaleResponse upscale(String accountId, UpscaleRequest request) {
    Stack stack = stackService.getByEnvironmentCrnAndAccountIdWithListsAndMdcContext(request.getEnvironmentCrn(), accountId);
    Set<InstanceMetaData> allInstances = stack.getNotDeletedInstanceMetaDataSet();
    AvailabilityType originalAvailabilityType = AvailabilityType.getByInstanceCount(allInstances.size());
    logRequest(OperationType.UPSCALE, request, originalAvailabilityType);
    validationService.validateStackForUpscale(allInstances, stack, new ScalingPath(originalAvailabilityType, request.getTargetAvailabilityType()));
    return triggerUpscale(request, stack, originalAvailabilityType);
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) ScalingPath(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.scale.ScalingPath) AvailabilityType(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.AvailabilityType) Stack(com.sequenceiq.freeipa.entity.Stack)

Example 42 with InstanceMetaData

use of com.sequenceiq.freeipa.entity.InstanceMetaData in project cloudbreak by hortonworks.

the class FreeIpaInstallService method installFreeIpa.

public void installFreeIpa(Long stackId) throws CloudbreakOrchestratorException {
    Stack stack = stackService.getByIdWithListsInTransaction(stackId);
    Set<InstanceMetaData> instanceMetaDatas = stack.getNotDeletedInstanceMetaDataSet();
    List<GatewayConfig> gatewayConfigs = gatewayConfigService.getGatewayConfigs(stack, instanceMetaDatas);
    Set<Node> allNodes = freeIpaNodeUtilService.mapInstancesToNodes(instanceMetaDatas);
    installFreeIpa(stackId, stack, gatewayConfigs, allNodes);
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) Stack(com.sequenceiq.freeipa.entity.Stack) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Example 43 with InstanceMetaData

use of com.sequenceiq.freeipa.entity.InstanceMetaData in project cloudbreak by hortonworks.

the class FreeIpaOrchestrationConfigService method configureOrchestrator.

public void configureOrchestrator(Long stackId) throws CloudbreakOrchestratorException {
    Stack stack = stackService.getByIdWithListsInTransaction(stackId);
    Set<InstanceMetaData> instanceMetaDatas = stack.getNotDeletedInstanceMetaDataSet();
    List<GatewayConfig> gatewayConfigs = gatewayConfigService.getGatewayConfigs(stack, instanceMetaDatas);
    Set<Node> allNodes = freeIpaNodeUtilService.mapInstancesToNodes(instanceMetaDatas);
    SaltConfig saltConfig = saltConfigProvider.getSaltConfig(stack, allNodes);
    hostOrchestrator.initSaltConfig(stack, gatewayConfigs, allNodes, saltConfig, new StackBasedExitCriteriaModel(stackId));
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) StackBasedExitCriteriaModel(com.sequenceiq.freeipa.orchestrator.StackBasedExitCriteriaModel) SaltConfig(com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig) Stack(com.sequenceiq.freeipa.entity.Stack) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Example 44 with InstanceMetaData

use of com.sequenceiq.freeipa.entity.InstanceMetaData in project cloudbreak by hortonworks.

the class FreeIpaClientFactory method getFreeIpaClient.

private FreeIpaClient getFreeIpaClient(Stack stack, boolean withPing, boolean forceCheckUnreachable, Optional<String> freeIpaFqdn) throws FreeIpaClientException {
    stack = stackService.getByIdWithListsInTransaction(stack.getId());
    Status stackStatus = stack.getStackStatus().getStatus();
    if (forceCheckUnreachable || !stackStatus.isFreeIpaUnreachableStatus()) {
        try {
            Optional<FreeIpaClient> client = Optional.empty();
            if (clusterProxyService.isCreateConfigForClusterProxy(stack)) {
                return getFreeIpaClientBuilderForClusterProxy(stack, freeIpaFqdn).build(withPing);
            } else {
                List<InstanceMetaData> instanceMetaDatas = getPriorityOrderedFreeIpaInstances(stack, forceCheckUnreachable).stream().filter(instanceMetaData -> freeIpaFqdn.isEmpty() || freeIpaFqdn.get().equals(instanceMetaData.getDiscoveryFQDN())).collect(Collectors.toList());
                for (Iterator<InstanceMetaData> instanceIterator = instanceMetaDatas.iterator(); instanceIterator.hasNext() && client.isEmpty(); ) {
                    InstanceMetaData instanceMetaData = instanceIterator.next();
                    client = getFreeIpaClientForDirectConnect(stack, instanceMetaData, withPing, !instanceIterator.hasNext());
                }
            }
            return client.orElseThrow(() -> new FreeIpaHostNotAvailableException("No FreeIPA client was available"));
        } catch (RetryableFreeIpaClientException e) {
            throw createFreeIpaUnableToBuildClient(e);
        } catch (Exception e) {
            throw createFreeIpaUnableToBuildClient(e);
        }
    } else {
        throw createFreeIpaStateIsInvalidException(stackStatus);
    }
}
Also used : Status(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.Status) HttpStatus(org.springframework.http.HttpStatus) InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) FreeIpaDomainUtils(com.sequenceiq.freeipa.service.config.FreeIpaDomainUtils) FreeIpaClientBuilder(com.sequenceiq.freeipa.client.FreeIpaClientBuilder) LoggerFactory(org.slf4j.LoggerFactory) MDCBuilder(com.sequenceiq.cloudbreak.logger.MDCBuilder) HashMap(java.util.HashMap) Supplier(java.util.function.Supplier) ClusterProxyConfiguration(com.sequenceiq.cloudbreak.clusterproxy.ClusterProxyConfiguration) Inject(javax.inject.Inject) RetryableFreeIpaClientException(com.sequenceiq.freeipa.client.RetryableFreeIpaClientException) Service(org.springframework.stereotype.Service) Map(java.util.Map) FreeIpaHostNotAvailableException(com.sequenceiq.freeipa.client.FreeIpaHostNotAvailableException) StackService(com.sequenceiq.freeipa.service.stack.StackService) ServiceFamilies(com.sequenceiq.cloudbreak.ccm.endpoint.ServiceFamilies) Status(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.Status) InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) Stack(com.sequenceiq.freeipa.entity.Stack) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) Tracer(io.opentracing.Tracer) FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) ClusterProxyService(com.sequenceiq.freeipa.service.stack.ClusterProxyService) FreeIpaClientException(com.sequenceiq.freeipa.client.FreeIpaClientException) HttpClientConfig(com.sequenceiq.cloudbreak.client.HttpClientConfig) ClusterProxyServiceAvailabilityChecker(com.sequenceiq.freeipa.util.ClusterProxyServiceAvailabilityChecker) FreeIpaClient(com.sequenceiq.freeipa.client.FreeIpaClient) Collectors(java.util.stream.Collectors) HttpStatus(org.springframework.http.HttpStatus) List(java.util.List) ClusterProxyErrorRpcListener(com.sequenceiq.freeipa.client.ClusterProxyErrorRpcListener) Optional(java.util.Optional) TlsSecurityService(com.sequenceiq.freeipa.service.TlsSecurityService) InvalidFreeIpaStateException(com.sequenceiq.freeipa.client.InvalidFreeIpaStateException) RequestListener(com.googlecode.jsonrpc4j.JsonRpcClient.RequestListener) RetryableFreeIpaClientException(com.sequenceiq.freeipa.client.RetryableFreeIpaClientException) FreeIpaHostNotAvailableException(com.sequenceiq.freeipa.client.FreeIpaHostNotAvailableException) FreeIpaClient(com.sequenceiq.freeipa.client.FreeIpaClient) RetryableFreeIpaClientException(com.sequenceiq.freeipa.client.RetryableFreeIpaClientException) FreeIpaHostNotAvailableException(com.sequenceiq.freeipa.client.FreeIpaHostNotAvailableException) FreeIpaClientException(com.sequenceiq.freeipa.client.FreeIpaClientException) InvalidFreeIpaStateException(com.sequenceiq.freeipa.client.InvalidFreeIpaStateException)

Example 45 with InstanceMetaData

use of com.sequenceiq.freeipa.entity.InstanceMetaData in project cloudbreak by hortonworks.

the class KerberosConfigRegisterService method addAddressForLegacy.

/**
 * old FreeIPA instance doesn't have kerberos CNAME so we have to create the config differently
 */
private void addAddressForLegacy(Stack stack, KerberosConfig kerberosConfig, Set<InstanceMetaData> allNotDeletedInstances) {
    InstanceMetaData master = getMasterInstance(stack);
    kerberosConfig.setAdminUrl(master.getDiscoveryFQDN());
    String allNotDeletedIpaInstanceFQDNJoined = allNotDeletedInstances.stream().map(InstanceMetaData::getDiscoveryFQDN).collect(Collectors.joining(","));
    kerberosConfig.setUrl(allNotDeletedIpaInstanceFQDNJoined);
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData)

Aggregations

InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)163 Stack (com.sequenceiq.freeipa.entity.Stack)104 Test (org.junit.jupiter.api.Test)77 InstanceGroup (com.sequenceiq.freeipa.entity.InstanceGroup)30 List (java.util.List)19 Logger (org.slf4j.Logger)19 LoggerFactory (org.slf4j.LoggerFactory)19 Map (java.util.Map)18 Collectors (java.util.stream.Collectors)18 Inject (javax.inject.Inject)18 Set (java.util.Set)16 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)13 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)13 Node (com.sequenceiq.cloudbreak.common.orchestration.Node)12 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)11 StackService (com.sequenceiq.freeipa.service.stack.StackService)10 ArrayList (java.util.ArrayList)10 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)9 HealthDetailsFreeIpaResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.health.HealthDetailsFreeIpaResponse)9 Operation (com.sequenceiq.freeipa.entity.Operation)9