use of com.sequenceiq.cloudbreak.cloud.event.platform.CheckPlatformVariantResult in project cloudbreak by hortonworks.
the class ServiceProviderConnectorAdapter method checkAndGetPlatformVariant.
public Variant checkAndGetPlatformVariant(Stack stack) {
LOGGER.debug("Get platform variant 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());
CheckPlatformVariantRequest checkPlatformVariantRequest = new CheckPlatformVariantRequest(cloudContext, cloudCredential);
eventBus.notify(checkPlatformVariantRequest.selector(), eventFactory.createEvent(checkPlatformVariantRequest));
try {
CheckPlatformVariantResult res = checkPlatformVariantRequest.await();
LOGGER.info("Platform variant result: {}", res);
if (res.getStatus().equals(EventStatus.FAILED)) {
LOGGER.error("Failed to get platform variant", res.getErrorDetails());
throw new OperationException(res.getErrorDetails());
}
return res.getDefaultPlatformVariant();
} catch (InterruptedException e) {
LOGGER.error("Error while getting the platform variant: " + cloudContext, e);
throw new OperationException(e);
}
}
use of com.sequenceiq.cloudbreak.cloud.event.platform.CheckPlatformVariantResult in project cloudbreak by hortonworks.
the class CheckPlatformVariantHandler method accept.
@Override
public void accept(Event<CheckPlatformVariantRequest> defaultPlatformVariantRequestEvent) {
LOGGER.info("Received event: {}", defaultPlatformVariantRequestEvent);
CheckPlatformVariantRequest request = defaultPlatformVariantRequestEvent.getData();
try {
CloudConnector cc = cloudPlatformConnectors.get(request.getCloudContext().getPlatform(), request.getCloudContext().getVariant());
Variant defaultVariant = cc.variant();
CheckPlatformVariantResult platformParameterResult = new CheckPlatformVariantResult(request, defaultVariant);
request.getResult().onNext(platformParameterResult);
LOGGER.info("Query platform variant finished.");
} catch (RuntimeException e) {
request.getResult().onNext(new CheckPlatformVariantResult(e.getMessage(), e, request));
}
}
Aggregations