napalm-automation / napalm-ios

Apache License 2.0
31 stars 40 forks source link

get_lldp_neighbors() fails with long neighbor names #103

Closed XioNoX closed 7 years ago

XioNoX commented 7 years ago

Description of Issue/Question

get_lldp_neighbors() seems to depend on spaces to separate fields of the "show lldp neighbors" command. In some cases, at least that IOS version, the output can have the columns "touching" each others, especially for neighbor with long host-names.

Device ID Local Intf Hold-time Capability Port ID foo.foobar.foo Gi2/0/2 121 O,R ethernet1/16 foobar.foobar.foobarGi2/0/4 120 B Gi2/1/2

Reducing the number of columns to 4 (see stack-trace bellow).

Note that the same issue happen if I explicitly set the terminal to the max width.

terminal width ?

<0-512> Number of characters on a screen line. ### Did you follow the steps from https://github.com/napalm-automation/napalm#faq - [x] Yes - [ ] No ### napalm-ios version (Paste verbatim output from `pip freeze | grep napalm-ios` between quotes below) ``` napalm-ios==0.5.0 ``` ### IOS version (Paste verbatim output from `show version` between quotes below) ``` Cisco IOS Software, IOS-XE Software, Catalyst L3 Switch Software (CAT3K_CAA-UNIVERSALK9-M), Version 03.06.04.E RELEASE SOFTWARE (fc2) ``` ### Error Traceback (Paste the complete traceback of the exception between quotes below) ``` >>> device. get_lldp_neighbors() Traceback (most recent call last): File "", line 1, in File "/home/xionox/Documents/Projects/Mozilla/network-automation/env/local/lib/python2.7/site-packages/napalm_ios/ios.py", line 453, in get_lldp_neighbors device_id, local_int_brief, hold_time, capability, remote_port = lldp_entry.split() ValueError: need more than 4 values to unpack ```
mirceaulinic commented 7 years ago

Seems legit.

I think this is even worse than https://github.com/napalm-automation/napalm-ios/issues/74. Wondering if it would be possible to extract the information when the text does not respect a certain pattern... But maybe @ktbyers can pull another rabbit out of the hat here.

ktbyers commented 7 years ago

@XioNoX Can you provide the CLI output from (for the above device)

show lldp neighbors

@mirceaulinic We can probably catch that ValueError exception and re-raise another exception and include the show command output (going forward).

XioNoX commented 7 years ago

@ktbyers I emailed the output directly to you.