@Override public EC2HardwareBuilder name(String name) { return EC2HardwareBuilder.class.cast(super.name(name)); }
@Override public EC2HardwareBuilder name(String name) { return EC2HardwareBuilder.class.cast(super.name(name)); }
@Override public Hardware apply(org.jclouds.servermanager.Hardware from) { HardwareBuilder builder = new HardwareBuilder(); builder.ids(from.id + ""); builder.name(from.name); builder.processors(ImmutableList.of(new Processor(from.cores, 1.0))); builder.ram(from.ram); builder.volumes(ImmutableList.<Volume> of(new VolumeImpl(from.disk, true, false))); return builder.build(); }
static Hardware stub(String type, int cores, int ram, float disk) { return new org.jclouds.compute.domain.HardwareBuilder().ids(type).name(type) .processors(ImmutableList.of(new Processor(cores, 1.0))).ram(ram) .volumes(ImmutableList.<Volume> of(new VolumeImpl(disk, true, false))).build(); }
@Override public Hardware apply(org.jclouds.servermanager.Hardware from) { HardwareBuilder builder = new HardwareBuilder(); builder.ids(from.id + ""); builder.name(from.name); builder.processors(ImmutableList.of(new Processor(from.cores, 1.0))); builder.ram(from.ram); builder.volumes(ImmutableList.<Volume> of(new VolumeImpl(from.disk, true, false))); return builder.build(); }
static Hardware stub(String type, int cores, int ram, float disk) { return new org.jclouds.compute.domain.HardwareBuilder().ids(type).name(type) .processors(ImmutableList.of(new Processor(cores, 1.0))).ram(ram) .volumes(ImmutableList.<Volume> of(new VolumeImpl(disk, true, false))).build(); }
static Hardware stub(String type, int cores, int ram, float disk) { return new org.jclouds.compute.domain.HardwareBuilder().ids(type).name(type) .processors(ImmutableList.of(new Processor(cores, 1.0))).ram(ram) .volumes(ImmutableList.<Volume> of(new VolumeImpl(disk, true, false))).build(); }
@Override public Iterable<Hardware> listHardwareProfiles() { Set<Hardware> hardware = Sets.newLinkedHashSet(); // todo they are only placeholders at the moment hardware.add(new HardwareBuilder().ids("micro").hypervisor("lxc").name("micro").processor(new Processor(1, 1)).ram(512).build()); hardware.add(new HardwareBuilder().ids("small").hypervisor("lxc").name("small").processor(new Processor(1, 1)).ram(1024).build()); hardware.add(new HardwareBuilder().ids("medium").hypervisor("lxc").name("medium").processor(new Processor(2, 1)).ram(2048).build()); hardware.add(new HardwareBuilder().ids("large").hypervisor("lxc").name("large").processor(new Processor(2, 1)).ram(3072).build()); return hardware; }
@Override public Hardware apply(FlavorInZone flavorInZone) { Location location = locationIndex.get().get(flavorInZone.getZone()); checkState(location != null, "location %s not in locationIndex: %s", flavorInZone.getZone(), locationIndex.get()); Flavor flavor = flavorInZone.getFlavor(); return new HardwareBuilder().id(flavorInZone.slashEncode()).providerId(flavor.getId()).name(flavor.getName()) .ram(flavor.getRam()).processor(new Processor(flavor.getVcpus(), 1.0)).volume( new VolumeImpl(Float.valueOf(flavor.getDisk()), true, true)).location(location).build(); } }
@Override public Hardware apply(FlavorInRegion flavorInRegion) { Location location = locationIndex.get().get(flavorInRegion.getRegion()); checkState(location != null, "location %s not in locationIndex: %s", flavorInRegion.getRegion(), locationIndex.get()); Flavor flavor = flavorInRegion.getFlavor(); return new HardwareBuilder().id(flavorInRegion.slashEncode()).providerId(flavor.getId()).name(flavor.getName()) .ram(flavor.getRam()).processor(new Processor(flavor.getVcpus(), 1.0)).volume( new VolumeImpl(Float.valueOf(flavor.getDisk()), true, true)).location(location).build(); } }
@Override public Hardware apply(FlavorInRegion flavorInRegion) { Location location = locationIndex.get().get(flavorInRegion.getRegion()); checkState(location != null, "location %s not in locationIndex: %s", flavorInRegion.getRegion(), locationIndex.get()); Flavor flavor = flavorInRegion.getFlavor(); return new HardwareBuilder().id(flavorInRegion.slashEncode()).providerId(flavor.getId()).name(flavor.getName()) .ram(flavor.getRam()).processor(new Processor(flavor.getVcpus(), 1.0)).volume( new VolumeImpl(Float.valueOf(flavor.getDisk()), true, true)).location(location).build(); } }
@Override public Hardware apply(FlavorInZone flavorInZone) { Location location = locationIndex.get().get(flavorInZone.getZone()); checkState(location != null, "location %s not in locationIndex: %s", flavorInZone.getZone(), locationIndex.get()); Flavor flavor = flavorInZone.getFlavor(); return new HardwareBuilder().id(flavorInZone.slashEncode()).providerId(flavor.getId()).name(flavor.getName()) .ram(flavor.getRam()).processor(new Processor(flavor.getVcpus(), 1.0)).volume( new VolumeImpl(Float.valueOf(flavor.getDisk()), true, true)).location(location).build(); } }
public Hardware apply(Flavor from) { return new HardwareBuilder().ids(from.getId() + "").name(from.getName()).hypervisor("xen") .processors(ImmutableList.of(new Processor(from.getDisk() / 10.0, 1.0))).ram(from.getRam()) .volumes(ImmutableList.<Volume> of(new VolumeImpl((float) from.getDisk(), true, true))).build(); } }
public Hardware apply(Flavor from) { return new HardwareBuilder().ids(from.getId() + "").name(from.getName()).hypervisor("xen") .processors(ImmutableList.of(new Processor(from.getDisk() / 10.0, 1.0))).ram(from.getRam()) .volumes(ImmutableList.<Volume> of(new VolumeImpl((float) from.getDisk(), true, true))).build(); } }
public Hardware apply(Flavor from) { return new HardwareBuilder() .ids(from.getId() + "") .name(from.getName()) .processors(ImmutableList.of(new Processor(from.getDisk() / 10.0, 1.0))) .ram(from.getRam()) .volumes(ImmutableList.<Volume> of(new VolumeImpl((float) from.getDisk(), true, true))) .uri(from.getURI()) .build(); } }
@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()); } }
@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()); } }
@Test public void testConvertSize() { Size size = Size.create("2gb", true, 1.0f, 10f, 0.05f, 2048, 1, 20, ImmutableList.<String> of()); Hardware expected = new HardwareBuilder().id("2gb").providerId("2gb").name("2gb") .processor(new Processor(1.0, 1.0)).ram(2048) .volume(new VolumeBuilder().size(20f).type(Type.LOCAL).build()) .userMetadata(ImmutableMap.of("costPerHour", "0.05", "costPerMonth", "10")).build(); SizeToHardware function = new SizeToHardware(); assertEquals(function.apply(size), expected); } }