use of com.sequenceiq.freeipa.flow.stack.termination.StackTerminationEvent in project cloudbreak by hortonworks.
the class AbstractStackTerminationAction method createFlowContext.
@Override
protected StackTerminationContext createFlowContext(FlowParameters flowParameters, StateContext<StackTerminationState, StackTerminationEvent> 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();
Credential credential = credentialService.getCredentialByEnvCrn(stack.getEnvironmentCrn());
CloudCredential cloudCredential = credentialConverter.convert(credential);
CloudStack cloudStack = cloudStackConverter.convert(stack);
List<Resource> resourceList = resourceService.findAllByStackId(stack.getId());
List<CloudResource> resources = resourceList.stream().map(r -> resourceConverter.convert(r)).collect(Collectors.toList());
return new StackTerminationContext(flowParameters, stack, cloudContext, cloudCredential, cloudStack, resources);
}
Aggregations