Search in sources :

Example 6 with StackCreationContext

use of com.sequenceiq.cloudbreak.core.flow2.stack.start.StackCreationContext in project cloudbreak by hortonworks.

the class KerberosConfigValidationActions method pollBindUserCreationAction.

@Bean(name = "POLL_BIND_USER_CREATION_STATE")
public Action<?, ?> pollBindUserCreationAction() {
    return new AbstractStackCreationAction<>(PollBindUserCreationEvent.class) {

        @Override
        protected void doExecute(StackCreationContext context, PollBindUserCreationEvent payload, Map<Object, Object> variables) {
            PollBindUserCreationEvent event = new PollBindUserCreationEvent(payload.getResourceId(), payload.getOperationId(), Crn.safeFromString(context.getStack().getResourceCrn()).getAccountId());
            sendEvent(context, event);
        }

        @Override
        protected Object getFailurePayload(PollBindUserCreationEvent payload, Optional<StackCreationContext> flowContext, Exception ex) {
            return new StackFailureEvent(KerberosConfigValidationEvent.VALIDATE_KERBEROS_CONFIG_FAILED_EVENT.selector(), payload.getResourceId(), ex);
        }
    };
}
Also used : StackCreationContext(com.sequenceiq.cloudbreak.core.flow2.stack.start.StackCreationContext) AbstractStackCreationAction(com.sequenceiq.cloudbreak.core.flow2.stack.provision.action.AbstractStackCreationAction) Optional(java.util.Optional) StackFailureEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent) PollBindUserCreationEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.PollBindUserCreationEvent) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 7 with StackCreationContext

use of com.sequenceiq.cloudbreak.core.flow2.stack.start.StackCreationContext in project cloudbreak by hortonworks.

the class KerberosConfigValidationActions method createBindUserAction.

@Bean(name = "CREATE_BIND_USER_STATE")
public Action<?, ?> createBindUserAction() {
    return new AbstractStackCreationAction<>(StackEvent.class) {

        @Override
        protected void doExecute(StackCreationContext context, StackEvent payload, Map<Object, Object> variables) {
            StartBindUserCreationEvent event = new StartBindUserCreationEvent(payload.getResourceId());
            sendEvent(context, event);
        }

        @Override
        protected Object getFailurePayload(StackEvent payload, Optional<StackCreationContext> flowContext, Exception ex) {
            return new StackFailureEvent(KerberosConfigValidationEvent.VALIDATE_KERBEROS_CONFIG_FAILED_EVENT.selector(), payload.getResourceId(), ex);
        }
    };
}
Also used : StackCreationContext(com.sequenceiq.cloudbreak.core.flow2.stack.start.StackCreationContext) StartBindUserCreationEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.StartBindUserCreationEvent) AbstractStackCreationAction(com.sequenceiq.cloudbreak.core.flow2.stack.provision.action.AbstractStackCreationAction) StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) Optional(java.util.Optional) StackFailureEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 8 with StackCreationContext

use of com.sequenceiq.cloudbreak.core.flow2.stack.start.StackCreationContext in project cloudbreak by hortonworks.

the class StackCreationActions method collectMetadataAction.

@Bean(name = "COLLECTMETADATA_STATE")
public Action<?, ?> collectMetadataAction() {
    return new AbstractStackCreationAction<>(CollectMetadataResult.class) {

        @Override
        protected void doExecute(StackCreationContext context, CollectMetadataResult payload, Map<Object, Object> variables) {
            Stack stack = stackCreationService.setupMetadata(context, payload);
            StackCreationContext newContext = new StackCreationContext(context.getFlowParameters(), stack, context.getCloudContext(), context.getCloudCredential(), context.getCloudStack());
            sendEvent(newContext);
        }

        @Override
        protected Selectable createRequest(StackCreationContext context) {
            List<LoadBalancerType> loadBalancerTypes = loadBalancerPersistenceService.findByStackId(context.getStack().getId()).stream().map(LoadBalancer::getType).collect(Collectors.toList());
            List<CloudResource> cloudResources = context.getStack().getResources().stream().map(r -> cloudResourceConverter.convert(r)).collect(Collectors.toList());
            return new CollectLoadBalancerMetadataRequest(context.getCloudContext(), context.getCloudCredential(), loadBalancerTypes, cloudResources);
        }
    };
}
Also used : START_DATE(com.sequenceiq.cloudbreak.core.flow2.stack.provision.StackProvisionConstants.START_DATE) CreateCredentialRequest(com.sequenceiq.cloudbreak.cloud.event.resource.CreateCredentialRequest) ProvisionEvent(com.sequenceiq.cloudbreak.reactor.api.event.stack.ProvisionEvent) CreateUserDataSuccess(com.sequenceiq.cloudbreak.reactor.api.event.stack.userdata.CreateUserDataSuccess) Action(org.springframework.statemachine.action.Action) PrepareImageRequest(com.sequenceiq.cloudbreak.cloud.event.setup.PrepareImageRequest) Date(java.util.Date) CollectLoadBalancerMetadataRequest(com.sequenceiq.cloudbreak.cloud.event.loadbalancer.CollectLoadBalancerMetadataRequest) StackToCloudStackConverter(com.sequenceiq.cloudbreak.converter.spi.StackToCloudStackConverter) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) LaunchLoadBalancerRequest(com.sequenceiq.cloudbreak.cloud.event.resource.LaunchLoadBalancerRequest) TlsInfo(com.sequenceiq.cloudbreak.cloud.model.TlsInfo) StackWithFingerprintsEvent(com.sequenceiq.cloudbreak.reactor.api.event.stack.StackWithFingerprintsEvent) ImageService(com.sequenceiq.cloudbreak.service.image.ImageService) InstanceMetaDataToCloudInstanceConverter(com.sequenceiq.cloudbreak.converter.spi.InstanceMetaDataToCloudInstanceConverter) CreateUserDataRequest(com.sequenceiq.cloudbreak.reactor.api.event.stack.userdata.CreateUserDataRequest) LoadBalancer(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer) Map(java.util.Map) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) ValidationRequest(com.sequenceiq.cloudbreak.cloud.event.setup.ValidationRequest) AbstractStackFailureAction(com.sequenceiq.cloudbreak.core.flow2.stack.AbstractStackFailureAction) LoadBalancerPersistenceService(com.sequenceiq.cloudbreak.service.stack.LoadBalancerPersistenceService) StackCreationService(com.sequenceiq.cloudbreak.core.flow2.stack.provision.service.StackCreationService) StackFailureContext(com.sequenceiq.cloudbreak.core.flow2.stack.StackFailureContext) CreateCredentialResult(com.sequenceiq.cloudbreak.cloud.event.resource.CreateCredentialResult) Collectors(java.util.stream.Collectors) GetTlsInfoResult(com.sequenceiq.cloudbreak.cloud.event.instance.GetTlsInfoResult) Configuration(org.springframework.context.annotation.Configuration) SetupResult(com.sequenceiq.cloudbreak.cloud.event.setup.SetupResult) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) List(java.util.List) ValidationResult(com.sequenceiq.cloudbreak.cloud.event.setup.ValidationResult) Optional(java.util.Optional) StackCreationEvent(com.sequenceiq.cloudbreak.core.flow2.stack.provision.StackCreationEvent) SetupRequest(com.sequenceiq.cloudbreak.cloud.event.setup.SetupRequest) CollectLoadBalancerMetadataResult(com.sequenceiq.cloudbreak.cloud.event.loadbalancer.CollectLoadBalancerMetadataResult) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) FailurePolicy(com.sequenceiq.cloudbreak.domain.FailurePolicy) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) StackFailureEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent) Image(com.sequenceiq.cloudbreak.cloud.model.Image) StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) LoadBalancerType(com.sequenceiq.common.api.type.LoadBalancerType) Inject(javax.inject.Inject) ResourceToCloudResourceConverter(com.sequenceiq.cloudbreak.converter.spi.ResourceToCloudResourceConverter) LaunchLoadBalancerResult(com.sequenceiq.cloudbreak.cloud.event.resource.LaunchLoadBalancerResult) GetSSHFingerprintsResult(com.sequenceiq.cloudbreak.cloud.event.instance.GetSSHFingerprintsResult) GetSSHFingerprintsRequest(com.sequenceiq.cloudbreak.cloud.event.instance.GetSSHFingerprintsRequest) CollectMetadataResult(com.sequenceiq.cloudbreak.cloud.event.instance.CollectMetadataResult) CollectMetadataRequest(com.sequenceiq.cloudbreak.cloud.event.instance.CollectMetadataRequest) LaunchStackResult(com.sequenceiq.cloudbreak.cloud.event.resource.LaunchStackResult) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) EnvironmentClientService(com.sequenceiq.cloudbreak.service.environment.EnvironmentClientService) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) MetricType(com.sequenceiq.cloudbreak.service.metrics.MetricType) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) GetTlsInfoRequest(com.sequenceiq.cloudbreak.cloud.event.instance.GetTlsInfoRequest) StackCreationContext(com.sequenceiq.cloudbreak.core.flow2.stack.start.StackCreationContext) LaunchStackRequest(com.sequenceiq.cloudbreak.cloud.event.resource.LaunchStackRequest) Bean(org.springframework.context.annotation.Bean) StackCreationState(com.sequenceiq.cloudbreak.core.flow2.stack.provision.StackCreationState) CollectLoadBalancerMetadataRequest(com.sequenceiq.cloudbreak.cloud.event.loadbalancer.CollectLoadBalancerMetadataRequest) StackCreationContext(com.sequenceiq.cloudbreak.core.flow2.stack.start.StackCreationContext) CollectMetadataResult(com.sequenceiq.cloudbreak.cloud.event.instance.CollectMetadataResult) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) Map(java.util.Map) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) LoadBalancerType(com.sequenceiq.common.api.type.LoadBalancerType) Bean(org.springframework.context.annotation.Bean)

Example 9 with StackCreationContext

use of com.sequenceiq.cloudbreak.core.flow2.stack.start.StackCreationContext in project cloudbreak by hortonworks.

the class StackCreationActions method createCredentialAction.

@Bean(name = "CREATE_CREDENTIAL_STATE")
public Action<?, ?> createCredentialAction() {
    return new AbstractStackCreationAction<>(StackEvent.class) {

        @Override
        protected void doExecute(StackCreationContext context, StackEvent payload, Map<Object, Object> variables) {
            variables.put(START_DATE, new Date());
            stackCreationService.startProvisioning(context, variables);
            sendEvent(context);
        }

        @Override
        protected Selectable createRequest(StackCreationContext context) {
            return new CreateCredentialRequest(context.getCloudContext(), context.getCloudCredential(), context.getCloudStack());
        }
    };
}
Also used : CreateCredentialRequest(com.sequenceiq.cloudbreak.cloud.event.resource.CreateCredentialRequest) StackCreationContext(com.sequenceiq.cloudbreak.core.flow2.stack.start.StackCreationContext) StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) Map(java.util.Map) Date(java.util.Date) Bean(org.springframework.context.annotation.Bean)

Example 10 with StackCreationContext

use of com.sequenceiq.cloudbreak.core.flow2.stack.start.StackCreationContext in project cloudbreak by hortonworks.

the class StackCreationActions method provisioningFinishedAction.

@Bean(name = "PROVISIONING_FINISHED_STATE")
public Action<?, ?> provisioningFinishedAction() {
    return new AbstractStackCreationAction<>(LaunchLoadBalancerResult.class) {

        @Override
        protected void doExecute(StackCreationContext context, LaunchLoadBalancerResult payload, Map<Object, Object> variables) {
            Stack stack = stackCreationService.loadBalancerProvisioningFinished(context, payload, variables);
            StackCreationContext newContext = new StackCreationContext(context.getFlowParameters(), stack, context.getCloudContext(), context.getCloudCredential(), context.getCloudStack());
            sendEvent(newContext);
        }

        @Override
        protected Selectable createRequest(StackCreationContext context) {
            List<CloudInstance> cloudInstances = cloudStackConverter.buildInstances(context.getStack());
            List<CloudResource> cloudResources = context.getStack().getResources().stream().map(r -> cloudResourceConverter.convert(r)).collect(Collectors.toList());
            return new CollectMetadataRequest(context.getCloudContext(), context.getCloudCredential(), cloudResources, cloudInstances, cloudInstances);
        }
    };
}
Also used : START_DATE(com.sequenceiq.cloudbreak.core.flow2.stack.provision.StackProvisionConstants.START_DATE) CreateCredentialRequest(com.sequenceiq.cloudbreak.cloud.event.resource.CreateCredentialRequest) ProvisionEvent(com.sequenceiq.cloudbreak.reactor.api.event.stack.ProvisionEvent) CreateUserDataSuccess(com.sequenceiq.cloudbreak.reactor.api.event.stack.userdata.CreateUserDataSuccess) Action(org.springframework.statemachine.action.Action) PrepareImageRequest(com.sequenceiq.cloudbreak.cloud.event.setup.PrepareImageRequest) Date(java.util.Date) CollectLoadBalancerMetadataRequest(com.sequenceiq.cloudbreak.cloud.event.loadbalancer.CollectLoadBalancerMetadataRequest) StackToCloudStackConverter(com.sequenceiq.cloudbreak.converter.spi.StackToCloudStackConverter) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) LaunchLoadBalancerRequest(com.sequenceiq.cloudbreak.cloud.event.resource.LaunchLoadBalancerRequest) TlsInfo(com.sequenceiq.cloudbreak.cloud.model.TlsInfo) StackWithFingerprintsEvent(com.sequenceiq.cloudbreak.reactor.api.event.stack.StackWithFingerprintsEvent) ImageService(com.sequenceiq.cloudbreak.service.image.ImageService) InstanceMetaDataToCloudInstanceConverter(com.sequenceiq.cloudbreak.converter.spi.InstanceMetaDataToCloudInstanceConverter) CreateUserDataRequest(com.sequenceiq.cloudbreak.reactor.api.event.stack.userdata.CreateUserDataRequest) LoadBalancer(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer) Map(java.util.Map) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) ValidationRequest(com.sequenceiq.cloudbreak.cloud.event.setup.ValidationRequest) AbstractStackFailureAction(com.sequenceiq.cloudbreak.core.flow2.stack.AbstractStackFailureAction) LoadBalancerPersistenceService(com.sequenceiq.cloudbreak.service.stack.LoadBalancerPersistenceService) StackCreationService(com.sequenceiq.cloudbreak.core.flow2.stack.provision.service.StackCreationService) StackFailureContext(com.sequenceiq.cloudbreak.core.flow2.stack.StackFailureContext) CreateCredentialResult(com.sequenceiq.cloudbreak.cloud.event.resource.CreateCredentialResult) Collectors(java.util.stream.Collectors) GetTlsInfoResult(com.sequenceiq.cloudbreak.cloud.event.instance.GetTlsInfoResult) Configuration(org.springframework.context.annotation.Configuration) SetupResult(com.sequenceiq.cloudbreak.cloud.event.setup.SetupResult) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) List(java.util.List) ValidationResult(com.sequenceiq.cloudbreak.cloud.event.setup.ValidationResult) Optional(java.util.Optional) StackCreationEvent(com.sequenceiq.cloudbreak.core.flow2.stack.provision.StackCreationEvent) SetupRequest(com.sequenceiq.cloudbreak.cloud.event.setup.SetupRequest) CollectLoadBalancerMetadataResult(com.sequenceiq.cloudbreak.cloud.event.loadbalancer.CollectLoadBalancerMetadataResult) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) FailurePolicy(com.sequenceiq.cloudbreak.domain.FailurePolicy) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) StackFailureEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent) Image(com.sequenceiq.cloudbreak.cloud.model.Image) StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) LoadBalancerType(com.sequenceiq.common.api.type.LoadBalancerType) Inject(javax.inject.Inject) ResourceToCloudResourceConverter(com.sequenceiq.cloudbreak.converter.spi.ResourceToCloudResourceConverter) LaunchLoadBalancerResult(com.sequenceiq.cloudbreak.cloud.event.resource.LaunchLoadBalancerResult) GetSSHFingerprintsResult(com.sequenceiq.cloudbreak.cloud.event.instance.GetSSHFingerprintsResult) GetSSHFingerprintsRequest(com.sequenceiq.cloudbreak.cloud.event.instance.GetSSHFingerprintsRequest) CollectMetadataResult(com.sequenceiq.cloudbreak.cloud.event.instance.CollectMetadataResult) CollectMetadataRequest(com.sequenceiq.cloudbreak.cloud.event.instance.CollectMetadataRequest) LaunchStackResult(com.sequenceiq.cloudbreak.cloud.event.resource.LaunchStackResult) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) EnvironmentClientService(com.sequenceiq.cloudbreak.service.environment.EnvironmentClientService) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) MetricType(com.sequenceiq.cloudbreak.service.metrics.MetricType) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) GetTlsInfoRequest(com.sequenceiq.cloudbreak.cloud.event.instance.GetTlsInfoRequest) StackCreationContext(com.sequenceiq.cloudbreak.core.flow2.stack.start.StackCreationContext) LaunchStackRequest(com.sequenceiq.cloudbreak.cloud.event.resource.LaunchStackRequest) Bean(org.springframework.context.annotation.Bean) StackCreationState(com.sequenceiq.cloudbreak.core.flow2.stack.provision.StackCreationState) StackCreationContext(com.sequenceiq.cloudbreak.core.flow2.stack.start.StackCreationContext) CollectMetadataRequest(com.sequenceiq.cloudbreak.cloud.event.instance.CollectMetadataRequest) LaunchLoadBalancerResult(com.sequenceiq.cloudbreak.cloud.event.resource.LaunchLoadBalancerResult) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) Map(java.util.Map) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Bean(org.springframework.context.annotation.Bean)

Aggregations

StackCreationContext (com.sequenceiq.cloudbreak.core.flow2.stack.start.StackCreationContext)14 Map (java.util.Map)13 Bean (org.springframework.context.annotation.Bean)13 StackFailureEvent (com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent)7 Optional (java.util.Optional)7 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)6 AbstractStackCreationAction (com.sequenceiq.cloudbreak.core.flow2.stack.provision.action.AbstractStackCreationAction)6 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)6 StackEvent (com.sequenceiq.cloudbreak.reactor.api.event.StackEvent)6 GetTlsInfoResult (com.sequenceiq.cloudbreak.cloud.event.instance.GetTlsInfoResult)4 GetSSHFingerprintsRequest (com.sequenceiq.cloudbreak.cloud.event.instance.GetSSHFingerprintsRequest)3 GetSSHFingerprintsResult (com.sequenceiq.cloudbreak.cloud.event.instance.GetSSHFingerprintsResult)3 GetTlsInfoRequest (com.sequenceiq.cloudbreak.cloud.event.instance.GetTlsInfoRequest)3 CollectLoadBalancerMetadataResult (com.sequenceiq.cloudbreak.cloud.event.loadbalancer.CollectLoadBalancerMetadataResult)3 CreateCredentialRequest (com.sequenceiq.cloudbreak.cloud.event.resource.CreateCredentialRequest)3 PrepareImageRequest (com.sequenceiq.cloudbreak.cloud.event.setup.PrepareImageRequest)3 SetupResult (com.sequenceiq.cloudbreak.cloud.event.setup.SetupResult)3 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)3 Image (com.sequenceiq.cloudbreak.cloud.model.Image)3 TlsInfo (com.sequenceiq.cloudbreak.cloud.model.TlsInfo)3