use of com.sequenceiq.common.api.telemetry.model.Telemetry in project cloudbreak by hortonworks.
the class StackToStackV4ResponseConverter method convertTelemetryComponent.
private void convertTelemetryComponent(StackV4Response response, Stack source) {
TelemetryResponse telemetryResponse = null;
try {
Telemetry telemetry = componentConfigProviderService.getTelemetry(source.getId());
telemetryResponse = telemetryConverter.convert(telemetry);
} catch (CloudbreakServiceException exc) {
LOGGER.debug(exc.getMessage());
}
response.setTelemetry(telemetryResponse);
}
use of com.sequenceiq.common.api.telemetry.model.Telemetry in project cloudbreak by hortonworks.
the class ClusterService method cleanupCluster.
public void cleanupCluster(final Cluster cluster) {
if (StringUtils.isEmpty(cluster.getClusterManagerIp())) {
LOGGER.debug("Cluster server IP was not set before, cleanup cluster operation can be skipped.");
} else {
Stack stack = cluster.getStack();
if (stack != null) {
try {
Telemetry telemetry = componentConfigProviderService.getTelemetry(stack.getId());
clusterApiConnectors.getConnector(stack).clusterModificationService().cleanupCluster(telemetry);
altusMachineUserService.clearFluentMachineUser(stack, telemetry);
} catch (CloudbreakServiceException se) {
LOGGER.error("Cluster specific cleanup failed during obtaining telemetry component.", se);
} catch (CloudbreakException e) {
LOGGER.error("Cluster specific cleanup failed.", e);
}
}
}
}
use of com.sequenceiq.common.api.telemetry.model.Telemetry in project cloudbreak by hortonworks.
the class DiagnosticsService method startCmDiagnostics.
public FlowIdentifier startCmDiagnostics(BaseCmDiagnosticsCollectionRequest request, String stackCrn, String userCrn) {
Stack stack = stackService.getByCrn(stackCrn);
MDCBuilder.buildMdcContext(stack);
LOGGER.debug("Starting CM based diagnostics collection for Stack. Crn: '{}'", stack.getResourceCrn());
Telemetry telemetry = componentConfigProviderService.getTelemetry(stack.getId());
diagnosticsCollectionValidator.validate(request, stack, telemetry);
CmDiagnosticsParameters parameters = cmDiagnosticsDataToParameterConverter.convert(request, telemetry, stack.getName(), stack.getRegion());
CmDiagnosticsCollectionEvent diagnosticsCollectionEvent = CmDiagnosticsCollectionEvent.builder().withAccepted(new Promise<>()).withResourceId(stack.getId()).withResourceCrn(stack.getResourceCrn()).withSelector(CmDiagnosticsCollectionStateSelectors.START_CM_DIAGNOSTICS_INIT_EVENT.selector()).withParameters(parameters).build();
return reactorNotifier.notify(diagnosticsCollectionEvent, getFlowHeaders(userCrn));
}
use of com.sequenceiq.common.api.telemetry.model.Telemetry in project cloudbreak by hortonworks.
the class DiagnosticsService method startDiagnosticsCollection.
public FlowIdentifier startDiagnosticsCollection(BaseDiagnosticsCollectionRequest request, String stackCrn, String userCrn, String uuid) {
Stack stack = stackService.getByCrn(stackCrn);
MDCBuilder.buildMdcContext(stack);
LOGGER.debug("Starting diagnostics collection for Stack. Crn: '{}'", stack.getResourceCrn());
Telemetry telemetry = componentConfigProviderService.getTelemetry(stack.getId());
diagnosticsCollectionValidator.validate(request, stack, telemetry);
String clusterVersion = version;
if (stack.getCluster() != null && stack.getCluster().getBlueprint() != null && StringUtils.isNotBlank(stack.getCluster().getBlueprint().getStackVersion())) {
clusterVersion = stack.getCluster().getBlueprint().getStackVersion();
}
String accountId = Crn.fromString(stack.getResourceCrn()).getAccountId();
boolean useDbusCnameEndpoint = entitlementService.useDataBusCNameEndpointEnabled(accountId);
String databusEndpoint = dataBusEndpointProvider.getDataBusEndpoint(telemetry.getDatabusEndpoint(), useDbusCnameEndpoint);
DiagnosticParameters parameters = diagnosticsDataToParameterConverter.convert(request, telemetry, StringUtils.upperCase(stack.getType().getResourceType()), clusterVersion, accountId, stack.getRegion(), databusEndpoint);
// TODO: use DiagnosticParameters builder for UUID + decrease parameters in the converter above
parameters.setUuid(uuid);
DiagnosticsCollectionEvent diagnosticsCollectionEvent = DiagnosticsCollectionEvent.builder().withAccepted(new Promise<>()).withResourceId(stack.getId()).withResourceCrn(stack.getResourceCrn()).withSelector(DiagnosticsCollectionStateSelectors.START_DIAGNOSTICS_SALT_VALIDATION_EVENT.selector()).withParameters(parameters).withHosts(parameters.getHosts()).withHostGroups(parameters.getHostGroups()).withExcludeHosts(parameters.getExcludeHosts()).build();
return reactorNotifier.notify(diagnosticsCollectionEvent, getFlowHeaders(userCrn));
}
use of com.sequenceiq.common.api.telemetry.model.Telemetry in project cloudbreak by hortonworks.
the class AltusMachineUserService method getOrCreateDataBusCredentialIfNeeded.
/**
* Gather or create DataBus credential for a stack.
* On creation it will generate aa new workload user with new access/private keys.
* @param stackId id of the stack
* @return databus credential holder
*/
public DataBusCredential getOrCreateDataBusCredentialIfNeeded(Long stackId) throws IOException {
LOGGER.debug("Get or create databus credential for stack");
Stack stack = stackService.get(stackId);
Cluster cluster = clusterService.findOneByStackIdOrNotFoundError(stackId);
cluster.getDatabusCredential();
Telemetry telemetry = componentConfigProviderService.getTelemetry(stackId);
if (cluster.getDatabusCredential() != null) {
LOGGER.debug("Databus credential has been found for the stack");
DataBusCredential dataBusCredential = new Json(cluster.getDatabusCredential()).get(DataBusCredential.class);
if (isDataBusCredentialStillExist(telemetry, dataBusCredential, stack)) {
LOGGER.debug("Databus credential exists both in the stack and on UMS side");
return dataBusCredential;
} else {
LOGGER.debug("Databus credential exists on stack side but does not exists on UMS side, it will be updated ...");
}
} else {
LOGGER.debug("Databus credential does not exist for the stack, it will be created ...");
}
Optional<AltusCredential> altusCredential = generateDatabusMachineUserForFluent(stack, telemetry, true);
return storeDataBusCredential(altusCredential, stack);
}
Aggregations