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

Parser "show lldp neighbors detail" for ios not working to parse "System Description" #1

Closed
cuiminghao8 opened this issue Jun 27, 2019 · 4 comments

Comments

@cuiminghao8
Copy link

cuiminghao8 commented Jun 27, 2019

I want to get LLDP neighbor details especially LLDP neighbor system description of a Cisco Catalyst switch. The playbook works without error, but it seemed the LLDP neighbor "system_description" is missing in the parsed output.
This is the output from Cisco switch:

UCBJSO_ASW01#show lldp nei detail
------------------------------------------------
Local Intf: Gi1/0/48
Chassis id: ec1d.8b2e.3700
Port id: Gi2/0/48
Port Description: GigabitEthernet2/0/48
System Name: UCBJSO_CSW02

System Description: 
Cisco IOS Software, IOS-XE Software, Catalyst L3 Switch Software (CAT3K_CAA-UNIVERSALK9-M), Version 03.06.06E RELEASE SOFTWARE (fc1)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2016 by Cisco Systems, Inc.
Compiled Sat 17-Dec-16 

Time remaining: 107 seconds
System Capabilities: B,R
Enabled Capabilities: B,R
Management Addresses:
    IP: 10.33.32.1
Auto Negotiation - supported, enabled
Physical media capabilities:
    1000baseT(FD)
    100base-TX(FD)
    100base-TX(HD)
    10base-T(FD)
    10base-T(HD)
Media Attachment Unit type: 30
Vlan ID: 1


Total entries displayed: 1

This is the parsed output:

TASK [parse LLDP neighbor] ****************************************************************************************************************************************************************************
ok: [10.33.33.21] => {
    "msg": {
        "interfaces": {
            "GigabitEthernet1/0/48": {
                "if_name": "GigabitEthernet1/0/48",
                "port_id": {
                    "GigabitEthernet2/0/48": {
                        "neighbors": {
                            "UCBJSO_CSW02": {
                                "auto_negotiation": "supported, enabled",
                                "capabilities": {
                                    "mac_bridge": {
                                        "enabled": true,
                                        "name": "mac_bridge",
                                        "system": true
                                    },
                                    "router": {
                                        "enabled": true,
                                        "name": "router",
                                        "system": true
                                    }
                                },
                                "chassis_id": "ec1d.8b2e.3700",
                                "management_address": "10.33.32.1",
                                "neighbor_id": "UCBJSO_CSW02",
                                "physical_media_capabilities": [
                                    "1000baseT(FD)",
                                    "100base-TX(FD)",
                                    "100base-TX(HD)",
                                    "10base-T(FD)",
                                    "10base-T(HD)"
                                ],
                                "port_description": "GigabitEthernet2/0/48",
                                "port_id": "GigabitEthernet2/0/48",
                                "system_name": "UCBJSO_CSW02",
                                "time_remaining": 108,
                                "unit_type": 30,
                                "vlan_id": 1
                            }
                        }
                    }
                }
            }
        },

My ansible version:

ansible 2.8.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/minghao.cui/ansible-env/lib/python3.7/site-packages/ansible
  executable location = /home/minghao.cui/ansible-env/bin/ansible
  python version = 3.7.3 (default, May 10 2019, 11:10:10) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]

The playbook look like this:

---
- name: parse lldp,cdp,vlan information
  hosts: '{{ hosts }}'
  gather_facts: no
  connection: local

  tasks:
  - name: "show ip interface brief"
    ios_command:
      commands: "show ip interface brief"
    register: intf_brief
  - name: "show lldp neighbor detail"
    ios_command:
      commands: "show lldp neighbors detail"
    register: lldp_neighbor
  - name: "show VLAN"
    ios_command:
      commands: "show vlan"
    register: vlan_brief
  - name: "show CDP neighbor detail"
    ios_command:
      commands: "show cdp neighbors"
    register: cdp_neighbor
  - include_role:
      name: clay584.parse_genie
  - name: "parse interface brief"
    debug:
      msg: "{{ intf_brief.stdout[0] | parse_genie(command='show ip interface brief', os='ios')}}"
    register: parsed_intf_brief
  - name: "parse LLDP neighbor"
    debug:
      msg: "{{ lldp_neighbor.stdout[0] | parse_genie(command='show lldp neighbors detail', os='ios')}}"
    register: parsed_lldp_neighbor
  - name: "parse VLAN"
    debug:
      msg: "{{ vlan_brief.stdout[0] | parse_genie(command='show vlan', os='ios')}}"
    register: parsed_vlan_brief
  - name: "parse CDP neighbor"
    debug:
      msg: "{{ cdp_neighbor.stdout[0] | parse_genie(command='show cdp neighbors', os='iosxe')}}"
    register: parsed_vlan_brief
@clay584
Copy link
Owner

clay584 commented Jun 27, 2019

You may have found a bug in the parser in Cisco's Genie library. I have opened an issue on your behalf there and linked it over to this issue.

This is the issue for your reference.
CiscoTestAutomation/genieparser#20

I have a feeling that the regex parser that they have built is not matching on the CLI output from your device, and therefore does not appear in the output.

@jeaubin
Copy link

jeaubin commented Jun 27, 2019

@cuiminghao8 - Thanks to report it, we are looking into it

@jeaubin
Copy link

jeaubin commented Jul 11, 2019

It has been fixed, and a beta package has been released

pip install genie.libs.parser --upgrade --pre

Give it a try and let us know.

Thanks

@cuiminghao8
Copy link
Author

Great job! It has been fixed, thanks!

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

3 participants