napalm-automation / napalm-ios

Apache License 2.0
31 stars 40 forks source link

get_lldp_neighbors fail if capabilities not present #86

Closed sjtarik closed 7 years ago

sjtarik commented 7 years ago

Description of Issue/Question

get_lldp_neighbors failed if device line does not have capabilities. maybe we should implement the case in textfsm and handle it?

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

Setup

napalm-ios version

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

napalm-ios==0.4.0

IOS version

(Paste verbatim output from show version between quotes below)

Cisco IOS Software, IOS-XE Software, Catalyst 4500 L3 Switch Software (cat4500es8-UNIVERSALK9-M), Version 03.03.02.XO RELEASE SOFTWARE (fc1)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2014 by Cisco Systems, Inc.
Compiled Tue 19-Aug-14 02:17 by prod_rel_team

Cisco IOS-XE software, Copyright (c) 2005-2013 by cisco Systems, Inc.
All rights reserved.  Certain components of Cisco IOS-XE software are
licensed under the GNU General Public License ("GPL") Version 2.0.  The
software code licensed under GPL Version 2.0 is free software that comes
with ABSOLUTELY NO WARRANTY.  You can redistribute and/or modify such
GPL code under the terms of GPL Version 2.0.  For more details, see the
documentation or "License Notice" file accompanying the IOS-XE software,
or the applicable URL provided on the flyer accompanying the IOS-XE
software.

ROM: 15.1(1r)SG2

Steps to Reproduce the Issue

Connect a security camera, dell server or any simple device that does not exchange capabilities. Then call get_lldp_neighbors()

Error Traceback

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

  File "/devs/lib/python2.7/site-packages/napalm_ios/ios.py", line 415, 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
ktbyers commented 7 years ago

@sjtarik Please post the output from the following command on your switch:

show lldp neighbors
sjtarik commented 7 years ago

I removed other regular lines. Last line breaks the logic since it does not have 5 tuples because of missing capability.

Device ID Local Intf Hold-time Capability Port ID 40:e3:d6:c9:95:2c Gi10/10 112 W 40e3.d6c9.952c 90b1.1c7d.2e69 Gi1/13 2878 90b1.1c7d.2e69

ktbyers commented 7 years ago

Okay, will fix...

sjtarik commented 7 years ago

@ktbyers @mirceaulinic in the long run if there is a plan refactoring with textfsm, I can help?

ktbyers commented 7 years ago

Yeah, I am not a fan of textfsm. It is incredibly hard to use/maintain.

Note, this isn't a textfsm issue versus the way we did it issue...

it is a having a large enough sample size issue to cover the possible outputs that Cisco IOS can generate.