Don Dupuis <donds...@gmail.com> writes:

> I am looking for an example on how to use the new VmMediatedDevices service
> to add an Nvidia vGPU in ovirt to guest vms. I had it working just fine in
> oVirt 4.4 when using the custom_properties method. Just need to understand
> the new method/way of doing it correctly using the python3-ovirt-engine-sdk.

You can retrieve the vGPU properties like:

  service = 
connection.system_service().vms_service().vm_service('123').mediated_devices_service()
  vgpu_devices = service.list()
  first_vgpu = vgpu_devices[0]
  # id of the device
  first_vgpu.id
  # properties of the device
  [(p.name, p.value) for p in first_vgpu]

Example of adding and removing a vGPU device:

  service = 
connection.system_service().vms_service().vm_service('123').mediated_devices_service()
  spec_params = [ovirtsdk4.types.Property(name=name, value=value)
                 for name, value in (('mdevType', 'nvidia-22'),
                                     ('nodisplay', 'true'),
                                     ('driverParams', 'enable_uvm=1'))]
  service.add(ovirtsdk4.types.VmMediatedDevice(spec_params=spec_params))
  service.device_service('456').remove()

HTH,
Milan
_______________________________________________
Users mailing list -- users@ovirt.org
To unsubscribe send an email to users-le...@ovirt.org
Privacy Statement: https://www.ovirt.org/privacy-policy.html
oVirt Code of Conduct: 
https://www.ovirt.org/community/about/community-guidelines/
List Archives: 
https://lists.ovirt.org/archives/list/users@ovirt.org/message/SDP5P5XF2W22ZE6DOGP7EXTLDLDSEX7B/

Reply via email to