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