Search in sources :

Example 1 with CloudIpPools

use of com.sequenceiq.cloudbreak.cloud.model.CloudIpPools in project cloudbreak by hortonworks.

the class PlatformParameterV1Controller method getIpPoolsCredentialId.

@Override
public PlatformIpPoolsResponse getIpPoolsCredentialId(PlatformResourceRequestJson resourceRequestJson) {
    resourceRequestJson = prepareAccountAndOwner(resourceRequestJson, authenticatedUserService.getCbUser());
    PlatformResourceRequest convert = conversionService.convert(resourceRequestJson, PlatformResourceRequest.class);
    CloudIpPools cloudIpPools = cloudParameterService.getPublicIpPools(convert.getCredential(), convert.getRegion(), convert.getPlatformVariant(), convert.getFilters());
    return conversionService.convert(cloudIpPools, PlatformIpPoolsResponse.class);
}
Also used : CloudIpPools(com.sequenceiq.cloudbreak.cloud.model.CloudIpPools) PlatformResourceRequest(com.sequenceiq.cloudbreak.domain.PlatformResourceRequest)

Example 2 with CloudIpPools

use of com.sequenceiq.cloudbreak.cloud.model.CloudIpPools in project cloudbreak by hortonworks.

the class OpenStackPlatformResources method publicIpPool.

@Override
public CloudIpPools publicIpPool(CloudCredential cloudCredential, Region region, Map<String, String> filters) {
    OSClient<?> osClient = openStackClient.createOSClient(cloudCredential);
    Map<String, Set<CloudIpPool>> cloudIpPools = new HashMap<>();
    CloudRegions regions = regions(cloudCredential, region, filters);
    for (Entry<Region, List<AvailabilityZone>> regionListEntry : regions.getCloudRegions().entrySet()) {
        Set<CloudIpPool> cloudGateWays = new HashSet<>();
        List<? extends Network> networks = getNetworks(osClient);
        List<? extends Network> networksWithExternalRouter = networks.stream().filter(Network::isRouterExternal).collect(Collectors.toList());
        for (Network network : networksWithExternalRouter) {
            CloudIpPool cloudIpPool = new CloudIpPool();
            cloudIpPool.setId(network.getId());
            cloudIpPool.setName(network.getName());
            cloudGateWays.add(cloudIpPool);
        }
        for (AvailabilityZone availabilityZone : regionListEntry.getValue()) {
            cloudIpPools.put(availabilityZone.value(), cloudGateWays);
        }
    }
    LOGGER.info("openstack public ip pool result: {}", cloudIpPools);
    return new CloudIpPools(cloudIpPools);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) CloudIpPool(com.sequenceiq.cloudbreak.cloud.model.CloudIpPool) CloudRegions(com.sequenceiq.cloudbreak.cloud.model.CloudRegions) AvailabilityZone(com.sequenceiq.cloudbreak.cloud.model.AvailabilityZone) CloudIpPools(com.sequenceiq.cloudbreak.cloud.model.CloudIpPools) Network(org.openstack4j.model.network.Network) CloudNetwork(com.sequenceiq.cloudbreak.cloud.model.CloudNetwork) Region(com.sequenceiq.cloudbreak.cloud.model.Region) List(java.util.List) HashSet(java.util.HashSet)

Example 3 with CloudIpPools

use of com.sequenceiq.cloudbreak.cloud.model.CloudIpPools 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

CloudIpPools (com.sequenceiq.cloudbreak.cloud.model.CloudIpPools)3 GetPlatformCloudIpPoolsRequest (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformCloudIpPoolsRequest)1 GetPlatformCloudIpPoolsResult (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformCloudIpPoolsResult)1 AvailabilityZone (com.sequenceiq.cloudbreak.cloud.model.AvailabilityZone)1 CloudIpPool (com.sequenceiq.cloudbreak.cloud.model.CloudIpPool)1 CloudNetwork (com.sequenceiq.cloudbreak.cloud.model.CloudNetwork)1 CloudPlatformVariant (com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)1 CloudRegions (com.sequenceiq.cloudbreak.cloud.model.CloudRegions)1 Region (com.sequenceiq.cloudbreak.cloud.model.Region)1 PlatformResourceRequest (com.sequenceiq.cloudbreak.domain.PlatformResourceRequest)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 Network (org.openstack4j.model.network.Network)1