Search in sources :

Example 41 with NetworkDto

use of com.sequenceiq.environment.network.dto.NetworkDto 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)

Example 42 with NetworkDto

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

the class EnvironmentNetworkProviderValidator method validate.

public ValidationResult validate(EnvironmentValidationDto environmentValidationDto) {
    EnvironmentDto environmentDto = environmentValidationDto.getEnvironmentDto();
    NetworkDto network = environmentDto.getNetwork();
    String cloudPlatform = environmentDto.getCloudPlatform();
    ValidationResultBuilder resultBuilder = ValidationResult.builder();
    validateNetworkHasTheSamePropertyFilledAsTheDesiredCloudPlatform(network, cloudPlatform, resultBuilder);
    validateNetwork(network, cloudPlatform, resultBuilder, environmentValidationDto);
    validateSecurityGroup(environmentValidationDto, cloudPlatform, resultBuilder);
    return resultBuilder.build();
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder)

Example 43 with NetworkDto

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

the class FreeIpaAwsNetworkProvider method network.

@Override
public NetworkRequest network(EnvironmentDto environment, boolean multiAzRequired) {
    NetworkDto network = environment.getNetwork();
    NetworkRequest networkRequest = new NetworkRequest();
    AwsParams awsParams = network.getAws();
    AwsNetworkParameters awsNetworkParameters = new AwsNetworkParameters();
    networkRequest.setNetworkCidrs(collectNetworkCidrs(network));
    networkRequest.setOutboundInternetTraffic(network.getOutboundInternetTraffic());
    awsNetworkParameters.setVpcId(awsParams.getVpcId());
    if (!multiAzRequired) {
        ProvidedSubnetIds providedSubnetIds = subnetIdProvider.subnets(environment.getNetwork(), environment.getExperimentalFeatures().getTunnel(), CloudPlatform.AWS, multiAzRequired);
        awsNetworkParameters.setSubnetId(providedSubnetIds.getSubnetId());
    }
    networkRequest.setAws(awsNetworkParameters);
    return networkRequest;
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) ProvidedSubnetIds(com.sequenceiq.environment.network.service.domain.ProvidedSubnetIds) InstanceGroupNetworkRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupNetworkRequest) NetworkRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest) AwsNetworkParameters(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.AwsNetworkParameters) InstanceGroupAwsNetworkParameters(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.aws.InstanceGroupAwsNetworkParameters) AwsParams(com.sequenceiq.environment.network.dto.AwsParams)

Example 44 with NetworkDto

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

the class FreeIpaAzureNetworkProvider method network.

@Override
public NetworkRequest network(EnvironmentDto environment, boolean multiAzRequired) {
    NetworkRequest networkRequest = new NetworkRequest();
    NetworkDto network = environment.getNetwork();
    AzureParams azureParams = network.getAzure();
    AzureNetworkParameters azureNetworkParameters = new AzureNetworkParameters();
    azureNetworkParameters.setNetworkId(azureParams.getNetworkId());
    azureNetworkParameters.setNoPublicIp(azureParams.isNoPublicIp());
    azureNetworkParameters.setResourceGroupName(azureParams.getResourceGroupName());
    ProvidedSubnetIds providedSubnetIds = subnetIdProvider.subnets(network, environment.getExperimentalFeatures().getTunnel(), CloudPlatform.AZURE, multiAzRequired);
    azureNetworkParameters.setSubnetId(providedSubnetIds.getSubnetId());
    networkRequest.setAzure(azureNetworkParameters);
    networkRequest.setNetworkCidrs(collectNetworkCidrs(network));
    return networkRequest;
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) ProvidedSubnetIds(com.sequenceiq.environment.network.service.domain.ProvidedSubnetIds) AzureNetworkParameters(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.AzureNetworkParameters) AzureParams(com.sequenceiq.environment.network.dto.AzureParams) NetworkRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest)

Example 45 with NetworkDto

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

the class FreeIpaGcpNetworkProvider method network.

@Override
public NetworkRequest network(EnvironmentDto environment, boolean multiAzRequired) {
    NetworkRequest networkRequest = new NetworkRequest();
    NetworkDto network = environment.getNetwork();
    GcpParams gcpParams = network.getGcp();
    GcpNetworkParameters gcpNetworkParameters = new GcpNetworkParameters();
    gcpNetworkParameters.setNetworkId(gcpParams.getNetworkId());
    gcpNetworkParameters.setNoFirewallRules(gcpParams.getNoFirewallRules());
    gcpNetworkParameters.setNoPublicIp(gcpParams.getNoPublicIp());
    gcpNetworkParameters.setSharedProjectId(gcpParams.getSharedProjectId());
    gcpNetworkParameters.setSubnetId(network.getSubnetIds().iterator().next());
    networkRequest.setGcp(gcpNetworkParameters);
    networkRequest.setNetworkCidrs(collectNetworkCidrs(network));
    return networkRequest;
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) GcpParams(com.sequenceiq.environment.network.dto.GcpParams) NetworkRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest) GcpNetworkParameters(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.GcpNetworkParameters)

Aggregations

NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)144 Test (org.junit.jupiter.api.Test)124 ValidationResultBuilder (com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder)59 AzureParams (com.sequenceiq.environment.network.dto.AzureParams)40 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)31 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)27 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)21 EnvironmentValidationDto (com.sequenceiq.environment.environment.dto.EnvironmentValidationDto)21 UsageProto (com.cloudera.thunderhead.service.common.usage.UsageProto)15 Environment (com.sequenceiq.environment.environment.domain.Environment)15 ProvidedSubnetIds (com.sequenceiq.environment.network.service.domain.ProvidedSubnetIds)14 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)13 AwsNetwork (com.sequenceiq.environment.network.dao.domain.AwsNetwork)12 EnvironmentTelemetry (com.sequenceiq.environment.environment.dto.telemetry.EnvironmentTelemetry)10 AwsParams (com.sequenceiq.environment.network.dto.AwsParams)9 Features (com.sequenceiq.common.api.telemetry.model.Features)8 CloudPlatform (com.sequenceiq.cloudbreak.common.mappable.CloudPlatform)7 EnvironmentRequest (com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentRequest)7 ExperimentalFeatures (com.sequenceiq.environment.environment.domain.ExperimentalFeatures)7 BaseNetwork (com.sequenceiq.environment.network.dao.domain.BaseNetwork)7