private void addDiskItems(XMLBuilder sectionBuilder, VApp vApp, VAppConfiguration configuration) { for (ResourceAllocationSettingData disk : filter(vApp.getResourceAllocations(), CIMPredicates .resourceTypeIn(ResourceType.DISK_DRIVE))) { if (!configuration.getDisksToDelete().contains(Integer.valueOf(disk.getAddressOnParent()))) { addDiskWithQuantity(sectionBuilder, disk); } } for (Long quantity : configuration.getDisks()) { ResourceAllocationSettingData disk = ResourceAllocationSettingData.builder().instanceID("9").addressOnParent( "-1").elementName("").resourceType(ResourceType.DISK_DRIVE).virtualQuantity(quantity).build(); addDiskWithQuantity(sectionBuilder, disk); } }
public void testHosting() { InputStream is = getClass().getResourceAsStream("/resourceallocation-hosting.xml"); ResourceAllocationSettingData result = factory.create( injector.getInstance(ResourceAllocationSettingDataHandler.class)).parse(is); ResourceAllocationSettingData expects = ResourceAllocationSettingData.builder().elementName("1 virtual CPU(s)") .allocationUnits("hertz * 10^6").instanceID("1").resourceType(ResourceAllocationSettingData.ResourceType.PROCESSOR) .virtualQuantity(1l).description("Number of Virtual CPUs").virtualQuantityUnits("count").build(); assertEquals(result.toString(), expects.toString()); } }
public void testNormal() { InputStream is = getClass().getResourceAsStream("/resourceallocation.xml"); ResourceAllocationSettingData result = factory.create( injector.getInstance(ResourceAllocationSettingDataHandler.class)).parse(is); ResourceAllocationSettingData expects = ResourceAllocationSettingData.builder().allocationUnits("Gigabytes") .caption("1234568").description("Hard Disk").elementName("D:\\").hostResource("data").instanceID("6") .resourceType(ResourceAllocationSettingData.ResourceType.PARTITIONABLE_UNIT).virtualQuantity(50l) .build(); assertEquals(result.toString(), expects.toString()); }
ResourceType.PARALLEL_SCSI_HBA).resourceSubType("lsilogic").address("0").build().toString()); ResourceType.IDE_CONTROLLER).address("0").build().toString()); ResourceType.CD_DRIVE).addressOnParent("0").automaticAllocation(false).parent("3").build() .toString()); ResourceType.FLOPPY_DRIVE).addressOnParent("0").automaticAllocation(false).build().toString());
ResourceAllocationSettingData.builder().instanceID("1").elementName("1 virtual CPU(s)").description( "Number of Virtual CPUs").resourceType(ResourceType.PROCESSOR).virtualQuantity(1l) .allocationUnits("hertz * 10^6").virtualQuantityUnits("count").build(), "byte * 2^20").virtualQuantityUnits("byte * 2^20").build(), .address("0").build(), true).build(), .virtualQuantity(10485760l).build());
.virtualQuantity(2l).virtualQuantityUnits("hertz * 10^6").build(); .resourceSubType("lsilogic").address("0").virtualQuantity(1l).build(); ResourceAllocationSettingData memory = ResourceAllocationSettingData.builder().instanceID("2").elementName( "1024MB of memory").description("Memory Size").resourceType(ResourceType.MEMORY).virtualQuantity(1024l) .virtualQuantityUnits("byte * 2^20").build(); ResourceAllocationSettingData disk = ResourceAllocationSettingData.builder().instanceID("9").elementName( "Hard Disk 1").resourceType(ResourceType.DISK_DRIVE).hostResource("4194304").addressOnParent("0") .virtualQuantity(4194304l).virtualQuantityUnits("byte * 2^20").build(); ResourceAllocationSettingData disk2 = ResourceAllocationSettingData.builder().instanceID("9").elementName( "Hard Disk 2").resourceType(ResourceType.DISK_DRIVE).hostResource("26214400").addressOnParent("1") .virtualQuantity(26214400l).virtualQuantityUnits("byte * 2^20").build();
ResourceAllocationSettingData.builder().instanceID("1").elementName("1 virtual CPU(s)").description( "Number of Virtual CPUs").resourceType(ResourceType.PROCESSOR).virtualQuantity(1l) .allocationUnits("hertz * 10^6").virtualQuantityUnits("count").build(), "byte * 2^20").virtualQuantityUnits("byte * 2^20").build(), .address("0").build(), true).build(), .virtualQuantity(104857l).build());
.virtualQuantity(2l).virtualQuantityUnits("hertz * 10^6").build(); .resourceSubType("lsilogic").address("0").virtualQuantity(1l).build(); ResourceAllocationSettingData memory = ResourceAllocationSettingData.builder().instanceID("2").elementName( "512MB of memory").description("Memory Size").resourceType(ResourceType.MEMORY).virtualQuantity(512l) .virtualQuantityUnits("byte * 2^20").build(); ResourceAllocationSettingData disk = ResourceAllocationSettingData.builder().instanceID("9").elementName( "Hard Disk 1").resourceType(ResourceType.DISK_DRIVE).hostResource("10485760").addressOnParent("0") .virtualQuantity(10485760l).virtualQuantityUnits("byte * 2^20").build(); assertEquals(result.getResourceAllocations(), ImmutableSet.of(cpu, memory, controller, disk)); assertEquals(find(result.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.PROCESSOR))
.builder().instanceID("1").elementName("Network adapter 0").description("PCNet32 ethernet adapter") .resourceType(ResourceType.ETHERNET_ADAPTER).resourceSubType("PCNet32").address("00:50:56:8c:00:13") .automaticAllocation(true).connection("vAppNet-vApp Internal").addressOnParent("0").build().toString()); ResourceType.PARALLEL_SCSI_HBA).resourceSubType("lsilogic").address("0").build().toString()); ResourceType.DISK_DRIVE).addressOnParent("0").parent("2").build().toString()); ResourceType.IDE_CONTROLLER).address("0").build().toString()); ResourceType.CD_DRIVE).addressOnParent("0").parent("3").automaticAllocation(false).build() .toString()); ResourceType.FLOPPY_DRIVE).addressOnParent("0").automaticAllocation(false).build().toString()); .reservation(0l).weight(0).build().toString()); .weight(0).build().toString());
public void testRemoveDisk() throws IOException { VAppImpl vApp = new VAppImpl("MyAppServer6", URI .create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), Status.OFF, 4194304l, null, ImmutableListMultimap.<String, String> of(), null, null, null, ImmutableSet.of( ResourceAllocationSettingData.builder().instanceID("1").elementName("foo").resourceType( ResourceType.PROCESSOR).virtualQuantity(2l).build(),// ResourceAllocationSettingData.builder().instanceID("2").elementName("foo").resourceType( ResourceType.MEMORY).virtualQuantity(1024l).build(), // ResourceAllocationSettingData.builder().instanceID("9").elementName("foo").addressOnParent("0") .hostResource("1048576").resourceType(ResourceType.DISK_DRIVE) .virtualQuantity(209152l).build(),// ResourceAllocationSettingData.builder().instanceID("9").elementName("foo").addressOnParent("1") .hostResource("1048576").resourceType(ResourceType.DISK_DRIVE) .virtualQuantity(209152l).build()// ) ); String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/configureVApp.xml")) .replace("eduardo", "MyAppServer6"); VAppConfiguration config = new VAppConfiguration().deleteDiskWithAddressOnParent(1); GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of(vApp, config)); BindVAppConfigurationToXmlPayload binder = injector.getInstance(BindVAppConfigurationToXmlPayload.class); Map<String, Object> map = Maps.newHashMap(); assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected); }
public void testChangeCPUCountTo4() throws IOException { VAppImpl vApp = new VAppImpl("eduardo", URI .create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), Status.OFF, 4194304l, null, ImmutableListMultimap.<String, String> of(), null, null, null, ImmutableSet.of( ResourceAllocationSettingData.builder().instanceID("1").elementName("foo").resourceType( ResourceType.PROCESSOR).virtualQuantity(4l).build(), ResourceAllocationSettingData .builder().instanceID("2").elementName("foo").resourceType(ResourceType.MEMORY) .virtualQuantity(1024l).build(), ResourceAllocationSettingData.builder().instanceID( "9").elementName("foo").addressOnParent("0").hostResource("1048576").resourceType( ResourceType.DISK_DRIVE).virtualQuantity(209152l).build())); String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/configureVApp4.xml")); VAppConfiguration config = new VAppConfiguration().changeProcessorCountTo(4); GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of(vApp, config)); BindVAppConfigurationToXmlPayload binder = injector.getInstance(BindVAppConfigurationToXmlPayload.class); Map<String, Object> map = Maps.newHashMap(); assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected); }
public void testChangeAll() throws IOException { VAppImpl vApp = new VAppImpl("MyAppServer6", URI .create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), Status.OFF, 4194304l, null, ImmutableListMultimap.<String, String> of(), null, null, null, ImmutableSet.of( ResourceAllocationSettingData.builder().instanceID("1").elementName("foo").resourceType( ResourceType.PROCESSOR).virtualQuantity(2l).build(), ResourceAllocationSettingData .builder().instanceID("2").elementName("foo").resourceType(ResourceType.MEMORY) .virtualQuantity(1024l).build(), ResourceAllocationSettingData.builder().instanceID( "9").elementName("foo").addressOnParent("0").hostResource("1048576").resourceType( ResourceType.DISK_DRIVE).virtualQuantity(209152l).build())); String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/configureVAppAll.xml")); VAppConfiguration config = changeNameTo("eduardo").changeMemoryTo(1536).changeProcessorCountTo(1).addDisk( 25 * 1048576).addDisk(25 * 1048576); GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of(vApp, config)); BindVAppConfigurationToXmlPayload binder = injector.getInstance(BindVAppConfigurationToXmlPayload.class); Map<String, Object> map = Maps.newHashMap(); assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected); }
public void testChangeMemoryTo1536() throws IOException { VAppImpl vApp = new VAppImpl("MyAppServer6", URI .create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), Status.OFF, 4194304l, null, ImmutableListMultimap.<String, String> of(), null, null, null, ImmutableSet.of( ResourceAllocationSettingData.builder().instanceID("1").elementName("foo").resourceType( ResourceType.PROCESSOR).virtualQuantity(2l).build(), ResourceAllocationSettingData .builder().instanceID("2").elementName("foo").resourceType(ResourceType.MEMORY) .virtualQuantity(1536l).build(), ResourceAllocationSettingData.builder().instanceID( "9").elementName("foo").addressOnParent("0").hostResource("1048576").resourceType( ResourceType.DISK_DRIVE).virtualQuantity(209152l).build())); String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/configureVApp.xml")) .replace("eduardo", "MyAppServer6").replace("1024", "1536"); VAppConfiguration config = new VAppConfiguration().changeMemoryTo(1536); GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of(vApp, config)); BindVAppConfigurationToXmlPayload binder = injector.getInstance(BindVAppConfigurationToXmlPayload.class); Map<String, Object> map = Maps.newHashMap(); assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected); } }
public void testChangeName() throws IOException { VAppImpl vApp = new VAppImpl("MyAppServer6", URI .create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), Status.OFF, 4194304l, null, ImmutableListMultimap.<String, String> of(), null, null, null, ImmutableSet.of( ResourceAllocationSettingData.builder().instanceID("1").elementName("foo").resourceType( ResourceType.PROCESSOR).virtualQuantity(2l).build(), ResourceAllocationSettingData .builder().instanceID("2").elementName("foo").resourceType(ResourceType.MEMORY) .virtualQuantity(1024l).build(), ResourceAllocationSettingData.builder().instanceID( "9").elementName("foo").addressOnParent("0").hostResource("1048576").resourceType( ResourceType.DISK_DRIVE).virtualQuantity(209152l).build())); String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/configureVApp.xml")) .replace("eduardo", "roberto"); VAppConfiguration config = new VAppConfiguration().changeNameTo("roberto"); GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of(vApp, config)); BindVAppConfigurationToXmlPayload binder = injector.getInstance(BindVAppConfigurationToXmlPayload.class); Map<String, Object> map = Maps.newHashMap(); assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected); }
public ResourceAllocationSettingData getResult() { try { return builder.build(); } finally { builder = ResourceAllocationSettingData.builder(); } }
public ResourceAllocationSettingData getResult() { try { return builder.build(); } finally { builder = ResourceAllocationSettingData.builder(); } }
public ResourceAllocationSettingData getResult() { try { return builder.build(); } finally { builder = ResourceAllocationSettingData.builder(); } }
public ResourceAllocationSettingData getResult() { try { return builder.build(); } finally { builder = ResourceAllocationSettingData.builder(); } }