Search in sources :

Example 16 with StorageIdentityBase

use of com.sequenceiq.common.api.cloudstorage.StorageIdentityBase 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;
}
Also used : CloudStorage(com.sequenceiq.cloudbreak.domain.cloudstorage.CloudStorage) AwsStorageParameters(com.sequenceiq.common.api.cloudstorage.AwsStorageParameters) CloudStorageRequest(com.sequenceiq.common.api.cloudstorage.CloudStorageRequest) S3Guard(com.sequenceiq.common.api.cloudstorage.S3Guard) StorageIdentityBase(com.sequenceiq.common.api.cloudstorage.StorageIdentityBase) StorageLocationBase(com.sequenceiq.common.api.cloudstorage.StorageLocationBase)

Example 17 with StorageIdentityBase

use of com.sequenceiq.common.api.cloudstorage.StorageIdentityBase in project cloudbreak by hortonworks.

the class CloudStorageConverter method cloudIdentityToRequest.

private StorageIdentityBase cloudIdentityToRequest(CloudIdentity cloudIdentity) {
    StorageIdentityBase storageIdentityRequest = new StorageIdentityBase();
    storageIdentityRequest.setType(cloudIdentity.getIdentityType());
    if (cloudIdentity.getS3Identity() != null) {
        S3CloudStorageV1Parameters s3Parameters = s3IdentityToParameters(cloudIdentity.getS3Identity());
        storageIdentityRequest.setS3(s3Parameters);
    } else if (cloudIdentity.getWasbIdentity() != null) {
        WasbCloudStorageV1Parameters wasbParameters = wasbIdentityToParameters(cloudIdentity.getWasbIdentity());
        storageIdentityRequest.setWasb(wasbParameters);
    } else if (cloudIdentity.getAdlsGen2Identity() != null) {
        AdlsGen2CloudStorageV1Parameters adlsGen2CloudStorageV1Parameters = adlsGen2IdentityToParameters(cloudIdentity.getAdlsGen2Identity());
        storageIdentityRequest.setAdlsGen2(adlsGen2CloudStorageV1Parameters);
    } else if (cloudIdentity.getGcsIdentity() != null) {
        GcsCloudStorageV1Parameters gcsCloudStorageV1Parameters = gcsIdentityToParameters(cloudIdentity.getGcsIdentity());
        storageIdentityRequest.setGcs(gcsCloudStorageV1Parameters);
    }
    return storageIdentityRequest;
}
Also used : S3CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters) AdlsGen2CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.AdlsGen2CloudStorageV1Parameters) WasbCloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.WasbCloudStorageV1Parameters) GcsCloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.GcsCloudStorageV1Parameters) StorageIdentityBase(com.sequenceiq.common.api.cloudstorage.StorageIdentityBase)

Example 18 with StorageIdentityBase

use of com.sequenceiq.common.api.cloudstorage.StorageIdentityBase 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;
}
Also used : CloudStorage(com.sequenceiq.cloudbreak.domain.cloudstorage.CloudStorage) AwsStorageParameters(com.sequenceiq.common.api.cloudstorage.AwsStorageParameters) 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) CloudStorageResponse(com.sequenceiq.common.api.cloudstorage.CloudStorageResponse) S3Guard(com.sequenceiq.common.api.cloudstorage.S3Guard) StorageIdentityBase(com.sequenceiq.common.api.cloudstorage.StorageIdentityBase) StorageLocationBase(com.sequenceiq.common.api.cloudstorage.StorageLocationBase)

Example 19 with StorageIdentityBase

use of com.sequenceiq.common.api.cloudstorage.StorageIdentityBase in project cloudbreak by hortonworks.

the class CloudStorageManifester method addLogIdentity.

private void addLogIdentity(CloudStorageRequest cloudStorageRequest, DetailedEnvironmentResponse environment) {
    if (containsIdentityType(CloudIdentityType.LOG, cloudStorageRequest)) {
        LOGGER.debug("Cloud storage log identity already set. Skip fetching it from environment.");
    } else {
        StorageIdentityBase log = new StorageIdentityBase();
        log.setType(CloudIdentityType.LOG);
        LoggingResponse logging = environment.getTelemetry().getLogging();
        if (logging.getS3() != null) {
            log.setS3(logging.getS3());
        } else if (logging.getAdlsGen2() != null) {
            log.setAdlsGen2(logging.getAdlsGen2());
        } else if (logging.getGcs() != null) {
            log.setGcs(logging.getGcs());
        } else if (logging.getCloudwatch() != null) {
            LOGGER.debug("Cloudwatch will act as s3 storage identity!");
            S3CloudStorageV1Parameters s3CloudwatchParams = new S3CloudStorageV1Parameters();
            s3CloudwatchParams.setInstanceProfile(logging.getCloudwatch().getInstanceProfile());
            log.setS3(s3CloudwatchParams);
        }
        cloudStorageRequest.getIdentities().add(log);
    }
}
Also used : S3CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters) LoggingResponse(com.sequenceiq.common.api.telemetry.response.LoggingResponse) StorageIdentityBase(com.sequenceiq.common.api.cloudstorage.StorageIdentityBase)

Example 20 with StorageIdentityBase

use of com.sequenceiq.common.api.cloudstorage.StorageIdentityBase in project cloudbreak by hortonworks.

the class CloudStorageManifester method addIdBrokerIdentity.

private void addIdBrokerIdentity(SdxCloudStorageRequest cloudStorage, CloudStorageRequest cloudStorageRequest) {
    StorageIdentityBase idBroker = new StorageIdentityBase();
    idBroker.setType(CloudIdentityType.ID_BROKER);
    FileSystemType fileSystemType = cloudStorage.getFileSystemType();
    if (isFileSystemConfigured(fileSystemType)) {
        if (fileSystemType.isS3()) {
            idBroker.setS3(cloudStorage.getS3());
        } else if (fileSystemType.isWasb()) {
            idBroker.setWasb(cloudStorage.getWasb());
        } else if (fileSystemType.isAdlsGen2()) {
            idBroker.setAdlsGen2(cloudStorage.getAdlsGen2());
        } else if (fileSystemType.isGcs()) {
            idBroker.setGcs(cloudStorage.getGcs());
        }
        cloudStorageRequest.getIdentities().add(idBroker);
    }
}
Also used : FileSystemType(com.sequenceiq.common.model.FileSystemType) StorageIdentityBase(com.sequenceiq.common.api.cloudstorage.StorageIdentityBase)

Aggregations

StorageIdentityBase (com.sequenceiq.common.api.cloudstorage.StorageIdentityBase)22 CloudStorageRequest (com.sequenceiq.common.api.cloudstorage.CloudStorageRequest)10 S3CloudStorageV1Parameters (com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters)9 StorageLocationBase (com.sequenceiq.common.api.cloudstorage.StorageLocationBase)8 AdlsGen2CloudStorageV1Parameters (com.sequenceiq.common.api.cloudstorage.old.AdlsGen2CloudStorageV1Parameters)6 GcsCloudStorageV1Parameters (com.sequenceiq.common.api.cloudstorage.old.GcsCloudStorageV1Parameters)5 Test (org.junit.Test)5 Test (org.junit.jupiter.api.Test)5 WasbCloudStorageV1Parameters (com.sequenceiq.common.api.cloudstorage.old.WasbCloudStorageV1Parameters)4 ArrayList (java.util.ArrayList)4 FileSystemType (com.sequenceiq.common.model.FileSystemType)3 ConstraintViolation (javax.validation.ConstraintViolation)3 SpiFileSystem (com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem)2 CloudFileSystemView (com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudFileSystemView)2 CloudStorage (com.sequenceiq.cloudbreak.domain.cloudstorage.CloudStorage)2 AwsStorageParameters (com.sequenceiq.common.api.cloudstorage.AwsStorageParameters)2 CloudStorageResponse (com.sequenceiq.common.api.cloudstorage.CloudStorageResponse)2 S3Guard (com.sequenceiq.common.api.cloudstorage.S3Guard)2 LoggingRequest (com.sequenceiq.common.api.telemetry.request.LoggingRequest)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1