fix(lldp): report the neighbour's chassis MAC
driver / standard (pull_request) Successful in 18s
driver / lint (pull_request) Successful in 28s
driver / types (pull_request) Failing after 30s
driver / test (3.13) (pull_request) Failing after 15s
driver / test (3.12) (pull_request) Failing after 17s
driver / lowest (pull_request) Failing after 18s
driver / build (pull_request) Successful in 35s
driver / security (pull_request) Failing after 40s
CI / driver (pull_request) Failing after 1m41s
driver / publish (pull_request) Skipped

lldpd tells the chassis MAC, but get_lldp_neighbors reported only name
and port, so netOrk, which matches a neighbour by MAC first, could match
OpenWrt's neighbours by name only. napalm-device-types' lldp_neighbors
projection now carries mac (lower case) when the chassis id is a MAC
address, as napalm-linux reports it.

Closes #31
This commit is contained in:
Christian Manivong committed 2026-11-02 08:51:27 +01:00
1 parent aafb5636a9
commit 071beeb68a
3 files changed
+23 -6

No files matched your search

+15 -4
View File
@@ -336,6 +336,17 @@ class TestGetLldpNeighbors:
assert result["eth0"][0]["hostname"] == "core-router"
assert result["eth0"][0]["port"] == "ether1"
def test_the_chassis_mac_is_reported(self, driver):
# netOrk matches a neighbour by this MAC first (#31).
driver._send_command = lambda cmd, **kw: LLDPCTL_KV
assert driver.get_lldp_neighbors()["eth0"][0]["mac"] == "00:aa:bb:cc:dd:ee"
def test_a_chassis_named_by_a_local_id_has_no_mac(self, driver):
driver._send_command = lambda cmd, **kw: LLDPCTL_KV_DOTTED_AND_ID_TYPES
assert driver.get_lldp_neighbors()["eth1"] == [{"hostname": "access-sw", "port": "gi1/0/7"}]
# Two neighbours on one port, laid out the way lldpd's keyvalue writer prints them
# (src/client/display.c, kv_writer.c): every neighbour opens with an optional
@@ -402,11 +413,11 @@ class TestLldpSeveralNeighboursOnOnePort:
result = driver.get_lldp_neighbors()
assert result["lan1"] == [
{"hostname": "desk-phone", "port": "lan"},
{"hostname": "desk-pc", "port": "eno1"},
assert [(n["hostname"], n["port"]) for n in result["lan1"]] == [
("desk-phone", "lan"),
("desk-pc", "eno1"),
]
assert result["eth0"] == [{"hostname": "core-router", "port": "ether1"}]
assert [(n["hostname"], n["port"]) for n in result["eth0"]] == [("core-router", "ether1")]
def test_a_neighbour_keeps_only_its_own_fields(self, driver):
driver._send_command = lambda cmd, **kw: LLDPCTL_KV_TWO_ON_ONE_PORT