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();
}
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));
}
}
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();
}
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));
}
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));
}
}
Aggregations