Search in sources :

Example 1 with FreeIpaCreationDto

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

the class EnvironmentDetailsToCDPFreeIPADetailsConverter method convert.

public UsageProto.CDPFreeIPADetails convert(EnvironmentDetails environmentDetails) {
    UsageProto.CDPFreeIPADetails.Builder cdpFreeIPADetails = UsageProto.CDPFreeIPADetails.newBuilder();
    cdpFreeIPADetails.setNodes(DEFAULT_INTEGER_VALUE);
    if (environmentDetails != null) {
        FreeIpaCreationDto freeIpaCreationDto = environmentDetails.getFreeIpaCreation();
        if (freeIpaCreationDto != null) {
            cdpFreeIPADetails.setNodes(freeIpaCreationDto.getInstanceCountByGroup());
            cdpFreeIPADetails.setMultiAz(freeIpaCreationDto.isEnableMultiAz());
            FreeIpaCreationAwsParametersDto aws = freeIpaCreationDto.getAws();
            if (aws != null) {
                FreeIpaCreationAwsSpotParametersDto spot = aws.getSpot();
                if (spot != null && spot.getPercentage() != null) {
                    cdpFreeIPADetails.setSpot(spot.getPercentage() > 0);
                }
            }
        }
    }
    UsageProto.CDPFreeIPADetails ret = cdpFreeIPADetails.build();
    LOGGER.debug("Converted CDPFreeIPADetails: {}", ret);
    return ret;
}
Also used : FreeIpaCreationDto(com.sequenceiq.environment.environment.dto.FreeIpaCreationDto) FreeIpaCreationAwsSpotParametersDto(com.sequenceiq.environment.environment.dto.FreeIpaCreationAwsSpotParametersDto) FreeIpaCreationAwsParametersDto(com.sequenceiq.environment.environment.dto.FreeIpaCreationAwsParametersDto) UsageProto(com.cloudera.thunderhead.service.common.usage.UsageProto)

Example 2 with FreeIpaCreationDto

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

the class EnvironmentApiConverterTest method testAzureSingleRgEnabledAndEmptyAzureRequest.

@Test
void testAzureSingleRgEnabledAndEmptyAzureRequest() {
    EnvironmentRequest request = createEnvironmentRequest(AZURE);
    request.setAzure(null);
    FreeIpaCreationDto freeIpaCreationDto = mock(FreeIpaCreationDto.class);
    EnvironmentTelemetry environmentTelemetry = mock(EnvironmentTelemetry.class);
    AccountTelemetry accountTelemetry = mock(AccountTelemetry.class);
    Features features = mock(Features.class);
    NetworkDto networkDto = mock(NetworkDto.class);
    when(credentialService.getCloudPlatformByCredential(anyString(), anyString(), any())).thenReturn(AZURE.name());
    when(freeIpaConverter.convert(request.getFreeIpa(), "id", CloudConstants.AWS)).thenReturn(freeIpaCreationDto);
    when(accountTelemetry.getFeatures()).thenReturn(features);
    when(accountTelemetryService.getOrDefault(any())).thenReturn(accountTelemetry);
    when(telemetryApiConverter.convert(eq(request.getTelemetry()), any(), anyString())).thenReturn(environmentTelemetry);
    when(tunnelConverter.convert(request.getTunnel())).thenReturn(request.getTunnel());
    when(networkRequestToDtoConverter.convert(request.getNetwork())).thenReturn(networkDto);
    EnvironmentCreationDto actual = testInitCreationDto(request);
    assertEquals(ResourceGroupUsagePattern.USE_MULTIPLE, actual.getParameters().getAzureParametersDto().getAzureResourceGroupDto().getResourceGroupUsagePattern());
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) EnvironmentTelemetry(com.sequenceiq.environment.environment.dto.telemetry.EnvironmentTelemetry) FreeIpaCreationDto(com.sequenceiq.environment.environment.dto.FreeIpaCreationDto) AccountTelemetry(com.sequenceiq.environment.telemetry.domain.AccountTelemetry) EnvironmentRequest(com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentRequest) Features(com.sequenceiq.common.api.telemetry.model.Features) ExperimentalFeatures(com.sequenceiq.environment.environment.domain.ExperimentalFeatures) EnvironmentCreationDto(com.sequenceiq.environment.environment.dto.EnvironmentCreationDto) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with FreeIpaCreationDto

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

the class FreeIpaConverterTest method testConvertWithInstanceType.

@Test
public void testConvertWithInstanceType() {
    // GIVEN
    AttachedFreeIpaRequest request = new AttachedFreeIpaRequest();
    request.setCreate(true);
    request.setInstanceType(INSTANCE_TYPE);
    // WHEN
    FreeIpaCreationDto result = underTest.convert(request, "id", CloudConstants.AWS);
    // THEN
    assertNotNull(result.getInstanceType());
    assertEquals(INSTANCE_TYPE, result.getInstanceType());
}
Also used : AttachedFreeIpaRequest(com.sequenceiq.environment.api.v1.environment.model.request.AttachedFreeIpaRequest) FreeIpaCreationDto(com.sequenceiq.environment.environment.dto.FreeIpaCreationDto) Test(org.junit.jupiter.api.Test)

Example 4 with FreeIpaCreationDto

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

the class FreeIpaConverterTest method testConvertWithFreeIpaImageCatalogButWithoutImageId.

@Test
public void testConvertWithFreeIpaImageCatalogButWithoutImageId() {
    // GIVEN
    FreeIpaCreationDto request = FreeIpaCreationDto.builder().withImageCatalog(IMAGE_CATALOG).build();
    // WHEN
    FreeIpaResponse result = underTest.convert(request);
    // THEN
    assertNull(result.getImage());
}
Also used : FreeIpaCreationDto(com.sequenceiq.environment.environment.dto.FreeIpaCreationDto) FreeIpaResponse(com.sequenceiq.environment.api.v1.environment.model.response.FreeIpaResponse) Test(org.junit.jupiter.api.Test)

Example 5 with FreeIpaCreationDto

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

the class FreeIpaConverterTest method testConvertWithoutImage.

@Test
public void testConvertWithoutImage() {
    // GIVEN
    AttachedFreeIpaRequest request = new AttachedFreeIpaRequest();
    request.setCreate(true);
    request.setImage(null);
    // WHEN
    FreeIpaCreationDto result = underTest.convert(request, "id", CloudConstants.AWS);
    // THEN
    assertNull(result.getImageCatalog());
    assertNull(result.getImageId());
}
Also used : AttachedFreeIpaRequest(com.sequenceiq.environment.api.v1.environment.model.request.AttachedFreeIpaRequest) FreeIpaCreationDto(com.sequenceiq.environment.environment.dto.FreeIpaCreationDto) Test(org.junit.jupiter.api.Test)

Aggregations

FreeIpaCreationDto (com.sequenceiq.environment.environment.dto.FreeIpaCreationDto)21 Test (org.junit.jupiter.api.Test)16 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)8 Features (com.sequenceiq.common.api.telemetry.model.Features)7 EnvironmentRequest (com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentRequest)7 ExperimentalFeatures (com.sequenceiq.environment.environment.domain.ExperimentalFeatures)7 EnvironmentCreationDto (com.sequenceiq.environment.environment.dto.EnvironmentCreationDto)7 EnvironmentTelemetry (com.sequenceiq.environment.environment.dto.telemetry.EnvironmentTelemetry)7 NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)7 AccountTelemetry (com.sequenceiq.environment.telemetry.domain.AccountTelemetry)7 FreeIpaResponse (com.sequenceiq.environment.api.v1.environment.model.response.FreeIpaResponse)6 AttachedFreeIpaRequest (com.sequenceiq.environment.api.v1.environment.model.request.AttachedFreeIpaRequest)4 EnvironmentBackup (com.sequenceiq.environment.environment.dto.EnvironmentBackup)4 UsageProto (com.cloudera.thunderhead.service.common.usage.UsageProto)1 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)1 FreeIpaImageRequest (com.sequenceiq.environment.api.v1.environment.model.request.FreeIpaImageRequest)1 FreeIpaCreationAwsParametersDto (com.sequenceiq.environment.environment.dto.FreeIpaCreationAwsParametersDto)1 FreeIpaCreationAwsSpotParametersDto (com.sequenceiq.environment.environment.dto.FreeIpaCreationAwsSpotParametersDto)1 InstanceGroupNetworkRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupNetworkRequest)1