Search in sources :

Example 1 with DatabusConfigView

use of com.sequenceiq.cloudbreak.telemetry.databus.DatabusConfigView in project cloudbreak by hortonworks.

the class TelemetryDecoratorTest method testDecorateWithMonitoring.

@Test
public void testDecorateWithMonitoring() {
    // GIVEN
    Map<String, SaltPillarProperties> servicePillar = new HashMap<>();
    TelemetryClusterDetails clusterDetails = TelemetryClusterDetails.Builder.builder().withCrn("myClusterCrn").withType("datahub").withVersion("1.0.0").build();
    MonitoringConfigView monitoringConfigView = new MonitoringConfigView.Builder().withEnabled(true).withClusterDetails(clusterDetails).build();
    NodeStatusConfigView nodeStatusConfigView = new NodeStatusConfigView.Builder().withServerUsername("admin").withServerPassword("admin".toCharArray()).build();
    DatabusConfigView dataConfigView = new DatabusConfigView.Builder().build();
    TelemetryCommonConfigView telemetryCommonConfigView = new TelemetryCommonConfigView.Builder().withClusterDetails(clusterDetails).build();
    MeteringConfigView meteringConfigView = new MeteringConfigView.Builder().build();
    mockConfigServiceResults(dataConfigView, new FluentConfigView.Builder().build(), meteringConfigView, monitoringConfigView, nodeStatusConfigView, telemetryCommonConfigView);
    // WHEN
    Map<String, SaltPillarProperties> result = underTest.decoratePillar(servicePillar, createStack(), new Telemetry());
    // THEN
    Map<String, Object> results = createMapFromFluentPillars(result, "monitoring");
    assertEquals(results.get("clusterType"), "datahub");
    assertEquals(results.get("clusterVersion"), "1.0.0");
    assertEquals(results.get("clusterCrn"), "myClusterCrn");
    assertEquals(results.get("enabled"), true);
}
Also used : TelemetryCommonConfigView(com.sequenceiq.cloudbreak.telemetry.common.TelemetryCommonConfigView) NodeStatusConfigView(com.sequenceiq.cloudbreak.telemetry.nodestatus.NodeStatusConfigView) HashMap(java.util.HashMap) TelemetryClusterDetails(com.sequenceiq.cloudbreak.telemetry.TelemetryClusterDetails) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) DatabusConfigView(com.sequenceiq.cloudbreak.telemetry.databus.DatabusConfigView) MeteringConfigView(com.sequenceiq.cloudbreak.telemetry.metering.MeteringConfigView) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties) MonitoringConfigView(com.sequenceiq.cloudbreak.telemetry.monitoring.MonitoringConfigView) Test(org.junit.Test)

Example 2 with DatabusConfigView

use of com.sequenceiq.cloudbreak.telemetry.databus.DatabusConfigView in project cloudbreak by hortonworks.

the class TelemetryDecorator method decoratePillar.

public Map<String, SaltPillarProperties> decoratePillar(Map<String, SaltPillarProperties> servicePillar, Stack stack, Telemetry telemetry, DataBusCredential dataBusCredential) {
    AltusCredential dbusCredential = getAltusCredentialForDataBus(stack, telemetry, dataBusCredential);
    String clusterType = StackType.DATALAKE.equals(stack.getType()) ? FluentClusterType.DATALAKE.value() : FluentClusterType.DATAHUB.value();
    String serviceType = StackType.WORKLOAD.equals(stack.getType()) ? FluentClusterType.DATAHUB.value() : "";
    String accountId = Crn.safeFromString(stack.getResourceCrn()).getAccountId();
    boolean useDbusCnameEndpoint = entitlementService.useDataBusCNameEndpointEnabled(accountId);
    String databusEndpoint = dataBusEndpointProvider.getDataBusEndpoint(telemetry.getDatabusEndpoint(), useDbusCnameEndpoint);
    String databusS3Endpoint = dataBusEndpointProvider.getDatabusS3Endpoint(databusEndpoint);
    DatabusConfigView databusConfigView = databusConfigService.createDatabusConfigs(dbusCredential.getAccessKey(), dbusCredential.getPrivateKey(), null, databusEndpoint);
    if (databusConfigView.isEnabled()) {
        Map<String, Object> databusConfig = databusConfigView.toMap();
        servicePillar.put("databus", new SaltPillarProperties("/databus/init.sls", singletonMap("databus", databusConfig)));
    }
    boolean datalakeCluster = StackType.DATALAKE.equals(stack.getType());
    boolean meteringFeatureEnabled = telemetry.isMeteringFeatureEnabled();
    // for datalake - metering is not enabled yet
    boolean meteringEnabled = meteringFeatureEnabled && !datalakeCluster;
    boolean databusEndpointValidationEnabled = !datalakeCluster && entitlementService.isDatahubDatabusEndpointValidationEnabled(accountId);
    String clusterCrn = datalakeCluster ? getDatalakeCrn(telemetry, stack.getResourceCrn()) : stack.getResourceCrn();
    final TelemetryClusterDetails clusterDetails = TelemetryClusterDetails.Builder.builder().withOwner(stack.getCreator().getUserCrn()).withName(stack.getName()).withType(clusterType).withCrn(clusterCrn).withPlatform(stack.getCloudPlatform()).withVersion(version).withDatabusEndpoint(databusEndpoint).withDatabusS3Endpoint(databusS3Endpoint).withDatabusEndpointValidation(databusEndpointValidationEnabled).build();
    final TelemetryCommonConfigView telemetryCommonConfigs = telemetryCommonConfigService.createTelemetryCommonConfigs(telemetry, vmLogsService.getVmLogs(), clusterDetails);
    servicePillar.put("telemetry", new SaltPillarProperties("/telemetry/init.sls", Collections.singletonMap("telemetry", telemetryCommonConfigs.toMap())));
    FluentConfigView fluentConfigView = fluentConfigService.createFluentConfigs(clusterDetails, databusConfigView.isEnabled(), meteringEnabled, stack.getRegion(), telemetry);
    if (fluentConfigView.isEnabled()) {
        Map<String, Object> fluentConfig = fluentConfigView.toMap();
        servicePillar.put("fluent", new SaltPillarProperties("/fluent/init.sls", singletonMap("fluent", fluentConfig)));
    }
    boolean cdpSaasEnabled = entitlementService.isCdpSaasEnabled(accountId);
    setupMetering(servicePillar, stack, serviceType, meteringEnabled);
    char[] nodePasswordInput = null;
    if (StringUtils.isNotBlank(stack.getCluster().getCdpNodeStatusMonitorPassword())) {
        nodePasswordInput = stack.getCluster().getCdpNodeStatusMonitorPassword().toCharArray();
    }
    setupMonitoring(servicePillar, cdpSaasEnabled, stack, telemetry, nodePasswordInput);
    setupNodeStatusMonitor(servicePillar, stack, nodePasswordInput);
    return servicePillar;
}
Also used : TelemetryCommonConfigView(com.sequenceiq.cloudbreak.telemetry.common.TelemetryCommonConfigView) TelemetryClusterDetails(com.sequenceiq.cloudbreak.telemetry.TelemetryClusterDetails) AltusCredential(com.sequenceiq.cloudbreak.auth.altus.model.AltusCredential) FluentConfigView(com.sequenceiq.cloudbreak.telemetry.fluent.FluentConfigView) DatabusConfigView(com.sequenceiq.cloudbreak.telemetry.databus.DatabusConfigView) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties)

Example 3 with DatabusConfigView

use of com.sequenceiq.cloudbreak.telemetry.databus.DatabusConfigView in project cloudbreak by hortonworks.

the class TelemetryDecoratorTest method testS3DecorateWithOverrides.

@Test
public void testS3DecorateWithOverrides() {
    // GIVEN
    Map<String, SaltPillarProperties> servicePillar = new HashMap<>();
    Map<String, Object> overrides = new HashMap<>();
    overrides.put("providerPrefix", "s3a");
    TelemetryClusterDetails clusterDetails = TelemetryClusterDetails.Builder.builder().withPlatform("AWS").build();
    FluentConfigView fluentConfigView = new FluentConfigView.Builder().withClusterDetails(clusterDetails).withEnabled(true).withS3LogArchiveBucketName("mybucket").withLogFolderName("cluster-logs/datahub/cl1").withProviderPrefix("s3").withOverrideAttributes(overrides).build();
    DatabusConfigView dataConfigView = new DatabusConfigView.Builder().build();
    mockConfigServiceResults(dataConfigView, fluentConfigView, new MeteringConfigView.Builder().build());
    // WHEN
    Map<String, SaltPillarProperties> result = underTest.decoratePillar(servicePillar, createStack(), new Telemetry());
    // THEN
    Map<String, Object> results = createMapFromFluentPillars(result, "fluent");
    assertEquals(results.get("providerPrefix"), "s3a");
    assertEquals(results.get("s3LogArchiveBucketName"), "mybucket");
    assertEquals(results.get("logFolderName"), "cluster-logs/datahub/cl1");
    assertEquals(results.get("enabled"), true);
}
Also used : HashMap(java.util.HashMap) TelemetryClusterDetails(com.sequenceiq.cloudbreak.telemetry.TelemetryClusterDetails) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) DatabusConfigView(com.sequenceiq.cloudbreak.telemetry.databus.DatabusConfigView) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties) FluentConfigView(com.sequenceiq.cloudbreak.telemetry.fluent.FluentConfigView) Test(org.junit.Test)

Example 4 with DatabusConfigView

use of com.sequenceiq.cloudbreak.telemetry.databus.DatabusConfigView in project cloudbreak by hortonworks.

the class TelemetryDecoratorTest method testDecorateWithDisabledLogging.

@Test
public void testDecorateWithDisabledLogging() {
    // GIVEN
    Map<String, SaltPillarProperties> servicePillar = new HashMap<>();
    FluentConfigView fluentConfigView = new FluentConfigView.Builder().build();
    DatabusConfigView dataConfigView = new DatabusConfigView.Builder().build();
    mockConfigServiceResults(dataConfigView, fluentConfigView, new MeteringConfigView.Builder().build());
    // WHEN
    Map<String, SaltPillarProperties> result = underTest.decoratePillar(servicePillar, createStack(), new Telemetry());
    // THEN
    assertNotNull(result.get("telemetry"));
    assertNull(result.get("fleunt"));
}
Also used : HashMap(java.util.HashMap) FluentConfigView(com.sequenceiq.cloudbreak.telemetry.fluent.FluentConfigView) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) DatabusConfigView(com.sequenceiq.cloudbreak.telemetry.databus.DatabusConfigView) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties) Test(org.junit.Test)

Example 5 with DatabusConfigView

use of com.sequenceiq.cloudbreak.telemetry.databus.DatabusConfigView in project cloudbreak by hortonworks.

the class TelemetryDecoratorTest method testS3DecorateWithDefaultPath.

@Test
public void testS3DecorateWithDefaultPath() {
    // GIVEN
    Map<String, SaltPillarProperties> servicePillar = new HashMap<>();
    TelemetryClusterDetails clusterDetails = TelemetryClusterDetails.Builder.builder().withPlatform("AWS").build();
    FluentConfigView fluentConfigView = new FluentConfigView.Builder().withClusterDetails(clusterDetails).withEnabled(true).withS3LogArchiveBucketName("mybucket").withLogFolderName("cluster-logs/datahub/cl1").withProviderPrefix("s3").build();
    DatabusConfigView dataConfigView = new DatabusConfigView.Builder().withAccessKeySecretAlgorithm("RSA").build();
    mockConfigServiceResults(dataConfigView, fluentConfigView, new MeteringConfigView.Builder().build());
    // WHEN
    Map<String, SaltPillarProperties> result = underTest.decoratePillar(servicePillar, createStack(), new Telemetry());
    // THEN
    Map<String, Object> results = createMapFromFluentPillars(result, "fluent");
    assertEquals(results.get("providerPrefix"), "s3");
    assertEquals(results.get("s3LogArchiveBucketName"), "mybucket");
    assertEquals(results.get("logFolderName"), "cluster-logs/datahub/cl1");
    assertEquals(results.get("enabled"), true);
    assertEquals(results.get("platform"), CloudPlatform.AWS.name());
    assertEquals(results.get("user"), "root");
    verify(fluentConfigService, times(1)).createFluentConfigs(any(TelemetryClusterDetails.class), anyBoolean(), anyBoolean(), isNull(), any(Telemetry.class));
    verify(meteringConfigService, times(1)).createMeteringConfigs(anyBoolean(), anyString(), anyString(), anyString(), anyString(), anyString());
}
Also used : HashMap(java.util.HashMap) TelemetryClusterDetails(com.sequenceiq.cloudbreak.telemetry.TelemetryClusterDetails) FluentConfigView(com.sequenceiq.cloudbreak.telemetry.fluent.FluentConfigView) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) DatabusConfigView(com.sequenceiq.cloudbreak.telemetry.databus.DatabusConfigView) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties) Test(org.junit.Test)

Aggregations

SaltPillarProperties (com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties)9 DatabusConfigView (com.sequenceiq.cloudbreak.telemetry.databus.DatabusConfigView)9 Telemetry (com.sequenceiq.common.api.telemetry.model.Telemetry)7 HashMap (java.util.HashMap)7 Test (org.junit.Test)7 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)7 TelemetryClusterDetails (com.sequenceiq.cloudbreak.telemetry.TelemetryClusterDetails)5 FluentConfigView (com.sequenceiq.cloudbreak.telemetry.fluent.FluentConfigView)5 TelemetryCommonConfigView (com.sequenceiq.cloudbreak.telemetry.common.TelemetryCommonConfigView)3 MeteringConfigView (com.sequenceiq.cloudbreak.telemetry.metering.MeteringConfigView)3 MonitoringConfigView (com.sequenceiq.cloudbreak.telemetry.monitoring.MonitoringConfigView)2 NodeStatusConfigView (com.sequenceiq.cloudbreak.telemetry.nodestatus.NodeStatusConfigView)2 AltusCredential (com.sequenceiq.cloudbreak.auth.altus.model.AltusCredential)1 CloudbreakOrchestratorFailedException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException)1 DataBusCredential (com.sequenceiq.common.api.telemetry.model.DataBusCredential)1 IOException (java.io.IOException)1