Search in sources :

Example 1 with StorageIdentityBase

use of com.sequenceiq.common.api.cloudstorage.StorageIdentityBase 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);
}
Also used : FileSystemType(com.sequenceiq.common.model.FileSystemType) CloudFileSystemView(com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudFileSystemView) ArrayList(java.util.ArrayList) SpiFileSystem(com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem) StorageIdentityBase(com.sequenceiq.common.api.cloudstorage.StorageIdentityBase)

Example 2 with StorageIdentityBase

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

the class StorageIdentityValidatorTest method testCloudStorageValidationWithMoreThanOneStorageParameter.

@Test
void testCloudStorageValidationWithMoreThanOneStorageParameter() {
    StorageIdentityBase storage = new StorageIdentityBase();
    storage.setType(CloudIdentityType.LOG);
    S3CloudStorageV1Parameters s3 = new S3CloudStorageV1Parameters();
    s3.setInstanceProfile("instace::profile");
    storage.setS3(s3);
    GcsCloudStorageV1Parameters gcs = new GcsCloudStorageV1Parameters();
    gcs.setServiceAccountEmail("service.account@googlecloud.com");
    storage.setGcs(gcs);
    Set<ConstraintViolation<StorageIdentityBase>> constraintViolations = validator.validate(storage);
    assertEquals(1, constraintViolations.size());
    ConstraintViolation<StorageIdentityBase> violation = constraintViolations.iterator().next();
    assertEquals(ValidCloudStorage.MESSAGE, violation.getMessage());
}
Also used : S3CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters) ConstraintViolation(javax.validation.ConstraintViolation) GcsCloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.GcsCloudStorageV1Parameters) StorageIdentityBase(com.sequenceiq.common.api.cloudstorage.StorageIdentityBase) Test(org.junit.jupiter.api.Test)

Example 3 with StorageIdentityBase

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

the class CloudStorageValidationUtilTest method testIsCloudStorageConfiguredWhenS3NotNull.

@Test
public void testIsCloudStorageConfiguredWhenS3NotNull() {
    CloudStorageRequest cloudStorageRequest = new CloudStorageRequest();
    StorageIdentityBase storageIdentityBase = new StorageIdentityBase();
    storageIdentityBase.setS3(new S3CloudStorageV1Parameters());
    cloudStorageRequest.setIdentities(List.of(storageIdentityBase));
    cloudStorageRequest.setLocations(List.of(new StorageLocationBase()));
    boolean actual = underTest.isCloudStorageConfigured(cloudStorageRequest);
    Assert.assertTrue(actual);
}
Also used : CloudStorageRequest(com.sequenceiq.common.api.cloudstorage.CloudStorageRequest) S3CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters) StorageIdentityBase(com.sequenceiq.common.api.cloudstorage.StorageIdentityBase) StorageLocationBase(com.sequenceiq.common.api.cloudstorage.StorageLocationBase) Test(org.junit.Test)

Example 4 with StorageIdentityBase

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

the class CloudStorageDecorator method decorate.

public CloudStorageRequest decorate(String blueprintName, String clusterName, CloudStorageRequest request, DetailedEnvironmentResponse environment) {
    if (environment != null) {
        if (request == null) {
            request = new CloudStorageRequest();
        }
        TelemetryResponse telemetry = environment.getTelemetry();
        if (telemetry != null && telemetry.getLogging() != null) {
            LoggingResponse logging = telemetry.getLogging();
            StorageIdentityBase identity = new StorageIdentityBase();
            identity.setType(CloudIdentityType.LOG);
            identity.setS3(logging.getS3());
            identity.setAdlsGen2(logging.getAdlsGen2());
            identity.setGcs(logging.getGcs());
            List<StorageIdentityBase> identities = request.getIdentities();
            if (identities == null) {
                identities = new ArrayList<>();
            }
            boolean logConfiguredInRequest = false;
            for (StorageIdentityBase identityBase : identities) {
                if (CloudIdentityType.LOG.equals(identityBase.getType())) {
                    logConfiguredInRequest = true;
                }
            }
            if (!logConfiguredInRequest) {
                identities.add(identity);
            }
            request.setIdentities(identities);
        }
        List<SdxClusterResponse> datalakes = sdxClientService.getByEnvironmentCrn(environment.getCrn());
        updateCloudStorageLocations(blueprintName, clusterName, request, datalakes);
        updateDynamoDBTable(request, environment);
    }
    return request;
}
Also used : TelemetryResponse(com.sequenceiq.common.api.telemetry.response.TelemetryResponse) CloudStorageRequest(com.sequenceiq.common.api.cloudstorage.CloudStorageRequest) LoggingResponse(com.sequenceiq.common.api.telemetry.response.LoggingResponse) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) StorageIdentityBase(com.sequenceiq.common.api.cloudstorage.StorageIdentityBase)

Example 5 with StorageIdentityBase

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

the class StackRequestManifesterTest method testAddAzureIdbrokerMsiToTelemetry.

@Test
public void testAddAzureIdbrokerMsiToTelemetry() {
    Map<String, Object> attributes = new HashMap<>();
    CloudStorageRequest cloudStorageRequest = new CloudStorageRequest();
    List<StorageIdentityBase> identities = new ArrayList<>();
    StorageIdentityBase identity = new StorageIdentityBase();
    identity.setType(CloudIdentityType.ID_BROKER);
    AdlsGen2CloudStorageV1Parameters adlsGen2 = new AdlsGen2CloudStorageV1Parameters();
    adlsGen2.setManagedIdentity("msi");
    identity.setAdlsGen2(adlsGen2);
    identities.add(identity);
    cloudStorageRequest.setIdentities(identities);
    when(stackV4Request.getCluster()).thenReturn(clusterV4Request);
    clusterV4Request.setCloudStorage(cloudStorageRequest);
    underTest.addAzureIdbrokerMsiToTelemetry(attributes, stackV4Request);
    assertThat(clusterV4Request.getCloudStorage()).isNotNull();
    assertThat(attributes.get(FluentConfigView.AZURE_IDBROKER_INSTANCE_MSI)).isEqualTo("msi");
}
Also used : CloudStorageRequest(com.sequenceiq.common.api.cloudstorage.CloudStorageRequest) AdlsGen2CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.AdlsGen2CloudStorageV1Parameters) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) StorageIdentityBase(com.sequenceiq.common.api.cloudstorage.StorageIdentityBase) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

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