0

Using Python 2.7.6

I am looking for the capability to deploy a VM from an OVF and then configure an SRIOV network device on it (similar to using the vsphere web ui -> Add network adapter -> change network adapter type to SRIOV) This requires two things that I could not find how to do:

1) Query an ESXi host itself and understand which NICs are supporting SRIOV and how many virtual functions do they expose (possibly query the vcenter)

2) configure the vm itself with the SRIOV network adapter of this type (after it was deployed from the OVF)

I looked at the git samples and vsphere sdk documentation and could not find how to do this, and there seems to be very little documentation at all about the pyVmomi

Thanks

Shimonbd
  • 84
  • 1
  • 8
  • I feel like there may be some bug in how this works.. The reason I think that is there is a data object called HostSriovInfo, but its not the property of anything, so I have no idea how you would access that data object. I have opened an issue on github so maybe someone can clear it up there. Please feel free to chime in there if you find out this answer. Once someone answers me there I will bring that info back here and share with the group. https://github.com/vmware/pyvmomi/issues/164 – Michael Rice Sep 14 '14 at 02:01

1 Answers1

2

ok, to answer my own question (for future generations)

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)
Shimonbd
  • 84
  • 1
  • 8
  • Doesn't seem to work - I'm getting "Reconfigure virtual machine Card1 Invalid configuration for device '0'." Am I missing something? – user852689 Jan 24 '18 at 09:29