use of com.sequenceiq.distrox.api.v1.distrox.model.network.InstanceGroupNetworkV1Base in project cloudbreak by hortonworks.
the class DistroXV1RequestToStackV4RequestConverter method getNetwork.
NetworkV4Request getNetwork(NetworkV1Request networkRequest, DetailedEnvironmentResponse environment, Set<InstanceGroupV1Request> instanceGroupRequests) {
Set<String> subnetIds = new HashSet<>();
if (instanceGroupRequests != null) {
subnetIds.addAll(instanceGroupRequests.stream().map(ig -> Optional.ofNullable(ig.getNetwork()).map(InstanceGroupNetworkV1Base::getAws).map(InstanceGroupAwsNetworkV1Parameters::getSubnetIds).orElseGet(ArrayList::new)).flatMap(Collection::stream).collect(Collectors.toSet()));
}
if (subnetIds.size() == 1) {
String subnetId = subnetIds.stream().findFirst().get();
LOGGER.info("Update the global subnet id to {}, because it is configured in instance group level as the new way", subnetId);
if (networkRequest == null) {
networkRequest = new NetworkV1Request();
}
if (networkRequest.getAws() == null) {
networkRequest.setAws(new AwsNetworkV1Parameters());
}
networkRequest.getAws().setSubnetId(subnetId);
} else {
LOGGER.info("Use the legacy way to configure the global network.");
}
NetworkV4Request network = getIfNotNull(new ImmutablePair<>(networkRequest, environment), networkConverter::convertToNetworkV4Request);
validateSubnetIds(network, environment);
return network;
}
Aggregations