@Override public int compareTo(ServiceOffering o) { return id.compareTo(o.getId()); }
@Override public int compareTo(ServiceOffering o) { return id.compareTo(o.getId()); }
@Override public int compareTo(ServiceOffering o) { return id.compareTo(o.getId()); }
private void checkServiceOffering(ServiceOffering offering) { assertNotNull(offering.getId()); assertEquals(offering.getCpuNumber(), 2); assertEquals(offering.getCpuSpeed(), 1024); assertEquals(offering.getMemory(), 2048); assertTrue(offering.supportsHA()); assertEquals(offering.getStorageType(), StorageType.LOCAL); }
private void checkServiceOffering(ServiceOffering offering) { assertNotNull(offering.getId()); assertEquals(offering.getCpuNumber(), 2); assertEquals(offering.getCpuSpeed(), 1024); assertEquals(offering.getMemory(), 2048); assertTrue(offering.supportsHA()); assertEquals(offering.getStorageType(), StorageType.LOCAL); }
public void testListServiceOfferings() throws Exception { Set<ServiceOffering> response = client.getOfferingClient().listServiceOfferings(); assert null != response; long offeringCount = response.size(); assertTrue(offeringCount >= 0); for (ServiceOffering offering : response) { ServiceOffering newDetails = Iterables.getOnlyElement(client.getOfferingClient().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; } }
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; } }
@Override public Hardware apply(ServiceOffering offering) { return new HardwareBuilder() .ids(offering.getId() + "") .name(offering.getName()) .tags(offering.getTags()) .processors(ImmutableList.of(new Processor(offering.getCpuNumber(), offering.getCpuSpeed()))) .ram(offering.getMemory())// // TODO: hypervisor probably from zone? // TODO .volumes() // displayText // created // haSupport // storageType // TODO where's the location of this? .build(); }
@Override public Hardware apply(ServiceOffering offering) { return new HardwareBuilder() .ids(offering.getId() + "") .name(offering.getName()) .tags(offering.getTags()) .processors(ImmutableList.of(new Processor(offering.getCpuNumber(), offering.getCpuSpeed()))) .ram(offering.getMemory())// // TODO: hypervisor probably from zone? // TODO .volumes() // displayText // created // haSupport // storageType // TODO where's the location of this? .build(); }
@Override public Hardware apply(ServiceOffering offering) { return new HardwareBuilder() .ids(offering.getId() + "") .name(offering.getName()) .tags(offering.getTags()) .processors(ImmutableList.of(new Processor(offering.getCpuNumber(), offering.getCpuSpeed()))) .ram(offering.getMemory())// // TODO: hypervisor probably from zone? // TODO .volumes() // displayText // created // haSupport // storageType // TODO where's the location of this? .build(); }
public static VirtualMachine createVirtualMachineWithOptionsInZone(DeployVirtualMachineOptions options, String zoneId, String templateId, CloudStackClient client, Predicate<String> jobComplete, Predicate<VirtualMachine> virtualMachineRunning) { String serviceOfferingId = DEFAULT_SIZE_ORDERING.min(client.getOfferingClient().listServiceOfferings()).getId(); System.out.printf("serviceOfferingId %s, templateId %s, zoneId %s, options %s%n", serviceOfferingId, templateId, zoneId, options); AsyncCreateResponse job = client.getVirtualMachineClient().deployVirtualMachineInZone(zoneId, serviceOfferingId, templateId, options); assertTrue(jobComplete.apply(job.getJobId())); AsyncJob<VirtualMachine> jobWithResult = client.getAsyncJobClient().<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; }
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; }
@Test(groups = "live", enabled = true) public void testCreateServiceOffering() throws Exception { skipIfNotGlobalAdmin(); String name = prefix + "-test-create-service-offering"; String displayText = name + "-display"; ServiceOffering offering = null; try { offering = globalAdminClient.getOfferingClient(). createServiceOffering(name, displayText, 2, 1024, 2048, highlyAvailable(true).storageType(StorageType.LOCAL)); Logger.CONSOLE.info("Created Service Offering: " + offering); assertEquals(offering.getName(), name); assertEquals(offering.getDisplayText(), displayText); checkServiceOffering(offering); offering = globalAdminClient.getOfferingClient() .updateServiceOffering(offering.getId(), UpdateServiceOfferingOptions.Builder.name(name + "-2").displayText(displayText + "-2")); assertEquals(offering.getName(), name + "-2"); assertEquals(offering.getDisplayText(), displayText + "-2"); checkServiceOffering(offering); } finally { if (offering != null) { globalAdminClient.getOfferingClient().deleteServiceOffering(offering.getId()); } } }
@Test(groups = "live", enabled = true) public void testCreateServiceOffering() throws Exception { skipIfNotGlobalAdmin(); String name = prefix + "-test-create-service-offering"; String displayText = name + "-display"; ServiceOffering offering = null; try { offering = globalAdminClient.getOfferingApi(). createServiceOffering(name, displayText, 2, 1024, 2048, highlyAvailable(true).storageType(StorageType.LOCAL)); Logger.CONSOLE.info("Created Service Offering: " + offering); assertEquals(offering.getName(), name); assertEquals(offering.getDisplayText(), displayText); checkServiceOffering(offering); offering = globalAdminClient.getOfferingApi() .updateServiceOffering(offering.getId(), UpdateServiceOfferingOptions.Builder.name(name + "-2").displayText(displayText + "-2")); assertEquals(offering.getName(), name + "-2"); assertEquals(offering.getDisplayText(), displayText + "-2"); checkServiceOffering(offering); } finally { if (offering != null) { globalAdminClient.getOfferingApi().deleteServiceOffering(offering.getId()); } } }
public T fromServiceOffering(ServiceOffering in) { return this .id(in.getId()) .name(in.getName()) .displayText(in.getDisplayText()) .created(in.getCreated()) .domain(in.getDomain()) .domainId(in.getDomainId()) .cpuNumber(in.getCpuNumber()) .cpuSpeed(in.getCpuSpeed()) .memory(in.getMemory()) .supportsHA(in.supportsHA()) .storageType(in.getStorageType()) .tags(in.getTags()) .defaultUse(in.isDefaultUse()) .systemOffering(in.isSystemOffering()) .cpuUseLimited(in.isCpuUseLimited()) .networkRate(in.getNetworkRate()) .systemVmType(in.isSystemVmType()); } }
public T fromServiceOffering(ServiceOffering in) { return this .id(in.getId()) .name(in.getName()) .displayText(in.getDisplayText()) .created(in.getCreated()) .domain(in.getDomain()) .domainId(in.getDomainId()) .cpuNumber(in.getCpuNumber()) .cpuSpeed(in.getCpuSpeed()) .memory(in.getMemory()) .supportsHA(in.supportsHA()) .storageType(in.getStorageType()) .tags(in.getTags()) .defaultUse(in.isDefaultUse()) .systemOffering(in.isSystemOffering()) .cpuUseLimited(in.isCpuUseLimited()) .networkRate(in.getNetworkRate()) .systemVmType(in.isSystemVmType()); } }
public T fromServiceOffering(ServiceOffering in) { return this .id(in.getId()) .name(in.getName()) .displayText(in.getDisplayText()) .created(in.getCreated()) .domain(in.getDomain()) .domainId(in.getDomainId()) .cpuNumber(in.getCpuNumber()) .cpuSpeed(in.getCpuSpeed()) .memory(in.getMemory()) .supportsHA(in.supportsHA()) .storageType(in.getStorageType()) .tags(in.getTags()) .defaultUse(in.isDefaultUse()) .systemOffering(in.isSystemOffering()) .cpuUseLimited(in.isCpuUseLimited()) .networkRate(in.getNetworkRate()) .systemVmType(in.isSystemVmType()); } }