napalm-automation / napalm

Network Automation and Programmability Abstraction Layer with Multivendor support
Apache License 2.0
2.26k stars 555 forks source link

ios get_lldp_neighbor fails when parsing blank column rows #1803

Open awcrate opened 2 years ago

awcrate commented 2 years ago

Description of Issue/Question

Note: Please check https://guides.github.com/features/mastering-markdown/ to see how to properly format your request.

Did you follow the steps from https://github.com/napalm-automation/napalm#faq

(Place an x between the square brackets where applicable)

Setup

napalm version

(Paste verbatim output from pip freeze | grep napalm between quotes below)

napalm==4.0.0

Network operating system version

(Paste verbatim output from show version - or equivalent - between quotes below)

Cisco IOS Software, c7600rsp72043_rp Software (c7600rsp72043_rp-ADVIPSERVICESK9-M), Version 15.4(3)S6, RELEASE SOFTWARE (fc1)

Steps to Reproduce the Issue

Run the following command when one of the rows within the Compatibility column is blank.

napalm --vendor ios --user USER --password PASSWORD HOSTNAME call get_lldp_neighbors

Error Traceback

(Paste the complete traceback of the exception between quotes below)

Traceback (most recent call last):
  File "/home/<redacted>/.local/bin/napalm", line 8, in <module>
    sys.exit(main())
  File "/home/<redacted>/.local/lib/python3.8/site-packages/napalm/base/clitools/cl_napalm.py", line 308, in main
    run_tests(args)
  File "/home/<redacted>/.local/lib/python3.8/site-packages/napalm/base/clitools/cl_napalm.py", line 291, in run_tests
    call_getter(device, args.method, **method_kwargs)
  File "/home/<redacted>/.local/lib/python3.8/site-packages/napalm/base/clitools/cl_napalm.py", line 27, in wrapper
    r = func(*args, **kwargs)
  File "/home/<redacted>/.local/lib/python3.8/site-packages/napalm/base/clitools/cl_napalm.py", line 255, in call_getter
    r = func(**kwargs)
  File "/home/<redacted>/.local/lib/python3.8/site-packages/napalm/ios/ios.py", line 991, in get_lldp_neighbors
    port = napalm.base.helpers.mac(port)
  File "/home/<redacted>/.local/lib/python3.8/site-packages/napalm/base/helpers.py", line 514, in mac
    return str(EUI(raw, dialect=_MACFormat))
  File "/usr/lib/python3/dist-packages/netaddr/eui/__init__.py", line 387, in __init__
    self.value = addr
  File "/usr/lib/python3/dist-packages/netaddr/eui/__init__.py", line 436, in _set_value
    raise AddrFormatError('failed to detect EUI version: %r'
netaddr.core.AddrFormatError: failed to detect EUI version: '0/51'

Full CLI output of "show lldp neighbors"

Note: HOSTNAME indicates a hostname I've removed. 0000.0000.0000 indicates a mac address originally formatted as three groups of four, whose specifics I've removed. I've included as much of the original formatting as is applicable to the above error message.

Capability codes:
    (R) Router, (B) Description, (T) Telephone, (C) DOCSIS Cable Device
    (W) WLAN Access Point, (P) Repeater, (S) Station, (O) Other

Device ID           Local Intf     Hold-time  Capability      Port ID
HOSTNAME            Gi0/0          120        B,R             Description
HOSTNAME            Gi0/0          30         B,R             Description
HOSTNAME            Gi0/0          120        B,R             Description
HOSTNAME            Gi0/0          120        B,R             Description
HOSTNAME            Te0/0          120        B,R             Te0/0
HOSTNAME            Te0/0          120        B,R             Description
HOSTNAME            Te0/0          120        B,R             Description
0000.0000.0000      Gi0/0          120                        0/51
HOSTNAME            Gi0/0          120        B,R             Description
HOSTNAME            Gi0/0          30         B,R             Description
0000.0000.0000      Gi0/0          120                        0/0
HOSTNAME            Gi0/0          120        B,R             Gi0/0
HOSTNAME            Gi0/0          120        B               Gi0/0/0
HOSTNAME            Gi0/0          120        B,R             Description
HOSTNAME            Te0/0          40         B               0/0/0
HOSTNAME            Te0/0          120        B,R             Te0/0
HOSTNAME            Gi0/0          120        B,R             Description
HOSTNAME            Te0/0          120        B,R             Description
HOSTNAME            Te0/0          120        B,R             Description
0000.0000.0000      Te0/0          120                        0/0

Total entries displayed: 20
itdependsnetworks commented 2 years ago

I am not sure it is using show lldp neighbors, I think on the show lldp neighbors details something is getting tripped up.

You are failing here: https://github.com/napalm-automation/napalm/blob/7ecb9b9a330579fc9669b92b2bb56ff54131e83a/napalm/ios/ios.py#L990

Which is referencing remote_chassis_id, here: https://github.com/napalm-automation/napalm/blob/7ecb9b9a330579fc9669b92b2bb56ff54131e83a/napalm/ios/ios.py#L989

Which is defined in template, here: https://github.com/napalm-automation/napalm/blob/7ecb9b9a330579fc9669b92b2bb56ff54131e83a/napalm/ios/utils/textfsm_templates/show_lldp_neighbors_detail.tpl#L12

Can you show me your show lldp neighbors details?

Compare that to what is showing in mocked responses as shown here: https://github.com/napalm-automation/napalm/blob/d782cc72c4adc24de168a8b0a594a61ec90d4472/test/ios/mocked_data/test_get_lldp_neighbors_detail/alternate/show_lldp_neighbors_detail.txt#L3

awcrate commented 2 years ago

Thank you for your response. Please note that napalm --vendor ios --user USER --PASSWORD HOSTNAME call get_lldp_neighbors_detail does not throw any errors.

An uncensored version of the following output can be provided if necessary. show lldp neighbors detail

------------------------------------------------
Chassis id: 0000.0000.0000
Port id: PORT
Port Description - not advertised
System Name: HOSTNAME

System Description:
DESCRIPTION 0000.0000.0000 (stable) MODEL

Time remaining: 111 seconds
System Capabilities: B,R
Enabled Capabilities: B,R
Management Addresses:
    IP: 0000.0000.0000.00
    IPV6: ::
    IPV6: ::
Auto Negotiation - not supported
Physical media capabilities - not advertised
Media Attachment Unit type - not advertised
Vlan ID: - not advertised

------------------------------------------------
Chassis id: 0000.0000.0000
Port id: PORT
Port Description: DESC
System Name: HOST-0000.0000.0000

System Description:
Arista Networks EOS version 0000.0000.0000 running on an Arista Networks DCS-7280SR2-48YC6

Time remaining: 21 seconds
System Capabilities: B,R
Enabled Capabilities: B,R
Management Addresses:
    IP: 0000.0000.0000.58
Auto Negotiation - not supported
Physical media capabilities - not advertised
Media Attachment Unit type - not advertised
Vlan ID: - not advertised

------------------------------------------------
Chassis id: 0000.0000.0000
Port id: PORT
Port Description - not advertised
System Name: HOST

System Description:
MikroTik RouterOS 0000.0000.0000 (long-term) CCR1009-8G-1S-1S+

Time remaining: 109 seconds
System Capabilities: B,R
Enabled Capabilities: B,R
Management Addresses:
    IP: 0000.0000.0000.150
    IPV6: ::
    IPV6: ::
Auto Negotiation - not supported
Physical media capabilities - not advertised
Media Attachment Unit type - not advertised
Vlan ID: - not advertised

------------------------------------------------
Chassis id: 0000.0000.0000
Port id: PORT
Port Description: DESC
System Name: CRE1B-0000.0000.0000

System Description:
Arista Networks EOS version 0000.0000.0000.1M running on an Arista Networks DCS-7280SR2A-48YC6

Time remaining: 112 seconds
System Capabilities: B,R
Enabled Capabilities: B,R
Management Addresses:
    IP: 0000.0000.0000.115
Auto Negotiation - not supported
Physical media capabilities - not advertised
Media Attachment Unit type - not advertised
Vlan ID: 0

------------------------------------------------
Chassis id: 0000.0000.0000
Port id: PORT
Port Description: PORTDESC
System Name: 0000.0000.0000.com

System Description:
Cisco IOS Software, c7600rsp72043_rp Software (c7600rsp72043_rp-ADVIPSERVICESK9-M), Version 15.2(4)S4a, RELEASE SOFTWARE (fc1)
Technical Support: http://0000.0000.0000/techsupport
Copyright (c) 1986-2013 by Cisco Systems, Inc.
Compiled Mon 07-Oct-13 13:22

Time remaining: 100 seconds
System Capabilities: B,R
Enabled Capabilities: B,R
Management Addresses:
    IP: 0000.0000.0000.125
    IPV6: ::
Auto Negotiation - not supported
Physical media capabilities - not advertised
Media Attachment Unit type - not advertised
Vlan ID: - not advertised

------------------------------------------------
Chassis id: 0000.0000.0000
Port id: PORT
Port Description: DESC
System Name: HOST-0000.0000.0000

System Description:
Arista Networks EOS version 0000.0000.0000 running on an Arista Networks DCS-7280SR2-48YC6

Time remaining: 115 seconds
System Capabilities: B,R
Enabled Capabilities: B,R
Management Addresses:
    IP: 0000.0000.0000.61
Auto Negotiation - not supported
Physical media capabilities - not advertised
Media Attachment Unit type - not advertised
Vlan ID: 0

------------------------------------------------
Chassis id: 0000.0000.0000
Port id: PORT
Port Description: DESC
System Name: LEAF1B-0000.0000.0000

System Description:
Arista Networks EOS version 0000.0000.0000 running on an Arista Networks DCS-7280SR2-48YC6

Time remaining: 115 seconds
System Capabilities: B,R
Enabled Capabilities: B,R
Management Addresses:
    IP: 0000.0000.0000.61
Auto Negotiation - not supported
Physical media capabilities - not advertised
Media Attachment Unit type - not advertised
Vlan ID: 0

------------------------------------------------
Chassis id: 0000.0000.0000
Port id: 0/51
Port Description - not advertised
System Name - not advertised
System Description - not advertised

Time remaining: 96 seconds
System Capabilities - not advertised
Enabled Capabilities - not advertised
Management Addresses - not advertised
Auto Negotiation - not supported
Physical media capabilities - not advertised
Media Attachment Unit type - not advertised
Vlan ID: 0

------------------------------------------------
Chassis id: 0000.0000.0000
Port id: PORT
Port Description: DESC
System Name: HOST-0000.0000.0000

System Description:
Arista Networks EOS version 0000.0000.0000 running on an Arista Networks DCS-7280SR2-48YC6

Time remaining: 114 seconds
System Capabilities: B,R
Enabled Capabilities: B,R
Management Addresses:
    IP: 0000.0000.0000.61
Auto Negotiation - not supported
Physical media capabilities - not advertised
Media Attachment Unit type - not advertised
Vlan ID: - not advertised

------------------------------------------------
Chassis id: 0000.0000.0000
Port id: PORT
Port Description: DESC
System Name: HOST-0000.0000.0000

System Description:
Arista Networks EOS version 0000.0000.0000 running on an Arista Networks DCS-7280SR2-48YC6

Time remaining: 22 seconds
System Capabilities: B,R
Enabled Capabilities: B,R
Management Addresses:
    IP: 0000.0000.0000.59
Auto Negotiation - not supported
Physical media capabilities - not advertised
Media Attachment Unit type - not advertised
Vlan ID: - not advertised

------------------------------------------------
Chassis id: 0000.0000.0000
Port id: 0/52
Port Description - not advertised
System Name - not advertised
System Description - not advertised

Time remaining: 91 seconds
System Capabilities - not advertised
Enabled Capabilities - not advertised
Management Addresses - not advertised
Auto Negotiation - not supported
Physical media capabilities - not advertised
Media Attachment Unit type - not advertised
Vlan ID: 0

------------------------------------------------
Chassis id: 0000.0000.0000
Port id: PORT
Port Description: DESC
System Name: HOST-0000.0000.0000.ca

System Description:
Cisco IOS Software, C3560 Software (C3560-IPBASEK9-M), Version 15.0(2)SE11, RELEASE SOFTWARE (fc3)
Technical Support: http://0000.0000.0000/techsupport
Copyright (c) 1986-2017 by Cisco Systems, Inc.
Compiled Sat 19-Aug-17 09:21 by prod_rel_team

Time remaining: 97 seconds
System Capabilities: B,R
Enabled Capabilities: B,R
Management Addresses:
    IP: 0000.0000.0000.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: 0

------------------------------------------------
Chassis id: 0000.0000.0000
Port id: PORT
Port Description: DESC
System Name: HOST-0000.0000.0000

System Description:
Cisco IOS Software, C3750E Software (C3750E-UNIVERSALK9-M), Version 15.0(2)SE6, RELEASE SOFTWARE (fc2)
Technical Support: http://0000.0000.0000/techsupport
Copyright (c) 1986-2014 by Cisco Systems, Inc.
Compiled Wed 09-Apr-14 02:55 by prod_rel_team

Time remaining: 91 seconds
System Capabilities: B,R
Enabled Capabilities: B
Management Addresses:
    IP: 0000.0000.0000.201
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: 0

------------------------------------------------
Chassis id: 0000.0000.0000
Port id: PORT
Port Description: DESC
System Name: HOST-0000.0000.0000

System Description:
Arista Networks EOS version 0000.0000.0000 running on an Arista Networks DCS-7280CR2A-30

Time remaining: 116 seconds
System Capabilities: B,R
Enabled Capabilities: B,R
Management Addresses:
    IP: 0000.0000.0000.28
Auto Negotiation - not supported
Physical media capabilities - not advertised
Media Attachment Unit type - not advertised
Vlan ID: - not advertised

------------------------------------------------
Chassis id: ID
Port id: 0/0/x0
Port Description: DESC
System Name: HOST

System Description:
DESC

Time remaining: 35 seconds
System Capabilities: B
Enabled Capabilities: B
Management Addresses:
    IP: 0000.0000.0000.122
Auto Negotiation - not supported
Physical media capabilities - not advertised
Media Attachment Unit type - not advertised
Vlan ID: - not advertised

------------------------------------------------
Chassis id: 0000.0000.0000
Port id: PORT
Port Description: PORT
System Name: HOST

System Description:
Cisco IOS Software, c7600s72033_rp Software (c7600s72033_rp-ADVIPSERVICESK9-M), Version 15.4(3)S3, RELEASE SOFTWARE (fc1)
Technical Support: http://0000.0000.0000/techsupport
Copyright (c) 1986-2015 by Cisco Systems, Inc.
Compiled Thu 28-May-15 06:30 by pr

Time remaining: 97 seconds
System Capabilities: B,R
Enabled Capabilities: B,R
Management Addresses:
    IP: 0000.0000.0000.4
Auto Negotiation - not supported
Physical media capabilities - not advertised
Media Attachment Unit type - not advertised
Vlan ID: - not advertised

------------------------------------------------
Chassis id: 0000.0000.0000
Port id: PORT
Port Description - not advertised
System Name: HOST

System Description:
MikroTik RouterOS 0000.0000.0000 (stable) May/02/2022 15:18:17 CRS354-48G-4S+2Q+

Time remaining: 67 seconds
System Capabilities: B,R
Enabled Capabilities: B,R
Management Addresses - not advertised
Auto Negotiation - not supported
Physical media capabilities - not advertised
Media Attachment Unit type - not advertised
Vlan ID: - not advertised

------------------------------------------------
Chassis id: 0000.0000.0000
Port id: 0000.0000.0000
Port Description: DESC
System Name: HOST

System Description:
Brocade MLXe (System Mode: XMR), IronWare Version 0000.0000.0000 Compiled on Jul  6 2017 at 04:45:06 labeled as 0000.0000.0000

Time remaining: 95 seconds
System Capabilities: B,R
Enabled Capabilities: B,R
Management Addresses:
    IP: 0000.0000.0000.8
Auto Negotiation - supported, disabled
Physical media capabilities - not advertised
Media Attachment Unit type: 35
Vlan ID: - not advertised

------------------------------------------------
Chassis id: 0000.0000.0000
Port id: 0000.0000.0000
Port Description: DESC
System Name: HOST

System Description:
Brocade MLXe (System Mode: XMR), IronWare Version 0000.0000.0000 Compiled on Jul  6 2017 at 04:45:06 labeled as 0000.0000.0000

Time remaining: 91 seconds
System Capabilities: B,R
Enabled Capabilities: B,R
Management Addresses:
    IP: 0000.0000.0000.47
Auto Negotiation - supported, disabled
Physical media capabilities - not advertised
Media Attachment Unit type: 35
Vlan ID: - not advertised

------------------------------------------------
Chassis id: 0000.0000.0000
Port id: 0/49
Port Description - not advertised
System Name - not advertised
System Description - not advertised

Time remaining: 105 seconds
System Capabilities - not advertised
Enabled Capabilities - not advertised
Management Addresses - not advertised
Auto Negotiation - not supported
Physical media capabilities - not advertised
Media Attachment Unit type - not advertised
Vlan ID: 0

Total entries displayed: 20
awcrate commented 2 years ago

I realized I did not provide the full output from get_lldp_neighbors

0000.0000.0000
00:00:00:00:00:00
0000.0000.0000
00:00:00:00:00:00
0000.0000.0000
00:00:00:00:00:00
0000.0000.0000
00:00:00:00:00:00
0000.0000.0000
00:00:00:00:00:00
0000.0000.0000
00:00:00:00:00:00
0000.0000.0000
00:00:00:00:00:00
0000.0000.0000
00:00:00:00:00:00
0000.0000.0000
00:00:00:00:00:00
0000.0000.0000
00:00:00:00:00:00
0000.0000.0000
00:00:00:00:00:00
0000.0000.0000
00:00:00:00:00:00
0000.0000.0000
00:00:00:00:00:00
0000.0000.0000
00:00:00:00:00:00
E7-2:SN00000000000
0000.0000.0000
00:00:00:00:00:00
0000.0000.0000
00:00:00:00:00:00
0000.0000.0000
00:00:00:00:00:00
0000.0000.0000
00:00:00:00:00:00
0000.0000.0000
00:00:00:00:00:00
00:00:00:00:00:00
00:00:00:00:00:00
0/51
2022-11-22 12:54:47,783 - napalm - ERROR - method - Failed: failed to detect EUI version: '0/51'

Then the traceback I posted above follows the above text.

awcrate commented 1 year ago

Hi,

I found some time to look in to this.

https://github.com/napalm-automation/napalm/blob/7ecb9b9a330579fc9669b92b2bb56ff54131e83a/napalm/ios/ios.py#L977-L994

In the above snippet, we pass the remote_port through the mac() helper function. For the device I'm encountering issues with this function on, the remote_port is seldom a MAC address. Hence why this fails.

As a workaround for myself, commenting this line allowed the get_lldp_neighbors() function to run: https://github.com/napalm-automation/napalm/blob/7ecb9b9a330579fc9669b92b2bb56ff54131e83a/napalm/ios/ios.py#L990

I suppose this function could be improved by checking to ensure the port is indeed a MAC address. e.g.) with a try, except.

I also noticed that the port only gets formatted with the mac() helper method in get_lldp_neighbors() if line 988 is true, if not hostname. Otherwise, it doesn't get formatted and remains as hhhh.hhhh.hhhh. Likewise, the get_lldp_neighbors_detail() method does not format the port as a MAC. I'm not sure what the intended functionality is here. Maybe I don't understand something, but it appears inconsistent.

I haven't seen the show lldp neighbor detail output from many Cisco devices. I can only imagine that those who have written and contributed to this specific function have seen the output of show lldp neighbor detail from many Cisco devices. I think it's interesting that the assumed output of the remote port is a MAC address, and I just happen to have a device with unexpected output, but that it only matters if the if no hostname logic is true.