use of com.sequenceiq.freeipa.flow.stack.StackContext in project cloudbreak by hortonworks.
the class AbstractUserDataUpdateAction method createFlowContext.
@Override
protected StackContext createFlowContext(FlowParameters flowParameters, StateContext<UpdateUserDataState, UpdateUserDataEvents> stateContext, P payload) {
Stack stack = stackService.getByIdWithListsInTransaction(payload.getResourceId());
MDCBuilder.buildMdcContext(stack);
Location location = location(region(stack.getRegion()), availabilityZone(stack.getAvailabilityZone()));
CloudContext cloudContext = CloudContext.Builder.builder().withId(stack.getId()).withName(stack.getName()).withCrn(stack.getResourceCrn()).withPlatform(stack.getCloudPlatform()).withVariant(stack.getPlatformvariant()).withLocation(location).withUserName(stack.getOwner()).withAccountId(stack.getAccountId()).build();
CloudCredential cloudCredential = credentialConverter.convert(credentialService.getCredentialByEnvCrn(stack.getEnvironmentCrn()));
CloudStack cloudStack = cloudStackConverter.convert(stack);
return new StackContext(flowParameters, stack, cloudContext, cloudCredential, cloudStack);
}
use of com.sequenceiq.freeipa.flow.stack.StackContext in project cloudbreak by hortonworks.
the class UserDataUpdateActions method updateUserData.
@Bean(name = "UPDATE_USERDATA_STATE")
public AbstractUserDataUpdateAction<?> updateUserData() {
return new AbstractUserDataUpdateAction<>(UserDataUpdateRequest.class) {
@Override
protected void doExecute(StackContext context, UserDataUpdateRequest payload, Map<Object, Object> variables) throws Exception {
LOGGER.info("Recreate userdata for new freeipa instances");
setOperationId(variables, payload.getOperationId());
setChainedAction(variables, payload.isChained());
setFinalChain(variables, payload.isFinal());
sendEvent(context, new UserDataUpdateRequest(context.getStack().getId(), payload.getOldTunnel()));
}
@Override
protected Object getFailurePayload(UserDataUpdateRequest payload, Optional<StackContext> flowContext, Exception ex) {
return new UserDataUpdateFailed(payload.getResourceId(), ex);
}
};
}
use of com.sequenceiq.freeipa.flow.stack.StackContext in project cloudbreak by hortonworks.
the class AbstractStackProvisionAction method createFlowContext.
@Override
protected StackContext createFlowContext(FlowParameters flowParameters, StateContext<StackProvisionState, StackProvisionEvent> stateContext, P payload) {
Stack stack = stackService.getByIdWithListsInTransaction(payload.getResourceId());
MDCBuilder.buildMdcContext(stack);
Location location = location(region(stack.getRegion()), availabilityZone(stack.getAvailabilityZone()));
CloudContext cloudContext = CloudContext.Builder.builder().withId(stack.getId()).withName(stack.getName()).withCrn(stack.getResourceCrn()).withPlatform(stack.getCloudPlatform()).withVariant(stack.getPlatformvariant()).withLocation(location).withUserName(stack.getOwner()).withAccountId(stack.getAccountId()).build();
CloudCredential cloudCredential = credentialConverter.convert(credentialService.getCredentialByEnvCrn(stack.getEnvironmentCrn()));
CloudStack cloudStack = cloudStackConverter.convert(stack);
return new StackContext(flowParameters, stack, cloudContext, cloudCredential, cloudStack);
}
use of com.sequenceiq.freeipa.flow.stack.StackContext in project cloudbreak by hortonworks.
the class StackProvisionActions method prepareImageAction.
@Bean(name = "IMAGESETUP_STATE")
public Action<?, ?> prepareImageAction() {
return new AbstractStackProvisionAction<>(SetupResult.class) {
@Override
protected void doExecute(StackContext context, SetupResult payload, Map<Object, Object> variables) {
stackProvisionService.prepareImage(context.getStack());
sendEvent(context);
}
@Override
protected Selectable createRequest(StackContext context) {
CloudStack cloudStack = cloudStackConverter.convert(context.getStack());
Image image = imageConverter.convert(imageService.getByStack(context.getStack()));
return new PrepareImageRequest<>(context.getCloudContext(), context.getCloudCredential(), cloudStack, image);
}
};
}
use of com.sequenceiq.freeipa.flow.stack.StackContext in project cloudbreak by hortonworks.
the class StackProvisionActions method collectMetadataAction.
@Bean(name = "COLLECTMETADATA_STATE")
public Action<?, ?> collectMetadataAction() {
return new AbstractStackProvisionAction<>(CollectMetadataResult.class) {
@Override
protected void doExecute(StackContext context, CollectMetadataResult payload, Map<Object, Object> variables) {
Stack stack = stackProvisionService.setupMetadata(context, payload);
StackContext newContext = new StackContext(context.getFlowParameters(), stack, context.getCloudContext(), context.getCloudCredential(), context.getCloudStack());
if (newContext.getStack().getTunnel().useCcm()) {
GetTlsInfoResult getTlsInfoResult = new GetTlsInfoResult(context.getCloudContext().getId(), new TlsInfo(true));
sendEvent(newContext, getTlsInfoResult.selector(), getTlsInfoResult);
} else {
sendEvent(newContext);
}
}
@Override
protected Selectable createRequest(StackContext context) {
CloudStack cloudStack = cloudStackConverter.convert(context.getStack());
return new GetTlsInfoRequest<GetTlsInfoResult>(context.getCloudContext(), context.getCloudCredential(), cloudStack);
}
};
}
Aggregations