Search in sources :

Example 1 with AbstractStackCreationAction

use of com.sequenceiq.cloudbreak.core.flow2.stack.provision.action.AbstractStackCreationAction in project cloudbreak by hortonworks.

the class ClusterCreationActions method clusterProxyRegistrationAction.

@Bean(name = "CLUSTER_PROXY_REGISTRATION_STATE")
public Action<?, ?> clusterProxyRegistrationAction() {
    return new AbstractStackCreationAction<>(ProvisionEvent.class) {

        @Inject
        private ClusterProxyEnablementService clusterProxyEnablementService;

        @Override
        protected void prepareExecution(ProvisionEvent payload, Map<Object, Object> variables) {
            super.prepareExecution(payload, variables);
            variables.put(PROVISION_TYPE, payload.getProvisionType());
        }

        @Override
        protected void doExecute(StackCreationContext context, ProvisionEvent payload, Map<Object, Object> variables) {
            if (clusterProxyEnablementService.isClusterProxyApplicable(context.getStack().cloudPlatform())) {
                clusterCreationService.registeringToClusterProxy(context.getStack());
                sendEvent(context);
            } else {
                ClusterProxyRegistrationSuccess clusterProxyRegistrationSuccess = new ClusterProxyRegistrationSuccess(payload.getResourceId());
                sendEvent(context, clusterProxyRegistrationSuccess);
            }
        }

        @Override
        protected Selectable createRequest(StackCreationContext context) {
            return new ClusterProxyRegistrationRequest(context.getStack().getId(), context.getStack().cloudPlatform());
        }
    };
}
Also used : StackCreationContext(com.sequenceiq.cloudbreak.core.flow2.stack.start.StackCreationContext) AbstractStackCreationAction(com.sequenceiq.cloudbreak.core.flow2.stack.provision.action.AbstractStackCreationAction) ClusterProxyEnablementService(com.sequenceiq.cloudbreak.clusterproxy.ClusterProxyEnablementService) ClusterProxyRegistrationRequest(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ClusterProxyRegistrationRequest) ProvisionEvent(com.sequenceiq.cloudbreak.reactor.api.event.stack.ProvisionEvent) ClusterProxyRegistrationSuccess(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ClusterProxyRegistrationSuccess) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 2 with AbstractStackCreationAction

use of com.sequenceiq.cloudbreak.core.flow2.stack.provision.action.AbstractStackCreationAction in project cloudbreak by hortonworks.

the class StackCreationActions method tlsSetupAction.

@Bean(name = "TLS_SETUP_STATE")
public Action<?, ?> tlsSetupAction() {
    return new AbstractStackCreationAction<>(GetSSHFingerprintsResult.class) {

        @Override
        protected void doExecute(StackCreationContext context, GetSSHFingerprintsResult payload, Map<Object, Object> variables) throws Exception {
            if (!context.getStack().getTunnel().useCcm()) {
                stackCreationService.setupTls(context);
            }
            StackWithFingerprintsEvent fingerprintsEvent = new StackWithFingerprintsEvent(payload.getResourceId(), payload.getSshFingerprints());
            sendEvent(context, StackCreationEvent.TLS_SETUP_FINISHED_EVENT.event(), fingerprintsEvent);
        }
    };
}
Also used : StackCreationContext(com.sequenceiq.cloudbreak.core.flow2.stack.start.StackCreationContext) StackWithFingerprintsEvent(com.sequenceiq.cloudbreak.reactor.api.event.stack.StackWithFingerprintsEvent) Map(java.util.Map) GetSSHFingerprintsResult(com.sequenceiq.cloudbreak.cloud.event.instance.GetSSHFingerprintsResult) Bean(org.springframework.context.annotation.Bean)

Example 3 with AbstractStackCreationAction

use of com.sequenceiq.cloudbreak.core.flow2.stack.provision.action.AbstractStackCreationAction in project cloudbreak by hortonworks.

the class StackCreationActions method prepareImageAction.

@Bean(name = "IMAGESETUP_STATE")
public Action<?, ?> prepareImageAction() {
    return new AbstractStackCreationAction<>(SetupResult.class) {

        @Override
        protected void doExecute(StackCreationContext context, SetupResult payload, Map<Object, Object> variables) {
            stackCreationService.prepareImage(context.getStack(), variables);
            sendEvent(context);
        }

        @Override
        protected Selectable createRequest(StackCreationContext context) {
            try {
                CloudStack cloudStack = cloudStackConverter.convert(context.getStack());
                Image image = imageService.getImage(context.getCloudContext().getId());
                return new PrepareImageRequest<>(context.getCloudContext(), context.getCloudCredential(), cloudStack, image);
            } catch (CloudbreakImageNotFoundException e) {
                throw new CloudbreakServiceException(e);
            }
        }
    };
}
Also used : SetupResult(com.sequenceiq.cloudbreak.cloud.event.setup.SetupResult) StackCreationContext(com.sequenceiq.cloudbreak.core.flow2.stack.start.StackCreationContext) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) Image(com.sequenceiq.cloudbreak.cloud.model.Image) Map(java.util.Map) PrepareImageRequest(com.sequenceiq.cloudbreak.cloud.event.setup.PrepareImageRequest) Bean(org.springframework.context.annotation.Bean)

Example 4 with AbstractStackCreationAction

use of com.sequenceiq.cloudbreak.core.flow2.stack.provision.action.AbstractStackCreationAction in project cloudbreak by hortonworks.

the class StackCreationActions method getTlsInfoAction.

@Bean(name = "GET_TLS_INFO_STATE")
public Action<?, ?> getTlsInfoAction() {
    return new AbstractStackCreationAction<>(GetTlsInfoResult.class) {

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

        @Override
        protected Selectable createRequest(StackCreationContext context) {
            Stack stack = context.getStack();
            InstanceMetaData gatewayMetaData = stack.getPrimaryGatewayInstance();
            DetailedEnvironmentResponse environment = environmentClientService.getByCrnAsInternal(stack.getEnvironmentCrn());
            CloudInstance gatewayInstance = metadataConverter.convert(gatewayMetaData, environment, stack.getStackAuthentication());
            return new GetSSHFingerprintsRequest<GetSSHFingerprintsResult>(context.getCloudContext(), context.getCloudCredential(), gatewayInstance);
        }
    };
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) StackCreationContext(com.sequenceiq.cloudbreak.core.flow2.stack.start.StackCreationContext) GetSSHFingerprintsRequest(com.sequenceiq.cloudbreak.cloud.event.instance.GetSSHFingerprintsRequest) GetTlsInfoResult(com.sequenceiq.cloudbreak.cloud.event.instance.GetTlsInfoResult) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) Map(java.util.Map) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Bean(org.springframework.context.annotation.Bean)

Example 5 with AbstractStackCreationAction

use of com.sequenceiq.cloudbreak.core.flow2.stack.provision.action.AbstractStackCreationAction 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)

Aggregations

StackCreationContext (com.sequenceiq.cloudbreak.core.flow2.stack.start.StackCreationContext)13 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 AbstractStackCreationAction (com.sequenceiq.cloudbreak.core.flow2.stack.provision.action.AbstractStackCreationAction)6 StackEvent (com.sequenceiq.cloudbreak.reactor.api.event.StackEvent)6 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)5 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)5 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