use of com.sequenceiq.cloudbreak.cloud.event.platform.PlatformParameterResult in project cloudbreak by hortonworks.
the class ServiceProviderConnectorAdapter method getPlatformParameters.
public PlatformParameters getPlatformParameters(Stack stack) {
LOGGER.debug("Get platform parameters for: {}", 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());
PlatformParameterRequest parameterRequest = new PlatformParameterRequest(cloudContext, cloudCredential);
eventBus.notify(parameterRequest.selector(), eventFactory.createEvent(parameterRequest));
try {
PlatformParameterResult res = parameterRequest.await();
LOGGER.info("Platform parameter result: {}", res);
if (res.getStatus().equals(EventStatus.FAILED)) {
LOGGER.error("Failed to get platform parameters", res.getErrorDetails());
throw new OperationException(res.getErrorDetails());
}
return res.getPlatformParameters();
} catch (InterruptedException e) {
LOGGER.error("Error while getting platform parameters: " + cloudContext, e);
throw new OperationException(e);
}
}
use of com.sequenceiq.cloudbreak.cloud.event.platform.PlatformParameterResult in project cloudbreak by hortonworks.
the class PlatformParameterHandler method accept.
@Override
public void accept(Event<PlatformParameterRequest> platformParameterRequestEvent) {
LOGGER.info("Received event: {}", platformParameterRequestEvent);
PlatformParameterRequest request = platformParameterRequestEvent.getData();
try {
CloudConnector connector = cloudPlatformConnectors.get(request.getCloudContext().getPlatformVariant());
PlatformParameters platformParameters = connector.parameters();
PlatformParameterResult platformParameterResult = new PlatformParameterResult(request, platformParameters);
request.getResult().onNext(platformParameterResult);
LOGGER.info("Query platform parameters finished.");
} catch (RuntimeException e) {
request.getResult().onNext(new PlatformParameterResult(e.getMessage(), e, request));
}
}
Aggregations