use of com.sequenceiq.cloudbreak.cloud.event.setup.PrepareImageResult in project cloudbreak by hortonworks.
the class PrepareImageHandler method accept.
@Override
public void accept(Event<PrepareImageRequest> event) {
LOGGER.info("Received event: {}", event);
PrepareImageRequest request = event.getData();
CloudContext cloudContext = request.getCloudContext();
try {
CloudConnector connector = cloudPlatformConnectors.get(request.getCloudContext().getPlatformVariant());
AuthenticatedContext auth = connector.authentication().authenticate(cloudContext, request.getCloudCredential());
Image image = request.getImage();
CloudStack stack = request.getStack();
connector.setup().prepareImage(auth, stack, image);
PrepareImageResult result = new PrepareImageResult(request);
request.getResult().onNext(result);
eventBus.notify(result.selector(), new Event<>(event.getHeaders(), result));
LOGGER.info("Prepare image finished for {}", cloudContext);
} catch (RuntimeException e) {
PrepareImageResult failure = new PrepareImageResult(e, request);
request.getResult().onNext(failure);
eventBus.notify(failure.selector(), new Event<>(event.getHeaders(), failure));
}
}
Aggregations