use of com.sequenceiq.common.api.type.CcmV2TlsType in project cloudbreak by hortonworks.
the class EnvironmentDetailsToCDPNetworkDetailsConverter method convert.
public UsageProto.CDPNetworkDetails convert(EnvironmentDetails environmentDetails) {
UsageProto.CDPNetworkDetails.Builder cdpNetworkDetails = UsageProto.CDPNetworkDetails.newBuilder();
cdpNetworkDetails.setNumberPublicSubnets(DEFAULT_INTEGER_VALUE);
cdpNetworkDetails.setNumberPrivateSubnets(DEFAULT_INTEGER_VALUE);
Tunnel tunnel = environmentDetails.getTunnel();
if (tunnel != null) {
cdpNetworkDetails.setConnectivity(tunnel.name());
}
CcmV2TlsType tlsType = environmentDetails.getTlsType();
if (tlsType != null) {
cdpNetworkDetails.setControlPlaneAndCCMAgentConnectionSecurity(tlsType.name());
}
NetworkDto network = environmentDetails.getNetwork();
if (network != null) {
cdpNetworkDetails.setNetworkType(network.getRegistrationType().name());
cdpNetworkDetails.setServiceEndpointCreation(network.getServiceEndpointCreation().name());
if (network.getSubnetMetas() != null) {
if (network.getSubnetMetas().isEmpty()) {
cdpNetworkDetails.setNumberPrivateSubnets(0);
cdpNetworkDetails.setNumberPublicSubnets(0);
} else {
List<SubnetType> types = network.getSubnetMetas().values().stream().map(CloudSubnet::getType).filter(Objects::nonNull).sorted().collect(Collectors.toUnmodifiableList());
if (!types.isEmpty()) {
cdpNetworkDetails.setNumberPrivateSubnets(types.stream().filter(e -> e.equals(SubnetType.PRIVATE) || e.equals(SubnetType.MLX) || e.equals(SubnetType.DWX)).collect(Collectors.toList()).size());
cdpNetworkDetails.setNumberPublicSubnets(types.stream().filter(e -> e.equals(SubnetType.PUBLIC)).collect(Collectors.toList()).size());
}
}
}
cdpNetworkDetails.setPublicEndpointAccessGateway(network.getPublicEndpointAccessGateway() != null ? network.getPublicEndpointAccessGateway().name() : PublicEndpointAccessGateway.DISABLED.name());
}
cdpNetworkDetails.setSecurityAccessType(defaultIfEmpty(environmentDetails.getSecurityAccessType(), ""));
cdpNetworkDetails.setProxyDetails(convertProxy(environmentDetails.getProxyDetails()));
cdpNetworkDetails.setDomain(defaultIfEmpty(environmentDetails.getDomain(), ""));
cdpNetworkDetails.setOwnDnsZones(convertOwnDnsZones(network, environmentDetails.getCloudPlatform()));
UsageProto.CDPNetworkDetails ret = cdpNetworkDetails.build();
LOGGER.debug("Converted CDPNetworkDetails: {}", ret);
return ret;
}
Aggregations