use of com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudFileSystemView in project cloudbreak by hortonworks.
the class AzureIDBrokerObjectStorageValidator method validateObjectStorage.
public ValidationResult validateObjectStorage(AzureClient client, SpiFileSystem spiFileSystem, String logsLocationBase, String backupLocationBase, String singleResourceGroupName, ValidationResultBuilder resultBuilder) {
LOGGER.info("Validating Azure identities...");
List<CloudFileSystemView> cloudFileSystems = spiFileSystem.getCloudFileSystems();
validateHierarchicalNamespace(client, spiFileSystem, logsLocationBase, backupLocationBase, resultBuilder);
if (Objects.nonNull(cloudFileSystems) && cloudFileSystems.size() > 0) {
for (CloudFileSystemView cloudFileSystemView : cloudFileSystems) {
CloudAdlsGen2View cloudFileSystem = (CloudAdlsGen2View) cloudFileSystemView;
String managedIdentityId = cloudFileSystem.getManagedIdentity();
Identity identity = client.getIdentityById(managedIdentityId);
CloudIdentityType cloudIdentityType = cloudFileSystem.getCloudIdentityType();
if (identity != null) {
if (ID_BROKER.equals(cloudIdentityType)) {
List<RoleAssignmentInner> roleAssignments;
Optional<ResourceGroup> singleResourceGroup;
if (singleResourceGroupName != null) {
ResourceGroup resourceGroup = client.getResourceGroup(singleResourceGroupName);
roleAssignments = client.listRoleAssignmentsByScopeInner(resourceGroup.id());
singleResourceGroup = Optional.of(resourceGroup);
} else {
roleAssignments = client.listRoleAssignments();
singleResourceGroup = Optional.empty();
}
validateIDBroker(client, roleAssignments, identity, cloudFileSystem, singleResourceGroup, resultBuilder);
} else if (LOG.equals(cloudIdentityType)) {
validateLog(client, identity, logsLocationBase, resultBuilder);
}
} else {
addError(resultBuilder, String.format("%s Identity with id %s does not exist in the given Azure subscription. %s", getIdentityType(cloudIdentityType), managedIdentityId, getAdviceMessage(IDENTITY, cloudIdentityType)));
}
}
}
return resultBuilder.build();
}
use of com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudFileSystemView in project cloudbreak by hortonworks.
the class GcpServiceAccountObjectStorageValidator method validateObjectStorage.
public ValidationResultBuilder validateObjectStorage(CloudCredential cloudCredential, SpiFileSystem spiFileSystem, ValidationResultBuilder resultBuilder) throws IOException {
LOGGER.info("Validating Gcp identities...");
Iam iam = gcpIamFactory.buildIam(cloudCredential);
List<CloudFileSystemView> cloudFileSystems = spiFileSystem.getCloudFileSystems();
if (Objects.nonNull(cloudFileSystems) && cloudFileSystems.size() > 0) {
String projectId = gcpStackUtil.getProjectId(cloudCredential);
Set<String> serviceAccountEmailsToFind = cloudFileSystems.stream().map(cloudFileSystemView -> ((CloudGcsView) cloudFileSystemView).getServiceAccountEmail()).collect(Collectors.toSet());
Iam.Projects.ServiceAccounts.List listServiceAccountEmailsRequest = iam.projects().serviceAccounts().list("projects/" + projectId).setPageSize(DEFAULT_PAGE_SIZE);
ListServiceAccountsResponse response;
do {
response = listServiceAccountEmailsRequest.execute();
response.getAccounts().forEach(serviceAccount -> serviceAccountEmailsToFind.remove(serviceAccount.getEmail()));
listServiceAccountEmailsRequest.setPageToken(response.getNextPageToken());
} while (response.getNextPageToken() != null && !serviceAccountEmailsToFind.isEmpty());
if (!serviceAccountEmailsToFind.isEmpty()) {
addError(resultBuilder, String.format("Service Account with email(s) '%s' could not be found in the configured Google Cloud project '%s'.", String.join(", ", serviceAccountEmailsToFind), projectId));
}
}
return resultBuilder;
}
use of com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudFileSystemView in project cloudbreak by hortonworks.
the class CloudStorageConverter method getCloudFileSystemView.
private FileSystemType getCloudFileSystemView(CloudStorageBase cloudStorageRequest, List<CloudFileSystemView> cloudFileSystemViews, StorageIdentityBase storageIdentity) {
FileSystemType type = null;
if (storageIdentity != null) {
CloudFileSystemView cloudFileSystemView = null;
if (storageIdentity.getAdls() != null) {
cloudFileSystemView = cloudStorageParametersConverter.adlsToCloudView(storageIdentity);
type = FileSystemType.ADLS;
} else if (storageIdentity.getGcs() != null) {
cloudFileSystemView = cloudStorageParametersConverter.gcsToCloudView(storageIdentity);
type = FileSystemType.GCS;
} else if (storageIdentity.getS3() != null) {
cloudFileSystemView = cloudStorageParametersConverter.s3ToCloudView(storageIdentity);
setDynamoDBTableName((CloudS3View) cloudFileSystemView, cloudStorageRequest);
type = FileSystemType.S3;
} else if (storageIdentity.getWasb() != null) {
cloudFileSystemView = cloudStorageParametersConverter.wasbToCloudView(storageIdentity);
type = FileSystemType.WASB;
} else if (storageIdentity.getAdlsGen2() != null) {
cloudFileSystemView = cloudStorageParametersConverter.adlsGen2ToCloudView(storageIdentity);
type = FileSystemType.ADLS_GEN_2;
}
if (cloudFileSystemView != null) {
cloudFileSystemView.setAccountMapping(cloudStorageRequest.getAccountMapping());
cloudFileSystemView.setLocations(cloudStorageRequest.getLocations());
cloudFileSystemViews.add(cloudFileSystemView);
}
}
return type;
}
use of com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudFileSystemView in project cloudbreak by hortonworks.
the class CloudFileSystemViewProviderTest method testBuild.
@Test
public void testBuild() {
List<CloudIdentity> cloudIdentities = getCloudIdentities();
CloudStorage cloudStorage = getCloudStorage(cloudIdentities);
FileSystem fileSystem = getFileSystem(cloudStorage);
Map<String, Set<String>> componentsByHostGroup = new HashMap<>();
InstanceGroup idBrokerGroup = getIdBrokerGroup(componentsByHostGroup);
InstanceGroup computeGroup = new InstanceGroup();
computeGroup.setGroupName(COMPUTE_INSTANCE_GROUP_NAME);
componentsByHostGroup.put(COMPUTE_INSTANCE_GROUP_NAME, new HashSet<>());
Optional<CloudFileSystemView> idBrokerGroupResult = cloudFileSystemViewProvider.getCloudFileSystemView(fileSystem, componentsByHostGroup, idBrokerGroup);
Assertions.assertEquals(idBrokerGroupResult.get().getCloudIdentityType(), CloudIdentityType.ID_BROKER);
Optional<CloudFileSystemView> computeGroupResult = cloudFileSystemViewProvider.getCloudFileSystemView(fileSystem, componentsByHostGroup, computeGroup);
Assertions.assertEquals(computeGroupResult.get().getCloudIdentityType(), CloudIdentityType.LOG);
Mockito.verify(instanceGroupService, Mockito.times(2)).setCloudIdentityType(any(), any());
}
use of com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudFileSystemView in project cloudbreak by hortonworks.
the class CloudFileSystemViewProviderTest method testBuildWithNullComponents.
@Test
public void testBuildWithNullComponents() {
List<CloudIdentity> cloudIdentities = getCloudIdentities();
CloudStorage cloudStorage = getCloudStorage(cloudIdentities);
FileSystem fileSystem = getFileSystem(cloudStorage);
Map<String, Set<String>> componentsByHostGroup = new HashMap<>();
InstanceGroup idBrokerGroup = getIdBrokerGroup(componentsByHostGroup);
InstanceGroup computeGroup = new InstanceGroup();
computeGroup.setGroupName(COMPUTE_INSTANCE_GROUP_NAME);
componentsByHostGroup.put(COMPUTE_INSTANCE_GROUP_NAME, null);
Optional<CloudFileSystemView> idBrokerGroupResult = cloudFileSystemViewProvider.getCloudFileSystemView(fileSystem, componentsByHostGroup, idBrokerGroup);
Assertions.assertEquals(idBrokerGroupResult.get().getCloudIdentityType(), CloudIdentityType.ID_BROKER);
Optional<CloudFileSystemView> computeGroupResult = cloudFileSystemViewProvider.getCloudFileSystemView(fileSystem, componentsByHostGroup, computeGroup);
Assertions.assertEquals(computeGroupResult.get().getCloudIdentityType(), CloudIdentityType.LOG);
}
Aggregations