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);
}
}
}
Aggregations