Search in sources :

Example 16 with BaseNetwork

use of com.sequenceiq.environment.network.dao.domain.BaseNetwork in project cloudbreak by hortonworks.

the class EnvironmentResourceServiceTest method createAndSetNetwork.

@Test
void createAndSetNetwork() {
    Environment environment = new Environment();
    NetworkDto networkDto = null;
    BaseNetwork network = new AwsNetwork();
    when(networkService.saveNetwork(eq(environment), eq(networkDto), eq(ACCOUNT_ID), any(), any())).thenReturn(network);
    assertEquals(network, environmentResourceServiceUnderTest.createAndSetNetwork(environment, networkDto, ACCOUNT_ID, Map.of(), Map.of()));
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) BaseNetwork(com.sequenceiq.environment.network.dao.domain.BaseNetwork) AwsNetwork(com.sequenceiq.environment.network.dao.domain.AwsNetwork) Environment(com.sequenceiq.environment.environment.domain.Environment) Test(org.junit.jupiter.api.Test)

Example 17 with BaseNetwork

use of com.sequenceiq.environment.network.dao.domain.BaseNetwork in project cloudbreak by hortonworks.

the class AzureEnvironmentNetworkConverter method convertToNetwork.

@Override
public Network convertToNetwork(BaseNetwork baseNetwork) {
    AzureNetwork azureNetwork = (AzureNetwork) baseNetwork;
    Map<String, Object> param = new HashMap<>();
    param.put(RG_NAME, azureNetwork.getResourceGroupName());
    param.put(NETWORK_ID, azureNetwork.getNetworkId());
    param.put(DATABASE_PRIVATE_DS_ZONE_ID, azureNetwork.getDatabasePrivateDnsZoneId());
    return new Network(null, param);
}
Also used : HashMap(java.util.HashMap) CreatedCloudNetwork(com.sequenceiq.cloudbreak.cloud.model.network.CreatedCloudNetwork) BaseNetwork(com.sequenceiq.environment.network.dao.domain.BaseNetwork) Network(com.sequenceiq.cloudbreak.cloud.model.Network) AzureNetwork(com.sequenceiq.environment.network.dao.domain.AzureNetwork) AzureNetwork(com.sequenceiq.environment.network.dao.domain.AzureNetwork)

Example 18 with BaseNetwork

use of com.sequenceiq.environment.network.dao.domain.BaseNetwork in project cloudbreak by hortonworks.

the class EnvironmentBaseNetworkConverter method convert.

@Override
public BaseNetwork convert(Environment environment, NetworkDto creationDto, Map<String, CloudSubnet> subnetMetas, Map<String, CloudSubnet> gatewayEndpointSubnetMetas) {
    BaseNetwork result = createProviderSpecificNetwork(creationDto);
    result.setName(creationDto.getNetworkName() != null ? creationDto.getNetworkName() : environment.getName());
    result.setNetworkCidr(creationDto.getNetworkCidr());
    result.setNetworkCidrs(StringUtils.join(creationDto.getNetworkCidrs(), ","));
    result.setEnvironments(convertEnvToView(environment));
    result.setPrivateSubnetCreation(creationDto.getPrivateSubnetCreation());
    result.setServiceEndpointCreation(creationDto.getServiceEndpointCreation());
    result.setOutboundInternetTraffic(creationDto.getOutboundInternetTraffic());
    setRegistrationType(result, creationDto);
    result.setSubnetMetas(subnetMetas);
    result.setPublicEndpointAccessGateway(creationDto.getPublicEndpointAccessGateway());
    result.setLoadBalancerCreation(creationDto.getLoadBalancerCreation());
    result.setEndpointGatewaySubnetMetas(gatewayEndpointSubnetMetas);
    return result;
}
Also used : BaseNetwork(com.sequenceiq.environment.network.dao.domain.BaseNetwork)

Example 19 with BaseNetwork

use of com.sequenceiq.environment.network.dao.domain.BaseNetwork in project cloudbreak by hortonworks.

the class NetworkService method saveNetwork.

public BaseNetwork saveNetwork(Environment environment, NetworkDto networkDto, String accountId, Map<String, CloudSubnet> subnetMetas, Map<String, CloudSubnet> endpointGatewaySubnetMetas) {
    BaseNetwork baseNetwork = null;
    if (networkDto != null) {
        EnvironmentNetworkConverter environmentNetworkConverter = environmentNetworkConverterMap.get(getCloudPlatform(environment));
        if (environmentNetworkConverter != null) {
            baseNetwork = environmentNetworkConverter.convert(environment, networkDto, subnetMetas, endpointGatewaySubnetMetas);
            baseNetwork.setId(getIfNotNull(networkDto, NetworkDto::getId));
            baseNetwork.setResourceCrn(createCRN(accountId));
            baseNetwork.setAccountId(accountId);
            baseNetwork = save(baseNetwork);
        }
    }
    return baseNetwork;
}
Also used : BaseNetwork(com.sequenceiq.environment.network.dao.domain.BaseNetwork) EnvironmentNetworkConverter(com.sequenceiq.environment.network.v1.converter.EnvironmentNetworkConverter)

Aggregations

BaseNetwork (com.sequenceiq.environment.network.dao.domain.BaseNetwork)19 AwsNetwork (com.sequenceiq.environment.network.dao.domain.AwsNetwork)9 Network (com.sequenceiq.cloudbreak.cloud.model.Network)8 Test (org.junit.jupiter.api.Test)8 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)7 Environment (com.sequenceiq.environment.environment.domain.Environment)6 NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)6 CreatedCloudNetwork (com.sequenceiq.cloudbreak.cloud.model.network.CreatedCloudNetwork)5 GcpNetwork (com.sequenceiq.environment.network.dao.domain.GcpNetwork)5 EnvironmentNetworkConverter (com.sequenceiq.environment.network.v1.converter.EnvironmentNetworkConverter)5 NetworkCidr (com.sequenceiq.cloudbreak.cloud.network.NetworkCidr)4 Credential (com.sequenceiq.environment.credential.domain.Credential)4 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)4 CloudPlatform (com.sequenceiq.cloudbreak.common.mappable.CloudPlatform)3 EnvironmentEditDto (com.sequenceiq.environment.environment.dto.EnvironmentEditDto)3 HashMap (java.util.HashMap)3 CloudPlatformVariant (com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)2 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)2 NetworkResourcesCreationRequest (com.sequenceiq.cloudbreak.cloud.model.network.NetworkResourcesCreationRequest)2 AuthenticationDto (com.sequenceiq.environment.environment.dto.AuthenticationDto)2