use of com.sequenceiq.cloudbreak.cloud.model.AvailabilityZone in project cloudbreak by hortonworks.
the class AwsPlatformResources method virtualMachines.
@Override
@Cacheable(cacheNames = "cloudResourceVmTypeCache", key = "#cloudCredential?.id + #region.getRegionName()")
public CloudVmTypes virtualMachines(CloudCredential cloudCredential, Region region, Map<String, String> filters) {
CloudRegions regions = regions(cloudCredential, region, filters);
Map<String, Set<VmType>> cloudVmResponses = new HashMap<>();
Map<String, VmType> defaultCloudVmResponses = new HashMap<>();
for (AvailabilityZone availabilityZone : regions.getCloudRegions().get(region)) {
cloudVmResponses.put(availabilityZone.value(), vmTypes.get(region));
defaultCloudVmResponses.put(availabilityZone.value(), defaultVmTypes.get(region));
}
return new CloudVmTypes(cloudVmResponses, defaultCloudVmResponses);
}
use of com.sequenceiq.cloudbreak.cloud.model.AvailabilityZone in project cloudbreak by hortonworks.
the class AzureTemplateBuilderTest method setUp.
@Before
public void setUp() throws Exception {
initMocks(this);
FreeMarkerConfigurationFactoryBean factoryBean = new FreeMarkerConfigurationFactoryBean();
factoryBean.setPreferFileSystemAccess(false);
factoryBean.setTemplateLoaderPath("classpath:/");
factoryBean.afterPropertiesSet();
Configuration configuration = factoryBean.getObject();
ReflectionTestUtils.setField(azureTemplateBuilder, "freemarkerConfiguration", configuration);
ReflectionTestUtils.setField(azureTemplateBuilder, "armTemplatePath", templatePath);
ReflectionTestUtils.setField(azureTemplateBuilder, "armTemplateParametersPath", "templates/parameters.ftl");
Map<InstanceGroupType, String> userData = ImmutableMap.of(InstanceGroupType.CORE, CORE_CUSTOM_DATA, InstanceGroupType.GATEWAY, GATEWAY_CUSTOM_DATA);
groups = new ArrayList<>();
stackName = "testStack";
name = "master";
List<Volume> volumes = Arrays.asList(new Volume("/hadoop/fs1", "HDD", 1), new Volume("/hadoop/fs2", "HDD", 1));
InstanceTemplate instanceTemplate = new InstanceTemplate("m1.medium", name, 0L, volumes, InstanceStatus.CREATE_REQUESTED, new HashMap<>(), 0L);
Map<String, Object> params = new HashMap<>();
params.put(CloudInstance.SUBNET_ID, "existingSubnet");
InstanceAuthentication instanceAuthentication = new InstanceAuthentication("sshkey", "", "cloudbreak");
instance = new CloudInstance("SOME_ID", instanceTemplate, instanceAuthentication, params);
List<SecurityRule> rules = Collections.singletonList(new SecurityRule("0.0.0.0/0", new PortDefinition[] { new PortDefinition("22", "22"), new PortDefinition("443", "443") }, "tcp"));
security = new Security(rules, null);
image = new Image("cb-centos66-amb200-2015-05-25", userData, "redhat6", "", "default", "default-id");
cloudContext = new CloudContext(7899L, "thisisaverylongazureresourcenamewhichneedstobeshortened", "dummy1", "dummy2", "test", Location.location(Region.region("EU"), new AvailabilityZone("availabilityZone")));
azureCredentialView = new AzureCredentialView(cloudCredential("siq-haas"));
azureStorageView = new AzureStorageView(azureCredentialView, cloudContext, azureStorage, null);
azureSubnetStrategy = AzureSubnetStrategy.getAzureSubnetStrategy(FILL, Collections.singletonList("existingSubnet"), ImmutableMap.of("existingSubnet", 100));
defaultTags.put(CloudbreakResourceType.DISK.templateVariable(), CloudbreakResourceType.DISK.key());
defaultTags.put(CloudbreakResourceType.INSTANCE.templateVariable(), CloudbreakResourceType.INSTANCE.key());
defaultTags.put(CloudbreakResourceType.IP.templateVariable(), CloudbreakResourceType.IP.key());
defaultTags.put(CloudbreakResourceType.NETWORK.templateVariable(), CloudbreakResourceType.NETWORK.key());
defaultTags.put(CloudbreakResourceType.SECURITY.templateVariable(), CloudbreakResourceType.SECURITY.key());
defaultTags.put(CloudbreakResourceType.STORAGE.templateVariable(), CloudbreakResourceType.STORAGE.key());
defaultTags.put(CloudbreakResourceType.TEMPLATE.templateVariable(), CloudbreakResourceType.TEMPLATE.key());
reset(azureUtils);
}
use of com.sequenceiq.cloudbreak.cloud.model.AvailabilityZone in project cloudbreak by hortonworks.
the class OpenStackPlatformResourcesTest method testVirtualMachines.
@Test
public void testVirtualMachines() {
CloudCredential cloudCredential = new CloudCredential(0L, "name");
OSClient osClient = mock(OSClient.class);
String regionName = "region1";
Set<String> regionsFromOpenStack = Sets.newHashSet(regionName);
List<AvailabilityZone> availabilityZones = newArrayList(new AvailabilityZone("zone1"));
Flavor flavor8GB = flavor(8192);
when(openStackClient.createOSClient(cloudCredential)).thenReturn(osClient);
when(openStackClient.getRegion(cloudCredential)).thenReturn(regionsFromOpenStack);
when(openStackClient.getZones(osClient, regionName)).thenReturn(availabilityZones);
when(openStackClient.getFlavors(osClient)).thenReturn((List) Collections.singletonList(flavor8GB));
CloudVmTypes actual = underTest.virtualMachines(cloudCredential, null, null);
Assert.assertEquals(1, actual.getCloudVmResponses().get("zone1").size());
Assert.assertEquals(1, actual.getDefaultCloudVmResponses().size());
Assert.assertEquals("8.0", actual.getCloudVmResponses().get("zone1").iterator().next().getMetaData().getProperties().get("Memory"));
Assert.assertNotNull(actual.getDefaultCloudVmResponses().get(regionName));
}
use of com.sequenceiq.cloudbreak.cloud.model.AvailabilityZone in project cloudbreak by hortonworks.
the class OpenStackPlatformResources method regions.
@Override
@Cacheable(cacheNames = "cloudResourceRegionCache", key = "#cloudCredential?.id")
public CloudRegions regions(CloudCredential cloudCredential, Region region, Map<String, String> filters) {
Set<String> regionsFromOpenStack = openStackClient.getRegion(cloudCredential);
OSClient<?> osClient = openStackClient.createOSClient(cloudCredential);
Map<Region, List<AvailabilityZone>> cloudRegions = new HashMap<>();
Map<Region, String> displayNames = new HashMap<>();
for (String regionFromOpenStack : regionsFromOpenStack) {
List<AvailabilityZone> availabilityZones = openStackClient.getZones(osClient, regionFromOpenStack);
cloudRegions.put(region(regionFromOpenStack), availabilityZones);
displayNames.put(region(regionFromOpenStack), regionFromOpenStack);
}
String defaultRegion = null;
if (!cloudRegions.keySet().isEmpty()) {
defaultRegion = ((StringType) cloudRegions.keySet().toArray()[0]).value();
}
CloudRegions regions = new CloudRegions(cloudRegions, displayNames, defaultRegion);
LOGGER.info("openstack regions result: {}", regions);
return regions;
}
use of com.sequenceiq.cloudbreak.cloud.model.AvailabilityZone in project cloudbreak by hortonworks.
the class OpenStackPlatformResources method gateways.
@Override
public CloudGateWays gateways(CloudCredential cloudCredential, Region region, Map<String, String> filters) {
OSClient<?> osClient = openStackClient.createOSClient(cloudCredential);
Map<String, Set<CloudGateWay>> resultCloudGateWayMap = new HashMap<>();
CloudRegions regions = regions(cloudCredential, region, filters);
for (Entry<Region, List<AvailabilityZone>> regionListEntry : regions.getCloudRegions().entrySet()) {
Set<CloudGateWay> cloudGateWays = new HashSet<>();
List<? extends Router> routerList = osClient.networking().router().list();
LOGGER.info("routers from openstack: {}", routerList);
for (Router router : routerList) {
CloudGateWay cloudGateWay = new CloudGateWay();
cloudGateWay.setId(router.getId());
cloudGateWay.setName(router.getName());
Map<String, Object> properties = new HashMap<>();
properties.put("tenantId", router.getTenantId());
cloudGateWay.setProperties(properties);
cloudGateWays.add(cloudGateWay);
}
for (AvailabilityZone availabilityZone : regionListEntry.getValue()) {
resultCloudGateWayMap.put(availabilityZone.value(), cloudGateWays);
}
}
CloudGateWays cloudGateWays = new CloudGateWays(resultCloudGateWayMap);
LOGGER.info("openstack cloudgateway result: {}", cloudGateWays);
return cloudGateWays;
}
Aggregations