use of com.sequenceiq.common.api.backup.request.BackupRequest in project cloudbreak by hortonworks.
the class BackupConverterTest method testConvertFromAzureRequest.
@Test
public void testConvertFromAzureRequest() {
// GIVEN
BackupRequest backupRequest = new BackupRequest();
AdlsGen2CloudStorageV1Parameters adlsGen2CloudStorageV1Parameters = new AdlsGen2CloudStorageV1Parameters();
adlsGen2CloudStorageV1Parameters.setAccountKey("someaccount");
backupRequest.setAdlsGen2(adlsGen2CloudStorageV1Parameters);
backupRequest.setStorageLocation("abfs://mybucket@someaccount");
// WHEN
Backup result = underTest.convert(backupRequest);
// THEN
assertThat(result.getStorageLocation(), is("abfs://mybucket@someaccount"));
}
use of com.sequenceiq.common.api.backup.request.BackupRequest in project cloudbreak by hortonworks.
the class EnvironmentValidationHandler method validateCloudStorage.
private void validateCloudStorage(Event<EnvironmentValidationDto> environmentDtoEvent, EnvironmentDto environmentDto) {
EnvironmentCloudStorageValidationRequest cloudStorageValidationRequest = new EnvironmentCloudStorageValidationRequest();
cloudStorageValidationRequest.setCredentialCrn(environmentDto.getCredential().getResourceCrn());
TelemetryRequest telemetryRequest = telemetryApiConverter.convertToRequest(environmentDto.getTelemetry());
BackupRequest backupRequest = backupConverter.convertToRequest(environmentDto.getBackup());
cloudStorageValidationRequest.setTelemetry(telemetryRequest);
cloudStorageValidationRequest.setBackup(backupRequest);
ObjectStorageValidateResponse response = null;
try {
response = cloudStorageValidator.validateCloudStorage(environmentDto.getAccountId(), cloudStorageValidationRequest);
} catch (Exception e) {
String message = String.format("Error occured during object storage validation, validation skipped. Error: %s", e.getMessage());
LOGGER.warn(message);
eventSenderService.sendEventAndNotification(environmentDto, ThreadBasedUserCrnProvider.getUserCrn(), ResourceEvent.ENVIRONMENT_VALIDATION_FAILED_AND_SKIPPED, Set.of(e.getMessage()));
}
if (response != null && ResponseStatus.ERROR.equals(response.getStatus())) {
throw new EnvironmentServiceException(response.getError());
}
if (response != null && ResponseStatus.OK.equals(response.getStatus()) && isNotBlank(response.getError())) {
eventSenderService.sendEventAndNotification(environmentDto, ThreadBasedUserCrnProvider.getUserCrn(), ResourceEvent.ENVIRONMENT_VALIDATION_FAILED_AND_SKIPPED, Set.of(response.getError()));
}
}
use of com.sequenceiq.common.api.backup.request.BackupRequest in project cloudbreak by hortonworks.
the class BackupConverter method createBackupRequestFromEnvSource.
private BackupRequest createBackupRequestFromEnvSource(EnvironmentBackup backup) {
BackupRequest backupRequest = null;
if (backup != null) {
backupRequest = new BackupRequest();
backupRequest.setStorageLocation(backup.getStorageLocation());
backupRequest.setS3(convertS3(backup.getS3()));
backupRequest.setAdlsGen2(convertAdlsV2(backup.getAdlsGen2()));
backupRequest.setGcs(convertGcs(backup.getGcs()));
backupRequest.setCloudwatch(BackupCloudwatchParams.copy(backup.getCloudwatch()));
}
return backupRequest;
}
use of com.sequenceiq.common.api.backup.request.BackupRequest in project cloudbreak by hortonworks.
the class BackupConverterTest method testConvertFromWhenfreeIpaBackupDisabled.
@Test
public void testConvertFromWhenfreeIpaBackupDisabled() {
// GIVEN
BackupRequest backupRequest = new BackupRequest();
backupRequest.setS3(new S3CloudStorageV1Parameters());
backupRequest.setStorageLocation("s3://mybucket");
// WHEN
Backup result = underTestBackupDisabled.convert(backupRequest);
// THEN
assertThat(result, is(IsNull.nullValue()));
}
use of com.sequenceiq.common.api.backup.request.BackupRequest in project cloudbreak by hortonworks.
the class StackToCreateFreeIpaRequestConverter method getBackup.
private BackupRequest getBackup(Stack stack) {
BackupRequest request = null;
Backup backup = stack.getBackup();
if (backup != null) {
request = new BackupRequest();
request.setStorageLocation(getBackupLocation(stack, backup.getStorageLocation()));
request.setS3(backup.getS3());
request.setAdlsGen2(backup.getAdlsGen2());
request.setGcs(backup.getGcs());
}
LOGGER.debug("Created backup request {} from backup {}", request, backup);
return request;
}
Aggregations