Search in sources :

Example 1 with UpdateDnsSoaRecordsResponse

use of com.sequenceiq.freeipa.flow.freeipa.downscale.event.dnssoarecords.UpdateDnsSoaRecordsResponse in project cloudbreak by hortonworks.

the class FreeIpaDownscaleActions method removeHostsFromOrchestrationAction.

@Bean(name = "DOWNSCALE_REMOVE_HOSTS_FROM_ORCHESTRATION_STATE")
public Action<?, ?> removeHostsFromOrchestrationAction() {
    return new AbstractDownscaleAction<>(UpdateDnsSoaRecordsResponse.class) {

        @Override
        protected void doExecute(StackContext context, UpdateDnsSoaRecordsResponse payload, Map<Object, Object> variables) {
            stackUpdater.updateStackStatus(context.getStack().getId(), getInProgressStatus(variables), "Removing hosts from orchestration");
            CleanupEvent cleanupEvent = buildCleanupEvent(context, getDownscaleHosts(variables));
            RemoveHostsFromOrchestrationRequest request = new RemoveHostsFromOrchestrationRequest(cleanupEvent);
            sendEvent(context, request);
        }
    };
}
Also used : StackContext(com.sequenceiq.freeipa.flow.stack.StackContext) CleanupEvent(com.sequenceiq.freeipa.flow.freeipa.cleanup.CleanupEvent) Map(java.util.Map) UpdateDnsSoaRecordsResponse(com.sequenceiq.freeipa.flow.freeipa.downscale.event.dnssoarecords.UpdateDnsSoaRecordsResponse) RemoveHostsFromOrchestrationRequest(com.sequenceiq.freeipa.flow.freeipa.downscale.event.removehosts.RemoveHostsFromOrchestrationRequest) Bean(org.springframework.context.annotation.Bean)

Example 2 with UpdateDnsSoaRecordsResponse

use of com.sequenceiq.freeipa.flow.freeipa.downscale.event.dnssoarecords.UpdateDnsSoaRecordsResponse in project cloudbreak by hortonworks.

the class UpdateDnsSoaRecordsHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<UpdateDnsSoaRecordsRequest> event) {
    UpdateDnsSoaRecordsRequest request = event.getData();
    Selectable result;
    try {
        Long stackId = request.getResourceId();
        Set<String> fqdns = request.getHosts().stream().map(hostname -> StringUtils.appendIfMissing(hostname, ".")).collect(Collectors.toSet());
        updateSoaRecords(stackId, fqdns);
        result = new UpdateDnsSoaRecordsResponse(request.getResourceId());
    } catch (Exception e) {
        LOGGER.error("Downscale updating DNS SOA records failed", e);
        result = new DownscaleFailureEvent(DOWNSCALE_UPDATE_DNS_SOA_RECORDS_FAILED_EVENT.event(), request.getResourceId(), "Downscale Update DNS SOA Records", Set.of(), Map.of(), e);
    }
    return result;
}
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) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) UpdateDnsSoaRecordsRequest(com.sequenceiq.freeipa.flow.freeipa.downscale.event.dnssoarecords.UpdateDnsSoaRecordsRequest) DownscaleFailureEvent(com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleFailureEvent) UpdateDnsSoaRecordsResponse(com.sequenceiq.freeipa.flow.freeipa.downscale.event.dnssoarecords.UpdateDnsSoaRecordsResponse) FreeIpaClientException(com.sequenceiq.freeipa.client.FreeIpaClientException)

Aggregations

UpdateDnsSoaRecordsResponse (com.sequenceiq.freeipa.flow.freeipa.downscale.event.dnssoarecords.UpdateDnsSoaRecordsResponse)2 Map (java.util.Map)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 FreeIpaClient (com.sequenceiq.freeipa.client.FreeIpaClient)1 FreeIpaClientException (com.sequenceiq.freeipa.client.FreeIpaClientException)1 DnsZone (com.sequenceiq.freeipa.client.model.DnsZone)1 IpaServer (com.sequenceiq.freeipa.client.model.IpaServer)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 UpdateDnsSoaRecordsRequest (com.sequenceiq.freeipa.flow.freeipa.downscale.event.dnssoarecords.UpdateDnsSoaRecordsRequest)1 RemoveHostsFromOrchestrationRequest (com.sequenceiq.freeipa.flow.freeipa.downscale.event.removehosts.RemoveHostsFromOrchestrationRequest)1 StackContext (com.sequenceiq.freeipa.flow.stack.StackContext)1 FreeIpaClientFactory (com.sequenceiq.freeipa.service.freeipa.FreeIpaClientFactory)1 Objects (java.util.Objects)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1