本文整理汇总了Java中com.vmware.vim25.VirtualMachineConfigSpec.setMemoryAllocation方法的典型用法代码示例。如果您正苦于以下问题:Java VirtualMachineConfigSpec.setMemoryAllocation方法的具体用法?Java VirtualMachineConfigSpec.setMemoryAllocation怎么用?Java VirtualMachineConfigSpec.setMemoryAllocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vmware.vim25.VirtualMachineConfigSpec
的用法示例。
在下文中一共展示了VirtualMachineConfigSpec.setMemoryAllocation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setVmScaleUpConfig
import com.vmware.vim25.VirtualMachineConfigSpec; //导入方法依赖的package包/类
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);
}
示例2: getUpdateConfigSpec
import com.vmware.vim25.VirtualMachineConfigSpec; //导入方法依赖的package包/类
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;
}
示例3: setBasicVmConfig
import com.vmware.vim25.VirtualMachineConfigSpec; //导入方法依赖的package包/类
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);
}
示例4: main
import com.vmware.vim25.VirtualMachineConfigSpec; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
if(args.length!=6)
{
System.out.println("Usage: java VmAllocateResource <url> " +
"<username> <password> <vmname> <device> <value>");
System.out.println("device - cpu|memory");
System.out.println("value: high|low|normal|numeric value");
System.exit(0);
}
String vmname = args[3];
String deviceType = args[4];
String value = args[5];
ServiceInstance si = new ServiceInstance(
new URL(args[0]), args[1], args[2], true);
Folder rootFolder = si.getRootFolder();
VirtualMachine vm = (VirtualMachine) new InventoryNavigator(
rootFolder).searchManagedEntity("VirtualMachine", vmname);
if(vm==null)
{
System.out.println("No VM " + vmname + " found");
si.getServerConnection().logout();
return;
}
VirtualMachineConfigSpec vmConfigSpec =
new VirtualMachineConfigSpec();
if("memory".equalsIgnoreCase(deviceType))
{
System.out.println("Reconfig memory for VM: " + vmname);
vmConfigSpec.setMemoryAllocation(getShares(value));
}
else if("cpu".equalsIgnoreCase(deviceType))
{
System.out.println("Reconfig CPU for VM: " + vmname);
vmConfigSpec.setCpuAllocation(getShares(value));
}
else
{
System.out.println("Incorrect option for " + vmname);
}
Task task = vm.reconfigVM_Task(vmConfigSpec);
task.waitForMe();
}