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));
}
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);
}
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://");
}
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);
}
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));
}
Aggregations