diff options
author | Daniil Baturin <daniil@vyos.io> | 2020-10-18 21:52:06 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-18 21:52:06 +0700 |
commit | 8ae0935d6b8a72ffe356a03f24387563ce8ae21f (patch) | |
tree | 8710c78914b4637ac92047152d3c4815e32e3522 /src/op_mode | |
parent | 6bd976a0ac33a21cc09fdd377b888e6a6eab178e (diff) | |
parent | b39d623170377b2e99fd7e88b627afea71e4d00c (diff) | |
download | vyos-1x-8ae0935d6b8a72ffe356a03f24387563ce8ae21f.tar.gz vyos-1x-8ae0935d6b8a72ffe356a03f24387563ce8ae21f.zip |
Merge pull request #577 from bmhughes/fix-show-lldp-neighbors
op-mode: lldp: T2993: Fix 'show lldp neighbors'
Diffstat (limited to 'src/op_mode')
-rwxr-xr-x | src/op_mode/lldp_op.py | 58 |
1 files changed, 28 insertions, 30 deletions
diff --git a/src/op_mode/lldp_op.py b/src/op_mode/lldp_op.py index 06958c605..5f86ad7a5 100755 --- a/src/op_mode/lldp_op.py +++ b/src/op_mode/lldp_op.py @@ -47,32 +47,31 @@ def get_neighbors(): def parse_data(data): output = [] - for tmp in data: - for local_if, values in tmp.items(): - for chassis, c_value in values.get('chassis', {}).items(): - capabilities = c_value['capability'] - if isinstance(capabilities, dict): - capabilities = [capabilities] - - cap = '' - for capability in capabilities: - if capability['enabled']: - if capability['type'] == 'Router': - cap += 'R' - if capability['type'] == 'Bridge': - cap += 'B' - if capability['type'] == 'Wlan': - cap += 'W' - if capability['type'] == 'Station': - cap += 'S' - if capability['type'] == 'Repeater': - cap += 'r' - if capability['type'] == 'Telephone': - cap += 'T' - if capability['type'] == 'Docsis': - cap += 'D' - if capability['type'] == 'Other': - cap += 'O' + for local_if, values in data.items(): + for chassis, c_value in values.get('chassis', {}).items(): + capabilities = c_value['capability'] + if isinstance(capabilities, dict): + capabilities = [capabilities] + + cap = '' + for capability in capabilities: + if capability['enabled']: + if capability['type'] == 'Router': + cap += 'R' + if capability['type'] == 'Bridge': + cap += 'B' + if capability['type'] == 'Wlan': + cap += 'W' + if capability['type'] == 'Station': + cap += 'S' + if capability['type'] == 'Repeater': + cap += 'r' + if capability['type'] == 'Telephone': + cap += 'T' + if capability['type'] == 'Docsis': + cap += 'D' + if capability['type'] == 'Other': + cap += 'O' remote_if = 'Unknown' @@ -109,10 +108,9 @@ if __name__ == '__main__': if args.all: neighbors = tmp['lldp']['interface'] elif args.interface: - neighbors = [] - for neighbor in tmp['lldp']['interface']: - if args.interface in neighbor: - neighbors.append(neighbor) + neighbors = dict() + if args.interface in tmp['lldp']['interface']: + neighbors[args.interface] = tmp['lldp']['interface'][args.interface] else: parser.print_help() |