Search in sources :

Example 41 with TelemetryRequest

use of com.sequenceiq.common.api.telemetry.request.TelemetryRequest in project cloudbreak by hortonworks.

the class EnvironmentValidationHandler method validateCloudStorage.

private void validateCloudStorage(Event<EnvironmentValidationDto> environmentDtoEvent, EnvironmentDto environmentDto) {
    EnvironmentCloudStorageValidationRequest cloudStorageValidationRequest = new EnvironmentCloudStorageValidationRequest();
    cloudStorageValidationRequest.setCredentialCrn(environmentDto.getCredential().getResourceCrn());
    TelemetryRequest telemetryRequest = telemetryApiConverter.convertToRequest(environmentDto.getTelemetry());
    BackupRequest backupRequest = backupConverter.convertToRequest(environmentDto.getBackup());
    cloudStorageValidationRequest.setTelemetry(telemetryRequest);
    cloudStorageValidationRequest.setBackup(backupRequest);
    ObjectStorageValidateResponse response = null;
    try {
        response = cloudStorageValidator.validateCloudStorage(environmentDto.getAccountId(), cloudStorageValidationRequest);
    } catch (Exception e) {
        String message = String.format("Error occured during object storage validation, validation skipped. Error: %s", e.getMessage());
        LOGGER.warn(message);
        eventSenderService.sendEventAndNotification(environmentDto, ThreadBasedUserCrnProvider.getUserCrn(), ResourceEvent.ENVIRONMENT_VALIDATION_FAILED_AND_SKIPPED, Set.of(e.getMessage()));
    }
    if (response != null && ResponseStatus.ERROR.equals(response.getStatus())) {
        throw new EnvironmentServiceException(response.getError());
    }
    if (response != null && ResponseStatus.OK.equals(response.getStatus()) && isNotBlank(response.getError())) {
        eventSenderService.sendEventAndNotification(environmentDto, ThreadBasedUserCrnProvider.getUserCrn(), ResourceEvent.ENVIRONMENT_VALIDATION_FAILED_AND_SKIPPED, Set.of(response.getError()));
    }
}
Also used : BackupRequest(com.sequenceiq.common.api.backup.request.BackupRequest) TelemetryRequest(com.sequenceiq.common.api.telemetry.request.TelemetryRequest) EnvironmentCloudStorageValidationRequest(com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentCloudStorageValidationRequest) ObjectStorageValidateResponse(com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageValidateResponse) EnvironmentServiceException(com.sequenceiq.environment.exception.EnvironmentServiceException) EnvironmentServiceException(com.sequenceiq.environment.exception.EnvironmentServiceException) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) WebApplicationException(javax.ws.rs.WebApplicationException)

Example 42 with TelemetryRequest

use of com.sequenceiq.common.api.telemetry.request.TelemetryRequest in project cloudbreak by hortonworks.

the class TelemetryApiConverter method convertToRequest.

public TelemetryRequest convertToRequest(EnvironmentTelemetry telemetry) {
    TelemetryRequest telemetryRequest = null;
    if (telemetry != null) {
        telemetryRequest = new TelemetryRequest();
        telemetryRequest.setFluentAttributes(telemetry.getFluentAttributes());
        telemetryRequest.setLogging(createLoggingRequestFromEnvSource(telemetry.getLogging()));
        telemetryRequest.setMonitoring(createMonitoringRequestFromEnvSource(telemetry.getMonitoring()));
        telemetryRequest.setFeatures(createFeaturesRequestEnvSource(telemetry.getFeatures()));
    }
    return telemetryRequest;
}
Also used : TelemetryRequest(com.sequenceiq.common.api.telemetry.request.TelemetryRequest)

Example 43 with TelemetryRequest

use of com.sequenceiq.common.api.telemetry.request.TelemetryRequest in project cloudbreak by hortonworks.

the class CreateFreeIpaRequestToStackConverterTest method createCreateFreeIpaRequest.

private CreateFreeIpaRequest createCreateFreeIpaRequest() {
    CreateFreeIpaRequest source = new CreateFreeIpaRequest();
    source.setEnvironmentCrn("envCrn");
    source.setName("dummyName");
    source.setAuthentication(new StackAuthenticationRequest());
    source.setTelemetry(new TelemetryRequest());
    source.setInstanceGroups(List.of(new InstanceGroupRequest()));
    FreeIpaServerRequest freeIpaServerRequest = new FreeIpaServerRequest();
    freeIpaServerRequest.setDomain("dummyDomain");
    freeIpaServerRequest.setHostname("dummyHostName");
    source.setFreeIpa(freeIpaServerRequest);
    return source;
}
Also used : StackAuthenticationRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.security.StackAuthenticationRequest) TelemetryRequest(com.sequenceiq.common.api.telemetry.request.TelemetryRequest) InstanceGroupRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest) CreateFreeIpaRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest) FreeIpaServerRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.FreeIpaServerRequest)

Example 44 with TelemetryRequest

use of com.sequenceiq.common.api.telemetry.request.TelemetryRequest in project cloudbreak by hortonworks.

the class CreateFreeIpaRequestToStackConverterTest method testConvertForInstanceGroupsWhenAwsNativeIsPresent.

@Test
void testConvertForInstanceGroupsWhenAwsNativeIsPresent() {
    CreateFreeIpaRequest source = new CreateFreeIpaRequest();
    source.setEnvironmentCrn("envCrn");
    source.setName("dummyName");
    source.setVariant("AWS_NATIVE");
    source.setAuthentication(new StackAuthenticationRequest());
    source.setTelemetry(new TelemetryRequest());
    source.setInstanceGroups(List.of(new InstanceGroupRequest()));
    FreeIpaServerRequest freeIpaServerRequest = new FreeIpaServerRequest();
    freeIpaServerRequest.setDomain("dummyDomain");
    freeIpaServerRequest.setHostname("dummyHostName");
    source.setNetwork(new NetworkRequest());
    source.setFreeIpa(freeIpaServerRequest);
    DetailedEnvironmentResponse environmentResponse = new DetailedEnvironmentResponse();
    environmentResponse.setAws(AwsEnvironmentParameters.builder().withAwsDiskEncryptionParameters(AwsDiskEncryptionParameters.builder().withEncryptionKeyArn("dummyEncryptionKeyArn").build()).build());
    Future<String> owner = CompletableFuture.completedFuture("dummyUser");
    when(crnService.createCrn(ACCOUNT_ID, CrnResourceDescriptor.FREEIPA)).thenReturn("resourceCrn");
    when(stackAuthenticationConverter.convert(source.getAuthentication())).thenReturn(new StackAuthentication());
    when(instanceGroupConverter.convert(any(), any(), any(), any(), any(), any(), mapCaptorForEncryption.capture())).thenReturn(new InstanceGroup());
    when(networkConverter.convert(any(NetworkRequest.class))).thenReturn(new Network());
    when(telemetryConverter.convert(source.getTelemetry())).thenReturn(new Telemetry());
    when(backupConverter.convert(source.getTelemetry())).thenReturn(new Backup());
    when(entitlementService.internalTenant(ACCOUNT_ID)).thenReturn(Boolean.FALSE);
    when(costTagging.prepareDefaultTags(any())).thenReturn(new HashMap<>());
    Stack stack = underTest.convert(source, environmentResponse, ACCOUNT_ID, owner, "crn1", CloudPlatform.AWS.name());
    assertEquals(stack.getPlatformvariant(), "AWS_NATIVE");
    assertNull(mapCaptorForEncryption.getValue().get(GCP_KMS_ENCRYPTION_KEY));
    assertNull(mapCaptorForEncryption.getValue().get(DISK_ENCRYPTION_SET_ID));
}
Also used : StackAuthenticationRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.security.StackAuthenticationRequest) StackAuthentication(com.sequenceiq.freeipa.entity.StackAuthentication) InstanceGroupRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest) CreateFreeIpaRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest) Backup(com.sequenceiq.freeipa.api.model.Backup) NetworkRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup) Stack(com.sequenceiq.freeipa.entity.Stack) TelemetryRequest(com.sequenceiq.common.api.telemetry.request.TelemetryRequest) Network(com.sequenceiq.freeipa.entity.Network) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) FreeIpaServerRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.FreeIpaServerRequest) Test(org.junit.jupiter.api.Test)

Example 45 with TelemetryRequest

use of com.sequenceiq.common.api.telemetry.request.TelemetryRequest in project cloudbreak by hortonworks.

the class TelemetryConverterTest method testConvertFromRequestForGCS.

@Test
public void testConvertFromRequestForGCS() {
    // GIVEN
    TelemetryRequest telemetryRequest = new TelemetryRequest();
    LoggingRequest logging = new LoggingRequest();
    GcsCloudStorageV1Parameters gcsCloudStorageV1Parameters = new GcsCloudStorageV1Parameters();
    gcsCloudStorageV1Parameters.setServiceAccountEmail(EMAIL);
    logging.setGcs(gcsCloudStorageV1Parameters);
    FeaturesRequest featuresRequest = new FeaturesRequest();
    featuresRequest.addClusterLogsCollection(false);
    telemetryRequest.setLogging(logging);
    telemetryRequest.setFeatures(featuresRequest);
    // WHEN
    Telemetry result = underTest.convert(telemetryRequest);
    // THEN
    assertThat(result.getFeatures().getWorkloadAnalytics(), nullValue());
    assertThat(result.getFeatures().getClusterLogsCollection().isEnabled(), is(false));
    assertThat(result.getDatabusEndpoint(), is(DATABUS_ENDPOINT));
    assertThat(result.getLogging().getGcs(), notNullValue());
    assertThat(result.getLogging().getGcs().getServiceAccountEmail(), is(EMAIL));
}
Also used : TelemetryRequest(com.sequenceiq.common.api.telemetry.request.TelemetryRequest) LoggingRequest(com.sequenceiq.common.api.telemetry.request.LoggingRequest) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) GcsCloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.GcsCloudStorageV1Parameters) FeaturesRequest(com.sequenceiq.common.api.telemetry.request.FeaturesRequest) Test(org.junit.jupiter.api.Test)

Aggregations

TelemetryRequest (com.sequenceiq.common.api.telemetry.request.TelemetryRequest)47 Test (org.junit.Test)19 Telemetry (com.sequenceiq.common.api.telemetry.model.Telemetry)15 Test (org.junit.jupiter.api.Test)15 FeaturesRequest (com.sequenceiq.common.api.telemetry.request.FeaturesRequest)13 Features (com.sequenceiq.common.api.telemetry.model.Features)10 EnvironmentTelemetry (com.sequenceiq.environment.environment.dto.telemetry.EnvironmentTelemetry)10 LoggingRequest (com.sequenceiq.common.api.telemetry.request.LoggingRequest)9 TelemetryResponse (com.sequenceiq.common.api.telemetry.response.TelemetryResponse)9 EnvironmentFeatures (com.sequenceiq.environment.environment.dto.telemetry.EnvironmentFeatures)9 S3CloudStorageV1Parameters (com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters)7 FeaturesResponse (com.sequenceiq.common.api.telemetry.response.FeaturesResponse)6 SdxClusterResponse (com.sequenceiq.sdx.api.model.SdxClusterResponse)6 MonitoringRequest (com.sequenceiq.common.api.telemetry.request.MonitoringRequest)4 WorkloadAnalyticsRequest (com.sequenceiq.common.api.telemetry.request.WorkloadAnalyticsRequest)3 FeatureSetting (com.sequenceiq.common.api.type.FeatureSetting)3 AltusDatabusConfiguration (com.sequenceiq.cloudbreak.altus.AltusDatabusConfiguration)2 ObjectStorageValidateRequest (com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageValidateRequest)2 ObjectStorageValidateResponse (com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageValidateResponse)2 Json (com.sequenceiq.cloudbreak.common.json.Json)2