use of com.sequenceiq.freeipa.flow.stack.StackEvent in project cloudbreak by hortonworks.
the class StackProvisionActions method createCredentialAction.
@Bean(name = "CREATE_CREDENTIAL_STATE")
public Action<?, ?> createCredentialAction() {
return new AbstractStackProvisionAction<>(StackEvent.class) {
@Override
protected void doExecute(StackContext context, StackEvent payload, Map<Object, Object> variables) {
variables.put(START_DATE, new Date());
stackProvisionService.startProvisioning(context);
sendEvent(context);
}
@Override
protected Selectable createRequest(StackContext context) {
return new CreateCredentialRequest(context.getCloudContext(), context.getCloudCredential(), context.getCloudStack());
}
};
}
use of com.sequenceiq.freeipa.flow.stack.StackEvent in project cloudbreak by hortonworks.
the class StackStartActions method stackStartAction.
@Bean(name = "START_STATE")
public Action<?, ?> stackStartAction() {
return new AbstractStackStartAction<>(StackEvent.class) {
@Value("${freeipa.delayed.stop-start-sec}")
private long delayInSec;
@Inject
private EntitlementService entitlementService;
@Override
protected void doExecute(StackStartContext context, StackEvent payload, Map<Object, Object> variables) {
stackStartService.startStack(context.getStack());
sendEvent(context);
}
@Override
protected Selectable createRequest(StackStartContext context) {
Stack stack = context.getStack();
LOGGER.debug("Assembling start request for stack: {}", stack);
List<CloudInstance> cloudInstances = stack.getNotDeletedInstanceMetaDataSet().stream().sorted(new PrimaryGatewayFirstThenSortByFqdnComparator()).map(i -> metadataConverter.convert(i)).collect(Collectors.toList());
List<CloudResource> cloudResources = getCloudResources(stack.getId());
if (entitlementService.isFmsDelayedStopStartEnabled(context.getStack().getAccountId())) {
return new DelayedStartInstancesRequest(context.getCloudContext(), context.getCloudCredential(), cloudResources, cloudInstances, delayInSec);
} else {
return new StartInstancesRequest(context.getCloudContext(), context.getCloudCredential(), cloudResources, cloudInstances);
}
}
};
}
use of com.sequenceiq.freeipa.flow.stack.StackEvent in project cloudbreak by hortonworks.
the class UpgradeCcmActions method failed.
@Bean(name = UPGRADE_CCM_FAILED_STATE_NAME)
public Action<?, ?> failed() {
return new AbstractUpgradeCcmAction<>(UpgradeCcmFailureEvent.class) {
@Override
protected UpgradeCcmContext createFlowContext(FlowParameters flowParameters, StateContext<UpgradeCcmState, UpgradeCcmStateSelector> stateContext, UpgradeCcmFailureEvent payload) {
Flow flow = getFlow(flowParameters.getFlowId());
flow.setFlowFailed(payload.getException());
return super.createFlowContext(flowParameters, stateContext, payload);
}
@Override
protected void doExecute(UpgradeCcmContext context, UpgradeCcmFailureEvent payload, Map<Object, Object> variables) {
LOGGER.info("FreeIPA CCM upgrade failed {}", payload);
upgradeCcmService.failedState(context, payload);
failOperation(context.getStack().getAccountId(), payload.getException().getMessage(), variables);
sendEvent(context, UPGRADE_CCM_FAILURE_HANDLED_EVENT.event(), new StackEvent(context.getStack().getId()));
}
};
}
use of com.sequenceiq.freeipa.flow.stack.StackEvent in project cloudbreak by hortonworks.
the class UserDataUpdateFailureHandlerAction method doExecute.
@Override
protected void doExecute(StackFailureContext context, StackFailureEvent payload, Map<Object, Object> variables) throws Exception {
LOGGER.error("UserData change failed", payload.getException());
if (isOperationIdSet(variables)) {
operationService.failOperation(context.getStack().getAccountId(), getOperationId(variables), payload.getException().getMessage());
}
sendEvent(context, new StackEvent(UPDATE_USERDATA_FAILURE_HANDLED_EVENT.event(), context.getStack().getId()));
}
use of com.sequenceiq.freeipa.flow.stack.StackEvent in project cloudbreak by hortonworks.
the class ImageChangeFailureHandlerAction method doExecute.
@Override
protected void doExecute(StackFailureContext context, StackFailureEvent payload, Map<Object, Object> variables) throws Exception {
LOGGER.error("Image change failed", payload.getException());
if (variables.containsKey(ImageChangeActions.ORIGINAL_IMAGE_REVISION) && variables.containsKey(ImageChangeActions.IMAGE_CHANGED_IN_DB)) {
LOGGER.info("Reverting to original image using revision [{}]", variables.get(ImageChangeActions.ORIGINAL_IMAGE_REVISION));
imageService.revertImageToRevision((Long) variables.get(ImageChangeActions.IMAGE_ENTITY_ID), (Number) variables.get(ImageChangeActions.ORIGINAL_IMAGE_REVISION));
} else if (variables.containsKey(ImageChangeActions.ORIGINAL_IMAGE) && variables.containsKey(ImageChangeActions.IMAGE_CHANGED_IN_DB)) {
LOGGER.info("Reverting to original image using entity stored in variables");
ImageEntity originalImage = (ImageEntity) variables.get(ImageChangeActions.ORIGINAL_IMAGE);
imageService.save(originalImage);
}
if (isOperationIdSet(variables)) {
operationService.failOperation(context.getStack().getAccountId(), getOperationId(variables), payload.getException().getMessage());
}
sendEvent(context, new StackEvent(IMAGE_CHANGE_FAILURE_HANDLED_EVENT.event(), context.getStack().getId()));
}
Aggregations