use of com.sequenceiq.common.api.cloudstorage.StorageLocationBase in project cloudbreak by hortonworks.
the class CloudStorageConverter method storageLocationToRequest.
private StorageLocationBase storageLocationToRequest(StorageLocation storageLocation) {
StorageLocationBase storageLocationRequest = new StorageLocationBase();
storageLocationRequest.setType(storageLocation.getType());
storageLocationRequest.setValue(storageLocation.getValue());
return storageLocationRequest;
}
use of com.sequenceiq.common.api.cloudstorage.StorageLocationBase in project cloudbreak by hortonworks.
the class CloudStorageConverter method fileSystemToRequest.
public CloudStorageRequest fileSystemToRequest(FileSystem fileSystem) {
CloudStorageRequest result = new CloudStorageRequest();
CloudStorage cloudStorage = fileSystem.getCloudStorage();
if (cloudStorage != null) {
List<StorageIdentityBase> storageIdentityRequests = cloudStorage.getCloudIdentities().stream().map(this::cloudIdentityToRequest).collect(Collectors.toList());
result.setIdentities(storageIdentityRequests);
List<StorageLocationBase> storageLocationRequests = cloudStorage.getLocations().stream().map(this::storageLocationToRequest).collect(Collectors.toList());
result.setLocations(storageLocationRequests);
NullUtil.doIfNotNull(cloudStorage.getS3GuardDynamoTableName(), tableName -> {
AwsStorageParameters awsStorageParameters = new AwsStorageParameters();
S3Guard s3Guard = new S3Guard();
s3Guard.setDynamoTableName(tableName);
awsStorageParameters.setS3Guard(s3Guard);
result.setAws(awsStorageParameters);
});
result.setAccountMapping(accountMappingToAccountMappingRequest(cloudStorage.getAccountMapping()));
}
return result;
}
use of com.sequenceiq.common.api.cloudstorage.StorageLocationBase in project cloudbreak by hortonworks.
the class CloudStorageConverter method fileSystemToResponse.
public CloudStorageResponse fileSystemToResponse(FileSystem fileSystem) {
CloudStorageResponse response = new CloudStorageResponse();
CloudStorage cloudStorage = fileSystem.getCloudStorage();
if (cloudStorage != null) {
if (StringUtils.isNotEmpty(cloudStorage.getS3GuardDynamoTableName())) {
AwsStorageParameters awsStorageParameters = new AwsStorageParameters();
S3Guard s3Guard = new S3Guard();
s3Guard.setDynamoTableName(cloudStorage.getS3GuardDynamoTableName());
awsStorageParameters.setS3Guard(s3Guard);
response.setAws(awsStorageParameters);
}
List<StorageIdentityBase> storageIdentities = cloudStorage.getCloudIdentities().stream().map(this::cloudIdentityToStorageIdentityBase).collect(Collectors.toList());
response.setIdentities(storageIdentities);
List<StorageLocationBase> storageLocations = cloudStorage.getLocations().stream().map(storageLocation -> {
StorageLocationBase storageLocationBase = new StorageLocationBase();
storageLocationBase.setType(storageLocation.getType());
storageLocationBase.setValue(storageLocation.getValue());
return storageLocationBase;
}).collect(Collectors.toList());
response.setLocations(storageLocations);
response.setAccountMapping(accountMappingToAccountMappingRequest(cloudStorage.getAccountMapping()));
}
return response;
}
use of com.sequenceiq.common.api.cloudstorage.StorageLocationBase in project cloudbreak by hortonworks.
the class AwsDataAccessRolePermissionValidatorTest method testGetPolicyJsonReplacements.
@Test
@Override
public void testGetPolicyJsonReplacements() {
String storageLocationBaseStr = "bucket/cluster";
String bucket = "bucket";
String dynamodbTableName = "tableName";
Map<String, String> expectedPolicyJsonReplacements = Map.ofEntries(Map.entry("${ARN_PARTITION}", "aws"), Map.entry("${STORAGE_LOCATION_BASE}", storageLocationBaseStr), Map.entry("${DATALAKE_BUCKET}", bucket), Map.entry("${DYNAMODB_TABLE_NAME}", dynamodbTableName));
StorageLocationBase storageLocationBase = new StorageLocationBase();
storageLocationBase.setValue(storageLocationBaseStr);
CloudS3View cloudFileSystem = new CloudS3View(CloudIdentityType.ID_BROKER);
cloudFileSystem.setS3GuardDynamoTableName(dynamodbTableName);
cloudFileSystem.setInstanceProfile("arn:aws:iam::11111111111:instance-profile/instanceprofile");
Map<String, String> policyJsonReplacements = awsDataAccessRolePermissionValidator.getPolicyJsonReplacements(storageLocationBase, cloudFileSystem);
assertThat(policyJsonReplacements).isEqualTo(expectedPolicyJsonReplacements);
}
use of com.sequenceiq.common.api.cloudstorage.StorageLocationBase in project cloudbreak by hortonworks.
the class AwsDataAccessRolePermissionValidatorTest method testCollectPolicies.
@Test
@Override
public void testCollectPolicies() {
ArgumentCaptor<Map<String, String>> replacementsCaptor = ArgumentCaptor.forClass(Map.class);
when(awsIamService.getPolicy(eq("policyFile1"), replacementsCaptor.capture())).thenReturn(new Policy());
CloudS3View cloudFileSystem = new CloudS3View(CloudIdentityType.ID_BROKER);
StorageLocationBase storageLocationBase1 = new StorageLocationBase();
storageLocationBase1.setType(CloudStorageCdpService.HIVE_METASTORE_WAREHOUSE);
storageLocationBase1.setValue("s3a://bucket/cluster/hive/metadata");
cloudFileSystem.setLocations(List.of(storageLocationBase1));
cloudFileSystem.setInstanceProfile("arn:aws:iam::11111111111:instance-profile/instanceprofile");
List<Policy> policies = getValidator().collectPolicies(cloudFileSystem, List.of("policyFile1"));
assertEquals(1, policies.size());
Map<String, String> replacements = replacementsCaptor.getValue();
assertEquals("bucket/cluster/hive/metadata", replacements.get("${STORAGE_LOCATION_BASE}"));
assertEquals("bucket", replacements.get("${DATALAKE_BUCKET}"));
assertEquals("", replacements.get("${DYNAMODB_TABLE_NAME}"));
}
Aggregations