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);
}
}
};
}
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);
}
};
}
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);
}
};
}
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);
}
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());
}
};
}
Aggregations