use of com.sequenceiq.common.model.FileSystemType in project cloudbreak by hortonworks.
the class CloudStorageConverter method requestToFileSystem.
public FileSystem requestToFileSystem(CloudStorageBase cloudStorageRequest) {
FileSystem fileSystem = new FileSystem();
fileSystem.setName(nameGenerator.generateName(FILESYSTEM));
FileSystemType fileSystemType = fileSystemResolver.determineFileSystemType(cloudStorageRequest);
fileSystem.setType(fileSystemType);
CloudStorage cloudStorage = new CloudStorage();
String s3GuardDynamoTableName = getS3GuardDynamoTableName(cloudStorageRequest);
cloudStorage.setS3GuardDynamoTableName(s3GuardDynamoTableName);
List<StorageLocation> storageLocations = cloudStorageRequest.getLocations().stream().map(this::storageLocationRequestToStorageLocation).collect(Collectors.toList());
cloudStorage.setLocations(storageLocations);
if (cloudStorageRequest.getIdentities() != null) {
List<CloudIdentity> cloudIdentities = cloudStorageRequest.getIdentities().stream().map(this::identityRequestToCloudIdentity).collect(Collectors.toList());
cloudStorage.setCloudIdentities(cloudIdentities);
}
cloudStorage.setAccountMapping(accountMappingRequestToAccountMapping(cloudStorageRequest.getAccountMapping()));
fileSystem.setCloudStorage(cloudStorage);
return fileSystem;
}
use of com.sequenceiq.common.model.FileSystemType in project cloudbreak by hortonworks.
the class CloudStorageConverter method requestToSpiFileSystem.
public SpiFileSystem requestToSpiFileSystem(CloudStorageBase cloudStorageRequest) {
List<CloudFileSystemView> cloudFileSystemViews = new ArrayList<>();
FileSystemType type = null;
if (cloudStorageRequest.getIdentities() != null && !cloudStorageRequest.getIdentities().isEmpty()) {
for (StorageIdentityBase storageIdentity : cloudStorageRequest.getIdentities()) {
type = getCloudFileSystemView(cloudStorageRequest, cloudFileSystemViews, storageIdentity);
}
}
validateCloudFileSystemViews(cloudFileSystemViews, type);
return new SpiFileSystem("", type, cloudFileSystemViews);
}
use of com.sequenceiq.common.model.FileSystemType in project cloudbreak by hortonworks.
the class AzureSetup method validateFileSystem.
@Override
public void validateFileSystem(CloudCredential credential, SpiFileSystem spiFileSystem) throws Exception {
FileSystemType fileSystemType = spiFileSystem.getType();
List<CloudFileSystemView> cloudFileSystems = spiFileSystem.getCloudFileSystems();
if (cloudFileSystems.size() > 2) {
throw new CloudConnectorException("More than 2 file systems (identities) are not yet supported on Azure!");
}
if (cloudFileSystems.isEmpty()) {
LOGGER.info("No filesystem was configured.");
return;
}
if (FileSystemType.ADLS.equals(fileSystemType)) {
validateAdlsFileSystem(credential, spiFileSystem);
} else if (FileSystemType.ADLS_GEN_2.equals(fileSystemType)) {
validateAdlsGen2FileSystem(spiFileSystem);
} else {
validateWasbFileSystem(spiFileSystem);
}
}
use of com.sequenceiq.common.model.FileSystemType in project cloudbreak by hortonworks.
the class CloudStorageConfigDetails method queryParameters.
public Set<ConfigQueryEntry> queryParameters(BlueprintTextProcessor blueprintTextProcessor, ConfigQueryEntries configQueryEntries, FileSystemConfigQueryObject request) {
Set<ConfigQueryEntry> filtered = new HashSet<>();
Map<String, Set<String>> componentsByHostGroup = blueprintTextProcessor.getComponentsByHostGroup();
boolean attachedCluster = request.isAttachedCluster();
for (Map.Entry<String, Set<String>> serviceHostgroupEntry : componentsByHostGroup.entrySet()) {
for (String service : serviceHostgroupEntry.getValue()) {
Set<ConfigQueryEntry> collectedEntries = configQueryEntries.getEntries().stream().filter(configQueryEntry -> configQueryEntry.getRelatedServices().stream().anyMatch(relatedService -> relatedService.equalsIgnoreCase(service))).filter(configQueryEntry -> {
if ((configQueryEntry.isRequiredForAttachedCluster() && attachedCluster) || !attachedCluster) {
return true;
}
return false;
}).filter(configQueryEntry -> configQueryEntry.getSupportedStorages().contains(request.getFileSystemType().toUpperCase())).collect(Collectors.toSet());
filtered.addAll(collectedEntries);
}
}
Set<ConfigQueryEntry> collectedEntries = configQueryEntries.getEntries().stream().filter(configQueryEntry -> blueprintDoesNotContainActual(configQueryEntry.getRelatedMissingServices(), componentsByHostGroup)).collect(Collectors.toSet());
filtered.addAll(collectedEntries);
String fileSystemTypeRequest = request.getFileSystemType();
FileSystemType fileSystemType = FileSystemType.valueOf(fileSystemTypeRequest);
String protocol = fileSystemType.getProtocol();
Map<String, Object> templateObject = getTemplateObject(request, protocol);
for (ConfigQueryEntry configQueryEntry : filtered) {
try {
boolean secure = request.isSecure();
configQueryEntry.setProtocol(secure ? protocol + "s" : protocol);
configQueryEntry.setSecure(secure);
configQueryEntry.setDefaultPath(generateConfigWithParameters(configQueryEntry.getDefaultPath(), fileSystemType, templateObject));
} catch (IOException e) {
}
}
filtered = filtered.stream().sorted(Comparator.comparing(ConfigQueryEntry::getPropertyName)).collect(Collectors.toCollection(LinkedHashSet::new));
return filtered;
}
use of com.sequenceiq.common.model.FileSystemType in project cloudbreak by hortonworks.
the class CloudStorageLocationValidator method validate.
public void validate(String storageLocation, Environment environment, ValidationResultBuilder resultBuilder) {
Optional<FileSystemType> fileSystemType = getFileSystemType(environment);
if (fileSystemType.isPresent() && FileSystemType.GCS.equals(fileSystemType.get()) && !storageLocation.startsWith("gs://")) {
throw new EnvironmentServiceException(String.format("The Google storage location [%s] should be a gs:// URL. %s", storageLocation, getDocLink(environment.getCloudPlatform())));
}
String bucketName = getBucketName(fileSystemType, storageLocation);
CloudCredential cloudCredential = credentialToCloudCredentialConverter.convert(environment.getCredential());
ObjectStorageMetadataRequest request = createObjectStorageMetadataRequest(environment.getCloudPlatform(), cloudCredential, bucketName);
ObjectStorageMetadataResponse response = ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> cloudProviderServicesV4Endopint.getObjectStorageMetaData(request));
resultBuilder.ifError(() -> response.getStatus() == ResponseStatus.OK && !environment.getLocation().equals(response.getRegion()), String.format("Object storage location [%s] of bucket '%s' must match environment location [%s].%s", response.getRegion(), bucketName, environment.getLocation(), getDocLink(environment.getCloudPlatform())));
}
Aggregations