当前位置: 首页>>代码示例>>Java>>正文


Java VirtualMachineConfigSpec.setMemoryAllocation方法代码示例

本文整理汇总了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);

}
 
开发者ID:apache,项目名称:cloudstack,代码行数:24,代码来源:VmwareHelper.java

示例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;
}
 
开发者ID:CloudSlang,项目名称:cs-actions,代码行数:16,代码来源:VmUtils.java

示例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);
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:30,代码来源:VmwareHelper.java

示例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();
}
 
开发者ID:Juniper,项目名称:vijava,代码行数:51,代码来源:VmAllocateResource.java


注:本文中的com.vmware.vim25.VirtualMachineConfigSpec.setMemoryAllocation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。