Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] custom_filter ineffective in module nutanix.ncp.ntnx_foundation_central_imaged_nodes_info #374

Open
nx-sbourdeaud opened this issue May 4, 2023 · 4 comments
Assignees
Labels
1.9.3_triage Bug fixes & Improvements bug Something isn't working

Comments

@nx-sbourdeaud
Copy link

Describe the bug
Using custom_filter has not effect on the result/output (all imaged nodes are displayed)

To Reproduce
Steps to reproduce the behavior:

  1. ansible-playbook imaged_nodes_info.yml
  2. sample playbook used:
---
- name: Imaged Nodes Playbook
  hosts: localhost
  gather_facts: false
  collections:
    - nutanix.ncp

  tasks:
  - name: Imaged-Node details with custom filter
    ntnx_foundation_central_imaged_nodes_info:
      nutanix_host: "{{ pc_ip }}"
      nutanix_username: "{{ vault_pc_username }}"
      nutanix_password: "{{ vault_pc_password }}"
      validate_certs: false
      custom_filter:
        block_serial: "22SG6M450006"
    register: output

  - name: details of imaged node 
    debug:
      msg: '{{ output }}'

Expected behavior
Only nodes whose properties match the custom filter should be returned.

@bhati-pradeep
Copy link
Collaborator

@abhimutant Please check this, thanks.

@bhati-pradeep bhati-pradeep added the 1.9.1 Bug fixes & Improvements label Sep 25, 2023
@bhati-pradeep bhati-pradeep added 1.9.3_triage Bug fixes & Improvements and removed 1.9.1 Bug fixes & Improvements labels Nov 9, 2023
@bhati-pradeep
Copy link
Collaborator

bhati-pradeep commented Nov 9, 2023

Moving it to 1.9.2 due to unavailability of fix.
Reminder: @abhimutant please can you check this, thanks

@mdhowle
Copy link

mdhowle commented Mar 29, 2024

I'm seeing a similar issue with ntnx_clusters_info and ntnx_hosts_info with both filter and custom_filter. Is this related?

Setting a filter name: "{{ cluster_name }}" with the ntnx_clusters_info module retrieves all clusters. Similarly, with ntnx_hosts_info, setting a filter cluster_name: "{{ cluster_name }}" retrieves all hosts.

ntnx_vms_info, however, filters correctly with cluster_name: "{{ cluster_name }}".

For example, this returns all clusters

---
[...]
  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

The work around I have is

    - 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 }}"  # DOES NOT WORK
      register: all_clusters

   - name: Get cluster
      set_fact:
        cluster: "{{ (all_clusters.response.entities | selectattr('status.name', '==', cluster_name ) | first) }}"

    - name: Get hosts
      nutanix.ncp.ntnx_hosts_info:
        nutanix_host: "{{ prism_host }}"
        nutanix_username: "{{ prism_username }}"
        nutanix_password: "{{ prism_password }}"
        filter:
          cluster_name: "{{ cluster_name }}"  # DOES NOT WORK
      register: all_hosts

    - name: Get hosts info
      set_fact:
        hosts: "{{ all_hosts.response.entities | selectattr('status.cluster_reference.uuid', '==', cluster.metadata.uuid ) }}"

@bhati-pradeep
Copy link
Collaborator

bhati-pradeep commented Oct 9, 2024

@nx-sbourdeaud What is the collection version you used ? We checked and it works as expected. Can you check if all nodes are not under same block ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.9.3_triage Bug fixes & Improvements bug Something isn't working
Projects
Status: In progress
Development

No branches or pull requests

7 participants