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);
}
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;
}
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);
}
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"));
}
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());
}
Aggregations