Search in sources :

Example 1 with AwsNetworkV4Parameters

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.network.AwsNetworkV4Parameters in project cloudbreak by hortonworks.

the class NetworkV4BaseTest method testIsEmptyShouldReturnFalseForEditedInstance.

@Test
void testIsEmptyShouldReturnFalseForEditedInstance() {
    underTest.setAws(new AwsNetworkV4Parameters());
    assertFalse(underTest.isEmpty());
}
Also used : AwsNetworkV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.network.AwsNetworkV4Parameters) Test(org.junit.jupiter.api.Test)

Example 2 with AwsNetworkV4Parameters

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.network.AwsNetworkV4Parameters in project cloudbreak by hortonworks.

the class NetworkV1ToNetworkV4Converter method convertToAwsStackRequest.

private AwsNetworkV4Parameters convertToAwsStackRequest(Pair<AwsNetworkV1Parameters, EnvironmentNetworkResponse> source) {
    EnvironmentNetworkResponse value = source.getValue();
    AwsNetworkV1Parameters key = source.getKey();
    AwsNetworkV4Parameters response = new AwsNetworkV4Parameters();
    if (key != null) {
        response.setVpcId(value.getAws().getVpcId());
        String subnetId = key.getSubnetId();
        if (!Strings.isNullOrEmpty(subnetId)) {
            response.setSubnetId(key.getSubnetId());
        } else if (value != null) {
            response.setSubnetId(value.getPreferedSubnetId());
        }
        if (PublicEndpointAccessGateway.ENABLED.equals(value.getPublicEndpointAccessGateway())) {
            ValidationResult validationResult = endpointGatewayNetworkValidator.validate(new ImmutablePair<>(response.getSubnetId(), value));
            if (validationResult.getState() == ValidationResult.State.ERROR || validationResult.hasError()) {
                throw new BadRequestException("Endpoint gateway subnet validation failed: " + validationResult.getFormattedErrors());
            }
            Optional<CloudSubnet> endpointGatewaySubnet = subnetSelector.chooseSubnetForEndpointGateway(value, response.getSubnetId());
            if (endpointGatewaySubnet.isPresent()) {
                response.setEndpointGatewaySubnetId(endpointGatewaySubnet.get().getId());
            }
        }
    }
    return response;
}
Also used : EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) AwsNetworkV1Parameters(com.sequenceiq.distrox.api.v1.distrox.model.network.aws.AwsNetworkV1Parameters) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) AwsNetworkV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.network.AwsNetworkV4Parameters)

Example 3 with AwsNetworkV4Parameters

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.network.AwsNetworkV4Parameters in project cloudbreak by hortonworks.

the class DistroXV1RequestToStackV4RequestConverterTest method createAwsNetworkV4Parameters.

private AwsNetworkV4Parameters createAwsNetworkV4Parameters() {
    AwsNetworkV4Parameters awsNetwork = new AwsNetworkV4Parameters();
    awsNetwork.setSubnetId("mysubnetid");
    awsNetwork.setVpcId("myvpc");
    return awsNetwork;
}
Also used : AwsNetworkV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.network.AwsNetworkV4Parameters)

Example 4 with AwsNetworkV4Parameters

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.network.AwsNetworkV4Parameters in project cloudbreak by hortonworks.

the class TestUtil method awsNetworkV4Parameters.

public static AwsNetworkV4Parameters awsNetworkV4Parameters() {
    AwsNetworkV4Parameters p = new AwsNetworkV4Parameters();
    p.setSubnetId("someAwsSubnet");
    p.setVpcId("someAwsVpc");
    p.setInternetGatewayId("someAwsInternetGatewayId");
    return p;
}
Also used : AwsNetworkV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.network.AwsNetworkV4Parameters)

Example 5 with AwsNetworkV4Parameters

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.network.AwsNetworkV4Parameters in project cloudbreak by hortonworks.

the class TestUtil method networkV4RequestForAws.

public static NetworkV4Request networkV4RequestForAws() {
    NetworkV4Request r = new NetworkV4Request();
    r.setAws(awsNetworkV4Parameters());
    r.setCloudPlatform(CloudPlatform.AWS);
    r.setSubnetCIDR("0.0.0.0/0");
    return r;
}
Also used : NetworkV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkV4Request)

Aggregations

AwsNetworkV4Parameters (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.network.AwsNetworkV4Parameters)10 NetworkV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkV4Request)4 Test (org.junit.Test)2 Test (org.junit.jupiter.api.Test)2 InstanceGroupAwsNetworkV4Parameters (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.instancegroup.network.aws.InstanceGroupAwsNetworkV4Parameters)1 InstanceGroupNetworkV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.network.InstanceGroupNetworkV4Request)1 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)1 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)1 AwsNetworkV1Parameters (com.sequenceiq.distrox.api.v1.distrox.model.network.aws.AwsNetworkV1Parameters)1 EnvironmentNetworkResponse (com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse)1