Search in sources :

Example 21 with LoggingResponse

use of com.sequenceiq.common.api.telemetry.response.LoggingResponse 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 22 with LoggingResponse

use of com.sequenceiq.common.api.telemetry.response.LoggingResponse in project cloudbreak by hortonworks.

the class TelemetryConverter method createLoggingResponseFromSource.

private LoggingResponse createLoggingResponseFromSource(Logging logging) {
    LoggingResponse loggingResponse = null;
    if (logging != null) {
        loggingResponse = new LoggingResponse();
        loggingResponse.setStorageLocation(logging.getStorageLocation());
        if (logging.getS3() != null) {
            S3CloudStorageV1Parameters s3Params = new S3CloudStorageV1Parameters();
            s3Params.setInstanceProfile(logging.getS3().getInstanceProfile());
            loggingResponse.setS3(s3Params);
        } else if (logging.getAdlsGen2() != null) {
            AdlsGen2CloudStorageV1Parameters adlsGen2Params = new AdlsGen2CloudStorageV1Parameters();
            adlsGen2Params.setAccountKey(logging.getAdlsGen2().getAccountKey());
            adlsGen2Params.setAccountName(logging.getAdlsGen2().getAccountName());
            adlsGen2Params.setSecure(logging.getAdlsGen2().isSecure());
            adlsGen2Params.setManagedIdentity(logging.getAdlsGen2().getManagedIdentity());
            loggingResponse.setAdlsGen2(adlsGen2Params);
        } else if (logging.getGcs() != null) {
            GcsCloudStorageV1Parameters gcsCloudStorageV1Parameters = new GcsCloudStorageV1Parameters();
            gcsCloudStorageV1Parameters.setServiceAccountEmail(logging.getGcs().getServiceAccountEmail());
            loggingResponse.setGcs(gcsCloudStorageV1Parameters);
        } else if (logging.getCloudwatch() != null) {
            loggingResponse.setCloudwatch(CloudwatchParams.copy(logging.getCloudwatch()));
        }
    }
    return loggingResponse;
}
Also used : S3CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters) AdlsGen2CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.AdlsGen2CloudStorageV1Parameters) LoggingResponse(com.sequenceiq.common.api.telemetry.response.LoggingResponse) GcsCloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.GcsCloudStorageV1Parameters)

Aggregations

LoggingResponse (com.sequenceiq.common.api.telemetry.response.LoggingResponse)22 TelemetryResponse (com.sequenceiq.common.api.telemetry.response.TelemetryResponse)17 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)12 CloudStorageRequest (com.sequenceiq.common.api.cloudstorage.CloudStorageRequest)10 Test (org.junit.jupiter.api.Test)10 S3CloudStorageV1Parameters (com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters)9 StorageLocationBase (com.sequenceiq.common.api.cloudstorage.StorageLocationBase)8 CloudIdentityType (com.sequenceiq.common.model.CloudIdentityType)7 CloudStorageCdpService (com.sequenceiq.common.model.CloudStorageCdpService)7 FileSystemType (com.sequenceiq.common.model.FileSystemType)7 ArrayList (java.util.ArrayList)7 List (java.util.List)7 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)7 Assertions.assertNull (org.junit.jupiter.api.Assertions.assertNull)7 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)7 InjectMocks (org.mockito.InjectMocks)7 Mock (org.mockito.Mock)7 Mockito.when (org.mockito.Mockito.when)7 MockitoExtension (org.mockito.junit.jupiter.MockitoExtension)7 ClusterV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request)5