Search in sources :

Example 1 with CleanupFailureEvent

use of com.sequenceiq.freeipa.flow.freeipa.cleanup.event.failure.CleanupFailureEvent in project cloudbreak by hortonworks.

the class FreeIpaCleanupActions method cleanupFailureAction.

@Bean(name = "CLEANUP_FAILED_STATE")
public Action<?, ?> cleanupFailureAction() {
    return new AbstractFreeIpaCleanupAction<>(CleanupFailureEvent.class) {

        @Inject
        private OperationService operationService;

        @Override
        protected void doExecute(FreeIpaContext context, CleanupFailureEvent payload, Map<Object, Object> variables) {
            LOGGER.error("Cleanup failed with payload: " + payload);
            String environmentCrn = payload.getEnvironmentCrn();
            SuccessDetails successDetails = new SuccessDetails(environmentCrn);
            successDetails.getAdditionalDetails().put(payload.getFailedPhase(), payload.getSuccess() == null ? List.of() : new ArrayList<>(payload.getSuccess()));
            String message = "Cleanup failed during " + payload.getFailedPhase();
            FailureDetails failureDetails = new FailureDetails(environmentCrn, message);
            if (payload.getFailureDetails() != null) {
                failureDetails.getAdditionalDetails().putAll(payload.getFailureDetails());
            }
            operationService.failOperation(payload.getAccountId(), payload.getOperationId(), message, List.of(successDetails), List.of(failureDetails));
            sendEvent(context, FreeIpaCleanupEvent.CLEANUP_FAILURE_HANDLED_EVENT.event(), payload);
        }

        @Override
        protected void initPayloadConverterMap(List<PayloadConverter<CleanupFailureEvent>> payloadConverters) {
            payloadConverters.add(new RemoveDnsResponseToCleanupFailureEventConverter());
            payloadConverters.add(new RemoveHostsResponseToCleanupFailureEventConverter());
            payloadConverters.add(new RemoveRolesResponseToCleanupFailureEventConverter());
            payloadConverters.add(new RemoveUsersResponseToCleanupFailureEventConverter());
            payloadConverters.add(new RevokeCertsResponseToCleanupFailureEventConverter());
            payloadConverters.add(new RemoveVaultEntriesResponseToCleanupFailureEventConverter());
        }
    };
}
Also used : SuccessDetails(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SuccessDetails) RemoveDnsResponseToCleanupFailureEventConverter(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.failure.RemoveDnsResponseToCleanupFailureEventConverter) RemoveRolesResponseToCleanupFailureEventConverter(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.failure.RemoveRolesResponseToCleanupFailureEventConverter) RemoveVaultEntriesResponseToCleanupFailureEventConverter(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.failure.RemoveVaultEntriesResponseToCleanupFailureEventConverter) ArrayList(java.util.ArrayList) FailureDetails(com.sequenceiq.freeipa.api.v1.freeipa.user.model.FailureDetails) RemoveUsersResponseToCleanupFailureEventConverter(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.failure.RemoveUsersResponseToCleanupFailureEventConverter) RevokeCertsResponseToCleanupFailureEventConverter(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.failure.RevokeCertsResponseToCleanupFailureEventConverter) RemoveHostsResponseToCleanupFailureEventConverter(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.failure.RemoveHostsResponseToCleanupFailureEventConverter) ArrayList(java.util.ArrayList) List(java.util.List) OperationService(com.sequenceiq.freeipa.service.operation.OperationService) Map(java.util.Map) CleanupFailureEvent(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.failure.CleanupFailureEvent) Bean(org.springframework.context.annotation.Bean)

Aggregations

FailureDetails (com.sequenceiq.freeipa.api.v1.freeipa.user.model.FailureDetails)1 SuccessDetails (com.sequenceiq.freeipa.api.v1.freeipa.user.model.SuccessDetails)1 CleanupFailureEvent (com.sequenceiq.freeipa.flow.freeipa.cleanup.event.failure.CleanupFailureEvent)1 RemoveDnsResponseToCleanupFailureEventConverter (com.sequenceiq.freeipa.flow.freeipa.cleanup.event.failure.RemoveDnsResponseToCleanupFailureEventConverter)1 RemoveHostsResponseToCleanupFailureEventConverter (com.sequenceiq.freeipa.flow.freeipa.cleanup.event.failure.RemoveHostsResponseToCleanupFailureEventConverter)1 RemoveRolesResponseToCleanupFailureEventConverter (com.sequenceiq.freeipa.flow.freeipa.cleanup.event.failure.RemoveRolesResponseToCleanupFailureEventConverter)1 RemoveUsersResponseToCleanupFailureEventConverter (com.sequenceiq.freeipa.flow.freeipa.cleanup.event.failure.RemoveUsersResponseToCleanupFailureEventConverter)1 RemoveVaultEntriesResponseToCleanupFailureEventConverter (com.sequenceiq.freeipa.flow.freeipa.cleanup.event.failure.RemoveVaultEntriesResponseToCleanupFailureEventConverter)1 RevokeCertsResponseToCleanupFailureEventConverter (com.sequenceiq.freeipa.flow.freeipa.cleanup.event.failure.RevokeCertsResponseToCleanupFailureEventConverter)1 OperationService (com.sequenceiq.freeipa.service.operation.OperationService)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 Bean (org.springframework.context.annotation.Bean)1