use of com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformNetworksResult in project cloudbreak by hortonworks.
the class CloudParameterService method getCloudNetworks.
public CloudNetworks getCloudNetworks(Credential credential, String region, String variant, Map<String, String> filters) {
LOGGER.debug("Get platform cloudnetworks");
ExtendedCloudCredential cloudCredential = credentialToExtendedCloudCredentialConverter.convert(credential);
GetPlatformNetworksRequest getPlatformNetworksRequest = new GetPlatformNetworksRequest(cloudCredential, cloudCredential, variant, region, filters);
eventBus.notify(getPlatformNetworksRequest.selector(), eventFactory.createEvent(getPlatformNetworksRequest));
try {
GetPlatformNetworksResult res = getPlatformNetworksRequest.await();
LOGGER.info("Platform networks types result: {}", res);
if (res.getStatus().equals(EventStatus.FAILED)) {
LOGGER.error("Failed to get platform networks", res.getErrorDetails());
throw new GetCloudParameterException("Failed to get networks for the cloud provider", res.getErrorDetails());
}
return res.getCloudNetworks();
} catch (InterruptedException e) {
LOGGER.error("Error while getting the platform networks", e);
throw new OperationException(e);
}
}
use of com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformNetworksResult in project cloudbreak by hortonworks.
the class GetPlatformNetworksHandler method accept.
@Override
public void accept(Event<GetPlatformNetworksRequest> getPlatformNetworksRequest) {
LOGGER.info("Received event: {}", getPlatformNetworksRequest);
GetPlatformNetworksRequest request = getPlatformNetworksRequest.getData();
try {
CloudPlatformVariant cloudPlatformVariant = new CloudPlatformVariant(Platform.platform(request.getExtendedCloudCredential().getCloudPlatform()), Variant.variant(request.getVariant()));
CloudNetworks networks = cloudPlatformConnectors.get(cloudPlatformVariant).platformResources().networks(request.getCloudCredential(), Region.region(request.getRegion()), request.getFilters());
GetPlatformNetworksResult getPlatformNetworksResult = new GetPlatformNetworksResult(request, networks);
request.getResult().onNext(getPlatformNetworksResult);
LOGGER.info("Query platform networks types finished.");
} catch (Exception e) {
request.getResult().onNext(new GetPlatformNetworksResult(e.getMessage(), e, request));
}
}
Aggregations