mirror of
https://github.com/hansjone/netx.git
synced 2026-10-17 10:53:21 +08:00
Reorganize biz-state parsers by vendor folder and per-command modules.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
da6b159703
commit
d587bf7bb9
14 changed files with 473 additions and 434 deletions
36
netx_api/biz_state/parsers/common/lldp_neighbors.py
Normal file
36
netx_api/biz_state/parsers/common/lldp_neighbors.py
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
"""LLDP neighbor normalize (multi-vendor via lldp_shared / TextFSM)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from ....lldp_shared import NeighborHit, parse_neighbor_output
|
||||
|
||||
|
||||
def normalize_lldp_neighbors(
|
||||
*,
|
||||
raw_text: str,
|
||||
vendor: str = "",
|
||||
device_type: str = "",
|
||||
command: str = "",
|
||||
params: dict[str, str] | None = None,
|
||||
) -> list[dict[str, Any]]:
|
||||
hits: list[NeighborHit] = parse_neighbor_output(
|
||||
raw_text,
|
||||
vendor=vendor,
|
||||
device_type=device_type,
|
||||
command=command,
|
||||
)
|
||||
_ = params
|
||||
rows: list[dict[str, Any]] = []
|
||||
for h in hits:
|
||||
rows.append(
|
||||
{
|
||||
"local_if": str(h.local_port or "").strip(),
|
||||
"remote_sys": str(h.remote_name or "").strip(),
|
||||
"remote_if": str(h.remote_port or "").strip(),
|
||||
"remote_ip": str(h.remote_ip or "").strip(),
|
||||
"protocol": str(h.protocol or "lldp").strip() or "lldp",
|
||||
}
|
||||
)
|
||||
return rows
|
||||
Loading…
Add table
Add a link
Reference in a new issue