use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.
the class FreeIpaUpscaleActions method recordHostnamesAction.
@Bean(name = "UPSCALE_RECORD_HOSTNAMES_STATE")
public Action<?, ?> recordHostnamesAction() {
return new AbstractUpscaleAction<>(HostMetadataSetupSuccess.class) {
@Override
protected void doExecute(StackContext context, HostMetadataSetupSuccess payload, Map<Object, Object> variables) {
Stack stack = context.getStack();
stackUpdater.updateStackStatus(stack.getId(), getInProgressStatus(variables), "Recording hostnames");
List<String> instanceIds = getInstanceIds(variables);
List<String> hosts = stack.getNotDeletedInstanceMetaDataList().stream().filter(instanceMetaData -> instanceIds.contains(instanceMetaData.getInstanceId())).map(InstanceMetaData::getDiscoveryFQDN).collect(Collectors.toList());
setUpscaleHosts(variables, hosts);
sendEvent(context, UPSCALE_RECORD_HOSTNAMES_FINISHED_EVENT.selector(), new StackEvent(stack.getId()));
}
};
}
use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.
the class FreeIpaUpscaleActions method collectingHostMetadataAction.
@Bean(name = "UPSCALE_COLLECTING_HOST_METADATA_STATE")
public Action<?, ?> collectingHostMetadataAction() {
return new AbstractUpscaleAction<>(BootstrapMachinesSuccess.class) {
@Override
protected void doExecute(StackContext context, BootstrapMachinesSuccess payload, Map<Object, Object> variables) {
Stack stack = context.getStack();
stackUpdater.updateStackStatus(stack.getId(), getInProgressStatus(variables), "Collecting host metadata");
HostMetadataSetupRequest request = new HostMetadataSetupRequest(stack.getId());
sendEvent(context, request.selector(), request);
}
};
}
use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.
the class FreeIpaDownscaleActions method updateMetadataForDeletionRequestAction.
@Bean(name = "DOWNSCALE_UPDATE_METADATA_FOR_DELETION_REQUEST_STATE")
public Action<?, ?> updateMetadataForDeletionRequestAction() {
return new AbstractDownscaleAction<>(StackEvent.class) {
@Override
protected void doExecute(StackContext context, StackEvent payload, Map<Object, Object> variables) {
Stack stack = context.getStack();
stackUpdater.updateStackStatus(stack.getId(), getInProgressStatus(variables), "Updating metadata for deletion request");
List<String> repairInstanceIds = getInstanceIds(variables);
terminationService.requestDeletion(stack.getId(), repairInstanceIds);
sendEvent(context, UPDATE_METADATA_FOR_DELETION_REQUEST_FINISHED_EVENT.selector(), new StackEvent(stack.getId()));
}
};
}
use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.
the class FreeIpaDownscaleActions method downscaleCollectAdditionalHostnamesAction.
@Bean(name = "DOWNSCALE_COLLECT_ADDITIONAL_HOSTNAMES_STATE")
public Action<?, ?> downscaleCollectAdditionalHostnamesAction() {
return new AbstractDownscaleAction<>(ClusterProxyUpdateRegistrationSuccess.class) {
@Override
protected void doExecute(StackContext context, ClusterProxyUpdateRegistrationSuccess payload, Map<Object, Object> variables) throws Exception {
Stack stack = context.getStack();
stackUpdater.updateStackStatus(stack.getId(), getInProgressStatus(variables), "Collecting additional hostnames.");
CollectAdditionalHostnamesRequest request = new CollectAdditionalHostnamesRequest(stack.getId());
sendEvent(context, request.selector(), request);
}
};
}
use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.
the class FreeIpaDownscaleActions method downscaleFailureAction.
@Bean(name = "DOWNSCALE_FAIL_STATE")
public Action<?, ?> downscaleFailureAction() {
return new AbstractDownscaleAction<>(DownscaleFailureEvent.class) {
@Inject
private OperationService operationService;
@Override
protected StackContext createFlowContext(FlowParameters flowParameters, StateContext<DownscaleState, DownscaleFlowEvent> stateContext, DownscaleFailureEvent payload) {
Flow flow = getFlow(flowParameters.getFlowId());
flow.setFlowFailed(payload.getException());
return super.createFlowContext(flowParameters, stateContext, payload);
}
@Override
protected void doExecute(StackContext context, DownscaleFailureEvent payload, Map<Object, Object> variables) {
LOGGER.error("Downscale failed with payload: " + payload);
Stack stack = context.getStack();
String environmentCrn = stack.getEnvironmentCrn();
SuccessDetails successDetails = new SuccessDetails(environmentCrn);
successDetails.getAdditionalDetails().put(payload.getFailedPhase(), payload.getSuccess() == null ? List.of() : new ArrayList<>(payload.getSuccess()));
String message = "Downscale failed during " + payload.getFailedPhase();
FailureDetails failureDetails = new FailureDetails(environmentCrn, message);
if (payload.getFailureDetails() != null) {
failureDetails.getAdditionalDetails().putAll(payload.getFailureDetails());
}
String errorReason = getErrorReason(payload.getException());
stackUpdater.updateStackStatus(context.getStack().getId(), getFailedStatus(variables), errorReason);
operationService.failOperation(stack.getAccountId(), getOperationId(variables), message, List.of(successDetails), List.of(failureDetails));
enableStatusChecker(stack, "Failed downscaling FreeIPA");
enableNodeStatusChecker(stack, "Failed downscaling FreeIPA");
sendEvent(context, FAIL_HANDLED_EVENT.event(), payload);
}
@Override
protected void initPayloadConverterMap(List<PayloadConverter<DownscaleFailureEvent>> payloadConverters) {
payloadConverters.add(new ClusterProxyUpdateRegistrationFailedToDownscaleFailureEventConverter());
payloadConverters.add(new DownscaleStackCollectResourcesResultToDownscaleFailureEventConverter());
payloadConverters.add(new DownscaleStackResultToDownscaleFailureEventConverter());
payloadConverters.add(new RemoveServersResponseToDownscaleFailureEventConverter());
payloadConverters.add(new RemoveDnsResponseToDownscaleFailureEventConverter());
payloadConverters.add(new RemoveHostsResponseToDownscaleFailureEventConverter());
payloadConverters.add(new RevokeCertsResponseToDownscaleFailureEventConverter());
}
};
}
Aggregations