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
Resolving problems found in review:
* Wrapping lldpcli inside op_mode/lldp.py for plain detail view, retaining
  existing raw detail-mode
* details => detail for non-specific view
  • Loading branch information
talmakion committed Jun 6, 2024
1 parent 97a767c commit 2e5f033
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
6 changes: 3 additions & 3 deletions op-mode-definitions/lldp.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
</properties>
<command>${vyos_op_scripts_dir}/lldp.py show_neighbors</command>
<children>
<node name="details">
<node name="detail">
<properties>
<help>Show extended detail for LLDP neighbors</help>
</properties>
<command>/usr/sbin/lldpcli show neighbors detail</command>
<command>${vyos_op_scripts_dir}/lldp.py show_neighbors --detail</command>
</node>
<tagNode name="interface">
<properties>
Expand All @@ -35,7 +35,7 @@
<script>${vyos_completion_dir}/list_interfaces</script>
</completionHelp>
</properties>
<command>/usr/sbin/lldpcli show neighbors ports $5 detail</command>
<command>${vyos_op_scripts_dir}/lldp.py show_neighbors --interface $5 --detail</command>
</node>
</children>
</tagNode>
Expand Down
16 changes: 11 additions & 5 deletions src/op_mode/lldp.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,17 @@ def _get_formatted_output(raw_data):

@_verify
def show_neighbors(raw: bool, interface: typing.Optional[str], detail: typing.Optional[bool]):
lldp_data = _get_raw_data(interface=interface, detail=detail)
if raw:
return lldp_data
else:
return _get_formatted_output(lldp_data)
if raw or not detail:
lldp_data = _get_raw_data(interface=interface, detail=detail)
if raw:
return lldp_data
else:
return _get_formatted_output(lldp_data)
else: # non-raw, detail
tmp = 'lldpcli -f text show neighbors details'
if interface:
tmp += f' ports {interface}'
return cmd(tmp)

if __name__ == "__main__":
try:
Expand Down

0 comments on commit 2e5f033

Please sign in to comment.