use of com.sequenceiq.freeipa.flow.freeipa.cleanup.event.vault.RemoveVaultEntriesResponse in project cloudbreak by hortonworks.
the class FreeIpaCleanupActions method removeUsersAction.
@Bean(name = "REMOVE_USERS_STATE")
public Action<?, ?> removeUsersAction() {
return new AbstractFreeIpaCleanupAction<>(RemoveVaultEntriesResponse.class) {
@Override
protected void doExecute(FreeIpaContext context, RemoveVaultEntriesResponse payload, Map<Object, Object> variables) {
if (shouldSkipState(payload, variables) || payload.getUsers() == null || payload.getUsers().isEmpty()) {
LOGGER.info("User is empty, skipping removing users");
RemoveUsersResponse response = new RemoveUsersResponse(payload, Collections.emptySet(), Collections.emptyMap());
sendEvent(context, response);
} else {
RemoveUsersRequest request = new RemoveUsersRequest(payload, context.getStack());
sendEvent(context, request);
}
}
};
}
use of com.sequenceiq.freeipa.flow.freeipa.cleanup.event.vault.RemoveVaultEntriesResponse 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.RemoveVaultEntriesResponse in project cloudbreak by hortonworks.
the class RemoveVaultEntriesResponseToCleanupFailureEventConverter method convert.
@Override
public CleanupFailureEvent convert(Object payload) {
RemoveVaultEntriesResponse removeVaultEntriesResponse = (RemoveVaultEntriesResponse) payload;
CleanupFailureEvent event = new CleanupFailureEvent(removeVaultEntriesResponse, "Vault entry removal", removeVaultEntriesResponse.getVaultCleanupFailed(), removeVaultEntriesResponse.getVaultCleanupSuccess());
return event;
}
use of com.sequenceiq.freeipa.flow.freeipa.cleanup.event.vault.RemoveVaultEntriesResponse 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