/** * The list hardware profiles command shows you the options including virtual cpu count, memory, * and disks. cpu count is not a portable quantity across clouds, as they are measured * differently. However, it is a good indicator of relative speed within a cloud. memory is * measured in megabytes and disks in gigabytes. * * @return a map of hardware profiles by ID, conceding that in some clouds the "id" is not used. */ @Override public Set<? extends Hardware> listHardwareProfiles() { return computeService.listHardwareProfiles(); }
/** * The list hardware profiles command shows you the options including virtual cpu count, memory, * and disks. cpu count is not a portable quantity across clouds, as they are measured * differently. However, it is a good indicator of relative speed within a cloud. memory is * measured in megabytes and disks in gigabytes. * * @return a map of hardware profiles by ID, conceding that in some clouds the "id" is not used. */ @Override public Set<? extends Hardware> listHardwareProfiles() { return computeService.listHardwareProfiles(); }
/** * Sets the available hardware profiles to the out message. */ protected void listHardware(Exchange exchange) { Set<? extends Hardware> hardwareProfiles = computeService.listHardwareProfiles(); exchange.getOut().setBody(hardwareProfiles); }
@Override protected void doCall(ComputeService computeService, String indent) throws Exception { Set<? extends Hardware> hardware = computeService.listHardwareProfiles(); stdout.println(indent+"Hardware Profiles {"); for (Hardware image : hardware) { stdout.println(indent+"\t"+image); } stdout.println(indent+"}"); } }
@Override public Set<? extends Hardware> listHardwareProfiles() { return delegate.listHardwareProfiles(); }
@Override protected Object doExecute() throws Exception { ComputeService service = null; try { service = getComputeService(); } catch (Throwable t) { System.err.println(t.getMessage()); t.printStackTrace(System.err); return null; } printHardwares(service, service.listHardwareProfiles(), System.out); return null; }
@Override public void updateOnAdded(ComputeService computeService) { if (computeService != null) { Set<? extends Hardware> hardwares = computeService.listHardwareProfiles(); if (hardwares != null) { for (Hardware hardware : hardwares) { for (String cacheKey : ServiceHelper.findCacheKeysForService(computeService)) { cache.put(cacheKey, hardware.getId()); } } } } } }
public void showHardware() { Set<? extends Hardware> hardwares = computeService.listHardwareProfiles(); for (Hardware hardware : hardwares) { if (verbose) { System.out.println(hardware); } else { StringBuilder sb = new StringBuilder(hardware.getId()); sb.append(" Ram: ").append(hardware.getRam()); sb.append(" Processors: ").append(hardware.getProcessors()); if (locationId == null) { Location location = hardware.getLocation(); if (location != null) { sb.append(" Location: ").append(location.getId()); } } System.out.println(sb.toString()); } } }
public void testHardwareId() { Hardware first = Iterables.get(computeService.listHardwareProfiles(), 0); assert HardwarePredicates.idEquals(first.getId()).apply(first); Hardware second = Iterables.get(computeService.listHardwareProfiles(), 1); assert !HardwarePredicates.idEquals(first.getId()).apply(second); }
public void testHardwareId() { Hardware first = Iterables.get(computeService.listHardwareProfiles(), 0); assert HardwarePredicates.idEquals(first.getId()).apply(first); Hardware second = Iterables.get(computeService.listHardwareProfiles(), 1); assert !HardwarePredicates.idEquals(first.getId()).apply(second); }
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())); } }
public void testListHardwareProfiles() throws Exception { GoogleComputeEngineApi api = client.getContext().unwrapApi(GoogleComputeEngineApi.class); ImmutableSet.Builder<String> deprecatedMachineTypes = ImmutableSet.builder(); for (MachineType machine : api.machineTypesInZone(DEFAULT_ZONE_NAME).list().next()) { if (machine.deprecated() != null) { deprecatedMachineTypes.add(machine.id()); } } ImmutableSet<String> deprecatedMachineTypeIds = deprecatedMachineTypes.build(); for (Hardware hardwareProfile : client.listHardwareProfiles()) { assertFalse(contains(deprecatedMachineTypeIds, hardwareProfile.getId())); } }
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); } }
@Test(dataProvider = "onlyIfAutomaticHardwareSupported", groups = {"integration", "live"}, expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "No hardware profile matching the given criteria was found. " + "If you want to use exact values, please set the minCores and minRam values") public void testAutoGeneratedHardwareWithOnlyMinRamNotMatchHardwareProfile() { if (view.getComputeService().listHardwareProfiles().isEmpty()) { view.getComputeService().templateBuilder().minRam(4096).build(); } else { throw new SkipException("Hardware profile list not empty."); } }
@Test(dataProvider = "onlyIfAutomaticHardwareSupported", groups = {"integration", "live"}, expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "No hardware profile matching the given criteria was found. " + "If you want to use exact values, please set the minCores and minRam values") public void testAutoGeneratedHardwareWithOnlyMinCoresNotMatchHardwareProfile() { if (view.getComputeService().listHardwareProfiles().isEmpty()) { view.getComputeService().templateBuilder().minCores(4).build(); } else { throw new SkipException("Hardware profile list not empty."); } }
public void testListSizes() throws Exception { for (Hardware hardware : client.listHardwareProfiles()) { assert hardware.getProviderId() != null : hardware; assert getCores(hardware) > 0 : hardware; assert hardware.getRam() > 0 : hardware; assertEquals(hardware.getType(), ComputeType.HARDWARE); checkVolumes(hardware); } }
@Test(dataProvider = "onlyIfAutomaticHardwareSupported", groups = {"integration", "live"}) public void testAutoGeneratedHardwareWithOnlyMinCoresMatchHardwareProfile() { if (!view.getComputeService().listHardwareProfiles().isEmpty()) { Template template = view.getComputeService().templateBuilder().minCores(4).build(); assertThat(AutomaticHardwareIdSpec.isAutomaticId(template.getHardware().getId())).isFalse(); assertThat(template.getHardware().getProcessors().get(0).getCores()).isGreaterThanOrEqualTo(4); } else { throw new SkipException("Hardware profile list is empty, this provider can not match any hardware profile" + "to the specified minRam and minCores."); } }
@Test(dataProvider = "onlyIfAutomaticHardwareSupported", groups = {"integration", "live"}) public void testAutoGeneratedHardwareWithOnlyMinRamMatchHardwareProfile() { if (!view.getComputeService().listHardwareProfiles().isEmpty()) { Template template = view.getComputeService().templateBuilder().minRam(4096).build(); assertThat(AutomaticHardwareIdSpec.isAutomaticId(template.getHardware().getId())).isFalse(); assertThat(template.getHardware().getRam()).isGreaterThanOrEqualTo(4096); } else { throw new SkipException("Hardware profile list is empty, this provider can not match any hardware profile" + "to the specified minRam and minCores."); } }
@Test(dataProvider = "onlyIfAutomaticHardwareSupported", groups = {"integration", "live"}) public void testAutoGeneratedHardwareWithMinCoresAndMinRam() { if (view.getComputeService().listHardwareProfiles().isEmpty()) { Template template = view.getComputeService().templateBuilder() .minRam(2048).minCores(2).build(); assertThat(AutomaticHardwareIdSpec.isAutomaticId(template.getHardware().getId())).isTrue(); assertThat(template.getHardware().getRam()).isEqualTo(2048); assertThat(template.getHardware().getProcessors().get(0).getCores()).isEqualTo(2); } else { throw new SkipException("Hardware profile list not empty."); } }
@Test(dataProvider = "onlyIfAutomaticHardwareSupported", groups = {"integration", "live"}) public void testAutoGeneratedHardwareMatchHardwareProfile() { if (!view.getComputeService().listHardwareProfiles().isEmpty()) { Template template = view.getComputeService().templateBuilder() .minRam(2048).minCores(2).build(); assertThat(AutomaticHardwareIdSpec.isAutomaticId(template.getHardware().getId())).isFalse(); assertThat(template.getHardware().getRam()).isGreaterThanOrEqualTo(2048); assertThat(template.getHardware().getProcessors().get(0).getCores()).isGreaterThanOrEqualTo(2); } else { throw new SkipException("Hardware profile list is empty, this provider can not match any hardware profile" + "to the specified minRam and minCores."); } }