# Buggy code
def __attach_disks(self, entity):
    disks_service = self._connection.system_service().disks_service()

    for disk in self.param("disks"):
        # If disk ID is not specified, find disk by name:
        disk_id = disk.get("id")
        if disk_id is None:
            disk_id = getattr(
                search_by_name(service=disks_service, name=disk.get("name")), "id", None
            )

        # Attach disk to VM:
        disk_attachments_service = self._service.service(
            entity.id
        ).disk_attachments_service()
        if get_entity(disk_attachments_service.attachment_service(disk_id)) is None:
            if not self._module.check_mode:
                disk_attachments_service.add(
                    otypes.DiskAttachment(
                        disk=otypes.Disk(
                            id=disk_id,
                        ),
                        active=disk.get("activate", True),
                        interface=otypes.DiskInterface(disk.get("interface", "virtio")),
                        bootable=disk.get("bootable", False),
                    )
                )
            self.changed = True


# Traceback (_raise_error)
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_e1Uae7/ansible_module_ovirt_vms.py", line 1155, in main
clone_permissions=module.params['clone_permissions'],
File "/tmp/ansible_e1Uae7/ansible_modlib.zip/ansible/module_utils/ovirt.py", line 576, in create
self.post_create(entity)
File "/tmp/ansible_e1Uae7/ansible_module_ovirt_vms.py", line 704, in post_create
self.changed = self.__attach_disks(entity)
File "/tmp/ansible_e1Uae7/ansible_module_ovirt_vms.py", line 864, in __attach_disks
bootable=disk.get('bootable', False),
File "/usr/lib64/python2.7/site-packages/ovirtsdk4/services.py", line 5180, in add
return self._internal_add(attachment, headers, query, wait)
File "/usr/lib64/python2.7/site-packages/ovirtsdk4/service.py", line 223, in _internal_add
return future.wait() if wait else future
File "/usr/lib64/python2.7/site-packages/ovirtsdk4/service.py", line 53, in wait
return self._code(response)
File "/usr/lib64/python2.7/site-packages/ovirtsdk4/service.py", line 220, in callback
self._check_fault(response)
File "/usr/lib64/python2.7/site-packages/ovirtsdk4/service.py", line 123, in _check_fault
self._raise_error(response, body)
File "/usr/lib64/python2.7/site-packages/ovirtsdk4/service.py", line 109, in _raise_error
raise error
Error: Fault reason is "Operation Failed". Fault detail is "[Cannot attach Virtual Disk because the VM is in Image Locked status.]". HTTP response code is 409.

# Fixed code
def __attach_disks(self, entity):
    if not self.param("disks"):
        return

    vm_service = self._service.service(entity.id)
    disks_service = self._connection.system_service().disks_service()
    disk_attachments_service = vm_service.disk_attachments_service()

    self._wait_for_vm_disks(vm_service)
    for disk in self.param("disks"):
        # If disk ID is not specified, find disk by name:
        disk_id = disk.get("id")
        if disk_id is None:
            disk_id = getattr(
                search_by_name(service=disks_service, name=disk.get("name")), "id", None
            )

        # Attach disk to VM:
        disk_attachment = disk_attachments_service.attachment_service(disk_id)
        if get_entity(disk_attachment) is None:
            if not self._module.check_mode:
                disk_attachments_service.add(
                    otypes.DiskAttachment(
                        disk=otypes.Disk(
                            id=disk_id,
                        ),
                        active=disk.get("activate", True),
                        interface=otypes.DiskInterface(disk.get("interface", "virtio")),
                        bootable=disk.get("bootable", False),
                    )
                )
            self.changed = True