From 5293a9d048b0187ad8c0819097edddc25c492519 Mon Sep 17 00:00:00 2001 From: "Benjamin M. Hughes" Date: Sun, 18 Oct 2020 16:20:37 +0100 Subject: 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. --- src/op_mode/lldp_op.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/op_mode') 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() -- cgit v1.2.3