use of com.sequenceiq.cloudbreak.cloud.event.setup.SetupResult in project cloudbreak by hortonworks.
the class ProvisionSetupHandler method accept.
@Override
public void accept(Event<SetupRequest> event) {
LOGGER.info("Received event: {}", event);
SetupRequest request = event.getData();
CloudContext cloudContext = request.getCloudContext();
SetupResult result;
try {
CloudConnector connector = cloudPlatformConnectors.get(cloudContext.getPlatformVariant());
AuthenticatedContext auth = connector.authentication().authenticate(cloudContext, request.getCloudCredential());
CloudStack cloudStack = request.getCloudStack();
connector.setup().prerequisites(auth, cloudStack, resourceNotifier);
result = new SetupResult(request);
LOGGER.info("Provision setup finished for {}", cloudContext);
} catch (RuntimeException e) {
result = new SetupResult(e, request);
}
request.getResult().onNext(result);
eventBus.notify(result.selector(), new Event<>(event.getHeaders(), result));
}
use of com.sequenceiq.cloudbreak.cloud.event.setup.SetupResult 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);
}
}
};
}
Aggregations