@Override public Iterable<ServiceOffering> listHardwareProfiles() { // TODO: we may need to filter these return client.getOfferingApi().listServiceOfferings(); }
protected DiskOffering getPreferredDiskOffering() { for (DiskOffering candidate : client.getOfferingApi().listDiskOfferings()) { //any will do return candidate; } throw new AssertionError("No suitable DiskOffering found."); } protected Snapshot getPreferredSnapshot() {
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)); } } }
public void testListNetworkOfferings() throws Exception { Set<NetworkOffering> response = client.getOfferingApi().listNetworkOfferings(); assert null != response; long offeringCount = response.size(); assertTrue(offeringCount >= 0); for (NetworkOffering offering : response) { NetworkOffering newDetails = Iterables.getOnlyElement(client.getOfferingApi().listNetworkOfferings( ListNetworkOfferingsOptions.Builder.id(offering.getId()))); assertEquals(offering, newDetails); assertEquals(offering, client.getOfferingApi().getNetworkOffering(offering.getId())); assert offering.getId() != null : offering; assert offering.getName() != null : offering; assert offering.getDisplayText() != null : offering; assert offering.getMaxConnections() == null || offering.getMaxConnections() > 0 : offering; assert offering.getTrafficType() != null && TrafficType.UNRECOGNIZED != offering.getTrafficType() : offering; assert offering.getTags() != null : offering; } } }
@Test public void testCreateGuestVirtualNetwork() { if (!networksSupported) return; final NetworkOffering offering; try { offering = find(client.getOfferingApi().listNetworkOfferings(), NetworkOfferingPredicates.supportsGuestVirtualNetworks()); } catch (NoSuchElementException e) { Logger.getAnonymousLogger().log(Level.SEVERE, "guest networks not supported, skipping test"); return; } String name = prefix + "-virtual"; Network network = null; try { network = client.getNetworkApi().createNetworkInZone(zone.getId(), offering.getId(), name, name); checkNetwork(network); } catch (IllegalStateException e) { Logger.getAnonymousLogger().log(Level.SEVERE, "couldn't create a network, skipping test", e); } finally { if (network != null) { String jobId = client.getNetworkApi().deleteNetwork(network.getId()); if (jobId != null) jobComplete.apply(jobId); } } }
try { offering = get( cloudStackContext.getApi().getOfferingApi().listNetworkOfferings(specifyVLAN(true).zoneId(zone.getId())), 0); } catch (NoSuchElementException e) { Logger.getAnonymousLogger().log(Level.SEVERE, "VLAN networks not supported, skipping test");
public void testListServiceOfferings() throws Exception { Set<ServiceOffering> response = client.getOfferingApi().listServiceOfferings(); assert null != response; long offeringCount = response.size(); assertTrue(offeringCount >= 0); for (ServiceOffering offering : response) { ServiceOffering newDetails = Iterables.getOnlyElement(client.getOfferingApi().listServiceOfferings( ListServiceOfferingsOptions.Builder.id(offering.getId()))); assertEquals(offering, newDetails); assert offering.getId() != null : offering; assert offering.getName() != null : offering; assert offering.getDisplayText() != null : offering; assert offering.getCpuNumber() > 0 : offering; assert offering.getCpuSpeed() > 0 : offering; assert offering.getMemory() > 0 : offering; assert offering.getStorageType() != null && StorageType.UNRECOGNIZED != offering.getStorageType() : offering; assert offering.getTags() != null : offering; } }
cloudStackContext.getApi().getOfferingApi().listNetworkOfferings(specifyVLAN(true).zoneId(zoneId)), 0).getId();
protected DiskOffering getPreferredDiskOffering() { for (DiskOffering candidate : client.getOfferingApi().listDiskOfferings()) { if (!candidate.isCustomized()) { return candidate; } } throw new AssertionError("No suitable DiskOffering found."); }
public static VirtualMachine createVirtualMachineWithOptionsInZone(DeployVirtualMachineOptions options, String zoneId, String templateId, CloudStackApi client, Predicate<String> jobComplete, Predicate<VirtualMachine> virtualMachineRunning) { String serviceOfferingId = DEFAULT_SIZE_ORDERING.min(client.getOfferingApi().listServiceOfferings()).getId(); System.out.printf("serviceOfferingId %s, templateId %s, zoneId %s, options %s%n", serviceOfferingId, templateId, zoneId, options); AsyncCreateResponse job = client.getVirtualMachineApi().deployVirtualMachineInZone(zoneId, serviceOfferingId, templateId, options); assertTrue(jobComplete.apply(job.getJobId())); AsyncJob<VirtualMachine> jobWithResult = client.getAsyncJobApi().<VirtualMachine> getAsyncJob(job.getJobId()); if (jobWithResult.getError() != null) Throwables.propagate(new ExecutionException(String.format("job %s failed with exception %s", job.getId(), jobWithResult.getError().toString())) { }); VirtualMachine vm = jobWithResult.getResult(); if (vm.isPasswordEnabled()) { assert vm.getPassword() != null : vm; } assertTrue(virtualMachineRunning.apply(vm)); assertEquals(vm.getServiceOfferingId(), serviceOfferingId); assertEquals(vm.getTemplateId(), templateId); assertEquals(vm.getZoneId(), zoneId); return vm; }
client.getOfferingApi().listNetworkOfferings( ListNetworkOfferingsOptions.Builder.zoneId(template.getZoneId()).specifyVLAN(true)), null); checkNotNull(offering, "No network offering found");
/** 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()); } }
final NetworkOffering offering = Iterables.tryFind(client.getOfferingApi().listNetworkOfferings(), NetworkOfferingPredicates.supportsGuestVirtualNetworks()).orNull();