Skip to content

Commit

Permalink
Log a note if the LLDP neighbor data is reported stale by the BMC
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Keay committed Nov 26, 2024
1 parent ac672d0 commit 672a88b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class InterfaceInfo:
dhcp: bool = False
remote_switch_mac_address: str | None = None
remote_switch_port_name: str | None = None
remote_switch_data_stale: bool = False


@dataclass(frozen=True)
Expand Down Expand Up @@ -232,16 +233,20 @@ def parse_lldp_port(port_data: dict[str, str]) -> dict:
"""
mac = str(port_data["SwitchConnectionID"]).upper()
port_name = normalize_interface_name(port_data["SwitchPortConnectionID"])
stale = str(port_data["StaleData"]) != "NotStale"


if mac in ["NOT AVAILABLE", "NO LINK", "NOT SUPPORTED"]:
return {
"remote_switch_mac_address": None,
"remote_switch_port_name": None,
"remote_switch_data_stale": stale,
}
else:
return {
"remote_switch_mac_address": mac,
"remote_switch_port_name": port_name,
"remote_switch_data_stale": stale,
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ def nautobot_switches(nautobot, mac_addresses: set[str]) -> dict[str, dict]:


def nautobot_switch(all_switches: dict[str, Any], interface: InterfaceInfo):
if interface.remote_switch_data_stale:
logger.info(f"Warning: BMC marked LLDP data stale for {interface.name}")

if not interface.remote_switch_mac_address or not interface.remote_switch_port_name:
raise ValueError(f"missing LDLDP info in {interface}")

Expand Down

0 comments on commit 672a88b

Please sign in to comment.