Change datastore check to check if the destination_datastore is the "primary" datastore in vmware_vmotion.py#2537
Open
ITJoeSchmo wants to merge 1 commit into
Open
Conversation
This change enables vMotion storage migration between datastores in the same host and that appear related to the VM. Before this, vMotion Storage migration between 2 datastores related to the VM would be seen as no changes needed and exit.
|
Build succeeded. ✔️ ansible-tox-linters SUCCESS in 5m 32s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change enables vMotion storage migration between datastores in the same host even when the destination datastore is technically used by the VM for ISO/media storage, but the VM doesn't actually "live" on that datastore. Before this, trying to do Storage vMotion via the module always returned no changes needed.
SUMMARY
The original logic evaluated idempotency by checking whether the destination datastore was present in vm.datastore. This list includes all datastores referenced by the VM, such as:
Because of this, the module could incorrectly conclude that no change was required even when the VM’s home datastore differed from the requested destination.
This change updates the comparison logic to use the VM’s actual home datastore derived from:
This accurately reflects where the VM “lives” and aligns the module’s behavior with vSphere UI and API semantics. This change does not modify migration behavior itself; we are just tweaking the logic used to determine whether a change is required.
ISSUE TYPE
COMPONENT NAME
vmware_vmotion
ADDITIONAL INFORMATION
`
community.vmware.vmware_vmotion:
hostname: "{{ hostvars[inventory_hostname].vsphere_hostname }}"
username: "{{ hostvars[inventory_hostname].vsphere_username }}"
validate_certs: "{{ hostvars[inventory_hostname].vsphere_validate_certs }}"
password: "{{ hostvars[inventory_hostname].vsphere_password }}"
use_instance_uuid: true
vm_uuid: "{{ vsphere_instance_uuid }}"
destination_datastore: "{{ new_vm_datastore }}"
destination_datacenter: "{{ hostvars[inventory_hostname].vsphere_datacenter }}"
delegate_to: localhost
register: vmotion_info
environment: # needed for validate_certs = false to apply per notes https://docs.ansible.com/projects/ansible/latest/collections/vmware/vmware/vms_inventory.html#ansible-collections-vmware-vmware-vms-inventory
REQUESTS_CA_BUNDLE: ""
`
Before
After