Search in sources :

Example 6 with FileSystemType

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())));
}
Also used : ObjectStorageMetadataResponse(com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageMetadataResponse) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) FileSystemType(com.sequenceiq.common.model.FileSystemType) ObjectStorageMetadataRequest(com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageMetadataRequest)

Example 7 with FileSystemType

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;
}
Also used : ConfigQueryEntry(com.sequenceiq.common.api.cloudstorage.query.ConfigQueryEntry) CloudStorageCdpService(com.sequenceiq.common.model.CloudStorageCdpService) CloudStorageRequest(com.sequenceiq.common.api.cloudstorage.CloudStorageRequest) FileSystemType(com.sequenceiq.common.model.FileSystemType)

Example 8 with FileSystemType

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;
}
Also used : AdlsGen2CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.AdlsGen2CloudStorageV1Parameters) WasbCloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.WasbCloudStorageV1Parameters) AdlsCloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.AdlsCloudStorageV1Parameters) FileSystemType(com.sequenceiq.common.model.FileSystemType)

Example 9 with 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;
}
Also used : FileSystemType(com.sequenceiq.common.model.FileSystemType) CloudFileSystemView(com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudFileSystemView)

Example 10 with FileSystemType

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;
}
Also used : EfsIdentity(com.sequenceiq.cloudbreak.domain.cloudstorage.EfsIdentity) AwsStorageParameters(com.sequenceiq.common.api.cloudstorage.AwsStorageParameters) AwsEfsParameters(com.sequenceiq.common.api.cloudstorage.AwsEfsParameters) SpiFileSystem(com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem) HashMap(java.util.HashMap) JsonUtil(com.sequenceiq.cloudbreak.common.json.JsonUtil) GcsCloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.GcsCloudStorageV1Parameters) StringUtils(org.apache.commons.lang3.StringUtils) AccountMapping(com.sequenceiq.cloudbreak.domain.cloudstorage.AccountMapping) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) AccountMappingBase(com.sequenceiq.common.api.cloudstorage.AccountMappingBase) CloudS3View(com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudS3View) CloudIdentity(com.sequenceiq.cloudbreak.domain.cloudstorage.CloudIdentity) Map(java.util.Map) AdlsGen2Identity(com.sequenceiq.cloudbreak.domain.cloudstorage.AdlsGen2Identity) GcsIdentity(com.sequenceiq.cloudbreak.domain.cloudstorage.GcsIdentity) CloudEfsConfiguration(com.sequenceiq.cloudbreak.cloud.model.filesystem.efs.CloudEfsConfiguration) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) CloudStorageBase(com.sequenceiq.common.api.cloudstorage.CloudStorageBase) CloudStorageCdpService(com.sequenceiq.common.model.CloudStorageCdpService) StorageIdentityBase(com.sequenceiq.common.api.cloudstorage.StorageIdentityBase) StorageLocationBase(com.sequenceiq.common.api.cloudstorage.StorageLocationBase) NullUtil(com.sequenceiq.cloudbreak.util.NullUtil) CloudStorageResponse(com.sequenceiq.common.api.cloudstorage.CloudStorageResponse) S3CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) CloudFileSystemView(com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudFileSystemView) Collectors(java.util.stream.Collectors) Json(com.sequenceiq.cloudbreak.common.json.Json) S3Identity(com.sequenceiq.cloudbreak.domain.cloudstorage.S3Identity) StorageLocation(com.sequenceiq.cloudbreak.domain.cloudstorage.StorageLocation) List(java.util.List) Component(org.springframework.stereotype.Component) WasbIdentity(com.sequenceiq.cloudbreak.domain.cloudstorage.WasbIdentity) WasbCloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.WasbCloudStorageV1Parameters) MissingResourceNameGenerator(com.sequenceiq.cloudbreak.common.converter.MissingResourceNameGenerator) FileSystem(com.sequenceiq.cloudbreak.domain.FileSystem) CloudStorageRequest(com.sequenceiq.common.api.cloudstorage.CloudStorageRequest) FileSystemType(com.sequenceiq.common.model.FileSystemType) AdlsGen2CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.AdlsGen2CloudStorageV1Parameters) Optional(java.util.Optional) FileSystemResolver(com.sequenceiq.cloudbreak.service.filesystem.FileSystemResolver) S3Guard(com.sequenceiq.common.api.cloudstorage.S3Guard) FILESYSTEM(com.sequenceiq.cloudbreak.common.type.APIResourceType.FILESYSTEM) CloudStorage(com.sequenceiq.cloudbreak.domain.cloudstorage.CloudStorage) HashMap(java.util.HashMap) CloudIdentity(com.sequenceiq.cloudbreak.domain.cloudstorage.CloudIdentity) Json(com.sequenceiq.cloudbreak.common.json.Json) CloudStorage(com.sequenceiq.cloudbreak.domain.cloudstorage.CloudStorage) SpiFileSystem(com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem) FileSystem(com.sequenceiq.cloudbreak.domain.FileSystem) FileSystemType(com.sequenceiq.common.model.FileSystemType) AwsEfsParameters(com.sequenceiq.common.api.cloudstorage.AwsEfsParameters) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Aggregations

FileSystemType (com.sequenceiq.common.model.FileSystemType)13 CloudFileSystemView (com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudFileSystemView)4 SpiFileSystem (com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem)3 StorageIdentityBase (com.sequenceiq.common.api.cloudstorage.StorageIdentityBase)3 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)2 ObjectStorageMetadataRequest (com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageMetadataRequest)2 ObjectStorageMetadataResponse (com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageMetadataResponse)2 FileSystem (com.sequenceiq.cloudbreak.domain.FileSystem)2 CloudIdentity (com.sequenceiq.cloudbreak.domain.cloudstorage.CloudIdentity)2 CloudStorage (com.sequenceiq.cloudbreak.domain.cloudstorage.CloudStorage)2 StorageLocation (com.sequenceiq.cloudbreak.domain.cloudstorage.StorageLocation)2 CloudStorageRequest (com.sequenceiq.common.api.cloudstorage.CloudStorageRequest)2 AdlsGen2CloudStorageV1Parameters (com.sequenceiq.common.api.cloudstorage.old.AdlsGen2CloudStorageV1Parameters)2 WasbCloudStorageV1Parameters (com.sequenceiq.common.api.cloudstorage.old.WasbCloudStorageV1Parameters)2 ConfigQueryEntry (com.sequenceiq.common.api.cloudstorage.query.ConfigQueryEntry)2 CloudStorageCdpService (com.sequenceiq.common.model.CloudStorageCdpService)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1