/** * {@inheritDoc} */ @Override public Builder toBuilder() { return builder().fromResourceAllocationSettingData(this); }
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(); } }
/** * {@inheritDoc} */ @Override public Builder toBuilder() { return builder().fromResourceAllocationSettingData(this); }
/** * {@inheritDoc} */ @Override public Builder toBuilder() { return builder().fromResourceAllocationSettingData(this); }
public ResourceAllocationSettingData getResult() { try { return builder.build(); } finally { builder = ResourceAllocationSettingData.builder(); } }
/** * {@inheritDoc} */ @Override public Builder toBuilder() { return builder().fromResourceAllocationSettingData(this); }
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 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 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 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 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()); }
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 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); }
assertEquals(result.getNetworkToAddresses().get("Internal"), ImmutableList.<String> of("10.114.34.132")); ResourceAllocationSettingData cpu = ResourceAllocationSettingData.builder().instanceID("1").elementName( "1 virtual CPU(s)").description("Number of Virtual CPUs").resourceType(ResourceType.PROCESSOR) .virtualQuantity(2l).virtualQuantityUnits("hertz * 10^6").build(); ResourceAllocationSettingData controller = ResourceAllocationSettingData.builder().instanceID("3").elementName( "SCSI Controller 0").description("SCSI Controller").resourceType(ResourceType.PARALLEL_SCSI_HBA) .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();
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(), ResourceAllocationSettingData.builder().instanceID("2").elementName("16MB of memory").description( "Memory Size").resourceType(ResourceType.MEMORY).virtualQuantity(16l).allocationUnits( "byte * 2^20").virtualQuantityUnits("byte * 2^20").build(), ResourceAllocationSettingData.builder().instanceID("3").elementName("SCSI Controller 0").description( "SCSI Controller").resourceType(ResourceType.PARALLEL_SCSI_HBA).resourceSubType("lsilogic") .address("0").build(), ResourceAllocationSettingData.builder().instanceID("8").elementName("Network Adapter 1").description( "PCNet32 ethernet adapter on \"Internal\" network").resourceType(ResourceType.ETHERNET_ADAPTER) .resourceSubType("PCNet32").addressOnParent("7").connection("Internal").automaticAllocation( true).build(), ResourceAllocationSettingData.builder().instanceID("9").elementName("Hard Disk 1").resourceType( ResourceType.DISK_DRIVE).hostResource("104857").addressOnParent("0").parent("3") .virtualQuantity(104857l).build());
.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()); .builder().instanceID("2").elementName("SCSI Controller 0").description("SCSI Controller").resourceType( ResourceType.PARALLEL_SCSI_HBA).resourceSubType("lsilogic").address("0").build().toString()); .builder().instanceID("2000").elementName("Hard disk 1").description("Hard disk").resourceType( ResourceType.DISK_DRIVE).addressOnParent("0").parent("2").build().toString()); .builder().instanceID("3").elementName("IDE Controller 0").description("IDE Controller").resourceType( ResourceType.IDE_CONTROLLER).address("0").build().toString()); .builder().instanceID("3002").elementName("CD/DVD Drive 1").description("CD/DVD Drive").resourceType( ResourceType.CD_DRIVE).addressOnParent("0").parent("3").automaticAllocation(false).build() .toString()); .builder().instanceID("8000").elementName("Floppy Drive 1").description("Floppy Drive").resourceType( ResourceType.FLOPPY_DRIVE).addressOnParent("0").automaticAllocation(false).build().toString()); .builder().instanceID("4").elementName("1 virtual CPU(s)").description("Number of Virtual CPUs") .resourceType(ResourceType.PROCESSOR).virtualQuantity(1l).allocationUnits("hertz * 10^6") .reservation(0l).weight(0).build().toString()); .builder().instanceID("5").elementName("512 MB of memory").description("Memory Size").resourceType( ResourceType.MEMORY).virtualQuantity(512l).allocationUnits("byte * 2^20").reservation(0l) .weight(0).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(), ResourceAllocationSettingData.builder().instanceID("2").elementName("512MB of memory").description( "Memory Size").resourceType(ResourceType.MEMORY).virtualQuantity(512l).allocationUnits( "byte * 2^20").virtualQuantityUnits("byte * 2^20").build(), ResourceAllocationSettingData.builder().instanceID("3").elementName("SCSI Controller 0").description( "SCSI Controller").resourceType(ResourceType.PARALLEL_SCSI_HBA).resourceSubType("lsilogic") .address("0").build(), ResourceAllocationSettingData.builder().instanceID("8").elementName("Network Adapter 1").description( "PCNet32 ethernet adapter on \"Internal\" network").resourceType(ResourceType.ETHERNET_ADAPTER) .resourceSubType("PCNet32").addressOnParent("7").connection("Internal").automaticAllocation( true).build(), ResourceAllocationSettingData.builder().instanceID("9").elementName("Hard Disk 1").resourceType( ResourceType.DISK_DRIVE).hostResource("10485760").addressOnParent("0").parent("3") .virtualQuantity(10485760l).build());