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


Java EnvironmentBrowser类代码示例

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


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

示例1: getDVPortgroupInfo

import com.vmware.vim25.mo.EnvironmentBrowser; //导入依赖的package包/类
public DistributedVirtualPortgroupInfo getDVPortgroupInfo(VirtualMachine machine, String networkName) {
    HostSystem host = new HostSystem(machine.getServerConnection(), machine.getRuntime().getHost());
    ComputeResource computeResource = (ComputeResource) host.getParent();
    EnvironmentBrowser envBrowser = computeResource.getEnvironmentBrowser();

    DistributedVirtualPortgroupInfo dvPortgroupInfo = null;
    try {
        ConfigTarget configTarget = envBrowser.queryConfigTarget(host);

        // 分散ポートグループの場合
        if (configTarget.getDistributedVirtualPortgroup() != null) {
            // 分散ポートグループ情報を取得
            dvPortgroupInfo = findDVPortgroupInfo(configTarget.getDistributedVirtualPortgroup(), networkName);
        }
    } catch (RemoteException e) {
        throw new RuntimeException(e);
    }

    return dvPortgroupInfo;
}
 
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:21,代码来源:VmwareNetworkProcess.java

示例2: getValidCdromOnHost

import com.vmware.vim25.mo.EnvironmentBrowser; //导入依赖的package包/类
private List<String> getValidCdromOnHost() throws InvalidProperty, RuntimeFault, RemoteException 
{
  List<String> result = new ArrayList<String>();

  EnvironmentBrowser envBrower = vm.getEnvironmentBrowser();

  ConfigTarget configTarget;

  try 
  {
    configTarget = envBrower.queryConfigTarget(null);
  } 
  catch (Exception ex) 
  {
    throw new RuntimeException("Error in getting Cdrom devices from host.");
  }

  if(configTarget != null && configTarget.cdRom != null) 
  {
    for(VirtualMachineCdromInfo cdromInfo : configTarget.cdRom) 
    {
             result.add(cdromInfo.name);
    }
  }
  return result;
}
 
开发者ID:Juniper,项目名称:vijava,代码行数:27,代码来源:VirtualMachineDeviceManager.java

示例3: doesNetworkNameExist

import com.vmware.vim25.mo.EnvironmentBrowser; //导入依赖的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

示例4: findDatastoreSummary

import com.vmware.vim25.mo.EnvironmentBrowser; //导入依赖的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

示例5: getDefaultDevices

import com.vmware.vim25.mo.EnvironmentBrowser; //导入依赖的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

示例6: createNetworkAdapter

import com.vmware.vim25.mo.EnvironmentBrowser; //导入依赖的package包/类
/** Create a new virtual network adapter on the VM
* Your MAC address should start with 00:50:56
  */
 public void createNetworkAdapter(VirtualNetworkAdapterType type, String networkName, String macAddress, boolean wakeOnLan, boolean startConnected) throws InvalidProperty, RuntimeFault, RemoteException, InterruptedException
 {
   VirtualMachinePowerState powerState = vm.getRuntime().getPowerState();
   String vmVerStr = vm.getConfig().getVersion();
   int vmVer = Integer.parseInt(vmVerStr.substring(vmVerStr.length()-2));
   
   if((powerState == VirtualMachinePowerState.suspended) ||
     (powerState == VirtualMachinePowerState.suspended && vmVer < 7))
   {
     throw new InvalidPowerState();
   }
   
   HostSystem host = new HostSystem(vm.getServerConnection(), vm.getRuntime().getHost());
   ComputeResource cr = (ComputeResource) host.getParent();
   EnvironmentBrowser envBrowser = cr.getEnvironmentBrowser();
   ConfigTarget configTarget = envBrowser.queryConfigTarget(host);
   VirtualMachineConfigOption vmCfgOpt = envBrowser.queryConfigOption(null, host);

   type = validateNicType(vmCfgOpt.getGuestOSDescriptor(), vm.getConfig().getGuestId(), type);

   VirtualDeviceConfigSpec nicSpec = createNicSpec(type, networkName, macAddress, wakeOnLan, startConnected, configTarget);
   
   VirtualMachineConfigSpec vmConfigSpec = new VirtualMachineConfigSpec();
   vmConfigSpec.setDeviceChange(new VirtualDeviceConfigSpec []{nicSpec});
   Task task = vm.reconfigVM_Task(vmConfigSpec);

   task.waitForTask(200, 100);
 }
 
开发者ID:Juniper,项目名称:vijava,代码行数:32,代码来源:VirtualMachineDeviceManager.java


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