Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fixing get_interfaces() to support interfaces without line pro… #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

humbertogaliza
Copy link
Collaborator

This PR is to adjust logic to support interfaces without "Line Protocol" in the "display interfaces" output, for example, Virtual-Ethernet interfaces configured in layer-2 mode.
Example:

Subtask: napalm_get (failed)

---- napalm_get ** changed : False --------------------------------------------- ERROR
Traceback (most recent call last):
  File "/Users/hgaliza/Library/Caches/pypoetry/virtualenvs/remessa-FeQPNv6p-py3.11/lib/python3.11/site-packages/nornir/core/task.py", line 99, in start
    r = self.task(self, **self.params)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hgaliza/Library/Caches/pypoetry/virtualenvs/remessa-FeQPNv6p-py3.11/lib/python3.11/site-packages/nornir_napalm/plugins/tasks/napalm_get.py", line 44, in napalm_get
    result[g] = method(**options)
                ^^^^^^^^^^^^^^^^^
  File "/Users/hgaliza/workspace/napalm-huawei-vrp/napalm_huawei_vrp/huawei_vrp.py", line 623, in get_interfaces
    raise ValueError(msg)
ValueError: Unexpected interface format: Virtual-Ethernet0/0/1 current state : UP
Description:
Route Port,The Maximum Transmit Unit is 1500
Internet protocol processing : disabled
IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is c4e2-8720-b160
Current system time: 2024-06-15 07:51:39-03:00
    Input bandwidth utilization  :    0%
    Output bandwidth utilization :    0%

Interface configuration, for reference:

dis cur int Virtual-Ethernet 0/0/1
#
interface Virtual-Ethernet0/0/1
 ve-group 1 l2-terminate
#

After this fix:

---- napalm_get ** changed : False --------------------------------------------- INFO
{ 'get_interfaces': { 'Virtual-Ethernet0/0/1': { 'description': '',
                                                 'is_enabled': True,
                                                 'is_up': False,
                                                 'last_flapped': -1.0,
                                                 'mac_address': 'C4:E2:87:20:B1:60',
                                                 'mtu': 1500,
                                                 'speed': -1.0},
(...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant