Search in sources :

Example 1 with GetPlatformCloudIpPoolsResult

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

Example 2 with GetPlatformCloudIpPoolsResult

use of com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformCloudIpPoolsResult 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));
    }
}
Also used : GetPlatformCloudIpPoolsRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformCloudIpPoolsRequest) CloudIpPools(com.sequenceiq.cloudbreak.cloud.model.CloudIpPools) CloudPlatformVariant(com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant) GetPlatformCloudIpPoolsResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformCloudIpPoolsResult)

Aggregations

GetPlatformCloudIpPoolsRequest (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformCloudIpPoolsRequest)2 GetPlatformCloudIpPoolsResult (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformCloudIpPoolsResult)2 CloudIpPools (com.sequenceiq.cloudbreak.cloud.model.CloudIpPools)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