Search in sources :

Example 1 with StackStopContext

use of com.sequenceiq.freeipa.flow.stack.stop.StackStopContext in project cloudbreak by hortonworks.

the class AbstractStackStopAction method createFlowContext.

@Override
protected StackStopContext createFlowContext(FlowParameters flowParameters, StateContext<StackStopState, StackStopEvent> stateContext, P payload) {
    Long stackId = payload.getResourceId();
    Stack stack = stackService.getByIdWithListsInTransaction(stackId);
    MDCBuilder.buildMdcContext(stack);
    List<InstanceMetaData> instances = new ArrayList<>(instanceMetaDataService.findNotTerminatedForStack(stackId));
    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 StackStopContext(flowParameters, stack, instances, cloudContext, cloudCredential);
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) Credential(com.sequenceiq.freeipa.dto.Credential) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) ArrayList(java.util.ArrayList) StackStopContext(com.sequenceiq.freeipa.flow.stack.stop.StackStopContext) Stack(com.sequenceiq.freeipa.entity.Stack) Location(com.sequenceiq.cloudbreak.cloud.model.Location)

Aggregations

CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)1 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)1 Location (com.sequenceiq.cloudbreak.cloud.model.Location)1 Credential (com.sequenceiq.freeipa.dto.Credential)1 InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)1 Stack (com.sequenceiq.freeipa.entity.Stack)1 StackStopContext (com.sequenceiq.freeipa.flow.stack.stop.StackStopContext)1 ArrayList (java.util.ArrayList)1