use of com.sequenceiq.freeipa.flow.stack.start.StackStartContext in project cloudbreak by hortonworks.
the class AbstractStackStartAction method createFlowContext.
@Override
protected StackStartContext createFlowContext(FlowParameters flowParameters, StateContext<StackStartState, StackStartEvent> stateContext, P payload) {
Long stackId = payload.getResourceId();
Stack stack = stackService.getByIdWithListsInTransaction(stackId);
MDCBuilder.buildMdcContext(stack);
List<InstanceMetaData> instances = stack.getNotDeletedInstanceMetaDataList();
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();
Credential credential = credentialService.getCredentialByEnvCrn(stack.getEnvironmentCrn());
CloudCredential cloudCredential = credentialConverter.convert(credential);
return new StackStartContext(flowParameters, stack, instances, cloudContext, cloudCredential);
}
use of com.sequenceiq.freeipa.flow.stack.start.StackStartContext 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);
}
}
};
}
Aggregations