networktocode/netutils

The canonical_interface_name method returns unusable interface name for Cisco IOS XR

vkrasnici opened this issue · 2 comments

Environment

  • Python version: 3.11.0
  • netutils version: 1.4.0

Expected Behavior

When trying to convert an interface like HundredGigE0/0/1/1 it should return HundredGigE0/0/1/1.

Python 3.11.0 (main, Nov 15 2022, 05:43:36) [Clang 14.0.0 (clang-1400.0.29.202)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from netutils.interface import canonical_interface_name
>>>
>>> canonical_interface_name("HundredGigE0/0/1/1")
'HundredGigE0/0/1/1'
>>>

Observed Behavior

The canonical_interface_name method returns the HundredGigabitEthernet0/0/1/1 for the given HundredGigE0/0/1/1 string as a parameter.

Steps to Reproduce

  1. Open python repl in an environment where netutils library is installed
  2. Import the canonical_interface_name method from netutils.interface
  3. Call the canonincal_interface_name method and pass HundredGigE0/0/1/1 string as a parameter
  4. You will get HundredGigabitEthernet0/0/1/1 as output.
Python 3.11.0 (main, Nov 15 2022, 05:43:36) [Clang 14.0.0 (clang-1400.0.29.202)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from netutils.interface import canonical_interface_name
>>>
>>> canonical_interface_name("HundredGigE0/0/1/1")
'HundredGigabitEthernet0/0/1/1'
>>>

Note:
Whilst the HundredGigabitEthernet0/0/1/1 looks ok to me, it is unusable on the actual router configuration as it is not recognized by IOS XR:

RP/0/RP0/CPU0:rtr-1#show interfaces HundredGigabitEthernet0/0/1/1
                                                      ^
% Invalid input detected at '^' marker.
RP/0/RP0/CPU0:rtr-1#

whereas HundredGigE0/0/1/1 is valid:

RP/0/RP0/CPU0:rtr-1#show interfaces HundredGigE 0/0/1/1
Tue Jan 17 07:52:20.501 UTC
HundredGigE0/0/1/1 is up, line protocol is up 
  Interface state transitions: 7
.... Output omitted ....

Happy also to update the mappings and submit a PR for this.

50/50 on this one, there is not much we can do if ios disagrees with iosxr as an example.

If we can show that no OS uses the full name may make sense to change, otherwise the addl_name_map parameter was created for this exact use case

@itdependsnetworks good point, that's how I'm handling another case. I won't be able to prove that no other OS uses the full name therefore I think we can close this issue since there's a workaround to overcome the actual problem.
Thank you for your swift support!