2014-08-27 127 views
0

配置SR-IOV使用Python 2.7.6使用pyVmomi对VM

我找的能力,从OVF部署虚拟机,然后在其上配置了SR-IOV的网络设备(类似于使用的vSphere Web UI - >添加网络适配器 - >更改网络适配器类型SR-IOV) 这需要两件事情,我找不到怎么办:

1)查询ESXi主机本身并了解哪些网卡都支持SR-IOV多少虚函数他们是否暴露(可能查询vcenter)

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

我查看了git示例和vsphere sdk文档,并且找不到如何执行此操作,并且似乎几乎没有关于pyVmomi的文档

感谢

+0

我觉得有可能是如何工作的一些bug ..究其原因,我认为这是有一个数据对象称为HostSriovInfo,但它不是任何属性的东西,所以我不知道你将如何访问该数据对象。我在github上打开了一个问题,所以也许有人可以在那里清除它。如果你发现这个答案,请随时在那里提示。一旦有人回答我,我会将这些信息带回这里并与小组分享。 https://github.com/vmware/pyvmomi/issues/164 – 2014-09-14 02:01:50

回答

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) 
+0

似乎无法正常工作 - 我收到了“重新配置虚拟机卡1设备无效的配置'0'。”我错过了什么吗? – user852689 2018-01-24 09:29:44