Search in sources :

Example 1 with DataBusCredential

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

the class AltusMachineUserService method storeDataBusCredential.

/**
 * Store databus access / secret keypair and machine user name in the cluster if altus credential exists
 * @param altusCredential dto for databus access/private key
 * @param stack component will be attached to this stack
 * @return domain object that holds databus credential
 */
public DataBusCredential storeDataBusCredential(Optional<AltusCredential> altusCredential, Stack stack) {
    if (altusCredential.isPresent()) {
        DataBusCredential dataBusCredential = new DataBusCredential();
        dataBusCredential.setMachineUserName(getFluentDatabusMachineUserName(stack));
        dataBusCredential.setAccessKey(altusCredential.get().getAccessKey());
        dataBusCredential.setPrivateKey(altusCredential.get().getPrivateKey() != null ? new String(altusCredential.get().getPrivateKey()) : null);
        String databusCredentialJsonString = new Json(dataBusCredential).getValue();
        Cluster cluster = stack.getCluster();
        if (cluster != null) {
            cluster.setDatabusCredential(databusCredentialJsonString);
            clusterService.updateCluster(cluster);
        }
        return dataBusCredential;
    }
    return null;
}
Also used : Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Json(com.sequenceiq.cloudbreak.common.json.Json) DataBusCredential(com.sequenceiq.common.api.telemetry.model.DataBusCredential)

Example 2 with DataBusCredential

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

the class TelemetryService method createTelemetryConfigs.

@Override
public Map<String, SaltPillarProperties> createTelemetryConfigs(Long stackId, Set<TelemetryComponentType> components) {
    Stack stack = stackService.getById(stackId);
    Cluster cluster = stack.getCluster();
    DataBusCredential dataBusCredential = getDatabusCredential(cluster).orElse(null);
    Telemetry telemetry = componentConfigProviderService.getTelemetry(stackId);
    LOGGER.debug("Generating telemetry configs for stack '{}'", stack.getResourceCrn());
    return telemetryDecorator.decoratePillar(new HashMap<>(), stack, telemetry, dataBusCredential);
}
Also used : Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) DataBusCredential(com.sequenceiq.common.api.telemetry.model.DataBusCredential) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 3 with DataBusCredential

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

the class DiagnosticsEnsureMachineUserHandlerTest method testDoAccept.

@Test
public void testDoAccept() throws IOException {
    // GIVEN
    given(altusMachineUserService.getOrCreateDataBusCredentialIfNeeded(anyLong())).willReturn(new DataBusCredential());
    DiagnosticParameters diagnosticParameters = new DiagnosticParameters();
    diagnosticParameters.setDestination(DiagnosticsDestination.SUPPORT);
    // WHEN
    DiagnosticsCollectionEvent event = new DiagnosticsCollectionEvent(ENSURE_MACHINE_USER_EVENT.selector(), STACK_ID, "crn", diagnosticParameters, Set.of(), Set.of(), Set.of());
    underTest.doAccept(new HandlerEvent<>(new Event<>(event)));
    // THEN
    verify(altusMachineUserService, times(1)).getOrCreateDataBusCredentialIfNeeded(anyLong());
}
Also used : DiagnosticParameters(com.sequenceiq.common.model.diagnostics.DiagnosticParameters) Event(reactor.bus.Event) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) DiagnosticsCollectionEvent(com.sequenceiq.cloudbreak.core.flow2.diagnostics.event.DiagnosticsCollectionEvent) DiagnosticsCollectionEvent(com.sequenceiq.cloudbreak.core.flow2.diagnostics.event.DiagnosticsCollectionEvent) DataBusCredential(com.sequenceiq.common.api.telemetry.model.DataBusCredential) Test(org.junit.jupiter.api.Test)

Example 4 with DataBusCredential

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

the class TelemetryDecoratorTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    AltusCredential altusCredential = new AltusCredential("myAccessKey", "mySecretKey".toCharArray());
    DataBusCredential dataBusCredential = new DataBusCredential();
    dataBusCredential.setAccessKey("myAccessKey");
    dataBusCredential.setPrivateKey("mySecretKey");
    given(altusMachineUserService.isMeteringOrAnyDataBusBasedFeatureSupported(any(Stack.class), any(Telemetry.class))).willReturn(true);
    given(altusMachineUserService.storeDataBusCredential(any(Optional.class), any(Stack.class))).willReturn(dataBusCredential);
    given(altusMachineUserService.generateDatabusMachineUserForFluent(any(Stack.class), any(Telemetry.class))).willReturn(Optional.of(altusCredential));
    given(vmLogsService.getVmLogs()).willReturn(new ArrayList<>());
    underTest = new TelemetryDecorator(databusConfigService, fluentConfigService, meteringConfigService, monitoringConfigService, nodeStatusConfigService, telemetryCommonConfigService, altusMachineUserService, vmLogsService, entitlementService, dataBusEndpointProvider, "1.0.0");
}
Also used : Optional(java.util.Optional) AltusCredential(com.sequenceiq.cloudbreak.auth.altus.model.AltusCredential) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) DataBusCredential(com.sequenceiq.common.api.telemetry.model.DataBusCredential) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Before(org.junit.Before)

Example 5 with DataBusCredential

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

the class DiagnosticsEnsureMachineUserHandler method executeOperation.

@Override
public Selectable executeOperation(HandlerEvent<DiagnosticsCollectionEvent> event) throws Exception {
    DiagnosticsCollectionEvent data = event.getData();
    Long resourceId = data.getResourceId();
    String resourceCrn = data.getResourceCrn();
    DiagnosticParameters parameters = data.getParameters();
    Map<String, Object> parameterMap = parameters.toMap();
    LOGGER.debug("Diagnostics collection ensure machine user operation started. resourceCrn: '{}', parameters: '{}'", resourceCrn, parameterMap);
    if (DiagnosticsDestination.SUPPORT.equals(parameters.getDestination())) {
        LOGGER.debug("Generating databus credential if required for diagnostics support destination.");
        DataBusCredential credential = altusMachineUserService.getOrCreateDataBusCredentialIfNeeded(resourceId);
        parameters.setSupportBundleDbusAccessKey(credential.getAccessKey());
        parameters.setSupportBundleDbusPrivateKey(credential.getPrivateKey());
    }
    return DiagnosticsCollectionEvent.builder().withResourceCrn(resourceCrn).withResourceId(resourceId).withSelector(START_DIAGNOSTICS_COLLECTION_EVENT.selector()).withParameters(parameters).withHosts(parameters.getHosts()).withHostGroups(parameters.getHostGroups()).withExcludeHosts(parameters.getExcludeHosts()).build();
}
Also used : DiagnosticParameters(com.sequenceiq.common.model.diagnostics.DiagnosticParameters) DiagnosticsCollectionEvent(com.sequenceiq.cloudbreak.core.flow2.diagnostics.event.DiagnosticsCollectionEvent) DataBusCredential(com.sequenceiq.common.api.telemetry.model.DataBusCredential)

Aggregations

DataBusCredential (com.sequenceiq.common.api.telemetry.model.DataBusCredential)12 Json (com.sequenceiq.cloudbreak.common.json.Json)5 Telemetry (com.sequenceiq.common.api.telemetry.model.Telemetry)5 DiagnosticParameters (com.sequenceiq.common.model.diagnostics.DiagnosticParameters)4 AltusCredential (com.sequenceiq.cloudbreak.auth.altus.model.AltusCredential)3 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)3 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)3 DiagnosticsCollectionEvent (com.sequenceiq.cloudbreak.core.flow2.diagnostics.event.DiagnosticsCollectionEvent)2 HandlerEvent (com.sequenceiq.flow.reactor.api.handler.HandlerEvent)2 DiagnosticsCollectionEvent (com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionEvent)2 IOException (java.io.IOException)2 Test (org.junit.jupiter.api.Test)2 Event (reactor.bus.Event)2 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)1 CloudbreakOrchestratorFailedException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException)1 SaltPillarProperties (com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties)1 DatabusConfigView (com.sequenceiq.cloudbreak.telemetry.databus.DatabusConfigView)1 Optional (java.util.Optional)1 Before (org.junit.Before)1