Search in sources :

Example 1 with StackContext

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

the class StackCreationActions method prepareImageAction.

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

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

        @Override
        protected Selectable createRequest(StackContext 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) StackContext(com.sequenceiq.cloudbreak.core.flow2.stack.StackContext) CloudbreakServiceException(com.sequenceiq.cloudbreak.service.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 2 with StackContext

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

the class StackCreationActions method tlsSetupAction.

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

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

Example 3 with StackContext

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

the class StackCreationActions method getTlsInfoAction.

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

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

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

Example 4 with StackContext

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

the class AbstractStackCreationAction method createFlowContext.

@Override
protected StackContext createFlowContext(String flowId, StateContext<StackCreationState, StackCreationEvent> stateContext, P payload) {
    Stack stack = stackService.getByIdWithLists(payload.getStackId());
    MDCBuilder.buildMdcContext(stack);
    Location location = location(region(stack.getRegion()), availabilityZone(stack.getAvailabilityZone()));
    CloudContext cloudContext = new CloudContext(stack.getId(), stack.getName(), stack.cloudPlatform(), stack.getOwner(), stack.getPlatformVariant(), location);
    CloudCredential cloudCredential = credentialConverter.convert(stack.getCredential());
    CloudStack cloudStack = cloudStackConverter.convert(stack);
    return new StackContext(flowId, stack, cloudContext, cloudCredential, cloudStack);
}
Also used : CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) StackContext(com.sequenceiq.cloudbreak.core.flow2.stack.StackContext) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) Stack(com.sequenceiq.cloudbreak.domain.Stack) Location(com.sequenceiq.cloudbreak.cloud.model.Location)

Example 5 with StackContext

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

the class StackCreationActions method createCredentialAction.

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

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

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

Aggregations

StackContext (com.sequenceiq.cloudbreak.core.flow2.stack.StackContext)7 Map (java.util.Map)6 Bean (org.springframework.context.annotation.Bean)6 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)5 Stack (com.sequenceiq.cloudbreak.domain.Stack)4 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)2 CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)1 CollectMetadataRequest (com.sequenceiq.cloudbreak.cloud.event.instance.CollectMetadataRequest)1 CollectMetadataResult (com.sequenceiq.cloudbreak.cloud.event.instance.CollectMetadataResult)1 GetSSHFingerprintsRequest (com.sequenceiq.cloudbreak.cloud.event.instance.GetSSHFingerprintsRequest)1 GetSSHFingerprintsResult (com.sequenceiq.cloudbreak.cloud.event.instance.GetSSHFingerprintsResult)1 GetTlsInfoRequest (com.sequenceiq.cloudbreak.cloud.event.instance.GetTlsInfoRequest)1 GetTlsInfoResult (com.sequenceiq.cloudbreak.cloud.event.instance.GetTlsInfoResult)1 CreateCredentialRequest (com.sequenceiq.cloudbreak.cloud.event.resource.CreateCredentialRequest)1 LaunchStackResult (com.sequenceiq.cloudbreak.cloud.event.resource.LaunchStackResult)1 PrepareImageRequest (com.sequenceiq.cloudbreak.cloud.event.setup.PrepareImageRequest)1 SetupResult (com.sequenceiq.cloudbreak.cloud.event.setup.SetupResult)1 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)1 CloudResource (com.sequenceiq.cloudbreak.cloud.model.CloudResource)1 Image (com.sequenceiq.cloudbreak.cloud.model.Image)1