summaryrefslogtreecommitdiff
path: root/src/op_mode
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2024-06-13 16:39:19 +0200
committerGitHub <noreply@github.com>2024-06-13 16:39:19 +0200
commitc4269a9ddb0342dee78175f557e331df518d55d3 (patch)
tree15daba4570dda9162a455d193c3122546397739b /src/op_mode
parent31f8e5ec6a75c7b385d14595c43a2ee46275c00f (diff)
parent83a51a045de5db99014f6886f5aca9b792200928 (diff)
downloadvyos-1x-c4269a9ddb0342dee78175f557e331df518d55d3.tar.gz
vyos-1x-c4269a9ddb0342dee78175f557e331df518d55d3.zip
Merge pull request #3590 from talmakion/feature/T6045
T6045: Recreate show lldp detail views & improve remote port selection
Diffstat (limited to 'src/op_mode')
-rwxr-xr-xsrc/op_mode/lldp.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/op_mode/lldp.py b/src/op_mode/lldp.py
index 58cfce443..fac622b81 100755
--- a/src/op_mode/lldp.py
+++ b/src/op_mode/lldp.py
@@ -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:
@@ -136,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: