Search in sources :

Example 11 with AzureParameters

use of com.sequenceiq.environment.parameters.dao.domain.AzureParameters in project cloudbreak by hortonworks.

the class ResourceEncryptionInitializationHandler method initializeEncryptionResources.

private void initializeEncryptionResources(EnvironmentDto environmentDto, Environment environment) {
    String environmentName = environment.getName();
    LOGGER.info("Initializing encryption resources for environment \"{}\".", environmentName);
    try {
        CreatedDiskEncryptionSet createdDiskEncryptionSet = environmentEncryptionService.createEncryptionResources(environmentDto);
        LOGGER.info("Created Disk Encryption Set resource for environment \"{}\": {}", environmentName, createdDiskEncryptionSet);
        AzureParameters azureParameters = (AzureParameters) environment.getParameters();
        azureParameters.setDiskEncryptionSetId(createdDiskEncryptionSet.getDiskEncryptionSetId());
        environment.setStatus(EnvironmentStatus.ENVIRONMENT_ENCRYPTION_RESOURCES_INITIALIZED);
        environment.setStatusReason(null);
        environmentService.save(environment);
        LOGGER.info("Finished initializing encryption resources for environment \"{}\".", environmentName);
    } catch (Exception e) {
        LOGGER.error(String.format("Failed to initialize encryption resources for environment \"%s\"", environmentName), e);
        throw new CloudbreakServiceException("Error occurred while initializing encryption resources: " + e.getMessage(), e);
    }
}
Also used : AzureParameters(com.sequenceiq.environment.parameters.dao.domain.AzureParameters) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) CreatedDiskEncryptionSet(com.sequenceiq.cloudbreak.cloud.model.encryption.CreatedDiskEncryptionSet) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)

Example 12 with AzureParameters

use of com.sequenceiq.environment.parameters.dao.domain.AzureParameters in project cloudbreak by hortonworks.

the class ParametersService method updateResourceGroupName.

public void updateResourceGroupName(Environment environment, String resourceGroupName) {
    if (!CloudPlatform.AZURE.name().equals(environment.getCloudPlatform())) {
        return;
    }
    Optional<BaseParameters> baseParametersOptional = baseParametersRepository.findByEnvironmentId(environment.getId());
    if (baseParametersOptional.isEmpty()) {
        return;
    }
    BaseParameters baseParameters = baseParametersOptional.get();
    AzureParameters azureParameters = (AzureParameters) baseParameters;
    azureParameters.setResourceGroupName(resourceGroupName);
    baseParametersRepository.save(baseParameters);
}
Also used : AzureParameters(com.sequenceiq.environment.parameters.dao.domain.AzureParameters) BaseParameters(com.sequenceiq.environment.parameters.dao.domain.BaseParameters)

Example 13 with AzureParameters

use of com.sequenceiq.environment.parameters.dao.domain.AzureParameters 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)

Aggregations

AzureParameters (com.sequenceiq.environment.parameters.dao.domain.AzureParameters)13 Test (org.junit.jupiter.api.Test)7 Environment (com.sequenceiq.environment.environment.domain.Environment)6 CreatedDiskEncryptionSet (com.sequenceiq.cloudbreak.cloud.model.encryption.CreatedDiskEncryptionSet)5 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)4 UpdateAzureResourceEncryptionDto (com.sequenceiq.environment.environment.dto.UpdateAzureResourceEncryptionDto)4 AzureParametersDto (com.sequenceiq.environment.parameter.dto.AzureParametersDto)3 AzureResourceEncryptionParametersDto (com.sequenceiq.environment.parameter.dto.AzureResourceEncryptionParametersDto)3 ParametersDto (com.sequenceiq.environment.parameter.dto.ParametersDto)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 BaseParameters (com.sequenceiq.environment.parameters.dao.domain.BaseParameters)2 BadRequestException (javax.ws.rs.BadRequestException)2 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)1 NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)1 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)1 EnvironmentView (com.sequenceiq.environment.environment.domain.EnvironmentView)1 AzureResourceGroupDto (com.sequenceiq.environment.parameter.dto.AzureResourceGroupDto)1 Headers (reactor.bus.Event.Headers)1