Skip to content

Commit

Permalink
T6045: Recreate show lldp detail views & improve remote port selection
Browse files Browse the repository at this point in the history
If the remote device has explicitly sent the interface name as the portID,
we should use that first as the interface name, before working through
the previous priority order.

I've brought back LLDP detail views directly calling lldpcli. This can be
extended to render a template from op_mode/lldp.py, but lldpcli isn't bad
at rendering readable info. Raw mode (including detailed raw) is still
accessible for programmatic access.
  • Loading branch information
talmakion committed Jun 6, 2024
1 parent f6752de commit 97a767c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
17 changes: 17 additions & 0 deletions op-mode-definitions/lldp.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
</properties>
<command>${vyos_op_scripts_dir}/lldp.py show_neighbors</command>
<children>
<node name="details">
<properties>
<help>Show extended detail for LLDP neighbors</help>
</properties>
<command>/usr/sbin/lldpcli show neighbors detail</command>
</node>
<tagNode name="interface">
<properties>
<help>Show LLDP for specified interface</help>
Expand All @@ -21,6 +27,17 @@
</completionHelp>
</properties>
<command>${vyos_op_scripts_dir}/lldp.py show_neighbors --interface $5</command>
<children>
<node name="detail">
<properties>
<help>Show detailed LLDP for specified interface</help>
<completionHelp>
<script>${vyos_completion_dir}/list_interfaces</script>
</completionHelp>
</properties>
<command>/usr/sbin/lldpcli show neighbors ports $5 detail</command>
</node>
</children>
</tagNode>
</children>
</node>
Expand Down
7 changes: 6 additions & 1 deletion src/op_mode/lldp.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,12 @@ def _get_formatted_output(raw_data):
tmp.append('')

# Remote interface
interface = jmespath.search('port.descr', values)
interface = None
if jmespath.search('port.id.type', values) == 'ifname':
# Remote peer has explicitly returned the interface name as the PortID
interface = jmespath.search('port.id.value', values)
if not interface:
interface = jmespath.search('port.descr', values)
if not interface:
interface = jmespath.search('port.id.value', values)
if not interface:
Expand Down

0 comments on commit 97a767c

Please sign in to comment.