use of com.sequenceiq.freeipa.entity.InstanceMetaData in project cloudbreak by hortonworks.
the class BootstrapService method bootstrap.
public void bootstrap(Long stackId, List<String> instanceIds) throws CloudbreakOrchestratorException {
Set<InstanceMetaData> instanceMetaDatas = instanceMetaDataService.findNotTerminatedForStack(stackId).stream().filter(instanceMetaData -> Objects.isNull(instanceIds) || instanceIds.contains(instanceMetaData.getInstanceId())).collect(Collectors.toSet());
Stack stack = stackRepository.findById(stackId).get();
FreeIpa freeIpa = freeIpaService.findByStack(stack);
List<GatewayConfig> gatewayConfigs = gatewayConfigService.getGatewayConfigs(stack, instanceMetaDatas);
Set<Node> allNodes = instanceMetaDatas.stream().map(im -> {
String hostname = getHostname(freeIpa, im);
return new Node(im.getPrivateIp(), im.getPublicIpWrapper(), im.getInstanceId(), im.getInstanceGroup().getTemplate().getInstanceType(), hostname, freeIpa.getDomain(), im.getInstanceGroup().getGroupName());
}).collect(Collectors.toSet());
BootstrapParams params = new BootstrapParams();
params.setCloud(stack.getCloudPlatform());
ImageEntity image = imageService.getByStack(stack);
params.setOs(image.getOs());
params.setSaltBootstrapFpSupported(true);
params.setRestartNeededFlagSupported(true);
try {
byte[] stateConfigZip = getStateConfigZip();
hostOrchestrator.bootstrapNewNodes(gatewayConfigs, allNodes, allNodes, stateConfigZip, params, new StackBasedExitCriteriaModel(stackId));
} catch (IOException e) {
LOGGER.error("Couldn't read state config", e);
throw new CloudbreakOrchestratorFailedException("Couldn't read state config", e);
} catch (CloudbreakOrchestratorException e) {
LOGGER.error("Bootstrap failed", e);
throw e;
}
}
use of com.sequenceiq.freeipa.entity.InstanceMetaData in project cloudbreak by hortonworks.
the class NodeStatusJob method checkNodeHealthReports.
private void checkNodeHealthReports(Stack stack, Set<InstanceMetaData> checkableInstances) {
for (InstanceMetaData instanceMetaData : checkableInstances) {
try {
CdpNodeStatuses nodeStatuses = checkedMeasure(() -> freeIpaNodeStatusService.nodeStatusReport(stack, instanceMetaData), LOGGER, "FreeIPA node status job checks ran in {}ms");
LOGGER.debug("Fetching node health reports for instance: {}", instanceMetaData.getInstanceId());
if (nodeStatuses.getNetworkReport().isPresent()) {
logReportResult(instanceMetaData, nodeStatuses.getNetworkReport().get(), "network");
}
if (nodeStatuses.getServicesReport().isPresent()) {
logReportResult(instanceMetaData, nodeStatuses.getServicesReport().get(), "services");
}
if (nodeStatuses.getSystemMetricsReport().isPresent()) {
logReportResult(instanceMetaData, nodeStatuses.getServicesReport().get(), "system metrics");
}
} catch (Exception e) {
LOGGER.info("FreeIpaClientException occurred during node status check: " + e.getMessage(), e);
}
}
}
use of com.sequenceiq.freeipa.entity.InstanceMetaData in project cloudbreak by hortonworks.
the class ValidateInstancesHealthHandler method fetchInstancesHealth.
private List<NodeHealthDetails> fetchInstancesHealth(ValidateInstancesHealthEvent event) {
Stack stack = stackService.getStackById(event.getResourceId());
MDCBuilder.buildMdcContext(stack);
Set<InstanceMetaData> instanceMetaDatas = instanceMetaDataService.getNotTerminatedByInstanceIds(stack.getId(), event.getInstanceIds());
List<NodeHealthDetails> healthDetails = instanceMetaDatas.stream().map(im -> getInstanceHealthDetails(stack, im)).collect(Collectors.toList());
LOGGER.info("Fetched healthdetails for instances {} - {}", event.getInstanceIds(), healthDetails);
return healthDetails;
}
use of com.sequenceiq.freeipa.entity.InstanceMetaData in project cloudbreak by hortonworks.
the class RebootActions method rebootFailureAction.
@Bean(name = "REBOOT_FAILED_STATE")
public Action<?, ?> rebootFailureAction() {
return new AbstractRebootAction<>(InstanceFailureEvent.class) {
@Inject
private OperationService operationService;
@Override
protected void doExecute(RebootContext context, InstanceFailureEvent payload, Map<Object, Object> variables) {
addMdcOperationId(variables);
rebootService.handleInstanceRebootError(context);
String message = String.format("Rebooting failed for %s.", context.getInstanceIds());
LOGGER.error(message);
Stack stack = context.getStack();
SuccessDetails successDetails = new SuccessDetails(stack.getEnvironmentCrn());
FailureDetails failureDetails = new FailureDetails(stack.getEnvironmentCrn(), message);
operationService.failOperation(stack.getAccountId(), getOperationId(variables), message, List.of(successDetails), List.of(failureDetails));
sendEvent(context, new InstanceEvent(RebootEvent.REBOOT_FAIL_HANDLED_EVENT.event(), context.getStack().getId(), context.getInstanceIdList()));
}
@Override
protected RebootContext createFlowContext(FlowParameters flowParameters, StateContext<RebootState, RebootEvent> stateContext, InstanceFailureEvent payload) {
Long stackId = payload.getResourceId();
Stack stack = stackService.getStackById(stackId);
MDCBuilder.buildMdcContext(stack);
return new RebootContext(flowParameters, stack, payload.getInstanceIds().stream().map(instanceId -> {
InstanceMetaData md = new InstanceMetaData();
md.setInstanceId(instanceId);
return md;
}).collect(Collectors.toList()), null, null);
}
@Override
protected Object getFailurePayload(InstanceFailureEvent payload, Optional<RebootContext> flowContext, Exception ex) {
return new InstanceFailureEvent(payload.getResourceId(), ex, payload.getInstanceIds());
}
@Override
protected void initPayloadConverterMap(List<PayloadConverter<InstanceFailureEvent>> payloadConverters) {
payloadConverters.add(new RebootInstancesResultToCleanupFailureEventConverter());
payloadConverters.add(new WaitUntilAvailableFailedToInstanceFailureEventConverter());
}
};
}
use of com.sequenceiq.freeipa.entity.InstanceMetaData in project cloudbreak by hortonworks.
the class StackProvisionService method setupTls.
public void setupTls(StackContext context) throws CloudbreakException {
Stack stack = context.getStack();
Set<InstanceMetaData> instanceMetaDataSet = stack.getInstanceGroups().stream().flatMap(instanceGroup -> instanceGroup.getAllInstanceMetaData().stream()).collect(Collectors.toSet());
for (InstanceMetaData gwInstance : instanceMetaDataSet) {
tlsSetupService.setupTls(stack.getId(), gwInstance);
}
}
Aggregations