Search in sources :

Example 6 with IpaServer

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);
    }
}
Also used : DOWNSCALE_UPDATE_DNS_SOA_RECORDS_FAILED_EVENT(com.sequenceiq.freeipa.flow.freeipa.downscale.DownscaleFlowEvent.DOWNSCALE_UPDATE_DNS_SOA_RECORDS_FAILED_EVENT) Logger(org.slf4j.Logger) LoggerFactory(org.slf4j.LoggerFactory) EventSelectorUtil(com.sequenceiq.flow.event.EventSelectorUtil) IpaServer(com.sequenceiq.freeipa.client.model.IpaServer) Set(java.util.Set) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) FreeIpaClientException(com.sequenceiq.freeipa.client.FreeIpaClientException) FreeIpaClient(com.sequenceiq.freeipa.client.FreeIpaClient) Collectors(java.util.stream.Collectors) StringUtils(org.apache.commons.lang3.StringUtils) UpdateDnsSoaRecordsResponse(com.sequenceiq.freeipa.flow.freeipa.downscale.event.dnssoarecords.UpdateDnsSoaRecordsResponse) UpdateDnsSoaRecordsRequest(com.sequenceiq.freeipa.flow.freeipa.downscale.event.dnssoarecords.UpdateDnsSoaRecordsRequest) Objects(java.util.Objects) Inject(javax.inject.Inject) DnsZone(com.sequenceiq.freeipa.client.model.DnsZone) Component(org.springframework.stereotype.Component) ExceptionCatcherEventHandler(com.sequenceiq.flow.reactor.api.handler.ExceptionCatcherEventHandler) DownscaleFailureEvent(com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleFailureEvent) Event(reactor.bus.Event) Map(java.util.Map) FreeIpaClientFactory(com.sequenceiq.freeipa.service.freeipa.FreeIpaClientFactory) FreeIpaClient(com.sequenceiq.freeipa.client.FreeIpaClient) Objects(java.util.Objects) DnsZone(com.sequenceiq.freeipa.client.model.DnsZone)

Aggregations

IpaServer (com.sequenceiq.freeipa.client.model.IpaServer)6 FreeIpaClient (com.sequenceiq.freeipa.client.FreeIpaClient)4 Map (java.util.Map)3 Set (java.util.Set)3 Event (reactor.bus.Event)3 DnsZone (com.sequenceiq.freeipa.client.model.DnsZone)2 UpdateDnsSoaRecordsRequest (com.sequenceiq.freeipa.flow.freeipa.downscale.event.dnssoarecords.UpdateDnsSoaRecordsRequest)2 Test (org.junit.Test)2 Test (org.junit.jupiter.api.Test)2 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)1 EventSelectorUtil (com.sequenceiq.flow.event.EventSelectorUtil)1 ExceptionCatcherEventHandler (com.sequenceiq.flow.reactor.api.handler.ExceptionCatcherEventHandler)1 HandlerEvent (com.sequenceiq.flow.reactor.api.handler.HandlerEvent)1 FreeIpaClientException (com.sequenceiq.freeipa.client.FreeIpaClientException)1 CleanupEvent (com.sequenceiq.freeipa.flow.freeipa.cleanup.CleanupEvent)1 DOWNSCALE_UPDATE_DNS_SOA_RECORDS_FAILED_EVENT (com.sequenceiq.freeipa.flow.freeipa.downscale.DownscaleFlowEvent.DOWNSCALE_UPDATE_DNS_SOA_RECORDS_FAILED_EVENT)1 DownscaleFailureEvent (com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleFailureEvent)1 CollectAdditionalHostnamesRequest (com.sequenceiq.freeipa.flow.freeipa.downscale.event.collecthostnames.CollectAdditionalHostnamesRequest)1 CollectAdditionalHostnamesResponse (com.sequenceiq.freeipa.flow.freeipa.downscale.event.collecthostnames.CollectAdditionalHostnamesResponse)1 UpdateDnsSoaRecordsResponse (com.sequenceiq.freeipa.flow.freeipa.downscale.event.dnssoarecords.UpdateDnsSoaRecordsResponse)1