use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.NetworkV4Base in project cloudbreak by hortonworks.
the class LoadBalancerConfigService method getNetworkV4Base.
private NetworkV4Base getNetworkV4Base(Network network) {
Json attributes = network.getAttributes();
Map<String, Object> params = attributes == null ? Collections.emptyMap() : attributes.getMap();
NetworkV4Base networkV4Base = new NetworkV4Base();
providerParameterCalculator.parse(params, networkV4Base);
return networkV4Base;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.NetworkV4Base in project cloudbreak by hortonworks.
the class LoadBalancerConfigService method isSelectedSubnetAvailableAndRequestedType.
private boolean isSelectedSubnetAvailableAndRequestedType(Network network, EnvironmentNetworkResponse envNetwork, boolean privateType) {
if (network != null && envNetwork != null) {
String subnetId = getSubnetId(network);
if (StringUtils.isNotEmpty(subnetId)) {
LOGGER.debug("Found selected stack subnet {}", subnetId);
Optional<CloudSubnet> selectedSubnet = subnetSelector.findSubnetById(envNetwork.getSubnetMetas(), subnetId);
// "noPublicIp" is an option for Azure and GCP that is used to set the network to private or public, it is not
// set on AWS networks. So, we check for it first, then fall back to AWS.
NetworkV4Base networkV4Base = getNetworkV4Base(network);
if (networkV4Base.isNoPublicIp().isPresent()) {
// azure and gcp specific
Boolean noPublicIp = networkV4Base.isNoPublicIp().get();
LOGGER.debug("Subnet {} type {}", subnetId, noPublicIp ? "private" : "public");
return privateType == noPublicIp;
} else if (selectedSubnet.isPresent()) {
// aws specific
LOGGER.debug("Subnet {} type {}", subnetId, selectedSubnet.get().isPrivateSubnet() ? "private" : "public");
return privateType == selectedSubnet.get().isPrivateSubnet();
}
}
}
LOGGER.debug("Subnet for load balancer creation was not found.");
return false;
}
Aggregations