Java Code Examples for com.vmware.vim25.VirtualMachineConfigSpec#setCpuAllocation()
The following examples show how to use
com.vmware.vim25.VirtualMachineConfigSpec#setCpuAllocation() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VmwareHelper.java From cloudstack with Apache License 2.0 | 6 votes |
public static void setVmScaleUpConfig(VirtualMachineConfigSpec vmConfig, int cpuCount, int cpuSpeedMHz, int cpuReservedMhz, int memoryMB, int memoryReserveMB, boolean limitCpuUse) { // VM config for scaling up vmConfig.setMemoryMB((long)memoryMB); vmConfig.setNumCPUs(cpuCount); ResourceAllocationInfo cpuInfo = new ResourceAllocationInfo(); if (limitCpuUse) { cpuInfo.setLimit((long)(cpuSpeedMHz * cpuCount)); } else { cpuInfo.setLimit(-1L); } cpuInfo.setReservation((long)cpuReservedMhz); vmConfig.setCpuAllocation(cpuInfo); ResourceAllocationInfo memInfo = new ResourceAllocationInfo(); memInfo.setLimit((long)memoryMB); memInfo.setReservation((long)memoryReserveMB); vmConfig.setMemoryAllocation(memInfo); }
Example 2
Source File: VmUtils.java From cs-actions with Apache License 2.0 | 5 votes |
public VirtualMachineConfigSpec getUpdateConfigSpec(VmInputs vmInputs, VirtualMachineConfigSpec vmConfigSpec, String device) throws Exception { if (!InputUtils.isUpdateOperation(vmInputs)) { throw new RuntimeException(ErrorMessages.CPU_OR_MEMORY_INVALID_OPERATION); } VmConfigSpecs specs = new VmConfigSpecs(); ResourceAllocationInfo resourceAllocationInfo = specs.getResourceAllocationInfo(vmInputs.getUpdateValue()); if (Constants.CPU.equalsIgnoreCase(device)) { vmConfigSpec.setCpuAllocation(resourceAllocationInfo); } else { vmConfigSpec.setMemoryAllocation(resourceAllocationInfo); } return vmConfigSpec; }
Example 3
Source File: VmwareHelper.java From cloudstack with Apache License 2.0 | 5 votes |
public static void setBasicVmConfig(VirtualMachineConfigSpec vmConfig, int cpuCount, int cpuSpeedMHz, int cpuReservedMhz, int memoryMB, int memoryReserveMB, String guestOsIdentifier, boolean limitCpuUse) { // VM config basics vmConfig.setMemoryMB((long)memoryMB); vmConfig.setNumCPUs(cpuCount); ResourceAllocationInfo cpuInfo = new ResourceAllocationInfo(); if (limitCpuUse) { cpuInfo.setLimit(((long)cpuSpeedMHz * cpuCount)); } else { cpuInfo.setLimit(-1L); } cpuInfo.setReservation((long)cpuReservedMhz); vmConfig.setCpuAllocation(cpuInfo); if (cpuSpeedMHz != cpuReservedMhz) { vmConfig.setCpuHotAddEnabled(true); } if (memoryMB != memoryReserveMB) { vmConfig.setMemoryHotAddEnabled(true); } ResourceAllocationInfo memInfo = new ResourceAllocationInfo(); memInfo.setLimit((long)memoryMB); memInfo.setReservation((long)memoryReserveMB); vmConfig.setMemoryAllocation(memInfo); vmConfig.setGuestId(guestOsIdentifier); }