@Override public boolean apply(Hardware input) { return input.getRam() >= TemplateBuilderImpl.this.minRam; }
@Override public boolean apply(Hardware input) { return input.getRam() >= TemplateBuilderImpl.this.minRam; }
@Override public boolean apply(Hardware input) { return input.getRam() == Integer.parseInt(instance.getRam().getName().replaceAll("[^0-9]", "")); } }
@Override public boolean apply(Hardware input) { return input.getRam() == Integer.parseInt(instance.getRam().getName().replaceAll("[^0-9]", "")); } }
@Override public boolean apply(Hardware input) { return input.getRam() == Integer.parseInt(instance.getRam().getName().replaceAll("[^0-9]", "")); } }
@Override public String apply(Hardware hardware) { if (hardware.getRam() >= 8 * 1024 || getCores(hardware) >= 6 || getSpace(hardware) >= 450) return "8GB"; if (hardware.getRam() >= 4 * 1024 || getCores(hardware) >= 3 || getSpace(hardware) >= 230) return "4GB"; if (hardware.getRam() >= 2 * 1024 || getSpace(hardware) >= 110) return "2GB"; if (hardware.getRam() >= 1024 || getSpace(hardware) >= 55) return "1GB"; return "512MB"; /* smallest */ } };
/** * {@inheritDoc} */ @Override public int compareTo(ResourceMetadata<ComputeType> that) { if (that instanceof Hardware) { Hardware thatHardware = Hardware.class.cast(that); return ComparisonChain.start().compare(getCores(this), getCores(thatHardware)).compare(this.getRam(), thatHardware.getRam()) .compare(getSpace(this), getSpace(thatHardware)).result(); } else { return super.compareTo(that); } }
@Override public InstantiateVAppTemplateOptions apply(Template from) { InstantiateVAppTemplateOptions options = processorCount(Double.valueOf(getCores(from.getHardware())).intValue()) .memory(from.getHardware().getRam()); if (!from.getOptions().shouldBlockUntilRunning()) options.block(false); String sshKeyFingerprint = TerremarkVCloudTemplateOptions.class.cast(from.getOptions()).getSshKeyFingerprint(); if (sshKeyFingerprint != null) options.sshKeyFingerprint(sshKeyFingerprint); return options; } }
@Override public boolean apply(Hardware input) { return input.getRam() == machineInDatacenter.get().getMemorySizeMb() && getSpace(input) == machineInDatacenter.get().getDiskSizeGb() && input.getLocation().getId().equals(machineInDatacenter.getDatacenter()); } }).orNull();
/** * {@inheritDoc} */ @Override public TemplateBuilder fromHardware(Hardware hardware) { if (currentLocationWiderThan(hardware.getLocation())) this.location = hardware.getLocation(); this.minCores = getCores(hardware); this.minRam = hardware.getRam(); this.minDisk = getSpace(hardware); this.hypervisor = hardware.getHypervisor(); return this; }
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); }
@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()); } }