use of com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformCloudIpPoolsRequest in project cloudbreak by hortonworks.
the class CloudParameterService method getPublicIpPools.
public CloudIpPools getPublicIpPools(Credential credential, String region, String variant, Map<String, String> filters) {
LOGGER.debug("Get platform publicIpPools");
ExtendedCloudCredential cloudCredential = credentialToExtendedCloudCredentialConverter.convert(credential);
GetPlatformCloudIpPoolsRequest getPlatformCloudIpPoolsRequest = new GetPlatformCloudIpPoolsRequest(cloudCredential, cloudCredential, variant, region, filters);
eventBus.notify(getPlatformCloudIpPoolsRequest.selector(), Event.wrap(getPlatformCloudIpPoolsRequest));
try {
GetPlatformCloudIpPoolsResult res = getPlatformCloudIpPoolsRequest.await();
LOGGER.info("Platform publicIpPools result: {}", res);
if (res.getStatus().equals(EventStatus.FAILED)) {
LOGGER.error("Failed to get platform publicIpPools", res.getErrorDetails());
throw new GetCloudParameterException("Failed to get public IP pools for the cloud provider", res.getErrorDetails());
}
return res.getCloudIpPools();
} catch (InterruptedException e) {
LOGGER.error("Error while getting the platform publicIpPools", e);
throw new OperationException(e);
}
}
use of com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformCloudIpPoolsRequest in project cloudbreak by hortonworks.
the class GetPlatformIpPoolsHandler method accept.
@Override
public void accept(Event<GetPlatformCloudIpPoolsRequest> getPlatformIpPoolsRequest) {
LOGGER.info("Received event: {}", getPlatformIpPoolsRequest);
GetPlatformCloudIpPoolsRequest request = getPlatformIpPoolsRequest.getData();
try {
CloudPlatformVariant cloudPlatformVariant = new CloudPlatformVariant(Platform.platform(request.getExtendedCloudCredential().getCloudPlatform()), Variant.variant(request.getVariant()));
CloudIpPools cloudIpPools = cloudPlatformConnectors.get(cloudPlatformVariant).platformResources().publicIpPool(request.getCloudCredential(), Region.region(request.getRegion()), request.getFilters());
GetPlatformCloudIpPoolsResult getPlatformIpPoolsResult = new GetPlatformCloudIpPoolsResult(request, cloudIpPools);
request.getResult().onNext(getPlatformIpPoolsResult);
LOGGER.info("Query platform ip pool types finished.");
} catch (Exception e) {
request.getResult().onNext(new GetPlatformCloudIpPoolsResult(e.getMessage(), e, request));
}
}
Aggregations