IOS: "show lldp neighbor detail" not parsing
See original GitHub issueUsing ansible and clay584.parse_genie module, parsing ‘show lldp neighbor detail’ and ‘show lldp entry *’.
Task returns “parse_genie: local variable ‘intf_dict’ referenced before assignment - Failed to parse command output.”
OS is IOS devices running versions 15.0 and 15.2
Relevant parts of ansible playbook
- name: "show lldp neighbor detail"
ios_command:
commands: "show lldp neighbors detail"
register: lldp_neighbors
- name: "parse LLDP neighbor"
debug:
msg: "{{ lldp_neighbors.stdout[0] | parse_genie(command='show lldp neighbors detail', os='ios')}}"
register: parsed_lldp_neighbor
Output from ansible playbook
TASK [parse LLDP neighbor] *****************************************************
fatal: [switch]: FAILED! => {"msg": "parse_genie: local variable 'intf_dict' referenced before assignment - Failed to parse command output."}
Ansible, python and genie versions
ansible 2.9.4
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/awx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /var/lib/awx/venv/genie/lib64/python3.6/site-packages/ansible
executable location = /var/lib/awx/venv/genie/bin/ansible
python version = 3.6.8 (default, Aug 7 2019, 17:28:10) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
Name: genie
Version: 20.1
Summary: Genie: THE standard pyATS Library System
Home-page: https://developer.cisco.com/pyats/
Author: Cisco Systems Inc.
Author-email: pyats-support-ext@cisco.com
License: Apache 2.0
Location: /var/lib/awx/venv/genie/lib/python3.6/site-packages
Requires: genie.libs.parser, genie.libs.sdk, tqdm, PrettyTable, netaddr, genie.libs.conf, genie.libs.filetransferutils, genie.libs.ops, jsonpickle, dill
switch show lldp neighbor detail sample output
------------------------------------------------
Chassis id: 10.10.191.15
Port id: ccf9.5493.ba88
Port Description: Avaya IP Deskphone
System Name - not advertised
System Description:
Avaya 1220 IP Deskphone, Firmware:06Q
Time remaining: 155 seconds
System Capabilities: B,T
Enabled Capabilities: B,T
Management Addresses - not advertised
Auto Negotiation - supported, enabled
Physical media capabilities:
100base-TX(FD)
100base-TX(HD)
10base-T(FD)
10base-T(HD)
Media Attachment Unit type: 16
Vlan ID: - not advertised
MED Information:
MED Codes:
(NP) Network Policy, (LI) Location Identification
(PS) Power Source Entity, (PD) Power Device
(IN) Inventory
F/W revision: 06Q
Manufacturer: Avaya-05
Model: 1220 IP Deskphone
Capabilities: NP, LI, PD, IN
Device type: Endpoint Class III
Network Policy(Voice): VLAN 110, tagged, Layer-2 priority: 5, DSCP: 46
Network Policy(Voice Signal): VLAN 110, tagged, Layer-2 priority: 0, DSCP: 0
PD device, Power source: Unknown, Power Priority: High, Wattage: 6.0
Location - not advertised
------------------------------------------------
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Parser "show lldp neighbors detail" for ios not working to ...
I want to get LLDP neighbor details especially LLDP neighbor system description of a Cisco Catalyst switch. The playbook works without error ...
Read more >Missing information in "show LLDP neighbors detail"
I am working on mapping layer 2 devices by parsing the output from "show LLDP neighbors detail". The network contains only Cisco devices....
Read more >Configuring LLDP
The neighbor database itself can be read by either LLDP or CDP methods or by using the show lldp commands. Take note of...
Read more >IP Fabric v3.x.x - IP Fabric Documentation Portal
Cisco NX-OS - fixed parsing of different output for command "show vrrp detail"; Cisco NX-OS - XDP links for LLDP protocol might have...
Read more >4.3.5+1 - IP Fabric Docs - Confluence
Arista Eos- Fix parsing of command "show lldp neighbors detail". ... Cisco - IOS/IOS-XE fixed parsing of "show ip mroute count" command.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey @xiaoxinz-cisco
Thank you for getting back to me so quickly. I have tested against the original output provided and the parser is working.
When testing against a different device, with a different neighbor type, the error is thrown. I will look through the code and hopefully make a pull request in the future.
Thank you again,
Nathan
Hi @nathantabailey ,
Based on the output you provided above, we updated the schema and parser class. This output and its parsed output can be found in this test.
Did you get this error from the above output?
Since we just release, we may not release another version with new fixes recently. To reduce your waiting time, I encourage you to jump into the code and fix it. I believe you can do this!
Here is an assumption about the error: `
` The reason is med_dict is not defined before line-5, or the first if-condition has not been called. There are a few reasons:
No F/W revision: …, S/W revision:… or H/W revision:… in your output. In this case, a possible solution: `
` 2. Those keys exist, but in lowercase, such as f/w revision. In this case, updating the regex med_pq will fix it.
Hope this example gives you some hints!
If there are any updates you want to share with us, you could create a pull request in this repo.
Thanks, Irene