use of com.sequenceiq.common.model.FileSystemType in project cloudbreak by hortonworks.
the class CloudStorageLocationValidator method validateBackup.
public void validateBackup(String storageLocation, Environment environment, ValidationResultBuilder resultBuilder) {
Optional<FileSystemType> fileSystemType = getBackupFileSystemType(environment);
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())));
}
use of com.sequenceiq.common.model.FileSystemType in project cloudbreak by hortonworks.
the class CloudStorageDecorator method updateCloudStorageLocations.
public CloudStorageRequest updateCloudStorageLocations(String blueprintName, String clusterName, CloudStorageRequest request, List<SdxClusterResponse> datalakes) {
if (hasDatalake(datalakes)) {
Pair<String, FileSystemType> sdxBaseLocationFileSystemType = getBaseLocationWithFileSystemTypeFromSdx(datalakes.get(0));
Set<ConfigQueryEntry> recommendations = getRecommendations(blueprintName, clusterName, sdxBaseLocationFileSystemType);
if (storageLocationsNotDefined(request)) {
if (request == null) {
request = new CloudStorageRequest();
}
if (request.getLocations() == null) {
request.setLocations(new ArrayList<>());
}
for (ConfigQueryEntry recommendation : recommendations) {
request.getLocations().add(createStorageLocationBaseByTypeAndDefaultPath(recommendation.getType(), recommendation.getDefaultPath()));
}
} else {
Map<CloudStorageCdpService, String> templatedLocations = findLocationsThatContainsTemplatedValue(request);
if (!templatedLocations.isEmpty()) {
LOGGER.info("Cloud storage location(s) has found with template placeholder(s). About to replace them with the recommended one(s).");
Set<ConfigQueryEntry> filtered = filterConfigsWithTemplatePlaceholder(request, recommendations);
Set<ConfigQueryEntry> replaced = queryParameters(filtered, blueprintName, clusterName, sdxBaseLocationFileSystemType);
replaceTemplatedLocationValuesWithFilledValues(request, replaced, templatedLocations);
}
}
}
return request;
}
use of com.sequenceiq.common.model.FileSystemType in project cloudbreak by hortonworks.
the class AzureCloudProvider method getFileSystemType.
@Override
public FileSystemType getFileSystemType() {
AdlsCloudStorageV1Parameters adlsCloudStorageV1Parameters = new AdlsCloudStorageV1Parameters();
AdlsGen2CloudStorageV1Parameters adlsGen2CloudStorageV1Parameters = new AdlsGen2CloudStorageV1Parameters();
WasbCloudStorageV1Parameters wasbCloudStorageV1Parameters = new WasbCloudStorageV1Parameters();
FileSystemType fileSystemType;
switch(azureProperties.getCloudStorage().getFileSystemType()) {
case "WASB_INTEGRATED":
case "WASB":
fileSystemType = wasbCloudStorageV1Parameters.getType();
break;
case "ADLS":
fileSystemType = adlsCloudStorageV1Parameters.getType();
break;
case "ADLS_GEN_2":
fileSystemType = adlsGen2CloudStorageV1Parameters.getType();
break;
default:
LOGGER.warn("The given {} File System Type is not in the list of Azure file system types. So we use the default one; {}", azureProperties.getCloudStorage().getFileSystemType(), "ADLS_GEN_2");
fileSystemType = adlsGen2CloudStorageV1Parameters.getType();
break;
}
return fileSystemType;
}
use of com.sequenceiq.common.model.FileSystemType 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.common.model.FileSystemType in project cloudbreak by hortonworks.
the class CloudStorageConverter method requestToAdditionalFileSystem.
public FileSystem requestToAdditionalFileSystem(CloudStorageBase cloudStorageRequest) {
FileSystem fileSystem = new FileSystem();
AwsEfsParameters efsParameters = cloudStorageRequest.getAws() == null ? null : cloudStorageRequest.getAws().getEfsParameters();
if (efsParameters == null || StringUtils.isEmpty(efsParameters.getName())) {
return null;
}
fileSystem.setName(efsParameters.getName());
FileSystemType fileSystemType = FileSystemType.EFS;
fileSystem.setType(fileSystemType);
Map<String, Object> configurations = new HashMap<>();
configurations.put(CloudEfsConfiguration.KEY_BACKUP_POLICY_STATUS, efsParameters.getBackupPolicyStatus());
configurations.put(CloudEfsConfiguration.KEY_ENCRYPTED, efsParameters.getEncrypted());
configurations.put(CloudEfsConfiguration.KEY_FILESYSTEM_POLICY, efsParameters.getFileSystemPolicy());
configurations.put(CloudEfsConfiguration.KEY_FILESYSTEM_TAGS, efsParameters.getFileSystemTags());
configurations.put(CloudEfsConfiguration.KEY_KMSKEYID, efsParameters.getKmsKeyId());
configurations.put(CloudEfsConfiguration.KEY_LIFECYCLE_POLICIES, efsParameters.getLifeCyclePolicies());
configurations.put(CloudEfsConfiguration.KEY_PERFORMANCE_MODE, efsParameters.getPerformanceMode());
configurations.put(CloudEfsConfiguration.KEY_PROVISIONED_THROUGHPUT_INMIBPS, efsParameters.getProvisionedThroughputInMibps());
configurations.put(CloudEfsConfiguration.KEY_THROUGHPUT_MODE, efsParameters.getThroughputMode());
String configString;
try {
configString = JsonUtil.writeValueAsString(configurations);
} catch (JsonProcessingException ignored) {
configString = configurations.toString();
}
fileSystem.setConfigurations(new Json(configString));
CloudStorage cloudStorage = new CloudStorage();
if (cloudStorageRequest.getIdentities() != null) {
Optional<CloudIdentity> cloudIdentity = cloudStorageRequest.getIdentities().stream().map(this::identityRequestToCloudIdentity).filter(currCloudIdentity -> currCloudIdentity.getEfsIdentity() != null).findFirst();
if (cloudIdentity != null && cloudIdentity.get() != null) {
cloudStorage.setCloudIdentities(List.of(cloudIdentity.get()));
}
}
cloudStorage.setAccountMapping(accountMappingRequestToAccountMapping(cloudStorageRequest.getAccountMapping()));
fileSystem.setCloudStorage(cloudStorage);
return fileSystem;
}
Aggregations