Search in sources :

Example 1 with ProvisionType

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);
}
Also used : StackCreationContext(com.sequenceiq.cloudbreak.core.flow2.stack.start.StackCreationContext) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) ProvisionType(com.sequenceiq.cloudbreak.reactor.api.event.stack.ProvisionType) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) Location(com.sequenceiq.cloudbreak.cloud.model.Location)

Example 2 with 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);
}
Also used : ProvisionType(com.sequenceiq.cloudbreak.reactor.api.event.stack.ProvisionType) StackView(com.sequenceiq.cloudbreak.domain.view.StackView)

Example 3 with 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);
}
Also used : ProvisionType(com.sequenceiq.cloudbreak.reactor.api.event.stack.ProvisionType) StackView(com.sequenceiq.cloudbreak.domain.view.StackView) Flow(com.sequenceiq.flow.core.Flow)

Aggregations

ProvisionType (com.sequenceiq.cloudbreak.reactor.api.event.stack.ProvisionType)3 StackView (com.sequenceiq.cloudbreak.domain.view.StackView)2 CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)1 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)1 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)1 Location (com.sequenceiq.cloudbreak.cloud.model.Location)1 StackCreationContext (com.sequenceiq.cloudbreak.core.flow2.stack.start.StackCreationContext)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 Flow (com.sequenceiq.flow.core.Flow)1