Search in sources :

Example 1 with EnvironmentNetworkConverter

use of com.sequenceiq.cloudbreak.converter.v4.environment.network.EnvironmentNetworkConverter in project cloudbreak by hortonworks.

the class StackV4RequestToStackConverter method setNetworkIfApplicable.

private void setNetworkIfApplicable(StackV4Request source, Stack stack, DetailedEnvironmentResponse environment) {
    if (source.getNetwork() != null) {
        source.getNetwork().setCloudPlatform(source.getCloudPlatform());
        Network network = networkV4RequestToNetworkConverter.convert(source.getNetwork());
        EnvironmentNetworkResponse envNetwork = environment == null ? null : environment.getNetwork();
        if (envNetwork != null) {
            network.setNetworkCidrs(envNetwork.getNetworkCidrs());
            network.setOutboundInternetTraffic(envNetwork.getOutboundInternetTraffic());
        }
        stack.setNetwork(network);
    } else {
        EnvironmentNetworkConverter environmentNetworkConverter = environmentNetworkConverterMap.get(source.getCloudPlatform());
        String availabilityZone = source.getPlacement() != null ? source.getPlacement().getAvailabilityZone() : null;
        if (environmentNetworkConverter != null && environment != null) {
            Network network = environmentNetworkConverter.convertToLegacyNetwork(environment.getNetwork(), availabilityZone);
            stack.setNetwork(network);
        }
    }
}
Also used : Network(com.sequenceiq.cloudbreak.domain.Network) EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) EnvironmentNetworkConverter(com.sequenceiq.cloudbreak.converter.v4.environment.network.EnvironmentNetworkConverter)

Aggregations

EnvironmentNetworkConverter (com.sequenceiq.cloudbreak.converter.v4.environment.network.EnvironmentNetworkConverter)1 Network (com.sequenceiq.cloudbreak.domain.Network)1 EnvironmentNetworkResponse (com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse)1