Search in sources :

Example 11 with CloudStorageRequest

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

the class CloudStorageDecoratorTest method testConvertWhenEnvironmentIsNullAndCloudStorageRequestIsNot.

@Test
void testConvertWhenEnvironmentIsNullAndCloudStorageRequestIsNot() {
    CloudStorageRequest request = new CloudStorageRequest();
    CloudStorageRequest result = underTest.decorate(BLUEPRINT_NAME, CLUSTER_NAME, request, null);
    assertNotNull(result);
}
Also used : CloudStorageRequest(com.sequenceiq.common.api.cloudstorage.CloudStorageRequest) Test(org.junit.jupiter.api.Test)

Example 12 with CloudStorageRequest

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

the class CloudStorageDecoratorTest method testConvertWhenEnvironmentAndStorageRequestAreNull.

@Test
void testConvertWhenEnvironmentAndStorageRequestAreNull() {
    CloudStorageRequest result = underTest.decorate(BLUEPRINT_NAME, CLUSTER_NAME, null, null);
    assertNull(result);
}
Also used : CloudStorageRequest(com.sequenceiq.common.api.cloudstorage.CloudStorageRequest) Test(org.junit.jupiter.api.Test)

Example 13 with CloudStorageRequest

use of com.sequenceiq.common.api.cloudstorage.CloudStorageRequest 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 14 with CloudStorageRequest

use of com.sequenceiq.common.api.cloudstorage.CloudStorageRequest 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 15 with CloudStorageRequest

use of com.sequenceiq.common.api.cloudstorage.CloudStorageRequest 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

CloudStorageRequest (com.sequenceiq.common.api.cloudstorage.CloudStorageRequest)53 Test (org.junit.jupiter.api.Test)27 StorageLocationBase (com.sequenceiq.common.api.cloudstorage.StorageLocationBase)24 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)16 CloudStorageCdpService (com.sequenceiq.common.model.CloudStorageCdpService)15 SdxCloudStorageRequest (com.sequenceiq.sdx.api.model.SdxCloudStorageRequest)15 ClusterV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request)14 LoggingResponse (com.sequenceiq.common.api.telemetry.response.LoggingResponse)14 ArrayList (java.util.ArrayList)14 TelemetryResponse (com.sequenceiq.common.api.telemetry.response.TelemetryResponse)13 FileSystemType (com.sequenceiq.common.model.FileSystemType)13 List (java.util.List)12 StorageIdentityBase (com.sequenceiq.common.api.cloudstorage.StorageIdentityBase)11 CloudIdentityType (com.sequenceiq.common.model.CloudIdentityType)11 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)10 Assertions.assertNull (org.junit.jupiter.api.Assertions.assertNull)10 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)10 InjectMocks (org.mockito.InjectMocks)10 Mock (org.mockito.Mock)10 Mockito.when (org.mockito.Mockito.when)10