use of com.sequenceiq.cloudbreak.reactor.api.event.stack.ProvisionType in project cloudbreak by hortonworks.
the class AbstractStackCreationAction method createFlowContext.
@Override
protected StackCreationContext createFlowContext(FlowParameters flowParameters, StateContext<StackCreationState, StackCreationEvent> stateContext, P payload) {
Stack stack = stackService.getByIdWithListsInTransaction(payload.getResourceId());
stack.setResources(new HashSet<>(resourceService.getAllByStackId(payload.getResourceId())));
Map<Object, Object> variables = stateContext.getExtendedState().getVariables();
ProvisionType provisionType = (ProvisionType) variables.getOrDefault(PROVISION_TYPE, ProvisionType.REGULAR);
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()).withUserName(stack.getCreator().getUserName()).withLocation(location).withWorkspaceId(stack.getWorkspace().getId()).withAccountId(Crn.safeFromString(stack.getResourceCrn()).getAccountId()).withTenantId(stack.getTenant().getId()).build();
CloudCredential cloudCredential = stackUtil.getCloudCredential(stack);
CloudStack cloudStack = cloudStackConverter.convert(stack);
return new StackCreationContext(flowParameters, stack, cloudContext, cloudCredential, cloudStack, provisionType);
}
use of com.sequenceiq.cloudbreak.reactor.api.event.stack.ProvisionType in project cloudbreak by hortonworks.
the class AbstractClusterCreationAction method createFlowContext.
@Override
protected ClusterCreationViewContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> clusterContext, P payload) {
Map<Object, Object> variables = clusterContext.getExtendedState().getVariables();
ProvisionType provisionType = (ProvisionType) variables.getOrDefault(PROVISION_TYPE, ProvisionType.REGULAR);
StackView stack = stackService.getViewByIdWithoutAuth(payload.getResourceId());
MDCBuilder.buildMdcContext(stack.getClusterView());
return new ClusterCreationViewContext(flowParameters, stack, provisionType);
}
use of com.sequenceiq.cloudbreak.reactor.api.event.stack.ProvisionType in project cloudbreak by hortonworks.
the class AbstractStackFailureAction method createFlowContext.
@Override
protected StackFailureContext createFlowContext(FlowParameters flowParameters, StateContext<S, E> stateContext, StackFailureEvent payload) {
Flow flow = getFlow(flowParameters.getFlowId());
StackView stack = stackService.getViewByIdWithoutAuth(payload.getResourceId());
MDCBuilder.buildMdcContext(stack);
flow.setFlowFailed(payload.getException());
Map<Object, Object> variables = stateContext.getExtendedState().getVariables();
ProvisionType provisionType = (ProvisionType) variables.getOrDefault(PROVISION_TYPE, ProvisionType.REGULAR);
return new StackFailureContext(flowParameters, stack, provisionType);
}
Aggregations