• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java SharesInfo类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中com.vmware.vim25.SharesInfo的典型用法代码示例。如果您正苦于以下问题:Java SharesInfo类的具体用法?Java SharesInfo怎么用?Java SharesInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

SharesInfo类属于com.vmware.vim25包,在下文中一共展示了SharesInfo类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getShares

点赞 3

import com.vmware.vim25.SharesInfo; //导入依赖的package包/类
static ResourceAllocationInfo getShares(String val) throws Exception 
{
  ResourceAllocationInfo raInfo = new ResourceAllocationInfo();
  SharesInfo sharesInfo = new SharesInfo();

  if("high".equalsIgnoreCase(val)) 
  {
    sharesInfo.setLevel(SharesLevel.high);          
  }
  else if("normal".equalsIgnoreCase(val)) 
  {
    sharesInfo.setLevel(SharesLevel.normal);
  }
  else if("low".equalsIgnoreCase(val)) 
  {
    sharesInfo.setLevel(SharesLevel.low);
  }
  else 
  {
    sharesInfo.setLevel(SharesLevel.custom);          
    sharesInfo.setShares(Integer.parseInt(val));          
  }    
  raInfo.setShares(sharesInfo);
  return raInfo;
}
 

开发者ID:Juniper,
项目名称:vijava
代码行数:26,
代码来源:VmAllocateResource.java

示例2: getStorageIOAllocationInfo

点赞 2

import com.vmware.vim25.SharesInfo; //导入依赖的package包/类
/**
 * Constructs storage IO allocation if this is not already dictated by the storage policy that
 * is chosen.
 */
public static StorageIOAllocationInfo getStorageIOAllocationInfo(
        DiskService.DiskStateExpanded diskState) throws
        NumberFormatException {
    if (diskState.customProperties != null) {
        String sharesLevel = diskState.customProperties.get(SHARES_LEVEL);
        // If the value is null or wrong value sent by the caller for SharesLevel then don't
        // set anything on the API for this. Hence default to null.
        if (sharesLevel != null) {
            try {
                StorageIOAllocationInfo allocationInfo = new StorageIOAllocationInfo();
                SharesInfo sharesInfo = new SharesInfo();
                sharesInfo.setLevel(SharesLevel.fromValue(sharesLevel));
                if (sharesInfo.getLevel() == SharesLevel.CUSTOM) {
                    // Set shares value
                    String sharesVal = diskState.customProperties.get(SHARES);
                    if (sharesVal == null || sharesVal.isEmpty()) {
                        // Reset to normal as nothing is specified for the shares
                        sharesInfo.setLevel(SharesLevel.NORMAL);
                    } else {
                        sharesInfo.setShares(Integer.parseInt(sharesVal));
                    }
                }
                allocationInfo.setShares(sharesInfo);
                String limitIops = diskState.customProperties.get(LIMIT_IOPS);
                if (limitIops != null && !limitIops.isEmpty()) {
                    allocationInfo.setLimit(Long.parseLong(limitIops));
                }
                return allocationInfo;
            } catch (Exception e) {
                logger.warn("Ignoring the storage IO allocation customization values due to {}",
                        e.getMessage());
                return null;
            }
        }
    }
    return null;
}
 

开发者ID:vmware,
项目名称:photon-model,
代码行数:42,
代码来源:ClientUtils.java

示例3: getSharesInfo

点赞 2

import com.vmware.vim25.SharesInfo; //导入依赖的package包/类
<T> SharesInfo getSharesInfo(T value) throws Exception {
    SharesInfo sharesInfo = new SharesInfo();
    if (InputUtils.isInt((String) value)) {
        sharesInfo.setLevel(SharesLevel.CUSTOM);
        sharesInfo.setShares(Integer.parseInt((String) value));
    } else {
        setSharesInfoLevel((String) value, sharesInfo);
    }

    return sharesInfo;
}
 

开发者ID:CloudSlang,
项目名称:cs-actions,
代码行数:12,
代码来源:VmUtils.java

示例4: setSharesInfoLevel

点赞 2

import com.vmware.vim25.SharesInfo; //导入依赖的package包/类
private void setSharesInfoLevel(String value, SharesInfo sharesInfo) throws Exception {
    String level = Level.getValue(value);
    if (SharesLevel.HIGH.toString().equalsIgnoreCase(level)) {
        sharesInfo.setLevel(SharesLevel.HIGH);
    } else if (SharesLevel.NORMAL.toString().equalsIgnoreCase(level)) {
        sharesInfo.setLevel(SharesLevel.NORMAL);
    } else {
        sharesInfo.setLevel(SharesLevel.LOW);
    }
}
 

开发者ID:CloudSlang,
项目名称:cs-actions,
代码行数:11,
代码来源:VmUtils.java

示例5: main

点赞 2

import com.vmware.vim25.SharesInfo; //导入依赖的package包/类
public static void main(String[] args) throws Exception
{
	if(args.length!=3)
	{
		System.out.println("Usage: DrsVmShares url username password");
		System.exit(-1);
	}
	
	URL url = null;
	try 
	{ 
		url = new URL(args[0]); 
	} catch ( MalformedURLException urlE)
	{
		System.out.println("The URL provided is NOT valid. Please check it.");
		System.exit(-1);
	}
	String username = args[1];
	String password = args[2];
	String vm1_oid = "vm-26"; // The reference ID for VM 1
	String vm2_oid = "vm-28"; // The reference ID for VM 2
	
	// initialize the system, set up web services
   ServiceInstance si = new ServiceInstance(url, username, password, true);
   
	// create a new VirtualMachineConfigSpec for VM1
	VirtualMachineConfigSpec vmcs1 = new VirtualMachineConfigSpec();
	ResourceAllocationInfo rai1 = new ResourceAllocationInfo();
	SharesInfo si1 = new SharesInfo();
	si1.setLevel(SharesLevel.custom);
	si1.setShares(1333);
	rai1.setShares(si1);
	vmcs1.setCpuAllocation(rai1);

	// do the same for VM2
	VirtualMachineConfigSpec vmcs2 = new VirtualMachineConfigSpec();
	ResourceAllocationInfo rai2 = new ResourceAllocationInfo();
	SharesInfo si2 = new SharesInfo();
	si2.setLevel(SharesLevel.high);
	rai2.setShares(si2);
	vmcs2.setCpuAllocation(rai2);
	
	ManagedObjectReference vm1_mor = createMOR("VirtualMachine", vm1_oid);
	ManagedObjectReference vm2_mor = createMOR("VirtualMachine", vm2_oid);
	VirtualMachine vm1 = (VirtualMachine) MorUtil.createExactManagedEntity(si.getServerConnection(), vm1_mor);
	VirtualMachine vm2 = (VirtualMachine) MorUtil.createExactManagedEntity(si.getServerConnection(), vm2_mor);
	
	// make a web service call to set the configuration.
	vm1.reconfigVM_Task(vmcs1);
	vm2.reconfigVM_Task(vmcs2);			

	// log out from web service
	si.getServerConnection().logout();
	System.out.println("Done with setting VM CPU shares.");
}
 

开发者ID:Juniper,
项目名称:vijava
代码行数:56,
代码来源:DrsVmShares.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)