Search in sources :

Example 1 with RevokeCertsRequest

use of com.sequenceiq.freeipa.flow.freeipa.cleanup.event.cert.RevokeCertsRequest in project cloudbreak by hortonworks.

the class FreeIpaDownscaleActions method revokeCertsAction.

@Bean(name = "DOWNSCALE_REVOKE_CERTS_STATE")
public Action<?, ?> revokeCertsAction() {
    return new AbstractDownscaleAction<>(StackEvent.class) {

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

Example 2 with RevokeCertsRequest

use of com.sequenceiq.freeipa.flow.freeipa.cleanup.event.cert.RevokeCertsRequest in project cloudbreak by hortonworks.

the class FreeIpaCleanupActions method revokeCertsAction.

@Bean(name = "REVOKE_CERTS_STATE")
public Action<?, ?> revokeCertsAction() {
    return new AbstractFreeIpaCleanupAction<>(CleanupEvent.class) {

        @Override
        protected void doExecute(FreeIpaContext context, CleanupEvent payload, Map<Object, Object> variables) {
            if (shouldSkipState(payload, variables) || payload.getHosts() == null || payload.getHosts().isEmpty()) {
                LOGGER.info("Host is empty, skipping revoking certificates");
                RevokeCertsResponse response = new RevokeCertsResponse(payload, Collections.emptySet(), Collections.emptyMap());
                sendEvent(context, response);
            } else {
                RevokeCertsRequest request = new RevokeCertsRequest(payload, context.getStack());
                sendEvent(context, request);
            }
        }
    };
}
Also used : RevokeCertsRequest(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.cert.RevokeCertsRequest) RevokeCertsResponse(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.cert.RevokeCertsResponse) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 3 with RevokeCertsRequest

use of com.sequenceiq.freeipa.flow.freeipa.cleanup.event.cert.RevokeCertsRequest in project cloudbreak by hortonworks.

the class CertRevokeHandler method accept.

@Override
public void accept(Event<RevokeCertsRequest> event) {
    RevokeCertsRequest request = event.getData();
    try {
        Pair<Set<String>, Map<String, String>> revokeCertResult = cleanupService.revokeCerts(request.getResourceId(), request.getHosts());
        RevokeCertsResponse response = new RevokeCertsResponse(request, revokeCertResult.getFirst(), revokeCertResult.getSecond());
        eventBus.notify(response.getCertCleanupFailed().isEmpty() ? EventSelectorUtil.selector(RevokeCertsResponse.class) : EventSelectorUtil.failureSelector(RevokeCertsResponse.class), new Event<>(event.getHeaders(), response));
    } catch (Exception e) {
        LOGGER.error("Revoking of certificates failed for hosts: [{}]", request.getHosts(), e);
        Map<String, String> failureResult = request.getHosts().stream().collect(Collectors.toMap(h -> h, h -> e.getMessage()));
        RevokeCertsResponse response = new RevokeCertsResponse(request, Collections.emptySet(), failureResult);
        eventBus.notify(EventSelectorUtil.failureSelector(RevokeCertsResponse.class), new Event<>(event.getHeaders(), response));
    }
}
Also used : Set(java.util.Set) RevokeCertsRequest(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.cert.RevokeCertsRequest) RevokeCertsResponse(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.cert.RevokeCertsResponse) Event(reactor.bus.Event) Map(java.util.Map)

Aggregations

RevokeCertsRequest (com.sequenceiq.freeipa.flow.freeipa.cleanup.event.cert.RevokeCertsRequest)3 Map (java.util.Map)3 RevokeCertsResponse (com.sequenceiq.freeipa.flow.freeipa.cleanup.event.cert.RevokeCertsResponse)2 Bean (org.springframework.context.annotation.Bean)2 CleanupEvent (com.sequenceiq.freeipa.flow.freeipa.cleanup.CleanupEvent)1 StackContext (com.sequenceiq.freeipa.flow.stack.StackContext)1 StackEvent (com.sequenceiq.freeipa.flow.stack.StackEvent)1 Set (java.util.Set)1 Event (reactor.bus.Event)1