summaryrefslogtreecommitdiff
path: root/src/op_mode/lldp_op.py
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2020-10-18 21:52:06 +0700
committerGitHub <noreply@github.com>2020-10-18 21:52:06 +0700
commit8ae0935d6b8a72ffe356a03f24387563ce8ae21f (patch)
tree8710c78914b4637ac92047152d3c4815e32e3522 /src/op_mode/lldp_op.py
parent6bd976a0ac33a21cc09fdd377b888e6a6eab178e (diff)
parentb39d623170377b2e99fd7e88b627afea71e4d00c (diff)
downloadvyos-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/lldp_op.py')
-rwxr-xr-xsrc/op_mode/lldp_op.py58
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()