Search in sources :

Example 31 with EnvironmentDeletionDto

use of com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto in project cloudbreak by hortonworks.

the class EnvDeleteActions method networkDeleteAction.

@Bean(name = "NETWORK_DELETE_STARTED_STATE")
public Action<?, ?> networkDeleteAction() {
    return new AbstractEnvDeleteAction<>(EnvDeleteEvent.class) {

        @Override
        protected void doExecute(CommonContext context, EnvDeleteEvent payload, Map<Object, Object> variables) {
            EnvironmentDto envDto = environmentStatusUpdateService.updateEnvironmentStatusAndNotify(context, payload, EnvironmentStatus.NETWORK_DELETE_IN_PROGRESS, ResourceEvent.ENVIRONMENT_NETWORK_DELETION_STARTED, EnvDeleteState.NETWORK_DELETE_STARTED_STATE);
            EnvironmentDeletionDto environmentDeletionDto = EnvironmentDeletionDto.builder().withEnvironmentDto(envDto).withForceDelete(payload.isForceDelete()).withId(payload.getResourceId()).build();
            sendEvent(context, DELETE_NETWORK_EVENT.selector(), environmentDeletionDto);
        }
    };
}
Also used : EnvDeleteEvent(com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteEvent) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) CommonContext(com.sequenceiq.flow.core.CommonContext) Map(java.util.Map) EnvironmentDeletionDto(com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto) Bean(org.springframework.context.annotation.Bean)

Example 32 with EnvironmentDeletionDto

use of com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto in project cloudbreak by hortonworks.

the class EnvDeleteActions method freeipaDeleteAction.

@Bean(name = "FREEIPA_DELETE_STARTED_STATE")
public Action<?, ?> freeipaDeleteAction() {
    return new AbstractEnvDeleteAction<>(EnvDeleteEvent.class) {

        @Override
        protected void doExecute(CommonContext context, EnvDeleteEvent payload, Map<Object, Object> variables) {
            EnvironmentDto envDto = environmentStatusUpdateService.updateEnvironmentStatusAndNotify(context, payload, EnvironmentStatus.FREEIPA_DELETE_IN_PROGRESS, ResourceEvent.ENVIRONMENT_FREEIPA_DELETION_STARTED, EnvDeleteState.FREEIPA_DELETE_STARTED_STATE);
            EnvironmentDeletionDto environmentDeletionDto = EnvironmentDeletionDto.builder().withEnvironmentDto(envDto).withForceDelete(payload.isForceDelete()).withId(payload.getResourceId()).build();
            sendEvent(context, DELETE_FREEIPA_EVENT.selector(), environmentDeletionDto);
        }
    };
}
Also used : EnvDeleteEvent(com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteEvent) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) CommonContext(com.sequenceiq.flow.core.CommonContext) Map(java.util.Map) EnvironmentDeletionDto(com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto) Bean(org.springframework.context.annotation.Bean)

Example 33 with EnvironmentDeletionDto

use of com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto in project cloudbreak by hortonworks.

the class ClusterDefinitionDeleteHandler method accept.

@Override
public void accept(Event<EnvironmentDeletionDto> environmentDtoEvent) {
    EnvironmentDeletionDto environmentDeletionDto = environmentDtoEvent.getData();
    EnvironmentDto environmentDto = environmentDeletionDto.getEnvironmentDto();
    AtomicReference<String> resourceCrn = new AtomicReference<>(null);
    EnvDeleteEvent envDeleteEvent = EnvDeleteEvent.builder().withResourceId(environmentDto.getResourceId()).withResourceCrn(environmentDto.getResourceCrn()).withResourceName(environmentDto.getName()).withForceDelete(environmentDeletionDto.isForceDelete()).withSelector(START_UMS_RESOURCE_DELETE_EVENT.selector()).build();
    try {
        environmentService.findEnvironmentById(environmentDto.getId()).ifPresent(environment -> {
            resourceCrn.set(environment.getResourceCrn());
            environmentResourceDeletionService.deleteClusterDefinitionsOnCloudbreak(environment.getResourceCrn());
        });
        eventSender().sendEvent(envDeleteEvent, environmentDtoEvent.getHeaders());
    } catch (Exception e) {
        exceptionProcessor.handle(new HandlerFailureConjoiner(e, environmentDtoEvent, envDeleteEvent), LOGGER, eventSender(), selector());
    }
}
Also used : EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) EnvDeleteEvent(com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteEvent) AtomicReference(java.util.concurrent.atomic.AtomicReference) EnvironmentDeletionDto(com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto)

Example 34 with EnvironmentDeletionDto

use of com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto in project cloudbreak by hortonworks.

the class IdBrokerMappingsDeleteHandler method accept.

@Override
public void accept(Event<EnvironmentDeletionDto> environmentDtoEvent) {
    EnvironmentDeletionDto environmentDeletionDto = environmentDtoEvent.getData();
    EnvironmentDto environmentDto = environmentDeletionDto.getEnvironmentDto();
    EnvDeleteEvent envDeleteEvent = EnvDeleteEvent.builder().withResourceId(environmentDto.getResourceId()).withResourceName(environmentDto.getName()).withResourceCrn(environmentDto.getResourceCrn()).withForceDelete(environmentDeletionDto.isForceDelete()).withSelector(START_S3GUARD_TABLE_DELETE_EVENT.selector()).build();
    try {
        environmentService.findEnvironmentById(environmentDto.getId()).ifPresent(environment -> {
            String environmentCrn = environment.getResourceCrn();
            if (environment.getExperimentalFeaturesJson().getIdBrokerMappingSource() == IdBrokerMappingSource.IDBMMS) {
                LOGGER.info("Deleting IDBroker mappings in IDBMMS associated with environment {}.", environmentCrn);
                deleteIdBrokerMappings(environmentCrn);
            } else {
                LOGGER.info("IDBMMS usage is disabled for environment {}. No need to delete IDBroker mappings.", environmentCrn);
            }
        });
        eventSender().sendEvent(envDeleteEvent, environmentDtoEvent.getHeaders());
    } catch (Exception e) {
        exceptionProcessor.handle(new HandlerFailureConjoiner(e, environmentDtoEvent, envDeleteEvent), LOGGER, eventSender(), selector());
    }
}
Also used : EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) EnvDeleteEvent(com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteEvent) IdbmmsOperationException(com.sequenceiq.cloudbreak.idbmms.exception.IdbmmsOperationException) EnvironmentDeletionDto(com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto)

Example 35 with EnvironmentDeletionDto

use of com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto in project cloudbreak by hortonworks.

the class RdbmsDeleteHandler method accept.

@Override
public void accept(Event<EnvironmentDeletionDto> environmentDtoEvent) {
    EnvironmentDeletionDto environmentDeletionDto = environmentDtoEvent.getData();
    EnvironmentDto environmentDto = environmentDeletionDto.getEnvironmentDto();
    EnvDeleteEvent envDeleteEvent = EnvDeleteEvent.builder().withResourceId(environmentDto.getResourceId()).withResourceCrn(environmentDto.getResourceCrn()).withResourceName(environmentDto.getName()).withForceDelete(environmentDeletionDto.isForceDelete()).withSelector(START_ENVIRONMENT_RESOURCE_ENCRYPTION_DELETE_EVENT.selector()).build();
    try {
        eventSender().sendEvent(envDeleteEvent, environmentDtoEvent.getHeaders());
    } catch (Exception e) {
        exceptionProcessor.handle(new HandlerFailureConjoiner(e, environmentDtoEvent, envDeleteEvent), LOGGER, eventSender(), selector());
    }
}
Also used : EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) EnvDeleteEvent(com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteEvent) EnvironmentDeletionDto(com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto)

Aggregations

EnvironmentDeletionDto (com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto)38 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)34 EnvDeleteEvent (com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteEvent)23 CommonContext (com.sequenceiq.flow.core.CommonContext)12 Map (java.util.Map)12 Bean (org.springframework.context.annotation.Bean)12 BeforeEach (org.junit.jupiter.api.BeforeEach)8 BaseNamedFlowEvent (com.sequenceiq.flow.reactor.api.event.BaseNamedFlowEvent)4 Test (org.junit.jupiter.api.Test)4 Environment (com.sequenceiq.environment.environment.domain.Environment)3 EnvClusterDeleteFailedEvent (com.sequenceiq.environment.environment.flow.deletion.event.EnvClusterDeleteFailedEvent)3 DescribeFreeIpaResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse)3 ResourceEvent (com.sequenceiq.cloudbreak.event.ResourceEvent)2 EnvironmentStatus (com.sequenceiq.environment.environment.EnvironmentStatus)2 PollingConfig (com.sequenceiq.environment.util.PollingConfig)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 Headers (reactor.bus.Event.Headers)2 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)1 ExceptionResponse (com.sequenceiq.cloudbreak.common.exception.ExceptionResponse)1