Search in sources :

Example 6 with StorageIdentityBase

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

the class StorageIdentityValidatorTest method testCloudStorageValidation.

@Test
void testCloudStorageValidation() {
    StorageIdentityBase storage = new StorageIdentityBase();
    S3CloudStorageV1Parameters s3 = new S3CloudStorageV1Parameters();
    s3.setInstanceProfile("instace::profile");
    storage.setS3(s3);
    storage.setType(CloudIdentityType.LOG);
    Set<ConstraintViolation<StorageIdentityBase>> constraintViolations = validator.validate(storage);
    assertTrue(constraintViolations.isEmpty());
}
Also used : S3CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters) ConstraintViolation(javax.validation.ConstraintViolation) StorageIdentityBase(com.sequenceiq.common.api.cloudstorage.StorageIdentityBase) Test(org.junit.jupiter.api.Test)

Example 7 with StorageIdentityBase

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

the class StorageIdentityValidatorTest method testCloudStorageValidationWithoutStorageParameter.

@Test
void testCloudStorageValidationWithoutStorageParameter() {
    StorageIdentityBase storage = new StorageIdentityBase();
    storage.setType(CloudIdentityType.LOG);
    Set<ConstraintViolation<StorageIdentityBase>> constraintViolations = validator.validate(storage);
    assertEquals(1, constraintViolations.size());
    ConstraintViolation<StorageIdentityBase> violation = constraintViolations.iterator().next();
    assertEquals(ValidCloudStorage.MESSAGE, violation.getMessage());
}
Also used : ConstraintViolation(javax.validation.ConstraintViolation) StorageIdentityBase(com.sequenceiq.common.api.cloudstorage.StorageIdentityBase) Test(org.junit.jupiter.api.Test)

Example 8 with StorageIdentityBase

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

the class CloudStorageValidatorTest method validateCloudStorageSetLocationBaseWhenLoggingIsConfigured.

@Test
public void validateCloudStorageSetLocationBaseWhenLoggingIsConfigured() {
    when(credentialService.getByCrnForAccountId(anyString(), anyString(), any(), anyBoolean())).thenReturn(new Credential());
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    EnvironmentCloudStorageValidationRequest request = new EnvironmentCloudStorageValidationRequest();
    TelemetryRequest telemetryRequest = new TelemetryRequest();
    LoggingRequest loggingRequest = new LoggingRequest();
    loggingRequest.setStorageLocation("s3://mybucket/location");
    S3CloudStorageV1Parameters s3CloudStorageV1Parameters = new S3CloudStorageV1Parameters();
    s3CloudStorageV1Parameters.setInstanceProfile("instanceProfile");
    loggingRequest.setS3(s3CloudStorageV1Parameters);
    telemetryRequest.setLogging(loggingRequest);
    request.setTelemetry(telemetryRequest);
    request.setCredentialCrn("credential");
    ArgumentCaptor<ObjectStorageValidateRequest> requestCaptor = ArgumentCaptor.forClass(ObjectStorageValidateRequest.class);
    when(cloudProviderServicesV4Endpoint.validateObjectStorage(requestCaptor.capture())).thenReturn(ObjectStorageValidateResponse.builder().withStatus(ResponseStatus.OK).build());
    ObjectStorageValidateResponse response = underTest.validateCloudStorage("1234", request);
    assertEquals(ResponseStatus.OK, response.getStatus());
    assertNull(response.getError());
    ObjectStorageValidateRequest objectStorageValidateRequest = requestCaptor.getValue();
    assertEquals("s3://mybucket/location", objectStorageValidateRequest.getLogsLocationBase());
    List<StorageIdentityBase> storageIdentities = objectStorageValidateRequest.getCloudStorageRequest().getIdentities();
    assertEquals(1, storageIdentities.size());
    StorageIdentityBase storageIdentity = storageIdentities.get(0);
    assertEquals(CloudIdentityType.LOG, storageIdentity.getType());
    assertEquals("instanceProfile", storageIdentity.getS3().getInstanceProfile());
}
Also used : Credential(com.sequenceiq.environment.credential.domain.Credential) TelemetryRequest(com.sequenceiq.common.api.telemetry.request.TelemetryRequest) S3CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters) EnvironmentCloudStorageValidationRequest(com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentCloudStorageValidationRequest) ObjectStorageValidateResponse(com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageValidateResponse) ObjectStorageValidateRequest(com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageValidateRequest) LoggingRequest(com.sequenceiq.common.api.telemetry.request.LoggingRequest) StorageIdentityBase(com.sequenceiq.common.api.cloudstorage.StorageIdentityBase) Test(org.junit.jupiter.api.Test)

Example 9 with StorageIdentityBase

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

the class StackRequestManifester method addAzureIdbrokerMsiToTelemetry.

void addAzureIdbrokerMsiToTelemetry(Map<String, Object> fluentAttributes, StackV4Request stackRequest) {
    if (stackRequest.getCluster() != null && stackRequest.getCluster().getCloudStorage() != null && stackRequest.getCluster().getCloudStorage().getIdentities() != null) {
        List<StorageIdentityBase> identities = stackRequest.getCluster().getCloudStorage().getIdentities();
        for (StorageIdentityBase identity : identities) {
            if (CloudIdentityType.ID_BROKER.equals(identity.getType()) && identity.getAdlsGen2() != null) {
                if (!fluentAttributes.containsKey(FluentConfigView.AZURE_IDBROKER_INSTANCE_MSI)) {
                    String idBrokerInstanceMsi = identity.getAdlsGen2().getManagedIdentity();
                    LOGGER.info("Setting idbroker instance msi for telemetry: {}", idBrokerInstanceMsi);
                    fluentAttributes.put(FluentConfigView.AZURE_IDBROKER_INSTANCE_MSI, idBrokerInstanceMsi);
                }
            }
        }
    }
}
Also used : StorageIdentityBase(com.sequenceiq.common.api.cloudstorage.StorageIdentityBase)

Example 10 with StorageIdentityBase

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

the class CloudStorageValidationUtilTest method testIsCloudStorageConfiguredWhenGcsNotNull.

@Test
public void testIsCloudStorageConfiguredWhenGcsNotNull() {
    CloudStorageRequest cloudStorageRequest = new CloudStorageRequest();
    StorageIdentityBase storageIdentityBase = new StorageIdentityBase();
    storageIdentityBase.setGcs(new GcsCloudStorageV1Parameters());
    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) GcsCloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.GcsCloudStorageV1Parameters) StorageIdentityBase(com.sequenceiq.common.api.cloudstorage.StorageIdentityBase) StorageLocationBase(com.sequenceiq.common.api.cloudstorage.StorageLocationBase) Test(org.junit.Test)

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