napalm-procurve
napalm-procurve copied to clipboard
get_lldp_neighbors errors with multiline show lldp info
Some devices can return a multiline sysname, i.e.:
# show lldp info remote-device
LLDP Remote Devices Information
LocalPort | ChassisId PortId PortDescr SysName
--------- + ------------------ ------------------ --------- ------------------
7 | 00 5f 67 d0 7e 5a gigabitEthernet... gigabi...
54 4c 2d 53 47 32 32 31 30 4d 50 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00
26 | cc 4e 24 83 08 a6 cc 4e 24 83 08 bd 10Giga... ROUTER-...
This results in the following errors:
Traceback (most recent call last):
File "/Users/johan/.local/share/virtualenvs/sohonet-netbox-importer-Gj3g_iu9/lib/python3.9/site-packages/napalm_procurve/procurve.py", line 308, in get_lldp_neighbors
(
ValueError: too many values to unpack (expected 11)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/johan/.local/share/virtualenvs/sohonet-netbox-importer-Gj3g_iu9/lib/python3.9/site-packages/nornir/core/task.py", line 98, in start
r = self.task(self, **self.params)
File "/Users/johan/git/vdl/sohonet-netbox-importer/bin/../nornirrunner/tasks/inventory.py", line 31, in get_device_info
return _get_device_data(task, getters)
File "/Users/johan/git/vdl/sohonet-netbox-importer/bin/../nornirrunner/tasks/inventory.py", line 50, in _get_device_data
return napalm_get(task, getters=getters)
File "/Users/johan/.local/share/virtualenvs/sohonet-netbox-importer-Gj3g_iu9/lib/python3.9/site-packages/nornir_napalm/plugins/tasks/napalm_get.py", line 44, in napalm_get
result[g] = method(**options)
File "/Users/johan/.local/share/virtualenvs/sohonet-netbox-importer-Gj3g_iu9/lib/python3.9/site-packages/napalm_procurve/procurve.py", line 325, in get_lldp_neighbors
remote_port, device_id = self._get_lldp_neighbors_detail(local_port)
File "/Users/johan/.local/share/virtualenvs/sohonet-netbox-importer-Gj3g_iu9/lib/python3.9/site-packages/napalm_procurve/procurve.py", line 376, in _get_lldp_neighbors_detail
return (tmp_lldp_details["PortId"], tmp_lldp_details["SysName"])
KeyError: 'PortId'
Because get_lldp_neighbors is using line-by-line parsing of the output, each line of the hex values is being processed as if it were a separate entry in the table