Source:
public void registerLoadBalancerDomainWithFreeIPA(Stack stack) { if (manageCertificateAndDnsInPem()) { Set<LoadBalancer> loadBalancers = loadBalancerPersistenceService.findByStackId(stack.getId()); if (!loadBalancers.isEmpty()) { Optional<LoadBalancer> loadBalancerOptional = selectLoadBalancer(loadBalancers); if (loadBalancerOptional.isEmpty()) { LOGGER.error("Unabled to determine load balancer type. Load balancer will not be registered with FreeIPA."); return; } LoadBalancer loadBalancer = loadBalancerOptional.get(); String endpoint = loadBalancer.getEndpoint(); String domain = getDomainFromStack(stack); if (StringUtils.isNotEmpty(loadBalancer.getDns())) { AddDnsCnameRecordRequest request = new AddDnsCnameRecordRequest(); request.setCname(endpoint); request.setDnsZone(domain); request.setTargetFqdn(StringUtils.appendIfMissing(loadBalancer.getDns(), DOMAIN_PART_DELIMITER)); request.setEnvironmentCrn(stack.getEnvironmentCrn()); dnsV1Endpoint.addDnsCnameRecord(request); } else if (StringUtils.isNotEmpty(loadBalancer.getIp())) { AddDnsARecordRequest request = new AddDnsARecordRequest(); request.setHostname(endpoint); request.setDnsZone(domain); request.setIp(loadBalancer.getIp()); request.setEnvironmentCrn(stack.getEnvironmentCrn()); dnsV1Endpoint.addDnsARecord(request); } else { LOGGER.error("Unable to find DNS or IP for load balancer. Load balancer will not be registered with FreeIPA."); } } } }

Target:
public void registerLoadBalancerDomainWithFreeIPA(Stack stack) { if (manageCertificateAndDnsInPem()) { Set<LoadBalancer> loadBalancers = loadBalancerPersistenceService.findByStackId(stack.getId()); if (!loadBalancers.isEmpty()) { Optional<LoadBalancer> loadBalancerOptional = loadBalancerConfigService.selectLoadBalancer(loadBalancers, LoadBalancerType.PRIVATE); if (loadBalancerOptional.isPresent()) { LoadBalancer loadBalancer = loadBalancerOptional.get(); String endpoint = loadBalancer.getEndpoint(); String domain = getDomainFromStack(stack); try { if (StringUtils.isNotEmpty(loadBalancer.getDns())) { String targetFQDN = StringUtils.appendIfMissing(loadBalancer.getDns(), DOMAIN_PART_DELIMITER); AddDnsCnameRecordRequest request = new AddDnsCnameRecordRequest(); request.setCname(endpoint); request.setDnsZone(domain); request.setTargetFqdn(targetFQDN); request.setEnvironmentCrn(stack.getEnvironmentCrn()); LOGGER.debug("Registering load balancer with target FQDN in FreeIPA with CNAME {}", targetFQDN, endpoint); dnsV1Endpoint.addDnsCnameRecord(request); } else if (StringUtils.isNotEmpty(loadBalancer.getIp())) { String ip = loadBalancer.getIp(); AddDnsARecordRequest request = new AddDnsARecordRequest(); request.setHostname(endpoint); request.setDnsZone(domain); request.setIp(ip); request.setEnvironmentCrn(stack.getEnvironmentCrn()); LOGGER.debug("Registering load balancer with target IP in FreeIPA with A record {}", ip, endpoint); dnsV1Endpoint.addDnsARecord(request); } else { LOGGER.error("Unable to find DNS or IP for load balancer. Load balancer will not be registered with FreeIPA."); } } catch (Exception e) { LOGGER.error("Unable to register load balancer with FreeIPA", e); } } else { LOGGER.error("Unable to determine load balancer type. Load balancer will not be registered with FreeIPA."); } } } }