Search in sources :

Example 16 with AvailabilityZone

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

the class MockPlatformResources method readVmTypes.

private Map<String, Set<VmType>> readVmTypes() {
    Map<String, Set<VmType>> availabilityZoneHashMap = new HashMap<>();
    Set<VmType> vmTypeList = new HashSet<>();
    for (MockedVmTypes vmType : MockedVmTypes.values()) {
        vmTypeList.add(VmType.vmTypeWithMeta(vmType.value, vmType.getVmTypeMeta(), true));
    }
    for (Entry<Region, List<AvailabilityZone>> regionListEntry : regions.entrySet()) {
        for (AvailabilityZone availabilityZone : regionListEntry.getValue()) {
            availabilityZoneHashMap.put(availabilityZone.value(), vmTypeList);
        }
    }
    return availabilityZoneHashMap;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) VmType(com.sequenceiq.cloudbreak.cloud.model.VmType) Region(com.sequenceiq.cloudbreak.cloud.model.Region) AvailabilityZone(com.sequenceiq.cloudbreak.cloud.model.AvailabilityZone) ArrayList(java.util.ArrayList) List(java.util.List) HashSet(java.util.HashSet)

Example 17 with AvailabilityZone

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

the class OpenStackClientTest method testGetZonesWhenAvailabiltyZonesEmpt.

@Test
public void testGetZonesWhenAvailabiltyZonesEmpt() {
    OSClient<?> osClient = mock(OSClient.class);
    ComputeService computeService = mock(ComputeService.class);
    ZoneService zoneService = mock(ZoneService.class);
    when(osClient.compute()).thenReturn(computeService);
    when(computeService.zones()).thenReturn(zoneService);
    when(zoneService.list()).thenReturn(Collections.emptyList());
    List<AvailabilityZone> actual = underTest.getZones(osClient, "region");
    Assert.assertEquals(0, actual.size());
}
Also used : ZoneService(org.openstack4j.api.compute.ext.ZoneService) AvailabilityZone(com.sequenceiq.cloudbreak.cloud.model.AvailabilityZone) ComputeService(org.openstack4j.api.compute.ComputeService) Test(org.junit.Test)

Aggregations

AvailabilityZone (com.sequenceiq.cloudbreak.cloud.model.AvailabilityZone)17 HashMap (java.util.HashMap)13 List (java.util.List)10 Region (com.sequenceiq.cloudbreak.cloud.model.Region)9 CloudRegions (com.sequenceiq.cloudbreak.cloud.model.CloudRegions)8 HashSet (java.util.HashSet)7 ArrayList (java.util.ArrayList)6 Set (java.util.Set)6 Cacheable (org.springframework.cache.annotation.Cacheable)5 CloudVmTypes (com.sequenceiq.cloudbreak.cloud.model.CloudVmTypes)4 Test (org.junit.Test)4 VmType (com.sequenceiq.cloudbreak.cloud.model.VmType)3 IOException (java.io.IOException)3 AmazonEC2Client (com.amazonaws.services.ec2.AmazonEC2Client)2 Compute (com.google.api.services.compute.Compute)2 MachineTypeList (com.google.api.services.compute.model.MachineTypeList)2 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)2 CloudGateWay (com.sequenceiq.cloudbreak.cloud.model.CloudGateWay)2 CloudGateWays (com.sequenceiq.cloudbreak.cloud.model.CloudGateWays)2 Collections.singletonList (java.util.Collections.singletonList)2