Search in sources :

Example 1 with YarnParams

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

the class YarnEnvironmentNetworkValidatorTest method testValidateDuringFlowWhenLifetimeLessThenZeroInYarnParams.

@Test
void testValidateDuringFlowWhenLifetimeLessThenZeroInYarnParams() {
    YarnParams yarnParams = YarnParams.builder().withQueue("queue").withLifetime(-1).build();
    NetworkDto networkDto = NetworkTestUtils.getNetworkDto(null, null, yarnParams, null, null, 1);
    ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
    EnvironmentDto environmentDto = new EnvironmentDto();
    environmentDto.setNetwork(networkDto);
    EnvironmentValidationDto environmentValidationDto = EnvironmentValidationDto.builder().withEnvironmentDto(environmentDto).build();
    underTest.validateDuringFlow(environmentValidationDto, networkDto, resultBuilder);
    NetworkTestUtils.checkErrorsPresent(resultBuilder, List.of("The 'lifetime' parameter should be non negative for 'YARN' environment specific network!"));
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) YarnParams(com.sequenceiq.environment.network.dto.YarnParams) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) EnvironmentValidationDto(com.sequenceiq.environment.environment.dto.EnvironmentValidationDto) Test(org.junit.jupiter.api.Test)

Example 2 with YarnParams

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

the class NetworkRequestToDtoConverter method convert.

public NetworkDto convert(EnvironmentNetworkRequest network) {
    LOGGER.debug("Converting network request to dto");
    NetworkDto.Builder builder = NetworkDto.builder();
    if (network.getAws() != null) {
        LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "AWS");
        AwsParams awsParams = AwsParams.builder().withVpcId(network.getAws().getVpcId()).build();
        builder.withAws(awsParams);
        builder.withNetworkId(network.getAws().getVpcId());
    }
    if (network.getAzure() != null) {
        LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "Azure");
        AzureParams azureParams = AzureParams.builder().withNetworkId(network.getAzure().getNetworkId()).withNoPublicIp(Boolean.TRUE.equals(network.getAzure().getNoPublicIp())).withResourceGroupName(network.getAzure().getResourceGroupName()).withDatabasePrivateDnsZoneId(network.getAzure().getDatabasePrivateDnsZoneId()).build();
        builder.withAzure(azureParams);
        builder.withNetworkId(network.getAzure().getNetworkId());
    }
    if (network.getGcp() != null) {
        LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "GCP");
        GcpParams gcpParams = GcpParams.builder().withNetworkId(network.getGcp().getNetworkId()).withSharedProjectId(network.getGcp().getSharedProjectId()).withNoFirewallRules(network.getGcp().getNoFirewallRules()).withNoPublicIp(network.getGcp().getNoPublicIp()).build();
        builder.withGcp(gcpParams);
        builder.withNetworkId(network.getGcp().getNetworkId());
    }
    if (network.getYarn() != null) {
        LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "Yarn");
        YarnParams yarnParams = YarnParams.builder().withQueue(network.getYarn().getQueue()).withLifetime(network.getYarn().getLifetime()).build();
        builder.withYarn(yarnParams);
    }
    if (network.getMock() != null) {
        LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "Mock");
        MockParams mockParams = MockParams.builder().withVpcId(network.getMock().getVpcId()).withInternetGatewayId(network.getMock().getInternetGatewayId()).build();
        builder.withMock(mockParams);
        builder.withNetworkId(mockParams.getVpcId());
    }
    if (network.getGcp() != null) {
        LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "Gcp");
        GcpParams gcpParams = GcpParams.builder().withSharedProjectId(network.getGcp().getSharedProjectId()).withNetworkId(network.getGcp().getNetworkId()).withNoFirewallRules(Boolean.TRUE.equals(network.getGcp().getNoFirewallRules())).withNoPublicIp(Boolean.TRUE.equals(network.getGcp().getNoPublicIp())).build();
        builder.withGcp(gcpParams);
        builder.withNetworkId(gcpParams.getNetworkId());
    }
    if (network.getSubnetIds() != null) {
        builder.withSubnetMetas(network.getSubnetIds().stream().collect(Collectors.toMap(id -> id, id -> new CloudSubnet(id, id))));
    }
    if (network.getEndpointGatewaySubnetIds() != null) {
        builder.withEndpointGatewaySubnetMetas(network.getEndpointGatewaySubnetIds().stream().collect(Collectors.toMap(id -> id, id -> new CloudSubnet(id, id))));
    }
    return builder.withNetworkCidr(network.getNetworkCidr()).withNetworkCidrs(getNetworkCidrs(network)).withPrivateSubnetCreation(getPrivateSubnetCreation(network)).withServiceEndpointCreation(getServiceEndpointCreation(network)).withOutboundInternetTraffic(getOutboundInternetTraffic(network)).withUsePublicEndpointAccessGateway(getUsePublicEndpointAccessGateway(network)).withLoadBalancerCreation(getLoadBalancerCreation(network)).build();
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) GcpParams(com.sequenceiq.environment.network.dto.GcpParams) MockParams(com.sequenceiq.environment.network.dto.MockParams) YarnParams(com.sequenceiq.environment.network.dto.YarnParams) AzureParams(com.sequenceiq.environment.network.dto.AzureParams) AwsParams(com.sequenceiq.environment.network.dto.AwsParams) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)

Aggregations

NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)2 YarnParams (com.sequenceiq.environment.network.dto.YarnParams)2 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)1 ValidationResultBuilder (com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder)1 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)1 EnvironmentValidationDto (com.sequenceiq.environment.environment.dto.EnvironmentValidationDto)1 AwsParams (com.sequenceiq.environment.network.dto.AwsParams)1 AzureParams (com.sequenceiq.environment.network.dto.AzureParams)1 GcpParams (com.sequenceiq.environment.network.dto.GcpParams)1 MockParams (com.sequenceiq.environment.network.dto.MockParams)1 Test (org.junit.jupiter.api.Test)1