nutanix / nutanix.ansible

Official Nutanix Ansible collections
GNU General Public License v3.0
64 stars 36 forks source link

[Bug] ntnx_clusters_info and ntnx_hosts_info filters does not filter #472

Closed mdhowle closed 2 weeks ago

mdhowle commented 6 months ago

Describe the bug When using ntnx_clusters_info and applying a filter of name: CLUSTERNAME, all clusters are returned when only CLUSTERNAME should be returned

Similarly, when using ntnx_hosts_info and applying a filter of cluster_name: CLUSTERNAME, all hosts are returned when only hosts in the CLUSTERNAME cluster should be returned.

However, ntnx_vms_info with a filter cluster_name: CLUSTERNAME, returns only those VMs hosted within the CLUSTERNAME cluster.

To Reproduce Steps to reproduce the behavior: ansible-playbook -i localhost, -c local playbook.yml

---
- name: Test playbook
  hosts: all
  tasks:
    - name: Get cluster info
      nutanix.ncp.ntnx_clusters_info:
        nutanix_host: "{{ prism_host }}"
        nutanix_username: "{{ prism_username }}"
        nutanix_password: "{{ prism_password }}"
        filter:
          name: "{{ cluster_name }}"
      register: cluster_info

    - name: Assert cluster info is only one result
       assert:
          that: cluster_info.response.entitites | length == 1

    - name: Get hosts info
      nutanix.ncp.ntnx_clusters_info:
        nutanix_host: "{{ prism_host }}"
        nutanix_username: "{{ prism_username }}"
        nutanix_password: "{{ prism_password }}"
        filter:
          cluster_name: "{{ cluster_name }}"
      register: hosts_info

    - name: Assert hosts info has five or fewer hosts
       assert:
          that: hosts_info.response.entitites | length <= 5  

Expected behavior For ntnx_clusters_info, it should only return the one cluster that matched the cluster name given in the filter.

For ntnx_hosts_info, it should return a list of hosts that matched the cluster name given in the filter.

Additional context This may be similar to #374 with a different module and using custom_filter.

This occurs in both nutanix.ncp versions 1.9.0 and 1.9.1

stahnjones commented 4 months ago

This is a v3 API bug as the same results happen with direct v3 REST API calls

bhati-pradeep commented 2 weeks ago

This is an existing bug in v3 which needs to be fixed from Prism Central v3 API team. Closing this for now since its not the ansible provider bug.

mdhowle commented 2 weeks ago

Is this bug being tracked upstream? Do I need to open a ticket with Nutanix?

bhati-pradeep commented 2 weeks ago

Yes there is bug logged with engineering team for this two v3 apis. I expect the fix to come with v4 API.

mdhowle commented 2 weeks ago

Thanks for the update!