Search in sources :

Example 21 with FreeIpa

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

the class FreeIpaDescribeService method getResponseForStack.

private DescribeFreeIpaResponse getResponseForStack(Stack stack, Boolean includeAllInstances) {
    MDCBuilder.buildMdcContext(stack);
    ImageEntity image = imageService.getByStack(stack);
    FreeIpa freeIpa = freeIpaService.findByStackId(stack.getId());
    Optional<UserSyncStatus> userSyncStatus = userSyncStatusService.findByStack(stack);
    return stackToDescribeFreeIpaResponseConverter.convert(stack, image, freeIpa, userSyncStatus, includeAllInstances);
}
Also used : FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) ImageEntity(com.sequenceiq.freeipa.entity.ImageEntity) UserSyncStatus(com.sequenceiq.freeipa.entity.UserSyncStatus)

Example 22 with FreeIpa

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

the class AbstractFreeIpaCleanupAction method createFlowContext.

@Override
protected FreeIpaContext createFlowContext(FlowParameters flowParameters, StateContext<FreeIpaCleanupState, FreeIpaCleanupEvent> stateContext, P payload) {
    FreeIpa freeIpa = freeIpaService.findByStackId(payload.getResourceId());
    MDCBuilder.addOperationId(payload.getOperationId());
    return new FreeIpaContext(flowParameters, freeIpa);
}
Also used : FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa)

Example 23 with FreeIpa

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

the class FreeIpaConfigService method createFreeIpaConfigs.

public FreeIpaConfigView createFreeIpaConfigs(Stack stack, Set<Node> hosts) {
    final FreeIpaConfigView.Builder builder = new FreeIpaConfigView.Builder();
    FreeIpa freeIpa = freeIpaService.findByStack(stack);
    Multimap<String, String> subnetWithCidr = networkService.getFilteredSubnetWithCidr(stack);
    LOGGER.debug("Subnets for reverse zone calculation : {}", subnetWithCidr);
    String reverseZones = reverseDnsZoneCalculator.reverseDnsZoneForCidrs(subnetWithCidr.values());
    LOGGER.debug("Reverse zones : {}", reverseZones);
    return builder.withRealm(freeIpa.getDomain().toUpperCase()).withDomain(freeIpa.getDomain()).withPassword(freeIpa.getAdminPassword()).withDnssecValidationEnabled(isDnsSecValidationEnabled(stack.getCloudPlatform())).withReverseZones(reverseZones).withAdminUser(freeIpaClientFactory.getAdminUser()).withFreeIpaToReplicate(gatewayConfigService.getPrimaryGatewayConfig(stack)).withHosts(hosts).withBackupConfig(determineAndSetBackup(stack)).withCcmv2Enabled(stack.getTunnel().useCcmV2OrJumpgate()).withCidrBlocks(stack.getNetwork().getNetworkCidrs()).withCcmv2JumpgateEnabled(stack.getTunnel().useCcmV2Jumpgate()).build();
}
Also used : FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa)

Example 24 with FreeIpa

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

the class DnsRecordService method createFreeIpaAndClient.

private FreeIpaAndClient createFreeIpaAndClient(String environmentCrn, String accountId) throws FreeIpaClientException {
    Stack stack = stackService.getByEnvironmentCrnAndAccountId(environmentCrn, accountId);
    MDCBuilder.buildMdcContext(stack);
    FreeIpa freeIpa = freeIpaService.findByStack(stack);
    FreeIpaClient freeIpaClient = freeIpaClientFactory.getFreeIpaClientForStack(stack);
    return new FreeIpaAndClient(freeIpa, freeIpaClient);
}
Also used : FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) FreeIpaClient(com.sequenceiq.freeipa.client.FreeIpaClient) Stack(com.sequenceiq.freeipa.entity.Stack)

Example 25 with FreeIpa

use of com.sequenceiq.freeipa.entity.FreeIpa 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)

Aggregations

FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)75 Stack (com.sequenceiq.freeipa.entity.Stack)62 Test (org.junit.jupiter.api.Test)50 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)12 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)11 AddDnsARecordRequest (com.sequenceiq.freeipa.api.v1.dns.model.AddDnsARecordRequest)10 AddDnsCnameRecordRequest (com.sequenceiq.freeipa.api.v1.dns.model.AddDnsCnameRecordRequest)10 FreeIpaClientException (com.sequenceiq.freeipa.client.FreeIpaClientException)10 ImageEntity (com.sequenceiq.freeipa.entity.ImageEntity)10 InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)8 InstanceGroup (com.sequenceiq.freeipa.entity.InstanceGroup)7 JsonRpcClientException (com.googlecode.jsonrpc4j.JsonRpcClientException)6 HttpClientConfig (com.sequenceiq.cloudbreak.client.HttpClientConfig)6 DnsRecord (com.sequenceiq.freeipa.client.model.DnsRecord)6 Set (java.util.Set)6 ClusterServiceConfig (com.sequenceiq.cloudbreak.clusterproxy.ClusterServiceConfig)5 ConfigRegistrationRequest (com.sequenceiq.cloudbreak.clusterproxy.ConfigRegistrationRequest)5 ConfigRegistrationResponse (com.sequenceiq.cloudbreak.clusterproxy.ConfigRegistrationResponse)5 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)5 Optional (java.util.Optional)5