Search in sources :

Example 6 with InstanceGroupNetworkV1Request

use of com.sequenceiq.distrox.api.v1.distrox.model.network.InstanceGroupNetworkV1Request in project cloudbreak by hortonworks.

the class AwsCloudProvider method instanceGroupNetworkV1Request.

@Override
public InstanceGroupNetworkV1Request instanceGroupNetworkV1Request(SubnetId subnetId) {
    if (awsProperties.getMultiaz()) {
        InstanceGroupNetworkV1Request result = new InstanceGroupNetworkV1Request();
        result.createAws();
        result.getAws().setSubnetIds(subnetId.collectSubnets(new LinkedList<>(awsProperties.getSubnetIds())));
        return result;
    } else {
        return null;
    }
}
Also used : InstanceGroupNetworkV1Request(com.sequenceiq.distrox.api.v1.distrox.model.network.InstanceGroupNetworkV1Request) LinkedList(java.util.LinkedList)

Example 7 with InstanceGroupNetworkV1Request

use of com.sequenceiq.distrox.api.v1.distrox.model.network.InstanceGroupNetworkV1Request in project cloudbreak by hortonworks.

the class DistroXV1RequestToStackV4RequestConverterTest method testGetNetworkWhenAwsIsNullInInstanceGroupsNetwork.

@Test
public void testGetNetworkWhenAwsIsNullInInstanceGroupsNetwork() {
    NetworkV1Request networkRequest = new NetworkV1Request();
    AwsNetworkV1Parameters aws = new AwsNetworkV1Parameters();
    aws.setSubnetId("sub1");
    networkRequest.setAws(aws);
    Set<InstanceGroupV1Request> instanceGroups = new HashSet<>();
    InstanceGroupV1Request ig1 = new InstanceGroupV1Request();
    ig1.setNetwork(new InstanceGroupNetworkV1Request());
    InstanceGroupV1Request ig2 = new InstanceGroupV1Request();
    ig2.setNetwork(new InstanceGroupNetworkV1Request());
    instanceGroups.add(ig1);
    instanceGroups.add(ig2);
    DetailedEnvironmentResponse environment = new DetailedEnvironmentResponse();
    environment.setCloudPlatform("ANY");
    NetworkV4Request networkV4Request = new NetworkV4Request();
    ArgumentCaptor<Pair<NetworkV1Request, DetailedEnvironmentResponse>> networkConverterCaptor = ArgumentCaptor.forClass(Pair.class);
    when(networkConverter.convertToNetworkV4Request(any())).thenReturn(networkV4Request);
    NetworkV4Request actual = underTest.getNetwork(networkRequest, environment, instanceGroups);
    verify(networkConverter).convertToNetworkV4Request(networkConverterCaptor.capture());
    Assertions.assertEquals(networkV4Request, actual);
    Pair<NetworkV1Request, DetailedEnvironmentResponse> captured = networkConverterCaptor.getValue();
    Assertions.assertEquals("sub1", captured.getKey().getAws().getSubnetId());
}
Also used : InstanceGroupV1Request(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.InstanceGroupV1Request) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) InstanceGroupNetworkV1Request(com.sequenceiq.distrox.api.v1.distrox.model.network.InstanceGroupNetworkV1Request) NetworkV1Request(com.sequenceiq.distrox.api.v1.distrox.model.network.NetworkV1Request) InstanceGroupNetworkV1Request(com.sequenceiq.distrox.api.v1.distrox.model.network.InstanceGroupNetworkV1Request) InstanceGroupAwsNetworkV1Parameters(com.sequenceiq.distrox.api.v1.distrox.model.network.aws.InstanceGroupAwsNetworkV1Parameters) AwsNetworkV1Parameters(com.sequenceiq.distrox.api.v1.distrox.model.network.aws.AwsNetworkV1Parameters) HashSet(java.util.HashSet) NetworkV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkV4Request) Pair(org.apache.commons.lang3.tuple.Pair) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 8 with InstanceGroupNetworkV1Request

use of com.sequenceiq.distrox.api.v1.distrox.model.network.InstanceGroupNetworkV1Request in project cloudbreak by hortonworks.

the class DistroXV1RequestToStackV4RequestConverterTest method testGetNetworkWhenHasOneSubnetIdInInstanceGroupsNetworkAws.

@Test
public void testGetNetworkWhenHasOneSubnetIdInInstanceGroupsNetworkAws() {
    NetworkV1Request networkRequest = new NetworkV1Request();
    AwsNetworkV1Parameters aws = new AwsNetworkV1Parameters();
    aws.setSubnetId("sub1");
    networkRequest.setAws(aws);
    Set<InstanceGroupV1Request> instanceGroups = new HashSet<>();
    InstanceGroupV1Request ig1 = new InstanceGroupV1Request();
    InstanceGroupNetworkV1Request network = new InstanceGroupNetworkV1Request();
    InstanceGroupAwsNetworkV1Parameters awsNetworkV1Parameters = new InstanceGroupAwsNetworkV1Parameters();
    awsNetworkV1Parameters.setSubnetIds(List.of("subnet1"));
    network.setAws(awsNetworkV1Parameters);
    ig1.setNetwork(network);
    InstanceGroupV1Request ig2 = new InstanceGroupV1Request();
    InstanceGroupNetworkV1Request network1 = new InstanceGroupNetworkV1Request();
    InstanceGroupAwsNetworkV1Parameters awsNetworkV1Parameters1 = new InstanceGroupAwsNetworkV1Parameters();
    network1.setAws(awsNetworkV1Parameters1);
    ig2.setNetwork(network1);
    instanceGroups.add(ig1);
    instanceGroups.add(ig2);
    DetailedEnvironmentResponse environment = new DetailedEnvironmentResponse();
    environment.setCloudPlatform("ANY");
    NetworkV4Request networkV4Request = new NetworkV4Request();
    ArgumentCaptor<Pair<NetworkV1Request, DetailedEnvironmentResponse>> networkConverterCaptor = ArgumentCaptor.forClass(Pair.class);
    when(networkConverter.convertToNetworkV4Request(any())).thenReturn(networkV4Request);
    NetworkV4Request actual = underTest.getNetwork(networkRequest, environment, instanceGroups);
    verify(networkConverter).convertToNetworkV4Request(networkConverterCaptor.capture());
    Assertions.assertEquals(networkV4Request, actual);
    Pair<NetworkV1Request, DetailedEnvironmentResponse> captured = networkConverterCaptor.getValue();
    Assertions.assertEquals("subnet1", captured.getKey().getAws().getSubnetId());
}
Also used : InstanceGroupV1Request(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.InstanceGroupV1Request) InstanceGroupAwsNetworkV1Parameters(com.sequenceiq.distrox.api.v1.distrox.model.network.aws.InstanceGroupAwsNetworkV1Parameters) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) InstanceGroupNetworkV1Request(com.sequenceiq.distrox.api.v1.distrox.model.network.InstanceGroupNetworkV1Request) NetworkV1Request(com.sequenceiq.distrox.api.v1.distrox.model.network.NetworkV1Request) InstanceGroupNetworkV1Request(com.sequenceiq.distrox.api.v1.distrox.model.network.InstanceGroupNetworkV1Request) InstanceGroupAwsNetworkV1Parameters(com.sequenceiq.distrox.api.v1.distrox.model.network.aws.InstanceGroupAwsNetworkV1Parameters) AwsNetworkV1Parameters(com.sequenceiq.distrox.api.v1.distrox.model.network.aws.AwsNetworkV1Parameters) HashSet(java.util.HashSet) NetworkV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkV4Request) Pair(org.apache.commons.lang3.tuple.Pair) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 9 with InstanceGroupNetworkV1Request

use of com.sequenceiq.distrox.api.v1.distrox.model.network.InstanceGroupNetworkV1Request in project cloudbreak by hortonworks.

the class DistroXV1RequestToStackV4RequestConverterTest method testGetNetworkWhenHasDiffSubnetIdInInstanceGroupsNetworkAws.

@Test
public void testGetNetworkWhenHasDiffSubnetIdInInstanceGroupsNetworkAws() {
    NetworkV1Request networkRequest = new NetworkV1Request();
    AwsNetworkV1Parameters aws = new AwsNetworkV1Parameters();
    aws.setSubnetId("sub1");
    networkRequest.setAws(aws);
    Set<InstanceGroupV1Request> instanceGroups = new HashSet<>();
    InstanceGroupV1Request ig1 = new InstanceGroupV1Request();
    InstanceGroupNetworkV1Request network = new InstanceGroupNetworkV1Request();
    InstanceGroupAwsNetworkV1Parameters awsNetworkV1Parameters = new InstanceGroupAwsNetworkV1Parameters();
    awsNetworkV1Parameters.setSubnetIds(List.of("subnet1"));
    network.setAws(awsNetworkV1Parameters);
    ig1.setNetwork(network);
    InstanceGroupV1Request ig2 = new InstanceGroupV1Request();
    InstanceGroupNetworkV1Request network1 = new InstanceGroupNetworkV1Request();
    InstanceGroupAwsNetworkV1Parameters awsNetworkV1Parameters1 = new InstanceGroupAwsNetworkV1Parameters();
    awsNetworkV1Parameters1.setSubnetIds(List.of("subnet2"));
    network1.setAws(awsNetworkV1Parameters1);
    ig2.setNetwork(network1);
    instanceGroups.add(ig1);
    instanceGroups.add(ig2);
    DetailedEnvironmentResponse environment = new DetailedEnvironmentResponse();
    environment.setCloudPlatform("ANY");
    NetworkV4Request networkV4Request = new NetworkV4Request();
    ArgumentCaptor<Pair<NetworkV1Request, DetailedEnvironmentResponse>> networkConverterCaptor = ArgumentCaptor.forClass(Pair.class);
    when(networkConverter.convertToNetworkV4Request(any())).thenReturn(networkV4Request);
    NetworkV4Request actual = underTest.getNetwork(networkRequest, environment, instanceGroups);
    verify(networkConverter).convertToNetworkV4Request(networkConverterCaptor.capture());
    Assertions.assertEquals(networkV4Request, actual);
    Pair<NetworkV1Request, DetailedEnvironmentResponse> captured = networkConverterCaptor.getValue();
    Assertions.assertEquals("sub1", captured.getKey().getAws().getSubnetId());
}
Also used : InstanceGroupV1Request(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.InstanceGroupV1Request) InstanceGroupAwsNetworkV1Parameters(com.sequenceiq.distrox.api.v1.distrox.model.network.aws.InstanceGroupAwsNetworkV1Parameters) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) InstanceGroupNetworkV1Request(com.sequenceiq.distrox.api.v1.distrox.model.network.InstanceGroupNetworkV1Request) NetworkV1Request(com.sequenceiq.distrox.api.v1.distrox.model.network.NetworkV1Request) InstanceGroupNetworkV1Request(com.sequenceiq.distrox.api.v1.distrox.model.network.InstanceGroupNetworkV1Request) InstanceGroupAwsNetworkV1Parameters(com.sequenceiq.distrox.api.v1.distrox.model.network.aws.InstanceGroupAwsNetworkV1Parameters) AwsNetworkV1Parameters(com.sequenceiq.distrox.api.v1.distrox.model.network.aws.AwsNetworkV1Parameters) HashSet(java.util.HashSet) NetworkV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkV4Request) Pair(org.apache.commons.lang3.tuple.Pair) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 10 with InstanceGroupNetworkV1Request

use of com.sequenceiq.distrox.api.v1.distrox.model.network.InstanceGroupNetworkV1Request in project cloudbreak by hortonworks.

the class GcpCloudProvider method instanceGroupNetworkV1Request.

@Override
public InstanceGroupNetworkV1Request instanceGroupNetworkV1Request(SubnetId subnetId) {
    if (gcpProperties.getMultiaz()) {
        InstanceGroupNetworkV1Request result = new InstanceGroupNetworkV1Request();
        result.createAws();
        result.getGcp().setSubnetIds(subnetId.collectSubnets(gcpProperties.getNetwork().getSubnetIds()));
        return result;
    } else {
        return null;
    }
}
Also used : InstanceGroupNetworkV1Request(com.sequenceiq.distrox.api.v1.distrox.model.network.InstanceGroupNetworkV1Request)

Aggregations

InstanceGroupNetworkV1Request (com.sequenceiq.distrox.api.v1.distrox.model.network.InstanceGroupNetworkV1Request)10 InstanceGroupAwsNetworkV1Parameters (com.sequenceiq.distrox.api.v1.distrox.model.network.aws.InstanceGroupAwsNetworkV1Parameters)7 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)7 NetworkV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkV4Request)5 InstanceGroupV1Request (com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.InstanceGroupV1Request)5 NetworkV1Request (com.sequenceiq.distrox.api.v1.distrox.model.network.NetworkV1Request)5 AwsNetworkV1Parameters (com.sequenceiq.distrox.api.v1.distrox.model.network.aws.AwsNetworkV1Parameters)5 HashSet (java.util.HashSet)5 Pair (org.apache.commons.lang3.tuple.Pair)5 Test (org.junit.jupiter.api.Test)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 InstanceGroupNetworkV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.network.InstanceGroupNetworkV4Request)1 CloudPlatform (com.sequenceiq.cloudbreak.common.mappable.CloudPlatform)1 InstanceGroupAzureNetworkV1Parameters (com.sequenceiq.distrox.api.v1.distrox.model.network.azure.InstanceGroupAzureNetworkV1Parameters)1 InstanceGroupGcpNetworkV1Parameters (com.sequenceiq.distrox.api.v1.distrox.model.network.gcp.InstanceGroupGcpNetworkV1Parameters)1 InstanceGroupMockNetworkV1Parameters (com.sequenceiq.distrox.api.v1.distrox.model.network.mock.InstanceGroupMockNetworkV1Parameters)1 EnvironmentNetworkResponse (com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse)1 EnvironmentClient (com.sequenceiq.it.cloudbreak.EnvironmentClient)1 TestFailException (com.sequenceiq.it.cloudbreak.exception.TestFailException)1 LinkedList (java.util.LinkedList)1