Search in sources :

Example 1 with InstanceGroupMockNetworkV1Parameters

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

the class InstanceGroupV1ToInstanceGroupV4Converter method getInstanceGroupNetworkV1RequestByProvider.

private InstanceGroupNetworkV1Request getInstanceGroupNetworkV1RequestByProvider(NetworkV4Request distroxNetwork, DetailedEnvironmentResponse environment) {
    InstanceGroupNetworkV1Request request = null;
    switch(environment.getCloudPlatform()) {
        case "AWS":
            if (distroxNetwork.getAws() != null) {
                request = new InstanceGroupNetworkV1Request();
                InstanceGroupAwsNetworkV1Parameters aws = new InstanceGroupAwsNetworkV1Parameters();
                aws.setSubnetIds(getSubnetIds(distroxNetwork.getAws().getSubnetId()));
                request.setAws(aws);
            }
            break;
        case "AZURE":
            if (distroxNetwork.getAzure() != null) {
                request = new InstanceGroupNetworkV1Request();
                InstanceGroupAzureNetworkV1Parameters azure = new InstanceGroupAzureNetworkV1Parameters();
                azure.setSubnetIds(getSubnetIds(distroxNetwork.getAzure().getSubnetId()));
                request.setAzure(azure);
            }
            break;
        case "MOCK":
            if (distroxNetwork.getMock() != null) {
                request = new InstanceGroupNetworkV1Request();
                InstanceGroupMockNetworkV1Parameters mock = new InstanceGroupMockNetworkV1Parameters();
                mock.setSubnetIds(getSubnetIds(distroxNetwork.getMock().getSubnetId()));
                request.setMock(mock);
            }
            break;
        case "GCP":
            if (distroxNetwork.getGcp() != null) {
                request = new InstanceGroupNetworkV1Request();
                InstanceGroupGcpNetworkV1Parameters gcp = new InstanceGroupGcpNetworkV1Parameters();
                gcp.setSubnetIds(getSubnetIds(distroxNetwork.getGcp().getSubnetId()));
                request.setGcp(gcp);
            }
            break;
        default:
    }
    return request;
}
Also used : InstanceGroupAwsNetworkV1Parameters(com.sequenceiq.distrox.api.v1.distrox.model.network.aws.InstanceGroupAwsNetworkV1Parameters) InstanceGroupGcpNetworkV1Parameters(com.sequenceiq.distrox.api.v1.distrox.model.network.gcp.InstanceGroupGcpNetworkV1Parameters) InstanceGroupAzureNetworkV1Parameters(com.sequenceiq.distrox.api.v1.distrox.model.network.azure.InstanceGroupAzureNetworkV1Parameters) InstanceGroupNetworkV1Request(com.sequenceiq.distrox.api.v1.distrox.model.network.InstanceGroupNetworkV1Request) InstanceGroupMockNetworkV1Parameters(com.sequenceiq.distrox.api.v1.distrox.model.network.mock.InstanceGroupMockNetworkV1Parameters)

Example 2 with InstanceGroupMockNetworkV1Parameters

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

the class InstanceGroupV1ToInstanceGroupV4Converter method hasMockSubnets.

private boolean hasMockSubnets(InstanceGroupV1Request instanceGroupV1Request) {
    boolean instanceGroupRequestHasSubnet = false;
    InstanceGroupMockNetworkV1Parameters mock = instanceGroupV1Request.getNetwork().getMock();
    if (mock != null) {
        instanceGroupRequestHasSubnet = isNotEmptyOrNull(mock.getSubnetIds());
    }
    return instanceGroupRequestHasSubnet;
}
Also used : InstanceGroupMockNetworkV1Parameters(com.sequenceiq.distrox.api.v1.distrox.model.network.mock.InstanceGroupMockNetworkV1Parameters)

Example 3 with InstanceGroupMockNetworkV1Parameters

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

the class InstanceGroupNetworkParameterConverter method convertToMockNetworkParams.

private InstanceGroupMockNetworkV4Parameters convertToMockNetworkParams(Pair<InstanceGroupMockNetworkV1Parameters, EnvironmentNetworkResponse> source) {
    EnvironmentNetworkResponse value = source.getValue();
    InstanceGroupMockNetworkV1Parameters key = source.getKey();
    InstanceGroupMockNetworkV4Parameters params = new InstanceGroupMockNetworkV4Parameters();
    if (key != null) {
        List<String> subnetIds = key.getSubnetIds();
        if (value != null) {
            if (subnetIdsDefined(subnetIds)) {
                params.setSubnetIds(subnetIds);
            } else {
                params.setSubnetIds(List.of(value.getPreferedSubnetId()));
            }
        }
    }
    return params;
}
Also used : InstanceGroupMockNetworkV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.instancegroup.network.mock.InstanceGroupMockNetworkV4Parameters) EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) InstanceGroupMockNetworkV1Parameters(com.sequenceiq.distrox.api.v1.distrox.model.network.mock.InstanceGroupMockNetworkV1Parameters)

Example 4 with InstanceGroupMockNetworkV1Parameters

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

the class InstanceGroupNetworkParameterConverter method convert.

public InstanceGroupMockNetworkV4Parameters convert(InstanceGroupMockNetworkV1Parameters mock, EnvironmentNetworkResponse value, CloudPlatform cloudPlatform) {
    InstanceGroupMockNetworkV4Parameters response = null;
    if (CloudPlatform.MOCK == cloudPlatform) {
        InstanceGroupMockNetworkV1Parameters params = mock == null ? new InstanceGroupMockNetworkV1Parameters() : mock;
        response = convertToMockNetworkParams(new ImmutablePair<>(params, value));
    }
    return response;
}
Also used : InstanceGroupMockNetworkV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.instancegroup.network.mock.InstanceGroupMockNetworkV4Parameters) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) InstanceGroupMockNetworkV1Parameters(com.sequenceiq.distrox.api.v1.distrox.model.network.mock.InstanceGroupMockNetworkV1Parameters)

Aggregations

InstanceGroupMockNetworkV1Parameters (com.sequenceiq.distrox.api.v1.distrox.model.network.mock.InstanceGroupMockNetworkV1Parameters)4 InstanceGroupMockNetworkV4Parameters (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.instancegroup.network.mock.InstanceGroupMockNetworkV4Parameters)2 InstanceGroupNetworkV1Request (com.sequenceiq.distrox.api.v1.distrox.model.network.InstanceGroupNetworkV1Request)1 InstanceGroupAwsNetworkV1Parameters (com.sequenceiq.distrox.api.v1.distrox.model.network.aws.InstanceGroupAwsNetworkV1Parameters)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 EnvironmentNetworkResponse (com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse)1 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)1