Search in sources :

Example 1 with AZURE

use of com.sequenceiq.cloudbreak.common.mappable.CloudPlatform.AZURE in project cloudbreak by hortonworks.

the class LoadBalancerConfigService method setupKnoxTargetGroup.

private Optional<TargetGroup> setupKnoxTargetGroup(Stack stack, boolean dryRun) {
    TargetGroup knoxTargetGroup = null;
    Set<String> knoxGatewayGroupNames = getKnoxGatewayGroups(stack);
    Set<InstanceGroup> knoxGatewayInstanceGroups = stack.getInstanceGroups().stream().filter(ig -> knoxGatewayGroupNames.contains(ig.getGroupName())).collect(Collectors.toSet());
    if (AZURE.equalsIgnoreCase(stack.getCloudPlatform()) && knoxGatewayInstanceGroups.size() > 1) {
        throw new CloudbreakServiceException("For Azure load balancers, Knox must be defined in a single instance group.");
    } else if (!knoxGatewayInstanceGroups.isEmpty()) {
        LOGGER.info("Knox gateway instance found; enabling Knox load balancer configuration.");
        knoxTargetGroup = new TargetGroup();
        knoxTargetGroup.setType(TargetGroupType.KNOX);
        knoxTargetGroup.setInstanceGroups(knoxGatewayInstanceGroups);
        if (!dryRun) {
            LOGGER.debug("Adding target group to Knox gateway instances groups.");
            TargetGroup finalKnoxTargetGroup = knoxTargetGroup;
            knoxGatewayInstanceGroups.forEach(ig -> ig.addTargetGroup(finalKnoxTargetGroup));
        } else {
            LOGGER.debug("Dry run, skipping instance group/target group linkage.");
        }
    }
    return Optional.ofNullable(knoxTargetGroup);
}
Also used : Arrays(java.util.Arrays) EntitlementService(com.sequenceiq.cloudbreak.auth.altus.EntitlementService) LoggerFactory(org.slf4j.LoggerFactory) StringUtils(org.apache.commons.lang3.StringUtils) OozieRoles(com.sequenceiq.cloudbreak.cmtemplate.configproviders.oozie.OozieRoles) ThreadBasedUserCrnProvider(com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider) LoadBalancer(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer) ProviderParameterCalculator(com.sequenceiq.cloudbreak.common.mappable.ProviderParameterCalculator) PublicEndpointAccessGateway(com.sequenceiq.common.api.type.PublicEndpointAccessGateway) Map(java.util.Map) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) SubnetSelector(com.sequenceiq.cloudbreak.converter.v4.environment.network.SubnetSelector) AzureStackV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.stack.AzureStackV4Parameters) LoadBalancerPersistenceService(com.sequenceiq.cloudbreak.service.stack.LoadBalancerPersistenceService) Set(java.util.Set) LoadBalancerSku(com.sequenceiq.common.api.type.LoadBalancerSku) Collectors(java.util.stream.Collectors) KnoxRoles(com.sequenceiq.cloudbreak.cmtemplate.configproviders.knox.KnoxRoles) Json(com.sequenceiq.cloudbreak.common.json.Json) List(java.util.List) Optional(java.util.Optional) GCP(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform.GCP) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor) CLOUDERA_STACK_VERSION_7_2_11(com.sequenceiq.cloudbreak.cmtemplate.CMRepositoryVersionUtil.CLOUDERA_STACK_VERSION_7_2_11) OOZIE_HTTPS_PORT(com.sequenceiq.cloudbreak.cmtemplate.configproviders.oozie.OozieHAConfigProvider.OOZIE_HTTPS_PORT) NetworkConstants(com.sequenceiq.cloudbreak.common.network.NetworkConstants) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) TargetGroupPortPair(com.sequenceiq.cloudbreak.cloud.model.TargetGroupPortPair) TargetGroup(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroup) Network(com.sequenceiq.cloudbreak.domain.Network) EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) CloudPlatform(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform) LoadBalancerType(com.sequenceiq.common.api.type.LoadBalancerType) HashSet(java.util.HashSet) Inject(javax.inject.Inject) Value(org.springframework.beans.factory.annotation.Value) AWS(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform.AWS) Service(org.springframework.stereotype.Service) CMRepositoryVersionUtil.isVersionNewerOrEqualThanLimited(com.sequenceiq.cloudbreak.cmtemplate.CMRepositoryVersionUtil.isVersionNewerOrEqualThanLimited) NetworkV4Base(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.NetworkV4Base) Map.entry(java.util.Map.entry) AzureInstanceGroupParameters(com.sequenceiq.cloudbreak.cloud.model.instance.AzureInstanceGroupParameters) LoadBalancerCreation(com.sequenceiq.common.api.type.LoadBalancerCreation) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) Logger(org.slf4j.Logger) AvailabilitySetNameService(com.sequenceiq.cloudbreak.cloud.model.instance.AvailabilitySetNameService) TargetGroupType(com.sequenceiq.common.api.type.TargetGroupType) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) StackType(com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType) Preconditions(com.google.common.base.Preconditions) AZURE(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform.AZURE) Collections(java.util.Collections) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) TargetGroup(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroup) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)

Example 2 with AZURE

use of com.sequenceiq.cloudbreak.common.mappable.CloudPlatform.AZURE in project cloudbreak by hortonworks.

the class EnvironmentCreationService method validateEncryptionKey.

private ValidationResult validateEncryptionKey(EnvironmentCreationDto creationDto) {
    ValidationResultBuilder resultBuilder = ValidationResult.builder();
    String cloudPlatform = creationDto.getCloudPlatform().toLowerCase(Locale.ROOT);
    switch(cloudPlatform) {
        case "azure":
            String encryptionKeyUrl = Optional.ofNullable(creationDto.getParameters()).map(paramsDto -> paramsDto.getAzureParametersDto()).map(azureParamsDto -> azureParamsDto.getAzureResourceEncryptionParametersDto()).map(azureREParamsDto -> azureREParamsDto.getEncryptionKeyUrl()).orElse(null);
            if (encryptionKeyUrl != null) {
                resultBuilder.merge(validatorService.validateEncryptionKeyUrl(encryptionKeyUrl, creationDto.getAccountId()));
            }
            break;
        case "gcp":
            String encryptionKey = Optional.ofNullable(creationDto.getParameters()).map(parametersDto -> parametersDto.getGcpParametersDto()).map(gcpParametersDto -> gcpParametersDto.getGcpResourceEncryptionParametersDto()).map(gcpREParamsDto -> gcpREParamsDto.getEncryptionKey()).orElse(null);
            if (encryptionKey != null) {
                resultBuilder.merge(validatorService.validateEncryptionKey(encryptionKey, creationDto.getAccountId()));
            }
            break;
        case "aws":
            String encryptionKeyArn = Optional.ofNullable(creationDto.getParameters()).map(paramsDto -> paramsDto.getAwsParametersDto()).map(awsParamsDto -> awsParamsDto.getAwsDiskEncryptionParametersDto()).map(awsREparamsDto -> awsREparamsDto.getEncryptionKeyArn()).orElse(null);
            if (encryptionKeyArn != null) {
                resultBuilder.merge(validatorService.validateEncryptionKeyArn(encryptionKeyArn, creationDto.getAccountId()));
            }
            break;
        default:
            break;
    }
    return resultBuilder.build();
}
Also used : EnvironmentDtoConverter(com.sequenceiq.environment.environment.dto.EnvironmentDtoConverter) Environment(com.sequenceiq.environment.environment.domain.Environment) NullUtil.getIfNotNull(com.sequenceiq.cloudbreak.util.NullUtil.getIfNotNull) EntitlementService(com.sequenceiq.cloudbreak.auth.altus.EntitlementService) AuthenticationDtoConverter(com.sequenceiq.environment.environment.dto.AuthenticationDtoConverter) Credential(com.sequenceiq.environment.credential.domain.Credential) LoggerFactory(org.slf4j.LoggerFactory) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) EnvironmentTelemetry(com.sequenceiq.environment.environment.dto.telemetry.EnvironmentTelemetry) LoadBalancerEntitlementService(com.sequenceiq.environment.network.service.LoadBalancerEntitlementService) StringUtils(org.apache.commons.lang3.StringUtils) Value(org.springframework.beans.factory.annotation.Value) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) Locale(java.util.Locale) Service(org.springframework.stereotype.Service) PublicEndpointAccessGateway(com.sequenceiq.common.api.type.PublicEndpointAccessGateway) BadRequestException(javax.ws.rs.BadRequestException) ParametersService(com.sequenceiq.environment.parameters.service.ParametersService) ExperimentalFeatures(com.sequenceiq.environment.environment.domain.ExperimentalFeatures) EnvironmentStatus(com.sequenceiq.environment.environment.EnvironmentStatus) Tunnel(com.sequenceiq.common.api.type.Tunnel) Logger(org.slf4j.Logger) EnvironmentCreationDto(com.sequenceiq.environment.environment.dto.EnvironmentCreationDto) ParametersDto(com.sequenceiq.environment.parameter.dto.ParametersDto) Crn(com.sequenceiq.cloudbreak.auth.crn.Crn) EnvironmentValidatorService(com.sequenceiq.environment.environment.validation.EnvironmentValidatorService) NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) Optional(java.util.Optional) GCP(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform.GCP) AZURE(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform.AZURE) ProxyConfig(com.sequenceiq.environment.proxy.domain.ProxyConfig) EnvironmentReactorFlowManager(com.sequenceiq.environment.environment.flow.EnvironmentReactorFlowManager) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder)

Aggregations

EntitlementService (com.sequenceiq.cloudbreak.auth.altus.EntitlementService)2 AZURE (com.sequenceiq.cloudbreak.common.mappable.CloudPlatform.AZURE)2 GCP (com.sequenceiq.cloudbreak.common.mappable.CloudPlatform.GCP)2 PublicEndpointAccessGateway (com.sequenceiq.common.api.type.PublicEndpointAccessGateway)2 Preconditions (com.google.common.base.Preconditions)1 StackType (com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType)1 NetworkV4Base (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.NetworkV4Base)1 AzureStackV4Parameters (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.stack.AzureStackV4Parameters)1 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)1 ThreadBasedUserCrnProvider (com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider)1 Crn (com.sequenceiq.cloudbreak.auth.crn.Crn)1 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)1 TargetGroupPortPair (com.sequenceiq.cloudbreak.cloud.model.TargetGroupPortPair)1 AvailabilitySetNameService (com.sequenceiq.cloudbreak.cloud.model.instance.AvailabilitySetNameService)1 AzureInstanceGroupParameters (com.sequenceiq.cloudbreak.cloud.model.instance.AzureInstanceGroupParameters)1 CLOUDERA_STACK_VERSION_7_2_11 (com.sequenceiq.cloudbreak.cmtemplate.CMRepositoryVersionUtil.CLOUDERA_STACK_VERSION_7_2_11)1 CMRepositoryVersionUtil.isVersionNewerOrEqualThanLimited (com.sequenceiq.cloudbreak.cmtemplate.CMRepositoryVersionUtil.isVersionNewerOrEqualThanLimited)1 CmTemplateProcessor (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)1 KnoxRoles (com.sequenceiq.cloudbreak.cmtemplate.configproviders.knox.KnoxRoles)1 OOZIE_HTTPS_PORT (com.sequenceiq.cloudbreak.cmtemplate.configproviders.oozie.OozieHAConfigProvider.OOZIE_HTTPS_PORT)1