use of com.sequenceiq.cloudbreak.cloud.model.CloudRegions 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);
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudRegions in project cloudbreak by hortonworks.
the class MockPlatformResourcesTest method getDefaultRegionWhenNoDefaultFoundForMockProviderThenShouldReturnWithTheFirstElement.
@Test
public void getDefaultRegionWhenNoDefaultFoundForMockProviderThenShouldReturnWithTheFirstElement() throws Exception {
ReflectionTestUtils.setField(underTest, "defaultRegions", "AWS:eu-west-1");
underTest.init();
CloudRegions regions = underTest.regions(new CloudCredential(1L, "mock"), region("mock"), new HashMap<>());
Assert.assertEquals("USA", regions.getDefaultRegion());
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudRegions in project cloudbreak by hortonworks.
the class MockPlatformResourcesTest method getDefaultRegionWhenDefaultFoundForMockProviderThenShouldReturnWithDefaultElement.
@Test
public void getDefaultRegionWhenDefaultFoundForMockProviderThenShouldReturnWithDefaultElement() throws Exception {
ReflectionTestUtils.setField(underTest, "defaultRegions", "AWS:eu-west-1,MOCK:Europe");
underTest.init();
CloudRegions regions = underTest.regions(new CloudCredential(1L, "mock"), region("mock"), new HashMap<>());
Assert.assertEquals("Europe", regions.getDefaultRegion());
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudRegions in project cloudbreak by hortonworks.
the class AzurePlatformResources method regions.
@Override
@Cacheable(cacheNames = "cloudResourceRegionCache", key = "#cloudCredential?.id")
public CloudRegions regions(CloudCredential cloudCredential, Region region, Map<String, String> filters) {
AzureClient client = azureClientService.getClient(cloudCredential);
Map<Region, List<AvailabilityZone>> cloudRegions = new HashMap<>();
Map<Region, String> displayNames = new HashMap<>();
String defaultRegion = armZoneParameterDefault;
for (com.microsoft.azure.management.resources.fluentcore.arm.Region azureRegion : client.getRegion(region)) {
cloudRegions.put(region(azureRegion.label()), new ArrayList<>());
displayNames.put(region(azureRegion.label()), azureRegion.label());
}
if (region != null && !Strings.isNullOrEmpty(region.value())) {
defaultRegion = region.value();
}
return new CloudRegions(cloudRegions, displayNames, defaultRegion);
}
Aggregations