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

Fixes #695 - inconsistent use of domain name in LLDP #698

Merged
merged 5 commits into from Apr 17, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions napalm/ios/ios.py
Expand Up @@ -822,6 +822,8 @@ def get_lldp_neighbors_detail(self, interface=''):
local_intf = match.group(1)
else:
system_name_match = re.search(r"^System Name:\s+(\S.*)$", lldp_entry, flags=re.M)
# Cisco is inconsistent on whether the domain name appears in LLDP brief output
system_name_alt = re.search(r"^System Name:\s+(\S.*?)\.", lldp_entry, flags=re.M)
port_id_match = re.search(r"^Port id:\s+(\S+)\s*$", lldp_entry, flags=re.M)
# Try to find the local_intf from the reverse_neighbors table
if system_name_match and port_id_match:
Expand All @@ -830,6 +832,11 @@ def get_lldp_neighbors_detail(self, interface=''):
system_name = system_name.strip()
key = "{}_{}".format(system_name, port_id)
local_intf = reverse_neighbors.get(key)
if local_intf is None and system_name_alt:
system_name_alt = system_name_alt.group(1)[:20]
system_name_alt = system_name_alt.strip()
alt_key = "{}_{}".format(system_name_alt, port_id)
local_intf = reverse_neighbors.get(alt_key)

if local_intf is not None:
lldp_fields = self._lldp_detail_parser(local_intf, lldp_entry=lldp_entry)
Expand Down
@@ -0,0 +1,86 @@
{
"TenGigabitEthernet1/6": [
{
"port": "Te1/3",
"hostname": "foo-vwd-d35a.foo.domain.com"
}
],
"TenGigabitEthernet1/5": [
{
"port": "xe-0/0/2",
"hostname": "foo-vwd-d34a"
}
],
"TenGigabitEthernet5/4": [
{
"port": "Te3/2",
"hostname": "foo-vsl-a.wan.domain.com"
}
],
"TenGigabitEthernet2/3": [
{
"port": "Te5/4",
"hostname": "foo-vsd-d32b.foo.domain.com"
}
],
"GigabitEthernet9/16": [
{
"port": "Gi2/1",
"hostname": "foo-sc-b.subd.domain.com"
}
],
"GigabitEthernet8/16": [
{
"port": "Gi2/1",
"hostname": "foo-sc-a.subd.domain.com"
}
],
"TenGigabitEthernet1/4": [
{
"port": "Eth3/1",
"hostname": "foo-vdd-d33a.foo.domain.com"
}
],
"TenGigabitEthernet2/8": [
{
"port": "xe-0/0/2",
"hostname": "foo-vdd-d37b"
}
],
"TenGigabitEthernet2/4": [
{
"port": "Eth3/1",
"hostname": "foo-vdd-d33b.foo.domain.com"
}
],
"GigabitEthernet8/18": [
{
"port": "Gi1/25",
"hostname": "foo-vsd-d17a.subd.domain.com"
}
],
"TenGigabitEthernet1/8": [
{
"port": "xe-0/0/2",
"hostname": "foo-vdd-d37a"
}
],
"TenGigabitEthernet2/2": [
{
"port": "Te5/4",
"hostname": "foo-vid-31b.foo.domain.com"
}
],
"TenGigabitEthernet2/5": [
{
"port": "xe-0/0/2",
"hostname": "foo-vwd-d34b"
}
],
"TenGigabitEthernet2/6": [
{
"port": "Te1/3",
"hostname": "foo-vwd-d35b.foo.domain.com"
}
]
}
@@ -0,0 +1,21 @@
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
foo-vwd-d35a Te1/6 120 B,R Te1/3
foo-vwd-d34a Te1/5 120 B,R xe-0/0/2
foo-vsl-a Te5/4 120 B,R Te3/2
foo-vsd-d32b Te2/3 120 B,R Te5/4
foo-sc-b Gi9/16 120 B,R Gi2/1
foo-sc-a Gi8/16 120 B,R Gi2/1
foo-vdd-d33a Te1/4 120 B,R Eth3/1
foo-vdd-d37b Te2/8 120 B,R xe-0/0/2
foo-vdd-d33b Te2/4 120 B,R Eth3/1
foo-vsd-d17a Gi8/18 120 R Gi1/25
foo-vdd-d37a Te1/8 120 B,R xe-0/0/2
foo-vid-31b Te2/2 120 B,R Te5/4
foo-vwd-d34b Te2/5 120 B,R xe-0/0/2
foo-vwd-d35b Te2/6 120 B,R Te1/3

Total entries displayed: 14