Search in sources :

Example 1 with GcpParams

use of com.sequenceiq.environment.network.dto.GcpParams 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 2 with GcpParams

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

Example 3 with GcpParams

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

the class GcpEnvironmentNetworkConverter method createProviderSpecificNetwork.

@Override
BaseNetwork createProviderSpecificNetwork(NetworkDto network) {
    GcpNetwork gcpNetwork = new GcpNetwork();
    GcpParams gcpParams = network.getGcp();
    if (gcpParams != null) {
        gcpNetwork.setNetworkId(gcpParams.getNetworkId());
        gcpNetwork.setNoFirewallRules(gcpParams.getNoFirewallRules());
        gcpNetwork.setNoPublicIp(gcpParams.getNoPublicIp());
        gcpNetwork.setSharedProjectId(gcpParams.getSharedProjectId());
    }
    return gcpNetwork;
}
Also used : GcpParams(com.sequenceiq.environment.network.dto.GcpParams) GcpNetwork(com.sequenceiq.environment.network.dao.domain.GcpNetwork)

Example 4 with GcpParams

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

the class GcpEnvironmentNetworkValidator method validateDuringRequest.

@Override
public void validateDuringRequest(NetworkDto networkDto, ValidationResult.ValidationResultBuilder resultBuilder) {
    if (networkDto == null) {
        return;
    }
    if (StringUtils.isEmpty(networkDto.getNetworkCidr()) && StringUtils.isEmpty(networkDto.getNetworkId())) {
        String message = "Either the GCP network id or cidr needs to be defined!";
        LOGGER.info(message);
        resultBuilder.error(message);
    }
    GcpParams gcpParams = networkDto.getGcp();
    if (gcpParams != null) {
        checkSubnetsProvidedWhenExistingNetwork(resultBuilder, gcpParams, networkDto.getSubnetMetas());
        checkExistingNetworkParamsProvidedWhenSubnetsPresent(networkDto, resultBuilder);
        checkNetworkIdIsSpecifiedWhenSubnetIdsArePresent(resultBuilder, gcpParams, networkDto);
    } else if (StringUtils.isEmpty(networkDto.getNetworkCidr())) {
        resultBuilder.error(missingParamsErrorMsg(GCP));
    }
}
Also used : GcpParams(com.sequenceiq.environment.network.dto.GcpParams)

Aggregations

GcpParams (com.sequenceiq.environment.network.dto.GcpParams)4 NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)2 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)1 GcpNetwork (com.sequenceiq.environment.network.dao.domain.GcpNetwork)1 AwsParams (com.sequenceiq.environment.network.dto.AwsParams)1 AzureParams (com.sequenceiq.environment.network.dto.AzureParams)1 MockParams (com.sequenceiq.environment.network.dto.MockParams)1 YarnParams (com.sequenceiq.environment.network.dto.YarnParams)1 GcpNetworkParameters (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.GcpNetworkParameters)1 NetworkRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest)1