Open meepsie206 opened 1 year ago
Thank you @meepsie206
Same here. In my case the datastore is not in a cluster but it does have a few subfolders. We have another cluster without any subfolders in the path (of the form: /dc/datastore/VxRail-Virtual-SAN-Datastore) and there the lookup does return the MOID.
Task:
- debug:
msg: "{{ lookup('vmware.vmware_rest.datastore_moid', '/dc/datastore/cluster/VxRail/VxRail-Virtual-SAN-Datastore-5c92ddfe-1463-4070-98f6-e6569494502f/', vcenter_hostname=vcenter_hostname) }}"
Returning empty string:
ok: [localhost] => msg: ''
My query path consists of:
Managed Object Type: ManagedObjectReference:Datacenter Managed Object ID: datacenter-21
Managed Object Type: ManagedObjectReference:Folder Managed Object ID: group-s24
Managed Object Type: ManagedObjectReference:Folder Managed Object ID: group-s194
Managed Object Type: ManagedObjectReference:Folder Managed Object ID: group-s53987
Managed Object Type: ManagedObjectReference:Datastore Managed Object ID: datastore-40375
Versions: vmware.vmware_rest 2.2.0 vSphere Client version 7.0.3.00700
I am having the same issue when trying to find the mold of a datastore that is part of a datastore cluster. I have used the managed object reference to confirm that the path I'm providing is correct and it works for datastores that are not part of a cluster giving me results the same as meepsie206.
Any update on this issue?
Hi, we recently over-hauled the lookup plugins, and I believe this issue should be fixed. Would someone with datastore clusters be able to confirm?
The fix is currently available on main and should be included in release 4.1.0
SUMMARY
The datastore_moid lookup only ever returns an empty string when all datastores are in datastore clusters.
ISSUE TYPE
COMPONENT NAME
vmware.vmware_rest.datastore_moid
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
vCenter: VMware vCenter Server 7.0.3 build-19717403 OS: Red Hat Enterprise Linux release 8.5 (Ootpa)
This is a container running in docker on a Redhat 7 host. Python 3.9 is installed with microdnf and all packages are install with python3 -m pip install. No venv or virtualenv is in use.
aiohttp 3.8.3
As the network_moid and cluster_moid work as expected, I am 100% confident that it is not an OS / environment issue.
STEPS TO REPRODUCE
Run a simple ansible.builtin.debug as demonstrated below, using the datastore_moid lookup. I have included a network_moid lookup test to show that other lookups work as expected.
EXPECTED RESULTS
Expected result is the datastore_moid returns the moref of the datastore.
ACTUAL RESULTS
As can be seen from the output below, the network_moid (path: /datacenter/network/network_name) has returned a moref as expected but either format of the datastore_moid lookup is returning an empty string. I would expect the need for the path to include the datastore cluster therefore the output of datastore without ds cluster is probably correct. I include it just to show I have tried many logical combinations but all return an empty string. I can see from the log (if necessary, I can post but will have to sanitise) the recursion finds the datastore folder but then doesn't recurse any further because the only child entities in the folder are storagepod objects (datastore clusters).
Using the vCenter MOB, this is the path taken to get to the relevant datastore from the home page:
Object types for each moref: group-d1 : ManagedObjectReference:Folder datacenter-1001 : ManagedObjectReference:Datacenter group-s1004 : ManagedObjectReference:Folder group-p1012 : ManagedObjectReference:StoragePod datastore-2009 : ManagedObjectReference:Datastore
Sorry I can not post actual names for either the path or the mob output but trust I have double checked (copied/pasted from the mob) that the names in the playbook are the names in the mob.
As this is my first time raising an issue, as well as feedback on the actual issue I am more than happy to take feedback on the content I have included. I hope I have demonstrated a level of understanding that you can trust but if this is too much detail then please let me know.