diff options
author | Benjamin M. Hughes <bmhughes@bmhughes.co.uk> | 2020-10-18 16:20:37 +0100 |
---|---|---|
committer | Benjamin M. Hughes <bmhughes@bmhughes.co.uk> | 2020-10-18 16:22:26 +0100 |
commit | 5293a9d048b0187ad8c0819097edddc25c492519 (patch) | |
tree | 0b977c18b744a815e21648c4487169f77de58f8c | |
parent | 8ae0935d6b8a72ffe356a03f24387563ce8ae21f (diff) | |
download | vyos-1x-5293a9d048b0187ad8c0819097edddc25c492519.tar.gz vyos-1x-5293a9d048b0187ad8c0819097edddc25c492519.zip |
op-mode: lldp: T2993: Fixup 'show lldp neighbors'
Check that interfaces have been returned from lldpcli to prevent trace when
no interfaces are enabled for lldp.
-rwxr-xr-x | src/op_mode/lldp_op.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/op_mode/lldp_op.py b/src/op_mode/lldp_op.py index 5f86ad7a5..172ce71b7 100755 --- a/src/op_mode/lldp_op.py +++ b/src/op_mode/lldp_op.py @@ -104,13 +104,14 @@ if __name__ == '__main__': exit(0) elif args.all or args.interface: tmp = json.loads(get_neighbors()) - - if args.all: - neighbors = tmp['lldp']['interface'] - elif args.interface: - neighbors = dict() - if args.interface in tmp['lldp']['interface']: - neighbors[args.interface] = tmp['lldp']['interface'][args.interface] + neighbors = dict() + + if 'interface' in tmp.get('lldp'): + if args.all: + neighbors = tmp['lldp']['interface'] + elif args.interface: + if args.interface in tmp['lldp']['interface']: + neighbors[args.interface] = tmp['lldp']['interface'][args.interface] else: parser.print_help() |