use of com.sequenceiq.environment.environment.domain.EnvironmentView in project cloudbreak by hortonworks.
the class EnvironmentDeletionService method deleteByNameAndAccountId.
public EnvironmentViewDto deleteByNameAndAccountId(String environmentName, String accountId, String actualUserCrn, boolean cascading, boolean forced) {
EnvironmentView environment = environmentViewService.getByNameAndAccountId(environmentName, accountId);
MDCBuilder.buildMdcContext(environment);
LOGGER.debug(String.format("Deleting environment [name: %s]", environment.getName()));
delete(environment, actualUserCrn, cascading, forced);
return environmentDtoConverter.environmentViewToViewDto(environment);
}
use of com.sequenceiq.environment.environment.domain.EnvironmentView 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.domain.EnvironmentView in project cloudbreak by hortonworks.
the class AwsEnvironmentParametersConverterTest method convertToDtoTest.
@Test
void convertToDtoTest() {
EnvironmentView environmentView = ENVIRONMENT_VIEW;
AwsParameters parameters = new AwsParameters();
parameters.setAccountId(ACCOUNT_ID);
parameters.setEnvironment(environmentView);
parameters.setId(ID);
parameters.setName(ENV_NAME);
parameters.setS3guardTableName(TABLE_NAME);
parameters.setS3guardTableCreation(S3GuardTableCreation.CREATE_NEW);
parameters.setFreeIpaSpotPercentage(null);
parameters.setFreeIpaSpotMaxPrice(0.9);
parameters.setEncryptionKeyArn(ENCRYPTION_KEY_ARN);
ParametersDto result = underTest.convertToDto(parameters);
assertEquals(ACCOUNT_ID, result.getAccountId());
assertEquals(ID, result.getId());
assertEquals(ENV_NAME, result.getName());
assertEquals(TABLE_NAME, result.getAwsParametersDto().getS3GuardTableName());
assertEquals(S3GuardTableCreation.CREATE_NEW, result.getAwsParametersDto().getDynamoDbTableCreation());
assertEquals(0, result.getAwsParametersDto().getFreeIpaSpotPercentage());
assertEquals(0.9, result.getAwsParametersDto().getFreeIpaSpotMaxPrice());
assertEquals(ENCRYPTION_KEY_ARN, result.getAwsParametersDto().getAwsDiskEncryptionParametersDto().getEncryptionKeyArn());
}
use of com.sequenceiq.environment.environment.domain.EnvironmentView in project cloudbreak by hortonworks.
the class AzureEnvironmentParametersConverterTest method convertToDtoTest.
@Test
void convertToDtoTest() {
EnvironmentView environmentView = ENVIRONMENT_VIEW;
AzureParameters parameters = new AzureParameters();
parameters.setAccountId(ACCOUNT_ID);
parameters.setEnvironment(environmentView);
parameters.setId(ID);
parameters.setName(ENV_NAME);
parameters.setEncryptionKeyUrl(KEY_URL);
parameters.setDiskEncryptionSetId("DummyDesId");
parameters.setEncryptionKeyResourceGroupName(KEY_RESOURCE_GROUP_NAME);
ParametersDto result = underTest.convertToDto(parameters);
assertEquals(ACCOUNT_ID, result.getAccountId());
assertEquals(ID, result.getId());
assertEquals(ENV_NAME, result.getName());
assertEquals(KEY_URL, result.getAzureParametersDto().getAzureResourceEncryptionParametersDto().getEncryptionKeyUrl());
assertEquals("DummyDesId", result.getAzureParametersDto().getAzureResourceEncryptionParametersDto().getDiskEncryptionSetId());
assertEquals(KEY_RESOURCE_GROUP_NAME, result.getAzureParametersDto().getAzureResourceEncryptionParametersDto().getEncryptionKeyResourceGroupName());
}
Aggregations