napalm-automation-community / napalm-aos

NAPALM driver for Alcatel Lucent Enterprise AOS
Apache License 2.0
11 stars 13 forks source link

get_lldp_neighbors - AttributeError: 'NoneType' object has no attribute 'groups' #25

Closed jrschneider closed 4 years ago

jrschneider commented 5 years ago
Problem Description

get_lldp_neighbors() raises an AttributeError against AOS8:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-6-995a495a8f91> in <module>
----> 1 device.get_lldp_neighbors()

~/lib/cpp-py3/lib/python3.6/site-packages/napalm_aos/aos.py in get_lldp_neighbors(self)
    575                 hostname = lldp_dict[local_port][chassis]['System Name'].strip()
    576                 port_match = re.match(r".*(Port) (\d+)", chassis)
--> 577                 port = port_match.groups()[1]
    578                 entry = {
    579                     'hostname': hostname,

AttributeError: 'NoneType' object has no attribute 'groups'
Analysis

The following basic script reproduces the error every time:

from napalm import get_network_driver('aos')
from napalm import get_network_driver
driver = get_network_driver('aos')
device = driver('switch', 'admin', '<password>')
device.open()
device.get_lldp_neighbors()

The get_lldp_neighbors_detail() method works as expected.

Runtime Information

Switch info: Alcatel-Lucent Enterprise OS6860E-P48 8.5.255.R02 GA, August 29, 2018.

$ pip freeze | grep napalm
napalm==2.4.0
napalm-aos==0.1.1
napalm-panos==0.5.2

Python 3.6.7 Ubuntu 18.04.2 LTS

jrschneider commented 5 years ago

https://github.com/napalm-automation-community/napalm-aos/blob/26c553e92b2fa1d48e5e2c9e69d93e460748d48b/napalm_aos/aos.py#L630-L640

On line 634, there is no protection against a failed regex match, which is ultimately causing the issue. Not sure if the output changed in recent versions of AOS8.

napalmaos commented 5 years ago

Could you please provide me the output of "show lldp remote-system" command on your system

Thanks

jrschneider commented 5 years ago

sh-lldp-remote-system-6860e.txt sh-lldp-remote-system-6900-t40.txt

I collected a 'show system' and a 'show lldp remote-system' from two different model lines, both running AOS 8.5. The original example script I posted breaks on both in the same fashion. The commands were collected using show system > sh-lldp-remote-system-6860e.txt and show lldp remote-system >> sh-lldp-remote-system-6860e.txt to try and preserve the spacing and output as best as possible. The files were downloaded from the switch and uploaded here without modification.

Thank you.

napalmaos commented 5 years ago

Thank for your file. I have found the root cause of issue.

I also check our napalm implementation and see it is outdated with napalm/base. It will take us some time to update the source code and fix issue.

Thank you.

vmuthukrishnan commented 5 years ago

@jrschneider The issue has been resolved. Could you check and update the ticket?

vmuthukrishnan commented 4 years ago

Issue is resolved.