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 static int getBootableDeviceType(Hardware hardware) { List<? extends Volume> volumes = hardware.getVolumes(); Optional<? extends Volume> optionalBootableVolume = tryFind(volumes, new Predicate<Volume>() { @Override public boolean apply(Volume volume) { return volume.getDevice().equals(BOOTABLE_DEVICE); } }); if (!optionalBootableVolume.isPresent()) { return Type.LOCAL.ordinal(); } return optionalBootableVolume.get().getType().ordinal(); }
private void listHardwares(ComputeService computeService) { log("list hardwares"); for (Hardware hardware : computeService.listHardwareProfiles()) {// TODO log(String.format(" hardware id=%s, cores=%s, ram=%s, volumes=%s", hardware.getProviderId(), getCores(hardware), hardware .getRam(), hardware.getVolumes())); } }
protected Hardware parseHardware(final RunningInstance instance) { Hardware hardware = getHardwareForInstance(instance); if (hardware != null) { hardware = HardwareBuilder.fromHardware(hardware).volumes(addEBS(instance, hardware.getVolumes())).build(); } return hardware; }
protected Hardware parseHardware(final RunningInstance instance) { Hardware hardware = getHardwareForInstance(instance); if (hardware != null) { hardware = HardwareBuilder.fromHardware(hardware).volumes(addEBS(instance, hardware.getVolumes())).build(); } return hardware; }
protected Hardware parseHardware(final RunningInstance instance) { Hardware hardware = getHardwareForInstance(instance); if (hardware != null) { hardware = HardwareBuilder.fromHardware(hardware).volumes(addEBS(instance, hardware.getVolumes())).build(); } return hardware; }
protected Hardware parseHardware(final RunningInstance instance) { Hardware hardware = getHardwareForInstance(instance); if (hardware != null) { hardware = HardwareBuilder.fromHardware(hardware).volumes(addEBS(instance, hardware.getVolumes())).build(); } return hardware; }
protected Hardware parseHardware(final RunningInstance instance) { Hardware hardware = getHardwareForInstance(instance); if (hardware != null) { hardware = HardwareBuilder.fromHardware(hardware).volumes(addEBS(instance, hardware.getVolumes())).build(); } return hardware; }
protected Hardware parseHardware(final RunningInstance instance) { Hardware hardware = getHardwareForInstance(instance); if (hardware != null) { hardware = HardwareBuilder.fromHardware(hardware).volumes(addEBS(instance, hardware.getVolumes())).build(); } return hardware; }
public void testListSizes() throws Exception { for (Hardware hardware : client.listHardwareProfiles()) { assert hardware.getProviderId() != null : hardware; assert getCores(hardware) > 0 : hardware; assert hardware.getVolumes().size() >= 0 : hardware; assert hardware.getRam() > 0 : hardware; assertEquals(hardware.getType(), ComputeType.HARDWARE); } }
@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 testFastestTemplateBuilder() throws IOException { Template template = view.getComputeService().templateBuilder().fastest().build(); assertEquals(getCores(template.getHardware()), 16.0d); assertEquals(template.getHardware().getRam(), 1); assertEquals(getSpace(template.getHardware()), 25.0d); assertEquals(template.getHardware().getVolumes().get(0).getType(), Volume.Type.LOCAL); }
@Test public void testBiggestTemplateBuilder() throws IOException { Template template = view.getComputeService().templateBuilder().biggest().build(); assertEquals(getCores(template.getHardware()), 16.0d); assertEquals(template.getHardware().getRam(), 16); assertEquals(getSpace(template.getHardware()), 100.0d); assertEquals(template.getHardware().getVolumes().get(0).getType(), Volume.Type.LOCAL); }
@Test public void testFastestTemplateBuilder() throws IOException { Template template = view.getComputeService().templateBuilder().fastest().build(); assertEquals(getCores(template.getHardware()), 16.0d); assertEquals(template.getHardware().getRam(), 1 * 1024); assertEquals(getSpace(template.getHardware()), 25.0d); assertEquals(template.getHardware().getVolumes().get(0).getType(), Volume.Type.LOCAL); }
@Test public void testDefaultTemplateBuilder() throws IOException { Template defaultTemplate = view.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "12.04"); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); assertEquals(defaultTemplate.getHardware().getRam(), 1); assertEquals(getSpace(defaultTemplate.getHardware()), 25.0d); assertEquals(defaultTemplate.getHardware().getVolumes().get(0).getType(), Volume.Type.LOCAL); // test that we bound the correct templateoptions in guice assertEquals(defaultTemplate.getOptions().getClass(), SoftLayerTemplateOptions.class); }
@SuppressWarnings("unchecked") public static HardwareBuilder fromHardware(Hardware in) { return new HardwareBuilder().id(in.getId()).providerId(in.getProviderId()).location(in.getLocation()).name( in.getName()).uri(in.getUri()).userMetadata(in.getUserMetadata()).tags(in.getTags()).processors( List.class.cast(in.getProcessors())).ram(in.getRam()).volumes(List.class.cast(in.getVolumes())) .supportsImage(in.supportsImage()).hypervisor(in.getHypervisor()); } }
@SuppressWarnings("unchecked") public static HardwareBuilder fromHardware(Hardware in) { return new HardwareBuilder().id(in.getId()).providerId(in.getProviderId()).location(in.getLocation()).name( in.getName()).uri(in.getUri()).userMetadata(in.getUserMetadata()).tags(in.getTags()).processors( List.class.cast(in.getProcessors())).ram(in.getRam()).volumes(List.class.cast(in.getVolumes())) .supportsImage(in.supportsImage()).hypervisor(in.getHypervisor()); } }
@SuppressWarnings("unchecked") public static HardwareBuilder fromHardware(Hardware in) { return new HardwareBuilder().id(in.getId()).providerId(in.getProviderId()).location(in.getLocation()).name( in.getName()).uri(in.getUri()).userMetadata(in.getUserMetadata()).tags(in.getTags()).processors( List.class.cast(in.getProcessors())).ram(in.getRam()).volumes(List.class.cast(in.getVolumes())) .supportsImage(in.supportsImage()).hypervisor(in.getHypervisor()); } }