Search in sources :

Example 1 with AzureResourceGroupDto

use of com.sequenceiq.environment.parameter.dto.AzureResourceGroupDto in project cloudbreak by hortonworks.

the class EnvironmentResponseConverter method azureEnvParamsToAzureEnvironmentParams.

private AzureEnvironmentParameters azureEnvParamsToAzureEnvironmentParams(ParametersDto parameters) {
    AzureResourceGroupDto resourceGroupDto = Optional.ofNullable(parameters.getAzureParametersDto()).map(AzureParametersDto::getAzureResourceGroupDto).filter(rgDto -> Objects.nonNull(rgDto.getResourceGroupUsagePattern())).filter(rgDto -> Objects.nonNull(rgDto.getResourceGroupCreation())).orElse(null);
    AzureResourceEncryptionParametersDto resourceEncryptionParametersDto = Optional.ofNullable(parameters.getAzureParametersDto()).map(AzureParametersDto::getAzureResourceEncryptionParametersDto).orElse(null);
    return AzureEnvironmentParameters.builder().withAzureResourceGroup(getIfNotNull(resourceGroupDto, this::azureParametersToAzureResourceGroup)).withResourceEncryptionParameters(getIfNotNull(resourceEncryptionParametersDto, this::azureParametersToAzureResourceEncryptionParameters)).build();
}
Also used : GcpEnvironmentParameters(com.sequenceiq.environment.api.v1.environment.model.request.gcp.GcpEnvironmentParameters) AzureResourceGroupDto(com.sequenceiq.environment.parameter.dto.AzureResourceGroupDto) NullUtil.getIfNotNull(com.sequenceiq.cloudbreak.util.NullUtil.getIfNotNull) GcpResourceEncryptionParametersDto(com.sequenceiq.environment.parameter.dto.GcpResourceEncryptionParametersDto) ResourceGroupUsage(com.sequenceiq.environment.api.v1.environment.model.request.azure.ResourceGroupUsage) EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) LoggerFactory(org.slf4j.LoggerFactory) AzureResourceEncryptionParameters(com.sequenceiq.environment.api.v1.environment.model.request.azure.AzureResourceEncryptionParameters) AuthenticationDto(com.sequenceiq.environment.environment.dto.AuthenticationDto) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) AzureEnvironmentParameters(com.sequenceiq.environment.api.v1.environment.model.request.azure.AzureEnvironmentParameters) GcpResourceEncryptionParameters(com.sequenceiq.environment.api.v1.environment.model.request.gcp.GcpResourceEncryptionParameters) SecurityAccessResponse(com.sequenceiq.environment.api.v1.environment.model.response.SecurityAccessResponse) AwsEnvironmentParameters(com.sequenceiq.environment.api.v1.environment.model.request.aws.AwsEnvironmentParameters) AwsDiskEncryptionParameters(com.sequenceiq.environment.api.v1.environment.model.request.aws.AwsDiskEncryptionParameters) CredentialViewConverter(com.sequenceiq.environment.credential.v1.converter.CredentialViewConverter) ResourceGroupUsagePattern(com.sequenceiq.environment.parameter.dto.ResourceGroupUsagePattern) SimpleEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.SimpleEnvironmentResponse) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) YarnEnvironmentParameters(com.sequenceiq.environment.api.v1.environment.model.request.yarn.YarnEnvironmentParameters) ProxyConfigToProxyResponseConverter(com.sequenceiq.environment.proxy.v1.converter.ProxyConfigToProxyResponseConverter) Tunnel(com.sequenceiq.common.api.type.Tunnel) CredentialToCredentialV1ResponseConverter(com.sequenceiq.environment.credential.v1.converter.CredentialToCredentialV1ResponseConverter) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) AwsDiskEncryptionParametersDto(com.sequenceiq.environment.parameter.dto.AwsDiskEncryptionParametersDto) ParametersDto(com.sequenceiq.environment.parameter.dto.ParametersDto) SecurityGroupSeparator.getSecurityGroupIds(com.sequenceiq.cloudbreak.util.SecurityGroupSeparator.getSecurityGroupIds) AzureResourceGroup(com.sequenceiq.environment.api.v1.environment.model.request.azure.AzureResourceGroup) TagResponse(com.sequenceiq.environment.api.v1.environment.model.response.TagResponse) NullUtil(com.sequenceiq.cloudbreak.util.NullUtil) SecurityAccessDto(com.sequenceiq.environment.environment.dto.SecurityAccessDto) AzureParametersDto(com.sequenceiq.environment.parameter.dto.AzureParametersDto) LocationResponse(com.sequenceiq.environment.api.v1.environment.model.response.LocationResponse) Objects(java.util.Objects) Component(org.springframework.stereotype.Component) EnvironmentAuthenticationResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentAuthenticationResponse) S3GuardRequestParameters(com.sequenceiq.environment.api.v1.environment.model.request.aws.S3GuardRequestParameters) NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) LocationDto(com.sequenceiq.environment.environment.dto.LocationDto) AwsParametersDto(com.sequenceiq.environment.parameter.dto.AwsParametersDto) EnvironmentTags(com.sequenceiq.environment.environment.domain.EnvironmentTags) Optional(java.util.Optional) EnvironmentViewDto(com.sequenceiq.environment.environment.dto.EnvironmentViewDto) AzureResourceEncryptionParametersDto(com.sequenceiq.environment.parameter.dto.AzureResourceEncryptionParametersDto) EnvironmentDeletionType(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentDeletionType) GcpParametersDto(com.sequenceiq.environment.parameter.dto.GcpParametersDto) AzureResourceEncryptionParametersDto(com.sequenceiq.environment.parameter.dto.AzureResourceEncryptionParametersDto) AzureResourceGroupDto(com.sequenceiq.environment.parameter.dto.AzureResourceGroupDto)

Example 2 with AzureResourceGroupDto

use of com.sequenceiq.environment.parameter.dto.AzureResourceGroupDto in project cloudbreak by hortonworks.

the class AzurePrivateEndpointValidator method checkNewPrivateDnsZone.

public void checkNewPrivateDnsZone(ValidationResult.ValidationResultBuilder resultBuilder, EnvironmentDto environmentDto, NetworkDto networkDto) {
    if (networkDto.isPrivateEndpointEnabled(CloudPlatform.AZURE) && ResourceGroupUsagePattern.USE_MULTIPLE != getResourceGroupUsagePattern(environmentDto)) {
        CloudCredential cloudCredential = credentialToCloudCredentialConverter.convert(environmentDto.getCredential());
        AzureClient azureClient = azureClientService.getClient(cloudCredential);
        Optional<String> resourceGroupName = getAzureResourceGroupDto(environmentDto).map(AzureResourceGroupDto::getName);
        resourceGroupName.ifPresent(rgName -> azureNewPrivateDnsZoneValidatorService.zonesNotConnectedToNetwork(azureClient, networkDto.getAzure().getNetworkId(), rgName, azureExistingPrivateDnsZonesService.getServicesWithExistingZones(networkDto), resultBuilder));
    }
}
Also used : AzureClient(com.sequenceiq.cloudbreak.cloud.azure.client.AzureClient) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) AzureResourceGroupDto(com.sequenceiq.environment.parameter.dto.AzureResourceGroupDto)

Example 3 with AzureResourceGroupDto

use of com.sequenceiq.environment.parameter.dto.AzureResourceGroupDto in project cloudbreak by hortonworks.

the class AzureParameterValidator method validate.

@Override
public ValidationResult validate(EnvironmentValidationDto environmentValidationDto, ParametersDto parametersDto, ValidationResultBuilder validationResultBuilder) {
    EnvironmentDto environmentDto = environmentValidationDto.getEnvironmentDto();
    LOGGER.debug("ParametersDto: {}", parametersDto);
    AzureParametersDto azureParametersDto = parametersDto.azureParametersDto();
    if (Objects.isNull(azureParametersDto)) {
        return validationResultBuilder.build();
    }
    ValidationResult validationResult;
    AzureResourceEncryptionParametersDto azureResourceEncryptionParametersDto = azureParametersDto.getAzureResourceEncryptionParametersDto();
    if (azureResourceEncryptionParametersDto != null) {
        validationResult = validateEncryptionParameters(validationResultBuilder, azureParametersDto, environmentDto.getAccountId());
        if (validationResult.hasError()) {
            return validationResult;
        }
    }
    AzureResourceGroupDto azureResourceGroupDto = azureParametersDto.getAzureResourceGroupDto();
    if (Objects.isNull(azureResourceGroupDto)) {
        return validationResultBuilder.build();
    }
    validationResult = validateEntitlement(validationResultBuilder, azureResourceGroupDto, environmentDto.getAccountId());
    if (validationResult.hasError()) {
        return validationResult;
    }
    if (USE_MULTIPLE.equals(azureResourceGroupDto.getResourceGroupUsagePattern())) {
        return validateMultipleResourceGroupUsage(validationResultBuilder, azureResourceGroupDto);
    }
    if (USE_EXISTING.equals(azureResourceGroupDto.getResourceGroupCreation())) {
        return validateExistingResourceGroupUsage(validationResultBuilder, environmentDto, azureResourceGroupDto);
    }
    return validationResultBuilder.build();
}
Also used : AzureResourceEncryptionParametersDto(com.sequenceiq.environment.parameter.dto.AzureResourceEncryptionParametersDto) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) AzureParametersDto(com.sequenceiq.environment.parameter.dto.AzureParametersDto) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) AzureResourceGroupDto(com.sequenceiq.environment.parameter.dto.AzureResourceGroupDto)

Example 4 with AzureResourceGroupDto

use of com.sequenceiq.environment.parameter.dto.AzureResourceGroupDto in project cloudbreak by hortonworks.

the class AzureEnvironmentParametersConverter method postConvert.

@Override
protected void postConvert(BaseParameters baseParameters, Environment environment, ParametersDto parametersDto) {
    super.postConvert(baseParameters, environment, parametersDto);
    AzureParameters azureParameters = (AzureParameters) baseParameters;
    Optional<AzureParametersDto> azureParametersDto = Optional.of(parametersDto).map(ParametersDto::getAzureParametersDto);
    azureParameters.setResourceGroupName(azureParametersDto.map(AzureParametersDto::getAzureResourceGroupDto).map(AzureResourceGroupDto::getName).orElse(null));
    azureParameters.setResourceGroupCreation(azureParametersDto.map(AzureParametersDto::getAzureResourceGroupDto).map(AzureResourceGroupDto::getResourceGroupCreation).orElse(null));
    azureParameters.setResourceGroupUsagePattern(azureParametersDto.map(AzureParametersDto::getAzureResourceGroupDto).map(AzureResourceGroupDto::getResourceGroupUsagePattern).orElse(null));
    azureParameters.setEncryptionKeyUrl(azureParametersDto.map(AzureParametersDto::getAzureResourceEncryptionParametersDto).map(AzureResourceEncryptionParametersDto::getEncryptionKeyUrl).orElse(null));
    azureParameters.setEncryptionKeyResourceGroupName(azureParametersDto.map(AzureParametersDto::getAzureResourceEncryptionParametersDto).map(AzureResourceEncryptionParametersDto::getEncryptionKeyResourceGroupName).orElse(null));
}
Also used : AzureParameters(com.sequenceiq.environment.parameters.dao.domain.AzureParameters) AzureResourceEncryptionParametersDto(com.sequenceiq.environment.parameter.dto.AzureResourceEncryptionParametersDto) ParametersDto(com.sequenceiq.environment.parameter.dto.ParametersDto) AzureResourceEncryptionParametersDto(com.sequenceiq.environment.parameter.dto.AzureResourceEncryptionParametersDto) AzureParametersDto(com.sequenceiq.environment.parameter.dto.AzureParametersDto) AzureParametersDto(com.sequenceiq.environment.parameter.dto.AzureParametersDto) AzureResourceGroupDto(com.sequenceiq.environment.parameter.dto.AzureResourceGroupDto)

Example 5 with AzureResourceGroupDto

use of com.sequenceiq.environment.parameter.dto.AzureResourceGroupDto in project cloudbreak by hortonworks.

the class AzureEnvironmentNetworkValidator method checkPrivateEndpointForExistingNetworkLink.

private void checkPrivateEndpointForExistingNetworkLink(ValidationResultBuilder resultBuilder, EnvironmentDto environmentDto, NetworkDto networkDto) {
    if (networkDto.getServiceEndpointCreation() == ServiceEndpointCreation.ENABLED_PRIVATE_ENDPOINT && ResourceGroupUsagePattern.USE_MULTIPLE != getResourceGroupUsagePattern(environmentDto)) {
        CloudCredential cloudCredential = credentialToCloudCredentialConverter.convert(environmentDto.getCredential());
        AzureClient azureClient = azureClientService.getClient(cloudCredential);
        Optional<String> resourceGroupName = getAzureResourceGroupDto(environmentDto).map(AzureResourceGroupDto::getName);
        resourceGroupName.ifPresent(rgName -> NullUtil.doIfNotNull(azureNetworkLinkService.validateExistingNetworkLink(azureClient, networkDto.getAzure().getNetworkId(), rgName), resultBuilder::merge));
    }
}
Also used : AzureClient(com.sequenceiq.cloudbreak.cloud.azure.client.AzureClient) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) AzureResourceGroupDto(com.sequenceiq.environment.parameter.dto.AzureResourceGroupDto)

Aggregations

AzureResourceGroupDto (com.sequenceiq.environment.parameter.dto.AzureResourceGroupDto)5 AzureParametersDto (com.sequenceiq.environment.parameter.dto.AzureParametersDto)3 AzureResourceEncryptionParametersDto (com.sequenceiq.environment.parameter.dto.AzureResourceEncryptionParametersDto)3 AzureClient (com.sequenceiq.cloudbreak.cloud.azure.client.AzureClient)2 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)2 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)2 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 NullUtil (com.sequenceiq.cloudbreak.util.NullUtil)1 NullUtil.getIfNotNull (com.sequenceiq.cloudbreak.util.NullUtil.getIfNotNull)1 SecurityGroupSeparator.getSecurityGroupIds (com.sequenceiq.cloudbreak.util.SecurityGroupSeparator.getSecurityGroupIds)1 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)1 Tunnel (com.sequenceiq.common.api.type.Tunnel)1 AwsDiskEncryptionParameters (com.sequenceiq.environment.api.v1.environment.model.request.aws.AwsDiskEncryptionParameters)1 AwsEnvironmentParameters (com.sequenceiq.environment.api.v1.environment.model.request.aws.AwsEnvironmentParameters)1 S3GuardRequestParameters (com.sequenceiq.environment.api.v1.environment.model.request.aws.S3GuardRequestParameters)1 AzureEnvironmentParameters (com.sequenceiq.environment.api.v1.environment.model.request.azure.AzureEnvironmentParameters)1 AzureResourceEncryptionParameters (com.sequenceiq.environment.api.v1.environment.model.request.azure.AzureResourceEncryptionParameters)1 AzureResourceGroup (com.sequenceiq.environment.api.v1.environment.model.request.azure.AzureResourceGroup)1 ResourceGroupUsage (com.sequenceiq.environment.api.v1.environment.model.request.azure.ResourceGroupUsage)1 GcpEnvironmentParameters (com.sequenceiq.environment.api.v1.environment.model.request.gcp.GcpEnvironmentParameters)1