public static double getSpace(Hardware input) { double total = 0; for (Volume volume : input.getVolumes()) { Float size = volume.getSize(); if (size != null) { total += size; } } return total; }
public static double getSpace(Hardware input) { double total = 0; for (Volume volume : input.getVolumes()) { Float size = volume.getSize(); if (size != null) { total += size; } } return total; }
public static double getSpace(Hardware input) { double total = 0; for (Volume volume : input.getVolumes()) { Float size = volume.getSize(); if (size != null) { total += size; } } return total; }
public static double getSpace(Hardware input) { double total = 0; for (Volume volume : input.getVolumes()) { Float size = volume.getSize(); if (size != null) { total += size; } } return total; }
private void mapDevices(EC2TemplateOptions ec2TemplateOptions, Template template, String user) { String mkfsOptions = simulatorProperties.get("INSTANCE_STORAGE_MKFS_OPTIONS", DEFAULT_MKFS_OPTIONS); String mountOptions = simulatorProperties.get("INSTANCE_STORAGE_MOUNT_OPTIONS", DEFAULT_MOUNT_OPTIONS); int ephemeralCounter = 0; for (Volume volume : template.getHardware().getVolumes()) { if (!volume.isBootDevice() && LOCAL.equals(volume.getType())) { String device = volume.getDevice(); LOGGER.info(format("Mapping device %s (%d GB)", device, round(volume.getSize()))); ec2TemplateOptions.mapEphemeralDeviceToDeviceName(device, "ephemeral" + ephemeralCounter++); mountDevice(device, mkfsOptions, mountOptions, user); } } }
public static Volume fromVolume(Volume in) { return new VolumeImpl(in.getId(), in.getType(), in.getSize(), in.getDevice(), in.isBootDevice(), in.isDurable()); } }
public static Volume fromVolume(Volume in) { return new VolumeImpl(in.getId(), in.getType(), in.getSize(), in.getDevice(), in.isBootDevice(), in.isDurable()); } }
public static Volume fromVolume(Volume in) { return new VolumeImpl(in.getId(), in.getType(), in.getSize(), in.getDevice(), in.isBootDevice(), in.isDurable()); } }
public static Volume fromVolume(Volume in) { return new VolumeImpl(in.getId(), in.getType(), in.getSize(), in.getDevice(), in.isBootDevice(), in.isDurable()); } }
@Override public NodeMetadata addNodeWithTag(String tag, String name, Template template) { InstantiateVAppTemplateOptions options = processorCount((int) getCores(template.getHardware())).memory( template.getHardware().getRam()).disk( (long) ((template.getHardware().getVolumes().get(0).getSize()) * 1024 * 1024l)); if (!template.getOptions().shouldBlockUntilRunning()) options.block(false); VCloudExpressVApp vApp = computeClient.start(URI.create(template.getLocation().getId()), URI.create(template.getImage().getId()), name, options, template.getOptions().getInboundPorts()); return vAppToNodeMetadata.apply(vApp); }
@Test public void testConversionWhereLocationFound() { UUID id = UUID.randomUUID(); FlavorInZone flavorInZoneToConvert = new FlavorInZone(Flavor.builder().id(id.toString()) .name("Test Flavor " + id).ram(262144).disk(10000).vcpus(16).build(), "az-1.region-a.geo-1"); Hardware converted = new FlavorInZoneToHardware(locationIndex).apply(flavorInZoneToConvert); Flavor flavorToConvert = flavorInZoneToConvert.getFlavor(); assertEquals(converted.getName(), flavorToConvert.getName()); assertEquals(converted.getId(), flavorInZoneToConvert.slashEncode()); assertEquals(converted.getProviderId(), flavorToConvert.getId()); assertEquals(converted.getLocation(), locationIndex.get().get("az-1.region-a.geo-1")); assertEquals(converted.getRam(), flavorToConvert.getRam()); assertNotNull(converted.getProcessors()); assertFalse(converted.getProcessors().isEmpty()); assertEquals(converted.getProcessors().iterator().next().getCores(), (double) flavorToConvert.getVcpus()); assertNotNull(converted.getVolumes()); assertFalse(converted.getVolumes().isEmpty()); assertEquals(converted.getVolumes().iterator().next().getSize(), Float.valueOf(flavorToConvert.getDisk())); }
@Override public Volume apply(@Nullable org.jclouds.compute.domain.Volume input) { if (input == null) { return null; } return Volume.builder().id(input.getId()).size(input.getSize()).type(input.getType().name()).device(input.getDevice()) .durable(input.isDurable()).bootDevice(input.isBootDevice()).build(); } }
@Override @Test(dataProvider = "onlyIfAutomaticHardwareSupported", groups = {"integration", "live"}) public void testCreateNodeWithCustomHardware() throws Exception { Template template = buildTemplate(templateBuilder() .hardwareId("automatic:cores=2;ram=2048;disk=10")); try { NodeMetadata node = getOnlyElement(client.createNodesInGroup(group + "custom", 1, template)); assertThat(node.getHardware().getRam()).isEqualTo(2048); assertThat(node.getHardware().getProcessors().get(0).getCores()).isEqualTo(2); assertThat(node.getHardware().getVolumes().get(0).getSize()).isEqualTo(10); assertThat(node.getHardware().getId()).isEqualTo("cpu=2,ram=2048,disk=10"); } finally { client.destroyNodesMatching(inGroup(group + "custom")); } }
@Test(dataProvider = "onlyIfAutomaticHardwareSupported", groups = {"integration", "live"}) public void testCreateNodeWithCustomHardwareUsingMins() throws Exception { Template template = buildTemplate(templateBuilder() .minCores(2).minRam(2048).minDisk(10)); try { NodeMetadata node = getOnlyElement(client.createNodesInGroup(group + "custom", 1, template)); assertThat(node.getHardware().getRam()).isEqualTo(2048); assertThat(node.getHardware().getProcessors().get(0).getCores()).isEqualTo(2); assertThat(node.getHardware().getVolumes().get(0).getSize()).isEqualTo(10); assertThat(node.getHardware().getId()).isEqualTo("cpu=2,ram=2048,disk=10"); } finally { client.destroyNodesMatching(inGroup(group + "custom")); } }
@Test public void testHardwareWithPrivateCore() { cpuItem = cpuItem.toBuilder() .description("Private 2 x 2.0 GHz Cores") .build(); Hardware hardware = toHardware.apply(ImmutableSet.of(cpuItem, ramItem, volumeItem)); assertEquals("123,456,789", hardware.getId()); List<? extends Processor> processors = hardware.getProcessors(); assertEquals(1, processors.size()); assertEquals(2.0, processors.get(0).getCores()); assertEquals(2, hardware.getRam()); List<? extends Volume> volumes = hardware.getVolumes(); assertEquals(1, volumes.size()); assertEquals(100F, volumes.get(0).getSize()); }
@Test public void testHardware() { Hardware hardware = toHardware.apply(ImmutableSet.of(cpuItem, ramItem, volumeItem)); assertEquals("123,456,789", hardware.getId()); List<? extends Processor> processors = hardware.getProcessors(); assertEquals(1, processors.size()); assertEquals(2.0, processors.get(0).getCores()); assertEquals(2, hardware.getRam()); List<? extends Volume> volumes = hardware.getVolumes(); assertEquals(1, volumes.size()); Volume volume = volumes.get(0); assertEquals(100F, volume.getSize()); assertEquals(Volume.Type.SAN, volume.getType()); assertEquals(true, volume.isBootDevice()); }
@Test(groups={"Live", "Live-sanity"}) public void testJcloudsCreateWithHardwareProfiles() throws Exception { // default minRam is 1gb (but default smallest VM in softlayer is 1024mb so not a particularly useful test!) obtainMachine(); assertTrue(template.getHardware().getRam() >= 1000, "template="+template); obtainMachine(MutableMap.of(JcloudsLocationConfig.MIN_RAM, "4096")); assertTrue(template.getHardware().getRam() >= 4096, "template="+template); obtainMachine(MutableMap.of(JcloudsLocationConfig.MIN_CORES, "4")); assertTrue(template.getHardware().getProcessors().get(0).getCores() >= 4, "template="+template); obtainMachine(MutableMap.of(JcloudsLocationConfig.MIN_DISK, "51")); assertTrue(template.getHardware().getVolumes().get(0).getSize() >= 51, "template="+template); String hardwareId = "cpu=1,memory=6144,disk=25,type=LOCAL"; obtainMachine(MutableMap.of(JcloudsLocationConfig.HARDWARE_ID, hardwareId)); assertEquals(template.getHardware().getId(), hardwareId, "template="+template); }
@Test public void testHardwareWithTwoDisks() { ProductItem localVolumeItem = ProductItem.builder().id(4).description("25 GB").capacity(25F).prices( ProductItemPrice.builder().id(987).build()).categories( ProductItemCategory.builder().categoryCode("guest_disk1").build()).build(); Hardware hardware = toHardware.apply(ImmutableSet.of(cpuItem, ramItem, volumeItem,localVolumeItem)); List<? extends Volume> volumes = hardware.getVolumes(); assertEquals(2, volumes.size()); Volume volume = volumes.get(0); assertEquals(100F, volume.getSize()); assertEquals(Volume.Type.SAN, volume.getType()); assertEquals(true, volume.isBootDevice()); Volume volume1 = volumes.get(1); assertEquals(25F, volume1.getSize()); assertEquals(Volume.Type.LOCAL, volume1.getType()); assertEquals(false, volume1.isBootDevice()); } }
private void applyAndAssert(Server server) { final Hardware hardware = serverToHardware.apply(server); assertEquals(server.memoryGb() * 1024, hardware.getRam()); assertEquals("vmx", hardware.getHypervisor()); assertEquals(server.id(), hardware.getId()); assertEquals(server.id(), hardware.getProviderId()); assertEquals(server.name(), hardware.getName()); assertEquals(server.disks().size(), hardware.getVolumes().size()); assertEquals(Float.valueOf(server.disks().get(0).sizeGb()), hardware.getVolumes().get(0).getSize()); assertEquals(Volume.Type.LOCAL, hardware.getVolumes().get(0).getType()); assertEquals(server.disks().get(0).id(), hardware.getVolumes().get(0).getId()); assertEquals(server.disks().get(0).scsiId().toString(), hardware.getVolumes().get(0).getDevice()); assertEquals(server.cpu().count(), hardware.getProcessors().size()); assertEquals(Double.valueOf(server.cpu().coresPerSocket()), hardware.getProcessors().get(0).getCores()); assertEquals(CpuSpeed.STANDARD.getSpeed(), hardware.getProcessors().get(0).getSpeed()); }
private void applyAndAssert(BaseImage baseImage) { final Hardware hardware = baseImageToHardware.apply(baseImage); assertEquals(baseImage.memoryGb() * 1024, hardware.getRam()); assertEquals("vmx", hardware.getHypervisor()); assertEquals(baseImage.id(), hardware.getId()); assertEquals(baseImage.id(), hardware.getProviderId()); assertEquals(baseImage.name(), hardware.getName()); assertEquals(baseImage.disks().size(), hardware.getVolumes().size()); assertEquals(Float.valueOf(baseImage.disks().get(0).sizeGb()), hardware.getVolumes().get(0).getSize()); assertEquals(Volume.Type.LOCAL, hardware.getVolumes().get(0).getType()); assertEquals(baseImage.disks().get(0).id(), hardware.getVolumes().get(0).getId()); assertEquals(baseImage.disks().get(0).scsiId().toString(), hardware.getVolumes().get(0).getDevice()); assertEquals(baseImage.cpu().count(), hardware.getProcessors().size()); assertEquals(Double.valueOf(baseImage.cpu().coresPerSocket()), hardware.getProcessors().get(0).getCores()); assertEquals(CpuSpeed.STANDARD.getSpeed(), hardware.getProcessors().get(0).getSpeed()); }