Fix disk creation resulting in 'invalid configuration for device' error
SUMMARY
Under some circumstances, disk creation fails with an invalid configuration for device error.
Once this error shows up for a VM, it persistently happens whenever trying to add disks, however, I do not know how to make it show up for a VM, sometimes it is just there.
In comparing the API calls done by VCenter (which works) and ansible (which fails with the error above), I noticed that VCenter sets fileOperation to create. Setting this in ansible, as done in this patch, fixes the disk creation in ansible.
The docs describe the fileOperation parameter like this:
Type of operation being performed on the backing of the specified virtual device. If no file operation is specified in the VirtualDeviceSpec, then any backing filenames in the VirtualDevice must refer to files that already exist. The "replace" and "delete" values for this property are only applicable to virtual disk backing files.
So it really must be set when the backing file does not exist, (which it ofc doesn't when creating a disk).
ISSUE TYPE
- Bugfix Pull Request
COMPONENT NAME
vm_device_helper
@mariolenz
The CI stage is failing with this error:
ERROR: Found 5 pylint issue(s) which need to be resolved:
ERROR: plugins/module_utils/vmware.py:1091:13: unidiomatic-typecheck: Use isinstance() rather than type() for a typecheck.
ERROR: plugins/module_utils/vmware.py:1093:13: unidiomatic-typecheck: Use isinstance() rather than type() for a typecheck.
ERROR: plugins/module_utils/vmware.py:1095:13: unidiomatic-typecheck: Use isinstance() rather than type() for a typecheck.
ERROR: scripts/inventory/vmware_inventory.py:286:11: unidiomatic-typecheck: Use isinstance() rather than type() for a typecheck.
ERROR: tests/unit/mock/loader.py:33:15: unidiomatic-typecheck: Use isinstance() rather than type() for a typecheck.
However, none of these LOC are touched by my PR.
Build succeeded. https://ansible.softwarefactory-project.io/zuul/buildset/65cf6f4e6221418bb9970330b68c3d89
:heavy_check_mark: ansible-tox-linters SUCCESS in 11m 09s :heavy_check_mark: build-ansible-collection SUCCESS in 11m 27s :heavy_check_mark: ansible-test-cloud-integration-vcenter7_only-stable216 SUCCESS in 21m 39s :heavy_check_mark: ansible-test-cloud-integration-vcenter7_2esxi-stable216 SUCCESS in 19m 10s :heavy_check_mark: ansible-test-cloud-integration-vcenter7_1esxi-stable216_1_of_2 SUCCESS in 48m 41s :heavy_check_mark: ansible-test-cloud-integration-vcenter7_1esxi-stable216_2_of_2 SUCCESS in 57m 52s :heavy_check_mark: ansible-galaxy-importer SUCCESS in 4m 05s
@mariolenz Please consider merging this :)
Build succeeded. https://ansible.softwarefactory-project.io/zuul/buildset/2539737bd4154a0cbcfdcc2eb0bd592a
:heavy_check_mark: ansible-tox-linters SUCCESS in 8m 32s :heavy_check_mark: build-ansible-collection SUCCESS in 8m 27s :heavy_check_mark: ansible-test-cloud-integration-vcenter7_only-stable217 SUCCESS in 17m 36s :heavy_check_mark: ansible-test-cloud-integration-vcenter7_2esxi-stable217 SUCCESS in 13m 30s :heavy_check_mark: ansible-test-cloud-integration-vcenter7_1esxi-stable217_1_of_2 SUCCESS in 51m 00s :heavy_check_mark: ansible-test-cloud-integration-vcenter7_1esxi-stable217_2_of_2 SUCCESS in 59m 02s :heavy_check_mark: ansible-galaxy-importer SUCCESS in 3m 38s