diff options
Diffstat (limited to 'src/op_mode')
-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() |