protected void addVirtualQuantityIfPresent(XMLBuilder instantiationParamsBuilder, SortedMap<ResourceType, String> virtualHardwareQuantity) { XMLBuilder productSectionBuilder = instantiationParamsBuilder.e("ProductSection").a("xmlns:q1", ns) .a("xmlns:ovf", "http://schemas.dmtf.org/ovf/envelope/1"); if (propLocal.get() != null) { for (Entry<String, String> entry : propLocal.get().entrySet()) { productSectionBuilder.e("Property").a("xmlns", "http://schemas.dmtf.org/ovf/envelope/1") .a("ovf:key", entry.getKey()).a("ovf:value", entry.getValue()); } propLocal.set(null); } if (virtualHardwareQuantity.size() > 0) { XMLBuilder virtualHardwareSectionBuilder = instantiationParamsBuilder.e("VirtualHardwareSection").a( "xmlns:q1", ns); for (Entry<ResourceType, String> entry : virtualHardwareQuantity.entrySet()) { XMLBuilder itemBuilder = virtualHardwareSectionBuilder.e("Item").a("xmlns", "http://schemas.dmtf.org/ovf/envelope/1"); itemBuilder.e("InstanceID") .a("xmlns", "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData") .t(virtualHardwareToInstanceId.get(entry.getKey())); itemBuilder.e("ResourceType") .a("xmlns", "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData") .t(entry.getKey().value()); itemBuilder.e("VirtualQuantity") .a("xmlns", "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData") .t(entry.getValue()); } } } }
@Override public <R extends HttpRequest> R bindToRequest(R request, Object payload) { checkArgument(checkNotNull(payload, "cpuCount") instanceof Integer, "this binder is only valid for Integers!"); Integer cpuCount = Integer.class.cast(payload); XMLBuilder cpuItem; try { cpuItem = XMLBuilder.create("Item").a("xmlns", ns).a("xmlns:rasd", RESOURCE_ALLOCATION_NS); cpuItem.e("rasd:AllocationUnits").t("hertz * 10^6"); cpuItem.e("rasd:Description").t("Number of Virtual CPUs"); cpuItem.e("rasd:ElementName").t(cpuCount.toString() + " virtual CPU(s)"); cpuItem.e("rasd:InstanceID").t("4"); cpuItem.e("rasd:ResourceType").t(ResourceType.PROCESSOR.value()); cpuItem.e("rasd:VirtualQuantity").t(cpuCount.toString()); cpuItem.e("rasd:Weight").t("0"); Properties outputProperties = new Properties(); outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes"); request = super.bindToRequest(request, cpuItem.asString(outputProperties)); } catch (Exception e) { Throwables.propagate(e); } return request; }
@Override public <R extends HttpRequest> R bindToRequest(R request, Object payload) { checkArgument(checkNotNull(payload, "cpuCount") instanceof Integer, "this binder is only valid for Integers!"); Integer cpuCount = Integer.class.cast(payload); XMLBuilder cpuItem; try { cpuItem = XMLBuilder.create("Item").a("xmlns", ns).a("xmlns:rasd", RESOURCE_ALLOCATION_NS); cpuItem.e("rasd:AllocationUnits").t("hertz * 10^6"); cpuItem.e("rasd:Description").t("Number of Virtual CPUs"); cpuItem.e("rasd:ElementName").t(cpuCount.toString() + " virtual CPU(s)"); cpuItem.e("rasd:InstanceID").t("4"); cpuItem.e("rasd:ResourceType").t(ResourceType.PROCESSOR.value()); cpuItem.e("rasd:VirtualQuantity").t(cpuCount.toString()); cpuItem.e("rasd:Weight").t("0"); Properties outputProperties = new Properties(); outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes"); request = super.bindToRequest(request, cpuItem.asString(outputProperties)); } catch (Exception e) { Throwables.propagate(e); } return request; }
@Override public <R extends HttpRequest> R bindToRequest(R request, Object payload) { checkArgument(checkNotNull(payload, "memoryInMB") instanceof Integer, "this binder is only valid for Integers!"); Integer memoryInMB = Integer.class.cast(payload); XMLBuilder cpuItem; try { cpuItem = XMLBuilder.create("Item").a("xmlns", ns).a("xmlns:rasd", RESOURCE_ALLOCATION_NS); cpuItem.e("rasd:AllocationUnits").t("byte * 2^20"); cpuItem.e("rasd:Description").t("Memory Size"); cpuItem.e("rasd:ElementName").t(memoryInMB.toString() + " MB of memory"); cpuItem.e("rasd:InstanceID").t("5"); cpuItem.e("rasd:Reservation").t("0"); cpuItem.e("rasd:ResourceType").t(ResourceType.MEMORY.value()); cpuItem.e("rasd:VirtualQuantity").t(memoryInMB.toString()); cpuItem.e("rasd:Weight").t("0"); Properties outputProperties = new Properties(); outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes"); request = super.bindToRequest(request, cpuItem.asString(outputProperties)); } catch (Exception e) { Throwables.propagate(e); } return request; }
@Override public <R extends HttpRequest> R bindToRequest(R request, Object payload) { checkArgument(checkNotNull(payload, "cpuCount") instanceof Integer, "this binder is only valid for Integers!"); Integer cpuCount = Integer.class.cast(payload); XMLBuilder cpuItem; try { cpuItem = XMLBuilder.create("Item").a("xmlns", ns).a("xmlns:rasd", RESOURCE_ALLOCATION_NS); cpuItem.e("rasd:AllocationUnits").t("hertz * 10^6"); cpuItem.e("rasd:Description").t("Number of Virtual CPUs"); cpuItem.e("rasd:ElementName").t(cpuCount.toString() + " virtual CPU(s)"); cpuItem.e("rasd:InstanceID").t("4"); cpuItem.e("rasd:ResourceType").t(ResourceType.PROCESSOR.value()); cpuItem.e("rasd:VirtualQuantity").t(cpuCount.toString()); cpuItem.e("rasd:Weight").t("0"); Properties outputProperties = new Properties(); outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes"); request = super.bindToRequest(request, cpuItem.asString(outputProperties)); } catch (Exception e) { Throwables.propagate(e); } return request; }
@Override public <R extends HttpRequest> R bindToRequest(R request, Object payload) { checkArgument(checkNotNull(payload, "memoryInMB") instanceof Integer, "this binder is only valid for Integers!"); Integer memoryInMB = Integer.class.cast(payload); XMLBuilder cpuItem; try { cpuItem = XMLBuilder.create("Item").a("xmlns", ns).a("xmlns:rasd", RESOURCE_ALLOCATION_NS); cpuItem.e("rasd:AllocationUnits").t("byte * 2^20"); cpuItem.e("rasd:Description").t("Memory Size"); cpuItem.e("rasd:ElementName").t(memoryInMB.toString() + " MB of memory"); cpuItem.e("rasd:InstanceID").t("5"); cpuItem.e("rasd:Reservation").t("0"); cpuItem.e("rasd:ResourceType").t(ResourceType.MEMORY.value()); cpuItem.e("rasd:VirtualQuantity").t(memoryInMB.toString()); cpuItem.e("rasd:Weight").t("0"); Properties outputProperties = new Properties(); outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes"); request = super.bindToRequest(request, cpuItem.asString(outputProperties)); } catch (Exception e) { Throwables.propagate(e); } return request; }
@Override public <R extends HttpRequest> R bindToRequest(R request, Object payload) { checkArgument(checkNotNull(payload, "memoryInMB") instanceof Integer, "this binder is only valid for Integers!"); Integer memoryInMB = Integer.class.cast(payload); XMLBuilder cpuItem; try { cpuItem = XMLBuilder.create("Item").a("xmlns", ns).a("xmlns:rasd", RESOURCE_ALLOCATION_NS); cpuItem.e("rasd:AllocationUnits").t("byte * 2^20"); cpuItem.e("rasd:Description").t("Memory Size"); cpuItem.e("rasd:ElementName").t(memoryInMB.toString() + " MB of memory"); cpuItem.e("rasd:InstanceID").t("5"); cpuItem.e("rasd:Reservation").t("0"); cpuItem.e("rasd:ResourceType").t(ResourceType.MEMORY.value()); cpuItem.e("rasd:VirtualQuantity").t(memoryInMB.toString()); cpuItem.e("rasd:Weight").t("0"); Properties outputProperties = new Properties(); outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes"); request = super.bindToRequest(request, cpuItem.asString(outputProperties)); } catch (Exception e) { Throwables.propagate(e); } return request; }
private void addCommonElements(XMLBuilder itemBuilder, ResourceAllocationSettingData resource, long quantity) { itemBuilder.e("InstanceID").a("xmlns", RESOURCE_ALLOCATION_NS).t(resource.getInstanceID() + ""); itemBuilder.e("ResourceType").a("xmlns", RESOURCE_ALLOCATION_NS).t(resource.getResourceType().value()); itemBuilder.e("VirtualQuantity").a("xmlns", RESOURCE_ALLOCATION_NS).t(quantity + ""); }