Source:
public Iterable<Hardware> listHardwareProfiles() { ContainerVirtualGuestConfiguration virtualGuestConfiguration = createObjectOptionsSupplier.get(); Builder<Hardware> hardware = ImmutableSortedSet.orderedBy(new Comparator<Hardware>() { @Override public int compare(Hardware h1, Hardware h2) { List<? extends Volume> volumes1 = h1.getVolumes(); List<? extends Volume> volumes2 = h2.getVolumes(); ComparisonChain comparisonChain = ComparisonChain.start().compare(getCores(h1), getCores(h2)) .compare(h1.getRam(), h2.getRam()) .compare(getSpace(h1), getSpace(h2)) .compare(getBootableDeviceType(h1), getBootableDeviceType(h2)); if(!volumes1.isEmpty() && !volumes2.isEmpty() && volumes1.size() == volumes2.size()) { for (int i = 0; i < volumes1.size(); i++) { comparisonChain.compare(volumes1.get(i).getType(), volumes2.get(i).getType()); } } return comparisonChain.result(); } }); for (Integer cpus : virtualGuestConfiguration.getCpusOfProcessors()) { for (Integer memory : virtualGuestConfiguration.getMemories()) { for (VirtualGuestBlockDevice blockDevice : virtualGuestConfiguration.getVirtualGuestBlockDevices()) { if (blockDevice.getDevice().equals(BOOTABLE_DEVICE)) { float capacity = blockDevice.getVirtualDiskImage().getCapacity(); Type type = blockDevice.getVirtualGuest().isLocalDiskFlag() ? Type.LOCAL : Type.SAN; String id = format("cpu=%s,memory=%s,disk=%s,type=%s", cpus, memory, round(capacity), type); hardware.add(new HardwareBuilder() .ids(id) .ram(memory) .processors(ImmutableList.of(new Processor(cpus, 0))) .hypervisor("XenServer") .volumes(ImmutableList.<Volume>of( new VolumeImpl(blockDevice.getId() + "", type, capacity, blockDevice.getDevice(), blockDevice.getBootableFlag() == 1, true))) .build()); } } } } return hardware.build(); }

Target:
public Iterable<Hardware> listHardwareProfiles() { ContainerVirtualGuestConfiguration virtualGuestConfiguration = createObjectOptionsSupplier.get(); Builder<Hardware> hardware = ImmutableSortedSet.orderedBy(new Comparator<Hardware>() { @Override public int compare(Hardware h1, Hardware h2) { List<? extends Volume> volumes1 = h1.getVolumes(); List<? extends Volume> volumes2 = h2.getVolumes(); ComparisonChain comparisonChain = ComparisonChain.start().compare(getCores(h1), getCores(h2)) .compare(h1.getRam(), h2.getRam()) .compare(getSpace(h1), getSpace(h2)) .compare(getBootableDeviceType(h1), getBootableDeviceType(h2)); if(!volumes1.isEmpty() && !volumes2.isEmpty() && volumes1.size() == volumes2.size()) { for (int i = 0; i < volumes1.size(); i++) { comparisonChain.compare(volumes1.get(i).getType(), volumes2.get(i).getType()); } } return comparisonChain.result(); } }); for (VirtualGuestBlockDevice blockDevice : virtualGuestConfiguration.getVirtualGuestBlockDevices()) { float capacity = blockDevice.getVirtualDiskImage().getCapacity(); Type type = blockDevice.getVirtualGuest().isLocalDiskFlag() ? Type.LOCAL : Type.SAN; if (blockDevice.getDevice().equals(BOOTABLE_DEVICE)) { for (Integer cpus : virtualGuestConfiguration.getCpusOfProcessors()) { for (Integer memory : virtualGuestConfiguration.getMemories()) { String id = format("cpu=%s,memory=%s,disk=%s,type=%s", cpus, memory, round(capacity), type); hardware.add(new HardwareBuilder() .ids(id) .ram(memory) .processors(ImmutableList.of(new Processor(cpus, 2))) .hypervisor("XenServer") .volumes(ImmutableList.<Volume>of( new VolumeImpl(blockDevice.getId() + "", type, capacity, blockDevice.getDevice(), blockDevice.getBootableFlag() == 1, true))) .build()); } } } } return hardware.build(); }