Add IOS-XR interface naming support to cisco-parse.py
- Add TenGigE, HundredGigE, FortyGigE, GigE, Bundle-Ether to the short-name expansion map - Add cross-platform matching fallback: when remPortId expands to an IOS-XE name but the target is IOS-XR (or vice versa), try the alternate naming convention - Handles NCS 5500 where ifDescr uses TenGigE0/0/0/5 format vs IOS-XE TenGigabitEthernet1/1/3 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
c64a80810f
commit
71eba349b8
@ -27,19 +27,29 @@ from pathlib import Path
|
|||||||
# ────────────────────────────────────────────────────────────────────────
|
# ────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
CISCO_SHORT_TO_LONG = {
|
CISCO_SHORT_TO_LONG = {
|
||||||
|
# IOS-XE naming
|
||||||
"Te": "TenGigabitEthernet",
|
"Te": "TenGigabitEthernet",
|
||||||
"Gi": "GigabitEthernet",
|
"Gi": "GigabitEthernet",
|
||||||
"Fa": "FastEthernet",
|
"Fa": "FastEthernet",
|
||||||
"Hu": "HundredGigE",
|
|
||||||
"Tw": "TwentyFiveGigE",
|
|
||||||
"Fo": "FortyGigabitEthernet",
|
"Fo": "FortyGigabitEthernet",
|
||||||
|
"Tw": "TwentyFiveGigE",
|
||||||
|
"Twe": "TwentyFiveGigE",
|
||||||
"Eth": "Ethernet",
|
"Eth": "Ethernet",
|
||||||
|
"Po": "Port-channel",
|
||||||
|
"Vl": "Vlan",
|
||||||
|
# IOS-XR naming (NCS 5500, ASR 9000, etc.)
|
||||||
|
"TenGigE": "TenGigE",
|
||||||
|
"HundredGigE": "HundredGigE",
|
||||||
|
"TwentyFiveGigE": "TwentyFiveGigE",
|
||||||
|
"FortyGigE": "FortyGigE",
|
||||||
|
"GigE": "GigE", # rare but exists on some XR platforms
|
||||||
|
"Bundle-Ether": "Bundle-Ether",
|
||||||
|
"BE": "Bundle-Ether",
|
||||||
|
# Common to both
|
||||||
|
"Hu": "HundredGigE",
|
||||||
"BDI": "BDI",
|
"BDI": "BDI",
|
||||||
"BVI": "BVI",
|
"BVI": "BVI",
|
||||||
"Lo": "Loopback",
|
"Lo": "Loopback",
|
||||||
"Vl": "Vlan",
|
|
||||||
"Po": "Port-channel",
|
|
||||||
"Twe": "TwentyFiveGigE",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Reverse map: long -> short (built from the canonical mapping)
|
# Reverse map: long -> short (built from the canonical mapping)
|
||||||
@ -308,6 +318,29 @@ def match_rem_port_id(interfaces, rem_port_id):
|
|||||||
_dbg(f"Matched remPortId '{rem_port_id}' via ifDescr direct -> ifIndex {ifindex}")
|
_dbg(f"Matched remPortId '{rem_port_id}' via ifDescr direct -> ifIndex {ifindex}")
|
||||||
return ifindex
|
return ifindex
|
||||||
|
|
||||||
|
# 4. Cross-platform fallback: IOS-XE short name on IOS-XR device or vice versa
|
||||||
|
# e.g., remPortId "Te0/0/0/5" expands to "TenGigabitEthernet0/0/0/5" (IOS-XE)
|
||||||
|
# but the NCS ifDescr is "TenGigE0/0/0/5" (IOS-XR)
|
||||||
|
# Try alternate expansions by extracting the slot/port suffix and matching
|
||||||
|
xr_xe_pairs = {
|
||||||
|
"TenGigabitEthernet": "TenGigE",
|
||||||
|
"TenGigE": "TenGigabitEthernet",
|
||||||
|
"GigabitEthernet": "GigE",
|
||||||
|
"GigE": "GigabitEthernet",
|
||||||
|
"FortyGigabitEthernet": "FortyGigE",
|
||||||
|
"FortyGigE": "FortyGigabitEthernet",
|
||||||
|
"Port-channel": "Bundle-Ether",
|
||||||
|
"Bundle-Ether": "Port-channel",
|
||||||
|
}
|
||||||
|
if expanded != rem_port_id:
|
||||||
|
for xe_name, xr_name in xr_xe_pairs.items():
|
||||||
|
if expanded.startswith(xe_name):
|
||||||
|
alt = xr_name + expanded[len(xe_name):]
|
||||||
|
for ifindex, info in interfaces.items():
|
||||||
|
if info.get("ifDescr", "") == alt:
|
||||||
|
_dbg(f"Matched remPortId '{rem_port_id}' via cross-platform '{alt}' -> ifIndex {ifindex}")
|
||||||
|
return ifindex
|
||||||
|
|
||||||
_dbg(f"WARNING: Could not match remPortId '{rem_port_id}' to any interface")
|
_dbg(f"WARNING: Could not match remPortId '{rem_port_id}' to any interface")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user