napalm-huawei-vrp
napalm-huawei-vrp copied to clipboard
chore: fixing get_interfaces() to support interfaces without line pro…
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},
(...)