mirror of
https://github.com/hansjone/netx.git
synced 2026-10-09 05:30:46 +08:00
Rename interface_detail admin field to port_status.
Header is/up/down is operational port state, not brief-style Admin. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
b6eab3ed8f
commit
5ab08bb9b3
4 changed files with 9 additions and 9 deletions
|
|
@ -36,7 +36,7 @@ _UTIL_RE = re.compile(
|
|||
def _empty_row(iface: str) -> dict[str, Any]:
|
||||
return {
|
||||
"interface": iface[:128],
|
||||
"admin": "",
|
||||
"port_status": "",
|
||||
"ifindex": "",
|
||||
"description": "",
|
||||
"port_media": "",
|
||||
|
|
@ -54,7 +54,7 @@ def _empty_row(iface: str) -> dict[str, Any]:
|
|||
}
|
||||
|
||||
|
||||
def _normalize_admin(state: str) -> str:
|
||||
def _normalize_port_status(state: str) -> str:
|
||||
s = str(state or "").strip().lower()
|
||||
# Guard against FSM greedily eating ", ifindex:"
|
||||
if "," in s:
|
||||
|
|
@ -78,11 +78,11 @@ def _map_fsm_rows(rows: list[dict[str, Any]]) -> list[dict[str, Any]]:
|
|||
if not iface or not in_util or iface in seen:
|
||||
continue
|
||||
seen.add(iface)
|
||||
admin_raw = row_get(r, "ADMIN_STATE", "ADMIN_OPER", "admin")
|
||||
status_raw = row_get(r, "ADMIN_STATE", "ADMIN_OPER", "port_status", "admin")
|
||||
out.append(
|
||||
{
|
||||
"interface": iface[:128],
|
||||
"admin": _normalize_admin(admin_raw)[:32],
|
||||
"port_status": _normalize_port_status(status_raw)[:32],
|
||||
"ifindex": row_get(r, "IFINDEX", "ifindex")[:32],
|
||||
"description": row_get(r, "DESCRIPTION", "description")[:256],
|
||||
"port_media": row_get(r, "PORT_MEDIA", "port_media")[:32],
|
||||
|
|
@ -122,7 +122,7 @@ def _hand_parse(*, raw_text: str, **_kw: Any) -> list[dict[str, Any]]:
|
|||
if m:
|
||||
_flush()
|
||||
cur = _empty_row(m.group("iface"))
|
||||
cur["admin"] = _normalize_admin(m.group("state"))
|
||||
cur["port_status"] = _normalize_port_status(m.group("state"))
|
||||
cur["ifindex"] = (m.group("ifindex") or "")[:32]
|
||||
in_rates = False
|
||||
saw_input = False
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ _IFACE_BRIEF_FIELDS: list[FieldDef] = [
|
|||
|
||||
_IFACE_DETAIL_FIELDS: list[FieldDef] = [
|
||||
FieldDef("interface", length=128, indexed=True, is_key=True, is_interface=True, display_name="接口"),
|
||||
FieldDef("admin", length=32, role="state", display_name="Admin"),
|
||||
FieldDef("port_status", length=32, role="state", display_name="Port Status"),
|
||||
# Rates churn between collects — display only, never default-compare.
|
||||
FieldDef("input_bps", length=32, role="counter", display_name="Input bps"),
|
||||
FieldDef("output_bps", length=32, role="counter", display_name="Output bps"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue