use of com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformRegionsResultV2 in project cloudbreak by hortonworks.
the class GetRegionsV2Handler method accept.
@Override
public void accept(Event<GetPlatformRegionsRequestV2> getRegionsRequestEvent) {
LOGGER.info("Received event: {}", getRegionsRequestEvent);
GetPlatformRegionsRequestV2 request = getRegionsRequestEvent.getData();
try {
CloudPlatformVariant cloudPlatformVariant = new CloudPlatformVariant(Platform.platform(request.getExtendedCloudCredential().getCloudPlatform()), Variant.variant(request.getVariant()));
CloudRegions cloudRegions = cloudPlatformConnectors.get(cloudPlatformVariant).platformResources().regions(request.getCloudCredential(), Region.region(request.getRegion()), request.getFilters());
GetPlatformRegionsResultV2 getPlatformRegionsResultV2 = new GetPlatformRegionsResultV2(request, cloudRegions);
request.getResult().onNext(getPlatformRegionsResultV2);
LOGGER.info("Query platform regions types finished.");
} catch (Exception e) {
LOGGER.warn("Could not get regions from the cloud provider due to:", e);
request.getResult().onNext(new GetPlatformRegionsResultV2(e.getMessage(), e, request));
}
}
use of com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformRegionsResultV2 in project cloudbreak by hortonworks.
the class CloudParameterService method getRegionsV2.
public CloudRegions getRegionsV2(Credential credential, String region, String variant, Map<String, String> filters) {
LOGGER.debug("Get platform regions");
ExtendedCloudCredential cloudCredential = credentialToExtendedCloudCredentialConverter.convert(credential);
GetPlatformRegionsRequestV2 getPlatformRegionsRequest = new GetPlatformRegionsRequestV2(cloudCredential, cloudCredential, variant, region, filters);
eventBus.notify(getPlatformRegionsRequest.selector(), Event.wrap(getPlatformRegionsRequest));
try {
GetPlatformRegionsResultV2 res = getPlatformRegionsRequest.await();
LOGGER.info("Platform regions result: {}", res);
if (res.getStatus().equals(EventStatus.FAILED)) {
throw new GetCloudParameterException("Failed to get regions from the cloud provider due to network issues or invalid credential", res.getErrorDetails());
}
return res.getCloudRegions();
} catch (InterruptedException e) {
LOGGER.error("Error while getting the platform regions", e);
throw new OperationException(e);
}
}
Aggregations