Milan
This is exactly what I needed and it worked the first time. I appreciate your quick response to my question. Have a great day.

Thanks
Don

On Thu, Jun 9, 2022 at 5:09 AM Milan Zamazal <mzamazal@redhat.com> wrote:
Don Dupuis <dondster@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