Search in sources :

Example 11 with SdxCloudStorageRequest

use of com.sequenceiq.sdx.api.model.SdxCloudStorageRequest in project cloudbreak by hortonworks.

the class StorageValidationService method validateObjectStorage.

public ObjectStorageValidateResponse validateObjectStorage(String credentialCrn, SdxCloudStorageRequest sdxCloudStorageRequest, String blueprintName, String clusterName, String dataAccessRole, String rangerAuditRole) {
    CredentialResponse credentialResponse = environmentClientService.getCredentialByCrn(credentialCrn);
    String attributes = secretService.getByResponse(credentialResponse.getAttributes());
    CloudCredential cloudCredential = new CloudCredential(credentialResponse.getCrn(), credentialResponse.getName(), new Json(attributes).getMap(), credentialResponse.getAccountId(), credentialResponse.isVerifyPermissions());
    CloudStorageRequest cloudStorageRequest = cloudStorageManifester.initSdxCloudStorageRequest(credentialResponse.getCloudPlatform(), blueprintName, clusterName, sdxCloudStorageRequest);
    AccountMappingBase accountMapping = new AccountMappingBase();
    Map<String, String> userMapping = getUserMapping(dataAccessRole, rangerAuditRole);
    accountMapping.setUserMappings(userMapping);
    cloudStorageRequest.setAccountMapping(accountMapping);
    ObjectStorageValidateRequest objectStorageValidateRequest = ObjectStorageValidateRequest.builder().withCloudPlatform(credentialResponse.getCloudPlatform()).withCredential(cloudCredential).withCloudStorageRequest(cloudStorageRequest).build();
    return ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> cloudProviderServicesV4Endpoint.validateObjectStorage(objectStorageValidateRequest));
}
Also used : AccountMappingBase(com.sequenceiq.common.api.cloudstorage.AccountMappingBase) CloudStorageRequest(com.sequenceiq.common.api.cloudstorage.CloudStorageRequest) SdxCloudStorageRequest(com.sequenceiq.sdx.api.model.SdxCloudStorageRequest) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) CredentialResponse(com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse) Json(com.sequenceiq.cloudbreak.common.json.Json) ObjectStorageValidateRequest(com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageValidateRequest)

Example 12 with SdxCloudStorageRequest

use of com.sequenceiq.sdx.api.model.SdxCloudStorageRequest in project cloudbreak by hortonworks.

the class SdxServiceTest method withCloudStorage.

private void withCloudStorage(SdxClusterRequestBase sdxClusterRequest) {
    SdxCloudStorageRequest cloudStorage = new SdxCloudStorageRequest();
    cloudStorage.setFileSystemType(FileSystemType.S3);
    cloudStorage.setBaseLocation("s3a://some/dir/");
    cloudStorage.setS3(new S3CloudStorageV1Parameters());
    sdxClusterRequest.setCloudStorage(cloudStorage);
}
Also used : SdxCloudStorageRequest(com.sequenceiq.sdx.api.model.SdxCloudStorageRequest) S3CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters)

Example 13 with SdxCloudStorageRequest

use of com.sequenceiq.sdx.api.model.SdxCloudStorageRequest in project cloudbreak by hortonworks.

the class StorageValidationServiceTest method throwErrorWhenS3LocationInvalid.

@Test
public void throwErrorWhenS3LocationInvalid() {
    SdxCloudStorageRequest cloudStorageRequest = new SdxCloudStorageRequest();
    cloudStorageRequest.setBaseLocation("cloudbreakbucket/something");
    S3CloudStorageV1Parameters params = new S3CloudStorageV1Parameters();
    params.setInstanceProfile("instanceProfile");
    cloudStorageRequest.setS3(params);
    BadRequestException exception = Assertions.assertThrows(BadRequestException.class, () -> underTest.validateCloudStorage(CloudPlatform.AWS.toString(), cloudStorageRequest));
    assertEquals(exception.getMessage(), "AWS baselocation missing protocol. please specify s3a://");
}
Also used : SdxCloudStorageRequest(com.sequenceiq.sdx.api.model.SdxCloudStorageRequest) S3CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) Test(org.junit.jupiter.api.Test)

Example 14 with SdxCloudStorageRequest

use of com.sequenceiq.sdx.api.model.SdxCloudStorageRequest in project cloudbreak by hortonworks.

the class StorageValidationServiceTest method okWhenS3LocationIsValid.

@Test
public void okWhenS3LocationIsValid() {
    SdxCloudStorageRequest cloudStorageRequest = new SdxCloudStorageRequest();
    cloudStorageRequest.setBaseLocation("s3a://cloudbreakbucket/something");
    S3CloudStorageV1Parameters params = new S3CloudStorageV1Parameters();
    params.setInstanceProfile("instanceProfile");
    cloudStorageRequest.setS3(params);
    underTest.validateCloudStorage(CloudPlatform.AWS.toString(), cloudStorageRequest);
}
Also used : SdxCloudStorageRequest(com.sequenceiq.sdx.api.model.SdxCloudStorageRequest) S3CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters) Test(org.junit.jupiter.api.Test)

Example 15 with SdxCloudStorageRequest

use of com.sequenceiq.sdx.api.model.SdxCloudStorageRequest in project cloudbreak by hortonworks.

the class StorageValidationServiceTest method whenGcsConfiguredWithoutRoleShouldThrowException.

@Test
public void whenGcsConfiguredWithoutRoleShouldThrowException() {
    SdxCloudStorageRequest cloudStorageRequest = new SdxCloudStorageRequest();
    cloudStorageRequest.setBaseLocation("gs://example-path");
    cloudStorageRequest.setFileSystemType(FileSystemType.GCS);
    GcsCloudStorageV1Parameters gcs = new GcsCloudStorageV1Parameters();
    gcs.setServiceAccountEmail(null);
    cloudStorageRequest.setGcs(gcs);
    Assertions.assertThrows(BadRequestException.class, () -> underTest.validateCloudStorage("GCP", cloudStorageRequest));
}
Also used : SdxCloudStorageRequest(com.sequenceiq.sdx.api.model.SdxCloudStorageRequest) GcsCloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.GcsCloudStorageV1Parameters) Test(org.junit.jupiter.api.Test)

Aggregations

SdxCloudStorageRequest (com.sequenceiq.sdx.api.model.SdxCloudStorageRequest)20 Test (org.junit.jupiter.api.Test)16 S3CloudStorageV1Parameters (com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters)9 CloudStorageRequest (com.sequenceiq.common.api.cloudstorage.CloudStorageRequest)5 GcsCloudStorageV1Parameters (com.sequenceiq.common.api.cloudstorage.old.GcsCloudStorageV1Parameters)4 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)4 SdxClusterRequest (com.sequenceiq.sdx.api.model.SdxClusterRequest)4 FileSystemParameterV4Responses (com.sequenceiq.cloudbreak.api.endpoint.v4.filesystems.responses.FileSystemParameterV4Responses)3 ClusterV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request)3 StorageLocationBase (com.sequenceiq.common.api.cloudstorage.StorageLocationBase)3 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 FileSystemV4Endpoint (com.sequenceiq.cloudbreak.api.endpoint.v4.filesystems.FileSystemV4Endpoint)2 FileSystemParameterV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.filesystems.responses.FileSystemParameterV4Response)2 ThreadBasedUserCrnProvider (com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider)2 RegionAwareInternalCrnGenerator (com.sequenceiq.cloudbreak.auth.crn.RegionAwareInternalCrnGenerator)2 RegionAwareInternalCrnGeneratorFactory (com.sequenceiq.cloudbreak.auth.crn.RegionAwareInternalCrnGeneratorFactory)2 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)2 LoggingResponse (com.sequenceiq.common.api.telemetry.response.LoggingResponse)2 TelemetryResponse (com.sequenceiq.common.api.telemetry.response.TelemetryResponse)2