Search in sources :

Example 1 with TelemetryClusterDetails

use of com.sequenceiq.cloudbreak.telemetry.TelemetryClusterDetails 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 TelemetryClusterDetails

use of com.sequenceiq.cloudbreak.telemetry.TelemetryClusterDetails 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 TelemetryClusterDetails

use of com.sequenceiq.cloudbreak.telemetry.TelemetryClusterDetails 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 TelemetryClusterDetails

use of com.sequenceiq.cloudbreak.telemetry.TelemetryClusterDetails 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)

Example 5 with TelemetryClusterDetails

use of com.sequenceiq.cloudbreak.telemetry.TelemetryClusterDetails in project cloudbreak by hortonworks.

the class TelemetryConfigService method getTelemetryCommonPillarConfig.

private Map<String, SaltPillarProperties> getTelemetryCommonPillarConfig(Stack stack, Telemetry telemetry, String databusEndpoint, boolean databusEndpointValidation) {
    TelemetryClusterDetails clusterDetails = TelemetryClusterDetails.Builder.builder().withVersion(version).withPlatform(stack.getCloudPlatform()).withCrn(stack.getResourceCrn()).withName(stack.getName()).withType(FluentClusterType.FREEIPA.value()).withOwner(stack.getOwner()).withDatabusEndpoint(databusEndpoint).withDatabusS3Endpoint(dataBusEndpointProvider.getDatabusS3Endpoint(databusEndpoint)).withDatabusEndpointValidation(databusEndpointValidation).build();
    TelemetryCommonConfigView telemetryCommonConfigs = telemetryCommonConfigService.createTelemetryCommonConfigs(telemetry, vmLogsService.getVmLogs(), clusterDetails);
    return Map.of("telemetry", new SaltPillarProperties("/telemetry/init.sls", Map.of("telemetry", telemetryCommonConfigs.toMap(), "cloudera-manager", getPaywallConfigs(stack))));
}
Also used : TelemetryCommonConfigView(com.sequenceiq.cloudbreak.telemetry.common.TelemetryCommonConfigView) TelemetryClusterDetails(com.sequenceiq.cloudbreak.telemetry.TelemetryClusterDetails) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties)

Aggregations

TelemetryClusterDetails (com.sequenceiq.cloudbreak.telemetry.TelemetryClusterDetails)7 SaltPillarProperties (com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties)6 DatabusConfigView (com.sequenceiq.cloudbreak.telemetry.databus.DatabusConfigView)5 Telemetry (com.sequenceiq.common.api.telemetry.model.Telemetry)5 HashMap (java.util.HashMap)5 Test (org.junit.Test)5 TelemetryCommonConfigView (com.sequenceiq.cloudbreak.telemetry.common.TelemetryCommonConfigView)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 FluentConfigView (com.sequenceiq.cloudbreak.telemetry.fluent.FluentConfigView)3 MeteringConfigView (com.sequenceiq.cloudbreak.telemetry.metering.MeteringConfigView)2 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 TelemetryComponentUpgradeConfiguration (com.sequenceiq.cloudbreak.telemetry.TelemetryComponentUpgradeConfiguration)1 VmLog (com.sequenceiq.common.api.telemetry.model.VmLog)1 ArrayList (java.util.ArrayList)1