use of com.sequenceiq.environment.environment.flow.creation.event.EnvCreationEvent in project cloudbreak by hortonworks.
the class EnvCreationActions method freeipaCreationAction.
@Bean(name = "FREEIPA_CREATION_STARTED_STATE")
public Action<?, ?> freeipaCreationAction() {
return new AbstractEnvironmentCreationAction<>(EnvCreationEvent.class) {
@Override
protected void doExecute(CommonContext context, EnvCreationEvent payload, Map<Object, Object> variables) {
environmentService.findEnvironmentById(payload.getResourceId()).ifPresentOrElse(environment -> {
LOGGER.info("Creation of FreeIPA has started. Current state is - FREEIPA_CREATION_STARTED_STATE");
environment.setStatus(EnvironmentStatus.FREEIPA_CREATION_IN_PROGRESS);
environment.setStatusReason(null);
environment = environmentService.save(environment);
EnvironmentDto environmentDto = environmentService.getEnvironmentDto(environment);
eventService.sendEventAndNotification(environmentDto, context.getFlowTriggerUserCrn(), ENVIRONMENT_FREEIPA_CREATION_STARTED);
sendEvent(context, CREATE_FREEIPA_EVENT.selector(), environmentDto);
}, () -> {
EnvCreationFailureEvent failureEvent = new EnvCreationFailureEvent(payload.getResourceId(), payload.getResourceName(), null, payload.getResourceCrn());
LOGGER.debug("Environment freeipa creation action went failed with EnvCreationFailureEvent was: {}", failureEvent);
eventService.sendEventAndNotificationForMissingEnv(payload, ENVIRONMENT_FREEIPA_CREATION_FAILED, context.getFlowTriggerUserCrn());
LOGGER.warn("Failed to create freeipa for environment! No environment found with id '{}'.", payload.getResourceId());
sendEvent(context, failureEvent);
});
}
};
}
Aggregations