use of com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformTemplateResult in project cloudbreak by hortonworks.
the class ServiceProviderConnectorAdapter method getTemplate.
public String getTemplate(Stack 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());
GetPlatformTemplateRequest getPlatformTemplateRequest = new GetPlatformTemplateRequest(cloudContext, cloudCredential);
eventBus.notify(getPlatformTemplateRequest.selector(), eventFactory.createEvent(getPlatformTemplateRequest));
try {
GetPlatformTemplateResult res = getPlatformTemplateRequest.await();
LOGGER.info("Get template result: {}", res);
if (res.getStatus().equals(EventStatus.FAILED)) {
LOGGER.error("Failed to get template", res.getErrorDetails());
throw new OperationException(res.getErrorDetails());
}
return res.getTemplate();
} catch (InterruptedException e) {
LOGGER.error("Error while getting template: " + cloudContext, e);
throw new OperationException(e);
}
}
use of com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformTemplateResult in project cloudbreak by hortonworks.
the class TemplateHandler method accept.
@Override
public void accept(Event<GetPlatformTemplateRequest> platformTemplateRequestEvent) {
LOGGER.info("Received event: {}", platformTemplateRequestEvent);
GetPlatformTemplateRequest request = platformTemplateRequestEvent.getData();
String template = null;
try {
CloudConnector connector = cloudPlatformConnectors.get(request.getCloudContext().getPlatformVariant());
if (connector != null) {
template = connector.resources().getStackTemplate();
}
} catch (TemplatingDoesNotSupportedException ignored) {
}
GetPlatformTemplateResult getPlatformTemplateResult = new GetPlatformTemplateResult(request, template);
request.getResult().onNext(getPlatformTemplateResult);
LOGGER.info("Get template finished.");
}
Aggregations