use of com.sequenceiq.freeipa.client.model.IpaServer in project cloudbreak by hortonworks.
the class UpdateDnsSoaRecordsHandler method updateSoaRecords.
private void updateSoaRecords(Long stackId, Set<String> fqdnsToUpdate) throws FreeIpaClientException {
FreeIpaClient freeIpaClient = freeIpaClientFactory.getFreeIpaClientForStackId(stackId);
String newFqdn = freeIpaClient.findAllServers().stream().map(IpaServer::getFqdn).filter(Objects::nonNull).map(fqdn -> StringUtils.appendIfMissing(fqdn, ".")).filter(fqdn -> !fqdnsToUpdate.contains(fqdn)).findFirst().orElseThrow(() -> new IllegalStateException("A alternate FreeIPA server was not found for the SOA records"));
Set<DnsZone> dnsZonesToUpdate = freeIpaClient.findAllDnsZone().stream().filter(dnsZone -> Objects.nonNull(dnsZone.getIdnssoamname())).filter(dnsZone -> fqdnsToUpdate.contains(dnsZone.getIdnssoamname())).collect(Collectors.toSet());
for (DnsZone dnsZone : dnsZonesToUpdate) {
freeIpaClient.setDnsZoneAuthoritativeNameserver(dnsZone.getIdnsname(), newFqdn);
}
}
Aggregations