Search in sources :

Example 1 with ProvidedSubnetIds

use of com.sequenceiq.environment.network.service.domain.ProvidedSubnetIds in project cloudbreak by hortonworks.

the class NetworkDtoToResponseConverterTest method testConvertWithAwsParams.

@Test
void testConvertWithAwsParams() {
    NetworkDto network = createNetworkDto().withAws(createAwsParams()).build();
    ProvidedSubnetIds providedSubnetIds = new ProvidedSubnetIds(PREFERRED_SUBNET_ID, Set.of(PREFERRED_SUBNET_ID));
    when(subnetIdProvider.subnets(network, TUNNEL, network.getCloudPlatform(), true)).thenReturn(providedSubnetIds);
    EnvironmentNetworkResponse actual = underTest.convert(network, TUNNEL, true);
    assertCommonFields(network, actual);
    assertEquals(network.getAws().getVpcId(), actual.getAws().getVpcId());
    assertNull(actual.getAzure());
    assertNull(actual.getYarn());
    assertNull(actual.getMock());
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) ProvidedSubnetIds(com.sequenceiq.environment.network.service.domain.ProvidedSubnetIds) EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) Test(org.junit.jupiter.api.Test)

Example 2 with ProvidedSubnetIds

use of com.sequenceiq.environment.network.service.domain.ProvidedSubnetIds in project cloudbreak by hortonworks.

the class NetworkDtoToResponseConverterTest method testConvertWithYarnParams.

@Test
void testConvertWithYarnParams() {
    NetworkDto network = createNetworkDto().withYarn(createYarnParams()).build();
    ProvidedSubnetIds providedSubnetIds = new ProvidedSubnetIds(PREFERRED_SUBNET_ID, Set.of(PREFERRED_SUBNET_ID));
    when(subnetIdProvider.subnets(network, TUNNEL, network.getCloudPlatform(), true)).thenReturn(providedSubnetIds);
    EnvironmentNetworkResponse actual = underTest.convert(network, TUNNEL, true);
    assertCommonFields(network, actual);
    assertEquals(network.getYarn().getQueue(), actual.getYarn().getQueue());
    assertEquals(network.getYarn().getLifetime(), actual.getYarn().getLifetime());
    assertNull(actual.getAws());
    assertNull(actual.getMock());
    assertNull(actual.getAzure());
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) ProvidedSubnetIds(com.sequenceiq.environment.network.service.domain.ProvidedSubnetIds) EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) Test(org.junit.jupiter.api.Test)

Example 3 with ProvidedSubnetIds

use of com.sequenceiq.environment.network.service.domain.ProvidedSubnetIds in project cloudbreak by hortonworks.

the class NetworkDtoToResponseConverterTest method testConvertWithLoadBalancerEnabled.

@Test
void testConvertWithLoadBalancerEnabled() {
    NetworkDto network = createNetworkDto().withAws(createAwsParams()).withLoadBalancerCreation(LoadBalancerCreation.ENABLED).build();
    ProvidedSubnetIds providedSubnetIds = new ProvidedSubnetIds(PREFERRED_SUBNET_ID, Set.of(PREFERRED_SUBNET_ID));
    when(subnetIdProvider.subnets(network, TUNNEL, network.getCloudPlatform(), true)).thenReturn(providedSubnetIds);
    EnvironmentNetworkResponse actual = underTest.convert(network, TUNNEL, true);
    assertEquals(network.getAws().getVpcId(), actual.getAws().getVpcId());
    assertEquals(LoadBalancerCreation.ENABLED, actual.getLoadBalancerCreation());
    assertNull(actual.getAzure());
    assertNull(actual.getYarn());
    assertNull(actual.getMock());
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) ProvidedSubnetIds(com.sequenceiq.environment.network.service.domain.ProvidedSubnetIds) EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) Test(org.junit.jupiter.api.Test)

Example 4 with ProvidedSubnetIds

use of com.sequenceiq.environment.network.service.domain.ProvidedSubnetIds 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 5 with ProvidedSubnetIds

use of com.sequenceiq.environment.network.service.domain.ProvidedSubnetIds in project cloudbreak by hortonworks.

the class FreeIpaAwsNetworkProvider method networkByGroup.

@Override
public InstanceGroupNetworkRequest networkByGroup(EnvironmentDto environment) {
    InstanceGroupNetworkRequest instanceGroupNetworkRequest = new InstanceGroupNetworkRequest();
    ProvidedSubnetIds providedSubnetIds = subnetIdProvider.subnets(environment.getNetwork(), environment.getExperimentalFeatures().getTunnel(), CloudPlatform.AWS, true);
    InstanceGroupAwsNetworkParameters instanceGroupAwsNetworkParameters = new InstanceGroupAwsNetworkParameters();
    instanceGroupAwsNetworkParameters.setSubnetIds(new ArrayList<>(providedSubnetIds.getSubnetIds()));
    instanceGroupNetworkRequest.setAws(instanceGroupAwsNetworkParameters);
    return instanceGroupNetworkRequest;
}
Also used : InstanceGroupNetworkRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupNetworkRequest) ProvidedSubnetIds(com.sequenceiq.environment.network.service.domain.ProvidedSubnetIds) InstanceGroupAwsNetworkParameters(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.aws.InstanceGroupAwsNetworkParameters)

Aggregations

ProvidedSubnetIds (com.sequenceiq.environment.network.service.domain.ProvidedSubnetIds)17 NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)14 Test (org.junit.jupiter.api.Test)12 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)6 EnvironmentNetworkResponse (com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse)5 NetworkRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest)3 NetworkConnector (com.sequenceiq.cloudbreak.cloud.NetworkConnector)2 SubnetSelectionParameters (com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionParameters)2 InstanceGroupNetworkRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupNetworkRequest)2 InstanceGroupAwsNetworkParameters (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.aws.InstanceGroupAwsNetworkParameters)2 CloudPlatformVariant (com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)1 SubnetSelectionResult (com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionResult)1 Tunnel (com.sequenceiq.common.api.type.Tunnel)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 AwsNetworkParameters (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.AwsNetworkParameters)1 AzureNetworkParameters (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.AzureNetworkParameters)1 MockNetworkParameters (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.MockNetworkParameters)1