Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nxos_ssh get_lldp_neighbors using TextFSM template is unlikely to be correct #834

Closed
ktbyers opened this issue Oct 15, 2018 · 3 comments · Fixed by #863
Closed

nxos_ssh get_lldp_neighbors using TextFSM template is unlikely to be correct #834

ktbyers opened this issue Oct 15, 2018 · 3 comments · Fixed by #863

Comments

@ktbyers
Copy link
Contributor

ktbyers commented Oct 15, 2018

I am basing this on IOS, but that first field in IOS is a fixed length field (20 characters) and can have spaces in it:

$ cat ./nxos_ssh/utils/textfsm_templates/lldp_neighbors.tpl
Value NEIGHBOR (\S+)
Value LOCAL_INTERFACE (\S+)
Value NEIGHBOR_INTERFACE (\S+)

Start
  ^Device.*ID -> LLDP

LLDP
  ^${NEIGHBOR}\s+${LOCAL_INTERFACE}\s+\d+\s+[\w+\s]+\S+\s+${NEIGHBOR_INTERFACE} -> Record

@ktbyers
Copy link
Contributor Author

ktbyers commented Oct 16, 2018

Looks like NXOS is different here:

show lldp neighbors 
Capability codes:
  (R) Router, (B) Bridge, (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     
nxos2_nxos2_nxos2_nxos2_nxos2_nxos2.twb-tech.com  Eth2/1              120          BR          Eth2/1      
nxos2_nxos2_nxos2_nxos2_nxos2_nxos2.twb-tech.com  Eth2/2              120          BR          Eth2/2      
nxos2_nxos2_nxos2_nxos2_nxos2_nxos2.twb-tech.com  Eth2/3              120          BR          Eth2/3      
nxos2_nxos2_nxos2_nxos2_nxos2_nxos2.twb-tech.com  Eth2/4              120          BR          Eth2/4      
Total entries displayed: 4

Names with whitespace could still be an issue though

@jobec
Copy link
Contributor

jobec commented Nov 30, 2018

I've found other issues with the LLDP stuff on nxos_ssh. When the chassis ID isn't a mac address (for example, an F5 Load Balancer sends it's serial number) then the code explodes with this erros:

Traceback (most recent call last):
  File "<input>", line 6, in <module>
  File "/home/vagrant/.venv/lib/python3.6/site-packages/napalm/nxos_ssh/nxos_ssh.py", line 735, in get_lldp_neighbors_detail
    'remote_chassis_id': napalm.base.helpers.mac(chassis_rgx.groups()[1])
  File "/home/vagrant/.venv/lib/python3.6/site-packages/napalm/base/helpers.py", line 224, in mac
    return py23_compat.text_type(EUI(raw, dialect=_MACFormat))
  File "/home/vagrant/.venv/lib/python3.6/site-packages/netaddr/eui/__init__.py", line 387, in __init__
    self.value = addr
  File "/home/vagrant/.venv/lib/python3.6/site-packages/netaddr/eui/__init__.py", line 437, in _set_value
    % value)
netaddr.core.AddrFormatError: failed to detect EUI version: 'chs123456s'

@ktbyers @mirceaulinic
Shall I send a PR to review this and rewrite it the same way as I did for IOS?

It will also make my todo in #816 simpler to implement.

@jobec
Copy link
Contributor

jobec commented Nov 30, 2018

To bypass the original problem of this issue, the LLDP neighbor output in PR #872 was switched to using the show lldp neighbors detail output. The standard show lldp neighbors output cannot be reliably parsed with long neighbor system names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants