Search in sources :

Example 1 with AltusCredential

use of com.sequenceiq.cloudbreak.auth.altus.model.AltusCredential 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 2 with AltusCredential

use of com.sequenceiq.cloudbreak.auth.altus.model.AltusCredential in project cloudbreak by hortonworks.

the class ClouderaManagerMgmtTelemetryService method setupTelemetryRole.

public void setupTelemetryRole(final Stack stack, final ApiClient client, final ApiHostRef cmHostRef, final ApiRoleList mgmtRoles, final Telemetry telemetry, String sdxStackCrn) throws ApiException {
    if (isWorkflowAnalyticsEnabled(stack, telemetry)) {
        WorkloadAnalytics workloadAnalytics = telemetry.getWorkloadAnalytics();
        String accountId = Crn.safeFromString(stack.getResourceCrn()).getAccountId();
        boolean useDbusCnameEndpoint = entitlementService.useDataBusCNameEndpointEnabled(accountId);
        String databusEndpoint = dataBusEndpointProvider.getDataBusEndpoint(workloadAnalytics.getDatabusEndpoint(), useDbusCnameEndpoint);
        ClouderaManagerResourceApi cmResourceApi = clouderaManagerApiFactory.getClouderaManagerResourceApi(client);
        ApiConfigList apiConfigList = buildTelemetryCMConfigList(workloadAnalytics, databusEndpoint);
        cmResourceApi.updateConfig("Adding telemetry settings.", apiConfigList);
        AltusCredential credentials = clouderaManagerDatabusService.getAltusCredential(stack, sdxStackCrn);
        Map<String, String> accountConfigs = new HashMap<>();
        accountConfigs.put(ALTUS_CREDENTIAL_ACCESS_KEY_NAME, credentials.getAccessKey());
        accountConfigs.put(ALTUS_CREDENTIAL_PRIVATE_KEY_NAME, new String(credentials.getPrivateKey()));
        externalAccountService.createExternalAccount(ALTUS_CREDENTIAL_NAME, ALTUS_CREDENTIAL_NAME, ALTUS_CREDENTIAL_TYPE, accountConfigs, client);
        final ApiRole telemetryPublisher = new ApiRole();
        telemetryPublisher.setName(TELEMETRYPUBLISHER);
        telemetryPublisher.setType(TELEMETRYPUBLISHER);
        telemetryPublisher.setHostRef(cmHostRef);
        mgmtRoles.addItemsItem(telemetryPublisher);
    } else {
        LOGGER.info("Telemetry WA is disabled");
    }
}
Also used : ApiConfigList(com.cloudera.api.swagger.model.ApiConfigList) ConfigUtils.makeApiConfigList(com.sequenceiq.cloudbreak.cm.util.ConfigUtils.makeApiConfigList) ApiRole(com.cloudera.api.swagger.model.ApiRole) HashMap(java.util.HashMap) AltusCredential(com.sequenceiq.cloudbreak.auth.altus.model.AltusCredential) ClouderaManagerResourceApi(com.cloudera.api.swagger.ClouderaManagerResourceApi) WorkloadAnalytics(com.sequenceiq.common.api.telemetry.model.WorkloadAnalytics)

Example 3 with AltusCredential

use of com.sequenceiq.cloudbreak.auth.altus.model.AltusCredential in project cloudbreak by hortonworks.

the class ClouderaManagerDatabusServiceTest method testGetAltusCredential.

@Test
public void testGetAltusCredential() {
    // GIVEN
    AltusCredential credential = new AltusCredential("accessKey", "secretKey".toCharArray());
    when(iamService.generateMachineUserWithAccessKeyForLegacyCm(any(), any(), any(), any())).thenReturn(credential);
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    when(roleCrnGenerator.getBuiltInWXMClusterAdminResourceRoleCrn(any())).thenReturn("resourceRoleCrn");
    when(regionAwareCrnGenerator.generateCrnString(any(), any(), any())).thenReturn("resourceCrn");
    // WHEN
    AltusCredential result = underTest.getAltusCredential(stack, SDX_STACK_CRN);
    // THEN
    assertEquals("secretKey", new String(result.getPrivateKey()));
}
Also used : AltusCredential(com.sequenceiq.cloudbreak.auth.altus.model.AltusCredential) Test(org.junit.Test)

Example 4 with AltusCredential

use of com.sequenceiq.cloudbreak.auth.altus.model.AltusCredential in project cloudbreak by hortonworks.

the class AltusMachineUserServiceTest method testCreateMachineUserAndGenerateKeys.

@Test
public void testCreateMachineUserAndGenerateKeys() {
    // GIVEN
    Optional<AltusCredential> altusCredential = Optional.of(new AltusCredential("accessKey", "secretKey".toCharArray()));
    when(altusIAMService.generateMachineUserWithAccessKey(any(), any(), any(), anyBoolean())).thenReturn(altusCredential);
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:freeipa:us-west-1:altus:user:__internal__actor__");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    // WHEN
    underTest.generateDatabusMachineUserForFluent(stack, telemetry);
    // THEN
    assertEquals("secretKey", new String(altusCredential.get().getPrivateKey()));
    verify(altusIAMService, times(1)).generateMachineUserWithAccessKey(any(), any(), any(), anyBoolean());
}
Also used : AltusCredential(com.sequenceiq.cloudbreak.auth.altus.model.AltusCredential) Test(org.junit.Test)

Example 5 with AltusCredential

use of com.sequenceiq.cloudbreak.auth.altus.model.AltusCredential in project cloudbreak by hortonworks.

the class ClouderaManagerMgmtTelemetryServiceTest method testSetupTelemetry.

@Test
public void testSetupTelemetry() throws ApiException {
    // GIVEN
    Stack stack = new Stack();
    stack.setType(StackType.WORKLOAD);
    User user = new User();
    user.setUserCrn("crn:cdp:iam:us-west-1:accountId:user:name");
    stack.setCreator(user);
    stack.setResourceCrn("crn:cdp:datahub:us-west-1:accountId:cluster:name");
    WorkloadAnalytics wa = new WorkloadAnalytics();
    Telemetry telemetry = new Telemetry();
    telemetry.setWorkloadAnalytics(wa);
    ApiConfigList apiConfigList = new ApiConfigList();
    ApiResponse response = new ApiResponse<>(0, null, apiConfigList);
    AltusCredential credential = new AltusCredential("accessKey", "secretKey".toCharArray());
    when(entitlementService.useDataBusCNameEndpointEnabled(anyString())).thenReturn(false);
    when(dataBusEndpointProvider.getDataBusEndpoint(anyString(), anyBoolean())).thenReturn("https://dbusapi.us-west-1.sigma.altus.cloudera.com");
    when(apiClient.execute(any(), any())).thenReturn(response);
    when(clouderaManagerDatabusService.getAltusCredential(stack, SDX_STACK_CRN)).thenReturn(credential);
    when(clouderaManagerApiFactory.getClouderaManagerResourceApi(apiClient)).thenReturn(cmResourceApi);
    when(cmResourceApi.updateConfig(anyString(), any())).thenReturn(apiConfigList);
    // WHEN
    underTest.setupTelemetryRole(stack, apiClient, null, new ApiRoleList(), telemetry, SDX_STACK_CRN);
    // THEN
    verify(externalAccountService, times(1)).createExternalAccount(anyString(), anyString(), anyString(), anyMap(), any(ApiClient.class));
    verify(clouderaManagerDatabusService, times(1)).getAltusCredential(stack, SDX_STACK_CRN);
}
Also used : ApiConfigList(com.cloudera.api.swagger.model.ApiConfigList) User(com.sequenceiq.cloudbreak.workspace.model.User) AltusCredential(com.sequenceiq.cloudbreak.auth.altus.model.AltusCredential) ApiRoleList(com.cloudera.api.swagger.model.ApiRoleList) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) ApiClient(com.cloudera.api.swagger.client.ApiClient) ApiResponse(com.cloudera.api.swagger.client.ApiResponse) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) WorkloadAnalytics(com.sequenceiq.common.api.telemetry.model.WorkloadAnalytics) Test(org.junit.Test)

Aggregations

AltusCredential (com.sequenceiq.cloudbreak.auth.altus.model.AltusCredential)15 Telemetry (com.sequenceiq.common.api.telemetry.model.Telemetry)4 ApiConfigList (com.cloudera.api.swagger.model.ApiConfigList)3 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)3 DataBusCredential (com.sequenceiq.common.api.telemetry.model.DataBusCredential)3 WorkloadAnalytics (com.sequenceiq.common.api.telemetry.model.WorkloadAnalytics)3 Test (org.junit.Test)3 ClouderaManagerResourceApi (com.cloudera.api.swagger.ClouderaManagerResourceApi)2 ApiRole (com.cloudera.api.swagger.model.ApiRole)2 CreateAccessKeyResponse (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.CreateAccessKeyResponse)2 UmsOperationException (com.sequenceiq.cloudbreak.auth.altus.exception.UmsOperationException)2 ConfigUtils.makeApiConfigList (com.sequenceiq.cloudbreak.cm.util.ConfigUtils.makeApiConfigList)2 Json (com.sequenceiq.cloudbreak.common.json.Json)2 StatusRuntimeException (io.grpc.StatusRuntimeException)2 HashMap (java.util.HashMap)2 Retryable (org.springframework.retry.annotation.Retryable)2 ApiClient (com.cloudera.api.swagger.client.ApiClient)1 ApiResponse (com.cloudera.api.swagger.client.ApiResponse)1 ApiRoleList (com.cloudera.api.swagger.model.ApiRoleList)1 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)1