mirror of
https://github.com/hansjone/netx.git
synced 2026-10-14 10:36:00 +08:00
Harden ZTE biz-state parsers and default | one-line collect CLIs.
Append secondary IPs with M/S tags, skip ND6 clock banners, split optical power vs thresholds including QSFP lanes, broaden static-route egress ifnames, and add | one-line to ZTE collect templates except interface detail. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
d900aca633
commit
ac4f115ee8
13 changed files with 373 additions and 109 deletions
|
|
@ -10,10 +10,23 @@ _ND6_ROW_RE = re.compile(
|
|||
r"(?P<iface>\S+)\s+(?P<type>\S+)\s*$",
|
||||
re.I,
|
||||
)
|
||||
# CLI banner / wall-clock line (e.g. "14:06:53 Beijing Sun Sep 20 2026")
|
||||
_CLOCK_LINE_RE = re.compile(r"^\d{1,2}:\d{2}:\d{2}\b")
|
||||
_TIME_OF_DAY_RE = re.compile(r"^\d{1,2}:\d{2}:\d{2}$")
|
||||
|
||||
RULE_KEYS: tuple[str, ...] = ()
|
||||
|
||||
|
||||
def _looks_like_ipv6(addr: str) -> bool:
|
||||
a = str(addr or "").strip()
|
||||
if not a or ":" not in a:
|
||||
return False
|
||||
# HH:MM:SS is not an IPv6 address
|
||||
if _TIME_OF_DAY_RE.match(a):
|
||||
return False
|
||||
return bool(re.search(r"[0-9a-fA-F]", a))
|
||||
|
||||
|
||||
def normalize_nd6_cache(
|
||||
*,
|
||||
raw_text: str,
|
||||
|
|
@ -30,6 +43,8 @@ def normalize_nd6_cache(
|
|||
line = raw.strip()
|
||||
if not line:
|
||||
continue
|
||||
if _CLOCK_LINE_RE.match(line):
|
||||
continue
|
||||
low = line.lower()
|
||||
if low.startswith("s-static") or low.startswith("total cache") or low.startswith("only current"):
|
||||
continue
|
||||
|
|
@ -39,6 +54,8 @@ def normalize_nd6_cache(
|
|||
if not m:
|
||||
continue
|
||||
addr = m.group("addr")
|
||||
if not _looks_like_ipv6(addr):
|
||||
continue
|
||||
iface = m.group("iface")
|
||||
key = (addr, iface)
|
||||
if key in seen:
|
||||
|
|
@ -56,4 +73,5 @@ def normalize_nd6_cache(
|
|||
)
|
||||
return out
|
||||
|
||||
|
||||
normalize_nd6_cache.RULE_KEYS = RULE_KEYS
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue