clay584 / parse_genie

Ansible filter plugin for network CLI parsing using Cisco's Genie and pyATS
GNU General Public License v3.0
52 stars 15 forks source link

Parser "show bgp all summary" not working on IOSXE #4

Closed sjhloco closed 5 years ago

sjhloco commented 5 years ago

I get the error _"msg": "genieparse: local variable 'cmd' referenced before assignment - Failed to parse command output." when trying to use this parser on an IOSXE device.

PLAY [Gather IOSXE BGP outputs] *******************************************************************************************************

TASK [SYS >> Read in parse_genie role] ************************************************************************************************

TASK [NET >> Get IOSXE BGP output] ****************************************************************************************************
ok: [dc1-csr-xnet1]

TASK [SYS >> Parse NXOS BGP output] ***************************************************************************************************
fatal: [dc1-csr-xnet1]: FAILED! => {"msg": "genie_parse: local variable 'cmd' referenced before assignment - Failed to parse command output."}

PLAY RECAP ****************************************************************************************************************************
dc1-csr-xnet1              : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

The playbook works fine with other cmds such as "show bgp all", also confirmed that the parser works fine using "genie parse "show bgp all summary" --testbed-file testbed.yaml --devices "DC1-CSR-XNET1"" against the same device.

Ansible version and playbook book:

ansible 2.8.4
  config file = /home/ste/playbooks/chk_device_states/ansible.cfg
  configured module search path = ['/home/ste/virt/ansible_2.8.4/lib/python3.6/site-packages/napalm_ansible/modules']
  ansible python module location = /home/ste/virt/ansible_2.8.4/lib/python3.6/site-packages/ansible
  executable location = /home/ste/virt/ansible_2.8.4/bin/ansible
  python version = 3.6.8 (default, Jan 14 2019, 11:02:34) [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]]
- name: "Gather IOSXE BGP outputs"
  hosts: dc1-csr-xnet1
  connection: local

  tasks:
  - name: SYS >> Read in parse_genie role
    include_role:
      name: clay584.parse_genie

  - name: NET >> Get IOSXE BGP output
    ios_command:
      commands:
        - show bgp all summary
    register: bgp_output

  - name: SYS >> Parse NXOS BGP output
    set_fact:
      pyats_bgp: "{{ bgp_output['stdout'][0] | parse_genie(command='show bgp all summary', os='iosxe') }}"

Device output, is on a CSR1000v version 16.06.02:

DC1-CSR-XNET1#show bgp all summary 
For address family: VPNv4 Unicast
BGP router identifier 10.10.108.17, local AS number 65002
BGP table version is 6, main routing table version 6
5 network entries using 1280 bytes of memory
5 path entries using 680 bytes of memory
3/3 BGP path/bestpath attribute entries using 888 bytes of memory
2 BGP AS-PATH entries using 48 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 2896 total bytes of memory
BGP activity 5/0 prefixes, 5/0 paths, scan interval 60 secs

Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
172.16.101.2    4          901    7199    7269        6    0    0 06:12:04        1
172.16.201.2    4        12076    7199    7269        6    0    0 06:12:06        3
192.168.12.6    4        65001    7422    7267        6    0    0 06:11:55        0
192.168.12.10   4        65001    7396    7242        6    0    0 06:10:36        0

Thanks

clay584 commented 5 years ago

There must be a bug in the genie parsing library as it worked for me on 19.4.0, but not on the latest 19.7.1. Cisco maintains this library. You will need to open an issue on that project (https://github.com/CiscoTestAutomation/genieparser)

This works for me on the following version:

genie==19.4.0
genie.abstract==19.4.0
genie.conf==19.4.0
genie.examples==19.4.0
genie.harness==19.4.0
genie.libs.conf==19.4.0
genie.libs.filetransferutils==19.4.0
genie.libs.ops==19.4.0
genie.libs.parser==19.4.0
genie.libs.sdk==19.4.0
genie.libs.telemetry==19.4.0
genie.metaparser==19.4.0
genie.ops==19.4.0
genie.parsergen==19.4.0
genie.predcore==19.4.0
genie.telemetry==19.4.0
genie.trafficgen==19.4.0
genie.utils==19.4.0

but fails on the later genie versions:

genie==19.7.1
genie.abstract==19.7
genie.conf==19.7.2
genie.examples==19.4.0
genie.harness==19.7.2
genie.libs.conf==19.7
genie.libs.filetransferutils==19.7
genie.libs.ops==19.7
genie.libs.parser==19.7
genie.libs.sdk==19.7
genie.libs.telemetry==19.7
genie.metaparser==19.7
genie.ops==19.7
genie.parsergen==19.7
genie.predcore==19.7
genie.telemetry==19.7
genie.trafficgen==19.7.1
genie.utils==19.7
cisco-allen commented 5 years ago

Thank you for reporting the issue. We will look into it.

It will be followed up here: https://github.com/CiscoTestAutomation/genieparser/issues/30 Thanks,

tahigash commented 5 years ago

Hi @sjhloco

I'm from pyATS/Genie team. We've release Genie v19.8 with this parser fix. Please upgrade Genie package by below either way and see if it works.

Genie all package upgrade:
pip install genie --upgrade

only genie.libs.parser upgrade:
pip install genie.libs.parser --upgrade
sjhloco commented 5 years ago

Hey tahigash,

Tested it and works a treat. Thanks for getting it fixed so fast.

niks202020 commented 4 years ago

Hi tahigash,

I am trying show bgp summary command with genie parser and it's failing TASK [debug] *** fatal: [sbx-iosxr-mgmt.cisco.com]: FAILED! => {"msg": "parse_genie: Parser Output is empty - Failed to parse command output."}

I am using Genie ver 20.6.0

I

tahigash commented 4 years ago

@niks202020 please make sure show command returned any neighbour. If no neighbour, it's expected. If you see neighbours in output, please send the issue with log(output) to pyats-support-ext(at)cisco.com. We will look into this further.