use of com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionEvent in project cloudbreak by hortonworks.
the class DiagnosticsCollectionHandler 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 started. resourceCrn: '{}', parameters: '{}'", resourceCrn, parameterMap);
diagnosticsOperationsService.collect(resourceId, parameters);
return DiagnosticsCollectionEvent.builder().withResourceCrn(resourceCrn).withResourceId(resourceId).withSelector(START_DIAGNOSTICS_UPLOAD_EVENT.selector()).withParameters(parameters).build();
}
use of com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionEvent 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();
try {
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).build();
} catch (Exception e) {
throw new CloudbreakServiceException(e);
}
}
use of com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionEvent in project cloudbreak by hortonworks.
the class DiagnosticsCollectionActions method diagnosticsCollectionAction.
@Bean(name = "DIAGNOSTICS_COLLECTION_STATE")
public Action<?, ?> diagnosticsCollectionAction() {
return new AbstractDiagnosticsCollectionActions<>(DiagnosticsCollectionEvent.class) {
@Override
protected void doExecute(CommonContext context, DiagnosticsCollectionEvent payload, Map<Object, Object> variables) {
String resourceCrn = payload.getResourceCrn();
LOGGER.debug("Flow entered into DIAGNOSTICS_COLLECTION_STATE. resourceCrn: '{}'", resourceCrn);
DiagnosticsCollectionEvent event = DiagnosticsCollectionEvent.builder().withResourceId(payload.getResourceId()).withResourceCrn(payload.getResourceCrn()).withSelector(DiagnosticsCollectionHandlerSelectors.COLLECT_DIAGNOSTICS_EVENT.selector()).withParameters(payload.getParameters()).build();
sendEvent(context, event);
}
};
}
use of com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionEvent in project cloudbreak by hortonworks.
the class DiagnosticsCollectionActions method diagnosticsSaltPillaarUpdateAction.
@Bean(name = "DIAGNOSTICS_SALT_PILLAR_UPDATE_STATE")
public Action<?, ?> diagnosticsSaltPillaarUpdateAction() {
return new AbstractDiagnosticsCollectionActions<>(DiagnosticsCollectionEvent.class) {
@Override
protected void doExecute(CommonContext context, DiagnosticsCollectionEvent payload, Map<Object, Object> variables) {
String resourceCrn = payload.getResourceCrn();
LOGGER.debug("Flow entered into DIAGNOSTICS_SALT_PILLAR_UPDATE_STATE. resourceCrn: '{}'", resourceCrn);
DiagnosticsCollectionEvent event = DiagnosticsCollectionEvent.builder().withResourceId(payload.getResourceId()).withResourceCrn(resourceCrn).withSelector(DiagnosticsCollectionHandlerSelectors.SALT_PILLAR_UPDATE_DIAGNOSTICS_EVENT.selector()).withParameters(payload.getParameters()).build();
sendEvent(context, event);
}
};
}
use of com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionEvent in project cloudbreak by hortonworks.
the class DiagnosticsCollectionActions method failedAction.
@Bean(name = "DIAGNOSTICS_COLLECTION_FAILED_STATE")
public Action<?, ?> failedAction() {
return new AbstractDiagnosticsCollectionActions<>(DiagnosticsCollectionFailureEvent.class) {
@Override
protected void doExecute(CommonContext context, DiagnosticsCollectionFailureEvent payload, Map<Object, Object> variables) {
String resourceCrn = payload.getResourceCrn();
LOGGER.debug("Flow entered into DIAGNOSTICS_COLLECTION_FAILED_STATE. resourceCrn: '{}'", resourceCrn);
InMemoryStateStore.deleteStack(payload.getResourceId());
DiagnosticParameters parameters = payload.getParameters();
if (payload.getException() != null) {
parameters.setStatusReason(payload.getException().getMessage());
}
DiagnosticsCollectionEvent event = DiagnosticsCollectionEvent.builder().withResourceId(payload.getResourceId()).withResourceCrn(payload.getResourceCrn()).withSelector(DiagnosticsCollectionStateSelectors.HANDLED_FAILED_DIAGNOSTICS_COLLECTION_EVENT.selector()).withParameters(parameters).build();
diagnosticsOperationsService.vmDiagnosticsReport(resourceCrn, payload.getParameters(), UsageProto.CDPVMDiagnosticsFailureType.Value.valueOf(payload.getFailureType()), payload.getException());
sendEvent(context, event);
}
};
}
Aggregations