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