Beside the doc you've referred to, the example codes for sdk [1] are always the recommendation. Well, you could also check the codes of oVirt module [2] for Ansible if the examples are incomplete.


[1]: https://github.com/oVirt/ovirt-engine-sdk/tree/master/sdk/examples 
[2]: https://github.com/ansible/ansible/tree/devel/lib/ansible/modules/cloud/ovirt

On Fri, Apr 26, 2019 at 5:10 PM Kaustav Majumder <kmajumde@redhat.com> wrote:
Thank you so much . It worked. i often get confused with the sdk. Is there  a doc explaining this?

On Fri, Apr 26, 2019 at 2:37 PM Joey Ma <majunjiev@gmail.com> wrote:
Hi Kaustav,

IHMO, the `attachment` variable is an instance of DiskAttachment, instead of the type of DiskAttachmentService as expected. You should probably replace 

```python 
    # Line 18-20
    if attachment:
        attachment.remove(detach_only=False)
        print("Disk removed")
 ```

with 

```python
    if attachment:
        attachment_service = disk_attachments_service.attachment_service(attachment.id)
        attachment_service.remove(detach_only=False)
        print("Disk removed")
```


On Fri, Apr 26, 2019 at 4:36 PM Kaustav Majumder <kmajumde@redhat.com> wrote:
Hi,
I am trying to detach and delete disk from my vm. I found this service in the docs
DiskAttachmentService
 http://ovirt.github.io/ovirt-engine-sdk/master/services.m.html#ovirtsdk4.services.DiskAttachmentService
I am not able to fetch this service. Below if the snippet of code I am trying. 
https://pastebin.com/UUu0Pfc8

Error-->   File "./pre_setup/delete_vm_disk.py", line 19, in remove_attached_vm_disk
    attachment.remove(detach_only=False)
AttributeError: 'DiskAttachment' object has no attribute 'remove'





--

Thanks,

Kaustav Majumder

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


--

Thanks,

Kaustav Majumder