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);
}
};
}
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);
}
}
};
}
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));
}
}
Aggregations