oVirt / ovirt-ansible-collection

Ansible collection with official oVirt modules and roles
72 stars 91 forks source link

Cannot attach/detach DirectLUN disk from/to VM with ansible module "ovirt_disk" #671

Open Woocki opened 1 year ago

Woocki commented 1 year ago

Problem with detaching and attaching LUN disks from/to VM with ansible modules "ovirt_disk" (via GUI all works as expected). The module at some point tries to check a storage_profile of the disk, but because the disk is an LUN type, it does not have such propertise (details about vdisk you will find below). We've tested collections ovirt.ovirt in ver.3.0.0 and 2.3.1.

Module fails with message: The full traceback is: Traceback (most recent call last): File "/tmp/ansible_ovirt_disk_payload_dhv02mk9/ansible_ovirt_disk_payload.zip/ansible_collections/ovirt/ovirt/plugins/modules/ovirt_disk.py", line 901, in main File "/tmp/ansible_ovirt_disk_payload_dhv02mk9/ansible_ovirt_disk_payload.zip/ansible_collections/ovirt/ovirt/plugins/module_utils/ovirt.py", line 644, in create if not self.update_check(entity): File "/tmp/ansible_ovirt_disk_payload_dhv02mk9/ansible_ovirt_disk_payload.zip/ansible_collections/ovirt/ovirt/plugins/modules/ovirt_disk.py", line 738, in update_check AttributeError: 'NoneType' object has no attribute 'name' We tried to add other keys like logical_unit(id) or profile, but without success. The only way which we ware able to run it correctly was commenting out line: # equal(self.param('profile'), follow_link(self._connection, entity.disk_profile).name) from _updatecheck() method from module _ovirtdisk.py.

Ansible/python version: ansible-playbook --version ansible-playbook [core 2.12.2] config file = /etc/ansible/ansible.cfg configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python3.8/site-packages/ansible ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections executable location = /usr/bin/ansible-playbook python version = 3.8.12 (default, Apr 5 2022, 08:07:47) [GCC 8.5.0 20210514 (Red Hat 8.5.0-10.0.1)] jinja version = 2.10.3 libyaml = True

Disk details: "ovirt_disks": [ { "alias": "os-edfstore01.gr7_data-edfstore_backup-template-DO-NOT-DELETE.img.qcow2", "content_type": "data", "description": "0000", "disk_snapshots": [], "href": "/ovirt-engine/api/disks/c1e98497-5049-4e0f-98a3-b1ff2175abc9", "id": "c1e98497-5049-4e0f-98a3-b1ff2175abc9", "lun_storage": { "id": "3600c0ff00050c878b225c96301000000", "logical_units": [ { "discard_max_size": 1073741824, "discard_zeroes_data": false, "disk_id": "c1e98497-5049-4e0f-98a3-b1ff2175abc9", "id": "3600c0ff00050c878b225c96301000000", "lun_mapping": 13, "paths": 0, "product_id": "MSA 2050 SAN", "serial": "SHPE_MSA_2050_SAN_00c0ff50c8780000b225c96301000000", "size": 0, "vendor_id": "HPE" } ] }, "name": "os-edfstore01.gr7_data-edfstore_backup-template-DO-NOT-DELETE.img.qcow2", "permissions": [], "propagate_errors": false, "shareable": false, "statistics": [], "storage_type": "lun", "wipe_after_delete": false } ]

We execute the module with following keys: `

freshpr commented 1 year ago

We have the same issue. We need to use a direct API call in the ansible scripts as attaching the direct LUNs do not work.

I will post our workaround here (just in case someone want to do something similar).