Remove fake VRF Route Summary collect item.

Drop the route-summary profiles/parser/persist path; keep VRF list discover for bindings and strip it from default cutover templates.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-09-20 09:58:26 +08:00
parent 1642a0adec
commit a769e603b7
10 changed files with 18 additions and 320 deletions

View file

@ -41,7 +41,6 @@ from ...ntc_parse import apply_rules, resolve_cli_platform, rules_for_command
from .cisco import PARSERS as _CISCO_PARSERS
from .common.lldp_neighbors import normalize_lldp_neighbors
from .common.vrf_list import normalize_vrf_list
from .common.vrf_route_summary import normalize_vrf_route_summary
from .ericsson import PARSERS as _ERICSSON_PARSERS
from .h3c import PARSERS as _H3C_PARSERS
from .huawei import PARSERS as _HUAWEI_PARSERS
@ -64,7 +63,6 @@ _VENDOR_PARSERS: list[dict[str, NormalizeFn]] = [
_REGISTRY: dict[str, NormalizeFn] = {
"lldp_neighbors": normalize_lldp_neighbors,
"vrf_list": normalize_vrf_list,
"vrf_route_summary": normalize_vrf_route_summary,
}
for _pack in _VENDOR_PARSERS:
_REGISTRY.update(_pack)

View file

@ -1,60 +0,0 @@
"""Per-VRF route summary counts (multi-vendor line scrape)."""
from __future__ import annotations
import re
from typing import Any
_SOURCE_PATTERNS: list[tuple[str, re.Pattern[str]]] = [
("connected", re.compile(r"(?i)^\s*connected\s+(\d+)\s*$")),
("static", re.compile(r"(?i)^\s*static\s+(\d+)\s*$")),
("local", re.compile(r"(?i)^\s*local\s+(\d+)\s*$")),
("ospf", re.compile(r"(?i)^\s*ospf(?:\s+\S+)?\s+(\d+)\s*$")),
("isis", re.compile(r"(?i)^\s*isis(?:\s+\S+)?\s+(\d+)\s*$")),
("bgp", re.compile(r"(?i)^\s*bgp(?:\s+\S+)?\s+(\d+)\s*$")),
("rip", re.compile(r"(?i)^\s*rip(?:\s+\S+)?\s+(\d+)\s*$")),
("total", re.compile(r"(?i)^\s*(?:total|totals?)\s+(?:routes?\s+)?(\d+)\s*$")),
]
RULE_KEYS: tuple[str, ...] = ()
def normalize_vrf_route_summary(
*,
raw_text: str,
fsm_tables=None,
vendor: str = "",
device_type: str = "",
command: str = "",
params: dict[str, str] | None = None,
) -> list[dict[str, Any]]:
_ = (vendor, device_type, command, fsm_tables)
vrf = str((params or {}).get("vrf") or (params or {}).get("vrf_name") or "").strip()
text = str(raw_text or "")
found: dict[str, int] = {}
for src, pat in _SOURCE_PATTERNS:
for line in text.splitlines():
m = pat.match(line.strip())
if m:
found[src] = int(m.group(1))
break
if not found:
n = 0
for line in text.splitlines():
s = line.strip()
if not s or s.startswith("-") or s.lower().startswith(("code", "codes", "gateway", "routing table")):
continue
if re.match(r"^[A-Z*+]>?\s+\S+", s) or re.match(r"^\S+\s+\d+\.\d+\.\d+\.\d+", s):
n += 1
if n:
found["routes"] = n
rows: list[dict[str, Any]] = []
for src, count in found.items():
rows.append({"vrf": vrf[:128], "source": src[:64], "networks": count})
if vrf and not rows:
rows.append({"vrf": vrf[:128], "source": "empty", "networks": 0})
return rows
normalize_vrf_route_summary.RULE_KEYS = RULE_KEYS

View file

@ -1,8 +1,7 @@
"""Compat shim — prefer ``parsers.common.vrf_list`` / ``vrf_route_summary``."""
"""Compat shim — prefer ``parsers.common.vrf_list``."""
from __future__ import annotations
from .common.vrf_list import normalize_vrf_list
from .common.vrf_route_summary import normalize_vrf_route_summary
__all__ = ["normalize_vrf_list", "normalize_vrf_route_summary"]
__all__ = ["normalize_vrf_list"]