0

使用 Python 2.7.6

我正在寻找从 OVF 部署 VM,然后在其上配置 SRIOV 网络设备的能力(类似于使用 vsphere web ui -> 添加网络适配器 -> 将网络适配器类型更改为 SRIOV)这需要我做两件事找不到怎么办:

1)查询ESXi主机本身,了解哪些网卡支持SRIOV以及它们暴露了多少虚拟功能(可能查询vcenter)

2) 使用这种类型的 SRIOV 网络适配器配置 vm 本身(从 OVF 部署之后)

我查看了 git 示例和 vsphere sdk 文档,但找不到如何执行此操作,而且关于 pyVmomi 的文档似乎很少

谢谢

4

1 回答 1

2

好的,回答我自己的问题(为后代)

devices = []
network_name = "Data"
vnic_label = "pyvmomi sriov nic1"

content = si.content
vm = get_obj(content, [vim.VirtualMachine], vm_name)
nic = vim.vm.device.VirtualDeviceSpec()

# VM device
nic.operation = vim.vm.device.VirtualDeviceSpec.Operation.add
nic.device = vim.vm.device.VirtualSriovEthernetCard()
nic.device.addressType = 'assigned'
nic.device.key = 13016
nic.device.deviceInfo = vim.Description()
nic.device.deviceInfo.label = vnic_label
nic.device.deviceInfo.summary = network_name
nic.device.backing = vim.vm.device.VirtualEthernetCard.NetworkBackingInfo()
nic.device.backing.network = get_obj(content, [vim.Network], network_name)
nic.device.backing.deviceName = network_name
nic.device.backing.useAutoDetect = False
nic.device.connectable = vim.vm.device.VirtualDevice.ConnectInfo()
nic.device.connectable.startConnected = True
nic.device.connectable.allowGuestControl = True

nic.device.sriovBacking = vim.vm.device.VirtualSriovEthernetCard.SriovBackingInfo()
nic.device.sriovBacking.physicalFunctionBacking = vim.vm.device.VirtualPCIPassthrough.DeviceBackingInfo()
nic.device.sriovBacking.physicalFunctionBacking.id = '84:00.1'
nic.device.sriovBacking.virtualFunctionBacking = vim.vm.device.VirtualPCIPassthrough.DeviceBackingInfo()
nic.device.sriovBacking.virtualFunctionBacking.id = '84:11.1'

devices.append(nic)

vmconf = vim.vm.ConfigSpec(deviceChange=devices)
task = vm.ReconfigVM_Task(vmconf)
于 2015-05-17T15:19:55.927 回答