Search in sources :

Example 1 with NetworkV4Base

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;
}
Also used : Json(com.sequenceiq.cloudbreak.common.json.Json) NetworkV4Base(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.NetworkV4Base)

Example 2 with 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;
}
Also used : NetworkV4Base(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.NetworkV4Base) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)

Aggregations

NetworkV4Base (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.NetworkV4Base)2 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)1 Json (com.sequenceiq.cloudbreak.common.json.Json)1