protected DiskOffering getPreferredDiskOffering() { for (DiskOffering candidate : client.getOfferingApi().listDiskOfferings()) { //any will do return candidate; } throw new AssertionError("No suitable DiskOffering found."); } protected Snapshot getPreferredSnapshot() {
protected DiskOffering getPreferredDiskOffering() { for (DiskOffering candidate : client.getOfferingApi().listDiskOfferings()) { if (!candidate.isCustomized()) { return candidate; } } throw new AssertionError("No suitable DiskOffering found."); }
public void testListDiskOfferings() throws Exception { Set<DiskOffering> response = client.getOfferingApi().listDiskOfferings(); assert null != response; long offeringCount = response.size(); assertTrue(offeringCount >= 0); for (DiskOffering offering : response) { try { DiskOffering newDetails = Iterables.getOnlyElement(client.getOfferingApi().listDiskOfferings( ListDiskOfferingsOptions.Builder.id(offering.getId()))); assertEquals(offering, newDetails); assertEquals(offering, client.getOfferingApi().getDiskOffering(offering.getId())); assert offering.getId() != null : offering; assert offering.getName() != null : offering; assert offering.getCreated() != null : offering; assert offering.getDisplayText() != null : offering; assert offering.getDiskSize() > 0 || (offering.getDiskSize() == 0 && offering.isCustomized()) : offering; assert offering.getTags() != null : offering; } catch (NoSuchElementException e) { // This bug is present both in 2.2.8 and 2.2.12 assertTrue(Predicates.in(ImmutableSet.of("2.2.8", "2.2.12")).apply(apiVersion)); } } }
/** Test requires a custom disk offering to be available */ public void testCreateVolumeFromCustomDiskOffering() { final int size = 1; DiskOffering offering = null; for (DiskOffering candidate : client.getOfferingApi().listDiskOfferings()) { if (candidate.isCustomized()) { offering = candidate; break; } } assertNotNull("No custom disk offering found!", offering); AsyncCreateResponse job = client.getVolumeApi().createVolumeFromCustomDiskOfferingInZone( prefix + "-jclouds-volume", offering.getId(), zoneId, size); assertTrue(jobComplete.apply(job.getJobId())); logger.info("created volume " + job.getId()); Volume volume = findVolumeWithId(job.getId()); try { checkVolume(volume); assertEquals(volume.getSize(), size * 1024 * 1024 * 1024); } finally { client.getVolumeApi().deleteVolume(volume.getId()); } }