Search in sources :

Example 1 with VmLog

use of com.sequenceiq.common.api.telemetry.model.VmLog in project cloudbreak by hortonworks.

the class TelemetryCommonConfigService method resolveLogPathReferences.

private void resolveLogPathReferences(Telemetry telemetry, List<VmLog> logs) {
    Map<String, Object> fluentAttributes = telemetry.getFluentAttributes();
    if (CollectionUtils.isNotEmpty(logs)) {
        Properties props = new Properties();
        props.setProperty(SERVER_LOG_FOLDER_PREFIX, fluentAttributes.getOrDefault(SERVER_LOG_FOLDER_PREFIX, LOG_FOLDER_DEFAULT).toString());
        props.setProperty(AGENT_LOG_FOLDER_PREFIX, fluentAttributes.getOrDefault(AGENT_LOG_FOLDER_PREFIX, LOG_FOLDER_DEFAULT).toString());
        props.setProperty(SERVICE_LOG_FOLDER_PREFIX, fluentAttributes.getOrDefault(SERVICE_LOG_FOLDER_PREFIX, LOG_FOLDER_DEFAULT).toString());
        PropertyPlaceholderHelper propertyPlaceholderHelper = new PropertyPlaceholderHelper("${", "}");
        for (VmLog log : logs) {
            String resolvedPath = propertyPlaceholderHelper.replacePlaceholders(log.getPath(), props);
            log.setPath(resolvedPath);
        }
    }
}
Also used : PropertyPlaceholderHelper(org.springframework.util.PropertyPlaceholderHelper) VmLog(com.sequenceiq.common.api.telemetry.model.VmLog) Properties(java.util.Properties)

Example 2 with VmLog

use of com.sequenceiq.common.api.telemetry.model.VmLog in project cloudbreak by hortonworks.

the class TelemetryConfigServiceTest method testCreateTelemetryConfigs.

@Test
public void testCreateTelemetryConfigs() throws Exception {
    // GIVEN
    UserManagementProto.Account account = UserManagementProto.Account.newBuilder().setClouderaManagerLicenseKey("myLicense").build();
    JsonCMLicense license = new JsonCMLicense();
    license.setName("myname");
    license.setUuid("myuuid");
    Stack stack = createStack();
    given(stackService.getStackById(STACK_ID)).willReturn(stack);
    given(entitlementService.useDataBusCNameEndpointEnabled(anyString())).willReturn(false);
    given(dataBusEndpointProvider.getDataBusEndpoint(anyString(), anyBoolean())).willReturn("myendpoint");
    given(vmLogsService.getVmLogs()).willReturn(List.of(new VmLog()));
    given(telemetryCommonConfigService.createTelemetryCommonConfigs(any(), any(), any())).willReturn(new TelemetryCommonConfigView.Builder().build());
    given(cmLicenseParser.parseLicense(anyString())).willReturn(Optional.of(license));
    given(umsClient.getAccountDetails(anyString(), any(), any())).willReturn(account);
    given(fluentConfigService.createFluentConfigs(any(), anyBoolean(), anyBoolean(), isNull(), any())).willReturn(new FluentConfigView.Builder().build());
    given(nodeStatusConfigService.createNodeStatusConfig(isNull(), isNull(), anyBoolean())).willReturn(new NodeStatusConfigView.Builder().build());
    given(monitoringConfigService.createMonitoringConfig(isNull(), any(), isNull(), isNull(), anyBoolean())).willReturn(new MonitoringConfigView.Builder().build());
    // WHEN
    Map<String, SaltPillarProperties> result = underTest.createTelemetryConfigs(STACK_ID, Set.of(TelemetryComponentType.CDP_TELEMETRY));
    // THEN
    verify(fluentConfigService, times(1)).createFluentConfigs(any(), anyBoolean(), anyBoolean(), isNull(), any());
    assertNotNull(result.get("telemetry").getProperties().get("cloudera-manager"));
    assertNotNull(result.get("telemetry").getProperties().get("telemetry"));
}
Also used : VmLog(com.sequenceiq.common.api.telemetry.model.VmLog) UserManagementProto(com.cloudera.thunderhead.service.usermanagement.UserManagementProto) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) JsonCMLicense(com.sequenceiq.cloudbreak.auth.JsonCMLicense) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 3 with VmLog

use of com.sequenceiq.common.api.telemetry.model.VmLog in project cloudbreak by hortonworks.

the class DiagnosticsParamsConverter method convertToRequest.

public DiagnosticsCollectionRequest convertToRequest(Map<String, Object> props) {
    DiagnosticsCollectionRequest request = new DiagnosticsCollectionRequest();
    request.setDestination(Optional.ofNullable(props.get(PARAM_DESTINATION)).map(v -> DiagnosticsDestination.valueOf(v.toString())).orElse(null));
    request.setStackCrn(Optional.ofNullable(props.get(PARAMS_STACK_CRN)).map(Object::toString).orElse(null));
    request.setHosts((Set<String>) Optional.ofNullable(props.get(PARAM_HOSTS)).orElse(null));
    request.setExcludeHosts((Set<String>) Optional.ofNullable(props.get(PARAMS_EXCLUDE_HOSTS)).orElse(null));
    request.setHostGroups((Set<String>) Optional.ofNullable(props.get(PARAMS_HOST_GROUPS)).orElse(null));
    request.setLabels((List<String>) Optional.ofNullable(props.get(PARAMS_LABELS)).orElse(null));
    request.setAdditionalLogs((List<VmLog>) Optional.ofNullable(props.get(PARAMS_ADDITIONAL_LOGS)).orElse(null));
    request.setDescription(Optional.ofNullable(props.get(PARAM_DESCRIPTION)).map(Object::toString).orElse(null));
    request.setIssue(Optional.ofNullable(props.get(PARAMS_ISSUE)).map(Object::toString).orElse(null));
    request.setStartTime((Date) Optional.ofNullable(props.get(PARAMS_START_TIME)).orElse(null));
    request.setEndTime((Date) Optional.ofNullable(props.get(PARAMS_END_TIME)).orElse(null));
    request.setIncludeSaltLogs((Boolean) Optional.ofNullable(props.get(PARAMS_INCLUDE_SALT_LOGS)).orElse(false));
    request.setIncludeSarOutput((Boolean) Optional.ofNullable(props.get(PARAMS_INCLUDE_SAR_OUTPUT)).orElse(false));
    request.setIncludeNginxReport((Boolean) Optional.ofNullable(props.get(PARAMS_INCLUDE_NGINX_REPORT)).orElse(false));
    request.setUpdatePackage((Boolean) Optional.ofNullable(props.get(PARAMS_UPDATE_PACKAGE)).orElse(false));
    request.setSkipValidation((Boolean) Optional.ofNullable(props.get(PARAMS_SKIP_VALIDATION)).orElse(false));
    request.setSkipUnresponsiveHosts((Boolean) Optional.ofNullable(props.get(PARAMS_SKIP_UNRESPONSIVE_HOSTS)).orElse(false));
    request.setSkipWorkspaceCleanupOnStartup((Boolean) Optional.ofNullable(props.get(PARAMS_SKIP_WORKSPACE_CLEANUP_ON_STARTUP)).orElse(false));
    request.setUuid(Optional.ofNullable(props.get(PARAMS_UUID)).map(Object::toString).orElse(null));
    return request;
}
Also used : VmLog(com.sequenceiq.common.api.telemetry.model.VmLog) DiagnosticsCollectionRequest(com.sequenceiq.cloudbreak.api.endpoint.v4.diagnostics.model.DiagnosticsCollectionRequest) CmDiagnosticsCollectionRequest(com.sequenceiq.cloudbreak.api.endpoint.v4.diagnostics.model.CmDiagnosticsCollectionRequest)

Example 4 with VmLog

use of com.sequenceiq.common.api.telemetry.model.VmLog in project cloudbreak by hortonworks.

the class TelemetryCommonConfigServiceTest method testCreateTelemetryCommonConfigs.

@Test
public void testCreateTelemetryCommonConfigs() {
    // GIVEN
    given(telemetryUpgradeConfiguration.isEnabled()).willReturn(true);
    TelemetryComponentUpgradeConfiguration cdpTelemetryConfig = new TelemetryComponentUpgradeConfiguration();
    cdpTelemetryConfig.setDesiredVersion("0.0.1");
    given(telemetryUpgradeConfiguration.getCdpTelemetry()).willReturn(cdpTelemetryConfig);
    given(altusDatabusConnectionConfiguration.getMaxTimeSeconds()).willReturn(1);
    Telemetry telemetry = new Telemetry();
    Map<String, Object> fluentAttributes = new HashMap<>();
    fluentAttributes.put(SERVICE_LOG_FOLDER_PREFIX, "/var/log");
    fluentAttributes.put(SERVER_LOG_FOLDER_PREFIX, "/custom/log");
    fluentAttributes.put(AGENT_LOG_FOLDER_PREFIX, "/grid/0/log");
    telemetry.setFluentAttributes(fluentAttributes);
    List<VmLog> vmLogs = new ArrayList<>();
    VmLog log1 = new VmLog();
    log1.setPath("${serviceLogFolderPrefix}/mylog.log");
    VmLog log2 = new VmLog();
    log2.setPath("${agentLogFolderPrefix}/*");
    VmLog log3 = new VmLog();
    log3.setPath("/my/path${serverLogFolderPrefix}/*");
    vmLogs.add(log1);
    vmLogs.add(log2);
    vmLogs.add(log3);
    TelemetryClusterDetails telemetryClusterDetails = TelemetryClusterDetails.Builder.builder().build();
    // WHEN
    TelemetryCommonConfigView result = underTest.createTelemetryCommonConfigs(telemetry, vmLogs, telemetryClusterDetails);
    // THEN
    assertEquals("/var/log/mylog.log", vmLogs.get(0).getPath());
    assertEquals("/grid/0/log/*", vmLogs.get(1).getPath());
    assertEquals("/my/path/custom/log/*", vmLogs.get(2).getPath());
    assertEquals("0.0.1", result.toMap().get("desiredCdpTelemetryVersion").toString());
    assertEquals(1, result.toMap().get("databusConnectMaxTime"));
}
Also used : VmLog(com.sequenceiq.common.api.telemetry.model.VmLog) TelemetryComponentUpgradeConfiguration(com.sequenceiq.cloudbreak.telemetry.TelemetryComponentUpgradeConfiguration) HashMap(java.util.HashMap) TelemetryClusterDetails(com.sequenceiq.cloudbreak.telemetry.TelemetryClusterDetails) ArrayList(java.util.ArrayList) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) Test(org.junit.Test)

Example 5 with VmLog

use of com.sequenceiq.common.api.telemetry.model.VmLog in project cloudbreak by hortonworks.

the class VmLogsToVmLogsResponseConverter method convert.

public VmLogsResponse convert(List<VmLog> vmLogs) {
    VmLogsResponse result = new VmLogsResponse();
    result.setLogs(Optional.ofNullable(vmLogs).orElse(List.of()).stream().map(logs -> {
        VmLog log = new VmLog();
        log.setName(logs.getName());
        log.setPath(logs.getPath());
        log.setType(logs.getType());
        log.setLabel(logs.getLabel());
        log.setExcludes(logs.getExcludes());
        return log;
    }).collect(Collectors.toList()));
    return result;
}
Also used : VmLog(com.sequenceiq.common.api.telemetry.model.VmLog) VmLogsResponse(com.sequenceiq.common.api.telemetry.response.VmLogsResponse)

Aggregations

VmLog (com.sequenceiq.common.api.telemetry.model.VmLog)5 UserManagementProto (com.cloudera.thunderhead.service.usermanagement.UserManagementProto)1 CmDiagnosticsCollectionRequest (com.sequenceiq.cloudbreak.api.endpoint.v4.diagnostics.model.CmDiagnosticsCollectionRequest)1 DiagnosticsCollectionRequest (com.sequenceiq.cloudbreak.api.endpoint.v4.diagnostics.model.DiagnosticsCollectionRequest)1 JsonCMLicense (com.sequenceiq.cloudbreak.auth.JsonCMLicense)1 SaltPillarProperties (com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties)1 TelemetryClusterDetails (com.sequenceiq.cloudbreak.telemetry.TelemetryClusterDetails)1 TelemetryComponentUpgradeConfiguration (com.sequenceiq.cloudbreak.telemetry.TelemetryComponentUpgradeConfiguration)1 Telemetry (com.sequenceiq.common.api.telemetry.model.Telemetry)1 VmLogsResponse (com.sequenceiq.common.api.telemetry.response.VmLogsResponse)1 Stack (com.sequenceiq.freeipa.entity.Stack)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Properties (java.util.Properties)1 Test (org.junit.Test)1 Test (org.junit.jupiter.api.Test)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 PropertyPlaceholderHelper (org.springframework.util.PropertyPlaceholderHelper)1