use of com.sequenceiq.cloudbreak.core.flow2.stack.start.StackCreationContext 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());
}
};
}
use of com.sequenceiq.cloudbreak.core.flow2.stack.start.StackCreationContext in project cloudbreak by hortonworks.
the class AbstractStackCreationAction method createFlowContext.
@Override
protected StackCreationContext createFlowContext(FlowParameters flowParameters, StateContext<StackCreationState, StackCreationEvent> stateContext, P payload) {
Stack stack = stackService.getByIdWithListsInTransaction(payload.getResourceId());
stack.setResources(new HashSet<>(resourceService.getAllByStackId(payload.getResourceId())));
Map<Object, Object> variables = stateContext.getExtendedState().getVariables();
ProvisionType provisionType = (ProvisionType) variables.getOrDefault(PROVISION_TYPE, ProvisionType.REGULAR);
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()).withUserName(stack.getCreator().getUserName()).withLocation(location).withWorkspaceId(stack.getWorkspace().getId()).withAccountId(Crn.safeFromString(stack.getResourceCrn()).getAccountId()).withTenantId(stack.getTenant().getId()).build();
CloudCredential cloudCredential = stackUtil.getCloudCredential(stack);
CloudStack cloudStack = cloudStackConverter.convert(stack);
return new StackCreationContext(flowParameters, stack, cloudContext, cloudCredential, cloudStack, provisionType);
}
use of com.sequenceiq.cloudbreak.core.flow2.stack.start.StackCreationContext 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);
}
};
}
use of com.sequenceiq.cloudbreak.core.flow2.stack.start.StackCreationContext 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);
}
}
};
}
use of com.sequenceiq.cloudbreak.core.flow2.stack.start.StackCreationContext 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);
}
};
}
Aggregations