Search in sources :

Example 6 with BackupRequest

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"));
}
Also used : BackupRequest(com.sequenceiq.common.api.backup.request.BackupRequest) AdlsGen2CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.AdlsGen2CloudStorageV1Parameters) Backup(com.sequenceiq.freeipa.api.model.Backup) Test(org.junit.jupiter.api.Test)

Example 7 with BackupRequest

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()));
    }
}
Also used : BackupRequest(com.sequenceiq.common.api.backup.request.BackupRequest) TelemetryRequest(com.sequenceiq.common.api.telemetry.request.TelemetryRequest) EnvironmentCloudStorageValidationRequest(com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentCloudStorageValidationRequest) ObjectStorageValidateResponse(com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageValidateResponse) EnvironmentServiceException(com.sequenceiq.environment.exception.EnvironmentServiceException) EnvironmentServiceException(com.sequenceiq.environment.exception.EnvironmentServiceException) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) WebApplicationException(javax.ws.rs.WebApplicationException)

Example 8 with BackupRequest

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;
}
Also used : BackupRequest(com.sequenceiq.common.api.backup.request.BackupRequest)

Example 9 with 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()));
}
Also used : BackupRequest(com.sequenceiq.common.api.backup.request.BackupRequest) S3CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters) Backup(com.sequenceiq.freeipa.api.model.Backup) Test(org.junit.jupiter.api.Test)

Example 10 with BackupRequest

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;
}
Also used : BackupRequest(com.sequenceiq.common.api.backup.request.BackupRequest) Backup(com.sequenceiq.freeipa.api.model.Backup)

Aggregations

BackupRequest (com.sequenceiq.common.api.backup.request.BackupRequest)10 Backup (com.sequenceiq.freeipa.api.model.Backup)6 Test (org.junit.jupiter.api.Test)5 S3CloudStorageV1Parameters (com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters)3 AdlsGen2CloudStorageV1Parameters (com.sequenceiq.common.api.cloudstorage.old.AdlsGen2CloudStorageV1Parameters)2 TelemetryRequest (com.sequenceiq.common.api.telemetry.request.TelemetryRequest)2 StackTags (com.sequenceiq.cloudbreak.cloud.model.StackTags)1 AwsInstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.instance.AwsInstanceTemplate)1 ObjectStorageValidateResponse (com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageValidateResponse)1 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 Json (com.sequenceiq.cloudbreak.common.json.Json)1 GcsCloudStorageV1Parameters (com.sequenceiq.common.api.cloudstorage.old.GcsCloudStorageV1Parameters)1 CloudwatchParams (com.sequenceiq.common.api.telemetry.model.CloudwatchParams)1 Features (com.sequenceiq.common.api.telemetry.model.Features)1 Logging (com.sequenceiq.common.api.telemetry.model.Logging)1 Telemetry (com.sequenceiq.common.api.telemetry.model.Telemetry)1 WorkloadAnalytics (com.sequenceiq.common.api.telemetry.model.WorkloadAnalytics)1 FeatureSetting (com.sequenceiq.common.api.type.FeatureSetting)1 EnvironmentCloudStorageValidationRequest (com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentCloudStorageValidationRequest)1 EnvironmentServiceException (com.sequenceiq.environment.exception.EnvironmentServiceException)1