use of com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto in project cloudbreak by hortonworks.
the class ResourceEncryptionDeleteHandlerTest method setUp.
@BeforeEach
void setUp() {
EnvironmentDto eventDto = EnvironmentDto.builder().withId(ENVIRONMENT_ID).withResourceCrn(ENVIRONMENT_CRN).withName(ENVIRONMENT_NAME).withCloudPlatform("AZURE").withParameters(ParametersDto.builder().withAzureParameters(AzureParametersDto.builder().withEncryptionParameters(AzureResourceEncryptionParametersDto.builder().withDiskEncryptionSetId("/subscriptions/dummySubscriptionId/resourceGroups/dummyResourceGroup/" + "providers/Microsoft.Compute/diskEncryptionSets/dummyDesId").withEncryptionKeyUrl("https://dummyVault.vault.azure.net/keys/dummyKey/dummyKeyVersion").build()).build()).build()).build();
EnvironmentDeletionDto environmentDeletionDto = EnvironmentDeletionDto.builder().withId(ENVIRONMENT_ID).withForceDelete(false).withEnvironmentDto(eventDto).build();
lenient().when(environmentDtoEvent.getData()).thenReturn(environmentDeletionDto);
lenient().when(environmentDtoEvent.getHeaders()).thenReturn(headers);
lenient().doAnswer(i -> null).when(eventSender).sendEvent(baseNamedFlowEventCaptor.capture(), any(Headers.class));
}
use of com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto in project cloudbreak by hortonworks.
the class DataHubClusterDeletionHandler method accept.
@Override
public void accept(Event<EnvironmentDeletionDto> environmentDtoEvent) {
LOGGER.debug("Accepting DataHubClustersDelete event");
EnvironmentDeletionDto environmentDeletionDto = environmentDtoEvent.getData();
EnvironmentDto environmentDto = environmentDeletionDto.getEnvironmentDto();
EnvDeleteEvent envDeleteEvent = getEnvDeleteEvent(environmentDeletionDto);
try {
PollingConfig pollingConfig = getPollingConfig();
environmentService.findEnvironmentById(environmentDto.getId()).ifPresent(environment -> datahubDeletionService.deleteDatahubClustersForEnvironment(pollingConfig, environment, environmentDeletionDto.isForceDelete()));
eventSender().sendEvent(envDeleteEvent, environmentDtoEvent.getHeaders());
} catch (Exception e) {
EnvClusterDeleteFailedEvent failedEvent = EnvClusterDeleteFailedEvent.builder().withEnvironmentID(environmentDto.getId()).withException(e).withResourceCrn(environmentDto.getResourceCrn()).withResourceName(environmentDto.getName()).build();
eventSender().sendEvent(failedEvent, environmentDtoEvent.getHeaders());
}
}
use of com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto in project cloudbreak by hortonworks.
the class ExperienceDeletionHandler method accept.
@Override
public void accept(Event<EnvironmentDeletionDto> environmentDeletionDtoEvent) {
LOGGER.debug("Accepting XP Delete event");
EnvironmentDeletionDto environmentDeletionDto = environmentDeletionDtoEvent.getData();
EnvironmentDto envDto = environmentDeletionDtoEvent.getData().getEnvironmentDto();
try {
if (experienceDeletionEnabled) {
if (entitlementService.isExperienceDeletionEnabled(envDto.getAccountId())) {
environmentService.findEnvironmentById(envDto.getId()).ifPresent(environment -> environmentExperienceDeletionAction.execute(environment, environmentDeletionDto.isForceDelete()));
} else {
LOGGER.debug("Experience deletion is disabled by entitlement.");
}
} else {
LOGGER.debug("Experience deletion is disabled by Spring config.");
}
EnvDeleteEvent envDeleteEvent = getEnvDeleteEvent(environmentDeletionDto);
eventSender().sendEvent(envDeleteEvent, environmentDeletionDtoEvent.getHeaders());
} catch (Exception e) {
LOGGER.debug("Experience deletion failed with exception", e);
EnvClusterDeleteFailedEvent failedEvent = EnvClusterDeleteFailedEvent.builder().withEnvironmentID(envDto.getId()).withException(e).withResourceCrn(envDto.getResourceCrn()).withResourceName(envDto.getName()).build();
eventSender().sendEvent(failedEvent, environmentDeletionDtoEvent.getHeaders());
}
}
use of com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto in project cloudbreak by hortonworks.
the class DataLakeClustersDeleteHandler method accept.
@Override
public void accept(Event<EnvironmentDeletionDto> environmentDtoEvent) {
LOGGER.debug("Accepting DataLakeClustersDelete event");
EnvironmentDeletionDto environmentDeletionDto = environmentDtoEvent.getData();
EnvironmentDto environmentDto = environmentDeletionDto.getEnvironmentDto();
EnvDeleteEvent envDeleteEvent = getEnvDeleteEvent(environmentDeletionDto);
try {
PollingConfig pollingConfig = getPollingConfig();
EnvironmentView environment = environmentViewService.getById(environmentDto.getId());
sdxDeleteService.deleteSdxClustersForEnvironment(pollingConfig, environment, environmentDeletionDto.isForceDelete());
eventSender().sendEvent(envDeleteEvent, environmentDtoEvent.getHeaders());
} catch (ClientErrorException e) {
String message;
try {
message = e.getResponse().readEntity(ExceptionResponse.class).getMessage();
} catch (Exception exception) {
message = null;
}
EnvClusterDeleteFailedEvent failedEvent = EnvClusterDeleteFailedEvent.builder().withEnvironmentID(environmentDto.getId()).withException(new BadRequestException(message)).withResourceCrn(environmentDto.getResourceCrn()).withResourceName(environmentDto.getName()).withMessage(message).build();
eventSender().sendEvent(failedEvent, environmentDtoEvent.getHeaders());
} catch (Exception e) {
EnvClusterDeleteFailedEvent failedEvent = EnvClusterDeleteFailedEvent.builder().withEnvironmentID(environmentDto.getId()).withException(e).withResourceCrn(environmentDto.getResourceCrn()).withResourceName(environmentDto.getName()).build();
eventSender().sendEvent(failedEvent, environmentDtoEvent.getHeaders());
}
}
use of com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto in project cloudbreak by hortonworks.
the class EnvClustersDeleteActions method datalakeClustersDeleteAction.
@Bean(name = "DATALAKE_CLUSTERS_DELETE_STARTED_STATE")
public Action<?, ?> datalakeClustersDeleteAction() {
return new AbstractEnvClustersDeleteAction<>(EnvDeleteEvent.class) {
@Override
protected void doExecute(CommonContext context, EnvDeleteEvent payload, Map<Object, Object> variables) {
EnvironmentStatus environmentStatus = EnvironmentStatus.DATALAKE_CLUSTERS_DELETE_IN_PROGRESS;
ResourceEvent resourceEvent = ResourceEvent.ENVIRONMENT_DATALAKE_CLUSTERS_DELETION_STARTED;
EnvClustersDeleteState envClustersDeleteState = EnvClustersDeleteState.DATALAKE_CLUSTERS_DELETE_STARTED_STATE;
String logDeleteState = "Data Lake clusters";
EnvironmentDeletionDto envDto = commonUpdateEnvironmentAndNotify(context, payload, environmentStatus, resourceEvent, envClustersDeleteState, logDeleteState);
sendEvent(context, DELETE_DATALAKE_CLUSTERS_EVENT.selector(), envDto);
}
};
}
Aggregations