Search in sources :

Example 1 with RemoveDnsRequest

use of com.sequenceiq.freeipa.flow.freeipa.cleanup.event.dns.RemoveDnsRequest in project cloudbreak by hortonworks.

the class FreeIpaDownscaleActions method removeDnsEntriesAction.

@Bean(name = "DOWNSCALE_REMOVE_DNS_ENTRIES_STATE")
public Action<?, ?> removeDnsEntriesAction() {
    return new AbstractDownscaleAction<>(RevokeCertsResponse.class) {

        @Override
        protected void doExecute(StackContext context, RevokeCertsResponse payload, Map<Object, Object> variables) {
            stackUpdater.updateStackStatus(context.getStack().getId(), getInProgressStatus(variables), "Remove DNS entries");
            CleanupEvent cleanupEvent = buildCleanupEvent(context, getDownscaleHosts(variables));
            RemoveDnsRequest request = new RemoveDnsRequest(cleanupEvent);
            sendEvent(context, request);
        }
    };
}
Also used : StackContext(com.sequenceiq.freeipa.flow.stack.StackContext) RemoveDnsRequest(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.dns.RemoveDnsRequest) RevokeCertsResponse(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.cert.RevokeCertsResponse) CleanupEvent(com.sequenceiq.freeipa.flow.freeipa.cleanup.CleanupEvent) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 2 with RemoveDnsRequest

use of com.sequenceiq.freeipa.flow.freeipa.cleanup.event.dns.RemoveDnsRequest in project cloudbreak by hortonworks.

the class FreeIpaCleanupActions method removeDnsEntriesAction.

@Bean(name = "REMOVE_DNS_ENTRIES_STATE")
public Action<?, ?> removeDnsEntriesAction() {
    return new AbstractFreeIpaCleanupAction<>(RemoveHostsResponse.class) {

        @Override
        protected void doExecute(FreeIpaContext context, RemoveHostsResponse payload, Map<Object, Object> variables) {
            if (shouldSkipState(payload, variables) || (payload.getHosts() == null || payload.getHosts().isEmpty()) && (payload.getIps() == null || payload.getIps().isEmpty())) {
                LOGGER.info("Host is empty, skipping removing hosts");
                RemoveDnsResponse response = new RemoveDnsResponse(payload, Collections.emptySet(), Collections.emptyMap());
                sendEvent(context, response);
            } else {
                RemoveDnsRequest request = new RemoveDnsRequest(payload);
                sendEvent(context, request);
            }
        }
    };
}
Also used : RemoveDnsResponse(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.dns.RemoveDnsResponse) RemoveHostsResponse(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.host.RemoveHostsResponse) RemoveDnsRequest(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.dns.RemoveDnsRequest) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 3 with RemoveDnsRequest

use of com.sequenceiq.freeipa.flow.freeipa.cleanup.event.dns.RemoveDnsRequest in project cloudbreak by hortonworks.

the class DnsRemoveHandler method accept.

@Override
public void accept(Event<RemoveDnsRequest> event) {
    RemoveDnsRequest request = event.getData();
    try {
        FreeIpa freeIpa = freeIpaService.findByStackId(request.getResourceId());
        Pair<Set<String>, Map<String, String>> removeDnsResult = cleanupService.removeDnsEntries(request.getResourceId(), request.getHosts(), request.getIps(), freeIpa.getDomain());
        RemoveDnsResponse response = new RemoveDnsResponse(request, removeDnsResult.getFirst(), removeDnsResult.getSecond());
        eventBus.notify(response.getDnsCleanupFailed().isEmpty() ? EventSelectorUtil.selector(RemoveDnsResponse.class) : EventSelectorUtil.failureSelector(RemoveDnsResponse.class), new Event<>(event.getHeaders(), response));
    } catch (Exception e) {
        LOGGER.error("Removing DNS entries failed for hosts: [{}]", request.getHosts(), e);
        Map<String, String> failureResult = request.getHosts().stream().collect(Collectors.toMap(h -> h, h -> e.getMessage()));
        RemoveDnsResponse response = new RemoveDnsResponse(request, Collections.emptySet(), failureResult);
        eventBus.notify(EventSelectorUtil.failureSelector(RemoveDnsResponse.class), new Event<>(event.getHeaders(), response));
    }
}
Also used : RemoveDnsResponse(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.dns.RemoveDnsResponse) Set(java.util.Set) FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) RemoveDnsRequest(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.dns.RemoveDnsRequest) Event(reactor.bus.Event) Map(java.util.Map)

Aggregations

RemoveDnsRequest (com.sequenceiq.freeipa.flow.freeipa.cleanup.event.dns.RemoveDnsRequest)3 Map (java.util.Map)3 RemoveDnsResponse (com.sequenceiq.freeipa.flow.freeipa.cleanup.event.dns.RemoveDnsResponse)2 Bean (org.springframework.context.annotation.Bean)2 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)1 CleanupEvent (com.sequenceiq.freeipa.flow.freeipa.cleanup.CleanupEvent)1 RevokeCertsResponse (com.sequenceiq.freeipa.flow.freeipa.cleanup.event.cert.RevokeCertsResponse)1 RemoveHostsResponse (com.sequenceiq.freeipa.flow.freeipa.cleanup.event.host.RemoveHostsResponse)1 StackContext (com.sequenceiq.freeipa.flow.stack.StackContext)1 Set (java.util.Set)1 Event (reactor.bus.Event)1