use of com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformResourceGroupsResult in project cloudbreak by hortonworks.
the class CloudParameterService method getResourceGroups.
@Retryable(value = GetCloudParameterException.class, maxAttempts = 5, backoff = @Backoff(delay = 1000, multiplier = 2, maxDelay = 10000))
public CloudResourceGroups getResourceGroups(ExtendedCloudCredential cloudCredential, String region, String platformVariant, Map<String, String> filters) {
LOGGER.debug("Get platform resource groups for credential: [{}]", cloudCredential.getName());
GetPlatformResourceGroupsRequest request = new GetPlatformResourceGroupsRequest(cloudCredential, cloudCredential, platformVariant, region, null);
eventBus.notify(request.selector(), Event.wrap(request));
try {
GetPlatformResourceGroupsResult result = request.await();
LOGGER.debug("Platform ResourceGroupsResult result: {}", result);
if (result.getStatus().equals(EventStatus.FAILED)) {
LOGGER.debug("Failed to get platform ResourceGroupsResult", result.getErrorDetails());
throw new GetCloudParameterException(String.format("Failed to get resource groups tables for the cloud provider: %s. %s", result.getStatusReason(), getCauseMessages(result.getErrorDetails())), result.getErrorDetails());
}
return result.getResourceGroups();
} catch (InterruptedException e) {
LOGGER.error("Error while getting the platform ResourceGroupsResult", e);
throw new OperationException(e);
}
}
use of com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformResourceGroupsResult in project cloudbreak by hortonworks.
the class GetPlatformResourceGroupsHandler method accept.
@Override
public void accept(Event<GetPlatformResourceGroupsRequest> event) {
LOGGER.debug("Received event: {}", event);
GetPlatformResourceGroupsRequest request = event.getData();
try {
CloudPlatformVariant cloudPlatformVariant = new CloudPlatformVariant(Platform.platform(request.getExtendedCloudCredential().getCloudPlatform()), Variant.variant(request.getVariant()));
CloudResourceGroups resourceGroups = cloudPlatformConnectors.get(cloudPlatformVariant).platformResources().resourceGroups(request.getExtendedCloudCredential(), Region.region(request.getRegion()), request.getFilters());
GetPlatformResourceGroupsResult result = new GetPlatformResourceGroupsResult(request.getResourceId(), resourceGroups);
request.getResult().onNext(result);
LOGGER.debug("Query platform Resource groups finished.");
} catch (RuntimeException e) {
request.getResult().onNext(new GetPlatformResourceGroupsResult(e.getMessage(), e, request.getResourceId()));
}
}
Aggregations