Search in sources :

Example 1 with GetPlatformCloudGatewaysResult

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));
    }
}
Also used : CloudGateWays(com.sequenceiq.cloudbreak.cloud.model.CloudGateWays) CloudPlatformVariant(com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant) GetPlatformCloudGatewaysRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformCloudGatewaysRequest) GetPlatformCloudGatewaysResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformCloudGatewaysResult)

Example 2 with GetPlatformCloudGatewaysResult

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);
    }
}
Also used : ExtendedCloudCredential(com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential) GetPlatformCloudGatewaysRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformCloudGatewaysRequest) GetPlatformCloudGatewaysResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformCloudGatewaysResult) OperationException(com.sequenceiq.cloudbreak.service.stack.connector.OperationException)

Aggregations

GetPlatformCloudGatewaysRequest (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformCloudGatewaysRequest)2 GetPlatformCloudGatewaysResult (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformCloudGatewaysResult)2 CloudGateWays (com.sequenceiq.cloudbreak.cloud.model.CloudGateWays)1 CloudPlatformVariant (com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)1 ExtendedCloudCredential (com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential)1 OperationException (com.sequenceiq.cloudbreak.service.stack.connector.OperationException)1