Search in sources :

Example 6 with DatabusConfigView

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

the class TelemetryDecoratorTest method testDecorateWithDatabus.

@Test
public void testDecorateWithDatabus() {
    // GIVEN
    Map<String, SaltPillarProperties> servicePillar = new HashMap<>();
    FluentConfigView fluentConfigView = new FluentConfigView.Builder().build();
    DatabusConfigView dataConfigView = new DatabusConfigView.Builder().withEnabled(true).withAccessKeyId("myAccessKeyId").withAccessKeySecret("mySecret".toCharArray()).withEndpoint("databusEndpoint").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, "databus");
    assertEquals(results.get("accessKeyId"), "myAccessKeyId");
    assertEquals(results.get("enabled"), true);
}
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 7 with DatabusConfigView

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

the class TelemetryDecoratorTest method testDecorateWithSaasMonitoring.

@Test
public void testDecorateWithSaasMonitoring() {
    // 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);
    given(entitlementService.isCdpSaasEnabled(anyString())).willReturn(true);
    // 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 8 with DatabusConfigView

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

the class TelemetryDecoratorTest method testDecorateWithMetering.

@Test
public void testDecorateWithMetering() {
    // GIVEN
    Map<String, SaltPillarProperties> servicePillar = new HashMap<>();
    MeteringConfigView meteringConfigView = new MeteringConfigView.Builder().withEnabled(true).withPlatform("AWS").withServiceType("DATAHUB").withServiceVersion("1.0.0").withClusterCrn("myClusterCrn").build();
    DatabusConfigView dataConfigView = new DatabusConfigView.Builder().build();
    mockConfigServiceResults(dataConfigView, new FluentConfigView.Builder().build(), meteringConfigView);
    // WHEN
    Map<String, SaltPillarProperties> result = underTest.decoratePillar(servicePillar, createStack(), new Telemetry());
    // THEN
    Map<String, Object> results = createMapFromFluentPillars(result, "metering");
    assertEquals(results.get("serviceType"), "DATAHUB");
    assertEquals(results.get("serviceVersion"), "1.0.0");
    assertEquals(results.get("clusterCrn"), "myClusterCrn");
    assertEquals(results.get("enabled"), true);
}
Also used : HashMap(java.util.HashMap) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) MeteringConfigView(com.sequenceiq.cloudbreak.telemetry.metering.MeteringConfigView) 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 9 with DatabusConfigView

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

the class TelemetryConfigService method getDatabusPillarConfig.

private Map<String, SaltPillarProperties> getDatabusPillarConfig(Stack stack, String databusEndpoint, boolean databusEnabled) throws CloudbreakOrchestratorFailedException {
    if (databusEnabled) {
        LOGGER.debug("Apply DataBus related pillars.");
        try {
            DataBusCredential dbusCredential = altusMachineUserService.getOrCreateDataBusCredentialIfNeeded(stack);
            DatabusConfigView databusConfigView = databusConfigService.createDatabusConfigs(dbusCredential.getAccessKey(), dbusCredential.getPrivateKey().toCharArray(), null, databusEndpoint);
            return Map.of("databus", new SaltPillarProperties("/databus/init.sls", Collections.singletonMap("databus", databusConfigView.toMap())));
        } catch (IOException e) {
            throw new CloudbreakOrchestratorFailedException(e);
        }
    } else {
        return Map.of();
    }
}
Also used : CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) IOException(java.io.IOException) DatabusConfigView(com.sequenceiq.cloudbreak.telemetry.databus.DatabusConfigView) DataBusCredential(com.sequenceiq.common.api.telemetry.model.DataBusCredential) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties)

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