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