Search in sources :

Example 1 with StackTerminationEvent

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);
}
Also used : CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) Payload(com.sequenceiq.cloudbreak.common.event.Payload) AvailabilityZone.availabilityZone(com.sequenceiq.cloudbreak.cloud.model.AvailabilityZone.availabilityZone) Location.location(com.sequenceiq.cloudbreak.cloud.model.Location.location) MDCBuilder(com.sequenceiq.cloudbreak.logger.MDCBuilder) ResourceToCloudResourceConverter(com.sequenceiq.freeipa.converter.cloud.ResourceToCloudResourceConverter) Inject(javax.inject.Inject) StackTerminationEvent(com.sequenceiq.freeipa.flow.stack.termination.StackTerminationEvent) StateContext(org.springframework.statemachine.StateContext) Credential(com.sequenceiq.freeipa.dto.Credential) ResourceService(com.sequenceiq.freeipa.service.resource.ResourceService) Resource(com.sequenceiq.freeipa.entity.Resource) Location(com.sequenceiq.cloudbreak.cloud.model.Location) StackService(com.sequenceiq.freeipa.service.stack.StackService) AbstractStackAction(com.sequenceiq.freeipa.flow.stack.AbstractStackAction) Stack(com.sequenceiq.freeipa.entity.Stack) StackFailureEvent(com.sequenceiq.freeipa.flow.stack.StackFailureEvent) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) StackTerminationState(com.sequenceiq.freeipa.flow.stack.termination.StackTerminationState) Region.region(com.sequenceiq.cloudbreak.cloud.model.Region.region) FlowParameters(com.sequenceiq.flow.core.FlowParameters) CredentialToCloudCredentialConverter(com.sequenceiq.freeipa.converter.cloud.CredentialToCloudCredentialConverter) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) Collectors(java.util.stream.Collectors) StackTerminationContext(com.sequenceiq.freeipa.flow.stack.termination.StackTerminationContext) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) List(java.util.List) StackToCloudStackConverter(com.sequenceiq.freeipa.converter.cloud.StackToCloudStackConverter) Optional(java.util.Optional) CredentialService(com.sequenceiq.freeipa.service.CredentialService) 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) StackTerminationContext(com.sequenceiq.freeipa.flow.stack.termination.StackTerminationContext) Resource(com.sequenceiq.freeipa.entity.Resource) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) Stack(com.sequenceiq.freeipa.entity.Stack) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) Location(com.sequenceiq.cloudbreak.cloud.model.Location)

Aggregations

CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)1 AvailabilityZone.availabilityZone (com.sequenceiq.cloudbreak.cloud.model.AvailabilityZone.availabilityZone)1 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)1 CloudResource (com.sequenceiq.cloudbreak.cloud.model.CloudResource)1 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)1 Location (com.sequenceiq.cloudbreak.cloud.model.Location)1 Location.location (com.sequenceiq.cloudbreak.cloud.model.Location.location)1 Region.region (com.sequenceiq.cloudbreak.cloud.model.Region.region)1 Payload (com.sequenceiq.cloudbreak.common.event.Payload)1 MDCBuilder (com.sequenceiq.cloudbreak.logger.MDCBuilder)1 FlowParameters (com.sequenceiq.flow.core.FlowParameters)1 CredentialToCloudCredentialConverter (com.sequenceiq.freeipa.converter.cloud.CredentialToCloudCredentialConverter)1 ResourceToCloudResourceConverter (com.sequenceiq.freeipa.converter.cloud.ResourceToCloudResourceConverter)1 StackToCloudStackConverter (com.sequenceiq.freeipa.converter.cloud.StackToCloudStackConverter)1 Credential (com.sequenceiq.freeipa.dto.Credential)1 Resource (com.sequenceiq.freeipa.entity.Resource)1 Stack (com.sequenceiq.freeipa.entity.Stack)1 AbstractStackAction (com.sequenceiq.freeipa.flow.stack.AbstractStackAction)1 StackFailureEvent (com.sequenceiq.freeipa.flow.stack.StackFailureEvent)1 StackTerminationContext (com.sequenceiq.freeipa.flow.stack.termination.StackTerminationContext)1