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


Java VirtualMachineRuntimeInfo.getHost方法代码示例

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


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

示例1: doesNetworkNameExist

import com.vmware.vim25.VirtualMachineRuntimeInfo; //导入方法依赖的package包/类
static boolean doesNetworkNameExist(VirtualMachine vm, 
    String netName) throws Exception 
{
  VirtualMachineRuntimeInfo vmRuntimeInfo = vm.getRuntime();
  EnvironmentBrowser envBrowser = vm.getEnvironmentBrowser();
  ManagedObjectReference hmor = vmRuntimeInfo.getHost();

  HostSystem host = new HostSystem(
      vm.getServerConnection(), hmor);
  ConfigTarget cfg = envBrowser.queryConfigTarget(host);
  VirtualMachineNetworkInfo[] nets = cfg.getNetwork();
  for (int i = 0; nets!=null && i < nets.length; i++) 
  {
    NetworkSummary netSummary = nets[i].getNetwork();
    if (netSummary.isAccessible() && 
        netSummary.getName().equalsIgnoreCase(netName)) 
    {
      return true;
    }
  }
  return false;
}
 
开发者ID:Juniper,项目名称:vijava,代码行数:23,代码来源:VmNicOp.java

示例2: findDatastoreSummary

import com.vmware.vim25.VirtualMachineRuntimeInfo; //导入方法依赖的package包/类
static DatastoreSummary findDatastoreSummary(VirtualMachine vm, String dsName) throws Exception 
{
  DatastoreSummary dsSum = null;
  VirtualMachineRuntimeInfo vmRuntimeInfo = vm.getRuntime();
  EnvironmentBrowser envBrowser = vm.getEnvironmentBrowser(); 
  ManagedObjectReference hmor = vmRuntimeInfo.getHost();

  if(hmor == null)
  {
    System.out.println("No Datastore found");
    return null;
  }
  
  ConfigTarget configTarget = envBrowser.queryConfigTarget(new HostSystem(vm.getServerConnection(), hmor));
  VirtualMachineDatastoreInfo[] dis = configTarget.getDatastore();
  for (int i=0; dis!=null && i<dis.length; i++) 
  {
    dsSum = dis[i].getDatastore();
    if (dsSum.isAccessible() && dsName.equals(dsSum.getName())) 
    {
      break;
    }
  }
  return dsSum;
}
 
开发者ID:Juniper,项目名称:vijava,代码行数:26,代码来源:VmCdOp.java

示例3: getDefaultDevices

import com.vmware.vim25.VirtualMachineRuntimeInfo; //导入方法依赖的package包/类
static VirtualDevice[] getDefaultDevices(VirtualMachine vm) 
throws Exception 
{
  VirtualMachineRuntimeInfo vmRuntimeInfo = vm.getRuntime();
  EnvironmentBrowser envBrowser = vm.getEnvironmentBrowser(); 
  ManagedObjectReference hmor = vmRuntimeInfo.getHost();
  VirtualMachineConfigOption cfgOpt = envBrowser.queryConfigOption(null, new HostSystem(vm.getServerConnection(), hmor));
  VirtualDevice[] defaultDevs = null;
  if (cfgOpt != null) 
  {
    defaultDevs = cfgOpt.getDefaultDevice();
    if (defaultDevs == null) 
    {
      throw new Exception("No Datastore found in ComputeResource");
    }
  }
  else
  {
    throw new Exception("No VirtualHardwareInfo found in ComputeResource");
  }
  return defaultDevs;
}
 
开发者ID:Juniper,项目名称:vijava,代码行数:23,代码来源:VmCdOp.java

示例4: getNetworkFromHost

import com.vmware.vim25.VirtualMachineRuntimeInfo; //导入方法依赖的package包/类
private static ManagedObjectReference getNetworkFromHost(VMwareClient vmw,
        ManagedObjectReference vmwInstance, String networkName)
        throws Exception {
    logger.debug("networkName: " + networkName);

    VirtualMachineRuntimeInfo vmRuntimeInfo = (VirtualMachineRuntimeInfo) vmw
            .getServiceUtil().getDynamicProperty(vmwInstance, "runtime");
    ManagedObjectReference hostRef = vmRuntimeInfo.getHost();
    List<ManagedObjectReference> networkRefList = (List<ManagedObjectReference>) vmw
            .getServiceUtil().getDynamicProperty(hostRef, "network");
    ManagedObjectReference netCard = null;
    StringBuffer networks = new StringBuffer();
    for (ManagedObjectReference networkRef : networkRefList) {
        String netCardName = (String) vmw.getServiceUtil()
                .getDynamicProperty(networkRef, "name");
        networks.append(netCardName + " ");
        if (netCardName.equalsIgnoreCase(networkName)) {
            netCard = networkRef;
            break;
        }
    }

    if (netCard == null) {
        String hostName = (String) vmw.getServiceUtil()
                .getDynamicProperty(hostRef, "name");
        logger.error("Network " + networkName + " not found on host "
                + hostName);
        logger.debug("available networks are: " + networks.toString());
        throw new Exception("Network card " + networkName
                + " not found on host " + hostName);
    }

    return netCard;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:35,代码来源:NetworkManager.java

示例5: getRunningHost

import com.vmware.vim25.VirtualMachineRuntimeInfo; //导入方法依赖的package包/类
public HostMO getRunningHost() throws Exception {
    VirtualMachineRuntimeInfo runtimeInfo = getRuntimeInfo();
    return new HostMO(_context, runtimeInfo.getHost());
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:5,代码来源:VirtualMachineMO.java


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