【问题标题】:How can I get list of adapter types in VMWare by vSphere client API如何通过 vSphere 客户端 API 获取 VMWare 中的适配器类型列表
【发布时间】:2017-10-14 10:09:04
【问题描述】:

我想通过配置的适配器类型在 ESXi 6.0 上创建一个虚拟机。 基本上,这 3 个(E1000、Vmxnet2、VMXNET3)在创建虚拟机时列出,但我在 java 中找不到任何 API。 我正在导入以下包:

import com.vmware.vim25.VirtualEthernetCard;
import com.vmware.vim25.VirtualEthernetCardNetworkBackingInfo;
import com.vmware.vim25.VirtualHardware;
import com.vmware.vim25.VirtualMachineConfigInfo;
import com.vmware.vim25.VirtualMachineConfigSpec;
import com.vmware.vim25.VirtualMachineNetworkInfo; 



 ArrayList<HostSystem> hosts = OperationHelper.GetAllHostReferene();
 ArrayList<String> networkNames = new ArrayList<String>();
 Network[] nws = null;
    for(HostSystem host : hosts) {
        Datastore[] dts = host.getDatastores();
        for(Datastore d : dts){
            if(d.getName().equals(m_datastore)) {
                log.info("Found host for datastore");
                nws = host.getNetworks();
              for(Network n : nws){
                 networkNames.add(n.getName());                 
              }
           }
       }
   }

我通过上面的代码得到网络接口卡列表。但我无法获得适配器类型。 请帮忙。

【问题讨论】:

    标签: java vsphere esxi


    【解决方案1】:

    每个 VM 网络适配器都继承自 VirtualEthernetCard。例如:

    VirtualEthernetCard VirtualVmxnet VirtualVmxnet3 VirtualVmxnet3Vrdma

    您应该在调用 ReconfigureVM() 时将这些类的实例传递给 VM 设备列表。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-09
      • 1970-01-01
      • 2021-11-28
      • 2019-05-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多