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

"missing" description on show interfaces #191

Open
tgraham2 opened this issue Nov 20, 2022 · 1 comment
Open

"missing" description on show interfaces #191

tgraham2 opened this issue Nov 20, 2022 · 1 comment
Assignees

Comments

@tgraham2
Copy link

When a "description" does not exist, pyATS does not return the key. In my use case I want to display the statistics of only the interfaces with a certain keyword in the interface description. The loop fails in the case there is no description.

- name: get interface status
  ansible.utils.cli_parse:
    command: show interfaces
    parser:
      name: ansible.netcommon.pyats
  register: intf_output

- name: Display Interface status
  debug:
    msg: 
      - "Interface {{item.key}}    Description: {{ item.description }}"
      - "Rate In: {{item.value.counters.rate.in_rate}} Out: {{item.value.counters.rate.out_rate}}"
      - "Counters: Cleared - {{item.value.counters.last_clear}}"
      - "          Errors: Input - {{item.value.counters.in_errors}}  Output - {{item.value.counters.out_errors}}"
  loop: "{{ query('dict', intf_output['parsed']|default({})) }}"
  when: item.description == "XXX"

"The conditional check 'item.description == "XXX"' failed. The error was: error while evaluating conditional (item.description == "XXX"): 'dict object' has no attribute 'description'

Could we consider making the change that the description is always returned - with a null string in the case of no description being configured (instead of no key-value pair at all).

@ketulsuthar
Copy link

Can you provide the logs as well as steps for reproducing it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants