use of com.sequenceiq.freeipa.flow.freeipa.cleanup.event.vault.RemoveVaultEntriesRequest in project cloudbreak by hortonworks.
the class FreeIpaCleanupActions method removeVaultEntriesAction.
@Bean(name = "REMOVE_VAULT_ENTRIES_STATE")
public Action<?, ?> removeVaultEntriesAction() {
return new AbstractFreeIpaCleanupAction<>(RemoveDnsResponse.class) {
@Override
protected void doExecute(FreeIpaContext context, RemoveDnsResponse payload, Map<Object, Object> variables) {
if (shouldSkipState(payload, variables) || payload.getHosts() == null || payload.getHosts().isEmpty()) {
LOGGER.info("Host is empty, skipping removing vault entries");
RemoveVaultEntriesResponse response = new RemoveVaultEntriesResponse(payload, Collections.emptySet(), Collections.emptyMap());
sendEvent(context, response);
} else {
RemoveVaultEntriesRequest request = new RemoveVaultEntriesRequest(payload, context.getStack());
sendEvent(context, request);
}
}
};
}
use of com.sequenceiq.freeipa.flow.freeipa.cleanup.event.vault.RemoveVaultEntriesRequest in project cloudbreak by hortonworks.
the class VaultRemoveHandler method accept.
@Override
public void accept(Event<RemoveVaultEntriesRequest> event) {
RemoveVaultEntriesRequest request = event.getData();
try {
Pair<Set<String>, Map<String, String>> removeVaultResult = cleanupService.removeVaultEntries(request.getResourceId(), request.getHosts());
RemoveVaultEntriesResponse response = new RemoveVaultEntriesResponse(request, removeVaultResult.getFirst(), removeVaultResult.getSecond());
eventBus.notify(response.getVaultCleanupFailed().isEmpty() ? EventSelectorUtil.selector(RemoveVaultEntriesResponse.class) : EventSelectorUtil.failureSelector(RemoveVaultEntriesResponse.class), new Event<>(event.getHeaders(), response));
} catch (Exception e) {
LOGGER.error("Removing vault entries for hosts failed: [{}]", request.getHosts(), e);
Map<String, String> failureResult = request.getHosts().stream().collect(Collectors.toMap(h -> h, h -> e.getMessage()));
RemoveVaultEntriesResponse response = new RemoveVaultEntriesResponse(request, Collections.emptySet(), failureResult);
eventBus.notify(EventSelectorUtil.failureSelector(RemoveVaultEntriesResponse.class), new Event<>(event.getHeaders(), response));
}
}
Aggregations